This file contains unidiffs between from version 1.08.1 to version 1.09 of the GNU C library. Changes in files produced by etags and TeX have been omitted. You will need GNU patch to apply these diffs; you must use `patch -E' to ensure that no empty files are left behind. diff -ruN glibc-1.08.1/ChangeLog glibc-1.09/ChangeLog --- glibc-1.08.1/ChangeLog Sun Jun 5 22:04:40 1994 +++ glibc-1.09/ChangeLog Sun Nov 6 19:26:33 1994 @@ -1,3 +1,1859 @@ +Sun Nov 6 19:26:28 1994 Roland McGrath + + * Version 1.09. + +Fri Nov 4 16:52:05 1994 Roland McGrath + + * Version 1.08.14. + + * manual/Makefile (stamp-summary): Depend on $(chapters-incl) too. + +Thu Nov 3 18:33:50 1994 Roland McGrath + + * sysdeps/generic/sigset.h (__sigemptyset): Cast to __sigset_t. + (__sigfillset): Likewise. Use ~(__sigset_t)0 in place of -1. + (__SIGSETFN): Don't try to be clever. Test bounds of SIG with < and >. + + * sysdeps/mach/hurd/__fork.c: Unlock signal state earlier, just + after unlocking _hurd_ports locks. + + * sysdeps/unix/bsd/osf1/direct.h: File removed. + * sysdeps/unix/bsd/direct.h (struct direct): Use `unsigned int' + instead of `unsigned long int' for `d_fileno' member. + + * Makerules (common-mostlyclean): Remove $(tests:=.out) too. + + * assert/assert-perr.c (__assert_perror_fail): Add missing comma. + + * sysdeps/unix/ioctls-tmpl.c [__osf__ && __alpha__] (FIOPIPESTAT, + SIOCSRREQR, SIOCSRREQW, SRVC_REQUEST): #undef these. + +Wed Nov 2 23:00:19 1994 Roland McGrath + + * sysdeps/mach/hurd/setegid.c: Pass poly and count args for + other_handles in correct order in call to auth_makeauth. + * sysdeps/mach/hurd/__setregid.c: Likewise. + * sysdeps/mach/hurd/__setreuid.c: Likewise. + + * Makerules (compile.S): Add -DASSEMBLER. + * sysdeps/mach/sysdep.h [ASSEMBLER]: Don't include + if this is defined. + +Wed Nov 2 22:39:55 1994 Michael I Bushnell + + * sysdeps/mach/hurd/seteuid.c: Pass poly and count args for + other_handles in correct order in call to auth_makeauth. + +Wed Nov 2 15:03:51 1994 Roland McGrath + + * stdio/internals.c (fillbuf): Make sure returned char doesn't get + sign extended. + +Tue Nov 1 01:25:28 1994 Roland McGrath + + * sysdeps/unix/common/Implies: File removed. + * sysdeps/unix/bsd/Implies: Add unix/inet. + + * assert/assert-perror.c: Renamed to assert-perr.c. + * assert/Makefile (routines): Rename assert-perror to assert-perr. + + * Version 1.08.13. + + * mach/Makefile (generated): Add __%.c for $(mach-shortcuts) too. + + * dirent/Makefile (tests): Add tst-seekdir. + * dirent/tst-seekdir.c (main): New file. + * sysdeps/unix/bsd/seekdir.c: New file. + * sysdeps/unix/bsd/telldir.c: New file. + * sysdeps/unix/bsd/dirstream.h (DIR): New member `__pos'. + * sysdeps/unix/bsd/readdir.c: Update DIRP->__pos in getdirentries + call. + * sysdeps/unix/opendir.c: Use calloc in place of malloc, to zero + fill new DIRs. + + * sysdeps/standalone/i386/force_cpu386/force_cpu386.ld: Renamed to + target.ld. + * sysdeps/standalone/i386/force_cpu386/Makefile: Install it from + that name (still into $(libdir)/force_cpu386.ld). + + * mach/Makefile (headers, user-interfaces, server-interfaces): + Don't add default_pager stuff. + +Mon Oct 31 07:00:40 1994 Roland McGrath + + * sysdeps/unix/bsd/sun/sunos4/termbits.h (TCSASOFT): Macro + removed. + + * malloc/malloc.h: Change #ifdef __STDC__ to #if defined + (__STDC__) && __STDC__. + +Fri Oct 28 00:09:24 1994 Roland McGrath + + * sysdeps/mach/sysdep.h: Include for decls. + (FATAL_PREPARE): Pass arg to __mig_dealloc_reply_port. + + * assert/Makefile (routines): Add assert-perror. + + * Makerules (stubs): cd into $(objdir) and use local file names, + making the cmd shorter. + + * sysdeps/mach/hurd/getprio.c (getonepriority): Call + proc_getprocinfo with proc port. + + * sysdeps/mach/hurd/errnos.awk: Grok "@comment errno %d" in + errno.texi, instead of assigning sequentially. + * sysdeps/mach/hurd/errlist.awk: Likewise. + + * stdio/fwrite.c: Reset BUFFER_SPACE after fflush in fill_buffer + case. + + * sysdeps/generic/sigset.h (__SIGSETFN): When losing, punt to + `raise (-1)'. Old method looped. + + * hurd/hurd/resource.h: Include . + +Thu Oct 27 15:00:50 1994 Roland McGrath + + * sysdeps/standalone/standalone.h: Fixed typo. + +Wed Oct 26 00:21:16 1994 Roland McGrath + + * sysdeps/unix/i386/vfork.S: New file. + + * sysdeps/generic/strchr.c: Increment CP properly in check for 5th + char of quadword hit. + + * sysdeps/mach/hurd/getprio.c (getonepriority): Always set ONERR. + +Tue Oct 25 03:53:26 1994 Roland McGrath + + * hurd/hurd/resource.h: Include . + + * stdio/ftell.c: If STREAM->__pushed_back, calculate from + pushback_bufp instead of bufp. + + * Makefile (format-me): New canned sequence; runs makeinfo + --no-headers. + (INSTALL): Use it. + (NOTES): New file rule. + + * manual/intro.texi (Feature Test Macros): Node moved off to + creature.texi. + * manual/creature.texi: New file, broken out of intro.texi. + + * manual/Makefile (indices): New variable; include ky. + (realclean): Use $(indices) to remove all index and sorted index files. + + * sysdeps/mach/hurd/fcntlbits.h (O_ASYNC, O_FSYNC, O_SYNC): + Protect with [__USE_BSD]. + +Mon Oct 24 00:16:59 1994 Roland McGrath + + * sysdeps/unix/bsd/utime.c: Initialize tv_usec fields. + Use __gettimeofday instead of time. + + * sunrpc/pmap_rmt.c: Include before . + Undef _POSIX_SOURCE before that. + * sunrpc/pm_getport.c: Likewise. + * sunrpc/pm_getmaps.c: Likewise. + * sunrpc/get_myaddr.c: Likewise. + + * misc/sys/cdefs.h: Undef __P first. + + * Version 1.08.12. + + * sysdeps/mach/hurd/getprio.c: Rewritten. + * sysdeps/mach/hurd/setprio.c: New file. + * hurd/hurdprio.c: New file. + * hurd/Makefile (routines): Add hurdprio. + * hurd/hurd/resource.h (_hurd_priority_which_map): Declare it. + (NICE_TO_MACH_PRIORITY, MACH_PRIORITY_TO_NICE): New macros. + +Sun Oct 23 19:39:18 1994 Roland McGrath + + * Makerules (sources): Fix typo in last change. + +Fri Oct 21 13:15:39 1994 Roland McGrath + + * sysdeps/generic/termbits.h (ECHOKE): Remove gratuitous leading + space before #define. + + * Makerules (sources): Filter out $(elided-routines). + + * sysdeps/sparc/divrem.m4 (entry point): For OP=rem, set SIGN from + dividend only, ignoring divisor. + (Lgot_result): Test SIGN here for OP=rem too (as originally). + +Wed Oct 19 02:40:02 1994 Roland McGrath + + * hurd/hurdsig.c: Use assert_perror. + + * assert/assert-perror.c (__assert_perror_fail): New file. + * assert/assert.h (assert_perror): New macro. + + * Version 1.08.11. + + * hurd/hurdsig.c (abort_rpcs): Actually return a port instead of + boolean, as the type says. + + * hurd/hurdsig.c (abort_all_rpcs): If waiting for reply from + interrupted RPC returns error, print debugging msg with error + test, don't assert. + +Mon Oct 17 00:06:03 1994 Roland McGrath + + * stdlib/strtol.c: Deansideclized. + * sysdeps/generic/strcspn.c: Deansideclized. + * sysdeps/generic/putenv.c: Deansideclized, added portability + cruft. + +Fri Oct 14 14:00:11 1994 Roland McGrath + + * sysdeps/unix/sysv/sysv4/solaris2/utsnamelen.h: + Moved to sysdeps/unix/sysv/sysv4. + +Thu Oct 13 22:06:50 1994 Roland McGrath + + * sysdeps/unix/common/glue-ctype.c [HAVE__LOCP]: Move this defn to + first. Include sys/types.h. + + * sysdeps/unix/bsd/readdir.c: Include direct.h. + + * socket/sys/socket.h (__SOCKADDR_ARG): Always use non-GCC defn, + for now. + * posix/sys/wait.h (__WAIT_STATUS): Likewise. + +Tue Oct 11 00:42:50 1994 Roland McGrath + + * Version 1.08.10. + +Mon Oct 10 00:33:47 1994 Roland McGrath + + * malloc/malloc.h [_MALLOC_INTERNAL] (CHAR_BIT): Don't define if + already defined. + + * stdio/__vfscanf.c: Grok %q modifier like %ll. + + * mach/__msgserver.c: Increase default MAX_SIZE to two pages. + + * misc/init-misc.c: Cast string constant to non-const type. + + * sysdeps/i386/ffs.c: Use %1 again instead of listing TMP as an + input with constraint "1". This avoids a warning that TMP may be + used before set. + +Sun Oct 9 22:41:20 1994 Roland McGrath + + * hurd/hurdsig.c (abort_all_rpcs): Declare SS. + +Sun Oct 09 01:19:38 1994 Jim Meyering (meyering@comco.com) + + * posix/fnmatch.c: Remove CONFIG_BROKETS conditional. + +Fri Oct 7 15:28:07 1994 Roland McGrath + + * stdio/__vfscanf.c: Properly grok %a modifier. + + * hurd/hurdsig.c (abort_rpcs): Return the reply port or null, + instead of boolean. + (abort_all_rpcs): Record the returns from abort_rpcs and wait for + a message on each reply port. Don't bother locking _hurd_siglock. + +Thu Oct 6 18:57:44 1994 Roland McGrath + + * hurd/hurd.h (_hurd_socket_server): Take new arg DEAD; explain + its use in comment. + * hurd/hurdsock.c (_hurd_socket_server): Take new arg DEAD; if + nonzero, clear any old cached port and always do a fresh lookup. + * sysdeps/mach/hurd/socket.c: Pass new arg to _hurd_socket_server, + cope with dead server on socket_create. + * sysdeps/mach/hurd/__pipe.c: Likewise. + +Mon Oct 3 02:09:43 1994 Roland McGrath + + * sysdeps/generic/utsnamelen.h (_UTSNAME_LENGTH): Increase to + 1024. + +Sun Oct 2 18:35:16 1994 Roland McGrath + + * posix/glob.h (__P): Change arg name to `protos', for congruence + with 4.4 BSD. + * posix/fnmatch.h (__P): Likewise. + +Sat Oct 1 04:25:35 1994 Roland McGrath + + * misc/Makefile (routines): Add daemon. + +Fri Sep 30 16:49:09 1994 Roland McGrath + + * misc/daemon.c: New file, incorporated from BSD 4.4-Lite. + + * sysdeps/mach/hurd/__setsid.c: Call _hurd_setcttyid with + MACH_PORT_NULL after proc_setsid. + + * hurd/hurdioctl.c (_hurd_setcttyid): Don't do mod_refs if port is + null. + + Always use fds' `port' cell for the generic port. + For ctty fds, use the `ctty' cell for the ctty-special port. + * hurd/dtable.c (get_dtable_port): Use port, never ctty. + (fork_child_dtable): Reset D->ctty instead of D->port. + (ctty_new_pgrp): Likewise. + * sysdeps/mach/hurd/__ioctl.c: Use ctty port for RPC if set and + !NOCTTY. + * hurd/port2fd.c (_hurd_port2fd): Install normal port in D->port + cell, and ctty-special port in the D->ctty cell, not the reverse. + * hurd/hurdioctl.c (tiocsctty): Don't assume MACH_PORT_NULL is + zero. + * hurd/hurdexec.c (_hurd_exec): Always pass fds' normal port, + never its ctty port. + * hurd/fd-write.c (_hurd_fd_write): Use ctty port for RPC if set + and !NOCTTY. + * hurd/fd-read.c (_hurd_fd_read): Use ctty port for RPC if set. + +Thu Sep 29 18:28:01 1994 Roland McGrath + + * mach/mig_syms.c (mig_put_reply_port): Add symbol alias to __ + name. + +Thu Sep 29 12:23:07 1994 Brendan Kehoe (brendan@zen.org) + + * sysdeps/unix/sysv/sysv4/solaris2/sparc/sysdep.h (ENTRY): Use + poundfnc instead of \#function, to satisfy gcc-2.6.0 and higher. + (cat, poundfnc): Define macros to pull it off. + + * sysdeps/unix/sysv/sysd-stdio.c: Include sysdeps/generic/sysd-stdio.h, + not looking in sysdeps/posix. + +Thu Sep 29 05:38:14 1994 Roland McGrath + + * sysdeps/unix/common/configure.in (ctype check): In test prog, + just reference $ctype; we don't care what type it is. + + * sysdeps/unix/bsd/bsd4.4/direct.h: New file. + (HAVE_D_TYPE): Define this macro. + * dirent/dirent.h (struct dirent): New member `d_type'; shorten + `d_namlen' to a byte. + * sysdeps/unix/bsd/readdir.c [! HAVE_D_TYPE]: Shuffle d_namlen and + clear d_type. + +Wed Sep 28 17:23:26 1994 Roland McGrath + + * posix/sys/utsname.h [__USE_SVID] (SYS_NMLN): New macro. + + * dirent/scandir.c: Free storage on error from readdir. + +Mon Sep 26 00:55:34 1994 Roland McGrath + + * Version 1.08.9. + + * MakeTAGS (all-dist): Prepend the appropriate sysdep dir names. + + * hurd/hurdsig.c (_hurd_internal_post_signal: sigwakeup): Create a + send right. + +Sat Sep 24 13:44:51 1994 Jim Meyering (meyering@comco.com) + + * sysdeps/generic/memcmp.c [CMP_LT_OR_GT]: New macro. + (memcmp): Use it in place of each of ten 5-line #ifdef blocks. + +Fri Sep 23 16:55:54 1994 Roland McGrath + + * sysdeps/mach/hurd/sigsuspend.c: Include . + + * sysdeps/mach/hurd/sigsuspend.c: Add missing & in __mach_msg + call. + +Thu Sep 15 14:22:56 1994 Roland McGrath + + * sysdeps/standalone/i386/force_cpu386/Dist: New file. + * sysdeps/standalone/m68k/m68020/mvme136/Dist: New file. + * sysdeps/standalone/i960/Dist: New file. + * sysdeps/standalone/m68k/m68020/Dist: New file. + * sysdeps/standalone/i386/force_cpu386/force_cpu386.ld: New file. + * sysdeps/standalone/m68k/m68020/mvme136/mvme136.ld: New file. + * sysdeps/standalone/i960/i960ca.h: New file. + * sysdeps/standalone/m68k/m68020/m68020.h: New file. + + * sysdeps/unix/common/configure.in: Use AC_COMPILE_CHECK instead + of AC_HAVE_FUNCS. + + * sysdeps/generic/make_siglist.c (sys_siglist): Define as macro to + my_siglist. + + * sysdeps/mach/i386/thread_state.h: Include from mach/machine, not + mach/i386. + * sysdeps/mach/hurd/i386/sigcontext.h: Likewise. + + * mach/mach/mig_support.h (__mig_put_reply_port): Declare. + (__mig_dealloc_reply_port): Take arg. + * sysdeps/mach/hurd/mig-reply.c (__mig_put_reply_port): New + function. + (__mig_dealloc_reply_port): Take arg, ignore it. + +Wed Sep 14 18:16:07 1994 Roland McGrath + + * sysdeps/mach/hurd/Makefile (libc-name): Set to crt. + [!subdir]: Install libc-ldscript as libc.a. + * sysdeps/mach/hurd/Dist: Add libc-ldscript. + +Tue Sep 13 19:57:09 1994 Roland McGrath + + * sysdeps/mach/hurd/sync.c: Don't be synchronous: pass WAIT=0 to + file_syncfs. + + * Makerules (libc-name): New variable. + (install, libc installation rule): Use $(libc-name) in place of `c'. + +Sun Sep 11 23:28:20 1994 Roland McGrath + + * sysdeps/mach/hurd/__readlink.c: Only decrement LEN to remove the + null terminator when LEN is already large enough to include it. + + * hurd/hurdlookup.c (__hurd_file_name_lookup_retry): Add break + after FS_RETRY_MAGICAL case. + +Fri Sep 9 04:03:59 1994 Roland McGrath + + * stdio/vfprintf.c: Grok q modifier like ll. + + * Make-dist (sysdep-Subdir-files, subdirs): Set these early on, + before doing distinfo. + [parent] (+distinfo): Set inhibit_interface_rules=t in sub-make. + +Thu Sep 8 17:18:14 1994 Roland McGrath + + * sysdeps/generic/morecore.c (__default_morecore) [! __STDC__]: + Declare arg as `int' instead of `ptrdiff_t'. + +Tue Sep 6 19:06:00 1994 Roland McGrath + + * posix/glob.c (prefix_array, glob): Avoid const on initialized + variables. Some compiler generates bad code. + +Mon Sep 5 13:24:26 1994 Roland McGrath + + * malloc/Makefile (malloc/%: ../sysdeps/generic/%): New rule, to get + morecore.c. + + * malloc/malloc.h (size_t, ptrdiff_t): Never define these as macros. + (__malloc_size_t): Define this instead. + Change all uses of size_t to __malloc_size_t. + * malloc/valloc.c: Replace all uses of size_t with __malloc_size_t. + * malloc/memalign.c: Likewise. + * malloc/mcheck.c: Likewise. + * malloc/mtrace.c: Likewise. + * malloc/malloc.c: Likewise. + * malloc/free.c: Likewise. + * malloc/realloc.c: Likewise. + * malloc/calloc.c: Likewise. + + * MakeTAGS (TAGS): Define first so as to be default goal. + (sysdep_dirs): Set this by running find, if it is not already set. + (all-dirs): Include that value. + (all-dist): Filter output of cat, not args to it. + * Makerules (TAGS): Depend on distinfo, not distfile. + + * resolv/getnetnamadr.c (getnetbyname): Arg is always const, + regardless of [sun]. + +Sun Sep 4 00:04:55 1994 Roland McGrath + + * Version 1.08.8. + + * Makerules (distinfo-vars): Double $s in final emitted sources defn. + + * inet/Makefile (headers): Add netdb.h. + * resolv/Makefile (headers): Remove netdb.h. + * resolv/netdb.h: Moved to inet. + * inet/netdb.h: Incorporated from BSD 4.4-Lite. + Add back h_errno declaration. + + * hurd/Makefile (faultexc.c): Change this to a pattern rule to + build both faultexc.[ch]. + (hurdfault.o): Depend on faultexc.h and faultexc.c to get them built. + + * sysdeps/mach/hurd/i386/trampoline.c + (_hurdsig_rcv_interrupted_p): Make PC volatile. + (_hurd_setup_sighandler): Cast SS->context to int before comparing to + _hurdsig_fault_sigcode. + + * sysdeps/mach/thread_state.h (MACHINE_THREAD_STATE_SET_{SP,PC}): + Cast args to unsigned long int. + + * sysdeps/mach/hurd/i386/trampoline.c: Use _hurdsig_catch_fault. + + * Make-dist (subdirs): Use sed to remove comments from Subdirs files. + * MakeTAGS (subdirs): Likewise. + + * sysdeps/mach/i386/thread_state.h: Include + first thing. + + * hurd/Makefile (sig): Add faultexc. + ($(objpfx)faultexc.c): New target. + (generated): Append faultexc.c. + + * hurd/Makefile (sig): Add hurdfault; remove init-fault. + (distribute): Add hurdfault.h. + * hurd/hurdfault.h: New file. + * hurd/hurdfault.c: New file. + * hurd/hurdsig.c (interrupted_reply_port_location): Use + _hurdsig_catch_fault and _hurdsig_end_catch_fault. + (_hurdsig_getenv): Likewise. + * sysdeps/mach/hurd/i386/trampoline.c: Likewise. + + * hurd/catch-exc.c: Return EPERM if TASK is not right. + + * hurd/hurdsig.c (_hurd_sigthread_fault_env): Variable moved to + hurdfault.c. + (_hurdsig_fault_init): Function moved to hurdfault.c. + +Sat Sep 3 12:22:53 1994 Roland McGrath + + * sysdeps/mach/thread_state.h (MACHINE_THREAD_STATE_SET_PC, + MACHINE_THREAD_STATE_SET_SP): New macros. + * mach/setup-thread.c: Use MACHINE_THREAD_STATE_SET_PC. + * sysdeps/mach/hurd/__fork.c: Likewise. + + * string/test-ffs.c (main: try): Actually call ffs in the test. + +Fri Sep 2 21:20:17 1994 Roland McGrath + + * sysdeps/mach/hurd/mips/__sigret.c: Restore FPU state. Code from + kkojima. + + * sysdeps/mach/hurd/__mknod.c: Fixed copying of the translator + name into buffer with major and minor numbers, and setting of LEN. + + * sysdeps/unix/configure (unix_syscall): In sed cmd, do = first to + avoid clobbering produced assignments. + +Thu Sep 1 03:25:17 1994 Roland McGrath + + * Version 1.08.7. + + * sysdeps/mach/hurd/connect.c (connect): Fix accidental renaming + of sun_path to sun_file_name. + + * bare/Makefile (routines, elided-routines): Set these both to + $(bare-routines). + (distribute): Don't set this. + + * Makerules (distinfo-vars): Fix cmd to echo `sources' defn. + + * sysdeps/unix/configure: Handle dirs other than common. Check + for [gs]etdomainname. + * misc/Makefile (routines): Add getdomain, setdomain. + * sysdeps/unix/bsd/bsd4.4/setdomain.S: New file. + * sysdeps/unix/bsd/bsd4.4/getdomain.S: New file. + * sysdeps/stub/setdomain.c: New file. + * sysdeps/stub/getdomain.c: New file. + +Wed Aug 31 01:15:26 1994 Roland McGrath + + * hurd/hurdsig.c (_hurd_internal_post_signal: sigwakeup): Take no + args; use parent SS variable. Changed all calls. + + * hurd/hurd/signal.h (struct hurd_sigstate): Make `suspended' a + port; remove `arrived'. + * sysdeps/mach/hurd/sigsuspend.c (sigsuspend): Rewritten to set + SS->suspended port and wait for msg on it. Check for and deliver + pending signals properly. + * hurd/hurdsig.c (_hurd_internal_post_signal: sigwakeup): If + SS->suspended is set, send an empty message on it and clear it. + + * math/test-math.c (print_trig_stuff): New function, tests many + math functions. + (main): Call it at end. + + * string/Makefile (tests): Added test-ffs. + * string/test-ffs.c: New file. + +Tue Aug 30 20:33:49 1994 Roland McGrath + + * misc/fstab.c (error): Return void. + (fstabscan): Return int. + + * sysdeps/i386/ffs.c: Use & modifier in constraint for CNT. + + * misc/fstab.c (EFTYPE): If not defined by errno.h, define this to + EINVAL. + (fstabscan): Return void. + +Tue Aug 30 11:00:01 1994 Michael I Bushnell + + * sysdeps/mach/hurd/__access.c (__access): Use a send right, + not a send-once right, in the new auth protocol. + * hurd/__setauth.c (_hurd_setauth): Likewise. + * hurd/hurdsig.c (reauth_proc): Likewise. + * hurd/dtable.c (reauth_dtable): Likewise. + * hurd/hurdlookup.c (__hurd_file_name_lookup_retry): Likewise. + +Tue Aug 30 03:59:38 1994 Roland McGrath + + * socket/sys/socket.h (__SOCKADDR_ARG) [GCC>=2.6]: Use a typedef + with the transparent_union attribute. + + * sysdeps/mach/hurd/__access.c: Use new authentication protocol: + for each port, create a fresh receive right and pass send-once + rights in the auth calls, then destroy the port. + + * sysdeps/mach/mips/syscall.S: New file. + + * stdio/Makefile (mpn-headers, mpn-sysdep): Change asm.h to + asm-syntax.h. + + * misc/Makefile (headers): Added fstab.h. + (routines): Added fstab. + * misc/fstab.c: New file. + * misc/fstab.h: New file. + + * hurd/Makefile (routines): Changed hurdpath to hurdlookup. + * hurd/hurdpath.c: Renamed to hurd/hurdlookup.c. + * hurd/hurdlookup.c: Globally replace `pathtrans' with `lookup' and + `path' with `file_name'. + (__hurd_file_name_split): Don't bother skipping leading slashes. + * hurd/hurd.h: Rename likewise in decls. + * hurd/fchroot.c: Globally replace `pathtrans' with `lookup' and + `path' with `file_name'. + * hurd/hurdsig.c: Likewise. + * hurd/hurdsock.c: Likewise. + * hurd/hurdsyms.c: Likewise. + * hurd/invoke-trans.c: Likewise. + * sysdeps/mach/hurd/__access.c: Likewise. + * sysdeps/mach/hurd/__chmod.c: Likewise. + * sysdeps/mach/hurd/__chown.c: Likewise. + * sysdeps/mach/hurd/__execve.c: Likewise. + * sysdeps/mach/hurd/__link.c: Likewise. + * sysdeps/mach/hurd/__lstat.c: Likewise. + * sysdeps/mach/hurd/__mkdir.c: Likewise. + * sysdeps/mach/hurd/__mknod.c: Likewise. + * sysdeps/mach/hurd/__open.c: Likewise. + * sysdeps/mach/hurd/__rmdir.c: Likewise. + * sysdeps/mach/hurd/__readlink.c: Likewise. + * sysdeps/mach/hurd/__stat.c: Likewise. + * sysdeps/mach/hurd/__symlink.c: Likewise. + * sysdeps/mach/hurd/__unlink.c: Likewise. + * sysdeps/mach/hurd/__utimes.c: Likewise. + * sysdeps/mach/hurd/bind.c: Likewise. + * sysdeps/mach/hurd/chflags.c: Likewise. + * sysdeps/mach/hurd/connect.c: Likewise. + * sysdeps/mach/hurd/fchdir.c: Likewise. + * sysdeps/mach/hurd/opendir.c: Likewise. + * sysdeps/mach/hurd/sysd-stdio.c: Likewise. + * sysdeps/mach/hurd/truncate.c: Likewise. + * sysdeps/mach/hurd/rename.c: Likewise. + * sysdeps/mach/hurd/getcwd.c: Likewise. + * sysdeps/mach/hurd/chroot.c: Likewise. + * sysdeps/mach/hurd/__chdir.c: Likewise. + + * hurd/__setauth.c (_hurd_setauth): Use new authentication + protocol: for each port, create a fresh receive right and pass + send-once rights in the auth calls, then destroy the port. + * hurd/hurdsig.c (reauth_proc): Likewise. + * hurd/dtable.c (reauth_dtable): Likewise. + + * hurd/hurdpath.c (__hurd_path_lookup_retry): Don't handle + FS_RETRY_NONE (it's gone). Use new authentication protocol: + create a fresh receive right and pass send-once rights in the auth + calls, then destroy the port. + +Mon Aug 29 13:17:39 1994 Michael I Bushnell + + * sysdeps/mach/hurd/__symlink.c (__symlink): Use new + file_set_translator protocol. + * sysdeps/mach/hurd/bind.c (bind): Likewise. + * sysdeps/mach/hurd/__mknod.c (__mknod): Likewise. + + * sysdeps/mach/hurd/__pipe.c (__pipe): Use PF_LOCAL instead + of AF_FILE. + +Fri Aug 26 01:21:09 1994 Roland McGrath + + * Makefile ($(objpfx)sysd-dirs): Use sed to remove # comments from + Subdirs files. + + Support for miscellaneous standalone boards (no OS), contributed + by Joel Sherrill (jsherril@redstone-emh2.army.mil), On-Line + Applications Research Corporation. + * sysdeps/standalone: New directory. + * sysdeps/standalone/standalone.h: New file. + * sysdeps/standalone/stdio_lim.h: New file. + * sysdeps/stub/strtsupp.c: New file. + * sysdeps/standalone/filedesc.h: New file. + * sysdeps/posix/{setenv,putenv}.c: Moved to sysdeps/generic. + * sysdeps/unix/getenv.c: Moved to sysdeps/generic. + * sysdeps/unix/morecore.c: Moved to sysdeps/generic. + * sysdeps/posix/sysd-stdio.c: Moved to sysdeps/generic. + * sysdeps/stub/errnos.h: Add ENFILE and EMFILE. + * sysdeps/stub/errlist.c (_sys_errlist): Likewise. + * sysdeps/stub/console.c: New file. + * sysdeps/standalone/__open.c: New file. + * sysdeps/standalone/__read.c: New file. + * sysdeps/standalone/__write.c: New file. + * sysdeps/standalone/__close.c: New file. + * sysdeps/stub/brdinit.c: New file. + * sysdeps/unix/__sbrk.c: Moved to sysdeps/generic. + * sysdeps/standalone/__brk.c: New file. + * sysdeps/standalone/Subdirs: New file + * bare/Makefile: New file (and new directory). + * sysdeps/i960/ffs.c: New file. + * sysdeps/i960/Implies: New file. + * configure.in (os=none): base_os=standalone + +Thu Aug 25 23:56:32 1994 Roland McGrath + + * sysdeps/stub/__sigret.c: Arg is not const. + * signal/sigret.c: Likewise. + +Tue Aug 23 14:43:19 1994 Roland McGrath + + * socket/sys/socket.h (PF_FILE, AF_FILE): Removed (use LOCAL instead). + (PF_XTP, PF_COIP, PF_CNT, PF_RTIP, PF_IPX, PF_SIP, PF_PIP): New macros. + (PF_MAX): Increased to 26. + (pseudo_AF_XTP, AF_COIP, AF_CNT, pseudo_AF_RTIP, AF_IPX, AF_SIP, + pseudo_AF_PIP): New macros. + (MSG_EOR, MSG_TRUNC, MSG_CTRUNC, MSG_WAITALL, MSG_DONTWAIT, + SO_REUSEPORT): New enum constants. + + * hurd/hurdsig.c (_hurd_internal_post_signal): If not preempted, + set ACT before checking for SIGCONT. When continuing and + ACT==handle, don't resume SS->thread; record that it is suspended + and in handler-setup code, don't suspend it again. + + * sysdeps/mach/hurd/sys/param.h: Include (BSD does). + + * sysdeps/mach/hurd/__fork.c: When unchaining old sigstates, check + for SS being head of chain. + +Mon Aug 22 00:29:02 1994 Roland McGrath + + * time/{asia,australasia,europe,northamerica}: New data from ADO. + + * hurd/hurdsig.c (abort_rpcs): After destroying MSGING_PORT, + change the return value register in STATE to EINTR. + * sysdeps/mach/mips/thread_state.h (SYSRETURN): New macro. + * sysdeps/mach/i386/thread_state.h (SYSRETURN): New macro. + + * hurd/hurdsig.c (default_sigaction): New function. + (_hurd_thread_sigstate): Use it to initialize SS->actions. + Initialize rest of new sigstate by hand, don't just bzero it. + + * hurd/hurdsig.c (_hurd_internal_post_signal): Initialize + THREAD_STATE.set to zero. + + * posix/execl.c: Use ARG instead of PATH in va_start. + + * sysdeps/mach/hurd/__fork.c: In child fork, unchain stale + structures from _hurd_sigstates first, and only free them after + other processing is complete. + + * hurd/hurdpath.c (__hurd_path_lookup_retry): For malformed number + in magic "fd/N", return ENOENT instead of treating it as bogus + magic. + + * sysdeps/mach/hurd/__chdir.c: After __path_lookup on arg, use + __hurd_path_lookup of empty file name on resultant port to check + that it's a directory. + * sysdeps/mach/hurd/chroot.c: Likewise. + * sysdeps/mach/hurd/fchdir.c: Use __hurd_path_lookup of empty file + name on FD port to check that it's a directory and acquire a + reference at the same time. + * hurd/fchroot.c: Likewise. + + * hurd/hurdpid.c (init_pids): Add gratuitous self reference to + silence compiler. + + * hurd/hurdpath.c: Include for cttyid opening rpc. + (__hurd_path_lookup_retry): Fixed typo. + + * sysdeps/mach/hurd/i386/__sigret.c: Push state onto the user's + stack, switch to it, pop and return. + + Major rewrite of Hurd signal delivery. + * hurd/hurd/signal.h (struct hurd_sigstate): New member `context'. + * sysdeps/mach/hurd/i386/trampoline.c: Include "thread_state.h" + instead of . + (struct mach_msg_trap_args): New type. + (trampoline): Function removed. + (_hurd_setup_sighandler): Take struct hurd_sigstate * arg instead + of FLAGS and SIGALTSTACK args; take new flag arg RPC_WAIT; use + struct machine_thread_all_state * for STATE arg. New declared + labels `trampoline', `rpc_wait_trampoline' mark asm code at end of + function (after return). Add another struct sigcontext * to + STACKFRAME after the first one, for the arg to __sigreturn. If + SS->context is set, fill registers in SCP from that instead of + STATE, and reset SS->INTR_PORT from it. Use memcpy to copy from + STATE into SCP; the structures are congruent. If RPC_WAIT is set, + set up to use rpc_wait_trampoline and frob args to mach_msg_trap + syscall in progress so that it will retry the receive operation + (but not resend!). + {rpc_wait_trampoline, trampoline}: New trampoline code. + (_hurd_rcv_interrupted_p): New function. + * sysdeps/mach/hurd/mips/trampoline.c: Likewise. + * hurd/hurdsig.c (write_corefile): Take new arg SIGERROR. Use + _hurdsig_getenv instead of getenv. Use dir_mkfile to create an + unlinked node for the core file; then use dir_link to name it, + only if core_dump_task succeeded. + (post_reply): New function. + (abort_thread): New function. + (interrupted_reply_port_location): New function. + (interrupted_reply_port): Function removed (replaced by above). + (abort_all_rpcs): Take struct machine_thread_all_state * for STATE. + (abort_rpcs): Likewise. + Return int, nonzero iff interrupt_operation RPC was done. Take + args for reply port and its port type; call abort_thread instead + of doing thread_abort and thread_get_state. Call + _hurdsig_rcv_interrupted_p instead of _hurd_thread_state_msging_p. + Use __interrupt_operation mig stub instead of manual packing. If + we destroy the msging port, and it is the thread's mig reply port, + clear its reply port slot. Fix inverted SA_RESTART test. + (_hurd_internal_post_signal): Take new arg SIGERROR. + Remove `cont' from ACT enum; SIGCONT processing is independent of + handling. Removed local function `check_pending'; add `reply'. + Use mask macro STOPSIGS instead of alternation to check for stop + signals. Process SIGCONT and do continuation before examining the + handler. Use SS->pending_data instead of SS->sigcodes. When + dying, don't lock _hurd_siglock around __proc_dostop call. When + dying, reply immediately after stopping user threads. When + handling, notice return from abort_rpcs and pass it to + _hurd_setup_sighandler; also pass SS instead of its components. + Set SCP->sc_error from SIGERROR; clear SS->intr_port after saving + it in SCP->sc_intr_port. For pending checks, use macro PENDING + and goto pending if returns true. + (_S_sig_post): Eliminate unnecessary variable WIN; pass SIGERROR + value of zero to _hurd_internal_post_signal. + (_hurdsig_getenv): New function. + * sysdeps/mach/hurd/i386/__sigret.c (sp): New global register + variable. + (__sigreturn): Arg is not const. + After restoring SCP->sc_mask, check for pending signals (newly + unblocked); if any, set SS->context to SCP, clear SS->intr_port, + and send sig_post to the signal thread to deliver the pending + signals. Point SP directly at &SCP->sc_gs and used popa;iret to + restore. (This does not actually work; iret is unhelpful.) + * sysdeps/mach/hurd/mips/__sigret.c (__sigreturn): Arg is not + const. After restoring SCP->sc_mask, check for pending signals + (newly unblocked); if any, set SS->context to SCP, clear + SS->intr_port, and send sig_post to the signal thread to deliver + the pending signals. Don't write $1 value into the user stack. + Instead, write it into the word just past SCP->sc_pc; then point + $1 at SCP->sc_pc and use `op_sigreturn' pseudo-instruction to + restore the PC and $1 from that. + +Fri Aug 19 15:39:54 1994 Roland McGrath + + * configure.in (machine): Grok i586 -> i386/i586. + * sysdeps/i386/pentium: Directory renamed to sysdeps/i386/i586. + + * hurd/hurd.h (_hurd_pids_changed_stamp, _hurd_pids_changed_sync): + New variables. + * hurd/hurdpid.c (_S_proc_newids): Last thing, increment + _hurd_pids_changed_stamp and broadcast on _hurd_pids_changed_sync. + * sysdeps/mach/hurd/__setpgrp.c: After proc_setpgrp succeeds and + PID is ourself, wait on _hurd_pids_changed_sync until + _hurd_pids_changed_stamp increases from the value before the RPC. + * sysdeps/mach/hurd/__setsid.c: After proc_setsid succeeds, wait + on _hurd_pids_changed_sync until _hurd_pids_changed_stamp + increases from the value before the RPC. + + * posix/sys/wait.h [GCC>=2.6] (__WAIT_STATUS): Define this with + typedef as a union with the new (GCC 2.6.1) `transparent_union' + attribute. + + * stdio/printf_fp.c (MPNSIZE): New macro, computed from DBL_MAX_EXP. + (MPN_VAR): Use that for size of bignums. + + * sysdeps/mach/hurd/__kill.c: For pgrp, ignore ESRCH error from + kill_pid of individual pids, unless from all of them. + * hurd/hurdkill.c (_hurd_sig_post): Likewise. + +Fri Aug 19 00:54:50 1994 Roland McGrath + + * configure.in (INSTALL): Quote this shell goop from m4. + + * sysdeps/stub/start.c (errno, __environ): Define these variables. + + * sysdeps/stub/errnos.h (ENOMEM, EACCES): New macros. + * sysdeps/stub/errlist.c (_sys_errlist): Add strings for all + macros defined in stub/errnos.h. + (_sys_nerr): Use value computed from sizeof (_sys_errlist). + +Wed Aug 17 15:32:39 1994 Roland McGrath + + * hurd/hurdmsg.c (_S_io_select_done): Take poly arg for notify + port arg. + + * mach/mach_init.h (vm_page_size): Remove macro defn. + + * hurd/Makefile (distribute): Added STATUS. + + * sysdeps/mach/thread_state.h: Include and + . + + * sysdeps/mach/hurd/__select.c: Pass port-type arg to io_select. + + * sysdeps/mach/hurd/__fork.c: Include "hurdmalloc.h", so we use + the right `free'. + + * sysdeps/mach/hurd/__select.c (SELECT_DONE_MSGID): Correct value + to 23020. + (__select): Don't set PORT until just before sending io_select calls. + Pass proper send-size for io_select_done reply message. Clear the + reply port slot in io_select_done reply message header. + + * sysdeps/mach/hurd/__kill.c: Rename parameter to ARG_SIG, make + SIG a local variable initialized to that (this to work around a + GCC bug). + Initialize PIDS and NPIDS properly for proc_getpgrppids call. + + * signal/signal.h (__sigreturn, sigreturn): Arg is not const. + + * hurd/hurdpath.c (__hurd_path_lookup_retry): For REAUTH or NORMAL + with empty retryname, treat like NONE (which is now obsolete) + after reauthentication. For magic "tty", use new + termctty_open_terminal RPC on cttyid port. + +Tue Aug 16 01:58:21 1994 Roland McGrath + + * sysdeps/mach/hurd/__kill.c (kill_pid): Make non-inline. Treat + null msgport like EPERM return from sig_post. + * hurd/hurdkill.c (_hurd_sig_post): Treat null msgport like EPERM. + + * sysdeps/mach/thread_state.h (machine_get_state, + machine_get_basic_state): Initialize count arg before calling + thread_get_state. + + * hurd/hurdpath.c (__hurd_path_lookup_retry): Initialize ERR to zero. + + * hurd/hurdpath.c (__hurd_path_lookup_retry): Grok magic "tty". + + * hurd/hurd/signal.h (struct hurd_sigstate): Replace `sigcodes' with + `pending_data'. + (_hurd_raise_signal, _hurd_setup_sighandler): Update prototypes. + (_hurd_thread_state_msging_p): Don't declare. + (_hurdsig_rcv_interrupted_p): Declare this instead. + (HURD_EINTR_RPC): Invert sense of restart test. + + * hurd/hurdrlimit.c (_hurd_rlimits): Add braces to initializer. + + * hurd/catch-exc.c: Unlock _hurd_siglock when done with it. Use + __spin_lock_locked on `held' member instead of __mutex_lock_locked. + + * sysdeps/mach/thread_state.h: New file. + * sysdeps/mach/i386/thread_state.h: Don't #include + . Add #include_next at end. + * sysdeps/mach/mips/thread_state.h: Likewise. + + * sysdeps/mach/hurd/i386/sigcontext.h (struct sigcontext): Lay out + corresponding to i386_thread_state and i386_float_state. + * sysdeps/mach/hurd/mips/sigcontext.h (sc_mips_thread_state, + sc_mips_exc_state, sc_mips_float_state): New macros, marking + members that correspond to thread_state.h structs. + +Mon Aug 15 17:21:20 1994 Roland McGrath + + * Rules [cross-compiling=yes] (tests): Depend on the binaries, not + the output files. + + * Makerules: Replace uses of HOST_CC with BUILD_CC and + native-CFLAGS with BUILD_CFLAGS. + + * sysdeps/unix/Makefile (mk-local_lim, make-ioctls): Replace uses + of CC with BUILD_CC and native-CFLAGS with BUILD_CFLAGS. + * sysdeps/unix/sysv/sysv4/solaris2/Makefile: Replace uses of + HOST_CC with BUILD_CC and native-CFLAGS with BUILD_CFLAGS. + * sysdeps/posix/Makefile: Likewise. + + * Makeconfig (+cc_version): Variable and associated code removed. + (HOST_CC): Use BUILD_CC instead; all uses changed. + (cross-compiling): Set to no if not the case. + + * sysdeps/m68k/fpu/__math.h: Replace all uses of __const with + __CONSTVALUE. + + * Makerules (distinfo-vars): Remove $@.new first thing. Write + elided-routines instead of sysdep_routines. After writing + variables, append to sources from $(elided-routines). + * sysdeps/vax/Makefile (elided-routines): New variable (append to + it). + (aux, routines): Don't set these. + (sysdep_routines): Append things here instead. + * sysdeps/generic/Makefile (elided-routines): New variable (append + to it). + (aux): Don't set this. + * sysdeps/generic/Makefile (routines): Don't set this. + (sysdep_routines): Append exp__E and log__L here instead. + + * time/test_time.c (main): Set TBUF.tm_isdst to -1 before calling + mktime. + + * stdlib/stdlib.h (atof, atoi, atol, random, srandom, setstate, + initstate, mblen): Never define as macros. + [__OPTIMZE__ && __GNUC__ >= 2]: Define those functions as extern + inlines. + + * hurd/hurdpath.c (__hurd_path_lookup_retry): For magic "fd/%u", + lose on random chars after number; for / after number, retry + remainder properly. + + * hurd/hurdpath.c (pathtrans_error): New function; filters errors + from dir_pathtrans: EOPNOTSUPP and MIG_BAD_ID become ENOTDIR. + (__hurd_path_lookup, __hurd_path_lookup_retry): Call it. + +Thu Aug 11 11:59:33 1994 Noel Cragg (noel@churchy.gnu.ai.mit.edu) + + * time/mktime.c (_mktime_internal): Add code to normalize value of + TM_ISDST to -1, 0, or 1 so code doesn't loop forever. + +Thu Aug 11 02:26:37 1994 Roland McGrath + + * resolv/Makefile (subdir): Set to resolv, not res. + + * sysdeps/mach/hurd/sysd-stdio.c (fd_fail): Pass ERR to + _hurd_raise_signal. + + * sysdeps/mach/i386/thread_state.h (struct machine_thread_all_state): + Add new member `fpu'. + +Wed Aug 10 23:39:49 1994 Karl Heuer + + * malloc/mcheck.c (mcheck): Remove obsolete extern declaration. + + * malloc/mcheck.c (flood): Add an arg. + (freehook, mallochook, reallochook): Use different flood bytes to + distinguish freed space from uninitialized allocated space. + + * malloc/mtrace.c (mtrace): Guard against being called twice. + (muntrace): New function, to turn off tracing. + * malloc/malloc.h: Declare it. + +Wed Aug 10 02:47:24 1994 Roland McGrath + + * sysdeps/mach/hurd/mips/sigcontext.h (struct sigcontext): Renamed + member `sc_err' to `sc_error'. + + * hurd/hurd-raise.c: Take new arg SIGERROR. Set + SS->pending_data[SIGNO] from SIGCODE and SIGERROR instead of + setting SS->sigcodes[SIGNO]. + + * Makeconfig (+includes): Use text manipulation to avoid + conditional for $(..). Append $(last-includes). + * sysdeps/mach/hurd/Makefile (last-includes): Append + -I.../libthreads to this. + (includes): Not to this. + + * hurd/hurd/fd.h (_hurd_fd_error): Pass ERR to _hurd_raise_signal. + + * stdlib/stdlib.h [__OPTIMIZE__] (cfree, rand, srand, random, + srandom, initstate, setstate): Macros removed. + + * malloc/mcheck.c (reallochook): Fixed typo. + (mabort) [! __GNU_LIBRARY__]: Use fprintf and abort instead of + __libc_fatal. + + * hurd/Makefile (sig): Remove msging-p; that function will go in + trampoline.c. + * sysdeps/stub/msging-p.c: File removed. + * sysdeps/mach/hurd/mips/msging-p.c: File removed. + * sysdeps/mach/hurd/i386/msging-p.c: File removed. + +Tue Aug 9 19:20:29 1994 Roland McGrath + + * hurd/catch-exc.c: Get error code from _hurd_exception2signal and + pass it to _hurd_internal_post_signal. Search for SS manually + rather than using _hurd_thread_sigstate, to avoid locks. + + * sysdeps/mach/hurd/mips/msging-p.c: Fetch port argument from + register $8 (t0) instead of stack. Change type of STATE arg to + `struct machine_thread_all_state *'. + + * inet/inet_netof.c: Incorporated from BSD 4.4-Lite. + * inet/inet_net.c: Incorporated from BSD 4.4-Lite. + +Tue Aug 9 18:28:40 1994 Karl Heuer + + * malloc/mtrace.c (tr_mallochook, tr_reallochook): Don't assume + %lx format matches size_t arg. + * malloc/mtrace.c: Enable file- and line-number tracing. + * malloc/mtrace.awk: Postprocess that trace information. + + * malloc/mcheck.c (flood): New function. + (freehook, mallochook, reallochook): Initialize new space and + freed space to non-zero garbage, to help find code that makes + unwarranted assumptions. + +Mon Aug 8 01:20:56 1994 Roland McGrath + + * sysdeps/mach/hurd/mips/exc2signal.c (_hurd_exception2signal): Take + new arg `int *error'; set it. + * sysdeps/mach/hurd/i386/exc2signal.c: Likewise. + * sysdeps/stub/exc2signal.c: Likewise. + * hurd/hurd/signal.h (_hurd_exception2signal): Take new arg + `int *error'. + (_hurd_internal_post_signal): Take new arg `int error'. + + * res: Directory renamed to resolv. + * sysdeps/unix/inet/Subdirs: Change res to resolv. + + * Version 1.08.6. + + * sysdeps/sparc/divrem.m4 (DEVELOP_QUOTIENT_BITS): Use ** instead of + ^ for exponentiation. Pinard says it is more portable. + + * sysdeps/mach/hurd/mips/sigcontext.h (struct sigcontext): Added + member `sc_err'. + * sysdeps/mach/hurd/i386/sigcontext.h (struct sigcontext): Move + sc_err to front machine-independent section; change its comment. + + * sysdeps/stub/thread_state.h (struct machine_thread_all_state): New + type. + * sysdeps/mach/i386/thread_state.h: Likewise. + * sysdeps/mach/mips/thread_state.h: Likewise. + + * sysdeps/mach/i386/Implies: File removed; it was superfluous. + + * sysdeps/sparc/divrem.m4 (Lgot_result): Add more quotes in ifelse. + + * configure.in (fpu_dirs): Fixed typo. + +Sun Aug 7 01:13:04 1994 Roland McGrath + + * inet/inet_lnaof.c: Incorporated from BSD 4.4-Lite. + * inet/inet_mkadr.c: Incorporated from BSD 4.4-Lite. + * inet/inet_addr.c: Incorporated from BSD 4.4-Lite. + * res/Makefile (headers): Use only arpa/nameser.h, not arpa/*.h. + * res/arpa/inet.h: Moved to inet/arpa/inet.h. + * inet/arpa/inet.h: Incorporated from BSD 4.4-Lite. + + * misc/init-misc.c: New file. + * misc/Makefile (aux): Added init-misc. + + * Makeconfig (localtime-file): Use $(sysconfdir) instead of + $(etcdir). + + * Makerules (install-bin-nosubdir): Use $(install-bin) instead of + $(install). + (install-sbin-nosubdir): New target. + (install-no-libc.a-nosubdir): Depend on that. + + * configure.in ($nfp check): Iterate through $mach and use all + fpu/ dirs that exist. + +Wed Aug 3 02:46:03 1994 Roland McGrath + + * sysdeps/mach/hurd/mips/sigcontext.h: Rearranged structure so + machine-dependent portion is laid out like `struct mips_thread_state; + struct mips_exc_state; struct mips_float_state;'. + + * Version 1.08.5. + + * sysdeps/mach/hurd/mips/__sigret.c: Compare *reply_port to + MACH_PORT_NULL, not implicit zero. + (restore_gpr): Use N-1 as subscript into sc_gpr (sc_gpr[0] => $1). + Before general regs, restore from sc_mdlo and sc_mdhi. Don't + treat sp, fp specially; use restore_gpr for them too. For final + return, store user $1 value beyond top of user stack ahead of + time; then use $1 to hold the user PC, and restore it from the + stack in the delay slot. + +Tue Aug 2 21:03:51 1994 Roland McGrath + + * sysdeps/mach/hurd/mips/trampoline.c (_hurd_setup_sighandler): + Copy TS to SCP all at once. + * sysdeps/mach/hurd/mips/sigcontext.h (struct sigcontext): sc_gpr + has 31 elts; sc_gpr, sc_pc, sc_mdlo, sc_mdhi are arranged in that + order to mimic struct mips_thread_state. + + * Make-dist (all-headers): Instead of removing rpcsvc/%, use + $(wildcard) to remove all headers that don't exist at top level, + but preserve top-level $(headers). + + * Make-dist (sysdep_dirs): Avoid directories called RCS. + (%/configure): Pass -f to mv. + + * sysdeps/mips/setjmp.S [__sgi__]: Use `fp' instead of `$fp'. + +Mon Aug 1 20:12:23 1994 Roland McGrath + + * sysdeps/mach/hurd/mips/sigcontext.h (struct sigcontext): Add + members sc_mdlo, sc_mdhi. + * sysdeps/mach/hurd/mips/trampoline.c (_hurd_setup_sighandler): + Save mdlo and mdhi. + +Sun Jul 31 14:21:16 1994 Roland McGrath + + * time/mktime.c: Remove errant comment end sequence. + + * termios/sys/ttydefaults.h: Incorporated from BSD 4.4-Lite. + * sysdeps/vax/DEFS.h: Incorporated from BSD 4.4-Lite. + * sysdeps/unix/bsd/sys/reboot.h: Incorporated from BSD 4.4-Lite. + * sysdeps/unix/bsd/bsd4.4/errnos.h: Updated from 4.4-Lite sys/errno.h. + [__USE_BSD] (EAUTH, ENEEDAUTH, ELAST): New macros. + * sysdeps/ieee754/support.c: Incorporated from BSD 4.4-Lite. + * sysdeps/ieee754/cbrt.c: Incorporated from BSD 4.4-Lite. + * sysdeps/generic/trig.h: Incorporated from BSD 4.4-Lite. + * sysdeps/generic/tanh.c: Incorporated from BSD 4.4-Lite. + * sysdeps/generic/tan.c: Incorporated from BSD 4.4-Lite. + * sysdeps/generic/sinh.c: Incorporated from BSD 4.4-Lite. + * sysdeps/generic/sincos.c: Incorporated from BSD 4.4-Lite. + * sysdeps/generic/pow.c: Incorporated from BSD 4.4-Lite. + * sysdeps/generic/mathimpl.h: Incorporated from BSD 4.4-Lite. + Add back __izing #define's, except for exp__E and log__L, which + have been renamed with __s in 4.4-Lite. + * sysdeps/generic/log__L.c: Incorporated from BSD 4.4-Lite. + * sysdeps/generic/log1p.c: Incorporated from BSD 4.4-Lite. + * sysdeps/generic/log.c: Incorporated from BSD 4.4-Lite. + * sysdeps/generic/fmod.c: Incorporated from BSD 4.4-Lite. + * sysdeps/generic/exp__E.c: Incorporated from BSD 4.4-Lite. + * sysdeps/generic/exp.c: Incorporated from BSD 4.4-Lite. + * sysdeps/generic/cosh.c: Incorporated from BSD 4.4-Lite. + * sysdeps/generic/atanh.c: Incorporated from BSD 4.4-Lite. + * sysdeps/generic/atan2.c: Incorporated from BSD 4.4-Lite. + * sysdeps/generic/asinh.c: Incorporated from BSD 4.4-Lite. + * sysdeps/generic/asincos.c: Incorporated from BSD 4.4-Lite. + * misc/getusersh.c: Incorporated from BSD 4.4-Lite. + (initshells): Reapply fix of 16 Nov 1992. + * sysdeps/generic/acosh.c: Incorporated from BSD 4.4-Lite. + * sysdeps/generic/__expm1.c: Incorporated from BSD 4.4-Lite. + * misc/ttyslot.c: Incorporated from BSD 4.4-Lite. + * misc/ttyent.h: Incorporated from BSD 4.4-Lite. + * misc/syslog.c: Incorporated from BSD 4.4-Lite. + * misc/paths.h: Incorporated from BSD 4.4-Lite. + * misc/getttyent.c: Incorporated from BSD 4.4-Lite. + * misc/sys/syslog.h: Incorporated from BSD 4.4-Lite. + Don't include ; define _BSD_VA_LIST_ to __gnuc_va_list. + * inet/rexec.c: Incorporated from BSD 4.4-Lite. + * inet/rcmd.c: Incorporated from BSD 4.4-Lite. + (rcmd): Reapply select max fd fix of 3 Jun 1994. + * inet/pathnames.h: File removed. + * inet/inet_ntoa.c: Incorporated from BSD 4.4-Lite. + * inet/getsrvbypt.c: Incorporated from BSD 4.4-Lite. + * inet/getsrvbynm.c: Incorporated from BSD 4.4-Lite. + * inet/getservent.c: Incorporated from BSD 4.4-Lite. + * inet/getprtname.c: Incorporated from BSD 4.4-Lite. + * inet/getprtent.c: Incorporated from BSD 4.4-Lite. + * inet/getproto.c: Incorporated from BSD 4.4-Lite. + * inet/protocols/timed.h: Incorporated from BSD 4.4-Lite. + * inet/protocols/talkd.h: Incorporated from BSD 4.4-Lite. + * inet/protocols/rwhod.h: Incorporated from BSD 4.4-Lite. + * inet/protocols/routed.h: Incorporated from BSD 4.4-Lite. + * inet/arpa/tftp.h: Incorporated from BSD 4.4-Lite. + * inet/arpa/telnet.h: Incorporated from BSD 4.4-Lite. + * inet/arpa/ftp.h: Incorporated from BSD 4.4-Lite. + +Fri Jul 29 01:50:37 1994 Roland McGrath + + * Version 1.08.4. + + * res/Makefile (routines): Add missing backslash. + + * sysdeps/mach/hurd/mips/__sigret.c: Rename variable AT (which is + the register's name) to SCPREG. Fix some SCP references in + register loads to use SCPREG instead. Load SCPREG->sc_pc into $24 + and jump to it, restoring $at in the delay slot. This still + leaves $24 clobbered. + + * sysdeps/mach/hurd/mips/sigcontext.h: Use `unsigned int' + consistently for port names. + + * sysdeps/mach/hurd/mips/trampoline.c: Don't set up args on the + stack; pass them in registers. + + * Makefile (%/configure, sysd-dirs, munch-init.c): Pass -f to mv. + + * misc/sys/cdefs.h (__NORETURN, __CONSTVALUE): Use the + __attribute__ defn for GCC>=2.7, not >=2.6. Use the keyword defn + only for GCC<2.5. Use __volatile__ and __const__ instead of + noreturn and const for namespace safety. + + * sysdeps/mach/hurd/__readlink.c: If BUF is null, return the size + of buffer required. + +Thu Jul 28 17:17:11 1994 Roland McGrath + + * res/netdb.h: Declare h_errno. + + * res: New directory, for all code incoporated from BIND. + * inet/arpa/inet.h, inet/arpa/resolv.h: Moved to res/arpa. + * inet/sys/bitypes.h: Moved to res/sys. + * inet/gethstnamad.c: Renamed to res/gethnamaddr.c. + * inet/getnetbyad.c: Renamed to res/getnetbyaddr.c. + * inet/getnetbynm.c: Renamed to res/getnetbyname.c. + * inet/res_mkqry.c: Renamed to res/res_mkquery.c. + * inet/Makefile (headers): Removed netdb.h, resolv.h, and + sys/bitypes.h. + (routines): Removed res_comp res_debug res_init res_mkqry res_query + res_send gethstnmad sethostent. + (aux, distribute): Variables removed. + * res/getnetnamadr.c, res/nsap_addr.c: New files. + * All .c and .h in res/ updated from BIND-4.9.3-BETA9. + * res/Makefile: New file. + * sysdeps/unix/inet/Subdirs: Added res. + + * Makerules: Replace all uses of `.dep' suffix with `.d' suffix. + (+make-deps): Replace `.dtm' suffix with `.T' suffix. + +Wed Jul 27 06:13:30 1994 Noel Cragg (noel@churchy.gnu.ai.mit.edu) + + * time/mktime.c: Add code to support tm_isdst flag in struct tm. + Fixed bug with handling of DST sections. + +Mon Jul 25 17:17:28 1994 Roland McGrath + + * sysdeps/sparc/divrem.m4 (Lgot_result) [S=true]: Only test SIGN + and negate for [OP=div]. + + * socket/sys/socket.h (__SOCKADDR_ARG): New macro; for GCC 2.6 and + later, a funky union similar to __WAIT_STATUS in . + (bind, getsockname, connect, getpeername, sendto, recvfrom, + accept): Use __SOCKADDR_ARG in place of `struct sockaddr *' in + declarations. + + * posix/glob/configure.bat: New file. + * posix/Makefile (glob.tar): Add glob/configure.bat. + + * sysdeps/unix/opendir.c: Fail with ENOENT when passed "". + Check STATBUF and fail with ENOTDIR if it's not a directory. + +Mon Jul 25 15:44:18 1994 Noel Cragg (noel@churchy.gnu.ai.mit.edu) + + * time/mktime.c: Fix range-checking bug in NORMALIZE macro. + +Fri Jul 22 02:42:44 1994 Roland McGrath + + * sysdeps/unix/readdir.c: Search for NUL character to limit + d_namlen. Some systems return very bogus values. + + * sysdeps/unix/sysv/sysv4/i386/sysdep.h (PSEUDO): Remove ret at end. + + * mach/Makefile (mach-shortcuts): Filter out device_writev_request. + + * limits.h (_LIBC_LIMITS_H_): Don't define if already defined. + [__GNUC__ < 2]: Only protect this section from multiple inclusion. + + * sysdeps/mach/hurd/i386/trampoline.c (_hurd_setup_sighandler): + Declare SIGSP volatile. + + * hurd/hurdinit.c (_hurd_setproc): Fixed arg in + _hurd_pgrp_changed_hook decl. + + * hurd/hurd/signal.h (_hurd_self_sigstate_unlocked): New function. + (HURD_EINTR_RPC): Use it instead of _hurd_self_sigstate followed by + __mutex_unlock; this thread might already hold the lock. + +Wed Jul 20 18:53:54 1994 Michael I Bushnell + + * hurd/fd-read.c (_hurd_fd_read): Test for EBACKGROUND in + do loop was reversed. + + * hurd/hurdpath.c (__hurd_path_lookup): Skip over initial slashes + before calling __dir_pathtrans. + +Tue Jul 19 15:28:39 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * mach/Makefile (user-interfaces): Add mach/mach4. + (mach-shortcuts): Match all syscall_% again; the missing ones are in + mach4.defs. + + * mach/Machrules (%.ir): Match SimpleRoutine as well as Routine + comments. + + * sysdeps/mach/hurd/Makefile ($(hurd)/errlist.c): Use -f flag to mv. + +Sat Jul 16 00:42:30 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Makerules [install]: Rewrite this rule to use install-bin. + [install-sbin]: New rule parallel to that one, installs in $(sbindir). + + * time/Makefile (install-sbin): Set this instead of install. + * sunrpc/Makefile (install-others): Use $(sysconfdir)/rpc instead + of $(etcdir)/rpc. + (install-bin): Set this instead of install; set it to just rpocgen. + (install-sbin): Put rpcinfo and portmap here instead. + ($(sysconfdir)/rpc): Rule renamed from $(etcdir)/rpc. + (defines): Rename it in _PATH_RPC defn here too. + + * posix/Makefile (install-bin): Set this instead of install. + + * Makeconfig (datadir): Default to $(prefix)/share, not $(prefix)/lib. + (sbindir): New variable. + (sysconfdir): Variable renamed from etcdir. + + * sysdeps/unix/bsd/sun/signum.h: New file; no SIGINFO, SIGLOST is 29. + + * sysdeps/unix/sysv/sco3.2.4/uname.S: New file from Scott Bartram. + + * sysdeps/unix/sysv/sco3.2.4/__getgrps.c: Include alloca.h. + + * configure.in (INSTALL): If it is $srcdir/install.sh after + AC_PROG_INSTALL, reset it to '$(..)./install.sh'. + + * sysdeps/mach/hurd/__ioctl.c (io2mach_type): Move macro defn before + first use. + (__ioctl): Fix swapped args to __sigismember; remove unused variable. + + * sysdeps/mach/hurd/send.c: Fix portsPoly arg to __socket_send. + * sysdeps/mach/hurd/sendto.c: Likewise. + + * sysdeps/mach/hurd/recv.c: Pass &BUFP, not BUFP. + * sysdeps/mach/hurd/recvfrom.c: Likewise. + + * sysdeps/mach/hurd/connect.c: Include . + + * sysdeps/mips/dec/bytesex.h: New file. + * sysdeps/mips/p40/bytesex.h: New file. + +Fri Jul 15 23:12:06 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * posix/sys/types.h (u_quad, quad): Renamed to &_t. + * posix/gnu/types.h [__GNUC__] (__u_quad_t, __quad_t, __qaddr_t): + New typedefs, using long long int and derivatives. + [! __GNUC__] (__u_quad, __quad): Renamed to &_t. + (__fsid_t): Make this always be __u_quad_t. + + * time/sys/time.h (struct timespec): New type. + (TIMEVAL_TO_TIMEPSEC, TIMESPEC_TO_TIMEVAL): New macros. + +Thu Jul 14 15:43:39 1994 Brendan Kehoe (brendan@zen.org) + + * sysdeps/unix/sysv/sysv4/sysinfo.S: New file. + * sysdeps/unix/sysv/sysv4/Dist: Add sysinfo.S. + * sysdeps/unix/sysv/sysv4/Makefile: Add sysinfo to sysdep_routines + if we're inside misc. + * sysdeps/unix/sysv/sysv4/sethostnam.c: New file. + * sysdeps/unix/sysv/sysv4/__gethstnm.c: New file. + + * sysdeps/unix/sysv/sysv4/solaris2/fsync.S: New file. + +Tue Jul 12 00:57:08 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * mach/Makefile (mach-shortcuts): Only match known Mach + subsystems: vm, task, mach_port, and thread. + +Mon Jul 11 20:18:29 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * hurd/intr-rpc.defs, hurd/intr-rpc.awk: New files. + * hurd/Makefile (user-MIGFLAGS): Add -imacros intr-rpc.defs. + (transform-user-stub): New canned sequence. + (transform-user-stub-output): New variable. + Make the .ustamp files depend on intr-rpc.awk. + + * mach/Machrules (%.ir): Cull the RPC names from the preceding + comment rather than the definition, so we don't see any userprefix. + (transform-user-stub-output): New variable. + (%.ustamp: %.defs): Invoke $(transform-user-stub) inside for loop. + Use $(transform-user-stub-output) in place of `tmp' in arg to + move-if-change. + + * mach/Makefile [! mach-shortcuts] (user-interfaces): Also filter + out device/device_request. + +Mon Jul 11 17:50:14 1994 Brendan Kehoe (brendan@mole.gnu.ai.mit.edu) + + * sysdeps/unix/sysv/sysv4/Makefile: Put the sys-sig.S stuff in + here, rather than in .../sysv4/solaris2/sparc/Makefile. + * sysdeps/unix/sysv/sysv4/solaris2/sparc/Makefile: Removed the + sys-sig.S part. + +Sun Jul 10 19:04:24 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * sysdeps/mach/hurd/bind.c: Call __hurd_invoke_translator. + + * hurd/hurd.h (__hurd_invoke_translator, hurd_invoke_translator): + Declare them. + * hurd/Makefile (routines): Add invoke-trans. + * hurd/invoke-trans.c (__hurd_invoke_translator): New file. + * hurd/hurdsyms.c (hurd_invoke_translator): New alias. + + * hurd/hurdpath.c (__hurd_path_lookup_retry): New function. + * hurd/hurdsyms.c (hurd_path_lookup_retry: New alias. + * hurd/hurd.h (__hurd_path_lookup_retry, hurd_path_lookup_retry): + Declare them. + + * hurd/hurd/fd.h (_hurd_fd_error_signal): Return SIGLOST for + MIG_SERVER_DIED. + + * time/strftime.c: Make %j value 1-origin instead of 0-origin. + +Sat Jul 9 02:31:23 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * gnu-stabs.h (__SYMBOL_PREFIX): New macro, based on NO_UNDERSCORES. + Use it in all macros instead of explicit leading underscores. + Removed all [! __STDC__] definitions. + + * sysdeps/mach/hurd/mips/trampoline.c: New file. + * sysdeps/mach/hurd/mips/sigcontext.h: New file. + * sysdeps/mach/hurd/mips/longjmp-ts.c: New file. + * sysdeps/mach/hurd/mips/msging-p.c: New file. + * sysdeps/mach/hurd/mips/longjmp-ctx.c: New file. + * sysdeps/mach/hurd/mips/init-fault.c: New file. + * hurd/mach/hurd/mips/__sigret.c: New file. + * sysdeps/mach/hurd/mips/exc2signal.c: New file. + * sysdeps/mach/mips/thread_state.h: New file. + * sysdeps/mach/mips/machine-sp.h: New file. + * sysdeps/mach/mips/machine-lock.h: New file. + * sysdeps/mach/mips/sysdep.h: New file. + + * mach/Makefile (mach-syscalls.mk): Snarf 3rd arg from kernel_trap. + ($(mach-syscalls:%=__%.S): Emit kernel_trap instead of SYSCALL_TRAP. + * mach/syscalls.awk: Print nargs-$1 = $3 for each line. + * sysdeps/mach/sysdep.h: Include . + * sysdeps/mach/i386/sysdep.h (ENTRY, SYSCALL_TRAP): Macros removed. + + * sysdeps/mach/i386/machine-lock.h: Use __volatile in place of + volatile to work with -traditional. + +Fri Jul 8 21:06:43 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * hurd/hurdsig.c (_hurd_internal_post_signal): For stop signals, + clear pending SIGCONT no matter what action we choose. + Add new value `cont' to ACT enum; use it for default SIGCONT action. + (_hurd_internal_post_signal: sigwakeup): New local inline. + +Fri Jul 8 20:26:49 1994 Brendan Kehoe (brendan@zen.org) + + * sysdeps/unix/sysv/sysv4/solaris2/sparc/Makefile (sysdep-CFLAGS): Set + this to include the -mhard-quad-float option. + + * sysdeps/unix/sysv/sysv4/solaris2/sparc/sys-sig.S: New file. + * sysdeps/unix/sysv/sysv4/solaris2/sparc/Makefile: New file. + * sysdeps/unix/sysv/sysv4/solaris2/sparc/Dist: New file. + +Fri Jul 8 13:54:54 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * hurd/hurdpath.c (__hurd_path_lookup): Don't treat leading / + specially for FS_RETRY_NORMAL. Handle FS_RETRY_MAGICAL; leading / + here means use crdir. In that case, deallocate *RESULT if nonnull. + + * sysdeps/unix/sysv/sysv4/i386/sysdep.h: Don't define _ERRNO_H if + already defined. + + * posix/gnu/types.h (__ino_t): Make this unsigned int instead of + unsigned long int (matters for Alpha). + + * Makeconfig (+gccopt): Variable removed. + (+cflags): Don't use it. + (CPPFLAGS): Append $(sysdep-CPPFLAGS). + (CFLAGS): Append $(sysdep-CFLAGS). + + * sysdeps/mach/hurd/__ioctl.c: In MSGID calculation, skip blocks + of 100 for request commands >= 100, to allow for the reply msgids. + +Thu Jul 7 19:07:00 1994 Brendan Kehoe (brendan@zen.org) + + * sysdeps/unix/bsd/osf1/dirstream.h (DIR): Make __allocation + member be int, not size_t (which is a long). + +Thu Jul 7 15:21:15 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * hurd/__fopenport.c (readio, writeio, seekio, closeio): New functions. + (funcsio): New const variable. + (__fopenport): Make the new stream use that for its io functions, and + the default room functions, and set its seen flag. + +Tue Jul 5 11:32:38 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * hurd/hurd/signal.h (struct hurd_sigstate): Removed `intr_restart'. + (HURD_EINTR_RPC): Uncommented. Declare label + `__do_call' so it has block instead of function scope. Don't use + SS->intr_restart; instead SS->intr_port being reset to + MACH_PORT_NULL tells us to restart the call. + + * sysdeps/mach/hurd/__ioctl.c: Enable use of HURD_EINTR_RPC. + Do ctty magic and check for EBACKGROUND to generate SIGTTOU. + + * mach/devstream.c (dealloc_ref): New function. + (mach_open_devstream): Add a user reference to DEV, and set + STREAM's close fn to dealloc_ref, which will release the reference. + + * hurd/fd-read.c (_hurd_fd_read): Enabled and rewrote SIGTTIN code. + * hurd/fd-write.c (_hurd_fd_write): Enabled and rewrote SIGTTOU code. + + * hurd/hurdsyms.c: Add an alias hurd_sig_post -> _hurd_sig_post. + * hurd/hurdkill.c (_hurd_sig_post): Renamed back from hurd_sig_post. + * hurd/hurd.h: Declare _hurd_sig_post. + + * hurd/hurdsig.c (_S_sig_post): Add SIGTTIN and SIGTTOU cases, + handled like SIGINT et al. + + * mach/devstream.c: Turn back on NL->CRNL translation. + + * stdio/xbug.c (main): Return instead of running off the end. + +Mon Jul 4 16:57:13 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 1.08.3. + +Sat Jul 2 00:15:37 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * sysdeps/mach/hurd/__ioctl.c: Account for three type fields in + message buffer size. + + * sysdeps/mach/hurd/i386/trampoline.c (_hurd_setup_sighandler): + Catch faults accessing user stack and return NULL. + * hurd/hurdsig.c (_hurd_internal_post_signal): When it does, die + with SIGILL and dump core. + + * hurd/hurdsig.c (_hurd_internal_post_signal): Use + _hurd_msgport_thread instead of __mach_thread_self () to avoid the + system call. (Signals will now lose if _hurd_msgport_thread gets + clobbered.) + (abort_rpcs): Always do thread_abort and thread_get_state. + + * misc/getpass.c: Fix typo resulting in newline not being removed. + + * termios/sys/ttydefaults.h [TTYDEFCHARS] (ttydefchars): Cast + _POSIX_VDISABLE to cc_t to avoid gcc warning. + +Fri Jul 1 14:07:40 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * hurd/Makefile (user-interfaces): Add hurd/ifsock. + + * socket/sys/socket.h (AF_LOCAL): New macro. + + * sysdeps/mach/hurd/__kill.c: Fix SIGKILL loop condition. + +Fri Jul 1 13:36:27 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) + + * hurd/hurdkill.c (hurd_sig_post): New var PIDSBUF; initialize + PIDS and NPIDS correctly; only free PIDS if the MiG stub + changed it. + +Thu Jun 30 18:47:48 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) + + * hurd/hurdsock.c (_hurd_socket_server): Zero up to and *including* + new[DOMAIN]. + +Thu Jun 30 08:12:28 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * hurd/hurdsig.c (abort_all_rpcs): Just iterate over _hurd_sigstates. + + * hurd/dtable.c (fork_child_dtable): Skip empty descriptor slots. + + * sysdeps/mach/hurd/__ioctl.c: Fix MSG.data size calculation. + +Wed Jun 29 19:06:54 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * sysdeps/mach/hurd/bind.c: For AF_LOCAL, create a new node in the + filesystem, put the ifsock translator on it, and fetch the + address port. + * sysdeps/mach/hurd/connect.c: For AF_LOCAL, look up the socket + file and fetch the address port using the ifsock protocol. + +Tue Jun 28 16:03:15 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * hurd/Makefile (routines): Add ports-get, ports-set, and hurdmsg. + (aux): Remove msgstub. + * hurd/hurdports.c (get): Just call _hurd_ports_get. + (set): Just call _hurd_ports_set. + (getcttyid, setcttyid): New functions. + * hurd/ports-get.c (_hurd_ports_get): New file, new function. + * hurd/ports-set.c (_hurd_ports_set): New file, new function. + * hurd/hurd.h: Declare _hurd_ports_get and _hurd_ports_set. + Declare getcttyid and setcttyid. + * hurd/__setauth.c (__setauth): Just call _hurd_setauth. + (_hurd_setauth): New function, code moved from __setauth. + * hurd/hurdinit.c (_hurd_setproc): New function. + * hurd/hurdioctl.c (_hurd_setcttyid): New function. + + * locale/C-ctype_ct.c (__ctype_tolower_C, __ctype_toupper_C): Use + integer constants instead of character constants for octal values + so they will not be sign extended. + + * sysdeps/mach/hurd/__setitmr.c (fork_itimer): New function, on + _hurd_fork_child_hook. + + * sysdeps/stub/sysd-stdio.c (__stdio_reopen): Fix typo in arg type. + * sysdeps/stub/__ioctl.c: Fix type of REQUEST arg. + * sysdeps/stub/syscall.c: Include ansidecl.h. + * sysdeps/stub/_exit.c: Add __NORETURN to defn. + + * sysdeps/unix/sysv/sysv4/sigset.h (_EXTERN_INLINE): Define to + `extern __inline', not empty. + + * sysdeps/mach/hurd/ttyname.c: Don't bother searching /dev. + +Sat Jun 25 15:41:29 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * sysdeps/mach/hurd/__fork.c: Moved proc_task2pid call to just + before proc_child. It is a waste to do it earlier. + +Sat Jun 25 13:17:39 1994 Michael I Bushnell (mib@geech.gnu.ai.mit.edu) + + * sysdeps/mach/hurd/__fork.c: Move proc_task2pid call to after + _hurd_ports are unlocked. Call proc_child nearly last thing. + Ignore errors from thread_resume. + +Fri Jun 24 20:21:11 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * sysdeps/posix/getcwd.c: Remove empty `#define'. + +Fri Jun 24 17:57:36 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) + + * sysdeps/mach/hurd/__fork.c: Call proc_task2pid immediately after + task_create. Add comment explaining why thread_resume must be the + last thing we do to the child. + +Fri Jun 24 01:41:41 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * hurd/hurdinit.c (_hurd_proc_init): Call __proc_set_arg_locations + in place of __proc_setprocargs (it was renamed). + + * hurd/hurd.h: Rename _hurd_sig_post to hurd_sig_post. + * hurd/hurdkill.c: Likewise. + + * hurd/port2fd.c (_hurd_port2fd): Call __term_open_ctty instead of + __term_become_ctty, and don't pass the message port. + * hurd/hurdioctl.c (rectty_dtable): Likewise. + * hurd/dtable.c (fork_child_dtable, ctty_new_pgrp): Likewise. + + * sysdeps/mach/hurd/__fork.c: Use __proc_{get,set}_arg_locations + to propagate argv and envp locations to the child. + + * stdio/freopen.c (freopen): If STREAM->__seen is clear, pass + __stdio_close to __stdio_reopen. + + * misc/Makefile (install-lib): Add libg.a. + ($(objpfx)libg.a): New rule; use make-dummy-lib. + (lib): Depend on $(objpfx)libg.a + +Thu Jun 23 01:14:36 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * termios/termios.h (CCEQ): New macro. + + * sysdeps/unix/sysv/irix4/__getgrps.c: Add missing __ to fn name. + + Don't compile in absolute file names for localtime and posixrules + files if they were specified relative to $(zonedir). + * time/Makefile (installed-localtime-file, + installed-posixrules-file): Set these instead of + {localtime,posixrules}-file to the absolute file names. + ($(localtime-file), $(posixrules-file)): Change targets to + $(installed-localtime-file) and $(installed-posixrules-file). + +Wed Jun 22 15:52:26 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * hurd/Makefile (sig): Add hurdkill. + +Sat Jun 18 12:57:54 1994 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * stdio/_itoa.h (_itoa): Change type of VALUE to unsigned long long. + * stdio/_itoa.c (_itoa): Likewise. + +Thu Jun 16 01:10:41 1994 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * sysdeps/mach/hurd/dirstream.h (DIR): Replace `__filepos' member + with `__entry_ptr' and `__entry_data'. Remove `__block_size' member. + Replace `__offset' member with `__ptr', a char *; no need to include + . + * sysdeps/mach/hurd/readdir.c: Use those, new dir_readdir protocol. + * sysdeps/mach/hurd/opendir.c: Initialize new members. + Don't do io_stat to set __blocksize. + * sysdeps/mach/hurd/telldir.c: Rewritten; return DIRP->__entry_ptr. + * sysdeps/mach/hurd/seekdir.c: Rewritten; just set DIRP->__entry_ptr + from arg, and zero DIRP->__size so a new block will be read. + + * sysdeps/mach/hurd/getcwd.c: Use new dir_readdir protocol. + + * hurd/msgstub.c: Add stubs for dir_changed, file_changed. + + * hurd/hurdsock.c (_hurd_socket_server): Removed unused label. + + * sysdeps/mach/hurd/__getdents.c: Use new dir_readdir protocol. + + * sysdeps/mach/hurd/__access.c: Open the file with 0 flags and + then use file_check_access to discover what we are allowed. + +Tue Jun 14 14:10:03 1994 Brendan Kehoe (brendan@zen.org) + + * sysdeps/mips/setjmp.S: Refer to `$fp', not `fp'. + +Tue Jun 14 00:50:54 1994 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * sysdeps/mach/hurd/__pipe.c: Set FDS[1], not FDS[2]. + +Mon Jun 13 06:48:48 1994 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * sysdeps/unix/bsd/sun/sparc/sigtramp.c (trampoline): Use a + comment instead of a pointless insn to reference %0 in final asm. + + * hurd/hurdsock.c (_hurd_socket_server): If realloc fails, don't + fail; just don't cache the port. + Look up the server node only if it is not in the cache. + Translate errno only if path_lookup fails. + (init): New function, on _hurd_preinit_hook. + + * sysdeps/mach/hurd/__symlink.c: Complement _hurd_umask before ANDing. + +Sat Jun 11 12:52:28 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * sysdeps/mach/hurd/__fork.c: Can't insert dead name rights into child. + +Sat Jun 11 05:19:47 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * sysdeps/mach/hurd/i386/longjmp-ts.c: Set TS->uesp instead of + TS->esp. Set TS->eip. + + * gnu-stabs.h (bss_set_element): New macro. + * hurd/dtable.c: Use bss_set_element instead of data_set_element + to put _hurd_dtable_lock in the _hurd_fork_locks set. + +Fri Jun 10 02:04:51 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * sysdeps/mach/hurd/__fork.c: Don't apply MACH_PORT_TYPE to result + from __mach_port_names. Unlock SS->lock before return. + Check for KERN_NAME_EXISTS from mach_port_allocate_name when + creating a receive right and possibly ignore it. + + * sysdeps/unix/sysv/sco3.2.4/Dist: Add sco_getgrp.S. + + * crypt/speeds.c: Include signal.h and stdio.h first thing. + [! SIGVTALRM]: Define NO_ITIMER. + + * sysdeps/unix/sysv/isc3/direct.h: New file. + + * hurd/hurdinline.c: Include lock-intern.h before #define + _EXTERN_INLINE. + + * sysdeps/mach/hurd/__fork.c (_hurd_fork_locks): Don't be const. + (__fork): Set SS from _hurd_self_sigstate so it is never null. + New local flag PORTS_LOCKED records when we have spin_locked all + the _hurd_ports cells; unlock them if necessary on error. + + * hurd/hurdsig.c (_hurd_siglock): Don't initialize it. + (_hurdsig_init): Initialize _hurd_siglock at runtime. + +Wed Jun 8 12:22:27 1994 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * hurd/hurdid.c (_hurd_check_ids): Zero P->nuids and P->ngids after + deallocating P->uids and P->ngids. + + * hurd/hurdioctl.c (_hurd_ioctl_handler_lists): Make defn initialized. + + * sysdeps/mach/hurd/__ioctl.c: Only try to unpack if IOC_OUT is set. + + * hurd/Makefile (routines): Replace $(inlines) with hurdinline. + (inlines): Variable and rule removed. + (generate-inlines): Variable removed. + * hurd/hurdinline.c: New file. + +Tue Jun 7 01:58:20 1994 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * Makerules: Add -f to all mv commands missing it. + + * hurd/Makefile (generate-inline): New canned sequence. + (inline-%.c): Use it. + + * time/asia, time/europe, time/northamerica: New versions from ADO. + +Mon Jun 6 21:36:04 1994 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * hurd/hurdid.c (init_id): New function. + + * Makerules (+make-deps): Put first s cmd before $(sed-remove-objpfx). + (sed-remove-objpfx): Replace occurrences at beginning of line too. + Sun Jun 5 14:34:12 1994 Roland McGrath (roland@geech.gnu.ai.mit.edu) * Version 1.08.1. @@ -7750,7 +9606,7 @@ * sysdeps/rs6000/memcopy.h (WORD_COPY_BWD): Add asm output specs (were missing completely). - * sysdeps/generic/memcpy.c,memmove.c: Make DSTP and SRCP unsigned + * sysdeps/generic/{memcpy.c,memmove.c}: Make DSTP and SRCP unsigned (safer with non-ANSI compilers). Fri Feb 14 01:52:12 1992 Roland McGrath (roland@wookumz.gnu.ai.mit.edu) diff -ruN glibc-1.08.1/INSTALL glibc-1.09/INSTALL --- glibc-1.08.1/INSTALL Mon Feb 7 18:24:45 1994 +++ glibc-1.09/INSTALL Sun Nov 6 22:07:29 1994 @@ -27,15 +27,23 @@ alpha-dec-osf1 i386-ANYTHING-bsd4.3 i386-ANYTHING-gnu + i386-ANYTHING-isc2.2 + i386-ANYTHING-isc3.N i386-ANYTHING-sco3.2 i386-ANYTHING-sco3.2v4 i386-ANYTHING-sysv i386-ANYTHING-sysv4 + i386-force_cpu386-none i386-sequent-bsd + i960-nindy960-none m68k-hp-bsd4.3 - m68k-sony-newsos + m68k-mvme135-none + m68k-mvme136-none + m68k-sony-newsos3 + m68k-sony-newsos4 m68k-sun-sunos4.N mips-dec-ultrix4.N + mips-sgi-irix4.N sparc-sun-solaris2.N sparc-sun-sunos4.N @@ -58,7 +66,10 @@ `--with-gnu-ld' Use this option if you plan to use GNU `ld' to link programs with - the GNU C Library. (We strongly recommend that you do.) + the GNU C Library. (We strongly recommend that you do.) This + option enables use of features that exist only in GNU `ld'; so if + you configure for GNU `ld' you must use GNU `ld' *every time* you + link with the GNU C Library, and when building it. `--with-gnu-as' Use this option if you plan to use the GNU assembler, `gas', when @@ -116,6 +127,16 @@ change, copy the definition from `Makeconfig' to your new `configparms' file, and change the value as appropriate for your system. + It is easy to configure the GNU C library for cross-compilation by +setting a few variables in `configparms'. Set `CC' to the +cross-compiler for the target you configured the library for; it is +important to use this same `CC' value when running `configure', like +this: `CC=TARGET-gcc configure TARGET'. Set `BUILD_CC' to the compiler +to use for for programs run on the build system as part of compiling +the library. You may need to set `AR' and `RANLIB' to cross-compiling +versions of `ar' and `ranlib' if the native tools are not configured to +work with object files for the target you configured for. + Some of the machine-dependent code for some machines uses extensions in the GNU C compiler, so you may need to compile the library with GCC. (In fact, all of the existing complete ports require GCC.) @@ -802,4 +823,10 @@ Sun Microsystems, Inc. 2550 Garcia Avenue Mountain View, California 94043 + + * The port to SGI machines running Irix 4 (`mips-sgi-irix4') was + contributed by Tom Quinn. + + * The port of the Mach and Hurd code to the MIPS architecture + (`mips-ANYTHING-gnu') was contribued by Kazumoto Kojima. diff -ruN glibc-1.08.1/Make-dist glibc-1.09/Make-dist --- glibc-1.08.1/Make-dist Wed May 18 22:44:29 1994 +++ glibc-1.09/Make-dist Tue Nov 1 06:35:55 1994 @@ -31,26 +31,32 @@ ifndef sysdep_dirs # Find all sysdep directories. -export sysdep_dirs := $(shell find $(..)sysdeps -type d -print) +export sysdep_dirs := $(shell find $(..)sysdeps -type d ! -name RCS -print) else # Defined by the parent. sysdep_dirs := $(addprefix $(..),$(sysdep_dirs)) endif +sysdep-Subdir-files := $(wildcard $(addsuffix /Subdirs,$(sysdep_dirs))) +ifdef sysdep-Subdir-files +subdirs := $(sort $(subdirs) \ + $(shell sed -e 's/\#.*$$//' $(sysdep-Subdir-files))) +endif + + # Makefiles can define `source_dirs' to list nonstandard directories # where source files might be found. ifdef subdir all-headers = $(headers) else -+distinfo := $(shell MAKEFLAGS= MFLAGS= $(MAKE) -s no_deps=t no_ir=t \ - echo-distinfo | grep -v '^make') ++distinfo := $(shell MAKEFLAGS= MFLAGS= $(MAKE) -s no_deps=t \ + inhibit_interface_rules=t inhibit_mach_syscalls=t \ + subdirs='$(subdirs)' echo-distinfo | grep -v '^make') +foo:=$(shell echo>&2 '+distinfo=$(+distinfo)') all-headers := $(patsubst +header+%,%,$(filter +header+%,$(+distinfo))) -# Filter out the generated rpc headers; they don't have top-level indirections. -# It is not safe to use `$(wildcard $(all-headers))' to ignore headers -# without top-level indirections because some of $(all-headers) might need -# to be found in sysdeps/. -all-headers := $(filter-out rpcsvc/%,$(all-headers)) +# Ignore subdir headers without top-level indirections. +all-headers := $(sort $(headers) $(wildcard $(all-headers))) +subdir-nodist := $(patsubst +nodist+%,%,$(filter +nodist+%,$(+distinfo))) +subdir-headers := $(filter-out $(headers),$(all-headers)) endif @@ -92,6 +98,8 @@ $(+sysdeps) foo:=$(shell echo made +tsrcs >&2) foo:=$(shell echo generated='$(generated)' >&2) +generated := $(sort $(generated) $(generated:.S=.c) $(generated:.s=.c)) +foo:=$(shell echo now generated='$(generated)' >&2) +tsrcs := $(sort $(filter-out $(generated),$(+tsrcs))) foo:=$(shell echo '+tsrcs=$(+tsrcs)'>&2) foo:=$(shell echo foobie, dammit! >&2) @@ -140,12 +148,9 @@ foo:=$(shell echo parent foobie>&2) +sysdep-distfiles := $(wildcard $(addsuffix /Dist,$(sysdep_dirs))) foo:=$(shell echo +sysdep-distfiles='$(+sysdep-distfiles)'>&2) -sysdep-Subdir-files := $(wildcard $(addsuffix /Subdirs,$(sysdep_dirs))) -ifdef sysdep-Subdir-files -subdirs := $(sort $(subdirs) $(shell cat $(sysdep-Subdir-files))) -endif +sysdep-dist := $(foreach file,$(+sysdep-distfiles),\ - $(addprefix $(dir $(file)),$(shell cat $(file)))) \ + $(addprefix $(dir $(file)), \ + $(shell sed -e 's/\#.*$$//' $(file)))) \ $(+sysdep-distfiles) \ $(sysdep-Subdir-files) foo:=$(shell echo '+sysdep-dist=$(+sysdep-dist)' >&2) @@ -161,7 +166,7 @@ %/configure: %/configure.in autoconf $(ACFLAGS) $< > $@.new - mv $@.new $@ + mv -f $@.new $@ .PHONY: dist dist: $(tardir).tar.gz $(tardir)-crypt.tar.gz @@ -187,7 +192,7 @@ %.gz: % gzip -9 -v -c $< > $@ -foo:=$(shell echo 'subdirs=$(subdirs)' >&2) +foo:=$(shell echo subdirs=$(subdirs) >&2) dist-subdirs := $(addprefix dist-,$(subdirs)) # dist-manual .PHONY: subdir_dist $(dist-subdirs) subdir_dist: $(dist-subdirs) diff -ruN glibc-1.08.1/MakeTAGS glibc-1.09/MakeTAGS --- glibc-1.08.1/MakeTAGS Thu May 13 01:03:10 1993 +++ glibc-1.09/MakeTAGS Mon Sep 26 22:59:53 1994 @@ -1,6 +1,6 @@ # Make the TAGS files. -# Copyright (C) 1992 Free Software Foundation, Inc. +# Copyright (C) 1992, 1994 Free Software Foundation, Inc. # This file is part of the GNU C Library. # The GNU C Library is free software; you can redistribute it and/or @@ -18,6 +18,9 @@ # not, write to the Free Software Foundation, Inc., 675 Mass Ave, # Cambridge, MA 02139, USA. +# Make this the default goal. +TAGS: + ifdef subdir .. := ../ endif @@ -38,26 +41,31 @@ sysdep-dirs := $(addprefix $(sysdep_dir)/,$(sysdirs)) +ifndef sysdep_dirs +# Find all sysdep directories. +sysdep_dirs := $(shell find $(..)sysdeps -type d ! -name RCS -print) +endif + # Find all sysdep dirs there are, but putting the ones # we are configured to use first and preserving their order. all-dirs := $(objdir) \ $(sysdep-dirs) \ $(source_dirs) \ - $(filter-out $(sysdep-dirs),\ - $(patsubst ./%,%,\ - $(shell find $(sysdep_dir) -type d -print)\ - )) + $(filter-out $(sysdep-dirs),$(sysdep_dirs)) # Find all the subdirs there are, but putting the ones # we are configured to use first and preserving their order. ifndef subdir subdirs := $(subdirs) \ $(filter-out $(subdirs),\ - $(shell cat $(wildcard $(addsuffix /Subdirs,\ + $(shell sed -e 's/\#.*$$//' \ + $(wildcard $(addsuffix /Subdirs,\ $(all-dirs)))\ /dev/null)) -all-dist = $(shell cat /dev/null $(wildcard $(filter %.c %.h %.S %.s,\ - $(all-dirs:%=%/Dist)))) +all-dist = $(foreach Dist,$(wildcard $(all-dirs:%=%/Dist)),\ + $(addprefix $(Dist:%/Dist=%)/,\ + $(filter %.c %.h %.S %.s,\ + $(shell cat $(Dist))))) tags_sources = $(all-sources) $(all-headers) $(all-dist) endif diff -ruN glibc-1.08.1/Makeconfig glibc-1.09/Makeconfig --- glibc-1.08.1/Makeconfig Wed May 4 00:17:51 1994 +++ glibc-1.09/Makeconfig Mon Aug 15 20:48:02 1994 @@ -143,7 +143,7 @@ # Where to install machine-independent data files. # These are the timezone database, and eventually the locale database. ifndef datadir -datadir = $(prefix)/lib +datadir = $(prefix)/share endif # Where to install the timezone data files (which are machine-independent). @@ -156,6 +156,11 @@ bindir = $(exec_prefix)/bin endif +# Where to install administrative programs. +ifndef sbindir +sbindir = $(exec_prefix)/sbin +endif + # Where to install the Info files. ifndef infodir infodir = $(prefix)/info @@ -163,8 +168,8 @@ # Where to install default configuration files. These include the local # timezone specification and network data base files. -ifndef etcdir -etcdir = $(prefix)/etc +ifndef sysconfdir +sysconfdir = $(prefix)/etc endif # What timezone should be the installed default (e.g., US/Eastern). @@ -180,7 +185,7 @@ # other than there, so the zoneinfo directory contains only universal data, # localizing the configuration data elsewhere. ifndef localtime-file -localtime-file = $(etcdir)/localtime +localtime-file = $(sysconfdir)/localtime endif # What timezone's DST rules should be used when a POSIX-style TZ @@ -229,8 +234,8 @@ # The name of the C compiler to use for compilations of programs to run on # the host that is building the library. If you set CC to a # cross-compiler, you must set this to the normal compiler. -ifndef HOST_CC -HOST_CC = $(CC) +ifndef BUILD_CC +BUILD_CC = $(CC) endif # Default flags to pass the C compiler. @@ -263,12 +268,8 @@ RANLIB = ranlib endif -# Define non-empty if the C compiler understands -v (print version). -+cc_version = $(filter gcc,$(notdir $(firstword $(CC)))) # if using gcc - # Extra flags to pass to GCC. +gccwarn := -Wall -Wwrite-strings -Wno-parentheses -+gccopt := -fstrength-reduce # This is the program that generates makefile # dependencies from C source files. @@ -324,10 +325,7 @@ # If using gcc, add flags that only it will grok. ifneq "$(findstring gcc,$(CC))" "" +cflags := $(+cflags) $(+gccwarn) -ifneq "$(filter -O,$(+cflags))" "" -+cflags := $(+cflags) $(+gccopt) +gcc-nowarn := -w -endif else +gcc-nowarn := endif # gcc @@ -336,27 +334,17 @@ +cflags := $(sort $(+cflags)) -ifneq "$(findstring v,$(MAKEFLAGS))" "" # if -v -ifneq "$(strip $(+cc_version))" "" -# If Make is telling us version info, tell the compiler to do so as well. -CC := $(CC) -v -endif # +cc_version -endif # -v - # These are flags given to the C compiler to tell it to look for include # files (including ones given in angle brackets) in the current directory # and in the parent library source directory. # `+sysdep-includes' will be defined by Makerules. -ifneq "$(..)" "" -+includes = -I. -I$(patsubst %/,%,$(..)) $(includes) $(+sysdep-includes) -else -+includes = -I. $(includes) $(+sysdep-includes) -endif ++includes = -I. $(filter-out -I,-I$(patsubst %/,%,$(..))) \ + $(includes) $(+sysdep-includes) $(last-includes) # These are the variables that the implicit compilation rules use. -CPPFLAGS = $(+includes) $(+defines) -D_LIBC -override CFLAGS = $(+cflags) +CPPFLAGS = $(+includes) $(+defines) -D_LIBC $(sysdep-CPPFLAGS) +override CFLAGS = $(+cflags) $(sysdep-CFLAGS) # This is the macro that the implicit linking rules use. @@ -373,8 +361,10 @@ gnu-as := yes endif -ifneq ($(HOST_CC),$(CC)) -cross-compiling = yes +ifneq ($(BUILD_CC),$(CC)) +cross-compiling := yes +else +cross-compiling := no endif diff -ruN glibc-1.08.1/Makefile glibc-1.09/Makefile --- glibc-1.08.1/Makefile Mon Apr 4 23:10:55 1994 +++ glibc-1.09/Makefile Tue Oct 25 21:50:00 1994 @@ -33,7 +33,7 @@ %/configure: %/configure.in autoconf $(ACFLAGS) $< > $@.new - mv $@.new $@ + mv -f $@.new $@ include Makeconfig @@ -90,7 +90,7 @@ $(objpfx)munch-init.c: munch.awk munch-tmpl.c $(+subdir_inits) awk -f $< subdirs='$(+init_subdirs)' $(word 2,$^) > $@-t - mv $@-t $@ + mv -f $@-t $@ generated := $(generated) munch-init.c endif @@ -127,12 +127,12 @@ (echo define sysdep-subdirs; \ for dir in $(sysdirs); do \ if [ -r $(sysdep_dir)/$$dir/Subdirs ]; then \ - cat $(sysdep_dir)/$$dir/Subdirs; \ + sed 's/#.*$$//' $(sysdep_dir)/$$dir/Subdirs; \ else true; \ fi; \ done; \ echo endef) > $@-tmp - mv $@-tmp $@ + mv -f $@-tmp $@ # Makerules creates a file `stub-$(subdir)' for each subdirectory, which # contains `#define __stub_FUNCTION' for each function which is a stub. @@ -236,5 +236,10 @@ README: README.template version.c ; # Make-dist should update README. -INSTALL: manual/maint.texi - makeinfo --no-validate --no-warn --no-headers $< -o $@ +define format-me +@rm -f $@ +makeinfo --no-validate --no-warn --no-headers $< -o $@ +-chmod a-w $@ +endef +INSTALL: manual/maint.texi; $(format-me) +NOTES: manual/creature.texi; $(format-me) diff -ruN glibc-1.08.1/Makerules glibc-1.09/Makerules --- glibc-1.08.1/Makerules Tue May 10 20:02:28 1994 +++ glibc-1.09/Makerules Thu Nov 3 18:50:16 1994 @@ -94,7 +94,7 @@ else true; fi; \ done; \ echo 'sysd-Makefile-done=t') > $@T - mv $@T $@ + mv -f $@T $@ # Reorder before-compile so that mach things come first, and hurd things @@ -124,13 +124,13 @@ # later directory would be chosen over a .c file in an earlier directory, # which does not preserve the desired sysdeps ordering behavior. -# When making the list of .dep files to include, we can't know which ones -# have source in .s files, and thus do not in fact need a .dep file. -# So we must define rules to make .dep files for .s files. +# When making the list of .d files to include, we can't know which ones +# have source in .s files, and thus do not in fact need a .d file. +# So we must define rules to make .d files for .s files. define make-dummy-dep -$(addprefix ln $(objpfx)dummy.dep ,$(filter-out $(wildcard $@),$@)) +$(addprefix ln $(objpfx)dummy.d ,$(filter-out $(wildcard $@),$@)) endef -$(objpfx)dummy.dep: +$(objpfx)dummy.d: echo '# .s files cannot contain includes, so they need no deps.' > $@ # It matters that this set of rules, for compiling from sources in @@ -139,11 +139,11 @@ # compiling in the source tree, generated sources go into the current # directory, and those should be chosen before any sources in sysdeps. $(objpfx)%.o: %.S $(before-compile); $(compile-command.S) -$(objpfx)%.dep: %.S $(before-compile); $(+make-deps) +$(objpfx)%.d: %.S $(before-compile); $(+make-deps) $(objpfx)%.o: %.s $(before-compile); $(compile-command.s) -$(objpfx)%.dep: %.s $(objpfx)dummy.dep; $(make-dummy-dep) +$(objpfx)%.d: %.s $(objpfx)dummy.d; $(make-dummy-dep) $(objpfx)%.o: %.c $(before-compile); $(compile-command.c) -$(objpfx)%.dep: %.c $(before-compile); $(+make-deps) +$(objpfx)%.d: %.c $(before-compile); $(+make-deps) # Omit the objpfx rules when building in the source tree, because # objpfx is empty and so these rules just override the ones above. @@ -151,11 +151,11 @@ # Define first rules to find the source files in $(objpfx). # Generated source files will end up there. $(objpfx)%.o: $(objpfx)%.S $(before-compile); $(compile-command.S) -$(objpfx)%.dep: $(objpfx)%.S $(before-compile); $(+make-deps) +$(objpfx)%.d: $(objpfx)%.S $(before-compile); $(+make-deps) $(objpfx)%.o: $(objpfx)%.s $(before-compile); $(compile-command.s) -$(objpfx)%.dep: $(objpfx)%.s $(objpfx)dummy.dep; $(make-dummy-dep) +$(objpfx)%.d: $(objpfx)%.s $(objpfx)dummy.d; $(make-dummy-dep) $(objpfx)%.o: $(objpfx)%.c $(before-compile); $(compile-command.c) -$(objpfx)%.dep: $(objpfx)%.c $(before-compile); $(+make-deps) +$(objpfx)%.d: $(objpfx)%.c $(before-compile); $(+make-deps) endif # System-dependent makefiles can put in `inhibit-sysdep-asm' wildcard @@ -183,18 +183,18 @@ $(open-check-inhibit-asm) \ echo "\$$(objpfx)%.o: $$dir/%.S \$$(before-compile); \ \$$(compile-command.S)"; \ - echo "\$$(objpfx)%.dep: $$dir/%.S \$$(before-compile); \ + echo "\$$(objpfx)%.d: $$dir/%.S \$$(before-compile); \ \$$(+make-deps)"; \ echo "\$$(objpfx)%.o: $$dir/%.s \$$(before-compile); \ \$$(compile-command.s)"; \ - echo "\$$(objpfx)%.dep: $$dir/%.s \$$(objpfx)dummy.dep; \ + echo "\$$(objpfx)%.d: $$dir/%.s \$$(objpfx)dummy.d; \ \$$(make-dummy-dep)" $(close-check-inhibit-asm); \ echo "\$$(objpfx)%.o: $$dir/%.c \$$(before-compile); \ \$$(compile-command.c)"; \ - echo "\$$(objpfx)%.dep: $$dir/%.c \$$(before-compile); \ + echo "\$$(objpfx)%.d: $$dir/%.c \$$(before-compile); \ \$$(+make-deps)"; \ done) > $@T - mv $@T $@ + mv -f $@T $@ ifndef compile-command.S compile-command.S = $(compile.S) $(OUTPUT_OPTION) @@ -208,10 +208,10 @@ ifeq ($(notdir $(firstword $(CC))),gcc) # GCC can grok options after the file name, and it looks nicer that way. -compile.S = $(CC) $< -c $(CPPFLAGS) $(asm-CPPFLAGS) +compile.S = $(CC) $< -c $(CPPFLAGS) -DASSEMBLER $(asm-CPPFLAGS) compile.c = $(CC) $< -c $(CFLAGS) $(CPPFLAGS) else -compile.S = $(COMPILE.S) $(asm-CPPFLAGS) $< +compile.S = $(COMPILE.S) -DASSEMBLER $(asm-CPPFLAGS) $< compile.c = $(COMPILE.c) $< endif @@ -228,28 +228,30 @@ define +make-deps -@rm -f $@ $(+mkdep) $< $(CPPFLAGS) $($(<:$*.%=%)-CPPFLAGS) | \ -sed $(sed-remove-objpfx) -e 's,$*\.o,$(@:.dep=.o) $@,' > $(@:.dep=.dtm) -mv $(@:.dep=.dtm) $@ +sed -e 's,$*\.o,$(@:.d=.o) $@,' $(sed-remove-objpfx) > $(@:.d=.T) +mv -f $(@:.d=.T) $@ endef ifneq (,$(objpfx)) -sed-remove-objpfx = -e 's@ $(subst @,\@,$(objpfx))@ $$(objpfx)@g' +sed-remove-objpfx = -e 's@ $(subst @,\@,$(objpfx))@ $$(objpfx)@g' \ + -e 's@^$(subst @,\@,$(objpfx))@$$(objpfx)@g' endif # Figure out the source filenames in this directory. -override sources := $(addsuffix .c,$(routines) $(aux) \ - $(sysdep_routines)) +override sources := $(addsuffix .c,$(filter-out $(elided-routines),\ + $(routines) $(aux) \ + $(sysdep_routines))) sysdep_routines := $(sysdep_routines) # This is the list of all object files, gotten by # replacing every ".c" in `sources' with a ".o". override objects := $(addprefix $(objpfx),$(sources:.c=.o)) -+depfiles := $(strip $(sources:.c=.dep) \ - $(patsubst %.o,%.dep,$(filter %.o,$(extra-objs))) \ - $(addsuffix .dep,$(others) $(tests))) ++depfiles := $(strip $(sources:.c=.d) \ + $(patsubst %.o,%.d,$(filter %.o,$(extra-objs))) \ + $(addsuffix .d,$(others) $(tests))) +depfiles := $(addprefix $(objpfx),\ - $(filter-out $(addsuffix .dep,$(omit-deps)),\ + $(filter-out $(addsuffix .d,$(omit-deps)),\ $(+depfiles))) $(objpfx)depend-$(subdir): Makefile @@ -270,7 +272,7 @@ # Maximize efficiency by minimizing the number of rules. .SUFFIXES: # Clear the suffix list. # Add the suffixes we use. -.SUFFIXES: .a .o .S .s .c .h .dep +.SUFFIXES: .a .o .S .s .c .h .d # Generic rule for making directories. %/: @@ -341,8 +343,16 @@ # files in $(install-lib) matching `lib%.a' are ranlib'd after installation # unless they also appear in $(non-lib.a). $(install-data) are installed # as they are into $(datadir). $(headers) are installed as they are in -# $(includedir). $(install-others) are absolute path names of files to -# install; rules to install them are defined elsewhere. +# $(includedir). $(install-bin) and $(install-sbin) are installed from the +# object directory into $(bindir) and $(sbindir), respectively. +# $(install-others) are absolute path names of files to install; rules to +# install them are defined elsewhere. + +# The simple library name to install libc.a under. +# This could be defined by a sysdep Makefile. +ifndef libc-name +libc-name := c +endif define do-install $(make-target-directory) @@ -362,21 +372,26 @@ # should install libc.a; this way "make install" in a subdir is guaranteed # to install everything it changes. ifdef objects -install: $(libdir)/lib$(libprefix)c.a +install: $(libdir)/lib$(libprefix)$(libc-name).a # We avoid depending on lib-noranlib because that makes the parent make # subdir_lib in all the subdirs, when the make install run they do will # update the library anyway. Running ranlib after installing makes the # __.SYMDEF time stamp up to date, which avoids messages from some linkers. # Depending on subdir_install gets all the subdirs to update the library, # and is optimal for `make install' at top level. -$(libdir)/lib$(libprefix)c.a: libobjs subdir_install +$(libdir)/lib$(libprefix)$(libc-name).a: libobjs subdir_install $(make-target-directory) $(INSTALL_DATA) $(libc.a) $@ $(RANLIB) $@ endif -ifdef install -$(addprefix $(bindir)/,$(install)): $(bindir)/%: $(objpfx)% +ifdef install-bin +$(addprefix $(bindir)/,$(install-bin)): $(bindir)/%: $(objpfx)% + $(make-target-directory) + $(INSTALL_PROGRAM) $< $@ +endif +ifdef install-sbin +$(addprefix $(sbindir)/,$(install-sbin)): $(sbindir)/%: $(objpfx)% $(make-target-directory) $(INSTALL_PROGRAM) $< $@ endif @@ -404,9 +419,10 @@ $(includedir)/%: %;$(do-install) endif # headers -.PHONY: install-bin-nosubdir install-lib-nosubdir \ +.PHONY: install-bin-nosubdir install-sbin-nosubdir install-lib-nosubdir \ install-data-nosubdir install-headers-nosubdir -install-bin-nosubdir: $(addprefix $(bindir)/,$(install)) +install-bin-nosubdir: $(addprefix $(bindir)/,$(install-bin)) +install-sbin-nosubdir: $(addprefix $(sbindir)/,$(install-sbin)) install-lib-nosubdir: $(addprefix $(libdir)/,\ $(patsubst lib%.a,lib$(libprefix)%.a,$(install-lib.a)) \ $(addprefix $(libprefix),$(install-lib-non.a))) @@ -423,29 +439,29 @@ .PHONY: install install-no-libc.a-nosubdir install-no-libc.a-nosubdir: install-headers-nosubdir install-data-nosubdir\ install-bin-nosubdir install-lib-nosubdir \ - install-others-nosubdir + install-others-nosubdir install-sbin-nosubdir install: install-no-libc.a-nosubdir # Command to compile $< in $(objdir) using the native libraries. define native-compile -cwd=`pwd`; cd $(@D); $(HOST_CC) $(native-CFLAGS) \ +cwd=`pwd`; cd $(@D); $(BUILD_CC) $(BUILD_CFLAGS) \ $(addprefix $$cwd/,$^) -o $(@F) endef # Command to compile $< in $(common-objdir) using the native libraries. define common-objdir-compile -cd $(@D); $(HOST_CC) $(native-CFLAGS) $(<:$(common-objpfx)%=%) -o $(@F) +cd $(@D); $(BUILD_CC) $(BUILD_CFLAGS) $(<:$(common-objpfx)%=%) -o $(@F) endef # We always want to use configuration -D switches. -native-CFLAGS = $(config-defines) +BUILD_CFLAGS = $(config-defines) # Support the GNU standard name for this target. .PHONY: check check: tests .PHONY: TAGS -TAGS: distfile $(..)MakeTAGS +TAGS: distinfo $(..)MakeTAGS $(MAKE) $(addprefix -f ,$^) .PHONY: echo-headers @@ -462,7 +478,8 @@ # Remove the object files. common-mostlyclean: -rm -f $(addprefix $(objpfx),$(tests) $(others) \ - $(addsuffix .o,$(tests) $(others))) + $(addsuffix .o,$(tests) $(others)) \ + $(addsuffix .out,$(tests))) -rm -f $(objects) $(addprefix $(objpfx),$(extra-objs) stamp-$(subdir)) -rm -f core TAGS @@ -472,7 +489,7 @@ -rm -f $(addprefix $(objpfx),$(generated)) # Produce a file `stub-$(subdir)' which contains `#define __stub_FUNCTION' -# for each function which is a stub. We grovel over all the .dep files +# for each function which is a stub. We grovel over all the .d files # looking for references to source files in sysdeps/stub. Then we grovel # over each referenced source file to see what stub function it defines. @@ -480,11 +497,12 @@ stubs: $(common-objpfx)stub-$(subdir) $(common-objpfx)stub-$(subdir): $(+depfiles) # Use /dev/null since `...` might expand to empty. + $(patsubst %,cd %;,$(objdir)) \ sed -n 's/^stub_warning *(\([^)]*\).*$$/#define __stub_\1/p' \ `sed -n 's@^.*\($(sysdep_dir)/stub/[a-z0-9_]*\.c\).*$$@\1@p' \ - $^ /dev/null` \ + $(patsubst $(objpfx)%,%,$^) /dev/null` \ /dev/null > $@T - mv $@T $@ + mv -f $@T $@ # Make the distribution tar file. @@ -503,9 +521,11 @@ mv -f $@.new $@ define distinfo-vars -$(foreach var,subdir sources sysdep_routines headers distribute \ +rm -f $@.new +$(foreach var,subdir sources elided-routines headers distribute \ dont_distribute generated others tests, echo >> $@.new '$(var) := $($(var))') +echo >> $@.new 'sources := $$(sources) $$(addsuffix .c,$$(elided-routines))' endef ifneq (,$(strip $(gpl2lgpl))) diff -ruN glibc-1.08.1/NEWS glibc-1.09/NEWS --- glibc-1.08.1/NEWS Mon May 16 15:41:16 1994 +++ glibc-1.09/NEWS Tue Oct 11 01:13:39 1994 @@ -1,9 +1,40 @@ -GNU C Library NEWS -- history of user-visible changes. 16 May 1994 +GNU C Library NEWS -- history of user-visible changes. 10 October 1994 Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc. See the end for copying conditions. Please send GNU C library bug reports to bug-glibc@prep.ai.mit.edu. + +Version 1.09 + +* For cross-compilation you should now set `BUILD_CC' instead of `HOST_CC'. + +* New header file and new functions `getfsspec', `getfsent' and + friends, for parsing /etc/fstab. This code comes from 4.4 BSD. + +* The new function `daemon' from 4.4 BSD is useful for server programs that + want to put themselves in the background. + +* Joel Sherrill has contributed support for several standalone boards that + run without an operating system. + +* `printf', `scanf' and friends now accept a `q' type modifier for long + long int as well as `ll'. Formats using these might be `%qu' or `%lld'. + +* All of the code taken from BSD (notably most of the math and networking + routines) has been updated from the BSD 4.4-Lite release. + +* The resolver code has been updated from the BIND-4.9.3-BETA9 release. + +* The new functions `getdomainname' and `setdomainname' fetch or change the + YP/NIS domain name. These are system calls which exist on systems which + have YP (aka NIS). + +* The time zone data files have been updated for the latest international + conventions. + +* The SunRPC programs `portmap' and `rpcinfo' are now installed in + $(sbindir) (usually /usr/local/sbin) instead of $(bindir). Version 1.08 diff -ruN glibc-1.08.1/NOTES glibc-1.09/NOTES --- glibc-1.08.1/NOTES Mon Feb 17 01:42:47 1992 +++ glibc-1.09/NOTES Tue Oct 25 21:52:27 1994 @@ -1,33 +1,37 @@ Feature Test Macros --------------------- +------------------- The exact set of features available when you compile a source file is controlled by which "feature test macros" you define. If you compile your programs using `gcc -ansi', you get only the ANSI C library features, unless you explicitly request additional -features by defining one or more of the feature macros. *Note -Options: (gcc.info)Options, for more information about GCC options. +features by defining one or more of the feature macros. *Note GNU CC +Command Options: (gcc.info)Invoking GCC, for more information about GCC +options. You should define these macros by using `#define' preprocessor -directives at the top of your source code files. You could also use -the `-D' option to GCC, but it's better if you make the source files -indicate their own meaning in a self-contained way. +directives at the top of your source code files. These directives +*must* come before any `#include' of a system header file. It is best +to make them the very first thing in the file, preceded only by +comments. You could also use the `-D' option to GCC, but it's better +if you make the source files indicate their own meaning in a +self-contained way. - -- Macro: _POSIX_SOURCE + - Macro: _POSIX_SOURCE If you define this macro, then the functionality from the POSIX.1 - standard (IEEE Standard 1003.1) is available, as well as all of - the ANSI C facilities. + standard (IEEE Standard 1003.1) is available, as well as all of the + ANSI C facilities. - -- Macro: _POSIX_C_SOURCE + - Macro: _POSIX_C_SOURCE If you define this macro with a value of `1', then the functionality from the POSIX.1 standard (IEEE Standard 1003.1) is made available. If you define this macro with a value of `2', then both the functionality from the POSIX.1 standard and the - functionality from the POSIX.2 standard (IEEE Standard 1003.2) - are made available. This is in addition to the ANSI C facilities. + functionality from the POSIX.2 standard (IEEE Standard 1003.2) are + made available. This is in addition to the ANSI C facilities. - -- Macro: _BSD_SOURCE + - Macro: _BSD_SOURCE If you define this macro, functionality derived from 4.3 BSD Unix is included as well as the ANSI C, POSIX.1, and POSIX.2 material. @@ -36,14 +40,25 @@ macro is defined, the 4.3 BSD definitions take precedence over the POSIX definitions. - -- Macro: _SVID_SOURCE + Due to the nature of some of the conflicts between 4.3 BSD and + POSIX.1, you need to use a special "BSD compatibility library" + when linking programs compiled for BSD compatibility. This is + because some functions must be defined in two different ways, one + of them in the normal C library, and one of them in the + compatibility library. If your program defines `_BSD_SOURCE', you + must give the option `-lbsd-compat' to the compiler or linker when + linking the program, to tell it to find functions in this special + compatibility library before looking for them in the normal C + library. + + - Macro: _SVID_SOURCE If you define this macro, functionality derived from SVID is included as well as the ANSI C, POSIX.1, and POSIX.2 material. - -- Macro: _GNU_SOURCE + - Macro: _GNU_SOURCE If you define this macro, everything is included: ANSI C, POSIX.1, - POSIX.2, BSD, SVID, and GNU extensions. In the cases where - POSIX.1 conflicts with BSD, the POSIX definitions take precedence. + POSIX.2, BSD, SVID, and GNU extensions. In the cases where POSIX.1 + conflicts with BSD, the POSIX definitions take precedence. If you want to get the full effect of `_GNU_SOURCE' but make the BSD definitions take precedence over the POSIX definitions, use @@ -53,23 +68,28 @@ #define _BSD_SOURCE #define _SVID_SOURCE + Note that if you do this, you must link your program with the BSD + compatibility library by passing the `-lbsd-compat' option to the + compiler or linker. *Note:* If you forget to do this, you may get + very strange errors at run time. + We recommend you use `_GNU_SOURCE' in new programs. If you don't specify the `-ansi' option to GCC and don't define any of these macros -explicitly, the effect as the same as defining `_GNU_SOURCE'. +explicitly, the effect is the same as defining `_GNU_SOURCE'. When you define a feature test macro to request a larger class of features, it is harmless to define in addition a feature test macro for a subset of those features. For example, if you define -`_POSIX_C_SOURCE', then defining `_POSIX_SOURCE' as well has no -effect. Likewise, if you define `_GNU_SOURCE', then defining either +`_POSIX_C_SOURCE', then defining `_POSIX_SOURCE' as well has no effect. +Likewise, if you define `_GNU_SOURCE', then defining either `_POSIX_SOURCE' or `_POSIX_C_SOURCE' or `_SVID_SOURCE' as well has no effect. - Note, however, that the features of `_BSD_SOURCE' are not a subset -of any of the other feature test macros supported. This is because it + Note, however, that the features of `_BSD_SOURCE' are not a subset of +any of the other feature test macros supported. This is because it defines BSD features that take precedence over the POSIX features that are requested by the other macros. For this reason, defining -`_BSD_SOURCE' in addition to the other feature test macros does have -an effect: it causes the BSD features to take priority over the -conflicting POSIX features. +`_BSD_SOURCE' in addition to the other feature test macros does have an +effect: it causes the BSD features to take priority over the conflicting +POSIX features. diff -ruN glibc-1.08.1/README glibc-1.09/README --- glibc-1.08.1/README Sun Jun 5 22:19:13 1994 +++ glibc-1.09/README Sun Nov 6 22:27:26 1994 @@ -1,19 +1,25 @@ -This directory contains the version 1.08.1 test release of the GNU C Library. +This directory contains the version 1.09 test release of the GNU C Library. Many bugs have been fixed since the last release. Some bugs surely remain. As of this release, the GNU C library has been ported to the following configurations: - alpha-dec-osf1 (mostly finished) + alpha-dec-osf1 i386-bsd4.3 + i386-force_cpu386-none i386-gnu (for Hurd development only) + i386-isc2.2 + i386-isc3 i386-sco3.2 i386-sco3.2v4 - i386-sequent-dynix + i386-sequent-bsd i386-sysv i386-sysv4 + i960-nindy960-none m68k-hp-bsd4.3 + m68k-mvme135-none + m68k-mvme136-none m68k-sony-newsos3 m68k-sony-newsos4 m68k-sun-sunos4 @@ -31,7 +37,7 @@ Because of the United States export restriction on DES implementations, we are distributing this code separately from the rest of the C library. There is an extra distribution tar file just for crypt; it is -called `glibc-1.08.1-crypt.tar.gz'. You can just unpack the crypt +called `glibc-1.09-crypt.tar.gz'. You can just unpack the crypt distribution along with the rest of the C library and build; you can also build the library without getting crypt. Users outside the USA can get the crypt distribution via anonymous FTP from ftp.uni-c.dk diff -ruN glibc-1.08.1/Rules glibc-1.09/Rules --- glibc-1.08.1/Rules Wed May 4 00:15:50 1994 +++ glibc-1.09/Rules Mon Aug 15 20:58:47 1994 @@ -72,7 +72,11 @@ .PHONY: others tests others: $(addprefix $(objpfx),$(others)) +ifeq ($(cross-compiling),yes) +tests: $(addprefix $(objpfx),$(tests)) +else tests: $(tests:%=$(objpfx)%.out) +endif ifneq "$(strip $(others) $(tests))" "" $(addprefix $(objpfx),$(others) $(tests)): %: %.o $(libc.a) diff -ruN glibc-1.08.1/arpa/nameser.h glibc-1.09/arpa/nameser.h --- glibc-1.08.1/arpa/nameser.h Mon Mar 29 13:06:08 1993 +++ glibc-1.09/arpa/nameser.h Mon Aug 8 18:50:31 1994 @@ -1 +1 @@ -#include +#include diff -ruN glibc-1.08.1/assert/Makefile glibc-1.09/assert/Makefile --- glibc-1.08.1/assert/Makefile Wed Jun 12 18:00:36 1991 +++ glibc-1.09/assert/Makefile Tue Nov 1 06:53:28 1994 @@ -1,4 +1,4 @@ -# Copyright (C) 1991 Free Software Foundation, Inc. +# Copyright (C) 1991, 1994 Free Software Foundation, Inc. # This file is part of the GNU C Library. # The GNU C Library is free software; you can redistribute it and/or @@ -21,6 +21,6 @@ # subdir := assert -routines := assert +routines := assert assert-perr include ../Rules diff -ruN glibc-1.08.1/assert/assert-perr.c glibc-1.09/assert/assert-perr.c --- glibc-1.08.1/assert/assert-perr.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/assert/assert-perr.c Thu Nov 3 18:49:21 1994 @@ -0,0 +1,55 @@ +/* Copyright (C) 1994 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include +#include + + +extern const char *__assert_program_name; /* In assert.c. */ + +/* This function, when passed an error number, a filename, and a line + number, prints a message on the standard error stream of the form: + a.c:10: foobar: Unexpected error: Computer bought the farm + It then aborts program execution via a call to `abort'. */ + +__NORETURN int +__assert_perror_fail (int errnum, + const char *file, unsigned int line, + const char *function) +{ +#ifdef FATAL_PREPARE + FATAL_PREPARE; +#endif + + /* Print the message. */ + (void) fprintf (stderr, "%s%s%s:%u: %s%sUnexpected error: %s.\n", + __assert_program_name ? __assert_program_name : "", + __assert_program_name ? ": " : "", + file, line, + function ? function : "", function ? ": " : "", + strerror (errnum)); + (void) fflush (stderr); + + abort (); + + /* This function never returns, so making it void would make sense, + but returning something makes the assert macro easier to write. */ + return 0; +} diff -ruN glibc-1.08.1/assert/assert.h glibc-1.09/assert/assert.h --- glibc-1.08.1/assert/assert.h Fri Feb 11 14:11:43 1994 +++ glibc-1.09/assert/assert.h Wed Oct 19 19:52:04 1994 @@ -30,13 +30,24 @@ #define _ASSERT_H 1 #include -/* void assert(int expression); +/* void assert (int expression); + If NDEBUG is defined, do nothing. If not, and EXPRESSION is zero, print an error message and abort. */ #ifdef NDEBUG -#define assert(expr) ((void) 0) +#define assert(expr) ((void) 0) + +/* void assert_perror (int errnum); + + If NDEBUG is defined, do nothing. If not, and ERRNUM is not zero, print an + error message with the error text for ERRNUM and abort. + (This is a GNU extension.) */ + +#ifdef __USE_GNU +#define assert_perror(errnum) ((void) 0) +#endif #else /* Not NDEBUG. */ @@ -50,12 +61,25 @@ unsigned int __line, __const char *__function)); +/* Likewise, but prints the error text for ERRNUM. */ +extern __NORETURN int __assert_perror_fail __P ((int __errnum, + __const char *__file, + unsigned int __line, + __const char *__function)); + __END_DECLS #define assert(expr) \ ((void) ((expr) || __assert_fail (__STRING(expr), \ __FILE__, __LINE__, __ASSERT_FUNCTION))) +#ifdef __USE_GNU +#define assert_perror(errnum) \ + ((void) ((errnum) && __assert_perror_fail ((errnum), \ + __FILE__, __LINE__, \ + __ASSERT_FUNCTION))) +#endif + /* Version 2.4 and later of GCC define a magical variable `__PRETTY_FUNCTION__' which contains the name of the function currently being defined. This is broken in G++ before version 2.6. */ @@ -65,6 +89,7 @@ #else #define __ASSERT_FUNCTION __PRETTY_FUNCTION__ #endif + #endif /* NDEBUG. */ diff -ruN glibc-1.08.1/bare/Makefile glibc-1.09/bare/Makefile --- glibc-1.08.1/bare/Makefile Wed Dec 31 19:00:00 1969 +++ glibc-1.09/bare/Makefile Thu Sep 1 23:20:47 1994 @@ -0,0 +1,55 @@ +# Copyright (C) 1994 Free Software Foundation, Inc. +# Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil), +# On-Line Applications Research Corporation. +# +# This file is part of the GNU C Library. +# +# The GNU C Library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Library General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# The GNU C Library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public +# License along with the GNU C Library; see the file COPYING.LIB. If +# not, write to the Free Software Foundation, Inc., 675 Mass Ave, +# Cambridge, MA 02139, USA. + +subdir := bare + +bare-routines := brdinit console strtsupp +routines = $(bare-routines) +elided-routines = $(bare-routines) +extra-objs = $(bare-routines:%=%.o) + +install-lib = lib$(config-vendor).a + +include ../Rules + +# +# For bare targets, the $(config-vendor) is the name of the board. +# We will place the board dependent code ONLY in a library which +# is board dependent. This way many target boards can share a +# single libc.a. To resolve all symbols and successfully link +# a program, the application must link against libc.a and libMY_TARGET.a. +# For example, the target specific library for the Motorola MVME135 +# board will be named libmvme135.a. To link a program for the +# MVME135, one must link against -lc and -lmvme135. +# + +lib: $(objpfx)lib$(config-vendor).a + +$(objpfx)lib$(config-vendor).a: $(bare-routines:%=$(objpfx)%.o) +# This library is small enough that it's simplest to recreate the archive +# from scratch each time. + rm -f $@ +ifdef objdir + cd $(objdir); $(AR) cq$(verbose) $@ $(^:$(objpfx)%=%) +else + $(AR) cq$(verbose) $@ $^ +endif + $(RANLIB) $@ diff -ruN glibc-1.08.1/config.guess glibc-1.09/config.guess --- glibc-1.08.1/config.guess Tue May 10 16:54:16 1994 +++ glibc-1.09/config.guess Tue Nov 1 14:23:22 1994 @@ -1,5 +1,5 @@ #!/bin/sh -# This script attempts to guess a canonical system name. +# Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc. # # This file is free software; you can redistribute it and/or modify it @@ -14,8 +14,15 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. +# Written by Per Bothner . +# The master version of this file is at the FSF in /home/gd/gnu/lib. # # This script attempts to guess a canonical system name similar to # config.sub. If it succeeds, it prints the system name on stdout, and @@ -28,6 +35,12 @@ # (but try to keep the structure clean). # +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi@noc.rutgers.edu 8/24/94.) +if (test -f /.attbin/uname) >/dev/null 2>&1 ; then + PATH=$PATH:/.attbin ; export PATH +fi + UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown @@ -38,17 +51,24 @@ # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in - alpha:OSF1:1.*:*) + alpha:OSF1:V*:*) + # After 1.2, OSF1 uses "V1.3" for uname -r. + echo alpha-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^V//'` + exit 0 ;; + alpha:OSF1:*:*) # 1.2 uses "1.2" for uname -r. echo alpha-dec-osf${UNAME_RELEASE} exit 0 ;; - alpha:OSF1:V1.*:*) - # 1.3 uses "V1.3" for uname -r. - echo alpha-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^V//'` - exit 0 ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit 0;; + Pyramid*:OSx*:*:*) + if test "`(/bin/universe) 2>/dev/null`" = att ; then + echo pyramid-pyramid-sysv3 + else + echo pyramid-pyramid-bsd + fi + exit 0 ;; sun4*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; @@ -59,7 +79,8 @@ echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; sun4*:SunOS:*:*) - echo sparc-sun-sunos${UNAME_RELEASE} + # Japanese Language versions have a version number like `4.1.3-JL'. + echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit 0 ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} @@ -73,6 +94,9 @@ mips:*:5*:RISCos) echo mips-mips-riscos${UNAME_RELEASE} exit 0 ;; + m88k:CX/UX:7*:*) + echo m88k-harris-cxux7 + exit 0 ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit 0 ;; @@ -80,8 +104,16 @@ echo m88k-motorola-sysv3 exit 0 ;; AViiON:dgux:*:*) - echo m88k-dg-dgux${UNAME_RELEASE} + if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx \ + -o ${TARGET_BINARY_INTERFACE}x = x ] ; then + echo m88k-dg-dgux${UNAME_RELEASE} + else + echo m88k-dg-dguxbcs${UNAME_RELEASE} + fi exit 0 ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + echo m88k-dolphin-sysv3 + exit 0 ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 @@ -100,6 +132,19 @@ exit 0 ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + sed 's/^ //' << EOF >dummy.c + #include + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + ${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0 + rm -f dummy.c dummy echo rs6000-ibm-aix3.2.5 elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 @@ -107,6 +152,21 @@ echo rs6000-ibm-aix3.2 fi exit 0 ;; + *:AIX:*:4) + if /usr/sbin/lsattr -EHl proc0 | grep POWER >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if grep bos410 /usr/include/stdio.h >/dev/null 2>&1; then + IBM_REV=4.1 + elif grep bos411 /usr/include/stdio.h >/dev/null 2>&1; then + IBM_REV=4.1.1 + else + IBM_REV=4.${UNAME_RELEASE} + fi + echo ${IBM_ARCH}-ibm-aix${IBM_REV} + exit 0 ;; *:AIX:*:*) echo rs6000-ibm-aix exit 0 ;; @@ -122,18 +182,14 @@ hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit 0 ;; - 9000/[3478]??:HP-UX:*:* | 9000/8?7:HP-UX:*:* ) + 9000/[3478]??:HP-UX:*:*) case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/7?? | 9000/8?7 ) HP_ARCH=hppa1.1 ;; 9000/8?? ) HP_ARCH=hppa1.0 ;; esac - case ${UNAME_RELEASE} in - *.B7.* ) HPUX_REV=7 ;; - *.B8.* | *.08.* ) HPUX_REV=8 ;; - *.09.* ) HPUX_REV=9 ;; - esac + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit 0 ;; 3050*:HI-UX:*:*) @@ -143,9 +199,10 @@ main () { long cpu = sysconf (_SC_CPU_VERSION); - if (CPU_IS_HP_MC68K (cpu)) - puts ("m68k-hitachi-hiuxwe2"); - else if (CPU_IS_PA_RISC (cpu)) + /* The order matters, because CPU_IS_HP_MC68K erroneously returns + true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct + results, however. */ + if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { @@ -155,6 +212,8 @@ default: puts ("hppa-hitachi-hiuxwe2"); break; } } + else if (CPU_IS_HP_MC68K (cpu)) + puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } @@ -169,11 +228,29 @@ 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit 0 ;; - C1*:ConvexOS:*:* | convex:ConvexOS:C1:*) + hp7??:OSF1:*:* | hp8?7:OSF1:*:* ) + echo hppa1.1-hp-osf + exit 0 ;; + hp8??:OSF1:*:*) + echo hppa1.0-hp-osf + exit 0 ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit 0 ;; - C2*:ConvexOS:*:* | convex:ConvexOS:C2:*) - echo c2-convex-bsd + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit 0 ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + echo c34-convex-bsd + exit 0 ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + echo c38-convex-bsd + exit 0 ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + echo c4-convex-bsd exit 0 ;; CRAY*X-MP:UNICOS:*:*) echo xmp-cray-unicos @@ -187,16 +264,27 @@ hp3[0-9][05]:NetBSD:*:*) echo m68k-hp-netbsd${UNAME_RELEASE} exit 0 ;; - i[34]86:FreeBSD:*:*) - echo ${UNAME_MACHINE}-unknown-freebsd + i[34]86:BSD/386:*:*) + echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + exit 0 ;; + *:FreeBSD:*:*) + echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit 0 ;; - i[34]86:NetBSD:*:*) - echo ${UNAME_MACHINE}-unknown-netbsd${UNAME_RELEASE} + *:NetBSD:*:*) + echo ${UNAME_MACHINE}-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` exit 0 ;; - i[34]86:Linux:*:*) + *:GNU:*:*) + echo `echo ${UNAME_MACHINE}|sed -e 's,/.*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + exit 0 ;; + *:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux exit 0 ;; - i[34]86:UNIX_SV:4.*:* | i[34]86:SYSTEM_V:4.*:*) +# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. earlier versions +# are messed up and put the nodename in both sysname and nodename. + i[34]86:DYNIX/ptx:4*:*) + echo i386-sequent-sysv4 + exit 0 ;; + i[34]86:*:4.*:* | i[34]86:SYSTEM_V:4.*:*) if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_RELEASE} else @@ -208,35 +296,68 @@ UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')` (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486 echo ${UNAME_MACHINE}-unknown-sco$UNAME_REL + elif test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' /dev/null 2>&1 ; then + echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + fi + exit 0 ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit 0 ;; M680[234]0:*:R3V[567]*:*) test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; - 3[34]??:*:4.0:* | 3[34]??,3[34]??:*:4.0:*) - uname -p 2>/dev/null | grep 86 >/dev/null \ - && echo i486-ncr-sysv4 && exit 0 ;; + 3[34]??:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0) + uname -p 2>/dev/null | grep 86 >/dev/null \ + && echo i486-ncr-sysv4.3 && exit 0 ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + uname -p 2>/dev/null | grep 86 >/dev/null \ + && echo i486-ncr-sysv4 && exit 0 ;; m680[234]0:LynxOS:2.2*:*) echo m68k-lynx-lynxos${UNAME_RELEASE} exit 0 ;; + mc68030:UNIX_System_V:4.*:*) + echo m68k-atari-sysv4 + exit 0 ;; i[34]86:LynxOS:2.2*:*) echo i386-lynx-lynxos${UNAME_RELEASE} exit 0 ;; TSUNAMI:LynxOS:2.2*:*) echo sparc-lynx-lynxos${UNAME_RELEASE} exit 0 ;; + rs6000:LynxOS:2.2*:*) + echo rs6000-lynx-lynxos${UNAME_RELEASE} + exit 0 ;; + RM*:SINIX-*:*:*) + echo mips-sni-sysv4 + exit 0 ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + echo ${UNAME_MACHINE}-sni-sysv4 + else + echo ns32k-sni-sysv + fi + exit 0 ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 cat >dummy.c </dev/null`; - if (version==2) - { - printf("%s-next-ns2\n", __ARCHITECTURE__); - exit(0); - } - else - { - printf("%s-next-ns3\n", __ARCHITECTURE__); - exit(0); - } + printf ("%s-next-nextstep%s\n", __ARCHITECTURE__, version==2 ? "2" : "3"); + exit (0); #endif #if defined (MULTIMAX) || defined (n16) #if defined (UMAXV) - printf("ns32k-encore-sysv\n"); exit(0); + printf ("ns32k-encore-sysv\n"); exit (0); #else #if defined (CMU) - printf("ns32k-encore-mach\n"); exit(0); + printf ("ns32k-encore-mach\n"); exit (0); #else - printf("ns32k-encore-bsd\n"); exit(0); + printf ("ns32k-encore-bsd\n"); exit (0); #endif #endif #endif -#if defined(__386BSD__) || (defined(__bsdi__) && defined(__i386__)) - printf("i386-unknown-bsd\n"); exit(0); +#if defined (__386BSD__) + printf ("i386-unknown-bsd\n"); exit (0); #endif -#if defined(sequent) -#if defined(i386) - printf("i386-sequent-dynix\n"); exit(0); +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); #endif #if defined (ns32000) - printf("ns32k-sequent-dynix\n"); exit(0); + printf ("ns32k-sequent-dynix\n"); exit (0); #endif #endif -#if defined(_SEQUENT_) - printf("i386-sequent-ptx\n"); exit(0); +#if defined (_SEQUENT_) + printf ("i386-sequent-ptx\n"); exit (0); #endif -#if defined(vax) -#if !defined(ultrix) - printf("vax-dec-bsd\n"); exit(0); +#if defined (vax) +#if !defined (ultrix) + printf ("vax-dec-bsd\n"); exit (0); #else - printf("vax-dec-ultrix\n"); exit(0); + printf ("vax-dec-ultrix\n"); exit (0); #endif #endif +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + exit (1); } EOF @@ -321,6 +438,32 @@ # Apollos put the system type in the environment. test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } + +# Convex versions that predate uname can use getsysinfo(1) + +if [ -x /usr/convex/getsysinfo ] +then + case `getsysinfo -f cpu_type` in + c1*) + echo c1-convex-bsd + exit 0 ;; + c2*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit 0 ;; + c34*) + echo c34-convex-bsd + exit 0 ;; + c38*) + echo c38-convex-bsd + exit 0 ;; + c4*) + echo c4-convex-bsd + exit 0 ;; + esac +fi #echo '(Unable to guess system type)' 1>&2 diff -ruN glibc-1.08.1/config.sub glibc-1.09/config.sub --- glibc-1.08.1/config.sub Fri May 20 01:18:20 1994 +++ glibc-1.09/config.sub Wed Oct 26 14:23:05 1994 @@ -4,21 +4,25 @@ # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software # can handle that machine. It does not imply ALL GNU software can. - -#This file is free software; you can redistribute it and/or modify -#it under the terms of the GNU General Public License as published by -#the Free Software Foundation; either version 2 of the License, or -#(at your option) any later version. - -#This program is distributed in the hope that it will be useful, -#but WITHOUT ANY WARRANTY; without even the implied warranty of -#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -#GNU General Public License for more details. - -#You should have received a copy of the GNU General Public License -#along with this program; if not, write to the Free Software -#Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. @@ -64,7 +68,7 @@ ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ - -unicom* | -ibm* | -next* | -hp | -isi* | -apollo | -altos* | \ + -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp ) @@ -103,16 +107,23 @@ -lynx) os=-lynxos ;; + -ptx*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + ;; + -windowsnt*) + os=`echo $os | sed -e 's/windowsnt/winnt/'` + ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. - tahoe | i[34]86 | i860 | m68k | m68000 | m88k | ns32k | arm | pyramid \ + tahoe | i[345]86 | i860 | m68k | m68000 | m88k | ns32k | arm | pyramid \ | tron | a29k | 580 | i960 | h8300 | hppa1.0 | hppa1.1 \ | alpha | we32k | ns16k | clipper | sparclite | i370 | sh \ - | powerpc) + | powerpc | sparc64 | 1750a | dsp16xx | mips64 | mipsel \ + | pdp11 | mips64el | mips64orion | mips64orionel ) basic_machine=$basic_machine-unknown ;; # Object if more than one company name word. @@ -121,13 +132,14 @@ exit 1 ;; # Recognize the basic CPU types with company name. - vax-* | tahoe-* | i[34]86-* | i860-* | m68k-* | m68000-* | m88k-* \ + vax-* | tahoe-* | i[345]86-* | i860-* | m68k-* | m68000-* | m88k-* \ | sparc-* | ns32k-* | fx80-* | arm-* | c[123]* \ | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \ | none-* | 580-* | cray2-* | h8300-* | i960-* | xmp-* | ymp-* \ | hppa1.0-* | hppa1.1-* | alpha-* | we32k-* | cydra-* | ns16k-* \ | pn-* | np1-* | xps100-* | clipper-* | orion-* | sparclite-* \ - | sh-* | powerpc-*) + | pdp11-* | sh-* | powerpc-* | sparc64-* | mips64-* | mipsel-* \ + | mips64el-* | mips64orion-* | mips64orionel-* ) ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. @@ -151,7 +163,7 @@ basic_machine=580-amdahl os=-sysv ;; - amiga) + amiga | amiga-*) basic_machine=m68k-cbm ;; amigados) @@ -201,7 +213,10 @@ crds | unos) basic_machine=m68k-crds ;; - decstation | decstation-3100 | pmax | pmin | dec3100 | decstatn) + da30 | da30-*) + basic_machine=m68k-da30 + ;; + decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; delta | 3300 | motorola-3300 | motorola-delta \ @@ -253,6 +268,9 @@ basic_machine=m88k-harris os=-sysv3 ;; + hp300-*) + basic_machine=m68k-hp + ;; hp300bsd) basic_machine=m68k-hp os=-bsd @@ -278,19 +296,19 @@ os=-mvs ;; # I'm not sure what "Sysv32" means. Should this be sysv3.2? - i[34]86v32) + i[345]86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-unknown/'` os=-sysv32 ;; - i[34]86v4*) + i[345]86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-unknown/'` os=-sysv4 ;; - i[34]86v) + i[345]86v) basic_machine=`echo $1 | sed -e 's/86.*/86-unknown/'` os=-sysv ;; - i[34]86sol2) + i[345]86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-unknown/'` os=-solaris2 ;; @@ -322,6 +340,12 @@ miniframe) basic_machine=m68000-convergent ;; + mips3*-*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + ;; + mips3*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown + ;; ncr3000) basic_machine=i486-ncr os=-sysv4 @@ -338,13 +362,16 @@ basic_machine=mips-sony os=-newsos ;; - next) + next | m*-next ) basic_machine=m68k-next case $os in + -nextstep* ) + ;; -ns2*) + os=-nextstep2 ;; *) - os=-ns3 + os=-nextstep3 ;; esac ;; @@ -377,9 +404,14 @@ pbb) basic_machine=m68k-tti ;; - pc532) + pc532 | pc532-*) basic_machine=ns32k-pc532 ;; + pentium-*) + # We will change tis to say i586 once there has been + # time for various packages to start to recognize that. + basic_machine=i486-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; pn) basic_machine=pn-gould ;; @@ -389,6 +421,9 @@ rtpc | rtpc-*) basic_machine=romp-ibm ;; + sequent) + basic_machine=i386-sequent + ;; sh) basic_machine=sh-hitachi os=-hms @@ -427,7 +462,7 @@ basic_machine=sparc-sun os=-sunos4 ;; - sun3) + sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) @@ -489,6 +524,9 @@ vax) basic_machine=vax-dec ;; + pdp11) + basic_machine=pdp11-dec + ;; we32k) basic_machine=we32k-att ;; @@ -534,18 +572,22 @@ -solaris) os=-solaris2 ;; + -gnu/linux*) + os=`echo $os | sed -e 's|gnu/linux|linux|'` + ;; # First accept the basic system types. # The portable systems comes first. # Each alternative must end in a *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ - | -vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]* \ + | -vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[345]* \ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ | -amigados* | -msdos* | -newsos* | -unicos* | -aos* \ | -nindy* | -vxworks* | -ebmon* | -hms* | -mvs* | -clix* \ | -riscos* | -linux* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -netbsd* | -freebsd* | -riscix* \ - | -lynxos* | -bosx* | -ns* | -cxux*) + | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* \ + | -ptx* | -coff* | -winnt*) ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` @@ -617,6 +659,9 @@ *-acorn) os=-riscix1.2 ;; + pdp11-*) + os=-none + ;; *-dec | vax-*) os=-ultrix4.2 ;; @@ -656,11 +701,14 @@ *-dolphin) os=-sysv3 ;; + m68k-ccur) + os=-rtu + ;; m88k-omron*) os=-luna ;; *-sequent) - os=-bsd + os=-ptx ;; *-crds) os=-unos @@ -672,10 +720,7 @@ os=-mvs ;; *-next) - os=-bsd - ;; - i[34]86-*) - os=-sco3.2v2 + os=-nextstep3 ;; *-gould) os=-sysv @@ -736,6 +781,9 @@ ;; -mvs*) vendor=ibm + ;; + -ptx*) + vendor=sequent ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` diff -ruN glibc-1.08.1/configure glibc-1.09/configure --- glibc-1.08.1/configure Fri May 20 20:48:05 1994 +++ glibc-1.09/configure Thu Oct 27 14:54:58 1994 @@ -244,8 +244,10 @@ # Make sco3.2v4 become sco3.2.4 and sunos4.1.1_U1 become sunos4.1.1.U1. os="`echo $os | sed 's/\([0-9A-Z]\)[v_]\([0-9A-Z]\)/\1.\2/g'`" +# Expand the configuration machine name into a subdirectory by architecture +# type and particular chip. case "$machine" in -i[34]86) +i[345]86) machine=i386/$machine ;; sparc[6789]) machine=sparc/$machine ;; @@ -274,6 +276,8 @@ base_os=unix/sysv ;; solaris[2-9]*) base_os=unix/sysv/sysv4 ;; +none) + base_os=standalone ;; esac case "$os:$base_os" in @@ -347,8 +351,14 @@ sysnames="`echo $sysnames | sed -e 's@^/@@' -e 's@ /@ @g'`" # Prepend the machine's FPU directory unless --nfp. -if [ ! "$nfp" -a -d $sysdep_dir/$machine/fpu ]; then - sysnames="${machine}/fpu $sysnames" +if [ ! "$nfp" ]; then + fpu_dirs= + for m in $mach; do + if [ -d $sysdep_dir$m/fpu ]; then + fpu_dirs="$fpu_dirs $m/fpu" + fi + done + sysnames="`echo $fpu_dirs | sed -e 's,^/,,' -e 's, /,,g'` $sysnames" fi # Expand the list of system names into a full list of directories @@ -413,7 +423,6 @@ for dir in $sysnames; do echo " $dir"; done - # Make sure to not get the incompatible SysV /etc/install and # /usr/sbin/install, which might be in PATH before a BSD-like install, # or the SunOS /usr/etc/install directory, or the AIX /bin/install, @@ -478,6 +487,10 @@ test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' test -n "$verbose" && echo " setting INSTALL_DATA to $INSTALL_DATA" +if [ "$INSTALL" = "${srcdir}/install.sh" ]; then + # The makefiles need to use a different form to find it in $srcdir. + INSTALL='$(..)./install.sh' +fi if test -z "$RANLIB"; then # Extract the first word of `ranlib', so it can be a program name with args. set ac_dummy ranlib; ac_word=$2 diff -ruN glibc-1.08.1/configure.in glibc-1.09/configure.in --- glibc-1.08.1/configure.in Fri May 20 20:42:31 1994 +++ glibc-1.09/configure.in Fri Aug 26 01:33:02 1994 @@ -189,8 +189,10 @@ # Make sco3.2v4 become sco3.2.4 and sunos4.1.1_U1 become sunos4.1.1.U1. os="`echo $os | sed 's/\([0-9A-Z]\)[v_]\([0-9A-Z]\)/\1.\2/g'`" +# Expand the configuration machine name into a subdirectory by architecture +# type and particular chip. case "$machine" in -i[34]86) +i[345]86) machine=i386/$machine ;; sparc[6789]) machine=sparc/$machine ;; @@ -219,6 +221,8 @@ base_os=unix/sysv ;; solaris[2-9]*) base_os=unix/sysv/sysv4 ;; +none) + base_os=standalone ;; esac case "$os:$base_os" in @@ -292,8 +296,14 @@ sysnames="`echo $sysnames | sed -e 's@^/@@' -e 's@ /@ @g'`" # Prepend the machine's FPU directory unless --nfp. -if [ ! "$nfp" -a -d $sysdep_dir/$machine/fpu ]; then - sysnames="${machine}/fpu $sysnames" +if [ ! "$nfp" ]; then + fpu_dirs= + for m in $mach; do + if [ -d $sysdep_dir$m/fpu ]; then + fpu_dirs="$fpu_dirs $m/fpu" + fi + done + sysnames="`echo $fpu_dirs | sed -e 's,^/,,' -e 's, /,,g'` $sysnames" fi # Expand the list of system names into a full list of directories @@ -360,9 +370,11 @@ changequote([,])dnl The world is now safe for m4, and unsafe for shell. dnl Be sure to add each macro used here to aclocal.m4 (which see). -dnl Without this hack, AC_PROG_INSTALL will expand ${srcdir} in the name. -define([AC_PROG_INSTALL_INSTALL_SH], ['$(..)install.sh -c']) AC_PROG_INSTALL +[if [ "$INSTALL" = "${srcdir}/install.sh" ]; then + # The makefiles need to use a different form to find it in $srcdir. + INSTALL='$(..)./install.sh' +fi] AC_PROG_RANLIB AC_PROG_CC diff -ruN glibc-1.08.1/ctype/test_ctype.c glibc-1.09/ctype/test_ctype.c --- glibc-1.08.1/ctype/test_ctype.c Tue Jul 16 22:48:29 1991 +++ glibc-1.09/ctype/test_ctype.c Mon Jul 18 18:00:19 1994 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1994 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -22,6 +22,10 @@ #include #include +#define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#define XOR(e,f) (((e) && !(f)) || (!(e) && (f))) + #ifdef __GNUC__ __inline #endif @@ -39,41 +43,50 @@ DEFUN(main, (argc, argv), int argc AND char **argv) { register unsigned short int c; + int lose = 0; - for (c = 0; c <= UCHAR_MAX; ++c) { - print_char(c); - if (isascii(c)) - fputs(" isascii", stdout); - if (isalnum(c)) - fputs(" isalnum", stdout); - if (isalpha(c)) - fputs(" isalpha", stdout); - if (iscntrl(c)) - fputs(" iscntrl", stdout); - if (isdigit(c)) - fputs(" isdigit", stdout); - if (isgraph(c)) - fputs(" isgraph", stdout); - if (islower(c)) - fputs(" islower", stdout); - if (isprint(c)) - fputs(" isprint", stdout); - if (ispunct(c)) - fputs(" ispunct", stdout); - if (isspace(c)) - fputs(" isspace", stdout); - if (isupper(c)) - fputs(" isupper", stdout); - if (isxdigit(c)) - fputs(" isxdigit", stdout); - if (isblank(c)) - fputs(" isblank", stdout); - fputs("; lower = ", stdout); - print_char(tolower(c)); - fputs("; upper = ", stdout); - print_char(toupper(c)); - putchar('\n'); - } + for (c = 0; c <= UCHAR_MAX; ++c) + { + print_char (c); + + if (XOR (islower (c), ISLOWER (c)) || toupper (c) != TOUPPER (c)) + { + fputs (" BOGUS", stdout); + ++lose; + } + + if (isascii(c)) + fputs(" isascii", stdout); + if (isalnum(c)) + fputs(" isalnum", stdout); + if (isalpha(c)) + fputs(" isalpha", stdout); + if (iscntrl(c)) + fputs(" iscntrl", stdout); + if (isdigit(c)) + fputs(" isdigit", stdout); + if (isgraph(c)) + fputs(" isgraph", stdout); + if (islower(c)) + fputs(" islower", stdout); + if (isprint(c)) + fputs(" isprint", stdout); + if (ispunct(c)) + fputs(" ispunct", stdout); + if (isspace(c)) + fputs(" isspace", stdout); + if (isupper(c)) + fputs(" isupper", stdout); + if (isxdigit(c)) + fputs(" isxdigit", stdout); + if (isblank(c)) + fputs(" isblank", stdout); + fputs("; lower = ", stdout); + print_char(tolower(c)); + fputs("; upper = ", stdout); + print_char(toupper(c)); + putchar('\n'); + } - exit(EXIT_SUCCESS); + exit (lose ? EXIT_FAILURE : EXIT_SUCCESS); } diff -ruN glibc-1.08.1/dirent/Makefile glibc-1.09/dirent/Makefile --- glibc-1.08.1/dirent/Makefile Wed Dec 22 17:55:46 1993 +++ glibc-1.09/dirent/Makefile Wed Oct 26 03:30:47 1994 @@ -1,4 +1,4 @@ -# Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. +# Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc. # This file is part of the GNU C Library. # The GNU C Library is free software; you can redistribute it and/or @@ -27,6 +27,6 @@ getdents __getdents distribute := direct.h -tests := list +tests := list tst-seekdir include ../Rules diff -ruN glibc-1.08.1/dirent/dirent.h glibc-1.09/dirent/dirent.h --- glibc-1.08.1/dirent/dirent.h Thu Jan 6 10:32:10 1994 +++ glibc-1.09/dirent/dirent.h Thu Sep 29 05:42:47 1994 @@ -33,7 +33,7 @@ /* Directory entry structure. This structure is laid out identically to the `struct direct' that - represents directory entries in the GNU Hurd and in BSD Unix (and + represents directory entries in the GNU Hurd and in BSD 4.4 (and incidentally, on disk in the Berkeley fast file system). The `readdir' implementations for GNU and BSD know this; you must change them if you change this structure. */ @@ -42,7 +42,8 @@ { __ino_t d_fileno; /* File serial number. */ unsigned short int d_reclen; /* Length of the whole `struct dirent'. */ - unsigned short int d_namlen; /* Length of the file name. */ + unsigned char d_type; /* File type, possibly unknown. */ + unsigned char d_namlen; /* Length of the file name. */ /* Only this member is in the POSIX standard. */ char d_name[1]; /* File name (actually longer). */ @@ -51,6 +52,26 @@ #if defined(__USE_BSD) || defined(__USE_MISC) #define d_ino d_fileno /* Backward compatibility. */ #endif + +#ifdef __USE_BSD +/* File types for `d_type'. */ +enum + { + DT_UNKNOWN = 0, + DT_FIFO = 1, + DT_CHR = 2, + DT_DIR = 4, + DT_BLK = 6, + DT_REG = 8, + DT_LNK = 10, + DT_SOCK = 12 + }; + +/* Convert between stat structure types and directory types. */ +#define IFTODT(mode) (((mode) & 0170000) >> 12) +#define DTTOIF(dirtype) ((dirtype) << 12) +#endif + /* Get the system-dependent definition of `DIR', the data type of directory stream objects. */ diff -ruN glibc-1.08.1/dirent/scandir.c glibc-1.09/dirent/scandir.c --- glibc-1.08.1/dirent/scandir.c Mon Aug 30 13:44:09 1993 +++ glibc-1.09/dirent/scandir.c Wed Sep 28 17:22:59 1994 @@ -1,4 +1,4 @@ -/* Copyright (C) 1992, 1993 Free Software Foundation, Inc. +/* Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -54,12 +54,8 @@ if (new == NULL) { lose: - (void) closedir (dp); - while (i > 0) - free (v[--i]); - free (v); errno = ENOMEM; - return -1; + break; } v = new; } @@ -75,6 +71,9 @@ { save = errno; (void) closedir (dp); + while (i > 0) + free (v[--i]); + free (v); errno = save; return -1; } diff -ruN glibc-1.08.1/dirent/tst-seekdir.c glibc-1.09/dirent/tst-seekdir.c --- glibc-1.08.1/dirent/tst-seekdir.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/dirent/tst-seekdir.c Tue Nov 1 02:26:51 1994 @@ -0,0 +1,40 @@ +#include +#include +#include + +int +main () +{ + + DIR * dirp; + long save3; + int i = 0; + struct dirent *dp; + + dirp = opendir("."); + for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) + { + /* save position 3 (fourth entry) */ + if (i++ == 3) + save3 = telldir(dirp); + + printf("%s\n", dp->d_name); + + /* stop at 400 (just to make sure dirp->__offset and dirp->__size are + scrambled */ + if (i == 400) + break; + } + + /* go back to saved entry */ + seekdir (dirp, save3); + + + /* print remaining files (3-last) */ + for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) + printf("%s\n", dp->d_name); + + + closedir (dirp); + exit(0); +} diff -ruN glibc-1.08.1/gnu-stabs.h glibc-1.09/gnu-stabs.h --- glibc-1.08.1/gnu-stabs.h Sat Mar 14 22:51:57 1992 +++ glibc-1.09/gnu-stabs.h Mon Jul 18 18:13:36 1994 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1992 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1992, 1994 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -33,48 +33,32 @@ #define function_alias_void(name, _name, args, defun) \ symbol_alias (_name, name); -/* Make references to ALIAS refer to SYMBOL. */ -#ifdef __STDC__ -#define symbol_alias(symbol, alias) \ - asm(".stabs \"" "_" #alias "\",11,0,0,0\n"\ - ".stabs \"" "_" #symbol "\",1,0,0,0") +#ifdef NO_UNDERSCORES +#define __SYMBOL_PREFIX #else -/* Your assembler better grok this right! */ -#define symbol_alias(symbol, alias) \ - asm(".stabs \"_/**/alias\",11,0,0,0\n.stabs \"_/**/symbol\",1,0,0,0") +#define __SYMBOL_PREFIX "_" #endif +/* Make references to ALIAS refer to SYMBOL. */ +#define symbol_alias(symbol, alias) \ + asm(".stabs \"" __SYMBOL_PREFIX #alias "\",11,0,0,0\n"\ + ".stabs \"" __SYMBOL_PREFIX #symbol "\",1,0,0,0") + /* Issue a warning message from the linker whenever SYMBOL is referenced. */ -#ifdef __STDC__ #define warn_references(symbol, msg) \ asm(".stabs \"" msg "\",30,0,0,0\n" \ - ".stabs \"_" #symbol "\",1,0,0,0") -#else -#define warn_references(symbol, msg) \ - asm(".stabs msg,30,0,0,0\n.stabs \"_/**/symbol\",1,0,0,0") -#endif + ".stabs \"" __SYMBOL_PREFIX #symbol "\",1,0,0,0") -#ifdef __STDC__ #define stub_warning(name) \ warn_references(name, \ "warning: " #name " is not implemented and will always fail") -#else -#define stub_warning(name) \ - warn_references(name, \ - "warning: name is not implemented and will always fail") -#endif -#ifdef __STDC__ #define text_set_element(set, symbol) \ - asm(".stabs \"_" #set "\",23,0,0,_" #symbol) + asm(".stabs \"" __SYMBOL_PREFIX #set "\",23,0,0," __SYMBOL_PREFIX #symbol) #define data_set_element(set, symbol) \ - asm(".stabs \"_" #set "\",25,0,0,_" #symbol) -#else -#define text_set_element(set, symbol) \ - asm(".stabs \"_/**/set\",23,0,0,_/**/symbol") -#define data_set_element(set, symbol) \ - asm(".stabs \"_/**/set\",25,0,0,_/**/symbol") -#endif + asm(".stabs \"" __SYMBOL_PREFIX #set "\",25,0,0," __SYMBOL_PREFIX #symbol) +#define bss_set_element(set, symbol) \ + asm(".stabs \"" __SYMBOL_PREFIX #set "\",27,0,0," __SYMBOL_PREFIX #symbol) #else /* No GNU stabs. */ diff -ruN glibc-1.08.1/hurd/Makefile glibc-1.09/hurd/Makefile --- glibc-1.08.1/hurd/Makefile Fri May 27 08:39:39 1994 +++ glibc-1.09/hurd/Makefile Mon Oct 24 00:25:33 1994 @@ -28,7 +28,7 @@ $(addprefix hurd/,fd.h id.h port.h signal.h userlink.h \ resource.h threadvar.h) -distribute := intr_rpc.awk hurdintr.awk +distribute := hurdfault.h intr-rpc.awk intr-rpc.defs STATUS # The RPC interfaces go in a separate library. interface-library := libhurduser.a @@ -36,35 +36,26 @@ auth process startup \ msg msg_reply msg_request \ exec core interrupt \ - fs fsys io term socket ) + fs fsys io term socket ifsock) server-interfaces := hurd/msg -routines = hurdid hurdpath hurdpid hurdports hurdrlimit \ - hurdexec \ +routines = hurdinit hurdid hurdlookup hurdpid hurdrlimit hurdprio hurdexec \ __setauth setauth \ __pid2task __task2pid pid2task task2pid \ getuids setuids getumask fchroot \ - hurdsock hurdauth \ + hurdsock hurdauth invoke-trans \ privports \ msgportdemux \ fopenport __fopenport \ vpprintf \ - $(sig) $(dtable) $(inlines) -sig = hurdsig siginfo init-fault msging-p hurd-raise preempt-sig \ - trampoline longjmp-ctx longjmp-ts catch-exc exc2signal + ports-get ports-set hurdports hurdmsg \ + $(sig) $(dtable) hurdinline +sig = hurdsig hurdfault faultexc siginfo hurd-raise preempt-sig \ + trampoline longjmp-ctx longjmp-ts catch-exc exc2signal hurdkill dtable = dtable port2fd new-fd alloc-fd intern-fd \ __getdport getdport openport \ fd-close fd-read fd-write hurdioctl -inlines = $(addprefix inline-,fd port signal userlink threadvar) -aux := hurdsyms hurdinit msgstub # hurdmsg - -# The files inline-*.c contain the real-function definitions of the -# functions defined with `extern inline' in hurd/*.h. -$(inlines:%=$(objpfx)%.c): $(objpfx)inline-%.c: - (echo '#define _EXTERN_INLINE /* Define the real function. */';\ - echo '#include "hurd/$*.h"') > $@-tmp - mv $@-tmp $@ -generated += $(inlines:%=%.c) +aux := hurdsyms # XXX this is a temporary hack; see hurdmalloc.h routines += hurdmalloc @@ -92,33 +83,36 @@ install-others += $(addprefix $(includedir)/,$(hurd-headers)) $(includedir)/hurd/%: $(hurd-srcdir)/hurd/%; $(do-install) -# Insert comment here. - -ifdef intrhack # XXX -# This rule needs to come before the implicit rules in Machrules. -__%.c: intr_rpc.awk %_rpc.c - gawk -v call=__$* -v rpc=__$*_rpc -f $^ > $@-new - mv $@-new $@ -# __%_rpc.c is made with mig by Machrules. -%_rpc.c: __%_rpc.c - sed s/MACH_MSG_OPTION_NONE/MACH_SEND_INTERRUPT/ $< > $@ -endif - include ../mach/Machrules - -ifdef intrhack # XXX -ifdef user-interfaces -include hurdintr -endif -hurdintr: hurdintr.awk $(user-interfaces:%=%.defs) - awk -f $^ varname=intr-calls > $@-new - mv $@-new $@ - -# Make the INTR user stubs be defined as CALL_rpc. -migdefines := $(migdefines) $(foreach call,$(intr-calls),-D$(call)=$(call)_rpc) - -interface-routines := $(filter-out %_rpc,$(interface-routines)) \ - $(intr-calls:%=__% %) -endif - include ../Rules + +# intr-rpc.defs defines the INTR_INTERFACE macro to make the generated RPC +# stubs send-interruptible, and to prefix them with `hurd_intr_rpc_'. +user-MIGFLAGS += -imacros intr-rpc.defs + +# Run each generated user stub through intr-rpc.awk, which will detect +# stubs __hurd_intr_rpc_% and generate the user-callable function for the +# stub: this is a wrapper which calls __hurd_intr_rpc_% inside +# HURD_EINTR_RPC. +define transform-user-stub +gawk -v call=$${call} -f $(word 2,$^) \ + $(objpfx)tmp_$${call}.c > $(objpfx)tmpi_$${call}.c; \ +rm -f $(objpfx)tmp_$${call}.c; +endef +transform-user-stub-output = tmpi + +$(foreach if,$(user-interfaces),$($(if)-calls:%=$(objpfx)RPC_%.o))): \ + hurd/signal.h + +$(user-interfaces:%=$(objpfx)%.ustamp): intr-rpc.awk + +$(objpfx)fault%.c $(objpfx)fault%.h: $(mach-srcdir)/mach/%.defs + $(MIG) $(MIGFLAGS) -prefix _hurdsig_fault_ \ + -server $(@:.h=.c) -sheader $(@:.c=.h) \ + -user /dev/null -header /dev/null \ + $< +generated += faultexc.c faultexc.h + +# We need this static dependency to get faultexc.h generated the first time. +$(objpfx)hurdfault.o $(objpfx)hurdfault.d: \ + $(objpfx)faultexc.h $(objpfx)faultexc.c diff -ruN glibc-1.08.1/hurd/STATUS glibc-1.09/hurd/STATUS --- glibc-1.08.1/hurd/STATUS Wed Dec 31 19:00:00 1969 +++ glibc-1.09/hurd/STATUS Wed Aug 24 21:15:54 1994 @@ -0,0 +1,70 @@ +Status of Hurd support in libc. Last updated 24 Aug 1994. +Roland McGrath + +Everything not noted below is implemented, most of it tested. There are +various very small things unfinished or thought to be perhaps wrong +throughout the code, marked by comments containing `XXX'. + + +* As of this writing, signal delivery works but the code is very much in flux. + +* We are not sure about possible races between setpgrp (A, pgrp) from + process B vs process A receiving proc_newids. + +* The rest of libc (stdio et al) is not safe for multithreaded programs. + mutex locks should be added to various things. + +* Recovery from faults in the signal thread is not implemented yet. + +* longjmp needs to clean up reply port, intr_port; needs thought about. + +* Cooperation with cthreads is not finished. If you link with cthreads, + libc internal code still does not use real condition variables. + sigsuspend currently does a busy wait where it should use a condition. + Signal state is per kernel thread; for unwired cthreads it should be per + cthread instead. + +* sigaltstack/sigstack do not really work: the signal stack needs thread + variables and cthread data set up, which is not done. + +* malloc is a kludge. + +* Nothing uses mapped io. Eventually stdio and read/write/seek should. I + have written a little code for this, but it is far from finished. + +* Resource limits do not really work; current implementation is patchy and + inconsistent. + +* libc implicitly uses some environment variables. This is a security + problem for setuid exec. Probably crt0 should remove the variables from + the environment if setuid. + +* The miscellaneous msg.defs calls are only partially implemented. + +* The default SIGINFO handler needs to be written. + +* File locking is not implemented; the RPC interface is not there yet. + +* The current getitimer/setitimer implementation is a kludge. + +* mmap cannot do MAP_NOEXTEND. + +* Unimplemented calls (from the 4.4 system call list): +acct +fstatfs +getfh +getfsstat +getrusage +madvise +mincore +mount +msync +profil +recvmsg +revoke +sendmsg +setpriority +sstk +statfs +swapon +unmount diff -ruN glibc-1.08.1/hurd/__fopenport.c glibc-1.09/hurd/__fopenport.c --- glibc-1.08.1/hurd/__fopenport.c Wed Apr 20 16:40:26 1994 +++ glibc-1.09/hurd/__fopenport.c Mon Jul 18 18:16:25 1994 @@ -22,6 +22,70 @@ #include +/* Read up to N chars into BUF from COOKIE. + Return how many chars were read, 0 for EOF or -1 for error. */ +static ssize_t +readio (void *cookie, char *buf, size_t n) +{ + unsigned int nread; + error_t err; + char *bufp = buf; + + nread = n; + if (err = __io_read ((io_t) cookie, &bufp, &nread, -1, n)) + return __hurd_fail (err); + + if (bufp != buf) + { + memcpy (buf, bufp, nread); + __vm_deallocate (__mach_task_self (), + (vm_address_t) bufp, (vm_size_t) nread); + } + + return nread; +} + +/* Write up to N chars from BUF to COOKIE. + Return how many chars were written or -1 for error. */ +static ssize_t +writeio (void *cookie, const char *buf, size_t n) +{ + unsigned int wrote; + error_t err; + + if (err = __io_write ((io_t) cookie, buf, n, -1, &wrote)) + return __hurd_fail (err); + + return wrote; +} + +/* Move COOKIE's file position *POS bytes, according to WHENCE. + The current file position is stored in *POS. + Returns zero if successful, nonzero if not. */ +static int +seekio (void *cookie, fpos_t *pos, int whence) +{ + error_t error = __io_seek ((file_t) cookie, *pos, whence, pos); + if (error) + return __hurd_fail (error); + return 0; +} + +/* Close the file associated with COOKIE. + Return 0 for success or -1 for failure. */ +static int +closeio (void *cookie) +{ + error_t error = __mach_port_deallocate (__mach_task_self (), + (mach_port_t) cookie); + if (error) + return __hurd_fail (error); + return 0; +} + +static const __io_functions funcsio = { readio, writeio, seekio, closeio }; + + /* Defined in fopen.c. */ extern int EXFUN(__getmode, (CONST char *mode, __io_mode *mptr)); @@ -55,10 +119,11 @@ if (stream == NULL) return NULL; - /* The default io functions in sysd-stdio.c use Hurd io ports as cookies. */ - stream->__cookie = (PTR) port; stream->__mode = m; + stream->__io_funcs = funcsio; + stream->__room_funcs = __default_room_functions; + stream->__seen = 1; return stream; } diff -ruN glibc-1.08.1/hurd/__setauth.c glibc-1.09/hurd/__setauth.c --- glibc-1.08.1/hurd/__setauth.c Mon May 16 21:50:22 1994 +++ glibc-1.09/hurd/__setauth.c Tue Aug 30 11:01:02 1994 @@ -31,20 +31,18 @@ /* Set the auth port to NEW, and reauthenticate everything used by the library. */ -int -__setauth (auth_t new) +error_t +_hurd_setauth (auth_t new) { + error_t err; int d; - mach_port_t newport; + mach_port_t newport, ref; /* Give the new send right a user reference. This is a good way to check that it is valid. */ - if (__mach_port_mod_refs (__mach_task_self (), new, - MACH_PORT_RIGHT_SEND, 1)) - { - errno = EINVAL; - return -1; - } + if (err = __mach_port_mod_refs (__mach_task_self (), new, + MACH_PORT_RIGHT_SEND, 1)) + return err; HURD_CRITICAL_BEGIN; @@ -70,28 +68,42 @@ if (_hurd_init_dtable[d] != MACH_PORT_NULL) { mach_port_t new; - if (! __io_reauthenticate (_hurd_init_dtable[d], _hurd_pid) && + ref = __mach_reply_port (); + if (! __io_reauthenticate (_hurd_init_dtable[d], + ref, MACH_MSG_TYPE_MAKE_SEND) && ! HURD_PORT_USE (&_hurd_ports[INIT_PORT_AUTH], - __auth_user_authenticate (port, - _hurd_init_dtable[d], - _hurd_pid, - &new))) + __auth_user_authenticate + (port, + _hurd_init_dtable[d], + ref, MACH_MSG_TYPE_MAKE_SEND, + &new))) { __mach_port_deallocate (__mach_task_self (), _hurd_init_dtable[d]); _hurd_init_dtable[d] = new; } + __mach_port_destroy (__mach_task_self (), ref); } + ref = __mach_reply_port (); if (__USEPORT (CRDIR, - ! __io_reauthenticate (port, _hurd_pid) && - ! __auth_user_authenticate (new, port, _hurd_pid, &newport))) + ! __io_reauthenticate (port, + ref, MACH_MSG_TYPE_MAKE_SEND) && + ! __auth_user_authenticate (new, port, + ref, MACH_MSG_TYPE_MAKE_SEND, + &newport))) _hurd_port_set (&_hurd_ports[INIT_PORT_CRDIR], newport); + __mach_port_destroy (__mach_task_self (), ref); + ref = __mach_reply_port (); if (__USEPORT (CWDIR, - ! __io_reauthenticate (port, _hurd_pid) && - ! __auth_user_authenticate (new, port, _hurd_pid, &newport))) + ! __io_reauthenticate (port, + ref, MACH_MSG_TYPE_MAKE_SEND) && + ! __auth_user_authenticate (new, port, + ref, MACH_MSG_TYPE_MAKE_SEND, + &newport))) _hurd_port_set (&_hurd_ports[INIT_PORT_CWDIR], newport); + __mach_port_destroy (__mach_task_self (), ref); /* Run things which want to do reauthorization stuff. */ RUN_HOOK (_hurd_reauth_hook, (new)); @@ -101,4 +113,11 @@ HURD_CRITICAL_END; return 0; +} + +int +__setauth (auth_t new) +{ + error_t err = _hurd_setauth (new); + return err ? __hurd_fail (err) : 0; } diff -ruN glibc-1.08.1/hurd/catch-exc.c glibc-1.09/hurd/catch-exc.c --- glibc-1.08.1/hurd/catch-exc.c Thu Apr 28 23:08:06 1994 +++ glibc-1.09/hurd/catch-exc.c Sun Sep 4 00:38:23 1994 @@ -29,14 +29,36 @@ int code, int subcode) { - int signo, sigcode; + int signo, sigcode, error; + struct hurd_sigstate *ss; + + if (task != __mach_task_self ()) + /* The sender wasn't the kernel. */ + return EPERM; /* Call the machine-dependent function to translate the Mach exception codes into a signal number and subcode. */ - _hurd_exception2signal (exception, code, subcode, &signo, &sigcode); + _hurd_exception2signal (exception, code, subcode, + &signo, &sigcode, &error); + + /* Find the sigstate structure for the faulting thread. */ + __mutex_lock (&_hurd_siglock); + for (ss = _hurd_sigstates; ss != NULL; ss = ss->next) + if (ss->thread == thread) + break; + __mutex_unlock (&_hurd_siglock); + if (ss == NULL) + ss = _hurd_thread_sigstate (thread); /* Allocate a fresh one. */ + + if (__spin_lock_locked (&ss->lock.held)) + /* Oops. The thread faulted with its sigstate lock held. + Bad scene. What to do? */ + ; /* XXX */ + else + __mutex_lock (&ss->lock); /* Post the signal. */ - _hurd_internal_post_signal (_hurd_thread_sigstate (thread), signo, sigcode, + _hurd_internal_post_signal (ss, signo, sigcode, error, MACH_PORT_NULL, MACH_MSG_TYPE_PORT_SEND); return KERN_SUCCESS; diff -ruN glibc-1.08.1/hurd/dtable.c glibc-1.09/hurd/dtable.c --- glibc-1.08.1/hurd/dtable.c Mon May 30 20:31:56 1994 +++ glibc-1.09/hurd/dtable.c Thu Nov 3 19:30:30 1994 @@ -30,7 +30,7 @@ #include "hurdmalloc.h" /* XXX */ -struct mutex _hurd_dtable_lock; +struct mutex _hurd_dtable_lock = MUTEX_INITIALIZER; /* XXX ld bug; must init */ struct hurd_fd **_hurd_dtable; int _hurd_dtablesize; @@ -95,6 +95,8 @@ /* Run things that want to run after the file descriptor table is initialized. */ RUN_HOOK (_hurd_fd_subinit, ()); + + (void) &init_dtable; /* Avoid "defined but not used" warning. */ } text_set_element (_hurd_subinit, init_dtable); @@ -109,7 +111,7 @@ { file_t dport; int err = HURD_DPORT_USE (fd, __mach_port_mod_refs (__mach_task_self (), - (dport = ctty ?: port), + (dport = port), MACH_PORT_RIGHT_SEND, 1)); if (err) @@ -139,25 +141,31 @@ for (i = 0; !err && i < _hurd_dtablesize; ++i) { struct hurd_fd *d = _hurd_dtable[i]; + if (d == NULL) + continue; /* No other thread is using the send rights in the child task. */ d->port.users = d->ctty.users = NULL; - if (d->ctty.port) - /* There was a ctty-special port in the parent. - We need to get one for ourselves too. */ - err = __term_become_ctty (d->ctty.port, - /* XXX no guarantee that init_pids hook - has been run BEFORE this one! */ - _hurd_pid, _hurd_pgrp, _hurd_msgport, - &d->port.port); + if (d->ctty.port != MACH_PORT_NULL) + { + /* There was a ctty-special port in the parent. + We need to get one for ourselves too. */ + __mach_port_deallocate (__mach_task_self (), d->ctty.port); + err = __term_open_ctty (d->port.port, _hurd_pid, _hurd_pgrp, + &d->ctty.port); + if (err) + d->ctty.port = MACH_PORT_NULL; + } /* XXX for each fd with a cntlmap, reauth and re-map_cntl. */ } return err; + + (void) &fork_child_dtable; /* Avoid "defined but not used" warning. */ } -data_set_element (_hurd_fork_locks, _hurd_dtable_lock); +data_set_element (_hurd_fork_locks, _hurd_dtable_lock); /* XXX ld bug: bss */ text_set_element (_hurd_fork_child_hook, fork_child_dtable); /* Called when our process group has changed. */ @@ -183,14 +191,14 @@ port = _hurd_port_get (&d->port, &ulink); ctty = _hurd_port_get (&d->ctty, &ctty_ulink); - if (ctty) + if (ctty != MACH_PORT_NULL) { /* This fd has a ctty-special port. We need a new one, to tell the io server of our different process group. */ io_t new; - if (! __term_become_ctty (ctty, _hurd_pid, _hurd_pgrp, _hurd_msgport, - &new)) - _hurd_port_set (&d->port, new); + if (__term_open_ctty (port, _hurd_pid, _hurd_pgrp, &new)) + new = MACH_PORT_NULL; + _hurd_port_set (&d->ctty, new); } _hurd_port_free (&d->port, &ulink, port); @@ -199,6 +207,8 @@ __mutex_unlock (&_hurd_dtable_lock); HURD_CRITICAL_END; + + (void) &ctty_new_pgrp; /* Avoid "defined but not used" warning. */ } text_set_element (_hurd_pgrp_changed_hook, ctty_new_pgrp); @@ -216,31 +226,38 @@ for (i = 0; i < _hurd_dtablesize; ++i) { struct hurd_fd *const d = _hurd_dtable[i]; - mach_port_t new, newctty; + mach_port_t new, newctty, ref; if (d == NULL) /* Nothing to do for an unused descriptor cell. */ continue; + ref = __mach_reply_port (); + /* Take the descriptor cell's lock. */ __spin_lock (&d->port.lock); /* Reauthenticate the descriptor's port. */ if (d->port.port != MACH_PORT_NULL && - ! __io_reauthenticate (d->port.port, _hurd_pid) && - ! __USEPORT (AUTH, __auth_user_authenticate (port, - d->port.port, _hurd_pid, - &new))) + ! __io_reauthenticate (d->port.port, + ref, MACH_MSG_TYPE_MAKE_SEND) && + ! __USEPORT (AUTH, __auth_user_authenticate + (port, + d->port.port, + ref, MACH_MSG_TYPE_MAKE_SEND, + &new))) { /* Replace the port in the descriptor cell with the newly reauthenticated port. */ if (d->ctty.port != MACH_PORT_NULL && - ! __io_reauthenticate (d->ctty.port, _hurd_pid) && - ! __USEPORT (AUTH, __auth_user_authenticate (port, - d->ctty.port, - _hurd_pid, - &newctty))) + ! __io_reauthenticate (d->ctty.port, + ref, MACH_MSG_TYPE_MAKE_SEND) && + ! __USEPORT (AUTH, __auth_user_authenticate + (port, + d->ctty.port, + ref, MACH_MSG_TYPE_MAKE_SEND, + &newctty))) _hurd_port_set (&d->ctty, newctty); _hurd_port_locked_set (&d->port, new); @@ -248,10 +265,14 @@ else /* Lost. Leave this descriptor cell alone. */ __spin_unlock (&d->port.lock); + + __mach_port_destroy (__mach_task_self (), ref); } __mutex_unlock (&_hurd_dtable_lock); HURD_CRITICAL_END; + + (void) &reauth_dtable; /* Avoid "defined but not used" warning. */ } text_set_element (_hurd_reauth_hook, reauth_dtable); diff -ruN glibc-1.08.1/hurd/fchroot.c glibc-1.09/hurd/fchroot.c --- glibc-1.08.1/hurd/fchroot.c Thu Feb 3 21:06:29 1994 +++ glibc-1.09/hurd/fchroot.c Tue Aug 30 05:08:26 1994 @@ -21,30 +21,23 @@ #include #include -/* Change the current directory root to FD. */ +/* Change the current root directory to FD. */ int DEFUN(fchroot, (fd), int fd) { error_t err; - file_t crdir; + file_t dir; - err = HURD_DPORT_USE - (fd, - ({ struct stat st; - crdir = port; - err = __io_stat (crdir, &st); - if (! err && ! S_ISDIR (st.st_mode)) - err = ENOTDIR; - if (! err) - __mach_port_mod_refs (__mach_task_self (), - crdir, MACH_PORT_RIGHT_SEND, 1); - err; - })); + err = __USEPORT (CRDIR, + ({ file_t crdir = port; + HURD_DPORT_USE (fd, + __hurd_file_name_lookup (crdir, port, "", + 0, 0, &dir)); + })); if (err) return __hurd_fail (err); - _hurd_port_set (&_hurd_ports[INIT_PORT_CRDIR], crdir); - + _hurd_port_set (&_hurd_ports[INIT_PORT_CRDIR], dir); return 0; } diff -ruN glibc-1.08.1/hurd/fd-read.c glibc-1.09/hurd/fd-read.c --- glibc-1.08.1/hurd/fd-read.c Wed May 11 23:42:53 1994 +++ glibc-1.09/hurd/fd-read.c Fri Sep 30 16:48:17 1994 @@ -32,35 +32,43 @@ err = HURD_FD_PORT_USE (fd, ({ - call: - err = __io_read (port, &data, &nread, -1, *nbytes); - if (ctty != MACH_PORT_NULL && err == EBACKGROUND) + do { -#if 1 - abort (); -#else - struct _hurd_sigstate *ss = _hurd_self_sigstate (); - if (_hurd_orphaned || - __sigismember (SIGTTIN, &ss->blocked) || - ss->actions[SIGTTIN].sa_handler == SIG_IGN) + err = __io_read (ctty != MACH_PORT_NULL ? ctty : port, + &data, &nread, -1, *nbytes); + if (ctty != MACH_PORT_NULL && err == EBACKGROUND) { - /* We are orphaned, or are blocking or ignoring SIGTTIN. - Return EOF instead of stopping. */ - __mutex_unlock (&ss->lock); - nread = 0; - err = 0; - } - else - { - const int restart = ss->actions[SIGTTIN].sa_flags & SA_RESTART; - _hurd_raise_signal (ss, SIGTTIN, 0); /* Unlocks SS->lock. */ - if (restart) - goto call; + /* We are a background job and tried to read from the tty. + We should probably get a SIGTTIN signal. */ + struct hurd_sigstate *ss; + if (_hurd_orphaned) + /* Our process group is orphaned. Don't stop; just fail. */ + err = EIO; else - err = EINTR; /* XXX Is this right? */ + { + ss = _hurd_self_sigstate (); + if (__sigismember (&ss->blocked, SIGTTIN) || + ss->actions[SIGTTIN].sa_handler == SIG_IGN) + /* We are blocking or ignoring SIGTTIN. Just fail. */ + err = EIO; + __mutex_unlock (&ss->lock); + } + if (err == EBACKGROUND) + { + /* Send a SIGTTIN signal to our process group. */ + err = __USEPORT (CTTYID, _hurd_sig_post (0, SIGTTIN, port)); + /* XXX what to do if error here? */ + /* At this point we should have just run the handler for + SIGTTIN or resumed after being stopped. Now this is + still a "system call", so check to see if we should + restart it. */ + __mutex_lock (&ss->lock); + if (!(ss->actions[SIGTTIN].sa_flags & SA_RESTART)) + err = EINTR; + __mutex_unlock (&ss->lock); + } } -#endif - } + } while (err == EBACKGROUND); err; })); diff -ruN glibc-1.08.1/hurd/fd-write.c glibc-1.09/hurd/fd-write.c --- glibc-1.08.1/hurd/fd-write.c Wed May 11 20:21:12 1994 +++ glibc-1.09/hurd/fd-write.c Fri Sep 30 16:50:19 1994 @@ -1,4 +1,5 @@ -/* Copyright (C) 1993, 1994 Free Software Foundation, Inc. +/* _hurd_fd_write -- write to a file descriptor; handles job control et al. +Copyright (C) 1993, 1994 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -27,40 +28,46 @@ error_t err; mach_msg_type_number_t wrote; int noctty; + struct hurd_sigstate *ss; -#ifdef notyet - struct _hurd_sigstate *ss = _hurd_self_sigstate (); + /* Note that __ioctl.c implements the same SIGTTOU behavior. + Any changes here should be done there as well. */ - /* Don't use the ctty io port if we are orphaned, or are blocking or - ignoring SIGTTOU. */ - noctty = (_hurd_orphaned || - __sigismember (SIGTTOU, &ss->blocked) || + /* Don't use the ctty io port if we are blocking or ignoring SIGTTOU. */ + ss = _hurd_self_sigstate (); + noctty = (__sigismember (&ss->blocked, SIGTTOU) || ss->actions[SIGTTOU].sa_handler == SIG_IGN); __mutex_unlock (&ss->lock); -#else - noctty = 1; -#endif - + err = HURD_FD_PORT_USE (fd, ({ - call: - err = __io_write (noctty ? port : ctty, buf, *nbytes, -1, &wrote); - if (!noctty && ctty != MACH_PORT_NULL && err == EBACKGROUND) + const io_t ioport = (!noctty && ctty != MACH_PORT_NULL) ? ctty : port; + do { -#if 1 - abort (); -#else - int restart; - __mutex_lock (&ss->lock); - restart = ss->actions[SIGTTOU].sa_flags & SA_RESTART; - _hurd_raise_signal (ss, SIGTTOU, 0); /* Unlocks SS->lock. */ - if (restart) - goto call; - else - err = EINTR; /* XXX Is this right? */ -#endif - } + err = __io_write (ioport, buf, *nbytes, -1, &wrote); + if (ioport == ctty && err == EBACKGROUND) + { + if (_hurd_orphaned) + /* Our process group is orphaned, so we never generate a + signal; we just fail. */ + err = EIO; + else + { + /* Send a SIGTTOU signal to our process group. */ + err = __USEPORT (CTTYID, _hurd_sig_post (0, SIGTTOU, port)); + /* XXX what to do if error here? */ + /* At this point we should have just run the handler for + SIGTTOU or resumed after being stopped. Now this is + still a "system call", so check to see if we should + restart it. */ + __mutex_lock (&ss->lock); + if (!(ss->actions[SIGTTOU].sa_flags & SA_RESTART)) + err = EINTR; + __mutex_unlock (&ss->lock); + } + } + } while (err == EBACKGROUND); err; })); diff -ruN glibc-1.08.1/hurd/hurd/fd.h glibc-1.09/hurd/hurd/fd.h --- glibc-1.08.1/hurd/hurd/fd.h Sat May 21 20:23:30 1994 +++ glibc-1.09/hurd/hurd/fd.h Wed Aug 10 17:03:09 1994 @@ -129,7 +129,9 @@ { switch (err) { - case MACH_SEND_INVALID_DEST: /* The server has disappeared! */ + case EMACH_SEND_INVALID_DEST: + case EMIG_SERVER_DIED: + /* The server has disappeared! */ return SIGLOST; case EPIPE: return SIGPIPE; @@ -148,7 +150,7 @@ { int signo = _hurd_fd_error_signal (err); if (signo) - _hurd_raise_signal (NULL, signo, fd); + _hurd_raise_signal (NULL, signo, fd, err); return err; } diff -ruN glibc-1.08.1/hurd/hurd/resource.h glibc-1.09/hurd/hurd/resource.h --- glibc-1.08.1/hurd/hurd/resource.h Fri May 27 07:22:53 1994 +++ glibc-1.09/hurd/hurd/resource.h Fri Oct 28 14:29:09 1994 @@ -20,10 +20,31 @@ #ifndef _HURD_RESOURCE_H #define _HURD_RESOURCE_H +#include #include +#include +#include /* This array contains the current resource limits for the process. */ extern struct rlimit _hurd_rlimits[RLIM_NLIMITS]; extern struct mutex _hurd_rlimit_lock; /* Locks _hurd_rlimits. */ + + +/* Helper function for getpriority and setpriority. Maps FN over all the + processes specified by WHICH and WHO. PI is non-null if a + proc_getprocinfo was already done; FN may use *PI arbitrarily, it is + reset on the next call. Returns FN's result the first time it returns + nonzero. If FN never returns nonzero, this returns zero. */ +extern error_t _hurd_priority_which_map (enum __priority_which which, int who, + error_t (*fn) (pid_t pid, + struct procinfo *pi)); + +/* Convert between Mach priority values and the priority + values used by getpriority, setpriority, and nice. */ +#define MACH_PRIORITY_TO_NICE(prio) (2 * ((prio) - 12)) +#define NICE_TO_MACH_PRIORITY(nice) (12 + ((nice) / 2)) + + + #endif diff -ruN glibc-1.08.1/hurd/hurd/signal.h glibc-1.09/hurd/hurd/signal.h --- glibc-1.08.1/hurd/hurd/signal.h Mon May 16 21:50:19 1994 +++ glibc-1.09/hurd/hurd/signal.h Wed Aug 31 03:39:49 1994 @@ -38,6 +38,7 @@ #include /* For `struct mutex'. */ #include +#include /* We cache sigstate in a threadvar. */ /* Per-thread signal state. */ @@ -58,19 +59,26 @@ sigset_t pending; struct sigaction actions[NSIG]; struct sigaltstack sigaltstack; - int sigcodes[NSIG]; /* Codes for pending signals. */ + struct + { + /* For each signal that may be pending, the + sigcode and error code to deliver it with. */ + int code, error; + } pending_data[NSIG]; /* If `suspended' is set when this thread gets a signal, - the signal thread clears it and then signals `arrived'. */ - int suspended; -#ifdef noteven - struct condition arrived; -#endif + the signal thread sends an empty message to it. */ + mach_port_t suspended; /* Not locked. Used only by this thread, or by the signal thread with this thread suspended. */ volatile mach_port_t intr_port; /* Port interruptible RPC was sent on. */ - volatile int intr_restart; /* If nonzero, restart interrupted RPC. */ + + /* If this is not null, the thread is in sigreturn awaiting delivery of + pending signals. This context (the machine-dependent portions only) + will be passed to sigreturn after running the handler for a pending + signal, instead of examining the thread state. */ + struct sigcontext *context; }; /* Linked list of states of all threads whose state has been asked for. */ @@ -86,7 +94,19 @@ /* Get the sigstate of the current thread, taking its lock. This uses a per-thread variable to optimize the lookup. */ -#include +_EXTERN_INLINE struct hurd_sigstate * +_hurd_self_sigstate_unlocked (void) +{ + struct hurd_sigstate **location = + (void *) __hurd_threadvar_location (_HURD_THREADVAR_SIGSTATE); + if (! *location) + { + *location = _hurd_thread_sigstate (__mach_thread_self ()); + __mutex_unlock (&(*location)->lock); + } + return *location; +} + _EXTERN_INLINE struct hurd_sigstate * _hurd_self_sigstate (void) { @@ -95,7 +115,7 @@ if (*location) __mutex_lock (&(*location)->lock); else - *location = _hurd_thread_sigstate (__mach_thread_self ()); /* cproc_self */ + *location = _hurd_thread_sigstate (__mach_thread_self ()); return *location; } @@ -191,17 +211,17 @@ extern void _hurdsig_fault_init (void); -/* Raise a signal as described by SIGNO and SIGCODE, on the thread whose - sigstate SS points to. If SS is a null pointer, this instead affects - the calling thread. */ +/* Raise a signal as described by SIGNO, SIGCODE and SIGERROR, on the + thread whose sigstate SS points to. If SS is a null pointer, this + instead affects the calling thread. */ extern void _hurd_raise_signal (struct hurd_sigstate *ss, - int signo, int sigcode); + int signo, int sigcode, int sigerror); /* Translate a Mach exception into a signal (machine-dependent). */ extern void _hurd_exception2signal (int exception, int code, int subcode, - int *signo, int *sigcode); + int *signo, int *sigcode, int *error); /* Make the thread described by SS take the signal described by SIGNO and @@ -210,32 +230,35 @@ entry, and released before return. */ extern void _hurd_internal_post_signal (struct hurd_sigstate *ss, - int signo, int sigcode, + int signo, int sigcode, int error, mach_port_t reply_port, mach_msg_type_name_t reply_port_type); -/* Set up STATE to handle signal SIGNO by running HANDLER. FLAGS is the - `sa_flags' member from `struct sigaction'. If the SA_ONSTACK bit is - set, *ALTSTACK describes the alternate signal stack to use. The handler - is passed SIGNO, SIGCODE, and the returned `struct sigcontext' (which - resides on the stack the handler will use, and which describes the state - of the thread encoded in STATE before running the handler). */ - -extern struct sigcontext *_hurd_setup_sighandler (int flags, - __sighandler_t handler, - struct sigaltstack *altstack, - int signo, int sigcode, - void *state); +/* Set up STATE and SS to handle signal SIGNO by running HANDLER. If + RPC_WAIT is nonzero, the thread needs to wait for a pending RPC to + finish before running the signal handler. The handler is passed SIGNO, + SIGCODE, and the returned `struct sigcontext' (which resides on the + stack the handler will use, and which describes the state of the thread + encoded in STATE before running the handler). */ + +struct machine_thread_all_state; +extern struct sigcontext * +_hurd_setup_sighandler (struct hurd_sigstate *ss, __sighandler_t handler, + int signo, int sigcode, + int rpc_wait, struct machine_thread_all_state *state); /* Function run by the signal thread to receive from the signal port. */ extern void _hurd_msgport_receive (void); -/* Return nonzero if STATE indicates a thread that is blocked in a mach_msg - system call (machine-dependent). If returning nonzero, set *PORT to - the receive right that the thread is blocked on. */ +/* STATE describes a thread that had intr_port set (meaning it was inside + HURD_EINTR_RPC), after it has been thread_abort'd. It it looks to have + just completed a mach_msg_trap system call that returned + MACH_RCV_INTERRUPTED, return nonzero and set *PORT to the receive right + being waited on. */ -extern int _hurd_thread_state_msging_p (void *state, mach_port_t *port); +extern int _hurdsig_rcv_interrupted_p (struct machine_thread_all_state *state, + mach_port_t *port); /* Set up STATE with a thread state that, when resumed, is like `longjmp (_hurd_sigthread_fault_env, 1)'. */ @@ -249,51 +272,51 @@ extern void _hurd_siginfo_handler (int); -#ifdef notyet - /* Perform interruptible RPC CALL on PORT. + The call should use The args in CALL should be constant or local variable refs. They may be evaluated many times, and must not change. PORT must not be deallocated before this RPC is finished. */ -#define HURD_EINTR_RPC(port, call) \ - ({ - error_t __err; - struct hurd_sigstate *__ss = _hurd_self_sigstate (); - __mutex_unlock (&__ss->lock); /* Lock not needed. */ - /* If we get a signal and should return EINTR, the signal thread will - clear this. The RPC might return EINTR when some other thread gets - a signal, in which case we want to restart our call. */ - __ss->intr_restart = 1; - /* This one needs to be last. A signal can arrive before here, - and if intr_port were set before intr_restart is - initialized, the signal thread would get confused. */ - __ss->intr_port = (port); - /* A signal may arrive here, after intr_port is set, - but before the mach_msg system call. The signal handler might do an - interruptible RPC, and clobber intr_port; then it would not be set - properly when we actually did send the RPC, and a later signal - wouldn't interrupt that RPC. So, _hurd_run_sighandler saves - intr_port in the sigcontext, and sigreturn restores it. */ - __do_call: - switch (__err = (call)) - { - case EINTR: /* RPC went out and was interrupted. */ - case MACH_SEND_INTERRUPTED: /* RPC didn't get out. */ - if (__ss->intr_restart) - /* Restart the interrupted call. */ - goto __do_call; - /* FALLTHROUGH */ - case MACH_RCV_PORT_DIED: - /* Server didn't respond to interrupt_operation, - so the signal thread destroyed the reply port. */ - __err = EINTR; - break; - } - __ss->intr_port = MACH_PORT_NULL; - __err; - }) +#define HURD_EINTR_RPC(port, call) \ + ({ \ + __label__ __do_call; /* Give this label block scope. */ \ + error_t __err; \ + struct hurd_sigstate *__ss = _hurd_self_sigstate_unlocked (); \ + __do_call: \ + /* Tell the signal thread that we are doing an interruptible RPC on \ + this port. If we get a signal and should return EINTR, the signal \ + thread will set this variable to MACH_PORT_NULL. The RPC might \ + return EINTR when some other thread gets a signal, in which case we \ + want to restart our call. */ \ + __ss->intr_port = (port); \ + /* A signal may arrive here, after intr_port is set, but before the \ + mach_msg system call. The signal handler might do an interruptible \ + RPC, and clobber intr_port; then it would not be set properly when \ + we actually did send the RPC, and a later signal wouldn't interrupt \ + that RPC. So, _hurd_setup_sighandler saves intr_port in the \ + sigcontext, and sigreturn restores it. */ \ + switch (__err = (call)) \ + { \ + case EINTR: /* RPC went out and was interrupted. */ \ + case MACH_SEND_INTERRUPTED: /* RPC didn't get out. */ \ + if (__ss->intr_port != MACH_PORT_NULL) \ + /* If this signal was for us and it should interrupt calls, the \ + signal thread will have cleared SS->intr_port. Since it's not \ + cleared, the signal was for another thread, or SA_RESTART is \ + set. Restart the interrupted call. */ \ + goto __do_call; \ + /* FALLTHROUGH */ \ + case MACH_RCV_PORT_DIED: \ + /* Server didn't respond to interrupt_operation, \ + so the signal thread destroyed the reply port. */ \ + __err = EINTR; \ + break; \ + default: /* Quiet -Wswitch-enum. */ \ + } \ + __ss->intr_port = MACH_PORT_NULL; \ + __err; \ + }) \ -#endif /* notyet */ /* Mask of signals that cannot be caught, blocked, or ignored. */ #define _SIG_CANT_MASK (__sigmask (SIGSTOP) | __sigmask (SIGKILL)) diff -ruN glibc-1.08.1/hurd/hurd-raise.c glibc-1.09/hurd/hurd-raise.c --- glibc-1.08.1/hurd/hurd-raise.c Fri Apr 29 01:01:29 1994 +++ glibc-1.09/hurd/hurd-raise.c Wed Aug 10 20:20:11 1994 @@ -26,14 +26,16 @@ SS->lock is held on entry and released before return. */ void -_hurd_raise_signal (struct hurd_sigstate *ss, int signo, int sigcode) +_hurd_raise_signal (struct hurd_sigstate *ss, + int signo, int sigcode, int sigerror) { if (ss == NULL) ss = _hurd_self_sigstate (); /* Mark SIGNO as pending to be delivered. */ __sigaddset (&ss->pending, signo); - ss->sigcodes[signo] = sigcode; + ss->pending_data[signo].code = sigcode; + ss->pending_data[signo].error = sigerror; __mutex_unlock (&ss->lock); diff -ruN glibc-1.08.1/hurd/hurd.h glibc-1.09/hurd/hurd.h --- glibc-1.08.1/hurd/hurd.h Wed Apr 27 07:08:55 1994 +++ glibc-1.09/hurd/hurd.h Thu Oct 6 19:02:08 1994 @@ -70,14 +70,17 @@ extern mach_port_t *_hurd_init_dtable; extern mach_msg_type_number_t _hurd_init_dtablesize; -/* Miscellaneous library state. */ - - /* Current process IDs. */ extern pid_t _hurd_pid, _hurd_ppid, _hurd_pgrp; extern int _hurd_orphaned; -extern struct mutex _hurd_pid_lock; /* Locks above. */ + +/* This variable is incremented every time the process IDs change. */ + +unsigned int _hurd_pids_changed_stamp; + +/* This condition is broadcast every time the process IDs change. */ +struct condition _hurd_pids_changed_sync; /* Unix `data break', for brk and sbrk. If brk and sbrk are not used, this info will not be initialized or used. */ @@ -105,11 +108,16 @@ /* Calls to get and set basic ports. */ +extern error_t _hurd_ports_get (int which, mach_port_t *result); +extern error_t _hurd_ports_set (int which, mach_port_t newport); + extern process_t getproc (void); -extern file_t getccdir (void), getcwdir (void), getcrdir (void); +extern file_t getcwdir (void), getcrdir (void); extern auth_t getauth (void); +extern mach_port_t getcttyid (); extern int setproc (process_t); extern int setcwdir (file_t), setcrdir (file_t); +extern int setcttyid (mach_port_t); /* Does reauth with the proc server and fd io servers. */ extern int __setauth (auth_t), setauth (auth_t); @@ -121,26 +129,45 @@ uses CRDIR for the root directory and CWDIR for the current directory. Returns zero on success or an error code. */ -extern error_t __hurd_path_split (file_t crdir, file_t cwdir, - const char *file, - file_t *dir, char **name); -extern error_t hurd_path_split (file_t crdir, file_t cwdir, - const char *file, - file_t *dir, char **name); +extern error_t __hurd_file_name_split (file_t crdir, file_t cwdir, + const char *file, + file_t *dir, char **name); +extern error_t hurd_file_name_split (file_t crdir, file_t cwdir, + const char *file, + file_t *dir, char **name); /* Open a port to FILE with the given FLAGS and MODE (see ). The file lookup uses CRDIR for the root directory and CWDIR for the current directory. If successful, returns zero and store the port to FILE in *PORT; otherwise returns an error code. */ -extern error_t __hurd_path_lookup (file_t crdir, file_t cwdir, - const char *file, - int flags, mode_t mode, - file_t *port); -extern error_t hurd_path_lookup (file_t crdir, file_t cwdir, - const char *filename, - int flags, mode_t mode, - file_t *port); +extern error_t __hurd_file_name_lookup (file_t crdir, file_t cwdir, + const char *file, + int flags, mode_t mode, + file_t *port); +extern error_t hurd_file_name_lookup (file_t crdir, file_t cwdir, + const char *filename, + int flags, mode_t mode, + file_t *port); + +/* Process the values returned by `dir_lookup' et al, and loop doing + `dir_lookup' calls until one returns FS_RETRY_NONE. CRDIR is the + root directory used for things like symlinks to absolute file names; the + other arguments should be those just passed to and/or returned from + `dir_lookup', `fsys_getroot', or `file_invoke_translator'. This + function consumes the reference in *RESULT even if it returns an error. */ + +extern error_t __hurd_file_name_lookup_retry (file_t crdir, + enum retry_type doretry, + char retryname[1024], + int flags, mode_t mode, + file_t *result); +extern error_t hurd_file_name_lookup_retry (file_t crdir, + enum retry_type doretry, + char retryname[1024], + int flags, mode_t mode, + file_t *result); + /* Split FILE into a directory and a name within the directory. The directory lookup uses the current root and working directory. If @@ -148,19 +175,32 @@ within directory begins and returns a port to the directory; otherwise sets `errno' and returns MACH_PORT_NULL. */ -extern file_t __path_split (const char *file, char **name); -extern file_t path_split (const char *file, char **name); +extern file_t __file_name_split (const char *file, char **name); +extern file_t file_name_split (const char *file, char **name); /* Open a port to FILE with the given FLAGS and MODE (see ). The file lookup uses the current root and working directory. Returns a port to the file if successful; otherwise sets `errno' and returns MACH_PORT_NULL. */ -extern file_t __path_lookup (const char *file, int flags, mode_t mode); -extern file_t path_lookup (const char *file, int flags, mode_t mode); +extern file_t __file_name_lookup (const char *file, int flags, mode_t mode); +extern file_t file_name_lookup (const char *file, int flags, mode_t mode); - -/* Open a file descriptor on a port. FLAGS are as for `open'. */ +/* Invoke any translator set on the node FILE represents, and return in + *TRANSLATED a port to the translated node. FLAGS are as for + `dir_lookup' et al, but the returned port will not necessarily have + any more access rights than FILE does. */ + +extern error_t __hurd_invoke_translator (file_t file, int flags, + file_t *translated); +extern error_t hurd_invoke_translator (file_t file, int flags, + file_t *translated); + + +/* Open a file descriptor on a port. FLAGS are as for `open'; flags + affected by io_set_openmodes are not changed by this. If successful, + this consumes a user reference for PORT (which will be deallocated on + close). */ extern int openport (io_t port, int flags); @@ -199,9 +239,18 @@ extern void _hurd_proc_init (char **argv); -/* Return the socket server for sockaddr domain DOMAIN. */ +/* Return the socket server for sockaddr domain DOMAIN. If DEAD is + nonzero, remove the old cached port and always do a fresh lookup. + + It is assumed that a socket server will stay alive during a complex socket + operation involving several RPCs. But a socket server may die during + long idle periods between socket operations. Callers should first pass + zero for DEAD; if the first socket RPC tried on the returned port fails + with MACH_SEND_INVALID_DEST or MIG_SERVER_DIED (indicating the server + went away), the caller should call _hurd_socket_server again with DEAD + nonzero and retry the RPC on the new socket server port. */ -extern socket_t _hurd_socket_server (int domain); +extern socket_t _hurd_socket_server (int domain, int dead); /* Send a `sig_post' RPC to process number PID. If PID is zero, send the message to all processes in the current process's process group. @@ -209,6 +258,7 @@ SIG and REFPORT are passed along in the request message. */ extern error_t _hurd_sig_post (pid_t pid, int sig, mach_port_t refport); +extern error_t hurd_sig_post (pid_t pid, int sig, mach_port_t refport); /* Fetch the host privileged port and device master port from the proc server. They are fetched only once and then cached in the diff -ruN glibc-1.08.1/hurd/hurdauth.c glibc-1.09/hurd/hurdauth.c --- glibc-1.08.1/hurd/hurdauth.c Wed May 11 23:47:25 1994 +++ glibc-1.09/hurd/hurdauth.c Mon Jul 18 18:16:32 1994 @@ -120,7 +120,7 @@ if (err) return err; - err = __setauth (newauth); /* XXX clobbers errno */ + err = __setauth (newauth); __mach_port_deallocate (__mach_task_self (), newauth); if (err) return errno; diff -ruN glibc-1.08.1/hurd/hurdexec.c glibc-1.09/hurd/hurdexec.c --- glibc-1.08.1/hurd/hurdexec.c Mon May 23 22:30:15 1994 +++ glibc-1.09/hurd/hurdexec.c Fri Sep 30 16:59:19 1994 @@ -39,10 +39,10 @@ int ints[INIT_INT_MAX]; mach_port_t ports[_hurd_nports]; struct hurd_userlink ulink_ports[_hurd_nports]; - file_t *dtable, *dtable_ctty; + file_t *dtable; int dtablesize; - struct hurd_port **dtable_cells, **dtable_ctty_cells; - struct hurd_userlink *ulink_dtable, *ulink_dtable_ctty; + struct hurd_port **dtable_cells; + struct hurd_userlink *ulink_dtable; int i; char *const *p; struct hurd_sigstate *ss; @@ -153,11 +153,8 @@ if (_hurd_dtable != NULL) { dtable = __alloca (dtablesize * sizeof (dtable[0])); - dtable_ctty = __alloca (dtablesize * sizeof (dtable[0])); ulink_dtable = __alloca (dtablesize * sizeof (ulink_dtable[0])); dtable_cells = __alloca (dtablesize * sizeof (dtable_cells[0])); - ulink_dtable_ctty = __alloca (dtablesize * sizeof (ulink_dtable[0])); - dtable_ctty_cells = __alloca (dtablesize * sizeof (dtable_cells[0])); for (i = 0; i < dtablesize; ++i) { struct hurd_fd *const d = _hurd_dtable[i]; @@ -183,26 +180,14 @@ } else { - /* If this is a descriptor to our controlling tty, - we want to give the normal port, not the foreground port. */ - dtable[i] = _hurd_port_get (&d->ctty, &ulink_dtable[i]); - if (dtable[i] == MACH_PORT_NULL) - { - dtable[i] = _hurd_port_locked_get (&d->port, - &ulink_dtable[i]); - dtable_cells[i] = &d->port; - } - else - { - if (pdp) - /* All the elements of DTABLE are added to PLEASE_DEALLOC - below, so we needn't add the port in the branch above. - But we must deallocate the foreground port as well as - the normal port that got installed in DTABLE[I]. */ - *pdp++ = d->port.port; - __spin_unlock (&d->port.lock); - dtable_cells[i] = &d->ctty; - } + if (pdp && d->ctty.port != MACH_PORT_NULL) + /* All the elements of DTABLE are added to PLEASE_DEALLOC + below, so we needn't add the port itself. + But we must deallocate the ctty port as well as + the normal port that got installed in DTABLE[I]. */ + *pdp++ = d->ctty.port; + dtable[i] = _hurd_port_locked_get (&d->port, &ulink_dtable[i]); + dtable_cells[i] = &d->port; } } } diff -ruN glibc-1.08.1/hurd/hurdfault.c glibc-1.09/hurd/hurdfault.c --- glibc-1.08.1/hurd/hurdfault.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/hurd/hurdfault.c Sun Sep 4 15:37:48 1994 @@ -0,0 +1,142 @@ +/* Handle faults in the signal thread. +Copyright (C) 1994 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include "hurdfault.h" +#include +#include +#include +#include +#include "thread_state.h" +#include "faultexc.h" /* mig-generated header for our exc server. */ + +jmp_buf _hurdsig_fault_env; + +static mach_port_t forward_sigexc; + +int _hurdsig_fault_expect_signo; +int _hurdsig_fault_sigcode; +int _hurdsig_fault_sigerror; + +kern_return_t +_hurdsig_fault_catch_exception_raise (mach_port_t port, + thread_t thread, + task_t task, + int exception, + int code, + int subcode) +{ + int signo; + + if (port != forward_sigexc || + thread != _hurd_msgport_thread || task != __mach_task_self ()) + return EPERM; /* Strange bogosity. */ + + /* Call the machine-dependent function to translate the Mach exception + codes into a signal number and subcode. */ + _hurd_exception2signal (exception, code, subcode, &signo, + &_hurdsig_fault_sigcode, &_hurdsig_fault_sigerror); + + return signo == _hurdsig_fault_expect_signo ? 0 : EGREGIOUS; +} + +static void +faulted (void) +{ + struct + { + mach_msg_header_t head; + char buf[64]; + } request; + struct + { + mach_msg_header_t head; + mach_msg_type_t type; + int result; + } reply; + extern int _hurdsig_fault_exc_server (mach_msg_header_t *, + mach_msg_header_t *); + + /* Wait for the exception_raise message forwarded by the proc server. */ + + if (__mach_msg (&request.head, MACH_RCV_MSG, 0, + sizeof request, forward_sigexc, + MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL) + != MACH_MSG_SUCCESS) + __libc_fatal ("msg receive failed on signal thread exc\n"); + + /* Run the exc demuxer which should call the server function above. + That function returns 0 if the exception was expected. */ + switch (_hurdsig_fault_exc_server (&request.head, &reply.head)) + { + case KERN_SUCCESS: + if (reply.head.msgh_remote_port != MACH_PORT_NULL) + __mach_msg (&reply.head, MACH_SEND_MSG, reply.head.msgh_size, + 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + break; + default: + __mach_msg_destroy (&request.head); + case MIG_NO_REPLY: + } + + _hurdsig_fault_expect_signo = 0; + longjmp (_hurdsig_fault_env, 1); +} + +static char faultstack[1024]; + +/* Send exceptions for the signal thread to the proc server. + It will forward the message on to our message port, + and then restore the thread's state to code which + does `longjmp (_hurd_sigthread_fault_env, 1)'. */ + +void +_hurdsig_fault_init (void) +{ + error_t err; + struct machine_thread_state state; + mach_port_t sigexc; + + if (err = __mach_port_allocate (__mach_task_self (), + MACH_PORT_RIGHT_RECEIVE, &sigexc)) + __libc_fatal ("hurd: Can't create receive right for signal thread exc\n"); + if (err = __mach_port_allocate (__mach_task_self (), + MACH_PORT_RIGHT_RECEIVE, &forward_sigexc)) + __libc_fatal ("hurd: Can't create receive right for signal thread exc\n"); + + memset (&state, 0, sizeof state); + MACHINE_THREAD_STATE_SET_PC (&state, faulted); + MACHINE_THREAD_STATE_SET_SP (&state, faultstack, sizeof faultstack); + +#if 0 /* Don't confuse gdb. */ + __thread_set_special_port (_hurd_msgport_thread, + THREAD_EXCEPTION_PORT, sigexc); +#endif + + if (err = __USEPORT + (PROC, + __proc_handle_exceptions (port, + sigexc, + forward_sigexc, MACH_MSG_TYPE_MAKE_SEND, + MACHINE_THREAD_STATE_FLAVOR, + (int *) &state, MACHINE_THREAD_STATE_COUNT))) + __libc_fatal ("hurd: proc won't handle signal thread exceptions\n"); +} + diff -ruN glibc-1.08.1/hurd/hurdfault.h glibc-1.09/hurd/hurdfault.h --- glibc-1.08.1/hurd/hurdfault.h Wed Dec 31 19:00:00 1969 +++ glibc-1.09/hurd/hurdfault.h Sun Sep 4 15:04:20 1994 @@ -0,0 +1,49 @@ +/* Declarations for handling faults in the signal thread. +Copyright (C) 1994 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#ifndef _HURD_FAULT_H +#define _HURD_FAULT_H + +#include + +/* Call this before code that might fault in the signal thread; SIGNO is + the signal expected to possibly arrive. This behaves like setjmp: it + returns zero the first time, and returns again nonzero if the signal + does arrive. */ + +#define _hurdsig_catch_fault(signo) \ + (_hurdsig_fault_expect_signo = (signo), setjmp (_hurdsig_fault_env)) + +/* Call this at the end of a section protected by _hurdsig_catch_fault. */ + +#define _hurdsig_end_catch_fault() \ + (_hurdsig_fault_expect_signo = 0) + +extern jmp_buf _hurdsig_fault_env; +extern int _hurdsig_fault_expect_signo; + +/* If _hurdsig_catch_fault returns nonzero, these variables + contain information about the signal that arrived. */ + + + +extern int _hurdsig_fault_sigcode; +extern int _hurdsig_fault_sigerror; + +#endif /* hurd/fault.h */ diff -ruN glibc-1.08.1/hurd/hurdid.c glibc-1.09/hurd/hurdid.c --- glibc-1.08.1/hurd/hurdid.c Mon Apr 4 23:00:32 1994 +++ glibc-1.09/hurd/hurdid.c Mon Jul 18 18:16:34 1994 @@ -20,7 +20,7 @@ #include #include -struct hurd_id_data _hurd_id /* = { lock: MUTEX_INITIALIZER } */; +struct hurd_id_data _hurd_id; /* Check that _hurd_id.{gen,aux} are valid and update them if not. @@ -31,7 +31,6 @@ { if (! _hurd_id.valid) { - error_t err; inline void dealloc (__typeof (_hurd_id.gen) *p) { if (p->uids) @@ -41,6 +40,7 @@ p->nuids * sizeof (uid_t)); p->uids = NULL; } + p->nuids = 0; if (p->gids) { __vm_deallocate (__mach_task_self (), @@ -48,11 +48,15 @@ p->ngids * sizeof (gid_t)); p->gids = NULL; } + p->ngids = 0; } + error_t err; + dealloc (&_hurd_id.gen); dealloc (&_hurd_id.aux); - if (_hurd_id.rid_auth) + + if (_hurd_id.rid_auth != MACH_PORT_NULL) { __mach_port_deallocate (__mach_task_self (), _hurd_id.rid_auth); _hurd_id.rid_auth = MACH_PORT_NULL; @@ -71,3 +75,18 @@ return 0; } + +static void +init_id (void) +{ + __mutex_init (&_hurd_id.lock); + _hurd_id.valid = 0; + _hurd_id.rid_auth = MACH_PORT_NULL; + _hurd_id.gen.uids = _hurd_id.aux.uids = NULL; + _hurd_id.gen.nuids = _hurd_id.aux.nuids = 0; + _hurd_id.gen.gids = _hurd_id.aux.gids = NULL; + _hurd_id.gen.ngids = _hurd_id.aux.ngids = 0; + + (void) &init_id; /* Avoid "defined but not used" warning. */ +} +text_set_element (_hurd_preinit_hook, init_id); diff -ruN glibc-1.08.1/hurd/hurdinit.c glibc-1.09/hurd/hurdinit.c --- glibc-1.08.1/hurd/hurdinit.c Wed May 25 22:15:10 1994 +++ glibc-1.09/hurd/hurdinit.c Fri Jul 22 11:41:40 1994 @@ -124,9 +124,9 @@ __mach_port_deallocate (__mach_task_self (), oldmsg); /* Tell the proc server where our args and environment are. */ - __proc_setprocargs (procserver, - _hide_arguments ? 0 : (vm_address_t) argv, - _hide_environment ? 0 : (vm_address_t) __environ); + __proc_set_arg_locations (procserver, + _hide_arguments ? 0 : (vm_address_t) argv, + _hide_environment ? 0 : (vm_address_t) __environ); _hurd_port_free (&_hurd_ports[INIT_PORT_PROC], &ulink, procserver); @@ -137,4 +137,46 @@ on the _hurd_subinit hook because things there assume that things done here, like _hurd_pid, are already initialized. */ RUN_HOOK (_hurd_proc_subinit, ()); +} + +/* Called when we get a message telling us to change our proc server port. */ + +error_t +_hurd_setproc (process_t procserver) +{ + error_t err; + mach_port_t oldmsg; + + /* Give the proc server our message port. */ + if (err = __proc_setmsgport (procserver, _hurd_msgport, &oldmsg)) + return err; + if (oldmsg != MACH_PORT_NULL) + /* Deallocate the old msg port we replaced. */ + __mach_port_deallocate (__mach_task_self (), oldmsg); + + /* Tell the proc server where our args and environment are. */ + if (err = __proc_set_arg_locations (procserver, + /* We don't know the ARGV location. */ + (vm_address_t) 0, + _hide_environment ? 0 : + (vm_address_t) __environ)) + return err; + + /* Those calls worked, so the port looks good. */ + _hurd_port_set (&_hurd_ports[INIT_PORT_PROC], procserver); + + { + extern DEFINE_HOOK (_hurd_pgrp_changed_hook, (pid_t)); + pid_t oldpgrp = _hurd_pgrp; + + /* Call these functions again so they can fetch the + new information from the new proc server. */ + RUN_HOOK (_hurd_proc_subinit, ()); + + if (_hurd_pgrp != oldpgrp) + /* Run things that want notification of a pgrp change. */ + RUN_HOOK (_hurd_pgrp_changed_hook, (_hurd_pgrp)); + } + + return 0; } diff -ruN glibc-1.08.1/hurd/hurdinline.c glibc-1.09/hurd/hurdinline.c --- glibc-1.08.1/hurd/hurdinline.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/hurd/hurdinline.c Mon Jul 18 18:16:35 1994 @@ -0,0 +1,11 @@ +/* Include this first to avoid defining its inline functions. */ +#include + +#undef _EXTERN_INLINE +#define _EXTERN_INLINE /* Define the real function. */ + +#include "hurd/fd.h" +#include "hurd/signal.h" +#include "hurd/userlink.h" +#include "hurd/threadvar.h" +#include "hurd/port.h" diff -ruN glibc-1.08.1/hurd/hurdintr.awk glibc-1.09/hurd/hurdintr.awk --- glibc-1.08.1/hurd/hurdintr.awk Tue Mar 24 05:26:25 1992 +++ glibc-1.09/hurd/hurdintr.awk Wed Dec 31 19:00:00 1969 @@ -1,25 +0,0 @@ -BEGIN { intr=0; wantcall=0; calls=""; } - -$1 == "/*" && $2 == "INTR" && $3 == "*/" { intr=1; } - -NF == 1 && $1 == "routine" { wantcall=1; next; } - -intr != 0 && wantcall == 0 && NF >= 2 && $1 == "routine" \ - { - if (substr($2, length($2)-2, 1) == "(") - calls = calls " " substr($2, 0, length($2)-1); - else calls = calls " " $2; - intr=0; - } - -wantcall != 0 && NF >= 1 \ - { - if (substr($1, length($1)-2, 1) == "(") - calls = calls " " substr($1, 0, length($1)-1); - else calls = calls " " $1; - intr=0; - } - -{ wantcall=0; } - -END { print varname " :=" calls; } diff -ruN glibc-1.08.1/hurd/hurdioctl.c glibc-1.09/hurd/hurdioctl.c --- glibc-1.08.1/hurd/hurdioctl.c Sat May 21 20:20:38 1994 +++ glibc-1.09/hurd/hurdioctl.c Fri Sep 30 17:44:50 1994 @@ -22,14 +22,19 @@ #include #include -/* Symbol set of ioctl handler lists. This definition is here so that when - __ioctl refers to it, we will link in fionread et al (below). */ -const struct +/* Symbol set of ioctl handler lists. + This must be uninitialized for ld to use it for the set. */ +struct handler_set { size_t n; struct ioctl_handler *v[0]; - } _hurd_ioctl_handler_lists; + }; +struct handler_set _hurd_ioctl_handler_lists; + +/* This definition is here (and initialized!) so that when __ioctl refers + to it, we will link in fionread et al (below). */ +struct handler_set *const _hurd_ioctl_handlers = &_hurd_ioctl_handler_lists; #include @@ -135,10 +140,9 @@ { if (id == cttyid && /* Is it ours? */ /* Get the ctty io port. */ - __term_become_ctty (port, _hurd_pid, - _hurd_pgrp, - _hurd_msgport, - &newctty)) + __term_open_ctty (port, + _hurd_pid, _hurd_pgrp, + &newctty)) /* XXX it is our ctty but the call failed? */ newctty = MACH_PORT_NULL; __mach_port_deallocate @@ -158,6 +162,32 @@ } +/* Called when we have received a message saying to use a new ctty ID port. */ + +error_t +_hurd_setcttyid (mach_port_t cttyid) +{ + error_t err; + + if (cttyid != MACH_PORT_NULL) + { + /* Give the new send right a user reference. + This is a good way to check that it is valid. */ + if (err = __mach_port_mod_refs (__mach_task_self (), cttyid, + MACH_PORT_RIGHT_SEND, 1)) + return err; + } + + /* Install the port, consuming the reference we just created. */ + _hurd_port_set (&_hurd_ports[INIT_PORT_CTTYID], cttyid); + + /* Reset all the ctty ports in all the descriptors. */ + __USEPORT (CTTYID, (rectty_dtable (cttyid), 0)); + + return 0; +} + + /* Make FD be the controlling terminal. This function is called for `ioctl (fd, TCIOSCTTY)'. */ @@ -169,8 +199,8 @@ error_t err; /* Get FD's cttyid port, unless it is already ours. */ - err = HURD_DPORT_USE (fd, - ctty ? EADDRINUSE : __term_getctty (port, &cttyid)); + err = HURD_DPORT_USE (fd, ctty != MACH_PORT_NULL ? EADDRINUSE : + __term_getctty (port, &cttyid)); if (err == EADDRINUSE) /* FD is already the ctty. Nothing to do. */ return 0; @@ -178,10 +208,10 @@ return __hurd_fail (err); /* Make it our own. */ - _hurd_port_set (&_hurd_ports[INIT_PORT_CTTYID], cttyid); /* Consumes ref. */ + _hurd_port_set (&_hurd_ports[INIT_PORT_CTTYID], cttyid); /* Reset all the ctty ports in all the descriptors. */ - __USEPORT (CTTYID, (rectty_dtable (port), 0)); + __USEPORT (CTTYID, (rectty_dtable (cttyid), 0)); return 0; } diff -ruN glibc-1.08.1/hurd/hurdkill.c glibc-1.09/hurd/hurdkill.c --- glibc-1.08.1/hurd/hurdkill.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/hurd/hurdkill.c Fri Aug 19 15:38:43 1994 @@ -0,0 +1,83 @@ +/* Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include +#include +#include +#include +#include + +/* Send a `sig_post' RPC to process number PID. If PID is zero, + send the message to all processes in the current process's process group. + If PID is < -1, send SIG to all processes in process group - PID. + SIG and REFPORT are passed along in the request message. */ +error_t +_hurd_sig_post (pid_t pid, int sig, mach_port_t arg_refport) +{ + int delivered = 0; /* Set when we deliver any signal. */ + error_t err; + mach_port_t proc; + struct hurd_userlink ulink; + + inline void kill_pid (pid_t pid) /* Kill one PID. */ + { + err = HURD_MSGPORT_RPC (__proc_getmsgport (proc, pid, &msgport), + ((refport = arg_refport), 0), + /* If no message port we cannot send signals. */ + msgport == MACH_PORT_NULL ? EPERM : + __sig_post (msgport, sig, refport)); + if (! err) + delivered = 1; + } + + proc = _hurd_port_get (&_hurd_ports[INIT_PORT_PROC], &ulink); + + if (pid <= 0) + { + /* Send SIG to each process in pgrp (- PID). */ + mach_msg_type_number_t npids = 10, i; + pid_t pidsbuf[10], *pids = pidsbuf; + + err = __proc_getpgrppids (proc, - pid, &pids, &npids); + if (!err) + { + for (i = 0; i < npids; ++i) + { + kill_pid (pids[i]); + if (err == ESRCH) + /* The process died already. Ignore it. */ + err = 0; + } + if (pids != pidsbuf) + __vm_deallocate (__mach_task_self (), + (vm_address_t) pids, npids * sizeof (pids[0])); + } + } + else + kill_pid (pid); + + _hurd_port_free (&_hurd_ports[INIT_PORT_PROC], &ulink, proc); + + /* If we delivered no signals, but ERR is clear, this must mean that + every kill_pid call failed with ESRCH, meaning all the processes in + the pgrp died between proc_getpgrppids and kill_pid; in that case we + fail with ESRCH. */ + return delivered ? 0 : err ?: ESRCH; +} diff -ruN glibc-1.08.1/hurd/hurdlookup.c glibc-1.09/hurd/hurdlookup.c --- glibc-1.08.1/hurd/hurdlookup.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/hurd/hurdlookup.c Sun Sep 11 23:28:06 1994 @@ -0,0 +1,373 @@ +/* Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include +#include +#include "stdio/_itoa.h" +#include + + +/* Translate the error from dir_lookup into the error the user sees. */ +static inline error_t +lookup_error (error_t error) +{ + switch (error) + { + case EOPNOTSUPP: + case MIG_BAD_ID: + /* These indicate that the server does not understand dir_lookup + at all. If it were a directory, it would, by definition. */ + return ENOTDIR; + default: + return error; + } +} + +error_t +__hurd_file_name_lookup (file_t crdir, file_t cwdir, + const char *file_name, int flags, mode_t mode, + file_t *result) +{ + error_t err; + enum retry_type doretry; + char retryname[1024]; /* XXX string_t LOSES! */ + file_t startdir; + + startdir = file_name[0] == '/' ? crdir : cwdir; + + while (file_name[0] == '/') + file_name++; + + if (err = __dir_lookup (startdir, file_name, flags, mode, + &doretry, retryname, result)) + return lookup_error (err); + + return __hurd_file_name_lookup_retry (crdir, doretry, retryname, flags, mode, + result); +} + +error_t +__hurd_file_name_lookup_retry (file_t crdir, + enum retry_type doretry, + char retryname[1024], + int flags, mode_t mode, + file_t *result) +{ + error_t err; + file_t startdir; + file_t newpt; + char *file_name; + int dealloc_dir; + int nloops; + + dealloc_dir = 0; + nloops = 0; + err = 0; + + while (1) + { + if (dealloc_dir) + __mach_port_deallocate (__mach_task_self (), startdir); + if (err) + return lookup_error (err); + + switch (doretry) + { + case FS_RETRY_REAUTH: + { + mach_port_t ref = __mach_reply_port (); + err = __io_reauthenticate (*result, + ref, MACH_MSG_TYPE_MAKE_SEND); + if (! err) + err = __USEPORT + (AUTH, __auth_user_authenticate (port, *result, + ref, + MACH_MSG_TYPE_MAKE_SEND, + &newpt)); + __mach_port_destroy (__mach_task_self (), ref); + } + __mach_port_deallocate (__mach_task_self (), *result); + if (err) + return err; + *result = newpt; + /* Fall through. */ + + case FS_RETRY_NORMAL: +#ifdef SYMLOOP_MAX + if (nloops++ >= SYMLOOP_MAX) + return ELOOP; +#endif + + /* An empty RETRYNAME indicates we have the final port. */ + if (retryname[0] == '\0') + { + /* We got a successful translation. Now apply any open-time + action flags we were passed. */ + if (flags & O_EXLOCK) + ; /* XXX */ + if (!err && (flags & O_SHLOCK)) + ; /* XXX */ + if (!err && (flags & O_TRUNC)) + err = __file_truncate (*result, 0); + + if (err) + __mach_port_deallocate (__mach_task_self (), *result); + return err; + } + + startdir = *result; + dealloc_dir = 1; + file_name = retryname; + break; + + case FS_RETRY_MAGICAL: + switch (retryname[0]) + { + case '/': + startdir = crdir; + dealloc_dir = 0; + if (*result != MACH_PORT_NULL) + __mach_port_deallocate (__mach_task_self (), *result); + file_name = &retryname[1]; + break; + + case 'f': + if (retryname[1] == 'd' && retryname[2] == '/') + { + int fd; + char *end; + int save = errno; + errno = 0; + fd = (int) strtol (retryname, &end, 10); + if (end == NULL || errno || /* Malformed number. */ + /* Check for excess text after the number. A slash + is valid; it ends the component. Anything else + does not name a numeric file descriptor. */ + (*end != '/' && *end != '\0')) + { + errno = save; + return ENOENT; + } + *result = __getdport (fd); + if (*result == MACH_PORT_NULL) + { + /* If the name was a proper number, but the file + descriptor does not exist, we return EBADF instead + of ENOENT. */ + error_t err = errno; + errno = save; + return err; + } + errno = save; + if (*end == '\0') + return 0; + else + { + /* Do a normal retry on the remaining components. */ + startdir = *result; + dealloc_dir = 1; + file_name = end + 1; /* Skip the slash. */ + break; + } + } + else + goto bad_magic; + break; + + case 'm': + if (retryname[1] == 'a' && retryname[2] == 'c' && + retryname[3] == 'h' && retryname[4] == 't' && + retryname[5] == 'y' && retryname[6] == 'p' && + retryname[7] == 'e') + { + error_t err; + struct host_basic_info hostinfo; + unsigned int hostinfocnt = HOST_BASIC_INFO_COUNT; + char *p; + if (err = __host_info (__mach_host_self (), HOST_BASIC_INFO, + (int *) &hostinfo, &hostinfocnt)) + return err; + if (hostinfocnt != HOST_BASIC_INFO_COUNT) + return EGRATUITOUS; + p = _itoa (hostinfo.cpu_subtype, &retryname[8], 10, 0); + *--p = '/'; + p = _itoa (hostinfo.cpu_type, &retryname[8], 10, 0); + if (p < retryname) + abort (); /* XXX write this right if this ever happens */ + if (p > retryname) + strcpy (retryname, p); + startdir = *result; + dealloc_dir = 1; + } + else + goto bad_magic; + break; + + case 't': + if (retryname[1] == 't' && retryname[2] == 'y') + switch (retryname[3]) + { + error_t opentty (file_t *result) + { + error_t err; + file_t unauth; + err = __USEPORT (CTTYID, + __termctty_open_terminal (port, + flags, + &unauth)); + if (! err) + { + mach_port_t ref = __mach_reply_port (); + err = __io_reauthenticate + (unauth, + ref, + MACH_MSG_TYPE_MAKE_SEND); + if (! err) + err = __USEPORT + (AUTH, __auth_user_authenticate + (port, + unauth, + ref, MACH_MSG_TYPE_MAKE_SEND, + result)); + __mach_port_deallocate (__mach_task_self (), + unauth); + __mach_port_destroy (__mach_task_self (), ref); + } + return err; + } + + case '\0': + return opentty (result); + case '/': + if (err = opentty (&startdir)) + return err; + dealloc_dir = 1; + strcpy (retryname, &retryname[4]); + break; + default: + goto bad_magic; + } + else + goto bad_magic; + break; + + default: + bad_magic: + return EGRATUITOUS; + } + break; + + default: + return EGRATUITOUS; + } + + err = __dir_lookup (startdir, file_name, flags, mode, + &doretry, retryname, result); + } +} + +error_t +__hurd_file_name_split (file_t crdir, file_t cwdir, + const char *file_name, + file_t *dir, char **name) +{ + const char *lastslash; + error_t err; + + lastslash = strrchr (file_name, '/'); + if (lastslash != NULL) + { + if (lastslash == file_name) + { + /* "/foobar" => crdir + "foobar". */ + *name = (char *) file_name + 1; + if (err = __mach_port_mod_refs (__mach_task_self (), + crdir, MACH_PORT_RIGHT_SEND, +1)) + return err; + *dir = crdir; + return 0; + } + else + { + /* "/dir1/dir2/.../file". */ + char dirname[lastslash - file_name + 1]; + memcpy (dirname, file_name, lastslash - file_name); + dirname[lastslash - file_name] = '\0'; + *name = (char *) lastslash + 1; + return __hurd_file_name_lookup (crdir, cwdir, dirname, 0, 0, dir); + } + } + else + { + /* "foobar" => cwdir + "foobar". */ + *name = (char *) file_name; + if (err = __mach_port_mod_refs (__mach_task_self (), + cwdir, MACH_PORT_RIGHT_SEND, +1)) + return err; + *dir = cwdir; + return 0; + } +} + +file_t +__file_name_lookup (const char *file_name, int flags, mode_t mode) +{ + error_t err; + file_t result, crdir, cwdir; + struct hurd_userlink crdir_ulink, cwdir_ulink; + + crdir = _hurd_port_get (&_hurd_ports[INIT_PORT_CRDIR], &crdir_ulink); + cwdir = _hurd_port_get (&_hurd_ports[INIT_PORT_CWDIR], &cwdir_ulink); + + err = __hurd_file_name_lookup (crdir, cwdir, file_name, flags, mode, + &result); + + _hurd_port_free (&_hurd_ports[INIT_PORT_CRDIR], &crdir_ulink, crdir); + _hurd_port_free (&_hurd_ports[INIT_PORT_CWDIR], &cwdir_ulink, cwdir); + + if (err) + return __hurd_fail (err), MACH_PORT_NULL; + else + return result; +} + +file_t +__file_name_split (const char *file_name, char **name) +{ + error_t err; + file_t dir, crdir, cwdir; + struct hurd_userlink crdir_ulink, cwdir_ulink; + + crdir = _hurd_port_get (&_hurd_ports[INIT_PORT_CRDIR], &crdir_ulink); + cwdir = _hurd_port_get (&_hurd_ports[INIT_PORT_CWDIR], &cwdir_ulink); + + err = __hurd_file_name_split (crdir, cwdir, file_name, &dir, name); + + _hurd_port_free (&_hurd_ports[INIT_PORT_CRDIR], &crdir_ulink, crdir); + _hurd_port_free (&_hurd_ports[INIT_PORT_CWDIR], &cwdir_ulink, cwdir); + + if (err) + { + errno = err; + return MACH_PORT_NULL; + } + else + return dir; +} diff -ruN glibc-1.08.1/hurd/hurdmalloc.c glibc-1.09/hurd/hurdmalloc.c --- glibc-1.08.1/hurd/hurdmalloc.c Fri Jun 3 21:48:44 1994 +++ glibc-1.09/hurd/hurdmalloc.c Mon Jul 18 18:16:38 1994 @@ -35,7 +35,10 @@ */ /* * HISTORY - * $Log: malloc.c,v $ + * $Log: hurdmalloc.c,v $ + * Revision 1.5 1994/06/04 01:48:44 roland + * entered into RCS + * * Revision 2.7 91/05/14 17:57:34 mrt * Correcting copyright * diff -ruN glibc-1.08.1/hurd/hurdmsg.c glibc-1.09/hurd/hurdmsg.c --- glibc-1.08.1/hurd/hurdmsg.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/hurd/hurdmsg.c Wed Aug 17 21:55:32 1994 @@ -0,0 +1,424 @@ +/* Copyright (C) 1992, 1994 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include +#include +#include +#include + + +#define AUTHCHECK \ + if (auth != mach_task_self () && ! __USEPORT (AUTH, port == auth)) \ + return EPERM + + +/* Snarfing and frobbing the init ports. */ + +kern_return_t +_S_get_init_port (mach_port_t msgport, mach_port_t auth, int which, + mach_port_t *result, mach_msg_type_name_t *result_type) +{ + AUTHCHECK; + *result_type = MACH_MSG_TYPE_MOVE_SEND; + /* This function adds a new user reference for the *RESULT it gives back. + Our reply message uses a move-send right that consumes this reference. */ + return _hurd_ports_get (which, result); +} + +kern_return_t +_S_set_init_port (mach_port_t msgport, mach_port_t auth, + int which, mach_port_t port) +{ + error_t err; + + AUTHCHECK; + + err = _hurd_ports_set (which, port); + if (err == 0) + __mach_port_deallocate (__mach_task_self (), port); + + return 0; +} + +kern_return_t +_S_get_init_ports (mach_port_t msgport, mach_port_t auth, + mach_port_t **ports, + mach_msg_type_name_t *ports_type, + unsigned int *nports) +{ + unsigned int i; + error_t err; + + AUTHCHECK; + + if (err = __vm_allocate (__mach_task_self (), (vm_address_t *) ports, + _hurd_nports * sizeof (mach_port_t), 1)) + return err; + *nports = _hurd_nports; + + for (i = 0; i < _hurd_nports; ++i) + /* This function adds a new user ref for the *RESULT it gives back. + Our reply message uses move-send rights that consumes this ref. */ + if (err = _hurd_ports_get (i, &(*ports)[i])) + { + /* Died part way through. Deallocate the ports already fetched. */ + while (i-- > 0) + __mach_port_deallocate (__mach_task_self (), (*ports)[i]); + __vm_deallocate (__mach_task_self (), + (vm_address_t) *ports, + *nports * sizeof (mach_port_t)); + return err; + } + + *ports_type = MACH_MSG_TYPE_MOVE_SEND; + return 0; +} + +kern_return_t +_S_set_init_ports (mach_port_t msgport, mach_port_t auth, + mach_port_t *ports, unsigned int nports) +{ + unsigned int i; + error_t err; + + AUTHCHECK; + + for (i = 0; i < _hurd_nports; ++i) + { + if (err = _hurd_ports_set (i, ports[i])) + return err; + else + __mach_port_deallocate (__mach_task_self (), ports[i]); + } + + return 0; +} + +/* Snarfing and frobbing the init ints. */ + +static kern_return_t +get_int (int which, int *value) +{ + switch (which) + { + case INIT_UMASK: + *value = _hurd_umask; + return 0; + case INIT_SIGMASK: + { + struct hurd_sigstate *ss = _hurd_thread_sigstate (_hurd_sigthread); + *value = ss->blocked; + __mutex_unlock (&ss->lock); + return 0; + } + case INIT_SIGPENDING: + { + struct hurd_sigstate *ss = _hurd_thread_sigstate (_hurd_sigthread); + *value = ss->pending; + __mutex_unlock (&ss->lock); + return 0; + } + case INIT_SIGIGN: + { + struct hurd_sigstate *ss = _hurd_thread_sigstate (_hurd_sigthread); + sigset_t ign; + int sig; + __sigemptyset (&ign); + for (sig = 1; sig < NSIG; ++sig) + if (ss->actions[sig].sa_handler == SIG_IGN) + __sigaddset (&ign, sig); + __mutex_unlock (&ss->lock); + *value = ign; + return 0; + } + default: + return EINVAL; + } +} + +kern_return_t +_S_get_init_int (mach_port_t msgport, mach_port_t auth, + int which, int *value) +{ + AUTHCHECK; + + return get_int (which, value); +} + +kern_return_t +_S_get_init_ints (mach_port_t msgport, mach_port_t auth, + int **values, unsigned int *nvalues) +{ + error_t err; + unsigned int i; + + AUTHCHECK; + + if (err = __vm_allocate (__mach_task_self (), (vm_address_t *) values, + INIT_INT_MAX * sizeof (int), 1)) + return err; + *nvalues = INIT_INT_MAX; + + for (i = 0; i < INIT_INT_MAX; ++i) + switch (err = get_int (i, &(*values)[i])) + { + case 0: /* Success. */ + break; + case EINVAL: /* Unknown index. */ + (*values)[i] = 0; + break; + default: /* Lossage. */ + __vm_deallocate (__mach_task_self (), + (vm_address_t) *values, INIT_INT_MAX * sizeof (int)); + return err; + } + + return 0; +} + + +static kern_return_t +set_int (int which, int value) +{ + switch (which) + { + case INIT_UMASK: + _hurd_umask = value; + return 0; + + /* These are pretty odd things to do. But you asked for it. */ + case INIT_SIGMASK: + { + struct hurd_sigstate *ss = _hurd_thread_sigstate (_hurd_sigthread); + ss->blocked = value; + __mutex_unlock (&ss->lock); + return 0; + } + case INIT_SIGPENDING: + { + struct hurd_sigstate *ss = _hurd_thread_sigstate (_hurd_sigthread); + ss->pending = value; + __mutex_unlock (&ss->lock); + return 0; + } + case INIT_SIGIGN: + { + struct hurd_sigstate *ss = _hurd_thread_sigstate (_hurd_sigthread); + int sig; + const sigset_t ign = value; + for (sig = 1; sig < NSIG; ++sig) + { + if (__sigismember (&ign, sig)) + ss->actions[sig].sa_handler = SIG_IGN; + else if (ss->actions[sig].sa_handler == SIG_IGN) + ss->actions[sig].sa_handler = SIG_DFL; + } + __mutex_unlock (&ss->lock); + return 0; + } + default: + return EINVAL; + } +} + +kern_return_t +_S_set_init_int (mach_port_t msgport, mach_port_t auth, + int which, int value) +{ + AUTHCHECK; + + return set_int (which, value); +} + +kern_return_t +_S_set_init_ints (mach_port_t msgport, mach_port_t auth, + int *values, unsigned int nvalues) +{ + error_t err; + unsigned int i; + + AUTHCHECK; + + for (i = 0; i < INIT_INT_MAX; ++i) + switch (err = set_int (i, values[i])) + { + case 0: /* Success. */ + break; + case EINVAL: /* Unknown index. */ + break; + default: /* Lossage. */ + return err; + } + + return 0; +} + + +kern_return_t +_S_get_fd (mach_port_t msgport, mach_port_t auth, + int which, mach_port_t *result, mach_msg_type_name_t *result_type) +{ + AUTHCHECK; + + /* This creates a new user reference for the send right. + Our reply message will move that reference to the caller. */ + *result = __getdport (which); + if (*result == MACH_PORT_NULL) + return errno; + *result_type = MACH_MSG_TYPE_MOVE_SEND; + + return 0; +} + +kern_return_t +_S_set_fd (mach_port_t msgport, mach_port_t auth, + int which, mach_port_t port) +{ + AUTHCHECK; + + /* We consume the reference if successful. */ + return HURD_FD_USE (which, (_hurd_port2fd (descriptor, port, 0), 0)); +} + +/* Snarfing and frobbing environment variables. */ + +kern_return_t +_S_get_env_variable (mach_port_t msgport, + char *variable, + char **data, unsigned int *datalen) +{ + const char *value = getenv (variable); + + if (value == NULL) + return ENOENT; + + /* XXX this pointer might become invalid */ + *data = value; + *datalen = strlen (value); + return 0; +} + + +kern_return_t +_S_set_env_variable (mach_port_t msgport, mach_port_t auth, + char *variable, + char *value, + int replace) +{ + AUTHCHECK; + + if (setenv (variable, value, replace)) /* XXX name space */ + return errno; + return 0; +} + +kern_return_t +_S_get_environment (mach_port_t msgport, + char **data, unsigned int *datalen) +{ + /* Pack the environment into an array with nulls separating elements. */ + if (__environ != NULL) + { + char *ap, **p; + size_t envlen = 0; + + for (p = __environ; *p != NULL; ++p) + envlen += strlen (*p) + 1; + + if (envlen > *datalen) + { + if (__vm_allocate (__mach_task_self (), + (vm_address_t *) data, envlen, 1)) + return ENOMEM; + } + + ap = *data; + for (p = __environ; *p != NULL; ++p) + ap = __memccpy (ap, *p, '\0', ULONG_MAX); + + *datalen = envlen; + } + else + *datalen = 0; + + return 0; +} + +kern_return_t +_S_set_environment (mach_port_t msgport, mach_port_t auth, + char *data, unsigned int datalen) +{ + int _hurd_split_args (char *, unsigned int, char **); + int envc; + char **envp; + + AUTHCHECK; + + envc = _hurd_split_args (data, datalen, NULL); + envp = malloc ((envc + 1) * sizeof (char *)); + if (envp == NULL) + return errno; + _hurd_split_args (data, datalen, envp); + __environ = envp; /* XXX cooperate with loadenv et al */ + return 0; +} + + + +/* XXX */ + +kern_return_t +_S_get_dtable (mach_port_t process, + mach_port_t refport, + portarray_t *dtable, + mach_msg_type_name_t *dtablePoly, + mach_msg_type_number_t *dtableCnt) +{ return EOPNOTSUPP; } + +kern_return_t +_S_set_dtable (mach_port_t process, + mach_port_t refport, + portarray_t dtable, + mach_msg_type_number_t dtableCnt) +{ return EOPNOTSUPP; } + +kern_return_t +_S_io_select_done (mach_port_t notify_port, + mach_msg_type_name_t notify_port_type, + int select_result, + int id_tag) +{ return EOPNOTSUPP; } + +kern_return_t +_S_startup_dosync (mach_port_t process) +{ return EOPNOTSUPP; } + +kern_return_t +_S_dir_changed (mach_port_t notify_port, + dir_changed_type_t change, + string_t name) +{ return EOPNOTSUPP; } + +kern_return_t +_S_file_changed (mach_port_t notify_port, + file_changed_type_t change, + off_t start, + off_t end) +{ return EOPNOTSUPP; } diff -ruN glibc-1.08.1/hurd/hurdpath.c glibc-1.09/hurd/hurdpath.c --- glibc-1.08.1/hurd/hurdpath.c Tue Apr 19 20:52:36 1994 +++ glibc-1.09/hurd/hurdpath.c Wed Dec 31 19:00:00 1969 @@ -1,210 +0,0 @@ -/* Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc. -This file is part of the GNU C Library. - -The GNU C Library is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. - -The GNU C Library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with the GNU C Library; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA. */ - -#include -#include -#include -#include - -error_t -__hurd_path_lookup (file_t crdir, file_t cwdir, - const char *path, int flags, mode_t mode, - file_t *result) -{ - error_t err; - file_t startdir; - - enum retry_type doretry; - char retryname[1024]; /* XXX string_t LOSES! */ - file_t newpt; - int dealloc_dir; - int nloops; - - if (*path == '/') - { - startdir = crdir; - while (*path == '/') - ++path; - } - else - startdir = cwdir; - - dealloc_dir = 0; - nloops = 0; - - for (;;) - { - err = __dir_pathtrans (startdir, (char *) path, flags, mode, - &doretry, retryname, result); - - if (dealloc_dir) - __mach_port_deallocate (__mach_task_self (), startdir); - if (err) - return err; - - switch (doretry) - { - case FS_RETRY_NONE: - /* We got a successful translation. Now apply any - open-time action flags we were passed. */ - if (flags & O_EXLOCK) - ; /* XXX */ - if (!err && (flags & O_SHLOCK)) - ; /* XXX */ - if (!err && (flags & O_TRUNC)) - err = __file_truncate (*result, 0); - - if (err) - __mach_port_deallocate (__mach_task_self (), *result); - return err; - - case FS_RETRY_REAUTH: - __io_reauthenticate (*result, _hurd_pid); - __USEPORT (AUTH, __auth_user_authenticate (port, *result, _hurd_pid, - &newpt)); - __mach_port_deallocate (__mach_task_self (), *result); - *result = newpt; - /* Fall through. */ - - case FS_RETRY_NORMAL: -#ifdef SYMLOOP_MAX - if (nloops++ >= SYMLOOP_MAX) - return ELOOP; -#endif - - if (retryname[0] == '/') - { - startdir = crdir; - dealloc_dir = 0; - path = retryname; - do - ++path; - while (*path == '/'); - } - else - { - startdir = *result; - dealloc_dir = 1; - path = retryname; - } - break; - - /* case FS_RETRY_MAGICAL: XXX */ - } - } -} - -error_t -__hurd_path_split (file_t crdir, file_t cwdir, - const char *path, - file_t *dir, char **name) -{ - const char *lastslash; - error_t err; - - /* Skip leading slashes in the pathname. */ - if (*path == '/') - { - while (*path == '/') - ++path; - --path; /* Leave on one slash. */ - } - - lastslash = strrchr (path, '/'); - - if (lastslash != NULL) - { - if (lastslash == path) - { - /* "/foobar" => crdir + "foobar". */ - *name = (char *) path + 1; - if (err = __mach_port_mod_refs (__mach_task_self (), - crdir, MACH_PORT_RIGHT_SEND, +1)) - return err; - *dir = crdir; - return 0; - } - else - { - /* "/dir1/dir2/.../file". */ - char dirname[lastslash - path + 1]; - memcpy (dirname, path, lastslash - path); - dirname[lastslash - path] = '\0'; - *name = (char *) lastslash + 1; - return __hurd_path_lookup (crdir, cwdir, dirname, 0, 0, dir); - } - } - else - { - /* "foobar" => cwdir + "foobar". */ - *name = (char *) path; - if (err = __mach_port_mod_refs (__mach_task_self (), - cwdir, MACH_PORT_RIGHT_SEND, +1)) - return err; - *dir = cwdir; - return 0; - } -} - -file_t -__path_lookup (const char *path, int flags, mode_t mode) -{ - error_t err; - file_t result, crdir, cwdir; - struct hurd_userlink crdir_ulink, cwdir_ulink; - - crdir = _hurd_port_get (&_hurd_ports[INIT_PORT_CRDIR], &crdir_ulink); - cwdir = _hurd_port_get (&_hurd_ports[INIT_PORT_CWDIR], &cwdir_ulink); - - err = __hurd_path_lookup (crdir, cwdir, path, flags, mode, &result); - - _hurd_port_free (&_hurd_ports[INIT_PORT_CRDIR], &crdir_ulink, crdir); - _hurd_port_free (&_hurd_ports[INIT_PORT_CWDIR], &cwdir_ulink, cwdir); - - if (err) - { - errno = err; - return MACH_PORT_NULL; - } - else - return result; -} - -file_t -__path_split (const char *path, char **name) -{ - error_t err; - file_t dir, crdir, cwdir; - struct hurd_userlink crdir_ulink, cwdir_ulink; - - crdir = _hurd_port_get (&_hurd_ports[INIT_PORT_CRDIR], &crdir_ulink); - cwdir = _hurd_port_get (&_hurd_ports[INIT_PORT_CWDIR], &cwdir_ulink); - - err = __hurd_path_split (crdir, cwdir, path, &dir, name); - - _hurd_port_free (&_hurd_ports[INIT_PORT_CRDIR], &crdir_ulink, crdir); - _hurd_port_free (&_hurd_ports[INIT_PORT_CWDIR], &cwdir_ulink, cwdir); - - if (err) - { - errno = err; - return MACH_PORT_NULL; - } - else - return dir; -} diff -ruN glibc-1.08.1/hurd/hurdpid.c glibc-1.09/hurd/hurdpid.c --- glibc-1.08.1/hurd/hurdpid.c Sat Jun 4 08:54:03 1994 +++ glibc-1.09/hurd/hurdpid.c Mon Aug 22 01:35:20 1994 @@ -30,15 +30,22 @@ __proc_getpids (port, &_hurd_pid, &_hurd_ppid, &_hurd_orphaned); __proc_getpgrp (port, _hurd_pid, &_hurd_pgrp); })); + + (void) &init_pids; /* Avoid "defined but not used" warning. */ } text_set_element (_hurd_proc_subinit, init_pids); #include #include "set-hooks.h" +#include DEFINE_HOOK (_hurd_pgrp_changed_hook, (pid_t)); - + +/* These let user threads synchronize with an operation which changes ids. */ +unsigned int _hurd_pids_changed_stamp; +struct condition _hurd_pids_changed_sync; + kern_return_t _S_proc_newids (mach_port_t me, task_t task, @@ -55,6 +62,12 @@ /* Run things that want notification of a pgrp change. */ RUN_HOOK (_hurd_pgrp_changed_hook, (_hurd_pgrp)); + + /* Notify any waiting user threads that the id change as been completed. */ + ++_hurd_pids_changed_stamp; +#ifdef noteven + __condition_broadcast (&_hurd_pids_changed_sync); +#endif return 0; } diff -ruN glibc-1.08.1/hurd/hurdports.c glibc-1.09/hurd/hurdports.c --- glibc-1.08.1/hurd/hurdports.c Thu Feb 3 21:07:46 1994 +++ glibc-1.09/hurd/hurdports.c Mon Jul 18 18:16:41 1994 @@ -19,38 +19,25 @@ #include #include + static inline mach_port_t -get (const size_t idx) +get (const int idx) { mach_port_t result; - error_t err = HURD_PORT_USE (&_hurd_ports[idx], - __mach_port_mod_refs (__mach_task_self (), - (result = port), - MACH_PORT_RIGHT_SEND, - 1)); + error_t err = _hurd_ports_get (idx, &result); + if (err) - { - errno = err; - return MACH_PORT_NULL; - } - else - return result; + return __hurd_fail (err), MACH_PORT_NULL; + return result; } #define GET(type, what, idx) \ type get##what (void) { return get (INIT_PORT_##idx); } static inline int -set (const size_t idx, mach_port_t new) +set (const int idx, mach_port_t new) { - error_t err; - if (err = __mach_port_mod_refs (__mach_task_self (), new, - MACH_PORT_RIGHT_SEND, 1)) - { - errno = EINVAL; - return -1; - } - _hurd_port_set (&_hurd_ports[idx], new); - return 0; + error_t err = _hurd_ports_set (idx, new); + return err ? __hurd_fail (err) : 0; } #define SET(type, what, idx) \ int set##what (type new) { return set (INIT_PORT_##idx, new); } @@ -59,8 +46,7 @@ GET (type, what, idx) SET (type, what, idx) GETSET (process_t, proc, PROC) +GETSET (mach_port_t, cttyid, CTTYID) GETSET (file_t, cwdir, CWDIR) GETSET (file_t, crdir, CRDIR) - -/* setauth is nontrivial; see __setauth.c. */ -GET (auth_t, auth, AUTH) +GETSET (auth_t, auth, AUTH) diff -ruN glibc-1.08.1/hurd/hurdprio.c glibc-1.09/hurd/hurdprio.c --- glibc-1.08.1/hurd/hurdprio.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/hurd/hurdprio.c Fri Oct 28 16:36:06 1994 @@ -0,0 +1,87 @@ +/* Support code for dealing with priorities in the Hurd. +Copyright (C) 1994 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include + +error_t +_hurd_priority_which_map (enum __priority_which which, int who, + error_t (*function) (pid_t, struct procinfo *)) +{ + unsigned int npids = 64, i; + pid_t pidbuf[npids], *pids; + error_t err; + struct procinfo *pip; + int pibuf[sizeof *pip + 5 * sizeof (pip->threadinfos[0])], *pi = pibuf; + unsigned int pisize = sizeof (pibuf) / sizeof (int); + + switch (which) + { + case PRIO_PROCESS: + npids = 1; + pids[0] = who; + err = 0; + break; + + case PRIO_PGRP: + err = __USEPORT (PROC, __proc_getpgrppids (port, who, &pids, &npids)); + break; + + case PRIO_USER: + err = __USEPORT (PROC, __proc_getallpids (port, &pids, &npids)); + break; + + default: + return EINVAL; + } + + for (i = 0; !err && i < npids; ++i) + { + if (which == PRIO_USER) + { + /* Get procinfo to check the owner. */ + int *oldpi = pi; + unsigned int oldpisize = pisize; + if (err = __USEPORT (PROC, __proc_getprocinfo (port, pids[i], + &pi, &pisize))) + continue; + if (pi != oldpi && oldpi != pibuf) + /* Old buffer from last call was not reused; free it. */ + __vm_deallocate (__mach_task_self (), + (vm_address_t) oldpi, oldpisize * sizeof pi[0]); + + pip = (struct procinfo *) pi; + if (pip->owner != who) + continue; + } + else + pip = NULL; + + err = (*function) (pids[i], pip); + } + + if (pids != pidbuf) + __vm_deallocate (__mach_task_self (), + (vm_address_t) pids, npids * sizeof pids[0]); + if (pi != pibuf) + __vm_deallocate (__mach_task_self (), + (vm_address_t) pi, pisize * sizeof pi[0]); + + return err; +} diff -ruN glibc-1.08.1/hurd/hurdrlimit.c glibc-1.09/hurd/hurdrlimit.c --- glibc-1.08.1/hurd/hurdrlimit.c Sat Jun 4 00:44:42 1994 +++ glibc-1.09/hurd/hurdrlimit.c Tue Aug 16 02:47:01 1994 @@ -24,7 +24,7 @@ /* This must be given an initializer, or the a.out linking rules will not include the entire file when this symbol is referenced. */ -struct rlimit _hurd_rlimits[RLIM_NLIMITS] = {[0] = 0}; +struct rlimit _hurd_rlimits[RLIM_NLIMITS] = { { 0, }, }; /* This must be initialized data for the same reason as above, but this is intentionally initialized to a bogus value to emphasize the point that diff -ruN glibc-1.08.1/hurd/hurdsig.c glibc-1.09/hurd/hurdsig.c --- glibc-1.08.1/hurd/hurdsig.c Sat Jun 4 08:52:54 1994 +++ glibc-1.09/hurd/hurdsig.c Wed Oct 19 19:58:46 1994 @@ -23,9 +23,12 @@ #include #include /* For `struct mutex'. */ #include +#include "hurdfault.h" #include "hurdmalloc.h" /* XXX */ -struct mutex _hurd_siglock = MUTEX_INITIALIZER; +const char *_hurdsig_getenv (const char *); + +struct mutex _hurd_siglock; int _hurd_stopped; /* Port that receives signals and other miscellaneous messages. */ @@ -39,6 +42,19 @@ /* Linked-list of per-thread signal state. */ struct hurd_sigstate *_hurd_sigstates; + +static void +default_sigaction (struct sigaction actions[NSIG]) +{ + int signo; + + __sigemptyset (&actions[0].sa_mask); + actions[0].sa_flags = SA_RESTART; + actions[0].sa_handler = SIG_DFL; + + for (signo = 1; signo < NSIG; ++signo) + actions[signo] = actions[0]; +} struct hurd_sigstate * _hurd_thread_sigstate (thread_t thread) @@ -53,9 +69,40 @@ ss = malloc (sizeof (*ss)); if (ss == NULL) __libc_fatal ("hurd: Can't allocate thread sigstate\n"); - memset (ss, 0, sizeof (*ss)); ss->thread = thread; __mutex_init (&ss->lock); + + /* Initialze default state. */ + __sigemptyset (&ss->blocked); + __sigemptyset (&ss->pending); + memset (&ss->sigaltstack, 0, sizeof (ss->sigaltstack)); + ss->suspended = 0; +#ifdef noteven + __condition_init (&ss->arrived); +#endif + ss->intr_port = MACH_PORT_NULL; + ss->context = NULL; + + /* Initialize the sigaction vector from the default signal receiving + thread's state, and its from the system defaults. */ + if (thread == _hurd_sigthread) + default_sigaction (ss->actions); + else + { + struct hurd_sigstate *s; + for (s = _hurd_sigstates; s != NULL; s = s->next) + if (s->thread == _hurd_sigthread) + break; + if (s) + { + __mutex_lock (&s->lock); + memcpy (ss->actions, s->actions, sizeof (s->actions)); + __mutex_unlock (&s->lock); + } + else + default_sigaction (ss->actions); + } + ss->next = _hurd_sigstates; _hurd_sigstates = ss; } @@ -64,6 +111,8 @@ return ss; } +/* Signal delivery itself is on this page. */ + #include #include #include @@ -73,229 +122,315 @@ #include "thread_state.h" #include #include /* For __sig_post_reply. */ - -jmp_buf _hurd_sigthread_fault_env; +#include +#include int _hurd_core_limit; /* XXX */ /* Call the core server to mummify us before we die. Returns nonzero if a core file was written. */ static int -write_corefile (int signo, int sigcode) +write_corefile (int signo, int sigcode, int sigerror) { error_t err; - volatile mach_port_t coreserver; - volatile file_t file; - char *volatile name; - char *volatile target; - - /* XXX RLIMIT_CORE */ + mach_port_t coreserver; + file_t file, coredir; + const char *name; + + /* XXX RLIMIT_CORE: + When we have a protocol to make the server return an error + for RLIMIT_FSIZE, then tell the corefile fs server the RLIMIT_CORE + value in place of the RLIMIT_FSIZE value. */ + /* First get a port to the core dumping server. */ coreserver = MACH_PORT_NULL; - if (!setjmp (_hurd_sigthread_fault_env)) - { - name = getenv ("CORESERVER"); - if (name != NULL) - coreserver = __path_lookup (name, 0, 0); - } - + name = _hurdsig_getenv ("CORESERVER"); + if (name != NULL) + coreserver = __file_name_lookup (name, 0, 0); if (coreserver == MACH_PORT_NULL) - coreserver = __path_lookup (_SERVERS_CORE, 0, 0); + coreserver = __file_name_lookup (_SERVERS_CORE, 0, 0); if (coreserver == MACH_PORT_NULL) return 0; - file = MACH_PORT_NULL; - name = NULL; - if (!setjmp (_hurd_sigthread_fault_env)) - { - name = getenv ("COREFILE"); - if (name != NULL) - file = __path_lookup (name, O_WRONLY|O_CREAT, 0666 & ~_hurd_umask); - } - if (name == NULL || file == MACH_PORT_NULL) - { - name = (char *) "core"; - file = __path_lookup (name, O_WRONLY|O_CREAT, 0666 & ~_hurd_umask); - } - - if (file == MACH_PORT_NULL) + /* Get a port to the directory where the new core file will reside. */ + name = _hurdsig_getenv ("COREFILE"); + if (name == NULL) + name = "core"; + coredir = __file_name_split (name, (char **) &name); + if (coredir == MACH_PORT_NULL) + return 0; + /* Create the new file, but don't link it into the directory yet. */ + if (err = __dir_mkfile (coredir, O_WRONLY|O_CREAT, + 0600 & ~_hurd_umask, /* XXX ? */ + &file)) return 0; - if (setjmp (_hurd_sigthread_fault_env)) - /* We bombed in getenv. */ - target = NULL; - else - { - target = getenv ("GNUTARGET"); - /* Fault now if TARGET is a bogus string. */ - (void) strlen (target); - } - + /* Call the core dumping server to write the core file. */ err = __core_dump_task (coreserver, __mach_task_self (), - file, - signo, sigcode, - target); + file, _hurdsig_getenv ("GNUTARGET"), + signo, sigcode, sigerror); __mach_port_deallocate (__mach_task_self (), coreserver); + if (! err) + /* The core dump into FILE succeeded, so now link it into the + directory. */ + err = __dir_link (file, coredir, name); __mach_port_deallocate (__mach_task_self (), file); - if (err) - (void) remove (name); + __mach_port_deallocate (__mach_task_self (), coredir); return !err; } -/* How long to give servers to respond to - interrupt_operation before giving up on them. */ -mach_msg_timeout_t _hurd_interrupt_timeout = 1000; /* One second. */ - -/* SS->thread is suspended. Fills STATE in with its registers. - SS->lock is held and kept. */ +/* Send a sig_post reply message if it hasn't already been sent. */ static inline void -abort_rpcs (struct hurd_sigstate *ss, int signo, void *state) +post_reply (mach_port_t *reply_port, mach_msg_type_name_t reply_port_type, + error_t result) { - unsigned int count = MACHINE_THREAD_STATE_COUNT; - __thread_abort (ss->thread); - if (__thread_get_state (ss->thread, MACHINE_THREAD_STATE_FLAVOR, - state, &count) != KERN_SUCCESS || - count != MACHINE_THREAD_STATE_COUNT) - /* What kind of thread?? */ - return; /* XXX */ - - if (ss->intr_port != MACH_PORT_NULL) - { - /* Abort whatever the thread is doing. - If it is in the mach_msg syscall doing the send, - the syscall will return MACH_SEND_INTERRUPTED. */ - mach_port_t msging_port; - if (_hurd_thread_state_msging_p (state, &msging_port)) - { - /* The thread was waiting for the RPC to return. - Abort the operation. The RPC will return EINTR. */ + if (reply_port == NULL || *reply_port == MACH_PORT_NULL) + return; + __sig_post_reply (*reply_port, reply_port_type, result); + *reply_port = MACH_PORT_NULL; +} - struct - { - mach_msg_header_t header; - mach_msg_type_t type; - kern_return_t retcode; - } msg; - kern_return_t err; - - msg.header.msgh_remote_port = ss->intr_port; - msg.header.msgh_local_port = __mach_reply_port (); - msg.header.msgh_seqno = 0; - msg.header.msgh_id = 33000; /* interrupt_operation XXX */ - err = __mach_msg (&msg.header, - MACH_SEND_MSG|MACH_RCV_MSG|MACH_RCV_TIMEOUT, - sizeof (msg.header), sizeof (msg), - msg.header.msgh_local_port, - _hurd_interrupt_timeout, - MACH_PORT_NULL); - if (err != MACH_MSG_SUCCESS) - /* The interrupt didn't work. - Destroy the receive right the thread is blocked on. */ - __mach_port_destroy (__mach_task_self (), msging_port); - else - /* In case the server returned something screwy. */ - __mach_msg_destroy (&msg.header); - /* Tell the thread whether it should restart the - operation or return EINTR when it wakes up. */ - ss->intr_restart = ss->actions[signo].sa_flags & SA_RESTART; - } +/* The lowest-numbered thread state flavor value is 1, + so we use bit 0 in machine_thread_all_state.set to + record whether we have done thread_abort. */ +#define THREAD_ABORTED 1 - /* If the thread is anywhere before the system call trap, - it will start the operation after the signal is handled. - - If the thread is after the system call trap, but before it has - cleared SS->intr_port, the operation is already finished. */ +/* SS->thread is suspended. Abort the thread and get its basic state. If + REPLY_PORT is not NULL, send a reply on *REPLY_PORT after aborting the + thread. */ +static void +abort_thread (struct hurd_sigstate *ss, struct machine_thread_all_state *state, + mach_port_t *reply_port, mach_msg_type_name_t reply_port_type) +{ + if (!(state->set & THREAD_ABORTED)) + { + __thread_abort (ss->thread); + /* Clear all thread state flavor set bits, because thread_abort may + have changed the state. */ + state->set = THREAD_ABORTED; } + + if (reply_port) + post_reply (reply_port, reply_port_type, 0); + + machine_get_basic_state (ss->thread, state); } -/* Abort the RPCs being run by all threads but this one; - all other threads should be suspended. */ -static inline void -abort_all_rpcs (int signo, void *state) +/* Find the location of the MiG reply port cell in use by the thread whose + state is described by THREAD_STATE. Make sure that this location can be + set without faulting, or else return NULL. */ + +static mach_port_t * +interrupted_reply_port_location (struct machine_thread_all_state *thread_state) { - thread_t me = __mach_thread_self (); - thread_t *threads; - mach_msg_type_number_t nthreads, i; + mach_port_t *portloc = (mach_port_t *) __hurd_threadvar_location_from_sp + (_HURD_THREADVAR_MIG_REPLY, (void *) thread_state->basic.SP); - __task_threads (__mach_task_self (), &threads, &nthreads); - for (i = 0; i < nthreads; ++i) + if (_hurdsig_catch_fault (SIGSEGV)) { - if (threads[i] != me) - { - struct hurd_sigstate *ss = _hurd_thread_sigstate (threads[i]); - abort_rpcs (ss, signo, state); - __mutex_unlock (&ss->lock); - } - __mach_port_deallocate (__mach_task_self (), threads[i]); + assert (_hurdsig_fault_sigcode == (int) portloc); + /* Faulted trying to read the stack. */ + return NULL; } + + /* Fault now if this pointer is bogus. */ + *(volatile mach_port_t *) portloc = *portloc; + + _hurdsig_end_catch_fault (); + + return portloc; } -struct hurd_signal_preempt *_hurd_signal_preempt[NSIG]; -struct mutex _hurd_signal_preempt_lock; +/* SS->thread is suspended. + + Abort any interruptible RPC operation the thread is doing. + This uses only the constant member SS->thread and the unlocked, atomically + set member SS->intr_port, so no locking is needed. -/* Fetch the MiG reply port in use by the thread whose interrupted state is - described by *THREAD_STATE, and ensure that the thread will not try to - use it again. */ + If successfully sent an interrupt_operation and therefore the thread should + wait for its pending RPC to return (possibly EINTR) before taking the + incoming signal, returns the reply port to be received on. Otherwise + returns MACH_PORT_NULL. */ static mach_port_t -interrupted_reply_port (struct machine_thread_state *thread_state) +abort_rpcs (struct hurd_sigstate *ss, int signo, + struct machine_thread_all_state *state, + mach_port_t *reply_port, mach_msg_type_name_t reply_port_type) { - mach_port_t port, *portloc; + mach_port_t msging_port; + mach_port_t intr_port; - if (setjmp (_hurd_sigthread_fault_env)) - /* Faulted trying to read the stack. */ + intr_port = ss->intr_port; + if (intr_port == MACH_PORT_NULL) + /* No interruption needs done. */ return MACH_PORT_NULL; - portloc = (mach_port_t *) __hurd_threadvar_location_from_sp - (_HURD_THREADVAR_MIG_REPLY, (void *) thread_state->SP); + /* Abort the thread's kernel context, so any pending message send or + receive completes immediately or aborts. */ + abort_thread (ss, state, reply_port, reply_port_type); + + if (_hurdsig_rcv_interrupted_p (state, &msging_port)) + { + error_t err; + + /* The RPC request message was sent and the thread was waiting for + the reply message; now the message receive has been aborted, so + the mach_msg_call will return MACH_RCV_INTERRUPTED. We must tell + the server to interrupt the pending operation. The thread must + wait for the reply message before running the signal handler (to + guarantee that the operation has finished being interrupted), so + our nonzero return tells the trampoline code to finish the message + receive operation before running the handler. */ + + err = __interrupt_operation (intr_port); + + if (err) + { + mach_port_t *reply; + + /* The interrupt didn't work. + Destroy the receive right the thread is blocked on. */ + __mach_port_destroy (__mach_task_self (), msging_port); + + /* The system call return value register now contains + MACH_RCV_INTERRUPTED; when mach_msg resumes, it will retry the + call. Since we have just destroyed the receive right, the + retry will fail with MACH_RCV_INVALID_NAME. Instead, just + change the return value here to EINTR so mach_msg will not + retry and the EINTR error code will propagate up. */ + state->basic.SYSRETURN = EINTR; + + /* If that was the thread's MiG reply port (which I think should + always be the case), clear the reply port cell so it won't be + reused. */ + reply = interrupted_reply_port_location (state); + if (reply != NULL && *reply == msging_port) + *reply = MACH_PORT_NULL; + } + + /* All threads whose RPCs were interrupted by the interrupt_operation + call above will retry their RPCs unless we clear SS->intr_port. + So we clear it for the thread taking a signal when SA_RESTART is + clear, so that its call returns EINTR. */ + if (!(ss->actions[signo].sa_flags & SA_RESTART)) + ss->intr_port = MACH_PORT_NULL; + + return err ? MACH_PORT_NULL : msging_port; + } + + /* One of the following is true: + + 1. The RPC has not yet been sent. The thread will start its operation + after the signal has been handled. - port = *portloc; - *portloc = MACH_PORT_NULL; - return port; + 2. The RPC has finished, but not yet cleared SS->intr_port. + The thread will clear SS->intr_port after running the handler. + + 3. The RPC request message was being sent was aborted. The mach_msg + system call will return MACH_SEND_INTERRUPTED, and HURD_EINTR_RPC will + notice the interruption (either retrying the RPC or returning EINTR). */ + + return MACH_PORT_NULL; +} + +/* Abort the RPCs being run by all threads but this one; + all other threads should be suspended. */ +static void +abort_all_rpcs (int signo, struct machine_thread_all_state *state) +{ + /* We can just loop over the sigstates. Any thread doing something + interruptible must have one. We needn't bother locking because all + other threads are stopped. */ + + struct hurd_sigstate *ss; + + for (ss = _hurd_sigstates; ss != NULL; ss = ss->next) + if (ss->thread != _hurd_msgport_thread) + /* Abort any operation in progress with interrupt_operation. We + record this by putting the reply port into SS->intr_port, or + MACH_PORT_NULL if no interruption was done. We will wait for + all the replies below. */ + ss->intr_port = abort_rpcs (ss, signo, state, NULL, 0); + + /* Wait for replies from all the successfully interrupted RPCs. */ + for (ss = _hurd_sigstates; ss != NULL; ss = ss->next) + if (ss->intr_port != MACH_PORT_NULL) + { + error_t err; + mach_msg_header_t head; + err = __mach_msg (&head, MACH_RCV_MSG, 0, sizeof head, ss->intr_port, + MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (err != MACH_RCV_TOO_LARGE) + assert_perror (err); + } } +struct hurd_signal_preempt *_hurd_signal_preempt[NSIG]; +struct mutex _hurd_signal_preempt_lock; + +/* Mask of stop signals. */ +#define STOPSIGS (sigmask (SIGTTIN) | sigmask (SIGTTOU) | \ + sigmask (SIGSTOP) | sigmask (SIGTSTP)) + /* Deliver a signal. SS->lock is held on entry and released before return. */ void _hurd_internal_post_signal (struct hurd_sigstate *ss, - int signo, int sigcode, + int signo, int sigcode, int sigerror, mach_port_t reply_port, mach_msg_type_name_t reply_port_type) { - struct machine_thread_state thread_state; + struct machine_thread_all_state thread_state; enum { stop, ignore, core, term, handle } act; sighandler_t handler; struct hurd_signal_preempt *pe; sighandler_t (*preempt) (thread_t, int, int) = NULL; + sigset_t pending; + int ss_suspended; - /* Check SS for pending signals and post them. SS->lock is held on entry. - Return zero if no signals were pending. If pending signals were posted, - unlock SS->lock and return nonzero. */ - inline int check_pending (struct hurd_sigstate *ss) - { - int signo; - - if (ss->pending) - for (signo = 1; signo < NSIG; ++signo) - if (__sigismember (&ss->pending, signo)) - { - __sigdelset (&ss->pending, signo); - _hurd_internal_post_signal (ss, signo, ss->sigcodes[signo], - reply_port, reply_port_type); - /* _hurd_internal_post_signal called us on SS before - returning, so no need to keep looping. */ - return 1; - } + /* Reply to this sig_post message. */ + inline void reply () + { + post_reply (&reply_port, reply_port_type, 0); + } - return 0; + /* Wake up a sigsuspend call that is blocking SS->thread. */ + inline void sigwakeup (void) + { + if (ss->suspended != MACH_PORT_NULL) + { + /* There is a sigsuspend waiting. Tell it to wake up. */ + error_t err; + mach_msg_header_t msg; + err = __mach_port_insert_right (__mach_task_self (), + ss->suspended, ss->suspended, + MACH_MSG_TYPE_MAKE_SEND); + assert_perror (err); + msg.msgh_bits = MACH_MSGH_BITS (MACH_MSG_TYPE_MOVE_SEND, 0); + msg.msgh_remote_port = ss->suspended; + msg.msgh_local_port = MACH_PORT_NULL; + /* These values do not matter. */ + msg.msgh_id = 8675309; /* Jenny, Jenny. */ + msg.msgh_seqno = 17; /* Random. */ + ss->suspended = MACH_PORT_NULL; + err = __mach_msg (&msg, MACH_SEND_MSG, sizeof msg, 0, + MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, + MACH_PORT_NULL); + assert_perror (err); + } + __mutex_unlock (&ss->lock); } + post_signal: + + thread_state.set = 0; /* We know nothing. */ + /* Check for a preempted signal. */ __mutex_lock (&_hurd_signal_preempt_lock); for (pe = _hurd_signal_preempt[signo]; pe != NULL; pe = pe->next) @@ -312,74 +447,115 @@ If it returns SIG_DFL, we run the normal handler; otherwise we use the handler it returns. */ handler = (*preempt) (ss->thread, signo, sigcode); - if (handler == SIG_DFL) - handler = ss->actions[signo].sa_handler; - - if (handler == SIG_DFL) - /* Figure out the default action for this signal. */ - switch (signo) - { - case 0: - /* A sig_post msg with SIGNO==0 is sent to - tell us to check for pending signals. */ - act = ignore; - break; - case SIGTTIN: - case SIGTTOU: - case SIGSTOP: - case SIGTSTP: - ss->pending &= ~sigmask (SIGCONT); - act = stop; - break; + ss_suspended = 0; - case SIGCONT: - ss->pending &= ~(sigmask (SIGSTOP) | sigmask (SIGTSTP) | - sigmask (SIGTTIN) | sigmask (SIGTTOU)); - /* Fall through. */ - case SIGIO: - case SIGURG: - case SIGCHLD: - case SIGWINCH: - act = ignore; - break; + if (handler != SIG_DFL) + /* Run the preemption-provided handler. */ + act = handle; + else + { + /* No preemption. Do normal handling. */ - case SIGQUIT: - case SIGILL: - case SIGTRAP: - case SIGIOT: - case SIGEMT: - case SIGFPE: - case SIGBUS: - case SIGSEGV: - case SIGSYS: - act = core; - break; + handler = ss->actions[signo].sa_handler; - case SIGINFO: - if (_hurd_pgrp == _hurd_pid) + if (handler == SIG_DFL) + /* Figure out the default action for this signal. */ + switch (signo) { - /* We are the process group leader. Since there is no - user-specified handler for SIGINFO, we use a default one - which prints something interesting. We use the normal - handler mechanism instead of just doing it here to avoid the - signal thread faulting or blocking in this potentially hairy - operation. */ - act = handle; - handler = _hurd_siginfo_handler; + case 0: + /* A sig_post msg with SIGNO==0 is sent to + tell us to check for pending signals. */ + act = ignore; + break; + + case SIGTTIN: + case SIGTTOU: + case SIGSTOP: + case SIGTSTP: + act = stop; + break; + + case SIGCONT: + case SIGIO: + case SIGURG: + case SIGCHLD: + case SIGWINCH: + act = ignore; + break; + + case SIGQUIT: + case SIGILL: + case SIGTRAP: + case SIGIOT: + case SIGEMT: + case SIGFPE: + case SIGBUS: + case SIGSEGV: + case SIGSYS: + act = core; + break; + + case SIGINFO: + if (_hurd_pgrp == _hurd_pid) + { + /* We are the process group leader. Since there is no + user-specified handler for SIGINFO, we use a default one + which prints something interesting. We use the normal + handler mechanism instead of just doing it here to avoid + the signal thread faulting or blocking in this + potentially hairy operation. */ + act = handle; + handler = _hurd_siginfo_handler; + } + else + act = ignore; + break; + + default: + act = term; + break; } - else - act = ignore; - break; + else if (handler == SIG_IGN) + act = ignore; + else + act = handle; - default: - act = term; - break; - } - else if (handler == SIG_IGN) - act = ignore; - else - act = handle; + if (sigmask (signo) & STOPSIGS) + /* Stop signals clear a pending SIGCONT even if they + are handled or ignored (but not if preempted). */ + ss->pending &= ~sigmask (SIGCONT); + else if (signo == SIGCONT) + { + /* Even if handled or ignored (but not preempted), + SIGCONT clears stop signals and resumes the process. */ + ss->pending &= ~STOPSIGS; + if (_hurd_stopped) + { + thread_t *threads; + unsigned int nthreads, i; + error_t err; + /* Tell the proc server we are continuing. */ + __USEPORT (PROC, __proc_mark_cont (port)); + /* Fetch ports to all our threads and resume them. */ + err = __task_threads (__mach_task_self (), &threads, &nthreads); + assert_perror (err); + for (i = 0; i < nthreads; ++i) + { + if (threads[i] != _hurd_msgport_thread && + (act != handle || threads[i] != ss->thread)) + __thread_resume (threads[i]); + __mach_port_deallocate (__mach_task_self (), threads[i]); + } + __vm_deallocate (__mach_task_self (), + (vm_address_t) threads, + nthreads * sizeof *threads); + _hurd_stopped = 0; + /* The thread that will run the handler is already suspended. */ + ss_suspended = 1; + } + } + } if (_hurd_orphaned && act == stop && (signo & (__sigmask (SIGTTIN) | __sigmask (SIGTTOU) | @@ -399,7 +575,8 @@ { __sigaddset (&ss->pending, signo); /* Save the code to be given to the handler when SIGNO is unblocked. */ - ss->sigcodes[signo] = sigcode; + ss->pending_data[signo].code = sigcode; + ss->pending_data[signo].error = sigerror; act = ignore; } @@ -407,34 +584,25 @@ switch (act) { case stop: - /* Stop all other threads and mark ourselves stopped. */ - __USEPORT (PROC, - ({ - /* Hold the siglock while stopping other threads to be - sure it is not held by another thread afterwards. */ - __mutex_unlock (&ss->lock); - __mutex_lock (&_hurd_siglock); - __proc_dostop (port, __mach_thread_self ()); - __mutex_unlock (&_hurd_siglock); - abort_all_rpcs (signo, &thread_state); - __proc_mark_stop (port, signo); - })); - _hurd_stopped = 1; - - __mutex_lock (&ss->lock); - if (ss->suspended) + if (! _hurd_stopped) { - /* There is a sigsuspend waiting. Tell it to wake up. */ - ss->suspended = 0; -#ifdef noteven - __condition_signal (&ss->arrived); -#else - __mutex_unlock (&ss->lock); -#endif + /* Stop all other threads and mark ourselves stopped. */ + __USEPORT (PROC, + ({ + /* Hold the siglock while stopping other threads to be + sure it is not held by another thread afterwards. */ + __mutex_unlock (&ss->lock); + __mutex_lock (&_hurd_siglock); + __proc_dostop (port, _hurd_msgport_thread); + __mutex_unlock (&_hurd_siglock); + abort_all_rpcs (signo, &thread_state); + __proc_mark_stop (port, signo); + })); + _hurd_stopped = 1; } - else - __mutex_unlock (&ss->lock); + __mutex_lock (&ss->lock); + sigwakeup (); /* Wake up sigsuspend. */ break; case ignore: @@ -443,54 +611,87 @@ case term: /* Time to die. */ case core: /* And leave a rotting corpse. */ + nirvana: + __mutex_unlock (&ss->lock); /* Have the proc server stop all other threads in our task. */ - __USEPORT (PROC, __proc_dostop (port, __mach_thread_self ())); + __USEPORT (PROC, __proc_dostop (port, _hurd_msgport_thread)); + /* No more user instructions will be executed. + The signal can now be considered delivered. */ + reply (); /* Abort all server operations now in progress. */ abort_all_rpcs (signo, &thread_state); - /* The signal can now be considered delivered. - Don't make the killer wait for us to dump core. */ - if (reply_port) - __sig_post_reply (reply_port, reply_port_type, 0); - /* Tell proc how we died and then stick the saber in the gut. */ - _hurd_exit (W_EXITCODE (0, signo) | - /* Do a core dump if desired. Only set the wait status - bit saying we in fact dumped core if the operation was - actually succesful. */ - (act == core && write_corefile (signo, sigcode) ? - WCOREFLAG : 0)); - /* NOTREACHED */ + + { + int status = W_EXITCODE (0, signo); + /* Do a core dump if desired. Only set the wait status bit saying we + in fact dumped core if the operation was actually successful. */ + if (act == core && write_corefile (signo, sigcode, sigerror)) + status |= WCOREFLAG; + /* Tell proc how we died and then stick the saber in the gut. */ + _hurd_exit (status); + /* NOTREACHED */ + } case handle: /* Call a handler for this signal. */ { struct sigcontext *scp; + int wait_for_reply; /* Stop the thread and abort its pending RPC operations. */ - __thread_suspend (ss->thread); - abort_rpcs (ss, signo, &thread_state); + if (! ss_suspended) + __thread_suspend (ss->thread); + wait_for_reply = (abort_rpcs (ss, signo, &thread_state, + &reply_port, reply_port_type) + != MACH_PORT_NULL); /* Call the machine-dependent function to set the thread up to run the signal handler, and preserve its old context. */ - scp = _hurd_setup_sighandler (ss->actions[signo].sa_flags, - handler, - &ss->sigaltstack, + scp = _hurd_setup_sighandler (ss, handler, signo, sigcode, - &thread_state); + wait_for_reply, &thread_state); + if (scp == NULL) + { + /* We got a fault setting up the stack frame for the handler. + Nothing to do but die; BSD gets SIGILL in this case. */ + sigcode = signo; /* XXX ? */ + signo = SIGILL; + act = core; + goto nirvana; + } /* Set the machine-independent parts of the signal context. */ - scp->sc_mask = ss->blocked; - scp->sc_intr_port = ss->intr_port; - /* Fetch the thread variable for the MiG reply port, - and set it to MACH_PORT_NULL. */ - scp->sc_reply_port = interrupted_reply_port (&thread_state); + + scp->sc_error = sigerror; + { + /* Fetch the thread variable for the MiG reply port, + and set it to MACH_PORT_NULL. */ + mach_port_t *loc = interrupted_reply_port_location (&thread_state); + if (loc) + { + scp->sc_reply_port = *loc; + *loc = MACH_PORT_NULL; + } + else + scp->sc_reply_port = MACH_PORT_NULL; + } /* Block SIGNO and requested signals while running the handler. */ + scp->sc_mask = ss->blocked; ss->blocked |= __sigmask (signo) | ss->actions[signo].sa_mask; - /* Start the thread running the handler. */ + /* Save the intr_port in use by the interrupted code, + and clear the cell before running the trampoline. */ + scp->sc_intr_port = ss->intr_port; + ss->intr_port = MACH_PORT_NULL; + + /* Start the thread running the handler (or possibly waiting for an + RPC reply before running the handler). */ __thread_set_state (ss->thread, MACHINE_THREAD_STATE_FLAVOR, - (int *) &thread_state, MACHINE_THREAD_STATE_COUNT); + (int *) &thread_state.basic, + MACHINE_THREAD_STATE_COUNT); __thread_resume (ss->thread); + thread_state.set = 0; /* Everything we know is now wrong. */ break; } } @@ -500,32 +701,29 @@ signal 0, which can be sent by a user thread to make us check for pending signals. In that case we want to deliver the pending signals before replying. */ - if (signo != 0 && reply_port) - { - __sig_post_reply (reply_port, reply_port_type, 0); - reply_port = MACH_PORT_NULL; - } + if (signo != 0) + reply (); /* We get here only if we are handling or ignoring the signal; otherwise we are stopped or dead by now. We still hold SS->lock. Check for pending signals, and loop to post them. */ - if (! check_pending (ss)) +#define PENDING (!_hurd_stopped && (pending = ss->pending & ~ss->blocked)) + if (PENDING) { - /* No more signals pending; SS->lock is still locked. */ - if (ss->suspended) - { - /* There is a sigsuspend waiting. Tell it to wake up. */ - ss->suspended = 0; -#ifdef noteven - __condition_signal (&ss->arrived); -#else - __mutex_unlock (&ss->lock); -#endif - } - else - __mutex_unlock (&ss->lock); + pending: + for (signo = 1; signo < NSIG; ++signo) + if (__sigismember (&pending, signo)) + { + __sigdelset (&ss->pending, signo); + sigcode = ss->pending_data[signo].code; + sigerror = ss->pending_data[signo].error; + goto post_signal; + } } + /* No more signals pending; SS->lock is still locked. */ + sigwakeup (); + /* No pending signals left undelivered for this thread. If we were sent signal 0, we need to check for pending signals for all threads. */ @@ -535,16 +733,16 @@ for (ss = _hurd_sigstates; ss != NULL; ss = ss->next) { __mutex_lock (&ss->lock); - if (! check_pending (ss)) - __mutex_unlock (&ss->lock); + if (PENDING) + goto pending; + __mutex_unlock (&ss->lock); } __mutex_unlock (&_hurd_siglock); } /* All pending signals delivered to all threads. Now we can send the reply message even for signal 0. */ - if (reply_port) - __sig_post_reply (reply_port, reply_port_type, 0); + reply (); } /* Implement the sig_post RPC from ; @@ -575,6 +773,8 @@ case SIGTSTP: case SIGHUP: case SIGINFO: + case SIGTTIN: + case SIGTTOU: /* Job control signals can be sent by the controlling terminal. */ if (__USEPORT (CTTYID, port == refport)) goto win; @@ -586,9 +786,8 @@ mach_port_t sessport; if (! __USEPORT (PROC, __proc_getsidport (port, &sessport))) { - int win = refport == sessport; __mach_port_deallocate (__mach_task_self (), sessport); - if (win) + if (refport == sessport) goto win; } } @@ -648,7 +847,7 @@ /* Post the signal; this will reply when the signal can be considered delivered. */ - _hurd_internal_post_signal (ss, signo, 0, reply_port, reply_port_type); + _hurd_internal_post_signal (ss, signo, 0, 0, reply_port, reply_port_type); return MIG_NO_REPLY; /* Already replied. */ } @@ -666,6 +865,8 @@ error_t err; vm_size_t stacksize; + __mutex_init (&_hurd_siglock); + if (err = __mach_port_allocate (__mach_task_self (), MACH_PORT_RIGHT_RECEIVE, &_hurd_msgport)) @@ -713,52 +914,44 @@ TASK_EXCEPTION_PORT, _hurd_msgport); #endif } - -/* Send exceptions for the signal thread to the proc server. - It will forward the message on to our message port, - and then restore the thread's state to code which - does `longjmp (_hurd_sigthread_fault_env, 1)'. */ - -void -_hurdsig_fault_init (void) -{ - error_t err; - mach_port_t sigexc; - struct machine_thread_state state; - - if (err = __mach_port_allocate (__mach_task_self (), - MACH_PORT_RIGHT_RECEIVE, &sigexc)) - __libc_fatal ("hurd: Can't create receive right for signal thread exc\n"); - - /* Set up STATE with a thread state that will longjmp immediately. */ - _hurd_initialize_fault_recovery_state (&state); - -#if 0 /* Don't confuse gdb. */ - __thread_set_special_port (_hurd_msgport_thread, - THREAD_EXCEPTION_PORT, sigexc); -#endif - - if (err = __USEPORT - (PROC, - __proc_handle_exceptions (port, - sigexc, - _hurd_msgport, MACH_MSG_TYPE_COPY_SEND, - MACHINE_THREAD_STATE_FLAVOR, - (int *) &state, MACHINE_THREAD_STATE_COUNT))) - __libc_fatal ("hurd: proc won't handle signal thread exceptions\n"); -} /* XXXX */ +/* Reauthenticate with the proc server. */ + static void reauth_proc (mach_port_t new) { - mach_port_t ignore; + mach_port_t ref, ignore; - /* Reauthenticate with the proc server. */ + ref = __mach_reply_port (); if (! HURD_PORT_USE (&_hurd_ports[INIT_PORT_PROC], - __proc_reauthenticate (port, _hurd_pid) || - __auth_user_authenticate (new, port, _hurd_pid, + __proc_reauthenticate (port, ref, + MACH_MSG_TYPE_MAKE_SEND) || + __auth_user_authenticate (new, port, ref, + MACH_MSG_TYPE_MAKE_SEND, &ignore)) && ignore != MACH_PORT_NULL) __mach_port_deallocate (__mach_task_self (), ignore); + __mach_port_destroy (__mach_task_self (), ref); + + (void) &reauth_proc; /* Silence compiler warning. */ } text_set_element (__hurd_reauth_hook, reauth_proc); + +/* Like `getenv', but safe for the signal thread to run. + If the environment is trashed, this will just return NULL. */ + +const char * +_hurdsig_getenv (const char *variable) +{ + if (_hurdsig_catch_fault (SIGSEGV)) + /* We bombed in getenv. */ + return NULL; + else + { + const char *value = getenv (variable); + /* Fault now if VALUE is a bogus string. */ + (void) strlen (value); + _hurdsig_end_catch_fault (); + return value; + } +} diff -ruN glibc-1.08.1/hurd/hurdsock.c glibc-1.09/hurd/hurdsock.c --- glibc-1.08.1/hurd/hurdsock.c Sat Jun 4 03:33:57 1994 +++ glibc-1.09/hurd/hurdsock.c Thu Oct 6 18:56:34 1994 @@ -28,7 +28,7 @@ #include /* For `struct mutex'. */ #include "hurdmalloc.h" /* XXX */ -static struct mutex lock = MUTEX_INITIALIZER; +static struct mutex lock; static file_t *servers; static int max_domain; @@ -44,7 +44,7 @@ and does not look them up in /servers/socket more than once. */ socket_t -_hurd_socket_server (int domain) +_hurd_socket_server (int domain, int dead) { socket_t server; @@ -53,35 +53,65 @@ if (domain > max_domain) { + error_t save = errno; file_t *new = realloc (servers, (domain + 1) * sizeof (file_t)); - if (new == NULL) + if (new != NULL) { - server = MACH_PORT_NULL; - goto out; + while (max_domain <= domain) + new[max_domain++] = MACH_PORT_NULL; + servers = new; } - while (max_domain < domain) - new[max_domain++] = MACH_PORT_NULL; - servers = new; + else + /* No space to cache the port; we will just fetch it anew below. */ + errno = save; } - { - char name[sizeof (_SERVERS_SOCKET) + 100]; - char *np = &name[sizeof (name)]; - *--np = '\0'; - np = _itoa (domain, np, 10, 0); - *--np = '/'; - np -= sizeof (_SERVERS_SOCKET) - 1; - memcpy (np, _SERVERS_SOCKET, sizeof (_SERVERS_SOCKET) - 1); - server = servers[domain] = __path_lookup (np, 0, 0); - } + if (dead && domain <= max_domain) + { + /* The user says the port we returned earlier (now in SERVERS[DOMAIN]) + was dead. Clear the cache and fetch a new one below. */ + __mach_port_deallocate (__mach_task_self (), servers[domain]); + servers[domain] = MACH_PORT_NULL; + } + + if (domain > max_domain || servers[domain] == MACH_PORT_NULL) + { + char name[sizeof (_SERVERS_SOCKET) + 100]; + char *np = &name[sizeof (name)]; + *--np = '\0'; + np = _itoa (domain, np, 10, 0); + *--np = '/'; + np -= sizeof (_SERVERS_SOCKET) - 1; + memcpy (np, _SERVERS_SOCKET, sizeof (_SERVERS_SOCKET) - 1); + server = __file_name_lookup (np, 0, 0); + if (domain <= max_domain) + servers[domain] = server; + } + else + server = servers[domain]; - if (errno == ENOENT) + if (server == MACH_PORT_NULL && errno == ENOENT) /* If the server node is absent, we don't support that protocol. */ errno = EPFNOSUPPORT; - out: __mutex_unlock (&lock); HURD_CRITICAL_END; return server; } + +#include + +static void +init (void) +{ + size_t i; + + __mutex_init (&lock); + + for (i = 0; i < max_domain; ++i) + servers[i] = MACH_PORT_NULL; + + (void) &init; /* Avoid "defined but not used" warning. */ +} +text_set_element (_hurd_preinit_hook, init); diff -ruN glibc-1.08.1/hurd/hurdsyms.c glibc-1.09/hurd/hurdsyms.c --- glibc-1.08.1/hurd/hurdsyms.c Sat Feb 8 03:13:04 1992 +++ glibc-1.09/hurd/hurdsyms.c Tue Aug 30 05:07:56 1994 @@ -1,4 +1,4 @@ -/* Copyright (C) 1992 Free Software Foundation, Inc. +/* Copyright (C) 1992, 1994 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -18,7 +18,12 @@ #include -symbol_alias (__hurd_path_lookup, hurd_path_lookup); -symbol_alias (__path_lookup, path_lookup); -symbol_alias (__hurd_path_split, hurd_path_split); -symbol_alias (__path_split, path_split); +symbol_alias (__hurd_file_name_lookup, hurd_file_name_lookup); +symbol_alias (__hurd_file_name_lookup_retry, hurd_file_name_lookup_retry); +symbol_alias (__file_name_lookup, file_name_lookup); +symbol_alias (__hurd_file_name_split, hurd_file_name_split); +symbol_alias (__file_name_split, file_name_split); + +symbol_alias (_hurd_sig_post, hurd_sig_post); + +symbol_alias (__hurd_invoke_translator, hurd_invoke_translator); diff -ruN glibc-1.08.1/hurd/intr-rpc.awk glibc-1.09/hurd/intr-rpc.awk --- glibc-1.08.1/hurd/intr-rpc.awk Wed Dec 31 19:00:00 1969 +++ glibc-1.09/hurd/intr-rpc.awk Mon Jul 18 18:16:44 1994 @@ -0,0 +1,44 @@ +# Icky intimate knowledge of MiG output. + +BEGIN \ + { + nprotolines=0; proto=0; + args=""; echo=1; isintr=0; + intrcall = "__hurd_intr_rpc_" call; + print "#include "; + } + +$NF == intrcall { isintr=1; } + +NF == 1 && $1 == ")" { proto=0; } +proto \ + { + protolines[nprotolines++] = $0; + arg = $NF; + if (substr(arg, 1, 1) == "*") + arg = substr(arg, 2, length(arg)-1); + args = args arg; + } +NF == 1 && $1 == "(" { proto=1; } + +NF == 3 && $1 == "InP->Head.msgh_request_port" \ + { portarg = substr($3, 1, length($3)-1); } + +{ print $0; } + +END \ + { + if (isintr) + { + print "\n\n/* User-callable interrupt-handling stub. */"; + print "kern_return_t __" call; + print "("; + for (i = 0; i < nprotolines; ++i) + print protolines[i]; + print ")"; + print "{"; + print " return HURD_EINTR_RPC (" portarg ", " \ + intrcall "(" args "));"; + print "}"; + } + } diff -ruN glibc-1.08.1/hurd/intr-rpc.defs glibc-1.09/hurd/intr-rpc.defs --- glibc-1.08.1/hurd/intr-rpc.defs Wed Dec 31 19:00:00 1969 +++ glibc-1.09/hurd/intr-rpc.defs Mon Jul 18 18:16:44 1994 @@ -0,0 +1,27 @@ +/* Special MiG definitions for interruptible RPC stubs. +Copyright (C) 1994 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +/* Set the MiG options for an interruptible RPC interface. + We rename each MiG-generated function to hurd_intr_rpc_CALL and + give it the option to return on an interrupted message send. */ + +#define INTR_INTERFACE \ +msgoption MACH_SEND_INTERRUPT;\ +userprefix hurd_intr_rpc_; + diff -ruN glibc-1.08.1/hurd/intr_rpc.awk glibc-1.09/hurd/intr_rpc.awk --- glibc-1.08.1/hurd/intr_rpc.awk Wed Sep 16 17:03:58 1992 +++ glibc-1.09/hurd/intr_rpc.awk Wed Dec 31 19:00:00 1969 @@ -1,28 +0,0 @@ -# Icky intimate knowledge of MiG output. - -BEGIN { args=""; argsnext=0; echo=1; print "#include "; } - -$NF == rpc \ - { - for (i = 1; i < NF; ++i) printf "%s ", $i; - print call; - next; - } - -args == "" && $1 == "#else" { argsnext=1; print $0; next; } - -argsnext == 1 { args=$0; firstarg=substr($1, 2, length($1)-2); } - -{ argsnext=0; } - -/^{/ { echo=0; } - -echo == 1 { print $0; } - -/^}/ \ - { - print "{"; - print " return HURD_EINTR_RPC (" firstarg ", " rpc args ");"; - print "}"; - echo = 1; - } diff -ruN glibc-1.08.1/hurd/invoke-trans.c glibc-1.09/hurd/invoke-trans.c --- glibc-1.08.1/hurd/invoke-trans.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/hurd/invoke-trans.c Tue Aug 30 05:07:48 1994 @@ -0,0 +1,37 @@ +/* Copyright (C) 1994 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include + +error_t +__hurd_invoke_translator (file_t file, int flags, file_t *newport) +{ + error_t err; + enum retry_type doretry; + char retryname[1024]; /* XXX string_t LOSES! */ + + err = __file_invoke_translator (file, flags, &doretry, retryname, newport); + + if (! err) + err = __USEPORT (CRDIR, __hurd_file_name_lookup_retry (port, + doretry, retryname, + flags, 0, newport)); + + return err; +} diff -ruN glibc-1.08.1/hurd/msgstub.c glibc-1.09/hurd/msgstub.c --- glibc-1.08.1/hurd/msgstub.c Thu Apr 21 22:31:41 1994 +++ glibc-1.09/hurd/msgstub.c Wed Dec 31 19:00:00 1969 @@ -1,24 +0,0 @@ -#include - -/* XXX */ -#define STUB(fn) error_t fn (mach_port_t port) { return EOPNOTSUPP; } - -STUB(_S_get_init_ports) -STUB(_S_set_init_ports) -STUB(_S_get_init_port) -STUB(_S_set_init_port) -STUB(_S_get_init_ints) -STUB(_S_set_init_ints) -STUB(_S_get_init_int) -STUB(_S_set_init_int) -STUB(_S_get_dtable) -STUB(_S_set_dtable) -STUB(_S_get_fd) -STUB(_S_set_fd) -STUB(_S_get_environment) -STUB(_S_set_environment) -STUB(_S_get_env_variable) -STUB(_S_set_env_variable) -STUB(_S_io_select_done) -STUB(_S_startup_dosync) - diff -ruN glibc-1.08.1/hurd/port2fd.c glibc-1.09/hurd/port2fd.c --- glibc-1.08.1/hurd/port2fd.c Tue May 3 23:20:56 1994 +++ glibc-1.09/hurd/port2fd.c Fri Sep 30 17:11:04 1994 @@ -55,16 +55,7 @@ } } - if (is_ctty && ! __term_become_ctty (port, _hurd_pid, _hurd_pgrp, - _hurd_msgport, &ctty)) - { - /* Operations on CTTY return EBACKGROUND when we are not a - foreground user of the tty. */ - mach_port_t tmp = port; - port = ctty; - ctty = tmp; - } - else + if (!is_ctty || __term_open_ctty (port, _hurd_pid, _hurd_pgrp, &ctty) != 0) /* XXX if IS_CTTY, then this port is our ctty, but we are not doing ctty style i/o because term_become_ctty barfed. What to do? */ diff -ruN glibc-1.08.1/hurd/ports-get.c glibc-1.09/hurd/ports-get.c --- glibc-1.08.1/hurd/ports-get.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/hurd/ports-get.c Mon Jul 18 18:16:47 1994 @@ -0,0 +1,46 @@ +/* Copyright (C) 1994 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include + +static error_t +getbootstrap (mach_port_t *result) +{ + return __task_get_special_port (__mach_task_self (), + TASK_BOOTSTRAP_PORT, + result); +} + +error_t (*_hurd_ports_getters[INIT_PORT_MAX]) (mach_port_t *result) = + { + [INIT_PORT_BOOTSTRAP] = getbootstrap, + }; + +error_t +_hurd_ports_get (int which, mach_port_t *result) +{ + if (which < 0 || which >= _hurd_nports) + return EINVAL; + if (which >= INIT_PORT_MAX || _hurd_ports_getters[which] == NULL) + return HURD_PORT_USE (&_hurd_ports[which], + __mach_port_mod_refs (__mach_task_self (), + (*result = port), + MACH_PORT_RIGHT_SEND, + +1)); + return (*_hurd_ports_getters[which]) (result); +} diff -ruN glibc-1.08.1/hurd/ports-set.c glibc-1.09/hurd/ports-set.c --- glibc-1.08.1/hurd/ports-set.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/hurd/ports-set.c Mon Jul 18 18:16:48 1994 @@ -0,0 +1,57 @@ +/* Copyright (C) 1994 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include + +static error_t +setbootstrap (mach_port_t newport) +{ + return __task_set_special_port (__mach_task_self (), + TASK_BOOTSTRAP_PORT, + newport); +} + +extern error_t _hurd_setauth (auth_t); +extern error_t _hurd_setproc (process_t); +extern error_t _hurd_setcttyid (mach_port_t); + +error_t (*_hurd_ports_setters[INIT_PORT_MAX]) (mach_port_t newport) = + { + [INIT_PORT_BOOTSTRAP] = setbootstrap, + [INIT_PORT_AUTH] = _hurd_setauth, + [INIT_PORT_PROC] = _hurd_setproc, + [INIT_PORT_CTTYID] = _hurd_setcttyid, + }; + + +error_t +_hurd_ports_set (int which, mach_port_t newport) +{ + error_t err; + if (which < 0 || which >= _hurd_nports) + return EINVAL; + if (err = __mach_port_mod_refs (__mach_task_self (), newport, + MACH_PORT_RIGHT_SEND, 1)) + return err; + if (which >= INIT_PORT_MAX || _hurd_ports_setters[which] == NULL) + { + _hurd_port_set (&_hurd_ports[which], newport); + return 0; + } + return (*_hurd_ports_setters[which]) (newport); +} diff -ruN glibc-1.08.1/inet/Makefile glibc-1.09/inet/Makefile --- glibc-1.08.1/inet/Makefile Wed May 19 16:01:51 1993 +++ glibc-1.09/inet/Makefile Sun Sep 4 22:06:26 1994 @@ -1,4 +1,4 @@ -# Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. +# Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc. # This file is part of the GNU C Library. # The GNU C Library is free software; you can redistribute it and/or @@ -21,22 +21,14 @@ # subdir := inet -headers := netdb.h resolv.h \ - netinet/in.h \ - sys/bitypes.h \ - $(wildcard arpa/*.h protocols/*.h) -distribute := ../conf/portability.h +headers := netinet/in.h $(wildcard arpa/*.h protocols/*.h) netdb.h routines := ntohl ntohs htonl htons \ inet_addr inet_lnaof inet_mkadr \ inet_netof inet_ntoa inet_net \ - getnetbyad getnetbynm getnetent \ getproto getprtent getprtname \ getsrvbynm getsrvbypt getservent \ - res_comp res_debug res_init res_mkqry res_query res_send \ - gethstnmad sethostent \ rcmd rexec -aux := herror # No warnings about losing BSD code. override +gccwarn := -w diff -ruN glibc-1.08.1/inet/arpa/ftp.h glibc-1.09/inet/arpa/ftp.h --- glibc-1.08.1/inet/arpa/ftp.h Wed May 13 02:59:42 1992 +++ glibc-1.09/inet/arpa/ftp.h Sun Jul 31 14:20:18 1994 @@ -1,6 +1,6 @@ /* - * Copyright (c) 1983, 1989 Regents of the University of California. - * All rights reserved. + * Copyright (c) 1983, 1989, 1993 + * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)ftp.h 5.6 (Berkeley) 4/3/91 + * @(#)ftp.h 8.1 (Berkeley) 6/2/93 */ #ifndef _FTP_H_ diff -ruN glibc-1.08.1/inet/arpa/inet.h glibc-1.09/inet/arpa/inet.h --- glibc-1.08.1/inet/arpa/inet.h Wed May 19 15:33:33 1993 +++ glibc-1.09/inet/arpa/inet.h Sun Aug 7 01:52:05 1994 @@ -1,14 +1,7 @@ /* - * @(#)inet.h 5.7 (Berkeley) 4/3/91 - * $Id: inet.h,v 4.9.1.2 1993/05/17 09:59:01 vixie Exp $ - */ - -/* - * ++Copyright++ 1983 - * - - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. - * + * 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: @@ -19,12 +12,12 @@ * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. + * This product includes software developed by the University of + * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -36,26 +29,8 @@ * LIABILITY, OR TORT (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-- + * + * @(#)inet.h 8.1 (Berkeley) 6/2/93 */ #ifndef _INET_H_ @@ -63,22 +38,16 @@ /* External definitions for functions in inet(3) */ -#include -#if (!defined(BSD)) || (BSD < 199306) -# include -#else -# include -#endif #include __BEGIN_DECLS -extern u_int32_t inet_addr __P((const char *)); -extern u_int32_t inet_lnaof __P((struct in_addr)); -extern struct in_addr inet_makeaddr __P((u_int32_t, u_int32_t)); -extern u_int32_t inet_netof __P((struct in_addr)); -extern u_int32_t inet_network __P((const char *)); -extern int inet_aton __P((const char *, struct in_addr *)); -extern char *inet_ntoa __P((struct in_addr)); +unsigned long inet_addr __P((const char *)); +int inet_aton __P((const char *, struct in_addr *)); +unsigned long inet_lnaof __P((struct in_addr)); +struct in_addr inet_makeaddr __P((u_long , u_long)); +unsigned long inet_netof __P((struct in_addr)); +unsigned long inet_network __P((const char *)); +char *inet_ntoa __P((struct in_addr)); __END_DECLS #endif /* !_INET_H_ */ diff -ruN glibc-1.08.1/inet/arpa/nameser.h glibc-1.09/inet/arpa/nameser.h --- glibc-1.08.1/inet/arpa/nameser.h Wed May 19 15:49:50 1993 +++ glibc-1.09/inet/arpa/nameser.h Wed Dec 31 19:00:00 1969 @@ -1,308 +0,0 @@ -/* - * @(#)nameser.h 5.25 (Berkeley) 4/3/91 - * $Id: nameser.h,v 4.9.1.2 1993/05/17 09:59:01 vixie Exp $ - */ - -/* - * ++Copyright++ 1983, 1989 - * - - * Copyright (c) 1983, 1989 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - - * Portions Copyright (c) 1993 by Digital Equipment Corporation. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies, and that - * the name of Digital Equipment Corporation not be used in advertising or - * publicity pertaining to distribution of the document or software without - * specific, written prior permission. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL - * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT - * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - * - - * --Copyright-- - */ - -#ifndef _NAMESER_H_ -#define _NAMESER_H_ - -#include -#if (!defined(BSD)) || (BSD < 199306) -# include -#else -# include -#endif -#include - -/* - * Define constants based on rfc883 - */ -#define PACKETSZ 512 /* maximum packet size */ -#define MAXDNAME 256 /* maximum domain name */ -#define MAXCDNAME 255 /* maximum compressed domain name */ -#define MAXLABEL 63 /* maximum length of domain label */ - /* Number of bytes of fixed size data in query structure */ -#define QFIXEDSZ 4 - /* number of bytes of fixed size data in resource record */ -#define RRFIXEDSZ 10 - -/* - * Internet nameserver port number - */ -#define NAMESERVER_PORT 53 - -/* - * Currently defined opcodes - */ -#define QUERY 0x0 /* standard query */ -#define IQUERY 0x1 /* inverse query */ -#define STATUS 0x2 /* nameserver status query */ -/*#define xxx 0x3 /* 0x3 reserved */ - /* non standard - supports ALLOW_UPDATES stuff from Mike Schwartz */ -#define UPDATEA 0x9 /* add resource record */ -#define UPDATED 0xa /* delete a specific resource record */ -#define UPDATEDA 0xb /* delete all named resource record */ -#define UPDATEM 0xc /* modify a specific resource record */ -#define UPDATEMA 0xd /* modify all named resource record */ - -#define ZONEINIT 0xe /* initial zone transfer */ -#define ZONEREF 0xf /* incremental zone referesh */ - -/* - * Currently defined response codes - */ -#define NOERROR 0 /* no error */ -#define FORMERR 1 /* format error */ -#define SERVFAIL 2 /* server failure */ -#define NXDOMAIN 3 /* non existent domain */ -#define NOTIMP 4 /* not implemented */ -#define REFUSED 5 /* query refused */ - /* non standard */ -#define NOCHANGE 0xf /* update failed to change db */ - -/* - * Type values for resources and queries - */ -#define T_A 1 /* host address */ -#define T_NS 2 /* authoritative server */ -#define T_MD 3 /* mail destination */ -#define T_MF 4 /* mail forwarder */ -#define T_CNAME 5 /* connonical name */ -#define T_SOA 6 /* start of authority zone */ -#define T_MB 7 /* mailbox domain name */ -#define T_MG 8 /* mail group member */ -#define T_MR 9 /* mail rename name */ -#define T_NULL 10 /* null resource record */ -#define T_WKS 11 /* well known service */ -#define T_PTR 12 /* domain name pointer */ -#define T_HINFO 13 /* host information */ -#define T_MINFO 14 /* mailbox information */ -#define T_MX 15 /* mail routing information */ -#define T_TXT 16 /* text strings */ -#define T_RP 17 /* responsible person */ - /* non standard */ -#define T_UINFO 100 /* user (finger) information */ -#define T_UID 101 /* user ID */ -#define T_GID 102 /* group ID */ -#define T_UNSPEC 103 /* Unspecified format (binary data) */ - /* Query type values which do not appear in resource records */ -#define T_AXFR 252 /* transfer zone of authority */ -#define T_MAILB 253 /* transfer mailbox records */ -#define T_MAILA 254 /* transfer mail agent records */ -#define T_ANY 255 /* wildcard match */ - -/* - * Values for class field - */ - -#define C_IN 1 /* the arpa internet */ -#define C_CHAOS 3 /* for chaos net (MIT) */ -#define C_HS 4 /* for Hesiod name server (MIT) */ - /* Query class values which do not appear in resource records */ -#define C_ANY 255 /* wildcard match */ - -/* - * Status return codes for T_UNSPEC conversion routines - */ -#define CONV_SUCCESS 0 -#define CONV_OVERFLOW -1 -#define CONV_BADFMT -2 -#define CONV_BADCKSUM -3 -#define CONV_BADBUFLEN -4 - -#ifndef BYTE_ORDER -#define LITTLE_ENDIAN 1234 /* least-significant byte first (vax, pc) */ -#define BIG_ENDIAN 4321 /* most-significant byte first (IBM, net) */ -#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long (pdp)*/ - -#if defined(vax) || defined(ns32000) || defined(sun386) || defined(i386) || \ - defined(MIPSEL) || defined(_MIPSEL) || defined(BIT_ZERO_ON_RIGHT) || \ - defined(__alpha__) || defined(__alpha) -#define BYTE_ORDER LITTLE_ENDIAN -#endif - -#if defined(sel) || defined(pyr) || defined(mc68000) || defined(sparc) || \ - defined(is68k) || defined(tahoe) || defined(ibm032) || defined(ibm370) || \ - defined(MIPSEB) || defined(_MIPSEB) || defined(_IBMR2) || \ - defined(apollo) || defined(hp9000) || defined(hp9000s300) || \ - defined (BIT_ZERO_ON_LEFT) -#define BYTE_ORDER BIG_ENDIAN -#endif -#endif /* BYTE_ORDER */ - -#if !defined(BYTE_ORDER) || \ - (BYTE_ORDER != BIG_ENDIAN && BYTE_ORDER != LITTLE_ENDIAN && \ - BYTE_ORDER != PDP_ENDIAN) - /* you must determine what the correct bit order is for - * your compiler - the next line is an intentional error - * which will force your compiles to bomb until you fix - * the above macros. - */ - #error "Undefined or invalid BYTE_ORDER"; -#endif -/* - * Structure for query header, the order of the fields is machine and - * compiler dependent, in our case, the bits within a byte are assignd - * least significant first, while the order of transmition is most - * significant first. This requires a somewhat confusing rearrangement. - */ - -typedef struct { - u_short id; /* query identification number */ -#if BYTE_ORDER == BIG_ENDIAN - /* fields in third byte */ - u_int qr:1; /* response flag */ - u_int opcode:4; /* purpose of message */ - u_int aa:1; /* authoritive answer */ - u_int tc:1; /* truncated message */ - u_int rd:1; /* recursion desired */ - /* fields in fourth byte */ - u_int ra:1; /* recursion available */ - u_int pr:1; /* primary server required (non standard) */ - u_int unused:2; /* unused bits */ - u_int rcode:4; /* response code */ -#endif -#if BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == PDP_ENDIAN - /* fields in third byte */ - u_int rd:1; /* recursion desired */ - u_int tc:1; /* truncated message */ - u_int aa:1; /* authoritive answer */ - u_int opcode:4; /* purpose of message */ - u_int qr:1; /* response flag */ - /* fields in fourth byte */ - u_int rcode:4; /* response code */ - u_int unused:2; /* unused bits */ - u_int pr:1; /* primary server required (non standard) */ - u_int ra:1; /* recursion available */ -#endif - /* remaining bytes */ - u_short qdcount; /* number of question entries */ - u_short ancount; /* number of answer entries */ - u_short nscount; /* number of authority entries */ - u_short arcount; /* number of resource entries */ -} HEADER; - -/* - * Defines for handling compressed domain names - */ -#define INDIR_MASK 0xc0 - -/* - * Structure for passing resource records around. - */ -struct rrec { - short r_zone; /* zone number */ - short r_class; /* class number */ - short r_type; /* type number */ - u_int32_t r_ttl; /* time to live */ - int r_size; /* size of data area */ - char *r_data; /* pointer to data */ -}; - -extern u_short _getshort(); -extern u_int32_t _getlong(); - -/* - * Inline versions of get/put short/long. Pointer is advanced. - * We also assume that a "u_short" holds 2 "chars" - * and that a "u_int32_t" holds 4 "chars". - * - * These macros demonstrate the property of C whereby it can be - * portable or it can be elegant but never both. - */ -#define GETSHORT(s, cp) { \ - register u_char *t_cp = (u_char*)(cp); \ - (s) = (((u_short)t_cp[0]) << 8) \ - | (((u_short)t_cp[1])) \ - ; \ - (cp) += 2; \ -} - -#define GETLONG(l, cp) { \ - register u_char *t_cp = (u_char*)(cp); \ - (l) = (((u_int32_t)t_cp[0]) << 24) \ - | (((u_int32_t)t_cp[1]) << 16) \ - | (((u_int32_t)t_cp[2]) << 8) \ - | (((u_int32_t)t_cp[3])) \ - ; \ - (cp) += 4; \ -} - -#define PUTSHORT(s, cp) { \ - register u_short t_s = (u_short)(s); \ - register u_char *t_cp = (u_char*)(cp); \ - *t_cp++ = t_s >> 8; \ - *t_cp = t_s; \ - (cp) += 2; \ -} - -/* - * Warning: PUTLONG --no-longer-- destroys its first argument. if you - * were depending on this "feature", you will lose. - */ -#define PUTLONG(l, cp) { \ - register u_int32_t t_l = (u_int32_t)(l); \ - register u_char *t_cp = (u_char*)(cp); \ - *t_cp++ = t_l >> 24; \ - *t_cp++ = t_l >> 16; \ - *t_cp++ = t_l >> 8; \ - *t_cp = t_l; \ - (cp) += 4; \ -} - -#endif /* !_NAMESER_H_ */ diff -ruN glibc-1.08.1/inet/arpa/telnet.h glibc-1.09/inet/arpa/telnet.h --- glibc-1.08.1/inet/arpa/telnet.h Wed May 13 02:59:44 1992 +++ glibc-1.09/inet/arpa/telnet.h Sun Jul 31 14:29:57 1994 @@ -1,6 +1,6 @@ /* - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. + * 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 @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)telnet.h 5.14 (Berkeley) 4/3/91 + * @(#)telnet.h 8.2 (Berkeley) 12/15/93 */ #ifndef _TELNET_H_ @@ -74,7 +74,8 @@ #define TELCMD_FIRST xEOF #define TELCMD_LAST IAC -#define TELCMD_OK(x) ((x) <= TELCMD_LAST && (x) >= TELCMD_FIRST) +#define TELCMD_OK(x) ((unsigned int)(x) <= TELCMD_LAST && \ + (unsigned int)(x) >= TELCMD_FIRST) #define TELCMD(x) telcmds[(x)-TELCMD_FIRST] /* telnet options */ @@ -114,13 +115,14 @@ #define TELOPT_LFLOW 33 /* remote flow control */ #define TELOPT_LINEMODE 34 /* Linemode option */ #define TELOPT_XDISPLOC 35 /* X Display Location */ -#define TELOPT_ENVIRON 36 /* Environment variables */ +#define TELOPT_OLD_ENVIRON 36 /* Old - Environment variables */ #define TELOPT_AUTHENTICATION 37/* Authenticate */ #define TELOPT_ENCRYPT 38 /* Encryption option */ +#define TELOPT_NEW_ENVIRON 39 /* New - Environment variables */ #define TELOPT_EXOPL 255 /* extended-options-list */ -#define NTELOPTS (1+TELOPT_ENCRYPT) +#define NTELOPTS (1+TELOPT_NEW_ENVIRON) #ifdef TELOPTS char *telopts[NTELOPTS+1] = { "BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME", @@ -131,13 +133,13 @@ "SEND LOCATION", "TERMINAL TYPE", "END OF RECORD", "TACACS UID", "OUTPUT MARKING", "TTYLOC", "3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW", - "LINEMODE", "XDISPLOC", "ENVIRON", "AUTHENTICATION", - "ENCRYPT", + "LINEMODE", "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION", + "ENCRYPT", "NEW-ENVIRON", 0, }; #define TELOPT_FIRST TELOPT_BINARY -#define TELOPT_LAST TELOPT_ENCRYPT -#define TELOPT_OK(x) ((x) <= TELOPT_LAST && (x) >= TELOPT_FIRST) +#define TELOPT_LAST TELOPT_NEW_ENVIRON +#define TELOPT_OK(x) ((unsigned int)(x) <= TELOPT_LAST) #define TELOPT(x) telopts[(x)-TELOPT_FIRST] #endif @@ -148,6 +150,11 @@ #define TELQUAL_REPLY 2 /* AUTHENTICATION: client version of IS */ #define TELQUAL_NAME 3 /* AUTHENTICATION: client version of IS */ +#define LFLOW_OFF 0 /* Disable remote flow control */ +#define LFLOW_ON 1 /* Enable remote flow control */ +#define LFLOW_RESTART_ANY 2 /* Restart output on any char */ +#define LFLOW_RESTART_XON 3 /* Restart output only on XON */ + /* * LINEMODE suboptions */ @@ -208,7 +215,7 @@ #define SLC_NAMES SLC_NAMELIST #endif -#define SLC_NAME_OK(x) ((x) >= 0 && (x) < NSLC) +#define SLC_NAME_OK(x) ((unsigned int)(x) <= NSLC) #define SLC_NAME(x) slc_names[x] #define SLC_NOSUPPORT 0 @@ -225,9 +232,12 @@ #define SLC_FLUSHIN 0x40 #define SLC_FLUSHOUT 0x20 -#define ENV_VALUE 0 -#define ENV_VAR 1 +#define OLD_ENV_VAR 1 +#define OLD_ENV_VALUE 0 +#define NEW_ENV_VAR 0 +#define NEW_ENV_VALUE 1 #define ENV_ESC 2 +#define ENV_USERVAR 3 /* * AUTHENTICATION suboptions @@ -264,7 +274,7 @@ extern char *authtype_names[]; #endif -#define AUTHTYPE_NAME_OK(x) ((x) >= 0 && (x) < AUTHTYPE_CNT) +#define AUTHTYPE_NAME_OK(x) ((unsigned int)(x) < AUTHTYPE_CNT) #define AUTHTYPE_NAME(x) authtype_names[x] /* @@ -301,10 +311,10 @@ #endif -#define ENCRYPT_NAME_OK(x) ((x) >= 0 && (x) < ENCRYPT_CNT) +#define ENCRYPT_NAME_OK(x) ((unsigned int)(x) < ENCRYPT_CNT) #define ENCRYPT_NAME(x) encrypt_names[x] -#define ENCTYPE_NAME_OK(x) ((x) >= 0 && (x) < ENCTYPE_CNT) +#define ENCTYPE_NAME_OK(x) ((unsigned int)(x) < ENCTYPE_CNT) #define ENCTYPE_NAME(x) enctype_names[x] #endif /* !_TELNET_H_ */ diff -ruN glibc-1.08.1/inet/arpa/tftp.h glibc-1.09/inet/arpa/tftp.h --- glibc-1.08.1/inet/arpa/tftp.h Wed May 13 03:00:25 1992 +++ glibc-1.09/inet/arpa/tftp.h Sun Jul 31 14:40:18 1994 @@ -1,6 +1,6 @@ /* - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. + * 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 @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)tftp.h 5.4 (Berkeley) 4/3/91 + * @(#)tftp.h 8.1 (Berkeley) 6/2/93 */ #ifndef _TFTP_H_ diff -ruN glibc-1.08.1/inet/gethstnmad.c glibc-1.09/inet/gethstnmad.c --- glibc-1.08.1/inet/gethstnmad.c Wed May 19 15:49:46 1993 +++ glibc-1.09/inet/gethstnmad.c Wed Dec 31 19:00:00 1969 @@ -1,506 +0,0 @@ -/* - * ++Copyright++ 1985, 1988 - * - - * Copyright (c) 1985, 1988 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - - * 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 6.47 (Berkeley) 6/18/92"; -static char rcsid[] = "$Id: gethnamaddr.c,v 4.9.1.1 1993/05/02 22:43:03 vixie Rel $"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "../conf/portability.h" - -#define MAXALIASES 35 -#define MAXADDRS 35 - -static char *h_addr_ptrs[MAXADDRS + 1]; - -static struct hostent host; -static char *host_aliases[MAXALIASES]; -static char hostbuf[BUFSIZ+1]; -static struct in_addr host_addr; -static FILE *hostf = NULL; -static char hostaddr[MAXADDRS]; -static char *host_addrs[2]; -static int stayopen = 0; -char *strpbrk(); - -#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; - -static struct hostent * -getanswer(answer, anslen, iquery) - querybuf *answer; - int anslen; - int iquery; -{ - register HEADER *hp; - register u_char *cp; - register int n; - u_char *eom; - char *bp, **ap; - int type, class, buflen, ancount, qdcount; - int haveanswer, getclass = C_ANY; - char **hap; - - eom = answer->buf + anslen; - /* - * find first satisfactory answer - */ - hp = &answer->hdr; - ancount = ntohs(hp->ancount); - qdcount = ntohs(hp->qdcount); - bp = hostbuf; - buflen = sizeof(hostbuf); - cp = answer->buf + sizeof(HEADER); - if (qdcount) { - if (iquery) { - if ((n = dn_expand((u_char *)answer->buf, - (u_char *)eom, (u_char *)cp, (u_char *)bp, - buflen)) < 0) { - h_errno = NO_RECOVERY; - return ((struct hostent *) NULL); - } - cp += n + QFIXEDSZ; - host.h_name = bp; - n = strlen(bp) + 1; - bp += n; - buflen -= n; - } else - cp += __dn_skipname(cp, eom) + QFIXEDSZ; - while (--qdcount > 0) - cp += __dn_skipname(cp, eom) + QFIXEDSZ; - } else if (iquery) { - if (hp->aa) - h_errno = HOST_NOT_FOUND; - else - h_errno = TRY_AGAIN; - return ((struct hostent *) NULL); - } - ap = host_aliases; - *ap = NULL; - host.h_aliases = host_aliases; - hap = h_addr_ptrs; - *hap = NULL; -#if BSD >= 43 || defined(h_addr) /* new-style hostent structure */ - host.h_addr_list = h_addr_ptrs; -#endif - haveanswer = 0; - while (--ancount >= 0 && cp < eom) { - if ((n = dn_expand((u_char *)answer->buf, (u_char *)eom, - (u_char *)cp, (u_char *)bp, buflen)) < 0) - break; - cp += n; - type = _getshort(cp); - cp += sizeof(u_short); - class = _getshort(cp); - cp += sizeof(u_short) + sizeof(u_int32_t); - n = _getshort(cp); - cp += sizeof(u_short); - if (type == T_CNAME) { - cp += n; - if (ap >= &host_aliases[MAXALIASES-1]) - continue; - *ap++ = bp; - n = strlen(bp) + 1; - bp += n; - buflen -= n; - continue; - } - if (iquery && type == T_PTR) { - if ((n = dn_expand((u_char *)answer->buf, - (u_char *)eom, (u_char *)cp, (u_char *)bp, - buflen)) < 0) { - cp += n; - continue; - } - cp += n; - host.h_name = bp; - return(&host); - } - if (iquery || type != T_A) { -#ifdef DEBUG - if (_res.options & RES_DEBUG) - printf("unexpected answer type %d, size %d\n", - type, n); -#endif - cp += n; - continue; - } - if (haveanswer) { - if (n != host.h_length) { - cp += n; - continue; - } - if (class != getclass) { - cp += n; - continue; - } - } else { - host.h_length = n; - getclass = class; - host.h_addrtype = (class == C_IN) ? AF_INET : AF_UNSPEC; - if (!iquery) { - host.h_name = bp; - bp += strlen(bp) + 1; - } - } - - bp += sizeof(align) - ((u_int32_t)bp % sizeof(align)); - - if (bp + n >= &hostbuf[sizeof(hostbuf)]) { -#ifdef DEBUG - if (_res.options & RES_DEBUG) - printf("size (%d) too big\n", n); -#endif - break; - } - bcopy(cp, *hap++ = bp, n); - bp +=n; - cp += n; - haveanswer++; - } - if (haveanswer) { - *ap = NULL; -#if BSD >= 43 || defined(h_addr) /* new-style hostent structure */ - *hap = NULL; -#else - host.h_addr = h_addr_ptrs[0]; -#endif - return (&host); - } else { - h_errno = TRY_AGAIN; - return ((struct hostent *) NULL); - } -} - -struct hostent * -gethostbyname(name) - const char *name; -{ - querybuf buf; - register const char *cp; - int n; - extern struct hostent *_gethtbyname(); - - /* - * disallow names consisting only of digits/dots, unless - * they end in a dot. - */ - if (isdigit(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_aton(name, &host_addr)) { - h_errno = HOST_NOT_FOUND; - return((struct hostent *) NULL); - } - host.h_name = (char *)name; - host.h_aliases = host_aliases; - host_aliases[0] = NULL; - host.h_addrtype = AF_INET; - host.h_length = sizeof(u_int32_t); - h_addr_ptrs[0] = (char *)&host_addr; - h_addr_ptrs[1] = (char *)0; -#if BSD >= 43 || defined(h_addr) /* new-style hostent structure */ - host.h_addr_list = h_addr_ptrs; -#else - host.h_addr = h_addr_ptrs[0]; -#endif - return (&host); - } - if (!isdigit(*cp) && *cp != '.') - break; - } - - if ((n = res_search(name, C_IN, T_A, buf.buf, sizeof(buf))) < 0) { -#ifdef DEBUG - if (_res.options & RES_DEBUG) - printf("res_search failed\n"); -#endif - if (errno == ECONNREFUSED) - return (_gethtbyname(name)); - else - return ((struct hostent *) NULL); - } - return (getanswer(&buf, n, 0)); -} - -struct hostent * -gethostbyaddr(addr, len, type) - const char *addr; - int len, type; -{ - int n; - querybuf buf; - register struct hostent *hp; - char qbuf[MAXDNAME]; - extern struct hostent *_gethtbyaddr(); - - if (type != AF_INET) - return ((struct hostent *) NULL); - (void)sprintf(qbuf, "%u.%u.%u.%u.in-addr.arpa", - ((unsigned)addr[3] & 0xff), - ((unsigned)addr[2] & 0xff), - ((unsigned)addr[1] & 0xff), - ((unsigned)addr[0] & 0xff)); - n = res_query(qbuf, C_IN, T_PTR, (char *)&buf, sizeof(buf)); - if (n < 0) { -#ifdef DEBUG - if (_res.options & RES_DEBUG) - printf("res_query failed\n"); -#endif - if (errno == ECONNREFUSED) - return (_gethtbyaddr(addr, len, type)); - return ((struct hostent *) NULL); - } - hp = getanswer(&buf, n, 1); - if (hp == NULL) - return ((struct hostent *) NULL); - hp->h_addrtype = type; - hp->h_length = len; - h_addr_ptrs[0] = (char *)&host_addr; - h_addr_ptrs[1] = (char *)0; - host_addr = *(struct in_addr *)addr; -#if BSD < 43 && !defined(h_addr) /* new-style hostent structure */ - hp->h_addr = h_addr_ptrs[0]; -#endif - return(hp); -} - -void -_sethtent(f) - int f; -{ - if (hostf == NULL) - hostf = fopen(_PATH_HOSTS, "r" ); - else - rewind(hostf); - stayopen |= f; -} - -void -_endhtent() -{ - if (hostf && !stayopen) { - (void) fclose(hostf); - hostf = NULL; - } -} - -struct hostent * -_gethtent() -{ - char *p; - register char *cp, **q; - - if (hostf == NULL && (hostf = fopen(_PATH_HOSTS, "r" )) == NULL) - return (NULL); -again: - if ((p = fgets(hostbuf, BUFSIZ, hostf)) == NULL) - return (NULL); - if (*p == '#') - goto again; - cp = strpbrk(p, "#\n"); - if (cp == NULL) - goto again; - *cp = '\0'; - cp = strpbrk(p, " \t"); - if (cp == NULL) - goto again; - *cp++ = '\0'; - /* THIS STUFF IS INTERNET SPECIFIC */ -#if BSD >= 43 || defined(h_addr) /* new-style hostent structure */ - host.h_addr_list = host_addrs; -#endif - host.h_addr = hostaddr; - *((u_int32_t *)host.h_addr) = inet_addr(p); - host.h_length = sizeof (u_int32_t); - host.h_addrtype = AF_INET; - while (*cp == ' ' || *cp == '\t') - cp++; - host.h_name = cp; - q = host.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 (&host); -} - -struct hostent * -_gethtbyname(name) - char *name; -{ - register struct hostent *p; - register char **cp; - - _sethtent(0); - while (p = _gethtent()) { - if (strcasecmp(p->h_name, name) == 0) - break; - for (cp = p->h_aliases; *cp != 0; cp++) - if (strcasecmp(*cp, name) == 0) - goto found; - } -found: - _endhtent(); - return (p); -} - -struct hostent * -_gethtbyaddr(addr, len, type) - const char *addr; - int len, type; -{ - register struct hostent *p; - - _sethtent(0); - while (p = _gethtent()) - if (p->h_addrtype == type && !bcmp(p->h_addr, addr, len)) - break; - _endhtent(); - return (p); -} - -#if defined(BSD43_BSD43_NFS) || defined(sun) -/* some libc's out there are bound internally to these names (UMIPS) */ -void -ht_sethostent(stayopen) - int stayopen; -{ - _sethtent(stayopen); -} - -void -ht_endhostent() -{ - _endhtent(); -} - -struct hostent * -ht_gethostbyname(name) - char *name; -{ - return _gethtbyname(name); -} - -struct hostent * -ht_gethostbyaddr(addr, len, type) - const char *addr; - int len, type; -{ - return _gethtbyaddr(addr, len, type); -} - -struct hostent * -gethostent() -{ - return _gethtent(); -} - -void -dns_service() -{ - return; -} - -#undef dn_skipname -dn_skipname(comp_dn, eom) - const u_char *comp_dn, *eom; -{ - return __dn_skipname(comp_dn, eom); -} -#endif /*old-style libc with yp junk in it*/ diff -ruN glibc-1.08.1/inet/getnetbyad.c glibc-1.09/inet/getnetbyad.c --- glibc-1.08.1/inet/getnetbyad.c Wed May 19 16:01:55 1993 +++ glibc-1.09/inet/getnetbyad.c Wed Dec 31 19:00:00 1969 @@ -1,56 +0,0 @@ -/* - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)getnetbyaddr.c 5.7 (Berkeley) 6/1/90"; -#endif /* LIBC_SCCS and not lint */ - -#include - -extern int _net_stayopen; - -struct netent * -getnetbyaddr(net, type) - register int32_t 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 -ruN glibc-1.08.1/inet/getnetbynm.c glibc-1.09/inet/getnetbynm.c --- glibc-1.08.1/inet/getnetbynm.c Fri May 15 20:02:08 1992 +++ glibc-1.09/inet/getnetbynm.c Wed Dec 31 19:00:00 1969 @@ -1,62 +0,0 @@ -/* - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)getnetbyname.c 5.7 (Berkeley) 2/24/91"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -extern int _net_stayopen; - -struct netent * -getnetbyname(name) - register const char *name; -{ - register struct netent *p; - register char **cp; - - setnetent(_net_stayopen); - while (p = getnetent()) { - if (strcmp(p->n_name, name) == 0) - break; - for (cp = p->n_aliases; *cp != 0; cp++) - if (strcmp(*cp, name) == 0) - goto found; - } -found: - if (!_net_stayopen) - endnetent(); - return (p); -} diff -ruN glibc-1.08.1/inet/getnetent.c glibc-1.09/inet/getnetent.c --- glibc-1.08.1/inet/getnetent.c Sat Apr 20 16:50:06 1991 +++ glibc-1.09/inet/getnetent.c Wed Dec 31 19:00:00 1969 @@ -1,121 +0,0 @@ -/* - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)getnetent.c 5.8 (Berkeley) 2/24/91"; -#endif /* LIBC_SCCS and not lint */ - -#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]; -int _net_stayopen; - -void -setnetent(f) - int f; -{ - if (netf == NULL) - netf = fopen(_PATH_NETWORKS, "r" ); - else - rewind(netf); - _net_stayopen |= f; -} - -void -endnetent() -{ - 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, BUFSIZ, 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); -} diff -ruN glibc-1.08.1/inet/getproto.c glibc-1.09/inet/getproto.c --- glibc-1.08.1/inet/getproto.c Sat Apr 20 16:50:07 1991 +++ glibc-1.09/inet/getproto.c Sun Jul 31 14:45:37 1994 @@ -1,6 +1,6 @@ /* - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. + * 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 @@ -32,7 +32,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)getproto.c 5.6 (Berkeley) 6/1/90"; +static char sccsid[] = "@(#)getproto.c 8.1 (Berkeley) 6/4/93"; #endif /* LIBC_SCCS and not lint */ #include diff -ruN glibc-1.08.1/inet/getprtent.c glibc-1.09/inet/getprtent.c --- glibc-1.08.1/inet/getprtent.c Fri May 15 20:00:22 1992 +++ glibc-1.09/inet/getprtent.c Sun Jul 31 14:46:13 1994 @@ -1,6 +1,6 @@ /* - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. + * 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 @@ -32,7 +32,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)getprotoent.c 5.8 (Berkeley) 2/24/91"; +static char sccsid[] = "@(#)getprotoent.c 8.1 (Berkeley) 6/4/93"; #endif /* LIBC_SCCS and not lint */ #include diff -ruN glibc-1.08.1/inet/getprtname.c glibc-1.09/inet/getprtname.c --- glibc-1.08.1/inet/getprtname.c Fri May 15 20:00:24 1992 +++ glibc-1.09/inet/getprtname.c Sun Jul 31 14:46:45 1994 @@ -1,6 +1,6 @@ /* - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. + * 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 @@ -32,7 +32,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)getprotoname.c 5.7 (Berkeley) 2/24/91"; +static char sccsid[] = "@(#)getprotoname.c 8.1 (Berkeley) 6/4/93"; #endif /* LIBC_SCCS and not lint */ #include diff -ruN glibc-1.08.1/inet/getservent.c glibc-1.09/inet/getservent.c --- glibc-1.08.1/inet/getservent.c Sat Apr 20 16:50:08 1991 +++ glibc-1.09/inet/getservent.c Sun Jul 31 14:47:11 1994 @@ -1,6 +1,6 @@ /* - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. + * 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 @@ -32,7 +32,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)getservent.c 5.9 (Berkeley) 2/24/91"; +static char sccsid[] = "@(#)getservent.c 8.1 (Berkeley) 6/4/93"; #endif /* LIBC_SCCS and not lint */ #include diff -ruN glibc-1.08.1/inet/getsrvbynm.c glibc-1.09/inet/getsrvbynm.c --- glibc-1.08.1/inet/getsrvbynm.c Fri May 15 20:00:27 1992 +++ glibc-1.09/inet/getsrvbynm.c Sun Jul 31 14:47:56 1994 @@ -1,6 +1,6 @@ /* - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. + * 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 @@ -32,7 +32,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)getservbyname.c 5.7 (Berkeley) 2/24/91"; +static char sccsid[] = "@(#)getservbyname.c 8.1 (Berkeley) 6/4/93"; #endif /* LIBC_SCCS and not lint */ #include diff -ruN glibc-1.08.1/inet/getsrvbypt.c glibc-1.09/inet/getsrvbypt.c --- glibc-1.08.1/inet/getsrvbypt.c Fri May 15 20:00:29 1992 +++ glibc-1.09/inet/getsrvbypt.c Sun Jul 31 14:48:30 1994 @@ -1,6 +1,6 @@ /* - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. + * 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 @@ -32,7 +32,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)getservbyport.c 5.7 (Berkeley) 2/24/91"; +static char sccsid[] = "@(#)getservbyport.c 8.1 (Berkeley) 6/4/93"; #endif /* LIBC_SCCS and not lint */ #include diff -ruN glibc-1.08.1/inet/herror.c glibc-1.09/inet/herror.c --- glibc-1.08.1/inet/herror.c Wed May 19 15:49:45 1993 +++ glibc-1.09/inet/herror.c Wed Dec 31 19:00:00 1969 @@ -1,110 +0,0 @@ -/* - * ++Copyright++ 1987 - * - - * Copyright (c) 1987 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - - * 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[] = "@(#)herror.c 6.6 (Berkeley) 2/24/91"; -static char rcsid[] = "$Id: herror.c,v 4.9.1.1 1993/05/02 23:14:35 vixie Rel $"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include "../conf/portability.h" - -char *h_errlist[] = { - "Error 0", - "Unknown host", /* 1 HOST_NOT_FOUND */ - "Host name lookup failure", /* 2 TRY_AGAIN */ - "Unknown server error", /* 3 NO_RECOVERY */ - "No address associated with name", /* 4 NO_ADDRESS */ -}; -int h_nerr = { sizeof(h_errlist)/sizeof(h_errlist[0]) }; - -extern 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 = (u_int)h_errno < h_nerr ? - h_errlist[h_errno] : "Unknown error"; - v->iov_len = strlen(v->iov_base); - v++; - v->iov_base = "\n"; - v->iov_len = 1; - writev(STDERR_FILENO, iov, (v - iov) + 1); -} - -char * -hstrerror(err) - int err; -{ - return (u_int)err < h_nerr ? h_errlist[err] : "Unknown resolver error"; -} diff -ruN glibc-1.08.1/inet/inet_addr.c glibc-1.09/inet/inet_addr.c --- glibc-1.08.1/inet/inet_addr.c Wed May 19 15:49:43 1993 +++ glibc-1.09/inet/inet_addr.c Sun Aug 7 01:53:50 1994 @@ -1,9 +1,7 @@ /* - * ++Copyright++ - * - - * Copyright (c) Regents of the University of California. - * All rights reserved. - * + * 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: @@ -14,12 +12,12 @@ * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. + * This product includes software developed by the University of + * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -31,44 +29,22 @@ * LIABILITY, OR TORT (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 5.11 (Berkeley) 12/9/91"; +static char sccsid[] = "@(#)inet_addr.c 8.1 (Berkeley) 6/17/93"; #endif /* LIBC_SCCS and not lint */ #include #include #include #include -#include "../conf/portability.h" -#if !defined(BSD) || (BSD <= 199006) /* * Ascii internet address interpretation routine. * The value returned is in network order. */ -u_int32_t +u_long inet_addr(cp) register const char *cp; { @@ -91,7 +67,7 @@ register const char *cp; struct in_addr *addr; { - register u_int32_t val; + register u_long val; register int base, n; register char c; u_int parts[4]; @@ -174,4 +150,3 @@ addr->s_addr = htonl(val); return (1); } -#endif /*BSD*/ diff -ruN glibc-1.08.1/inet/inet_lnaof.c glibc-1.09/inet/inet_lnaof.c --- glibc-1.08.1/inet/inet_lnaof.c Wed May 19 16:02:02 1993 +++ glibc-1.09/inet/inet_lnaof.c Sun Aug 7 01:55:58 1994 @@ -1,6 +1,6 @@ /* - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. + * 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 @@ -32,7 +32,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)inet_lnaof.c 5.7 (Berkeley) 2/24/91"; +static char sccsid[] = "@(#)inet_lnaof.c 8.1 (Berkeley) 6/4/93"; #endif /* LIBC_SCCS and not lint */ #include @@ -44,7 +44,7 @@ * internet address; handles class a/b/c network * number formats. */ -u_int32_t +u_long inet_lnaof(in) struct in_addr in; { diff -ruN glibc-1.08.1/inet/inet_mkadr.c glibc-1.09/inet/inet_mkadr.c --- glibc-1.08.1/inet/inet_mkadr.c Wed May 19 16:02:00 1993 +++ glibc-1.09/inet/inet_mkadr.c Sun Aug 7 01:55:25 1994 @@ -1,6 +1,6 @@ /* - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. + * 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 @@ -32,7 +32,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)inet_makeaddr.c 5.6 (Berkeley) 2/24/91"; +static char sccsid[] = "@(#)inet_makeaddr.c 8.1 (Berkeley) 6/4/93"; #endif /* LIBC_SCCS and not lint */ #include @@ -45,7 +45,7 @@ */ struct in_addr inet_makeaddr(net, host) - u_int32_t net, host; + u_long net, host; { u_long addr; diff -ruN glibc-1.08.1/inet/inet_net.c glibc-1.09/inet/inet_net.c --- glibc-1.08.1/inet/inet_net.c Wed May 19 16:01:59 1993 +++ glibc-1.09/inet/inet_net.c Tue Aug 9 19:20:10 1994 @@ -1,6 +1,6 @@ /* - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. + * 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 @@ -32,7 +32,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)inet_network.c 5.8 (Berkeley) 2/24/91"; +static char sccsid[] = "@(#)inet_network.c 8.1 (Berkeley) 6/4/93"; #endif /* LIBC_SCCS and not lint */ #include @@ -45,7 +45,7 @@ * The library routines call this routine to interpret * network numbers. */ -u_int32_t +u_long inet_network(cp) register const char *cp; { diff -ruN glibc-1.08.1/inet/inet_netof.c glibc-1.09/inet/inet_netof.c --- glibc-1.08.1/inet/inet_netof.c Wed May 19 16:01:57 1993 +++ glibc-1.09/inet/inet_netof.c Tue Aug 9 19:21:20 1994 @@ -1,6 +1,6 @@ /* - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. + * 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 @@ -32,7 +32,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)inet_netof.c 5.7 (Berkeley) 2/24/91"; +static char sccsid[] = "@(#)inet_netof.c 8.1 (Berkeley) 6/4/93"; #endif /* LIBC_SCCS and not lint */ #include @@ -43,7 +43,7 @@ * Return the network number from an internet * address; handles class a/b/c network #'s. */ -u_int32_t +u_long inet_netof(in) struct in_addr in; { diff -ruN glibc-1.08.1/inet/inet_ntoa.c glibc-1.09/inet/inet_ntoa.c --- glibc-1.08.1/inet/inet_ntoa.c Sat Apr 20 16:50:11 1991 +++ glibc-1.09/inet/inet_ntoa.c Sun Jul 31 14:53:42 1994 @@ -1,6 +1,6 @@ /* - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. + * 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 @@ -32,7 +32,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)inet_ntoa.c 5.6 (Berkeley) 2/24/91"; +static char sccsid[] = "@(#)inet_ntoa.c 8.1 (Berkeley) 6/4/93"; #endif /* LIBC_SCCS and not lint */ /* diff -ruN glibc-1.08.1/inet/netdb.h glibc-1.09/inet/netdb.h --- glibc-1.08.1/inet/netdb.h Sun Feb 6 23:56:15 1994 +++ glibc-1.09/inet/netdb.h Sun Sep 4 22:07:11 1994 @@ -1,14 +1,7 @@ -/* - * @(#)netdb.h 5.15 (Berkeley) 4/3/91 - * $Id: netdb.h,v 4.9.1.2 1993/05/17 09:59:01 vixie Exp $ - */ - -/* - * ++Copyright++ 1980, 1983, 1988 - * - - * Copyright (c) 1980, 1983, 1988 Regents of the University of California. - * All rights reserved. - * +/*- + * Copyright (c) 1980, 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: @@ -19,12 +12,12 @@ * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. + * This product includes software developed by the University of + * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -36,6 +29,9 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. + * + * @(#)netdb.h 8.1 (Berkeley) 6/2/93 + * $Id: netdb.h,v 1.8 1994/09/05 02:07:10 roland Exp $ * - * Portions Copyright (c) 1993 by Digital Equipment Corporation. * @@ -61,14 +57,6 @@ #ifndef _NETDB_H_ #define _NETDB_H_ -#include -#if (!defined(BSD)) || (BSD < 199306) -# include -#else -# include -#endif -#include - #define _PATH_HEQUIV "/etc/hosts.equiv" #define _PATH_HOSTS "/etc/hosts" #define _PATH_NETWORKS "/etc/networks" @@ -91,13 +79,13 @@ /* * Assumption here is that a network number - * fits in 32 bits -- probably a poor one. + * fits in an unsigned long -- probably a poor one. */ struct netent { char *n_name; /* official name of net */ char **n_aliases; /* alias list */ int n_addrtype; /* net address type */ - u_int32_t n_net; /* network # */ + unsigned long n_net; /* network # */ }; struct servent { @@ -118,12 +106,16 @@ * (left in extern int h_errno). */ +extern int h_errno; + #define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found */ #define TRY_AGAIN 2 /* Non-Authoritive Host not found, or SERVERFAIL */ #define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */ #define NO_DATA 4 /* Valid name, no data record of requested type */ #define NO_ADDRESS NO_DATA /* no address, look for MX record */ +#include + __BEGIN_DECLS void endhostent __P((void)); void endnetent __P((void)); @@ -132,7 +124,7 @@ struct hostent *gethostbyaddr __P((const char *, int, int)); struct hostent *gethostbyname __P((const char *)); struct hostent *gethostent __P((void)); -struct netent *getnetbyaddr __P((int32_t, int)); /* u_int32_t? */ +struct netent *getnetbyaddr __P((long, int)); /* u_long? */ struct netent *getnetbyname __P((const char *)); struct netent *getnetent __P((void)); struct protoent *getprotobyname __P((const char *)); @@ -142,15 +134,12 @@ struct servent *getservbyport __P((int, const char *)); struct servent *getservent __P((void)); void herror __P((const char *)); -char * hstrerror __P((int)); +char *hstrerror __P((int)); void sethostent __P((int)); /* void sethostfile __P((const char *)); */ void setnetent __P((int)); void setprotoent __P((int)); void setservent __P((int)); __END_DECLS - -/* Get `struct rpcent' and the definition for reading /etc/rpc. */ -#include #endif /* !_NETDB_H_ */ diff -ruN glibc-1.08.1/inet/protocols/routed.h glibc-1.09/inet/protocols/routed.h --- glibc-1.08.1/inet/protocols/routed.h Wed May 13 03:02:54 1992 +++ glibc-1.09/inet/protocols/routed.h Sun Jul 31 14:41:15 1994 @@ -1,6 +1,6 @@ /*- - * Copyright (c) 1983, 1989 Regents of the University of California. - * All rights reserved. + * Copyright (c) 1983, 1989, 1993 + * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)routed.h 5.3 (Berkeley) 4/3/91 + * @(#)routed.h 8.1 (Berkeley) 6/2/93 */ #ifndef _ROUTED_H_ diff -ruN glibc-1.08.1/inet/protocols/rwhod.h glibc-1.09/inet/protocols/rwhod.h --- glibc-1.08.1/inet/protocols/rwhod.h Wed May 13 03:02:54 1992 +++ glibc-1.09/inet/protocols/rwhod.h Sun Jul 31 14:42:45 1994 @@ -1,6 +1,6 @@ /* - * Copyright (c) 1983 The Regents of the University of California. - * All rights reserved. + * 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 @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)rwhod.h 5.6 (Berkeley) 4/3/91 + * @(#)rwhod.h 8.1 (Berkeley) 6/2/93 */ #ifndef _RWHOD_H_ diff -ruN glibc-1.08.1/inet/protocols/talkd.h glibc-1.09/inet/protocols/talkd.h --- glibc-1.08.1/inet/protocols/talkd.h Wed May 13 03:02:54 1992 +++ glibc-1.09/inet/protocols/talkd.h Sun Jul 31 14:43:25 1994 @@ -1,6 +1,6 @@ /* - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. + * 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 @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)talkd.h 5.7 (Berkeley) 4/3/91 + * @(#)talkd.h 8.1 (Berkeley) 6/2/93 */ #ifndef _TALKD_H_ diff -ruN glibc-1.08.1/inet/protocols/timed.h glibc-1.09/inet/protocols/timed.h --- glibc-1.08.1/inet/protocols/timed.h Wed May 13 03:02:55 1992 +++ glibc-1.09/inet/protocols/timed.h Sun Jul 31 14:43:56 1994 @@ -1,6 +1,6 @@ /* - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. + * 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 @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)timed.h 1.10 (Berkeley) 4/3/91 + * @(#)timed.h 8.1 (Berkeley) 6/2/93 */ #ifndef _TIMED_H_ diff -ruN glibc-1.08.1/inet/rcmd.c glibc-1.09/inet/rcmd.c --- glibc-1.08.1/inet/rcmd.c Fri Jun 3 22:04:49 1994 +++ glibc-1.09/inet/rcmd.c Sun Jul 31 14:59:14 1994 @@ -1,6 +1,6 @@ /* - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. + * 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 @@ -32,87 +32,94 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)rcmd.c 5.24 (Berkeley) 2/24/91"; +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 #include +int __ivaliduser __P((FILE *, u_long, const char *, const char *)); +static int __icheckhost __P((u_long, char *)); + +int rcmd(ahost, rport, locuser, remuser, cmd, fd2p) char **ahost; u_short rport; const char *locuser, *remuser, *cmd; int *fd2p; { - int s, timo = 1, pid; - long oldmask; - struct sockaddr_in sin, sin2, from; - char c; - int lport = IPPORT_RESERVED - 1; struct hostent *hp; + struct sockaddr_in sin, from; fd_set reads; + long oldmask; + pid_t pid; + int s, lport, timo; + char c; pid = getpid(); hp = gethostbyname(*ahost); - if (hp == 0) { + if (hp == NULL) { herror(*ahost); return (-1); } *ahost = hp->h_name; oldmask = sigblock(sigmask(SIGURG)); - for (;;) { + for (timo = 1, lport = IPPORT_RESERVED - 1;;) { s = rresvport(&lport); if (s < 0) { if (errno == EAGAIN) - fprintf(stderr, "socket: All ports in use\n"); + (void)fprintf(stderr, + "rcmd: socket: All ports in use\n"); else - perror("rcmd: socket"); + (void)fprintf(stderr, "rcmd: socket: %s\n", + strerror(errno)); sigsetmask(oldmask); return (-1); } fcntl(s, F_SETOWN, pid); sin.sin_family = hp->h_addrtype; - bcopy(hp->h_addr_list[0], (caddr_t)&sin.sin_addr, hp->h_length); + bcopy(hp->h_addr_list[0], &sin.sin_addr, hp->h_length); sin.sin_port = rport; if (connect(s, (struct sockaddr *)&sin, sizeof(sin)) >= 0) break; - (void) close(s); + (void)close(s); if (errno == EADDRINUSE) { lport--; continue; } if (errno == ECONNREFUSED && timo <= 16) { - sleep(timo); + (void)sleep(timo); timo *= 2; continue; } if (hp->h_addr_list[1] != NULL) { int oerrno = errno; - fprintf(stderr, - "connect to address %s: ", inet_ntoa(sin.sin_addr)); + (void)fprintf(stderr, "connect to address %s: ", + inet_ntoa(sin.sin_addr)); errno = oerrno; perror(0); hp->h_addr_list++; - bcopy(hp->h_addr_list[0], (caddr_t)&sin.sin_addr, - hp->h_length); - fprintf(stderr, "Trying %s...\n", - inet_ntoa(sin.sin_addr)); + bcopy(hp->h_addr_list[0], &sin.sin_addr, hp->h_length); + (void)fprintf(stderr, "Trying %s...\n", + inet_ntoa(sin.sin_addr)); continue; } - perror(hp->h_name); + (void)fprintf(stderr, "%s: %s\n", hp->h_name, strerror(errno)); sigsetmask(oldmask); return (-1); } @@ -123,15 +130,17 @@ } else { char num[8]; int s2 = rresvport(&lport), s3; - int len = sizeof (from); + int len = sizeof(from); if (s2 < 0) goto bad; listen(s2, 1); - (void) sprintf(num, "%d", lport); + (void)snprintf(num, sizeof(num), "%d", lport); if (write(s, num, strlen(num)+1) != strlen(num)+1) { - perror("write: setting up stderr"); - (void) close(s2); + (void)fprintf(stderr, + "rcmd: write (setting up stderr): %s\n", + strerror(errno)); + (void)close(s2); goto bad; } FD_ZERO(&reads); @@ -141,17 +150,20 @@ if (select(1 + (s > s2 ? s : s2), &reads, 0, 0, 0) < 1 || !FD_ISSET(s2, &reads)) { if (errno != 0) - perror("select: setting up stderr"); + (void)fprintf(stderr, + "rcmd: select (setting up stderr): %s\n", + strerror(errno)); else - fprintf(stderr, - "select: protocol failure in circuit setup.\n"); - (void) close(s2); + (void)fprintf(stderr, + "select: protocol failure in circuit setup\n"); + (void)close(s2); goto bad; } s3 = accept(s2, (struct sockaddr *)&from, &len); - (void) close(s2); + (void)close(s2); if (s3 < 0) { - perror("accept"); + (void)fprintf(stderr, + "rcmd: accept: %s\n", strerror(errno)); lport = 0; goto bad; } @@ -160,21 +172,22 @@ if (from.sin_family != AF_INET || from.sin_port >= IPPORT_RESERVED || from.sin_port < IPPORT_RESERVED / 2) { - fprintf(stderr, + (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); + (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) { - perror(*ahost); + (void)fprintf(stderr, + "rcmd: %s: %s\n", *ahost, strerror(errno)); goto bad2; } if (c != 0) { while (read(s, &c, 1) == 1) { - (void) write(2, &c, 1); + (void)write(STDERR_FILENO, &c, 1); if (c == '\n') break; } @@ -184,13 +197,14 @@ return (s); bad2: if (lport) - (void) close(*fd2p); + (void)close(*fd2p); bad: - (void) close(s); + (void)close(s); sigsetmask(oldmask); return (-1); } +int rresvport(alport) int *alport; { @@ -204,93 +218,144 @@ return (-1); for (;;) { sin.sin_port = htons((u_short)*alport); - if (bind(s, (struct sockaddr *)&sin, sizeof (sin)) >= 0) + if (bind(s, (struct sockaddr *)&sin, sizeof(sin)) >= 0) return (s); if (errno != EADDRINUSE) { - (void) close(s); + (void)close(s); return (-1); } (*alport)--; if (*alport == IPPORT_RESERVED/2) { - (void) close(s); + (void)close(s); errno = EAGAIN; /* close */ return (-1); } } } -int _check_rhosts_file = 1; +int __check_rhosts_file = 1; +char *__rcmd_errstr; +int ruserok(rhost, superuser, ruser, luser) const char *rhost, *ruser, *luser; int superuser; { - FILE *hostf; - char fhost[MAXHOSTNAMELEN]; - int first = 1; - register char *sp, *p; - int baselen = -1; - - sp = (char *)rhost; - p = fhost; - while (*sp) { - if (*sp == '.') { - if (baselen == -1) - baselen = sp - rhost; - *p++ = *sp++; - } else { - *p++ = isupper(*sp) ? tolower(*sp++) : *sp++; - } + struct hostent *hp; + u_long addr; + char **ap; + + if ((hp = gethostbyname(rhost)) == NULL) + return (-1); + for (ap = hp->h_addr_list; *ap; ++ap) { + bcopy(*ap, &addr, sizeof(addr)); + if (iruserok(addr, superuser, ruser, luser) == 0) + return (0); } - *p = '\0'; - hostf = superuser ? (FILE *)0 : fopen(_PATH_HEQUIV, "r"); + 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) + u_long raddr; + int superuser; + const char *ruser, *luser; +{ + register char *cp; + struct stat sbuf; + struct passwd *pwd; + FILE *hostf; + uid_t uid; + int first; + char pbuf[MAXPATHLEN]; + + first = 1; + hostf = superuser ? NULL : fopen(_PATH_HEQUIV, "r"); again: if (hostf) { - if (!_validuser(hostf, fhost, luser, ruser, baselen)) { - (void) fclose(hostf); - return(0); + if (__ivaliduser(hostf, raddr, luser, ruser) == 0) { + (void)fclose(hostf); + return (0); } - (void) fclose(hostf); + (void)fclose(hostf); } - if (first == 1 && (_check_rhosts_file || superuser)) { - struct stat sbuf; - struct passwd *pwd; - char pbuf[MAXPATHLEN]; - + if (first == 1 && (__check_rhosts_file || superuser)) { first = 0; if ((pwd = getpwnam(luser)) == NULL) - return(-1); + return (-1); (void)strcpy(pbuf, pwd->pw_dir); (void)strcat(pbuf, "/.rhosts"); - if ((hostf = fopen(pbuf, "r")) == NULL) - return(-1); + /* - * if owned by someone other than user or root or if - * writeable by anyone but the owner, quit + * 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. */ - if (fstat(fileno(hostf), &sbuf) || - sbuf.st_uid && sbuf.st_uid != pwd->pw_uid || - sbuf.st_mode&022) { - fclose(hostf); - return(-1); + 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); } -/* don't make static, used by lpd(8) */ -_validuser(hostf, rhost, luser, ruser, baselen) - char *rhost, *luser, *ruser; +/* + * 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; - int baselen; + u_long raddr; + const char *luser, *ruser; { - register char *p; - char *user, ahost[MAXHOSTNAMELEN]; - static int _checkhost(); - - while (fgets(ahost, sizeof (ahost), hostf)) { - p = ahost; + register char *user, *p; + int ch; + char buf[MAXHOSTNAMELEN + 128]; /* host + login */ + + 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; + } while (*p != '\n' && *p != ' ' && *p != '\t' && *p != '\0') { *p = isupper(*p) ? tolower(*p) : *p; p++; @@ -300,52 +365,45 @@ while (*p == ' ' || *p == '\t') p++; user = p; - while (*p != '\n' && *p != ' ' && *p != '\t' && *p != '\0') + while (*p != '\n' && *p != ' ' && + *p != '\t' && *p != '\0') p++; } else user = p; *p = '\0'; - if (_checkhost(rhost, ahost, baselen) && - !strcmp(ruser, *user ? user : luser)) { + if (__icheckhost(raddr, buf) && + strcmp(ruser, *user ? user : luser) == 0) { return (0); } } return (-1); } -static -_checkhost(rhost, lhost, len) - char *rhost, *lhost; - int len; +/* + * Returns "true" if match, 0 if no match. + */ +static int +__icheckhost(raddr, lhost) + u_long raddr; + register char *lhost; { - static char ldomain[MAXHOSTNAMELEN + 1]; - static char *domainp = NULL; - static int nodomain = 0; - register char *cp; + register struct hostent *hp; + register u_long laddr; + register char **pp; + + /* Try for raw ip address first. */ + if (isdigit(*lhost) && (long)(laddr = inet_addr(lhost)) != -1) + return (raddr == laddr); + + /* Better be a hostname. */ + if ((hp = gethostbyname(lhost)) == NULL) + return (0); + + /* Spin through ip addresses. */ + for (pp = hp->h_addr_list; *pp; ++pp) + if (!bcmp(&raddr, *pp, sizeof(u_long))) + return (1); - if (len == -1) - return(!strcmp(rhost, lhost)); - if (strncmp(rhost, lhost, len)) - return(0); - if (!strcmp(rhost, lhost)) - return(1); - if (*(lhost + len) != '\0') - return(0); - if (nodomain) - return(0); - if (!domainp) { - if (gethostname(ldomain, sizeof(ldomain)) == -1) { - nodomain = 1; - return(0); - } - ldomain[MAXHOSTNAMELEN] = NULL; - if ((domainp = index(ldomain, '.')) == (char *)NULL) { - nodomain = 1; - return(0); - } - for (cp = ++domainp; *cp; ++cp) - if (isupper(*cp)) - *cp = tolower(*cp); - } - return(!strcmp(domainp, rhost + len +1)); + /* No match. */ + return (0); } diff -ruN glibc-1.08.1/inet/res_comp.c glibc-1.09/inet/res_comp.c --- glibc-1.08.1/inet/res_comp.c Wed May 19 15:45:44 1993 +++ glibc-1.09/inet/res_comp.c Wed Dec 31 19:00:00 1969 @@ -1,358 +0,0 @@ -/* - * ++Copyright++ 1985 - * - - * Copyright (c) 1985 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - - * 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[] = "@(#)res_comp.c 6.22 (Berkeley) 3/19/91"; -static char rcsid[] = "$Id: res_comp.c,v 4.9.1.1 1993/05/02 22:43:03 vixie Rel $"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include "../conf/portability.h" - -static int dn_find(); - -/* - * Expand compressed domain name 'comp_dn' to full domain name. - * 'msg' is a pointer to the begining of the message, - * 'eomorig' points to the first location after the message, - * 'exp_dn' is a pointer to a buffer of size 'length' for the result. - * Return size of compressed name or -1 if there was an error. - */ -dn_expand(msg, eomorig, comp_dn, exp_dn, length) - const u_char *msg, *eomorig, *comp_dn; - u_char *exp_dn; - int length; -{ - register u_char *cp, *dn; - register int n, c; - u_char *eom; - int len = -1, checked = 0; - - dn = exp_dn; - cp = (u_char *)comp_dn; - eom = exp_dn + length; - /* - * fetch next label in domain name - */ - while (n = *cp++) { - /* - * Check for indirection - */ - switch (n & INDIR_MASK) { - case 0: - if (dn != exp_dn) { - if (dn >= eom) - return (-1); - *dn++ = '.'; - } - if (dn+n >= eom) - return (-1); - checked += n + 1; - while (--n >= 0) { - if ((c = *cp++) == '.') { - if (dn + n + 2 >= eom) - return (-1); - *dn++ = '\\'; - } - *dn++ = c; - if (cp >= eomorig) /* out of range */ - return(-1); - } - break; - - case INDIR_MASK: - if (len < 0) - len = cp - comp_dn + 1; - cp = (u_char *)msg + (((n & 0x3f) << 8) | (*cp & 0xff)); - if (cp < msg || cp >= eomorig) /* out of range */ - return(-1); - checked += 2; - /* - * Check for loops in the compressed name; - * if we've looked at the whole message, - * there must be a loop. - */ - if (checked >= eomorig - msg) - return (-1); - break; - - default: - return (-1); /* flag error */ - } - } - *dn = '\0'; - if (len < 0) - len = cp - comp_dn; - return (len); -} - -/* - * Compress domain name 'exp_dn' into 'comp_dn'. - * Return the size of the compressed name or -1. - * 'length' is the size of the array pointed to by 'comp_dn'. - * 'dnptrs' is a list of pointers to previous compressed names. dnptrs[0] - * is a pointer to the beginning of the message. The list ends with NULL. - * 'lastdnptr' is a pointer to the end of the arrary pointed to - * by 'dnptrs'. Side effect is to update the list of pointers for - * labels inserted into the message as we compress the name. - * If 'dnptr' is NULL, we don't try to compress names. If 'lastdnptr' - * is NULL, we don't update the list. - */ -dn_comp(exp_dn, comp_dn, length, dnptrs, lastdnptr) - const u_char *exp_dn; - u_char *comp_dn, **dnptrs, **lastdnptr; - int length; -{ - register u_char *cp, *dn; - register int c, l; - u_char **cpp, **lpp, *sp, *eob; - u_char *msg; - - dn = (u_char *)exp_dn; - cp = comp_dn; - eob = cp + length; - if (dnptrs != NULL) { - if ((msg = *dnptrs++) != NULL) { - for (cpp = dnptrs; *cpp != NULL; cpp++) - ; - lpp = cpp; /* end of list to search */ - } - } else - msg = NULL; - for (c = *dn++; c != '\0'; ) { - /* look to see if we can use pointers */ - if (msg != NULL) { - if ((l = dn_find(dn-1, msg, dnptrs, lpp)) >= 0) { - if (cp+1 >= eob) - return (-1); - *cp++ = (l >> 8) | INDIR_MASK; - *cp++ = l % 256; - return (cp - comp_dn); - } - /* not found, save it */ - if (lastdnptr != NULL && cpp < lastdnptr-1) { - *cpp++ = cp; - *cpp = NULL; - } - } - sp = cp++; /* save ptr to length byte */ - do { - if (c == '.') { - c = *dn++; - break; - } - if (c == '\\') { - if ((c = *dn++) == '\0') - break; - } - if (cp >= eob) { - if (msg != NULL) - *lpp = NULL; - return (-1); - } - *cp++ = c; - } while ((c = *dn++) != '\0'); - /* catch trailing '.'s but not '..' */ - if ((l = cp - sp - 1) == 0 && c == '\0') { - cp--; - break; - } - if (l <= 0 || l > MAXLABEL) { - if (msg != NULL) - *lpp = NULL; - return (-1); - } - *sp = l; - } - if (cp >= eob) { - if (msg != NULL) - *lpp = NULL; - return (-1); - } - *cp++ = '\0'; - return (cp - comp_dn); -} - -/* - * Skip over a compressed domain name. Return the size or -1. - */ -__dn_skipname(comp_dn, eom) - const u_char *comp_dn, *eom; -{ - register u_char *cp; - register int n; - - cp = (u_char *)comp_dn; - while (cp < eom && (n = *cp++)) { - /* - * check for indirection - */ - switch (n & INDIR_MASK) { - case 0: /* normal case, n == len */ - cp += n; - continue; - default: /* illegal type */ - return (-1); - case INDIR_MASK: /* indirection */ - cp++; - } - break; - } - return (cp - comp_dn); -} - -/* - * Search for expanded name from a list of previously compressed names. - * Return the offset from msg if found or -1. - * dnptrs is the pointer to the first name on the list, - * not the pointer to the start of the message. - */ -static int -dn_find(exp_dn, msg, dnptrs, lastdnptr) - u_char *exp_dn, *msg; - u_char **dnptrs, **lastdnptr; -{ - register u_char *dn, *cp, **cpp; - register int n; - u_char *sp; - - for (cpp = dnptrs; cpp < lastdnptr; cpp++) { - dn = exp_dn; - sp = cp = *cpp; - while (n = *cp++) { - /* - * check for indirection - */ - switch (n & INDIR_MASK) { - case 0: /* normal case, n == len */ - while (--n >= 0) { - if (*dn == '.') - goto next; - if (*dn == '\\') - dn++; - if (*dn++ != *cp++) - goto next; - } - if ((n = *dn++) == '\0' && *cp == '\0') - return (sp - msg); - if (n == '.') - continue; - goto next; - - default: /* illegal type */ - return (-1); - - case INDIR_MASK: /* indirection */ - cp = msg + (((n & 0x3f) << 8) | *cp); - } - } - if (*dn == '\0') - return (sp - msg); - next: ; - } - return (-1); -} - -/* - * Routines to insert/extract short/long's. Must account for byte - * order and non-alignment problems. This code at least has the - * advantage of being portable. - * - * used by sendmail. - */ - -u_short -_getshort(msgp) - register u_char *msgp; -{ - register u_short u; - - GETSHORT(u, msgp); - return u; -} - -u_int32_t -_getlong(msgp) - register u_char *msgp; -{ - register u_int32_t u; - - GETLONG(u, msgp); - return u; -} - -void -#if defined(__STDC__) || defined(__cplusplus) -__putshort(register u_short s, register u_char *msgp) -#else -__putshort(s, msgp) - register u_short s; - register u_char *msgp; -#endif -{ - PUTSHORT(s, msgp); -} - -void -__putlong(l, msgp) - register u_int32_t l; - register u_char *msgp; -{ - PUTLONG(l, msgp); -} diff -ruN glibc-1.08.1/inet/res_debug.c glibc-1.09/inet/res_debug.c --- glibc-1.08.1/inet/res_debug.c Wed May 19 15:45:45 1993 +++ glibc-1.09/inet/res_debug.c Wed Dec 31 19:00:00 1969 @@ -1,747 +0,0 @@ -/* - * ++Copyright++ 1985, 1990 - * - - * Copyright (c) 1985, 1990 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - - * 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[] = "@(#)res_debug.c 5.36 (Berkeley) 3/6/91"; -static char rcsid[] = "$Id: res_debug.c,v 4.9.1.2 1993/05/17 10:00:01 vixie Exp $"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include "../conf/portability.h" - -void __fp_query(); -char *__p_class(), *__p_time(), *__p_type(); -char *p_cdname(), *p_fqname(), *p_rr(); -static char *p_option __P((u_int32_t)); - -char *_res_opcodes[] = { - "QUERY", - "IQUERY", - "CQUERYM", - "CQUERYU", - "4", - "5", - "6", - "7", - "8", - "UPDATEA", - "UPDATED", - "UPDATEDA", - "UPDATEM", - "UPDATEMA", - "ZONEINIT", - "ZONEREF", -}; - -char *_res_resultcodes[] = { - "NOERROR", - "FORMERR", - "SERVFAIL", - "NXDOMAIN", - "NOTIMP", - "REFUSED", - "6", - "7", - "8", - "9", - "10", - "11", - "12", - "13", - "14", - "NOCHANGE", -}; - -static char retbuf[16]; - -static char * -dewks(wks) - int wks; -{ - switch (wks) { - case 5: return("rje"); - case 7: return("echo"); - case 9: return("discard"); - case 11: return("systat"); - case 13: return("daytime"); - case 15: return("netstat"); - case 17: return("qotd"); - case 19: return("chargen"); - case 20: return("ftp-data"); - case 21: return("ftp"); - case 23: return("telnet"); - case 25: return("smtp"); - case 37: return("time"); - case 39: return("rlp"); - case 42: return("name"); - case 43: return("whois"); - case 53: return("domain"); - case 57: return("apts"); - case 59: return("apfs"); - case 67: return("bootps"); - case 68: return("bootpc"); - case 69: return("tftp"); - case 77: return("rje"); - case 79: return("finger"); - case 87: return("link"); - case 95: return("supdup"); - case 100: return("newacct"); - case 101: return("hostnames"); - case 102: return("iso-tsap"); - case 103: return("x400"); - case 104: return("x400-snd"); - case 105: return("csnet-ns"); - case 109: return("pop-2"); - case 111: return("sunrpc"); - case 113: return("auth"); - case 115: return("sftp"); - case 117: return("uucp-path"); - case 119: return("nntp"); - case 121: return("erpc"); - case 123: return("ntp"); - case 133: return("statsrv"); - case 136: return("profile"); - case 144: return("NeWS"); - case 161: return("snmp"); - case 162: return("snmp-trap"); - case 170: return("print-srv"); - default: (void) sprintf(retbuf, "%d", wks); return(retbuf); - } -} - -static char * -deproto(protonum) - int protonum; -{ - switch (protonum) { - case 1: return("icmp"); - case 2: return("igmp"); - case 3: return("ggp"); - case 5: return("st"); - case 6: return("tcp"); - case 7: return("ucl"); - case 8: return("egp"); - case 9: return("igp"); - case 11: return("nvp-II"); - case 12: return("pup"); - case 16: return("chaos"); - case 17: return("udp"); - default: (void) sprintf(retbuf, "%d", protonum); return(retbuf); - } -} - -static char * -do_rrset(msg, cp, cnt, pflag, file, hs) - int cnt, pflag; - char *cp,*msg, *hs; - FILE *file; -{ - int n; - char *t1, *t2, *list[100],**tt; - int sflag; - /* - * Print answer records - */ - sflag = (_res.pfcode & pflag); - if (n = ntohs(cnt)) { - *list=NULL; - if ((!_res.pfcode) || ((sflag) && (_res.pfcode & RES_PRF_HEAD1))) - fprintf(file, hs); - while (--n >= 0) { - cp = p_rr(cp, msg, file); - if ((cp-msg) > PACKETSZ) - return (NULL); - } - if ((!_res.pfcode) || ((sflag) && (_res.pfcode & RES_PRF_HEAD1))) - putc('\n', file); - } - return(cp); -} - -__p_query(msg) - char *msg; -{ - __fp_query(msg, stdout); -} - -/* - * Print the current options. - * This is intended to be primarily a debugging routine. - */ -void -__fp_resstat(statp, file) - struct __res_state *statp; - FILE *file; -{ - int bit; - - fprintf(file, ";; res options:"); - if (!statp) - statp = &_res; - for (bit = 0; bit < 32; bit++) { /* XXX 32 - bad assumption! */ - if (statp->options & (1<rcode) { - fprintf(file,";; ->>HEADER<<- opcode: %s, status: %s, id: %d", - _res_opcodes[hp->opcode], - _res_resultcodes[hp->rcode], - ntohs(hp->id)); - putc('\n', file); - } - putc(';', file); - if ((!_res.pfcode) || (_res.pfcode & RES_PRF_HEAD2)) { - fprintf(file,"; flags:"); - if (hp->qr) - fprintf(file," qr"); - if (hp->aa) - fprintf(file," aa"); - if (hp->tc) - fprintf(file," tc"); - if (hp->rd) - fprintf(file," rd"); - if (hp->ra) - fprintf(file," ra"); - if (hp->pr) - fprintf(file," pr"); - } - if ((!_res.pfcode) || (_res.pfcode & RES_PRF_HEAD1)) { - fprintf(file,"; Ques: %d", ntohs(hp->qdcount)); - fprintf(file,", Ans: %d", ntohs(hp->ancount)); - fprintf(file,", Auth: %d", ntohs(hp->nscount)); - fprintf(file,", Addit: %d\n", ntohs(hp->arcount)); - } -#if 0 - if (_res.pfcode & (RES_PRF_HEADX | RES_PRF_HEAD2 | RES_PRF_HEAD1)) { - putc('\n',file); - } -#endif - /* - * Print question records. - */ - if (n = ntohs(hp->qdcount)) { - if ((!_res.pfcode) || (_res.pfcode & RES_PRF_QUES)) - fprintf(file,";; QUESTIONS:\n"); - while (--n >= 0) { - fprintf(file,";;\t"); - cp = p_cdname(cp, msg, file); - if (cp == NULL) - return; - if ((!_res.pfcode) || (_res.pfcode & RES_PRF_QUES)) - fprintf(file, ", type = %s", - __p_type(_getshort(cp))); - cp += sizeof(u_short); - if ((!_res.pfcode) || (_res.pfcode & RES_PRF_QUES)) - fprintf(file, ", class = %s\n\n", - __p_class(_getshort(cp))); - cp += sizeof(u_short); - } - } - /* - * Print authoritative answer records - */ - cp = do_rrset(msg, cp, hp->ancount, RES_PRF_ANS, file, - ";; ANSWERS:\n"); - if (cp == NULL) - return; - - /* - * print name server records - */ - cp = do_rrset(msg, cp, hp->nscount, RES_PRF_AUTH, file, - ";; AUTHORITY RECORDS:\n"); - if (!cp) - return; - - /* - * print additional records - */ - cp = do_rrset(msg, cp, hp->arcount, RES_PRF_ADD, file, - ";; ADDITIONAL RECORDS:\n"); - if (!cp) - return; -} - -char * -p_cdname(cp, msg, file) - char *cp, *msg; - FILE *file; -{ - char name[MAXDNAME]; - int n; - - if ((n = dn_expand((u_char *)msg, (u_char *)msg + 512, (u_char *)cp, - (u_char *)name, sizeof(name))) < 0) - return (NULL); - if (name[0] == '\0') { - putc('.', file); - } else { - fputs(name, file); - } - return (cp + n); -} - -char * -p_fqname(cp, msg, file) - char *cp, *msg; - FILE *file; -{ - char name[MAXDNAME]; - int n, len; - - if ((n = dn_expand((u_char *)msg, (u_char *)msg + 512, (u_char *)cp, - (u_char *)name, sizeof(name))) < 0) - return (NULL); - if (name[0] == '\0') { - putc('.', file); - } else { - fputs(name, file); - if (name[strlen(name) - 1] != '.') - putc('.', file); - } - return (cp + n); -} - - - -/* - * Print resource record fields in human readable form. - */ -char * -p_rr(cp, msg, file) - char *cp, *msg; - FILE *file; -{ - int type, class, dlen, n, c; - struct in_addr inaddr; - char *cp1, *cp2; - u_int32_t tmpttl, t; - int lcnt; - - if ((cp = p_fqname(cp, msg, file)) == NULL) - return (NULL); /* compression error */ - type = _getshort(cp); - cp += sizeof(u_short); - class = _getshort(cp); - cp += sizeof(u_short); - tmpttl = _getlong(cp); - cp += sizeof(u_int32_t); - dlen = _getshort(cp); - cp += sizeof(u_short); - cp1 = cp; - if ((!_res.pfcode) || (_res.pfcode & RES_PRF_TTLID)) - fprintf(file, "\t%lu", tmpttl); - if ((!_res.pfcode) || (_res.pfcode & RES_PRF_CLASS)) - fprintf(file, "\t%s", __p_class(class)); - fprintf(file, "\t%s", __p_type(type)); - /* - * Print type specific data, if appropriate - */ - switch (type) { - case T_A: - switch (class) { - case C_IN: - case C_HS: - bcopy(cp, (char *)&inaddr, sizeof(inaddr)); - if (dlen == 4) { - fprintf(file,"\t%s", inet_ntoa(inaddr)); - cp += dlen; - } else if (dlen == 7) { - char *address; - u_char protocol; - u_short port; - - address = inet_ntoa(inaddr); - cp += sizeof(inaddr); - protocol = *(u_char*)cp; - cp += sizeof(u_char); - port = _getshort(cp); - cp += sizeof(u_short); - fprintf(file, "\t%s\t; proto %d, port %d", - address, protocol, port); - } - break; - default: - cp += dlen; - } - break; - case T_CNAME: - case T_MB: - case T_MG: - case T_MR: - case T_NS: - case T_PTR: - putc('\t', file); - cp = p_fqname(cp, msg, file); - break; - - case T_HINFO: - if (n = *cp++) { - fprintf(file,"\t%.*s", n, cp); - cp += n; - } - if (n = *cp++) { - fprintf(file,"\t%.*s", n, cp); - cp += n; - } - break; - - case T_SOA: - putc('\t', file); - cp = p_fqname(cp, msg, file); /* origin */ - putc(' ', file); - cp = p_fqname(cp, msg, file); /* mail addr */ - fputs(" (\n", file); - t = _getlong(cp); cp += sizeof(u_int32_t); - fprintf(file,"\t\t\t%lu\t; serial\n", t); - t = _getlong(cp); cp += sizeof(u_int32_t); - fprintf(file,"\t\t\t%lu\t; refresh (%s)\n", t, __p_time(t)); - t = _getlong(cp); cp += sizeof(u_int32_t); - fprintf(file,"\t\t\t%lu\t; retry (%s)\n", t, __p_time(t)); - t = _getlong(cp); cp += sizeof(u_int32_t); - fprintf(file,"\t\t\t%lu\t; expire (%s)\n", t, __p_time(t)); - t = _getlong(cp); cp += sizeof(u_int32_t); - fprintf(file,"\t\t\t%lu )\t; minimum (%s)", t, __p_time(t)); - break; - - case T_MX: - fprintf(file,"\t%d ", _getshort(cp)); - cp += sizeof(u_short); - cp = p_fqname(cp, msg, file); - break; - - case T_TXT: - (void) fputs("\t\"", file); - cp2 = cp1 + dlen; - while (cp < cp2) { - if (n = (unsigned char) *cp++) { - for (c = n; c > 0 && cp < cp2; c--) - if (*cp == '\n') { - (void) putc('\\', file); - (void) putc(*cp++, file); - } else - (void) putc(*cp++, file); - } - } - putc('"', file); - break; - - case T_MINFO: - case T_RP: - putc('\t', file); - cp = p_fqname(cp, msg, file); - putc(' ', file); - cp = p_fqname(cp, msg, file); - break; - - case T_UINFO: - putc('\t', file); - fputs(cp, file); - cp += dlen; - break; - - case T_UID: - case T_GID: - if (dlen == 4) { - fprintf(file,"\t%u", _getlong(cp)); - cp += sizeof(int32_t); - } - break; - - case T_WKS: - if (dlen < sizeof(u_int32_t) + 1) - break; - bcopy(cp, (char *)&inaddr, sizeof(inaddr)); - cp += sizeof(u_int32_t); - fprintf(file, "\t%s %s ( ", - inet_ntoa(inaddr), - deproto((int) *cp)); - cp += sizeof(u_char); - n = 0; - lcnt = 0; - while (cp < cp1 + dlen) { - c = *cp++; - do { - if (c & 0200) { - if (lcnt == 0) { - fputs("\n\t\t\t", file); - lcnt = 5; - } - fputs(dewks(n), file); - putc(' ', file); - lcnt--; - } - c <<= 1; - } while (++n & 07); - } - putc(')', file); - break; - -#ifdef ALLOW_T_UNSPEC - case T_UNSPEC: - { - int NumBytes = 8; - char *DataPtr; - int i; - - if (dlen < NumBytes) NumBytes = dlen; - fprintf(file, "\tFirst %d bytes of hex data:", - NumBytes); - for (i = 0, DataPtr = cp; i < NumBytes; i++, DataPtr++) - fprintf(file, " %x", *DataPtr); - cp += dlen; - } - break; -#endif /* ALLOW_T_UNSPEC */ - - default: - fprintf(file,"\t?%d?", type); - cp += dlen; - } -#if 0 - fprintf(file, "\t; dlen=%d, ttl %s\n", dlen, __p_time(tmpttl)); -#else - putc('\n', file); -#endif - if (cp - cp1 != dlen) { - fprintf(file,";; packet size error (found %d, dlen was %d)\n", - cp - cp1, dlen); - cp = NULL; - } - return (cp); -} - -static char nbuf[40]; - -/* - * Return a string for the type - */ -char * -__p_type(type) - int type; -{ - switch (type) { - case T_A: - return("A"); - case T_NS: /* authoritative server */ - return("NS"); - case T_CNAME: /* canonical name */ - return("CNAME"); - case T_SOA: /* start of authority zone */ - return("SOA"); - case T_MB: /* mailbox domain name */ - return("MB"); - case T_MG: /* mail group member */ - return("MG"); - case T_MR: /* mail rename name */ - return("MR"); - case T_NULL: /* null resource record */ - return("NULL"); - case T_WKS: /* well known service */ - return("WKS"); - case T_PTR: /* domain name pointer */ - return("PTR"); - case T_HINFO: /* host information */ - return("HINFO"); - case T_MINFO: /* mailbox information */ - return("MINFO"); - case T_MX: /* mail routing info */ - return("MX"); - case T_TXT: /* text */ - return("TXT"); - case T_RP: /* responsible person */ - return("RP"); - case T_AXFR: /* zone transfer */ - return("AXFR"); - case T_MAILB: /* mail box */ - return("MAILB"); - case T_MAILA: /* mail address */ - return("MAILA"); - case T_ANY: /* matches any type */ - return("ANY"); - case T_UINFO: - return("UINFO"); - case T_UID: - return("UID"); - case T_GID: - return("GID"); -#ifdef ALLOW_T_UNSPEC - case T_UNSPEC: - return("UNSPEC"); -#endif /* ALLOW_T_UNSPEC */ - default: - (void)sprintf(nbuf, "%d", type); - return(nbuf); - } -} - -/* - * Return a mnemonic for class - */ -char * -__p_class(class) - int class; -{ - - switch (class) { - case C_IN: /* internet class */ - return("IN"); - case C_HS: /* hesiod class */ - return("HS"); - case C_ANY: /* matches any class */ - return("ANY"); - default: - (void)sprintf(nbuf, "%d", class); - return(nbuf); - } -} - -/* - * Return a mnemonic for an option - */ -static char * -p_option(option) - u_int32_t option; -{ - switch (option) { - case RES_INIT: return "init"; - case RES_DEBUG: return "debug"; - case RES_AAONLY: return "aaonly"; - case RES_USEVC: return "usevc"; - case RES_PRIMARY: return "primry"; - case RES_IGNTC: return "igntc"; - case RES_RECURSE: return "recurs"; - case RES_DEFNAMES: return "defnam"; - case RES_STAYOPEN: return "styopn"; - case RES_DNSRCH: return "dnsrch"; - default: sprintf(nbuf, "?0x%x?", option); return nbuf; - } -} - -/* - * Return a mnemonic for a time to live - */ -char * -__p_time(value) - u_int32_t value; -{ - int secs, mins, hours, days; - register char *p; - - if (value == 0) { - strcpy(nbuf, "0 secs"); - return(nbuf); - } - - secs = value % 60; - value /= 60; - mins = value % 60; - value /= 60; - hours = value % 24; - value /= 24; - days = value; - value = 0; - -#define PLURALIZE(x) x, (x == 1) ? "" : "s" - p = nbuf; - if (days) { - (void)sprintf(p, "%d day%s", PLURALIZE(days)); - while (*++p); - } - if (hours) { - if (days) - *p++ = ' '; - (void)sprintf(p, "%d hour%s", PLURALIZE(hours)); - while (*++p); - } - if (mins) { - if (days || hours) - *p++ = ' '; - (void)sprintf(p, "%d min%s", PLURALIZE(mins)); - while (*++p); - } - if (secs || ! (days || hours || mins)) { - if (days || hours || mins) - *p++ = ' '; - (void)sprintf(p, "%d sec%s", PLURALIZE(secs)); - } - return(nbuf); -} diff -ruN glibc-1.08.1/inet/res_init.c glibc-1.09/inet/res_init.c --- glibc-1.08.1/inet/res_init.c Wed May 19 15:45:45 1993 +++ glibc-1.09/inet/res_init.c Wed Dec 31 19:00:00 1969 @@ -1,228 +0,0 @@ -/* - * ++Copyright++ 1985, 1989 - * - - * Copyright (c) 1985, 1989 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - - * 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[] = "@(#)res_init.c 6.15 (Berkeley) 2/24/91"; -static char rcsid[] = "$Id: res_init.c,v 4.9.1.1 1993/05/02 22:43:03 vixie Rel $"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include "../conf/portability.h" - - -/* - * Resolver state default settings - */ - -struct __res_state _res = { - RES_TIMEOUT, /* retransmition time interval */ - 4, /* number of times to retransmit */ - RES_DEFAULT, /* options flags */ - 1, /* number of name servers */ -}; - -/* - * Set up default settings. If the configuration file exist, the values - * there will have precedence. Otherwise, the server address is set to - * 127.0.0.1 and the default domain name comes from the gethostname(). - * - * Previous resolver versions used INADDR_ANY rather than IN_LOOPBACKNET. - * This has bad side-effects in the kernel since 0.0.0.0 means "any interface" - * and the first one found may or may not be the loopback interface. - * If it is a point-to-point interface, then the SLIP or PPP or DDCMP state - * must be "up" in order for the packets to loop correctly. This is deemed - * "bad". - * - * The configuration file should only be used if you want to redefine your - * domain or run without a server on your machine. - * - * Return 0 if completes successfully, -1 on error - */ -res_init() -{ - register FILE *fp; - register char *cp, **pp; - register int n; - char buf[BUFSIZ]; - int nserv = 0; /* number of nameserver records read from file */ - int haveenv = 0; - int havesearch = 0; - - _res.nsaddr.sin_addr = inet_makeaddr(IN_LOOPBACKNET, 1); - _res.nsaddr.sin_family = AF_INET; - _res.nsaddr.sin_port = htons(NAMESERVER_PORT); - _res.nscount = 1; - _res.pfcode = 0; - - /* Allow user to override the local domain definition */ - if ((cp = getenv("LOCALDOMAIN")) != NULL) { - (void)strncpy(_res.defdname, cp, sizeof(_res.defdname)); - if ((cp = strpbrk(_res.defdname, " \t\n")) != NULL) - *cp = '\0'; - haveenv++; - } - - if ((fp = fopen(_PATH_RESCONF, "r")) != NULL) { - /* read the config file */ - while (fgets(buf, sizeof(buf), fp) != NULL) { - /* skip comments */ - if ((*buf == ';') || (*buf == '#')) - continue; - /* read default domain name */ - if (!strncmp(buf, "domain", sizeof("domain") - 1)) { - if (haveenv) /* skip if have from environ */ - continue; - cp = buf + sizeof("domain") - 1; - while (*cp == ' ' || *cp == '\t') - cp++; - if ((*cp == '\0') || (*cp == '\n')) - continue; - (void)strncpy(_res.defdname, cp, - sizeof(_res.defdname) - 1); - if ((cp = strpbrk(_res.defdname, " \t\n")) != NULL) - *cp = '\0'; - havesearch = 0; - continue; - } - /* set search list */ - if (!strncmp(buf, "search", sizeof("search") - 1)) { - if (haveenv) /* skip if have from environ */ - continue; - cp = buf + sizeof("search") - 1; - while (*cp == ' ' || *cp == '\t') - cp++; - if ((*cp == '\0') || (*cp == '\n')) - continue; - (void)strncpy(_res.defdname, cp, - sizeof(_res.defdname) - 1); - if ((cp = strchr(_res.defdname, '\n')) != NULL) - *cp = '\0'; - /* - * Set search list to be blank-separated strings - * on rest of line. - */ - cp = _res.defdname; - pp = _res.dnsrch; - *pp++ = cp; - for (n = 0; *cp && pp < _res.dnsrch + MAXDNSRCH; cp++) { - if (*cp == ' ' || *cp == '\t') { - *cp = 0; - n = 1; - } else if (n) { - *pp++ = cp; - n = 0; - } - } - /* null terminate last domain if there are excess */ - while (*cp != '\0' && *cp != ' ' && *cp != '\t') - cp++; - *cp = '\0'; - *pp++ = 0; - havesearch = 1; - continue; - } - /* read nameservers to query */ - if (!strncmp(buf, "nameserver", sizeof("nameserver") - 1) && - nserv < MAXNS) { - struct in_addr a; - - cp = buf + sizeof("nameserver") - 1; - while (*cp == ' ' || *cp == '\t') - cp++; - if ((*cp != '\0') && (*cp != '\n') && inet_aton(cp, &a)) { - _res.nsaddr_list[nserv].sin_addr = a; - _res.nsaddr_list[nserv].sin_family = AF_INET; - _res.nsaddr_list[nserv].sin_port = - htons(NAMESERVER_PORT); - nserv++; - } - continue; - } - } - if (nserv > 1) - _res.nscount = nserv; - (void) fclose(fp); - } - if (_res.defdname[0] == 0) { - if (gethostname(buf, sizeof(_res.defdname)) == 0 && - (cp = strchr(buf, '.'))) - (void)strcpy(_res.defdname, cp + 1); - } - - /* find components of local domain that might be searched */ - if (havesearch == 0) { - pp = _res.dnsrch; - *pp++ = _res.defdname; - for (cp = _res.defdname, n = 0; *cp; cp++) - if (*cp == '.') - n++; - cp = _res.defdname; - for (; - n >= LOCALDOMAINPARTS && pp < _res.dnsrch + MAXDFLSRCH; - n--) { - cp = strchr(cp, '.'); - *pp++ = ++cp; - } - *pp++ = 0; - } - _res.options |= RES_INIT; - return (0); -} diff -ruN glibc-1.08.1/inet/res_mkqry.c glibc-1.09/inet/res_mkqry.c --- glibc-1.08.1/inet/res_mkqry.c Wed May 19 15:45:46 1993 +++ glibc-1.09/inet/res_mkqry.c Wed Dec 31 19:00:00 1969 @@ -1,232 +0,0 @@ -/* - * ++Copyright++ 1985 - * - - * Copyright (c) 1985 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - - * 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[] = "@(#)res_mkquery.c 6.16 (Berkeley) 3/6/91"; -static char rcsid[] = "$Id: res_mkquery.c,v 4.9.1.2 1993/05/17 10:00:01 vixie Exp $"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include "../conf/portability.h" - -/* - * Form all types of queries. - * Returns the size of the result or -1. - */ -res_mkquery(op, dname, class, type, data, datalen, newrr_in, buf, buflen) - int op; /* opcode of query */ - const char *dname; /* domain name */ - int class, type; /* class and type of query */ - const char *data; /* resource record data */ - int datalen; /* length of data */ - const char *newrr_in; /* new rr for modify or append */ - char *buf; /* buffer to put query */ - int buflen; /* size of buffer */ -{ - register HEADER *hp; - register char *cp; - register int n; - struct rrec *newrr = (struct rrec *) newrr_in; - char *dnptrs[10], **dpp, **lastdnptr; - -#ifdef DEBUG - if (_res.options & RES_DEBUG) - printf(";; res_mkquery(%d, %s, %d, %d)\n", - op, dname, class, type); -#endif - /* - * Initialize header fields. - */ - if ((buf == NULL) || (buflen < sizeof(HEADER))) - return(-1); - bzero(buf, sizeof(HEADER)); - hp = (HEADER *) buf; - hp->id = htons(++_res.id); - hp->opcode = op; - hp->pr = (_res.options & RES_PRIMARY) != 0; - hp->rd = (_res.options & RES_RECURSE) != 0; - hp->rcode = NOERROR; - cp = buf + sizeof(HEADER); - buflen -= sizeof(HEADER); - dpp = dnptrs; - *dpp++ = buf; - *dpp++ = NULL; - lastdnptr = dnptrs + sizeof(dnptrs)/sizeof(dnptrs[0]); - /* - * perform opcode specific processing - */ - switch (op) { - case QUERY: - if ((buflen -= QFIXEDSZ) < 0) - return(-1); - if ((n = dn_comp((u_char *)dname, (u_char *)cp, buflen, - (u_char **)dnptrs, (u_char **)lastdnptr)) < 0) - return (-1); - cp += n; - buflen -= n; - __putshort(type, (u_char *)cp); - cp += sizeof(u_short); - __putshort(class, (u_char *)cp); - cp += sizeof(u_short); - hp->qdcount = htons(1); - if (op == QUERY || data == NULL) - break; - /* - * Make an additional record for completion domain. - */ - buflen -= RRFIXEDSZ; - if ((n = dn_comp((u_char *)data, (u_char *)cp, buflen, - (u_char **)dnptrs, (u_char **)lastdnptr)) < 0) - return (-1); - cp += n; - buflen -= n; - __putshort(T_NULL, (u_char *)cp); - cp += sizeof(u_short); - __putshort(class, (u_char *)cp); - cp += sizeof(u_short); - __putlong(0, (u_char *)cp); - cp += sizeof(u_int32_t); - __putshort(0, (u_char *)cp); - cp += sizeof(u_short); - hp->arcount = htons(1); - break; - - case IQUERY: - /* - * Initialize answer section - */ - if (buflen < 1 + RRFIXEDSZ + datalen) - return (-1); - *cp++ = '\0'; /* no domain name */ - __putshort(type, (u_char *)cp); - cp += sizeof(u_short); - __putshort(class, (u_char *)cp); - cp += sizeof(u_short); - __putlong(0, (u_char *)cp); - cp += sizeof(u_int32_t); - __putshort(datalen, (u_char *)cp); - cp += sizeof(u_short); - if (datalen) { - bcopy(data, cp, datalen); - cp += datalen; - } - hp->ancount = htons(1); - break; - -#ifdef ALLOW_UPDATES - /* - * For UPDATEM/UPDATEMA, do UPDATED/UPDATEDA followed by UPDATEA - * (Record to be modified is followed by its replacement in msg.) - */ - case UPDATEM: - case UPDATEMA: - - case UPDATED: - /* - * The res code for UPDATED and UPDATEDA is the same; user - * calls them differently: specifies data for UPDATED; server - * ignores data if specified for UPDATEDA. - */ - case UPDATEDA: - buflen -= RRFIXEDSZ + datalen; - if ((n = dn_comp(dname, cp, buflen, dnptrs, lastdnptr)) < 0) - return (-1); - cp += n; - __putshort(type, cp); - cp += sizeof(u_short); - __putshort(class, cp); - cp += sizeof(u_short); - __putlong(0, cp); - cp += sizeof(u_int32_t); - __putshort(datalen, cp); - cp += sizeof(u_short); - if (datalen) { - bcopy(data, cp, datalen); - cp += datalen; - } - if ( (op == UPDATED) || (op == UPDATEDA) ) { - hp->ancount = htons(0); - break; - } - /* Else UPDATEM/UPDATEMA, so drop into code for UPDATEA */ - - case UPDATEA: /* Add new resource record */ - buflen -= RRFIXEDSZ + datalen; - if ((n = dn_comp(dname, cp, buflen, dnptrs, lastdnptr)) < 0) - return (-1); - cp += n; - __putshort(newrr->r_type, cp); - cp += sizeof(u_short); - __putshort(newrr->r_class, cp); - cp += sizeof(u_short); - __putlong(0, cp); - cp += sizeof(u_int32_t); - __putshort(newrr->r_size, cp); - cp += sizeof(u_short); - if (newrr->r_size) { - bcopy(newrr->r_data, cp, newrr->r_size); - cp += newrr->r_size; - } - hp->ancount = htons(0); - break; - -#endif /* ALLOW_UPDATES */ - } - return (cp - buf); -} diff -ruN glibc-1.08.1/inet/res_query.c glibc-1.09/inet/res_query.c --- glibc-1.08.1/inet/res_query.c Wed May 19 15:45:47 1993 +++ glibc-1.09/inet/res_query.c Wed Dec 31 19:00:00 1969 @@ -1,304 +0,0 @@ -/* - * ++Copyright++ 1988 - * - - * Copyright (c) 1988 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - - * 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[] = "@(#)res_query.c 5.11 (Berkeley) 3/6/91"; -static char rcsid[] = "$Id: res_query.c,v 4.9.1.1 1993/05/02 22:43:03 vixie Rel $"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "../conf/portability.h" - -#if PACKETSZ > 1024 -#define MAXPACKET PACKETSZ -#else -#define MAXPACKET 1024 -#endif - -int h_errno; - -/* - * Formulate a normal query, send, and await answer. - * Returned answer is placed in supplied buffer "answer". - * Perform preliminary check of answer, returning success only - * if no error is indicated and the answer count is nonzero. - * Return the size of the response on success, -1 on error. - * Error number is left in h_errno. - * Caller must parse answer and determine whether it answers the question. - */ -res_query(name, class, type, answer, anslen) - char *name; /* domain name */ - int class, type; /* class and type of query */ - u_char *answer; /* buffer to put answer */ - int anslen; /* size of answer buffer */ -{ - char buf[MAXPACKET]; - HEADER *hp; - int n; - - if ((_res.options & RES_INIT) == 0 && res_init() == -1) - return (-1); -#ifdef DEBUG - if (_res.options & RES_DEBUG) - printf(";; res_query(%s, %d, %d)\n", name, class, type); -#endif - n = res_mkquery(QUERY, name, class, type, (char *)NULL, 0, NULL, - buf, sizeof(buf)); - - if (n <= 0) { -#ifdef DEBUG - if (_res.options & RES_DEBUG) - printf(";; res_query: mkquery failed\n"); -#endif - h_errno = NO_RECOVERY; - return (n); - } - n = res_send(buf, n, (char *)answer, anslen); - if (n < 0) { -#ifdef DEBUG - if (_res.options & RES_DEBUG) - printf(";; res_query: send error\n"); -#endif - h_errno = TRY_AGAIN; - return(n); - } - - hp = (HEADER *) answer; - if (hp->rcode != NOERROR || ntohs(hp->ancount) == 0) { -#ifdef DEBUG - if (_res.options & RES_DEBUG) - printf(";; rcode = %d, ancount=%d\n", hp->rcode, - ntohs(hp->ancount)); -#endif - switch (hp->rcode) { - case NXDOMAIN: - h_errno = HOST_NOT_FOUND; - break; - case SERVFAIL: - h_errno = TRY_AGAIN; - break; - case NOERROR: - h_errno = NO_DATA; - break; - case FORMERR: - case NOTIMP: - case REFUSED: - default: - h_errno = NO_RECOVERY; - break; - } - return (-1); - } - return(n); -} - -/* - * Formulate a normal query, send, and retrieve answer in supplied buffer. - * Return the size of the response on success, -1 on error. - * If enabled, implement search rules until answer or unrecoverable failure - * is detected. Error number is left in h_errno. - * Only useful for queries in the same name hierarchy as the local host - * (not, for example, for host address-to-name lookups in domain in-addr.arpa). - */ -int -res_search(name, class, type, answer, anslen) - char *name; /* domain name */ - int class, type; /* class and type of query */ - u_char *answer; /* buffer to put answer */ - int anslen; /* size of answer */ -{ - register char *cp, **domain; - int n, ret, got_nodata = 0; - char *__hostalias(); - - if ((_res.options & RES_INIT) == 0 && res_init() == -1) - return (-1); - - errno = 0; - h_errno = HOST_NOT_FOUND; /* default, if we never query */ - for (cp = name, n = 0; *cp; cp++) - if (*cp == '.') - n++; - if (n == 0 && (cp = __hostalias(name))) - return (res_query(cp, class, type, answer, anslen)); - - /* - * We do at least one level of search if - * - there is no dot and RES_DEFNAME is set, or - * - there is at least one dot, there is no trailing dot, - * and RES_DNSRCH is set. - */ - if ((n == 0 && _res.options & RES_DEFNAMES) || - (n != 0 && *--cp != '.' && _res.options & RES_DNSRCH)) - for (domain = _res.dnsrch; *domain; domain++) { - ret = res_querydomain(name, *domain, class, type, - answer, anslen); - if (ret > 0) - return (ret); - /* - * If no server present, give up. - * If name isn't found in this domain, - * keep trying higher domains in the search list - * (if that's enabled). - * On a NO_DATA error, keep trying, otherwise - * a wildcard entry of another type could keep us - * from finding this entry higher in the domain. - * If we get some other error (negative answer or - * server failure), then stop searching up, - * but try the input name below in case it's fully-qualified. - */ - if (errno == ECONNREFUSED) { - h_errno = TRY_AGAIN; - return (-1); - } - if (h_errno == NO_DATA) - got_nodata++; - if ((h_errno != HOST_NOT_FOUND && h_errno != NO_DATA) || - (_res.options & RES_DNSRCH) == 0) - break; - } - /* - * If the search/default failed, try the name as fully-qualified, - * but only if it contained at least one dot (even trailing). - * This is purely a heuristic; we assume that any reasonable query - * about a top-level domain (for servers, SOA, etc) will not use - * res_search. - */ - if (n && (ret = res_querydomain(name, (char *)NULL, class, type, - answer, anslen)) > 0) - return (ret); - if (got_nodata) - h_errno = NO_DATA; - return (-1); -} - -/* - * Perform a call on res_query on the concatenation of name and domain, - * removing a trailing dot from name if domain is NULL. - */ -res_querydomain(name, domain, class, type, answer, anslen) - char *name, *domain; - int class, type; /* class and type of query */ - u_char *answer; /* buffer to put answer */ - int anslen; /* size of answer */ -{ - char nbuf[2*MAXDNAME+2]; - char *longname = nbuf; - int n; - -#ifdef DEBUG - if (_res.options & RES_DEBUG) - printf(";; res_querydomain(%s, %s, %d, %d)\n", - name, domain, class, type); -#endif - if (domain == NULL) { - /* - * Check for trailing '.'; - * copy without '.' if present. - */ - n = strlen(name) - 1; - if (name[n] == '.' && n < sizeof(nbuf) - 1) { - bcopy(name, nbuf, n); - nbuf[n] = '\0'; - } else - longname = name; - } else - (void)sprintf(nbuf, "%.*s.%.*s", - MAXDNAME, name, MAXDNAME, domain); - - return (res_query(longname, class, type, answer, anslen)); -} - -char * -__hostalias(name) - register const char *name; -{ - register char *C1, *C2; - FILE *fp; - char *file, *getenv(), *strcpy(), *strncpy(); - char buf[BUFSIZ]; - static char abuf[MAXDNAME]; - - file = getenv("HOSTALIASES"); - if (file == NULL || (fp = fopen(file, "r")) == NULL) - return (NULL); - buf[sizeof(buf) - 1] = '\0'; - while (fgets(buf, sizeof(buf), fp)) { - for (C1 = buf; *C1 && !isspace(*C1); ++C1); - if (!*C1) - break; - *C1 = '\0'; - if (!strcasecmp(buf, name)) { - while (isspace(*++C1)); - if (!*C1) - break; - for (C2 = C1 + 1; *C2 && !isspace(*C2); ++C2); - abuf[sizeof(abuf) - 1] = *C2 = '\0'; - (void)strncpy(abuf, C1, sizeof(abuf) - 1); - fclose(fp); - return (abuf); - } - } - fclose(fp); - return (NULL); -} diff -ruN glibc-1.08.1/inet/res_send.c glibc-1.09/inet/res_send.c --- glibc-1.08.1/inet/res_send.c Wed May 19 15:45:48 1993 +++ glibc-1.09/inet/res_send.c Wed Dec 31 19:00:00 1969 @@ -1,478 +0,0 @@ -/* - * ++Copyright++ 1985, 1989 - * - - * Copyright (c) 1985, 1989 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - - * 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[] = "@(#)res_send.c 6.27 (Berkeley) 2/24/91"; -static char rcsid[] = "$Id: res_send.c,v 4.9.1.1 1993/05/02 22:43:03 vixie Rel $"; -#endif /* LIBC_SCCS and not lint */ - -/* - * Send query to name server and wait for reply. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "../conf/portability.h" - -static int s = -1; /* socket used for communications */ -static struct sockaddr no_addr; - -#ifndef FD_SET -#define NFDBITS 32 -#define FD_SETSIZE 32 -#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS))) -#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS))) -#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS))) -#define FD_ZERO(p) bzero((char *)(p), sizeof(*(p))) -#endif - -res_send(buf, buflen, answer, anslen) - const char *buf; - int buflen; - char *answer; - int anslen; -{ - register int n; - int try, v_circuit, resplen, ns; - int gotsomewhere = 0, connected = 0; - int connreset = 0; - u_short id, len; - char *cp; - fd_set dsmask; - struct timeval timeout; - HEADER *hp = (HEADER *) buf; - HEADER *anhp = (HEADER *) answer; - u_int badns; /* XXX NSMAX can't exceed #/bits per this */ - struct iovec iov[2]; - int terrno = ETIMEDOUT; - char junk[512]; - -#ifdef DEBUG - if ((_res.options & RES_DEBUG) || (_res.pfcode & RES_PRF_QUERY)) { - printf(";; res_send()\n"); - __p_query(buf); - } -#endif - if (!(_res.options & RES_INIT)) - if (res_init() == -1) { - return(-1); - } - v_circuit = (_res.options & RES_USEVC) || buflen > PACKETSZ; - id = hp->id; - badns = 0; - /* - * Send request, RETRY times, or until successful - */ - for (try = 0; try < _res.retry; try++) { - for (ns = 0; ns < _res.nscount; ns++) { - if (badns & (1< 0) { - cp += n; - len -= n; - } - if (n <= 0) { - terrno = errno; -#ifdef DEBUG - if (_res.options & RES_DEBUG) - perror("read failed"); -#endif - (void) close(s); - s = -1; - /* - * A long running process might get its TCP - * connection reset if the remote server was - * restarted. Requery the server instead of - * trying a new one. When there is only one - * server, this means that a query might work - * instead of failing. We only allow one reset - * per query to prevent looping. - */ - if (terrno == ECONNRESET && !connreset) { - connreset = 1; - ns--; - } - continue; - } - cp = answer; - if ((resplen = ntohs(*(u_short *)cp)) > anslen) { -#ifdef DEBUG - if (_res.options & RES_DEBUG) - fprintf(stderr, - ";; response truncated\n"); -#endif - len = anslen; - truncated = 1; - } else - len = resplen; - while (len != 0 && - (n = read(s, (char *)cp, (int)len)) > 0) { - cp += n; - len -= n; - } - if (n <= 0) { - terrno = errno; -#ifdef DEBUG - if (_res.options & RES_DEBUG) - perror("read failed"); -#endif - (void) close(s); - s = -1; - continue; - } - if (truncated) { - /* - * Flush rest of answer - * so connection stays in synch. - */ - anhp->tc = 1; - len = resplen - anslen; - while (len != 0) { - n = (len > sizeof(junk) ? - sizeof(junk) : len); - if ((n = read(s, junk, n)) > 0) - len -= n; - else - break; - } - } - } else { - /* - * Use datagrams. - */ - if (s < 0) { - s = socket(AF_INET, SOCK_DGRAM, 0); - if (s < 0) { - terrno = errno; -#ifdef DEBUG - if (_res.options & RES_DEBUG) - perror("socket (dg) failed"); -#endif - continue; - } - } -#if BSD >= 43 - /* - * I'm tired of answering this question, so: - * On a 4.3BSD+ machine (client and server, - * actually), sending to a nameserver datagram - * port with no nameserver will cause an - * ICMP port unreachable message to be returned. - * If our datagram socket is "connected" to the - * server, we get an ECONNREFUSED error on the next - * socket operation, and select returns if the - * error message is received. We can thus detect - * the absence of a nameserver without timing out. - * If we have sent queries to at least two servers, - * however, we don't want to remain connected, - * as we wish to receive answers from the first - * server to respond. - */ - if (_res.nscount == 1 || (try == 0 && ns == 0)) { - /* - * Don't use connect if we might - * still receive a response - * from another server. - */ - if (connected == 0) { - if (connect(s, - (struct sockaddr *) - &_res.nsaddr_list[ns], - sizeof(struct sockaddr) - ) < 0) { -#ifdef DEBUG - if (_res.options & RES_DEBUG) - perror("connect"); -#endif - continue; - } - connected = 1; - } - if (send(s, buf, buflen, 0) != buflen) { -#ifdef DEBUG - if (_res.options & RES_DEBUG) - perror("send"); -#endif - continue; - } - } else { - /* - * Disconnect if we want to listen - * for responses from more than one server. - */ - if (connected) { - (void) connect(s, &no_addr, - sizeof(no_addr)); - connected = 0; - } -#endif /* BSD */ - if (sendto(s, buf, buflen, 0, - (struct sockaddr *)&_res.nsaddr_list[ns], - sizeof(struct sockaddr)) != buflen) { -#ifdef DEBUG - if (_res.options & RES_DEBUG) - perror("sendto"); -#endif - continue; - } -#if BSD >= 43 - } -#endif - - /* - * Wait for reply - */ - timeout.tv_sec = (_res.retrans << try); - if (try > 0) - timeout.tv_sec /= _res.nscount; - if ((long) timeout.tv_sec <= 0) - timeout.tv_sec = 1; - timeout.tv_usec = 0; -wait: - FD_ZERO(&dsmask); - FD_SET(s, &dsmask); - n = select(s+1, &dsmask, (fd_set *)NULL, - (fd_set *)NULL, &timeout); - if (n < 0) { -#ifdef DEBUG - if (_res.options & RES_DEBUG) - perror("select"); -#endif - continue; - } - if (n == 0) { - /* - * timeout - */ -#ifdef DEBUG - if (_res.options & RES_DEBUG) - printf(";; timeout\n"); -#endif -#if BSD >= 43 - gotsomewhere = 1; -#endif - continue; - } - if ((resplen = recv(s, answer, anslen, 0)) <= 0) { -#ifdef DEBUG - if (_res.options & RES_DEBUG) - perror("recvfrom"); -#endif - continue; - } - gotsomewhere = 1; - if (id != anhp->id) { - /* - * response from old query, ignore it - */ -#ifdef DEBUG - if ((_res.options & RES_DEBUG) || - (_res.pfcode & RES_PRF_REPLY)) { - printf(";; old answer:\n"); - __p_query(answer); - } -#endif - goto wait; - } - if (anhp->rcode == SERVFAIL - || anhp->rcode == NOTIMP - || anhp->rcode == REFUSED) { -#ifdef DEBUG - if (_res.options & RES_DEBUG) { - printf("server rejected query:\n"); - __p_query(answer); - } -#endif DEBUG - badns |= (1<tc) { - /* - * get rest of answer; - * use TCP with same server. - */ -#ifdef DEBUG - if (_res.options & RES_DEBUG) - printf(";; truncated answer\n"); -#endif - (void) close(s); - s = -1; - v_circuit = 1; - goto usevc; - } - } -#ifdef DEBUG - if (_res.options & RES_DEBUG) - printf(";; got answer:\n"); - if ((_res.options & RES_DEBUG) - || (_res.pfcode & RES_PRF_REPLY)) { - __p_query(answer); - } -#endif - /* - * If using virtual circuits, we assume that the first server - * is preferred * over the rest (i.e. it is on the local - * machine) and only keep that one open. - * If we have temporarily opened a virtual circuit, - * or if we haven't been asked to keep a socket open, - * close the socket. - */ - if ((v_circuit && - ((_res.options & RES_USEVC) == 0 || ns != 0)) || - (_res.options & RES_STAYOPEN) == 0) { - (void) close(s); - s = -1; - } - return (resplen); - } - } - if (s >= 0) { - (void) close(s); - s = -1; - } - if (v_circuit == 0) - if (gotsomewhere == 0) - errno = ECONNREFUSED; /* no nameservers found */ - else - errno = ETIMEDOUT; /* no answer obtained */ - else - errno = terrno; - return (-1); -} - -/* - * This routine is for closing the socket if a virtual circuit is used and - * the program wants to close it. This provides support for endhostent() - * which expects to close the socket. - * - * This routine is not expected to be user visible. - */ -_res_close() -{ - if (s != -1) { - (void) close(s); - s = -1; - } -} diff -ruN glibc-1.08.1/inet/resolv.h glibc-1.09/inet/resolv.h --- glibc-1.08.1/inet/resolv.h Wed May 19 15:49:48 1993 +++ glibc-1.09/inet/resolv.h Wed Dec 31 19:00:00 1969 @@ -1,174 +0,0 @@ -/* - * @(#)resolv.h 5.15 (Berkeley) 4/3/91 - * $Id: resolv.h,v 4.9.1.2 1993/05/17 09:59:01 vixie Exp $ - */ - -/* - * ++Copyright++ 1983, 1987, 1989 - * - - * Copyright (c) 1983, 1987, 1989 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - - * Portions Copyright (c) 1993 by Digital Equipment Corporation. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies, and that - * the name of Digital Equipment Corporation not be used in advertising or - * publicity pertaining to distribution of the document or software without - * specific, written prior permission. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL - * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT - * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - * - - * --Copyright-- - */ - -#ifndef _RESOLV_H_ -#define _RESOLV_H_ - -#include -#if (!defined(BSD)) || (BSD < 199306) -# include -#else -# include -#endif -#include -#include - -/* - * Resolver configuration file. - * Normally not present, but may contain the address of the - * inital name server(s) to query and the domain search list. - */ - -#ifndef _PATH_RESCONF -#define _PATH_RESCONF "/etc/resolv.conf" -#endif - -/* - * Global defines and variables for resolver stub. - */ -#define MAXNS 3 /* max # name servers we'll track */ -#define MAXDFLSRCH 3 /* # default domain levels to try */ -#define MAXDNSRCH 6 /* max # domains in search path */ -#define LOCALDOMAINPARTS 2 /* min levels in name that is "local" */ - -#define RES_TIMEOUT 5 /* min. seconds between retries */ - -/* this was "struct state" until 4.9 */ -struct __res_state { - int retrans; /* retransmition time interval */ - int retry; /* number of times to retransmit */ - u_int32_t options; /* option flags - see below. */ - int nscount; /* number of name servers */ - struct sockaddr_in nsaddr_list[MAXNS]; /* address of name server */ -#define nsaddr nsaddr_list[0] /* for backward compatibility */ - u_short id; /* current packet id */ - char *dnsrch[MAXDNSRCH+1]; /* components of domain to search */ - char defdname[MAXDNAME]; /* default domain */ - u_int32_t pfcode; /* RES_PRF_ flags - see below. */ -}; - -/* - * Resolver options (keep these in synch with res_debug.c, please) - */ -#define RES_INIT 0x0001 /* address initialized */ -#define RES_DEBUG 0x0002 /* print debug messages */ -#define RES_AAONLY 0x0004 /* authoritative answers only */ -#define RES_USEVC 0x0008 /* use virtual circuit */ -#define RES_PRIMARY 0x0010 /* query primary server only */ -#define RES_IGNTC 0x0020 /* ignore trucation errors */ -#define RES_RECURSE 0x0040 /* recursion desired */ -#define RES_DEFNAMES 0x0080 /* use default domain name */ -#define RES_STAYOPEN 0x0100 /* Keep TCP socket open */ -#define RES_DNSRCH 0x0200 /* search up local domain tree */ - -#define RES_DEFAULT (RES_RECURSE | RES_DEFNAMES | RES_DNSRCH) - -/* - * Resolver "pfcode" values. Used by dig. - */ -#define RES_PRF_STATS 0x0001 -/* 0x0002 */ -#define RES_PRF_CLASS 0x0004 -#define RES_PRF_CMD 0x0008 -#define RES_PRF_QUES 0x0010 -#define RES_PRF_ANS 0x0020 -#define RES_PRF_AUTH 0x0040 -#define RES_PRF_ADD 0x0080 -#define RES_PRF_HEAD1 0x0100 -#define RES_PRF_HEAD2 0x0200 -#define RES_PRF_TTLID 0x0400 -#define RES_PRF_HEADX 0x0800 -#define RES_PRF_QUERY 0x1000 -#define RES_PRF_REPLY 0x2000 -#define RES_PRF_INIT 0x4000 -/* 0x8000 */ - -extern struct __res_state _res; - -/* Private routines shared between libc/net, named, nslookup and others. */ -#define dn_skipname __dn_skipname -#define fp_query __fp_query -#define hostalias __hostalias -#define putlong __putlong -#define putshort __putshort -#define p_class __p_class -#define p_time __p_time -#define p_type __p_type -__BEGIN_DECLS -int __dn_skipname __P((const u_char *, const u_char *)); -void __fp_resstat __P((struct __res_state *, FILE *)); -void __fp_query __P((char *, FILE *)); -char *__hostalias __P((const char *)); -void __putlong __P((u_int32_t, u_char *)); -void __putshort __P((u_short, u_char *)); -char *__p_class __P((int)); -char *__p_time __P((u_int32_t)); -char *__p_type __P((int)); - -int dn_comp __P((const u_char *, u_char *, int, u_char **, u_char **)); -int dn_expand __P((const u_char *, const u_char *, const u_char *, - u_char *, int)); -int res_init __P((void)); -int res_mkquery __P((int, const char *, int, int, const char *, int, - const char *, char *, int)); -int res_send __P((const char *, int, char *, int)); -__END_DECLS - -#endif /* !_RESOLV_H_ */ diff -ruN glibc-1.08.1/inet/rexec.c glibc-1.09/inet/rexec.c --- glibc-1.08.1/inet/rexec.c Tue Nov 6 00:33:46 1990 +++ glibc-1.09/inet/rexec.c Sun Jul 31 15:04:20 1994 @@ -1,22 +1,38 @@ /* - * Copyright (c) 1980 Regents of the University of California. - * All rights reserved. + * Copyright (c) 1980, 1993 + * The Regents of the University of California. All rights reserved. * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by the University of California, Berkeley. The name of the - * University may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. */ #if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)rexec.c 5.5 (Berkeley) 6/27/88"; +static char sccsid[] = "@(#)rexec.c 8.1 (Berkeley) 6/4/93"; #endif /* LIBC_SCCS and not lint */ #include @@ -39,15 +55,15 @@ char *name, *pass, *cmd; int *fd2p; { - int s, timo = 1, s3; struct sockaddr_in sin, sin2, from; - char c; - short port; struct hostent *hp; + u_short port; + int s, timo = 1, s3; + char c; hp = gethostbyname(*ahost); if (hp == 0) { - fprintf(stderr, "%s: unknown host\n", *ahost); + herror(*ahost); return (-1); } *ahost = hp->h_name; @@ -61,7 +77,7 @@ sin.sin_family = hp->h_addrtype; sin.sin_port = rport; bcopy(hp->h_addr, (caddr_t)&sin.sin_addr, hp->h_length); - if (connect(s, &sin, sizeof(sin)) < 0) { + if (connect(s, (struct sockaddr *)&sin, sizeof(sin)) < 0) { if (errno == ECONNREFUSED && timo <= 16) { (void) close(s); sleep(timo); @@ -85,17 +101,17 @@ } listen(s2, 1); sin2len = sizeof (sin2); - if (getsockname(s2, (char *)&sin2, &sin2len) < 0 || + if (getsockname(s2, (struct sockaddr *)&sin2, &sin2len) < 0 || sin2len != sizeof (sin2)) { perror("getsockname"); (void) close(s2); goto bad; } port = ntohs((u_short)sin2.sin_port); - (void) sprintf(num, "%d", port); + (void) sprintf(num, "%u", port); (void) write(s, num, strlen(num)+1); { int len = sizeof (from); - s3 = accept(s2, &from, &len); + s3 = accept(s2, (struct sockaddr *)&from, &len); close(s2); if (s3 < 0) { perror("accept"); diff -ruN glibc-1.08.1/inet/sethostent.c glibc-1.09/inet/sethostent.c --- glibc-1.08.1/inet/sethostent.c Sun May 24 01:56:17 1992 +++ glibc-1.09/inet/sethostent.c Wed Dec 31 19:00:00 1969 @@ -1,56 +0,0 @@ -/* - * Copyright (c) 1985 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)sethostent.c 6.9 (Berkeley) 3/19/91"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include - -void -sethostent(stayopen) -{ - if (stayopen) - _res.options |= RES_STAYOPEN | RES_USEVC; -} - -void -endhostent() -{ - _res.options &= ~(RES_STAYOPEN | RES_USEVC); - _res_close(); -} diff -ruN glibc-1.08.1/inet/sys/bitypes.h glibc-1.09/inet/sys/bitypes.h --- glibc-1.08.1/inet/sys/bitypes.h Wed May 18 22:56:46 1994 +++ glibc-1.09/inet/sys/bitypes.h Wed Dec 31 19:00:00 1969 @@ -1,3 +0,0 @@ -/* The GNU defines all the necessary types. */ - -#include diff -ruN glibc-1.08.1/install.sh glibc-1.09/install.sh --- glibc-1.08.1/install.sh Wed Apr 27 15:12:14 1994 +++ glibc-1.09/install.sh Tue Sep 13 00:32:22 1994 @@ -3,7 +3,9 @@ # install - install a program, script, or datafile # This comes from X11R5. # -# $XConsortium: install.sh,v 1.2 89/12/18 14:47:22 jim Exp $ +# Calling this script install-sh is preferred over install.sh, to prevent +# `make' implicit rules from creating a file called install from it +# when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. diff -ruN glibc-1.08.1/limits.h glibc-1.09/limits.h --- glibc-1.08.1/limits.h Tue Dec 29 17:31:55 1992 +++ glibc-1.09/limits.h Fri Jul 22 12:54:56 1994 @@ -20,9 +20,6 @@ * ANSI Standard: 4.14/2.2.4.2 Limits of integral types */ -#ifndef _LIMITS_H - -#define _LIMITS_H 1 #include #ifdef __USE_POSIX @@ -38,13 +35,21 @@ #if __GNUC__ >= 2 /* Get the compiler's limits.h, which defines all the ANSI constants. */ + #ifndef _LIBC_LIMITS_H_ #define _LIBC_LIMITS_H_ /* This tells it not to look for another. */ + #endif #ifndef _GCC_LIMITS_H_ /* This is what GCC's file defines. */ #include_next #endif #else /* Not GCC 2. */ +/* We only protect from multiple inclusion here, because all the other + #include's protect themselves, and in GCC 2 we may #include_next through + multiple copies of this file before we get to GCC's. */ +#ifndef _LIMITS_H +#define _LIMITS_H + /* We don't have #include_next. Define ANSI for standard 32-bit words. */ @@ -103,7 +108,5 @@ /* Maximum value an `unsigned long int' can hold. (Minimum is 0.) */ #define ULONG_MAX UINT_MAX -#endif /* GCC 2. */ - - #endif /* limits.h */ +#endif /* GCC 2. */ diff -ruN glibc-1.08.1/locale/C-ctype_ct.c glibc-1.09/locale/C-ctype_ct.c --- glibc-1.08.1/locale/C-ctype_ct.c Thu Dec 2 15:48:15 1993 +++ glibc-1.09/locale/C-ctype_ct.c Mon Jul 18 18:00:48 1994 @@ -266,39 +266,39 @@ CONST short int __ctype_tolower_C[] = { -1, - '\000', - '\001', - '\002', - '\003', - '\004', - '\005', - '\006', - '\007', - '\010', - '\011', - '\012', - '\013', - '\014', - '\015', - '\016', - '\017', - '\020', - '\021', - '\022', - '\023', - '\024', - '\025', - '\026', - '\027', - '\030', - '\031', - '\032', - '\033', - '\034', - '\035', - '\036', - '\037', - '\040', + 0000, + 0001, + 0002, + 0003, + 0004, + 0005, + 0006, + 0007, + 0010, + 0011, + 0012, + 0013, + 0014, + 0015, + 0016, + 0017, + 0020, + 0021, + 0022, + 0023, + 0024, + 0025, + 0026, + 0027, + 0030, + 0031, + 0032, + 0033, + 0034, + 0035, + 0036, + 0037, + 0040, '!', '"', '#', @@ -393,172 +393,172 @@ '|', '}', '~', - '\177', - '\200', - '\201', - '\202', - '\203', - '\204', - '\205', - '\206', - '\207', - '\210', - '\211', - '\212', - '\213', - '\214', - '\215', - '\216', - '\217', - '\220', - '\221', - '\222', - '\223', - '\224', - '\225', - '\226', - '\227', - '\230', - '\231', - '\232', - '\233', - '\234', - '\235', - '\236', - '\237', - '\240', - '\241', - '\242', - '\243', - '\244', - '\245', - '\246', - '\247', - '\250', - '\251', - '\252', - '\253', - '\254', - '\255', - '\256', - '\257', - '\260', - '\261', - '\262', - '\263', - '\264', - '\265', - '\266', - '\267', - '\270', - '\271', - '\272', - '\273', - '\274', - '\275', - '\276', - '\277', - '\300', - '\301', - '\302', - '\303', - '\304', - '\305', - '\306', - '\307', - '\310', - '\311', - '\312', - '\313', - '\314', - '\315', - '\316', - '\317', - '\320', - '\321', - '\322', - '\323', - '\324', - '\325', - '\326', - '\327', - '\330', - '\331', - '\332', - '\333', - '\334', - '\335', - '\336', - '\337', - '\340', - '\341', - '\342', - '\343', - '\344', - '\345', - '\346', - '\347', - '\350', - '\351', - '\352', - '\353', - '\354', - '\355', - '\356', - '\357', - '\360', - '\361', - '\362', - '\363', - '\364', - '\365', - '\366', - '\367', - '\370', - '\371', - '\372', - '\373', - '\374', - '\375', - '\376', - '\377', + 0177, + 0200, + 0201, + 0202, + 0203, + 0204, + 0205, + 0206, + 0207, + 0210, + 0211, + 0212, + 0213, + 0214, + 0215, + 0216, + 0217, + 0220, + 0221, + 0222, + 0223, + 0224, + 0225, + 0226, + 0227, + 0230, + 0231, + 0232, + 0233, + 0234, + 0235, + 0236, + 0237, + 0240, + 0241, + 0242, + 0243, + 0244, + 0245, + 0246, + 0247, + 0250, + 0251, + 0252, + 0253, + 0254, + 0255, + 0256, + 0257, + 0260, + 0261, + 0262, + 0263, + 0264, + 0265, + 0266, + 0267, + 0270, + 0271, + 0272, + 0273, + 0274, + 0275, + 0276, + 0277, + 0300, + 0301, + 0302, + 0303, + 0304, + 0305, + 0306, + 0307, + 0310, + 0311, + 0312, + 0313, + 0314, + 0315, + 0316, + 0317, + 0320, + 0321, + 0322, + 0323, + 0324, + 0325, + 0326, + 0327, + 0330, + 0331, + 0332, + 0333, + 0334, + 0335, + 0336, + 0337, + 0340, + 0341, + 0342, + 0343, + 0344, + 0345, + 0346, + 0347, + 0350, + 0351, + 0352, + 0353, + 0354, + 0355, + 0356, + 0357, + 0360, + 0361, + 0362, + 0363, + 0364, + 0365, + 0366, + 0367, + 0370, + 0371, + 0372, + 0373, + 0374, + 0375, + 0376, + 0377, }; CONST short int __ctype_toupper_C[] = { -1, - '\000', - '\001', - '\002', - '\003', - '\004', - '\005', - '\006', - '\007', - '\010', - '\011', - '\012', - '\013', - '\014', - '\015', - '\016', - '\017', - '\020', - '\021', - '\022', - '\023', - '\024', - '\025', - '\026', - '\027', - '\030', - '\031', - '\032', - '\033', - '\034', - '\035', - '\036', - '\037', - '\040', + 0000, + 0001, + 0002, + 0003, + 0004, + 0005, + 0006, + 0007, + 0010, + 0011, + 0012, + 0013, + 0014, + 0015, + 0016, + 0017, + 0020, + 0021, + 0022, + 0023, + 0024, + 0025, + 0026, + 0027, + 0030, + 0031, + 0032, + 0033, + 0034, + 0035, + 0036, + 0037, + 0040, '!', '"', '#', @@ -653,135 +653,135 @@ '|', '}', '~', - '\177', - '\200', - '\201', - '\202', - '\203', - '\204', - '\205', - '\206', - '\207', - '\210', - '\211', - '\212', - '\213', - '\214', - '\215', - '\216', - '\217', - '\220', - '\221', - '\222', - '\223', - '\224', - '\225', - '\226', - '\227', - '\230', - '\231', - '\232', - '\233', - '\234', - '\235', - '\236', - '\237', - '\240', - '\241', - '\242', - '\243', - '\244', - '\245', - '\246', - '\247', - '\250', - '\251', - '\252', - '\253', - '\254', - '\255', - '\256', - '\257', - '\260', - '\261', - '\262', - '\263', - '\264', - '\265', - '\266', - '\267', - '\270', - '\271', - '\272', - '\273', - '\274', - '\275', - '\276', - '\277', - '\300', - '\301', - '\302', - '\303', - '\304', - '\305', - '\306', - '\307', - '\310', - '\311', - '\312', - '\313', - '\314', - '\315', - '\316', - '\317', - '\320', - '\321', - '\322', - '\323', - '\324', - '\325', - '\326', - '\327', - '\330', - '\331', - '\332', - '\333', - '\334', - '\335', - '\336', - '\337', - '\340', - '\341', - '\342', - '\343', - '\344', - '\345', - '\346', - '\347', - '\350', - '\351', - '\352', - '\353', - '\354', - '\355', - '\356', - '\357', - '\360', - '\361', - '\362', - '\363', - '\364', - '\365', - '\366', - '\367', - '\370', - '\371', - '\372', - '\373', - '\374', - '\375', - '\376', - '\377', + 0177, + 0200, + 0201, + 0202, + 0203, + 0204, + 0205, + 0206, + 0207, + 0210, + 0211, + 0212, + 0213, + 0214, + 0215, + 0216, + 0217, + 0220, + 0221, + 0222, + 0223, + 0224, + 0225, + 0226, + 0227, + 0230, + 0231, + 0232, + 0233, + 0234, + 0235, + 0236, + 0237, + 0240, + 0241, + 0242, + 0243, + 0244, + 0245, + 0246, + 0247, + 0250, + 0251, + 0252, + 0253, + 0254, + 0255, + 0256, + 0257, + 0260, + 0261, + 0262, + 0263, + 0264, + 0265, + 0266, + 0267, + 0270, + 0271, + 0272, + 0273, + 0274, + 0275, + 0276, + 0277, + 0300, + 0301, + 0302, + 0303, + 0304, + 0305, + 0306, + 0307, + 0310, + 0311, + 0312, + 0313, + 0314, + 0315, + 0316, + 0317, + 0320, + 0321, + 0322, + 0323, + 0324, + 0325, + 0326, + 0327, + 0330, + 0331, + 0332, + 0333, + 0334, + 0335, + 0336, + 0337, + 0340, + 0341, + 0342, + 0343, + 0344, + 0345, + 0346, + 0347, + 0350, + 0351, + 0352, + 0353, + 0354, + 0355, + 0356, + 0357, + 0360, + 0361, + 0362, + 0363, + 0364, + 0365, + 0366, + 0367, + 0370, + 0371, + 0372, + 0373, + 0374, + 0375, + 0376, + 0377, }; diff -ruN glibc-1.08.1/mach/Machrules glibc-1.09/mach/Machrules --- glibc-1.08.1/mach/Machrules Wed Apr 27 06:45:23 1994 +++ glibc-1.09/mach/Machrules Tue Jul 19 17:51:29 1994 @@ -88,7 +88,8 @@ # intermediate in order to make %.ir and then removed before re-exec, when # %.uh is built all over again to build %.h. $(objpfx)%.ir: $(objpfx)%.uh $(objpfx)%.h - (awk "/^kern_return_t/ { printf \"$*-calls += %s\\n\", \$$2 } \ + (awk "NF == 4 && (\$$2 == \"Routine\" || \$$2 == \"SimpleRoutine\")\ + { printf \"$*-calls += %s\\n\", \$$3 } \ /^#include/ { printf \"$*-imports += %s\\n\", \$$2 }" $< ;\ echo '$$($*-calls:%=$$(objpfx)R\%C_%.c): $$(objpfx)$*.ustamp ;';\ echo '$$($*-calls:%=$$(objpfx)RPC_%.o): $$($*-imports:<%>=%)' ;\ @@ -96,13 +97,19 @@ mv $@-new $@ vpath Machrules ../mach # Find ourselves. +ifndef transform-user-stub-output +transform-user-stub-output = tmp +endif + # Not an implicit rule so the stamps are never removed as intermediates! $(patsubst %,$(objpfx)%.ustamp,$(user-interfaces)): $(objpfx)%.ustamp: %.defs $(MIG) $< $(MIGFLAGS) $(user-MIGFLAGS) \ -prefix __ -i $(objpfx)tmp_ \ -server /dev/null -user /dev/null -header /dev/null for call in $($*-calls); do \ - ../move-if-change $(objpfx)tmp_$${call}.c $(objpfx)RPC_$${call}.c; \ + $(transform-user-stub) \ + ../move-if-change $(objpfx)$(transform-user-stub-output)_$${call}.c \ + $(objpfx)RPC_$${call}.c; \ done touch $@ diff -ruN glibc-1.08.1/mach/Makefile glibc-1.09/mach/Makefile --- glibc-1.08.1/mach/Makefile Mon Jun 6 12:41:45 1994 +++ glibc-1.09/mach/Makefile Tue Nov 1 06:34:18 1994 @@ -45,7 +45,7 @@ user-interfaces := $(addprefix mach/,mach_interface mach_port mach_host \ memory_object_user \ memory_object_default \ - exc \ + exc mach4 \ )\ $(addprefix device/,device device_request) server-interfaces := device/device_reply mach/exc mach/notify @@ -57,14 +57,6 @@ errorlib.h err_*.sub -# XXX You should copy these files from mk/bootstrap and uncomment these lines. -ifneq (,) # like #if 0 in C -headers += $(addprefix mach/default_pager_types.,h defs) \ - mach/default_pager.defs mach/default_pager_helper.defs -user-interfaces += mach/default_pager -server-interfaces += mach/default_pager_helper -endif # end of commented-out - # Clear any environment value. generated = @@ -115,7 +107,7 @@ $(objpfx)mach-syscalls.mk: mach/syscall_sw.h syscalls.awk # Go kludges!!! sed -n -e '/Unix server implement them/,$$d' \ - -e 's/^kernel_trap(\(.*\),\([-0-9]*\),[0-9]*)$$/\1 \2/p' \ + -e 's/^kernel_trap(\(.*\),\([-0-9]*\),\([0-9]*\))$$/\1 \2 \3/p'\ < $< | awk -f $(word 2,$^) > $@-new mv $@-new $@ generated += mach-syscalls.mk @@ -127,7 +119,7 @@ else $(mach-syscalls:%=$(objpfx)__%.S): $(objpfx)__%.S: $(objpfx)mach-syscalls.mk (echo '#include '; \ - echo 'SYSCALL_TRAP (__$*, $(sysno-$*))') > $@-new + echo 'kernel_trap(__$*,$(sysno-$*),$(nargs-$*))') > $@-new mv $@-new $@ $(mach-syscalls:%=$(objpfx)%.c): $(objpfx)%.c: Makefile (echo '#include '; \ @@ -137,14 +129,17 @@ $(mach-syscalls:%=%.c) endif # mach-syscalls -mach-shortcuts := $(patsubst syscall_%,%,$(filter syscall_%,$(mach-syscalls))) +# syscall_device_writev_request has no RPC equivalent. +mach-shortcuts := $(filter-out device_writev_request,\ + $(patsubst syscall_%,%,$(filter syscall_%,$(mach-syscalls)))) ifndef mach-shortcuts # Forget about mach_interface.defs for this run. On the next run, # $(mach-shortcuts) will be set, and that will change how # mach_interface.defs is processed: it will get the -D flags below. user-interfaces := $(filter-out mach/mach_interface \ - mach/mach_port mach/mach_host,\ + mach/mach_port mach/mach_host \ + device/device_request,\ $(user-interfaces)) endif @@ -166,7 +161,7 @@ (echo '#include '; \ echo 'symbol_alias (__$*, $*);') > $@-new mv $@-new $@ -generated += $(mach-shortcuts:%=%.c) +generated += $(mach-shortcuts:%=%.c) $(mach-shortcuts:%=__%.c) endif # mach-shortcuts # Generate mach-shortcuts.h, which will contain the prototypes for the diff -ruN glibc-1.08.1/mach/__msg_dest.c glibc-1.09/mach/__msg_dest.c --- glibc-1.08.1/mach/__msg_dest.c Tue Aug 3 02:13:18 1993 +++ glibc-1.09/mach/__msg_dest.c Mon Jul 18 18:16:00 1994 @@ -25,7 +25,10 @@ */ /* * HISTORY - * $Log: mach_msg_destroy.c,v $ + * $Log: __msg_dest.c,v $ + * Revision 1.2 1993/08/03 06:13:18 roland + * entered into RCS + * * Revision 2.4 91/05/14 17:53:15 mrt * Correcting copyright * diff -ruN glibc-1.08.1/mach/__msgserver.c glibc-1.09/mach/__msgserver.c --- glibc-1.08.1/mach/__msgserver.c Mon Dec 6 18:25:25 1993 +++ glibc-1.09/mach/__msgserver.c Mon Oct 10 03:20:16 1994 @@ -1,4 +1,4 @@ -/* Copyright (C) 1993 Free Software Foundation, Inc. +/* Copyright (C) 1993, 1994 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -48,7 +48,13 @@ */ /* * HISTORY - * $Log: mach_msg_server.c,v $ + * $Log: __msgserver.c,v $ + * Revision 1.2 1994/10/10 07:20:14 roland + * Increase default MAX_SIZE to two pages. + * + * Revision 1.1 1993/12/06 23:25:25 roland + * entered into RCS + * * Revision 2.4 91/05/14 17:53:22 mrt * Correcting copyright * @@ -80,7 +86,7 @@ if (max_size == 0) { option |= MACH_RCV_LARGE; - max_size = __vm_page_size; /* Generic. Good? XXX */ + max_size = 2 * __vm_page_size; /* Generic. Good? XXX */ } request = __alloca (max_size); diff -ruN glibc-1.08.1/mach/devstream.c glibc-1.09/mach/devstream.c --- glibc-1.08.1/mach/devstream.c Mon May 23 22:57:40 1994 +++ glibc-1.09/mach/devstream.c Fri Oct 28 21:38:51 1994 @@ -48,8 +48,10 @@ f->__eof = 0; nread = to_read; - if (err = device_read_inband ((device_t) f->__cookie, 0, f->__target, - to_read, buffer, &nread)) + err = device_read_inband ((device_t) f->__cookie, 0, f->__target, + to_read, buffer, &nread); + + if (err) { f->__error = 1; f->__bufp = f->__get_limit = f->__put_limit = f->__buffer; @@ -57,6 +59,10 @@ return EOF; } + /* Echo it back. */ + err = device_write_inband ((device_t) f->__cookie, 0, f->__target, + buffer, nread, (int *) &to_read); + if (f->__buffer == NULL) return (unsigned char) c; @@ -67,6 +73,7 @@ } +#if 0 static void output (FILE *f, int c) { @@ -123,10 +130,9 @@ *f->__bufp++ = (unsigned char) c; } } +#endif - -#if 0 /* Translates \n to \r\n. */ static void output (FILE *f, int c) { @@ -216,18 +222,40 @@ *f->__bufp++ = (unsigned char) c; } } -#endif + +static int +dealloc_ref (void *cookie) +{ + if (mach_port_deallocate (mach_task_self (), (mach_port_t) cookie)) + { + errno = EINVAL; + return -1; + } + return 0; +} + FILE * mach_open_devstream (mach_port_t dev, const char *mode) { - FILE *stream = fopencookie ((void *) dev, mode, __default_io_functions); + FILE *stream; + + if (mach_port_mod_refs (mach_task_self (), dev, MACH_PORT_RIGHT_SEND, 1)) + { + errno = EINVAL; + return NULL; + } + + stream = fopencookie ((void *) dev, mode, __default_io_functions); if (stream == NULL) - return NULL; + { + mach_port_deallocate (mach_task_self (), dev); + return NULL; + } stream->__room_funcs.__input = input; stream->__room_funcs.__output = output; - stream->__io_funcs.__close = (__io_close_fn *) device_close; + stream->__io_funcs.__close = dealloc_ref; stream->__io_funcs.__seek = NULL; /* Cannot seek. */ stream->__io_funcs.__fileno = NULL; /* No corresponding POSIX.1 fd. */ stream->__seen = 1; diff -ruN glibc-1.08.1/mach/err_boot.sub glibc-1.09/mach/err_boot.sub --- glibc-1.08.1/mach/err_boot.sub Tue Oct 6 14:29:52 1992 +++ glibc-1.09/mach/err_boot.sub Mon Jul 18 18:16:02 1994 @@ -25,7 +25,10 @@ */ /* * HISTORY - * $Log: err_bootstrap.sub,v $ + * $Log: err_boot.sub,v $ +# Revision 1.1 1992/10/06 18:29:52 roland +# entered into RCS +# * Revision 2.2 92/04/01 19:37:59 rpd * Created. * [92/03/09 rpd] diff -ruN glibc-1.08.1/mach/err_ipc.sub glibc-1.09/mach/err_ipc.sub --- glibc-1.08.1/mach/err_ipc.sub Tue Oct 6 14:29:52 1992 +++ glibc-1.09/mach/err_ipc.sub Mon Jul 18 18:16:02 1994 @@ -25,7 +25,10 @@ */ /* * HISTORY - * $Log: err_ipc.sub,v $ + * $Log: err_ipc.sub,v $ +# Revision 1.1 1992/10/06 18:29:52 roland +# entered into RCS +# * Revision 2.2 92/01/16 00:08:40 rpd * Moved from user collection to mk collection. * diff -ruN glibc-1.08.1/mach/err_kern.sub glibc-1.09/mach/err_kern.sub --- glibc-1.08.1/mach/err_kern.sub Fri Dec 17 01:14:52 1993 +++ glibc-1.09/mach/err_kern.sub Mon Jul 18 18:16:03 1994 @@ -25,7 +25,10 @@ */ /* * HISTORY - * $Log: err_kern.sub,v $ + * $Log: err_kern.sub,v $ +# Revision 1.4 1993/12/17 06:14:52 mib +# entered into RCS +# * Revision 2.3 92/04/01 19:38:02 rpd * Added err_codes_device. * [92/03/09 rpd] diff -ruN glibc-1.08.1/mach/err_mach.sub glibc-1.09/mach/err_mach.sub --- glibc-1.08.1/mach/err_mach.sub Tue Oct 6 14:29:52 1992 +++ glibc-1.09/mach/err_mach.sub Mon Jul 18 18:16:03 1994 @@ -25,7 +25,10 @@ */ /* * HISTORY - * $Log: err_mach_ipc.sub,v $ + * $Log: err_mach.sub,v $ +# Revision 1.1 1992/10/06 18:29:52 roland +# entered into RCS +# * Revision 2.3 92/04/01 19:38:05 rpd * Added MIG_DESTROY_REQUEST. * [92/03/09 rpd] diff -ruN glibc-1.08.1/mach/err_server.sub glibc-1.09/mach/err_server.sub --- glibc-1.08.1/mach/err_server.sub Tue Oct 6 14:29:53 1992 +++ glibc-1.09/mach/err_server.sub Mon Jul 18 18:16:04 1994 @@ -25,7 +25,10 @@ */ /* * HISTORY - * $Log: err_server.sub,v $ + * $Log: err_server.sub,v $ +# Revision 1.1 1992/10/06 18:29:53 roland +# entered into RCS +# * Revision 2.2 92/01/16 00:10:29 rpd * Moved from user collection to mk collection. * diff -ruN glibc-1.08.1/mach/err_us.sub glibc-1.09/mach/err_us.sub --- glibc-1.08.1/mach/err_us.sub Tue Nov 23 16:14:05 1993 +++ glibc-1.09/mach/err_us.sub Mon Jul 18 18:16:04 1994 @@ -25,7 +25,10 @@ */ /* * HISTORY - * $Log: err_us.sub,v $ + * $Log: err_us.sub,v $ +# Revision 1.2 1993/11/23 21:14:05 mib +# entered into RCS +# * Revision 2.2 92/01/16 00:10:45 rpd * Moved from user collection to mk collection. * diff -ruN glibc-1.08.1/mach/error_compat.c glibc-1.09/mach/error_compat.c --- glibc-1.08.1/mach/error_compat.c Tue Nov 30 12:35:24 1993 +++ glibc-1.09/mach/error_compat.c Mon Jul 18 18:16:05 1994 @@ -25,7 +25,10 @@ */ /* This file was broken out from: - $Log: mach_error_string.c,v $ + $Log: error_compat.c,v $ + * Revision 1.1 1993/11/30 17:35:24 roland + * entered into RCS + * Revision 2.3 92/04/01 19:38:18 rpd The static do_compat function is renamed to be globally accessible. */ diff -ruN glibc-1.08.1/mach/errorlib.h glibc-1.09/mach/errorlib.h --- glibc-1.08.1/mach/errorlib.h Fri Dec 17 16:56:16 1993 +++ glibc-1.09/mach/errorlib.h Mon Jul 18 18:16:06 1994 @@ -25,7 +25,10 @@ */ /* * HISTORY - * $Log: errorlib.h,v $ + * $Log: errorlib.h,v $ + * Revision 1.4 1993/12/17 21:56:16 roland + * entered into RCS + * * Revision 2.3 92/03/31 15:18:52 rpd * Added KERN_DEVICE_MOD for device errors. * [92/03/09 rpd] diff -ruN glibc-1.08.1/mach/errstring.c glibc-1.09/mach/errstring.c --- glibc-1.08.1/mach/errstring.c Tue Nov 30 12:35:58 1993 +++ glibc-1.09/mach/errstring.c Mon Jul 18 18:16:08 1994 @@ -25,7 +25,10 @@ */ /* * HISTORY - * $Log: mach_error_string.c,v $ + * $Log: errstring.c,v $ + * Revision 1.1 1993/11/30 17:35:58 roland + * entered into RCS + * * Revision 2.3 92/04/01 19:38:18 rpd * Updated do_compat for kernel device errors, * bootstrap file-system errors. diff -ruN glibc-1.08.1/mach/mach/error.h glibc-1.09/mach/mach/error.h --- glibc-1.08.1/mach/mach/error.h Fri Dec 17 16:40:28 1993 +++ glibc-1.09/mach/mach/error.h Mon Jul 18 18:15:56 1994 @@ -26,7 +26,10 @@ */ /* * HISTORY - * $Log: error.h,v $ + * $Log: error.h,v $ + * Revision 1.1 1993/12/17 21:40:28 roland + * entered into RCS + * * Revision 2.6 93/01/14 17:41:31 danner * Standardized include symbol name. * [92/06/10 pds] diff -ruN glibc-1.08.1/mach/mach/mig_support.h glibc-1.09/mach/mach/mig_support.h --- glibc-1.08.1/mach/mach/mig_support.h Sat Oct 30 15:12:11 1993 +++ glibc-1.09/mach/mach/mig_support.h Thu Sep 15 14:23:12 1994 @@ -1,4 +1,4 @@ -/* Copyright (C) 1993 Free Software Foundation, Inc. +/* Copyright (C) 1993, 1994 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -39,10 +39,13 @@ extern void mig_deallocate (vm_address_t __addr, vm_size_t __size); /* Reply-port management support functions. */ -extern void __mig_dealloc_reply_port (void); -extern void mig_dealloc_reply_port (void); +extern void __mig_dealloc_reply_port (mach_port_t); +extern void mig_dealloc_reply_port (mach_port_t); extern mach_port_t __mig_get_reply_port (void); extern mach_port_t mig_get_reply_port (void); +extern void __mig_put_reply_port (mach_port_t); +extern void mig_put_reply_port (mach_port_t); + extern void __mig_reply_setup (const mach_msg_header_t *__request, mach_msg_header_t *__reply); extern void mig_reply_setup (const mach_msg_header_t *__request, diff -ruN glibc-1.08.1/mach/mach_error.c glibc-1.09/mach/mach_error.c --- glibc-1.08.1/mach/mach_error.c Tue Oct 6 14:29:54 1992 +++ glibc-1.09/mach/mach_error.c Mon Jul 18 18:16:10 1994 @@ -25,7 +25,10 @@ */ /* * HISTORY - * $Log: mach_error.c,v $ + * $Log: mach_error.c,v $ + * Revision 1.1 1992/10/06 18:29:54 roland + * entered into RCS + * * Revision 2.4 92/02/19 15:10:52 elf * Moved mach_error_string and mach_error_type to mach_error_string.c. * [92/02/11 rpd] diff -ruN glibc-1.08.1/mach/mach_error.h glibc-1.09/mach/mach_error.h --- glibc-1.08.1/mach/mach_error.h Tue Nov 23 15:39:08 1993 +++ glibc-1.09/mach/mach_error.h Mon Jul 18 18:16:11 1994 @@ -25,7 +25,10 @@ */ /* * HISTORY - * $Log: mach_error.h,v $ + * $Log: mach_error.h,v $ + * Revision 1.2 1993/11/23 20:39:08 mib + * entered into RCS + * * Revision 2.2 92/01/16 00:08:10 rpd * Moved from user collection to mk collection. * diff -ruN glibc-1.08.1/mach/mach_init.h glibc-1.09/mach/mach_init.h --- glibc-1.08.1/mach/mach_init.h Wed Mar 17 19:19:32 1993 +++ glibc-1.09/mach/mach_init.h Wed Aug 17 21:45:38 1994 @@ -1,5 +1,5 @@ /* Declarations and macros for the basic Mach things set at startup. -Copyright (C) 1993 Free Software Foundation, Inc. +Copyright (C) 1993, 1994 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -35,7 +35,6 @@ /* Kernel page size. */ extern vm_size_t __vm_page_size; extern vm_size_t vm_page_size; -#define vm_page_size __vm_page_size /* XXX ? */ /* Round the address X up to a page boundary. */ #define round_page(x) \ diff -ruN glibc-1.08.1/mach/mig_syms.c glibc-1.09/mach/mig_syms.c --- glibc-1.08.1/mach/mig_syms.c Sun May 1 19:38:57 1994 +++ glibc-1.09/mach/mig_syms.c Thu Sep 29 18:26:56 1994 @@ -6,4 +6,5 @@ symbol_alias (__mig_init, mig_init); symbol_alias (__mig_get_reply_port, mig_get_reply_port); +symbol_alias (__mig_put_reply_port, mig_put_reply_port); symbol_alias (__mig_dealloc_reply_port, mig_dealloc_reply_port); diff -ruN glibc-1.08.1/mach/setup-thread.c glibc-1.09/mach/setup-thread.c --- glibc-1.08.1/mach/setup-thread.c Wed Apr 27 02:36:49 1994 +++ glibc-1.09/mach/setup-thread.c Sat Sep 3 23:40:15 1994 @@ -74,7 +74,7 @@ *stack_size = size; memset (&ts, 0, sizeof (ts)); - ts.PC = (int) pc; + MACHINE_THREAD_STATE_SET_PC (&ts, pc); #ifdef STACK_GROWTH_DOWN if (stack_base) *stack_base = stack + __vm_page_size; diff -ruN glibc-1.08.1/mach/syscalls.awk glibc-1.09/mach/syscalls.awk --- glibc-1.08.1/mach/syscalls.awk Thu Apr 2 22:08:11 1992 +++ glibc-1.09/mach/syscalls.awk Mon Jul 18 18:16:19 1994 @@ -3,6 +3,7 @@ { calls = calls " " $1; print "sysno-" $1 " = " $2; + print "nargs-" $1 " = " $3; } END { print "mach-syscalls := " calls } diff -ruN glibc-1.08.1/malloc/Makefile glibc-1.09/malloc/Makefile --- glibc-1.08.1/malloc/Makefile Tue May 3 23:33:51 1994 +++ glibc-1.09/malloc/Makefile Mon Sep 5 23:53:28 1994 @@ -87,11 +87,11 @@ $(addsuffix .c,$(dist-routines))) $(MAKE) -C malloc gmalloc.c malloc/README: dist-README - @rm -f $@ - cp $< $@ + cp -f $< $@ +malloc/%: ../sysdeps/generic/% + cp -f $< $@ malloc/%: % - @rm -f $@ - cp $< $@ + cp -f $< $@ include ../Rules diff -ruN glibc-1.08.1/malloc/calloc.c glibc-1.09/malloc/calloc.c --- glibc-1.08.1/malloc/calloc.c Thu Jun 25 21:07:05 1992 +++ glibc-1.09/malloc/calloc.c Mon Sep 5 23:22:05 1994 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1992 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1992, 1994 Free Software Foundation, Inc. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as @@ -27,8 +27,8 @@ The entire array is initialized to zeros. */ __ptr_t calloc (nmemb, size) - register size_t nmemb; - register size_t size; + register __malloc_size_t nmemb; + register __malloc_size_t size; { register __ptr_t result = malloc (nmemb * size); diff -ruN glibc-1.08.1/malloc/free.c glibc-1.09/malloc/free.c --- glibc-1.08.1/malloc/free.c Wed Aug 26 18:16:39 1992 +++ glibc-1.09/malloc/free.c Sat Sep 24 13:02:52 1994 @@ -1,5 +1,5 @@ /* Free a block of memory allocated by `malloc'. - Copyright 1990, 1991, 1992 Free Software Foundation + Copyright 1990, 1991, 1992, 1994 Free Software Foundation, Inc. Written May 1989 by Mike Haertel. This library is free software; you can redistribute it and/or @@ -38,8 +38,8 @@ __ptr_t ptr; { int type; - size_t block, blocks; - register size_t i; + __malloc_size_t block, blocks; + register __malloc_size_t i; struct list *prev, *next; block = BLOCK (ptr); @@ -104,7 +104,7 @@ if (blocks >= FINAL_FREE_BLOCKS && block + blocks == _heaplimit && (*__morecore) (0) == ADDRESS (block + blocks)) { - register size_t bytes = blocks * BLOCKSIZE; + register __malloc_size_t bytes = blocks * BLOCKSIZE; _heaplimit -= blocks; (*__morecore) (-bytes); _heapinfo[_heapinfo[block].free.prev].free.next @@ -136,7 +136,7 @@ /* If all fragments of this block are free, remove them from the fragment list and free the whole block. */ next = prev; - for (i = 1; i < (size_t) (BLOCKSIZE >> type); ++i) + for (i = 1; i < (__malloc_size_t) (BLOCKSIZE >> type); ++i) next = next->next; prev->prev->next = next; if (next != NULL) diff -ruN glibc-1.08.1/malloc/getpagesize.h glibc-1.09/malloc/getpagesize.h --- glibc-1.08.1/malloc/getpagesize.h Fri Jul 30 18:30:50 1993 +++ glibc-1.09/malloc/getpagesize.h Fri Nov 4 11:29:59 1994 @@ -27,6 +27,10 @@ #else /* no NBPG */ #ifdef NBPC #define getpagesize() NBPC +#else /* no NBPC */ +#ifdef PAGESIZE +#define getpagesize() PAGESIZE +#endif #endif /* NBPC */ #endif /* no NBPG */ #endif /* no EXEC_PAGESIZE */ diff -ruN glibc-1.08.1/malloc/malloc.c glibc-1.09/malloc/malloc.c --- glibc-1.08.1/malloc/malloc.c Thu Apr 21 16:54:45 1994 +++ glibc-1.09/malloc/malloc.c Sat Sep 24 13:04:03 1994 @@ -1,5 +1,5 @@ /* Memory allocator `malloc'. - Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation + Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc. Written May 1989 by Mike Haertel. This library is free software; you can redistribute it and/or @@ -29,7 +29,7 @@ __ptr_t (*__morecore) __P ((ptrdiff_t __size)) = __default_morecore; /* Debugging hook for `malloc'. */ -__ptr_t (*__malloc_hook) __P ((size_t __size)); +__ptr_t (*__malloc_hook) __P ((__malloc_size_t __size)); /* Pointer to the base of the first block. */ char *_heapbase; @@ -38,22 +38,22 @@ malloc_info *_heapinfo; /* Number of info entries. */ -static size_t heapsize; +static __malloc_size_t heapsize; /* Search index in the info table. */ -size_t _heapindex; +__malloc_size_t _heapindex; /* Limit of valid info table indices. */ -size_t _heaplimit; +__malloc_size_t _heaplimit; /* Free lists for each fragment size. */ struct list _fraghead[BLOCKLOG]; /* Instrumentation. */ -size_t _chunks_used; -size_t _bytes_used; -size_t _chunks_free; -size_t _bytes_free; +__malloc_size_t _chunks_used; +__malloc_size_t _bytes_used; +__malloc_size_t _chunks_free; +__malloc_size_t _bytes_free; /* Are you experienced? */ int __malloc_initialized; @@ -61,10 +61,10 @@ void (*__after_morecore_hook) __P ((void)); /* Aligned allocation. */ -static __ptr_t align __P ((size_t)); +static __ptr_t align __P ((__malloc_size_t)); static __ptr_t align (size) - size_t size; + __malloc_size_t size; { __ptr_t result; unsigned long int adj; @@ -110,24 +110,24 @@ /* Get neatly aligned memory, initializing or growing the heap info table as necessary. */ -static __ptr_t morecore __P ((size_t)); +static __ptr_t morecore __P ((__malloc_size_t)); static __ptr_t morecore (size) - size_t size; + __malloc_size_t size; { __ptr_t result; malloc_info *newinfo, *oldinfo; - size_t newsize; + __malloc_size_t newsize; result = align (size); if (result == NULL) return NULL; /* Check if we need to grow the info table. */ - if ((size_t) BLOCK ((char *) result + size) > heapsize) + if ((__malloc_size_t) BLOCK ((char *) result + size) > heapsize) { newsize = heapsize; - while ((size_t) BLOCK ((char *) result + size) > newsize) + while ((__malloc_size_t) BLOCK ((char *) result + size) > newsize) newsize *= 2; newinfo = (malloc_info *) align (newsize * sizeof (malloc_info)); if (newinfo == NULL) @@ -157,11 +157,11 @@ /* Allocate memory from the heap. */ __ptr_t malloc (size) - size_t size; + __malloc_size_t size; { __ptr_t result; - size_t block, blocks, lastblocks, start; - register size_t i; + __malloc_size_t block, blocks, lastblocks, start; + register __malloc_size_t i; struct list *next; /* ANSI C allows `malloc (0)' to either return NULL, or to return a @@ -196,7 +196,7 @@ { /* Small allocation to receive a fragment of a block. Determine the logarithm to base two of the fragment size. */ - register size_t log = 1; + register __malloc_size_t log = 1; --size; while ((size /= 2) != 0) ++log; @@ -234,7 +234,7 @@ return NULL; /* Link all fragments but the first into the free list. */ - for (i = 1; i < (size_t) (BLOCKSIZE >> log); ++i) + for (i = 1; i < (__malloc_size_t) (BLOCKSIZE >> log); ++i) { next = (struct list *) ((char *) result + (i << log)); next->next = _fraghead[log].next; @@ -342,7 +342,7 @@ __ptr_t _malloc (size) - size_t size; + __malloc_size_t size; { return malloc (size); } @@ -357,7 +357,7 @@ __ptr_t _realloc (ptr, size) __ptr_t ptr; - size_t size; + __malloc_size_t size; { return realloc (ptr, size); } diff -ruN glibc-1.08.1/malloc/malloc.h glibc-1.09/malloc/malloc.h --- glibc-1.08.1/malloc/malloc.h Tue May 3 19:24:20 1994 +++ glibc-1.09/malloc/malloc.h Mon Oct 31 06:59:41 1994 @@ -41,11 +41,13 @@ #endif #endif -#if defined(__GNU_LIBRARY__) || defined(__STDC__) +#if defined (__GNU_LIBRARY__) || (defined (__STDC__) && __STDC__) #include #else +#ifndef CHAR_BIT #define CHAR_BIT 8 #endif +#endif #ifdef HAVE_UNISTD_H #include @@ -73,13 +75,11 @@ #define __ptr_t char * #endif /* C++ or ANSI C. */ -#ifdef __STDC__ +#if defined (__STDC__) && __STDC__ #include +#define __malloc_size_t size_t #else -#undef size_t -#define size_t unsigned int -#undef ptrdiff_t -#define ptrdiff_t int +#define __malloc_size_t unsigned int #endif #ifndef NULL @@ -137,20 +137,20 @@ { struct { - size_t nfree; /* Free fragments in a fragmented block. */ - size_t first; /* First free fragment of the block. */ + __malloc_size_t nfree; /* Free frags in a fragmented block. */ + __malloc_size_t first; /* First free fragment of the block. */ } frag; /* Size (in blocks) of a large cluster. */ - size_t size; + __malloc_size_t size; } info; } busy; /* Heap information for a free block (that may be the first of a free cluster). */ struct { - size_t size; /* Size (in blocks) of a free cluster. */ - size_t next; /* Index of next free cluster. */ - size_t prev; /* Index of previous free cluster. */ + __malloc_size_t size; /* Size (in blocks) of a free cluster. */ + __malloc_size_t next; /* Index of next free cluster. */ + __malloc_size_t prev; /* Index of previous free cluster. */ } free; } malloc_info; @@ -165,10 +165,10 @@ #define ADDRESS(B) ((__ptr_t) (((B) - 1) * BLOCKSIZE + _heapbase)) /* Current search index for the heap table. */ -extern size_t _heapindex; +extern __malloc_size_t _heapindex; /* Limit of valid info table indices. */ -extern size_t _heaplimit; +extern __malloc_size_t _heaplimit; /* Doubly linked lists of free fragments. */ struct list @@ -190,10 +190,10 @@ extern struct alignlist *_aligned_blocks; /* Instrumentation. */ -extern size_t _chunks_used; -extern size_t _bytes_used; -extern size_t _chunks_free; -extern size_t _bytes_free; +extern __malloc_size_t _chunks_used; +extern __malloc_size_t _bytes_used; +extern __malloc_size_t _chunks_free; +extern __malloc_size_t _bytes_free; /* Internal version of `free' used in `morecore' (malloc.c). */ extern void _free_internal __P ((__ptr_t __ptr)); @@ -243,15 +243,16 @@ /* Activate a standard collection of tracing hooks. */ extern void mtrace __P ((void)); +extern void muntrace __P ((void)); /* Statistics available to the user. */ struct mstats { - size_t bytes_total; /* Total size of the heap. */ - size_t chunks_used; /* Chunks allocated by the user. */ - size_t bytes_used; /* Byte total of user-allocated chunks. */ - size_t chunks_free; /* Chunks in the free list. */ - size_t bytes_free; /* Byte total of chunks in the free list. */ + __malloc_size_t bytes_total; /* Total size of the heap. */ + __malloc_size_t chunks_used; /* Chunks allocated by the user. */ + __malloc_size_t bytes_used; /* Byte total of user-allocated chunks. */ + __malloc_size_t chunks_free; /* Chunks in the free list. */ + __malloc_size_t bytes_free; /* Byte total of chunks in the free list. */ }; /* Pick up the current statistics. */ diff -ruN glibc-1.08.1/malloc/mcheck.c glibc-1.09/malloc/mcheck.c --- glibc-1.08.1/malloc/mcheck.c Mon Mar 28 15:55:11 1994 +++ glibc-1.09/malloc/mcheck.c Sat Sep 24 13:04:25 1994 @@ -1,5 +1,5 @@ /* Standard debugging hooks for `malloc'. - Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation + Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc. Written May 1989 by Mike Haertel. This library is free software; you can redistribute it and/or @@ -28,8 +28,8 @@ /* Old hook values. */ static void (*old_free_hook) __P ((__ptr_t ptr)); -static __ptr_t (*old_malloc_hook) __P ((size_t size)); -static __ptr_t (*old_realloc_hook) __P ((__ptr_t ptr, size_t size)); +static __ptr_t (*old_malloc_hook) __P ((__malloc_size_t size)); +static __ptr_t (*old_realloc_hook) __P ((__ptr_t ptr, __malloc_size_t size)); /* Function to call when something awful happens. */ static void (*abortfunc) __P ((enum mcheck_status)); @@ -38,13 +38,31 @@ #define MAGICWORD 0xfedabeeb #define MAGICFREE 0xd8675309 #define MAGICBYTE ((char) 0xd7) +#define MALLOCFLOOD ((char) 0x93) +#define FREEFLOOD ((char) 0x95) struct hdr { - size_t size; /* Exact size requested by user. */ + __malloc_size_t size; /* Exact size requested by user. */ unsigned long int magic; /* Magic number to check header integrity. */ }; +#if defined(_LIBC) || defined(STDC_HEADERS) || defined(USG) +#define flood memset +#else +static void flood __P ((__ptr_t, int, __malloc_size_t)); +static void +flood (ptr, val, size) + __ptr_t ptr; + int val; + __malloc_size_t size; +{ + char *cp = ptr; + while (size--) + *cp++ = val; +} +#endif + static enum mcheck_status checkhdr __P ((const struct hdr *)); static enum mcheck_status checkhdr (hdr) @@ -79,15 +97,16 @@ struct hdr *hdr = ((struct hdr *) ptr) - 1; checkhdr (hdr); hdr->magic = MAGICFREE; + flood (ptr, FREEFLOOD, hdr->size); __free_hook = old_free_hook; free (hdr); __free_hook = freehook; } -static __ptr_t mallochook __P ((size_t)); +static __ptr_t mallochook __P ((__malloc_size_t)); static __ptr_t mallochook (size) - size_t size; + __malloc_size_t size; { struct hdr *hdr; @@ -100,18 +119,22 @@ hdr->size = size; hdr->magic = MAGICWORD; ((char *) &hdr[1])[size] = MAGICBYTE; + flood ((__ptr_t) (hdr + 1), MALLOCFLOOD, size); return (__ptr_t) (hdr + 1); } -static __ptr_t reallochook __P ((__ptr_t, size_t)); +static __ptr_t reallochook __P ((__ptr_t, __malloc_size_t)); static __ptr_t reallochook (ptr, size) __ptr_t ptr; - size_t size; + __malloc_size_t size; { struct hdr *hdr = ((struct hdr *) ptr) - 1; + __malloc_size_t osize = hdr->size; checkhdr (hdr); + if (size < osize) + flood ((char *) ptr + size, FREEFLOOD, osize - size); __free_hook = old_free_hook; __malloc_hook = old_malloc_hook; __realloc_hook = old_realloc_hook; @@ -125,6 +148,8 @@ hdr->size = size; hdr->magic = MAGICWORD; ((char *) &hdr[1])[size] = MAGICBYTE; + if (size > osize) + flood ((char *) (hdr + 1) + osize, MALLOCFLOOD, size - osize); return (__ptr_t) (hdr + 1); } @@ -151,7 +176,13 @@ msg = "bogus mcheck_status, library is buggy"; break; } +#ifdef __GNU_LIBRARY__ __libc_fatal (msg); +#else + fprintf (stderr, "mcheck: %s\n", msg); + fflush (stderr); + abort (); +#endif } static int mcheck_used = 0; @@ -160,8 +191,6 @@ mcheck (func) void (*func) __P ((enum mcheck_status)); { - extern void abort __P ((void)); - abortfunc = (func != NULL) ? func : &mabort; /* These hooks may not be safely inserted if malloc is already in use. */ diff -ruN glibc-1.08.1/malloc/mem-limits.h glibc-1.09/malloc/mem-limits.h --- glibc-1.08.1/malloc/mem-limits.h Tue Apr 19 18:52:43 1994 +++ glibc-1.09/malloc/mem-limits.h Tue Nov 1 04:15:15 1994 @@ -34,7 +34,7 @@ #else -#if defined (__osf__) && (defined (__mips) || defined (mips)) +#if defined (__osf__) && (defined (__mips) || defined (mips) || defined(__alpha)) #include #include #endif @@ -46,7 +46,9 @@ #ifndef BSD4_2 #ifndef USG #ifndef MSDOS +#ifndef WINDOWSNT #include +#endif /* not WINDOWSNT */ #endif /* not MSDOS */ #endif /* not USG */ #else /* if BSD4_2 */ @@ -76,9 +78,9 @@ extern POINTER start_of_data (); #ifdef DATA_SEG_BITS #define EXCEEDS_LISP_PTR(ptr) \ - (((unsigned int) (ptr) & ~DATA_SEG_BITS) >> VALBITS) + (((EMACS_UINT) (ptr) & ~DATA_SEG_BITS) >> VALBITS) #else -#define EXCEEDS_LISP_PTR(ptr) ((unsigned int) (ptr) >> VALBITS) +#define EXCEEDS_LISP_PTR(ptr) ((EMACS_UINT) (ptr) >> VALBITS) #endif #ifdef BSD @@ -133,6 +135,16 @@ } #else /* not USG */ +#ifdef WINDOWSNT + +static void +get_lim_data () +{ + extern unsigned long data_region_size; + lim_data = data_region_size; +} + +#else #if !defined (BSD4_2) && !defined (__osf__) #ifdef MSDOS @@ -167,5 +179,6 @@ #endif } #endif /* BSD4_2 */ +#endif /* not WINDOWSNT */ #endif /* not USG */ #endif /* not NO_LIM_DATA */ diff -ruN glibc-1.08.1/malloc/memalign.c glibc-1.09/malloc/memalign.c --- glibc-1.08.1/malloc/memalign.c Wed Apr 20 17:55:57 1994 +++ glibc-1.09/malloc/memalign.c Mon Sep 5 23:48:48 1994 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as @@ -22,8 +22,8 @@ __ptr_t memalign (alignment, size) - size_t alignment; - size_t size; + __malloc_size_t alignment; + __malloc_size_t size; { __ptr_t result; unsigned long int adj; diff -ruN glibc-1.08.1/malloc/mstats.c glibc-1.09/malloc/mstats.c --- glibc-1.08.1/malloc/mstats.c Thu Jun 25 21:06:57 1992 +++ glibc-1.09/malloc/mstats.c Sat Sep 24 13:04:57 1994 @@ -1,5 +1,5 @@ /* Access the statistics maintained by `malloc'. - Copyright 1990, 1991, 1992 Free Software Foundation + Copyright 1990, 1991, 1992 Free Software Foundation, Inc. Written May 1989 by Mike Haertel. This library is free software; you can redistribute it and/or diff -ruN glibc-1.08.1/malloc/mtrace.awk glibc-1.09/malloc/mtrace.awk --- glibc-1.08.1/malloc/mtrace.awk Mon Nov 11 20:40:20 1991 +++ glibc-1.09/malloc/mtrace.awk Tue Aug 9 19:30:31 1994 @@ -1,36 +1,50 @@ # # Awk program to analyze mtrace.c output. # -$1 == "+" { if (allocated[$2] != "") - print "+", $2, "Alloc", NR, "duplicate:", allocated[$2]; - else - allocated[$2] = $3; - } -$1 == "-" { if (allocated[$2] != "") { - allocated[$2] = ""; - if (allocated[$2] != "") - print "DELETE FAILED", $2, allocated[$2]; - } else - print "-", $2, "Free", NR, "was never alloc'd"; - } -$1 == "<" { if (allocated[$2] != "") - allocated[$2] = ""; - else - print "-", $2, "Realloc", NR, "was never alloc'd"; - } -$1 == ">" { if (allocated[$2] != "") - print "+", $2, "Realloc", NR, "duplicate:", allocated[$2]; - else - allocated[$2] = $3; - } - -# Ignore "= Start" -$1 == "=" { } -# Ignore failed realloc attempts for now -$1 == "!" { } - - -END { for (x in allocated) - if (allocated[x] != "") - print "+", x, allocated[x]; - } +{ + if ($1 == "@") { + where = " (" $2 ")" + n = 3 + } else { + where = "" + n = 1 + } + if ($n == "+") { + if (allocated[$(n+1)] != "") + print "+", $(n+1), "Alloc", NR, "duplicate:", allocated[$(n+1)], wherewas[$(n+1)], where; + else { + wherewas[$(n+1)] = where; + allocated[$(n+1)] = $(n+2); + } + } else if ($n == "-") { + if (allocated[$(n+1)] != "") { + wherewas[$(n+1)] = ""; + allocated[$(n+1)] = ""; + if (allocated[$(n+1)] != "") + print "DELETE FAILED", $(n+1), allocated[$(n+1)]; + } else + print "-", $(n+1), "Free", NR, "was never alloc'd", where; + } else if ($n == "<") { + if (allocated[$(n+1)] != "") { + wherewas[$(n+1)] = ""; + allocated[$(n+1)] = ""; + } else + print "-", $(n+1), "Realloc", NR, "was never alloc'd", where; + } else if ($n == ">") { + if (allocated[$(n+1)] != "") + print "+", $(n+1), "Realloc", NR, "duplicate:", allocated[$(n+1)], where; + else { + wherewas[$(n+1)] = $(n+2); + allocated[$(n+1)] = $(n+2); + } + } else if ($n == "=") { + # Ignore "= Start" + } else if ($n == "!") { + # Ignore failed realloc attempts for now + } +} +END { + for (x in allocated) + if (allocated[x] != "") + print "+", x, allocated[x], wherewas[x]; +} diff -ruN glibc-1.08.1/malloc/mtrace.c glibc-1.09/malloc/mtrace.c --- glibc-1.08.1/malloc/mtrace.c Thu Jul 22 15:20:23 1993 +++ glibc-1.09/malloc/mtrace.c Mon Sep 5 23:47:59 1994 @@ -1,5 +1,5 @@ /* More debugging hooks for `malloc'. - Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. + Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc. Written April 2, 1991 by John Gilmore of Cygnus Support. Based on mcheck.c by Mike Haertel. @@ -41,10 +41,15 @@ /* Address to breakpoint on accesses to... */ __ptr_t mallwatch; +/* File name and line number information, for callers that had + the foresight to call through a macro. */ +char *_mtrace_file; +int _mtrace_line; + /* Old hook values. */ static void (*tr_old_free_hook) __P ((__ptr_t ptr)); -static __ptr_t (*tr_old_malloc_hook) __P ((size_t size)); -static __ptr_t (*tr_old_realloc_hook) __P ((__ptr_t ptr, size_t size)); +static __ptr_t (*tr_old_malloc_hook) __P ((__malloc_size_t size)); +static __ptr_t (*tr_old_realloc_hook) __P ((__ptr_t ptr, __malloc_size_t size)); /* This function is called when the block being alloc'd, realloc'd, or freed has an address matching the variable "mallwatch". In a debugger, @@ -57,11 +62,23 @@ { } +static void tr_where __P ((void)); +static void +tr_where () +{ + if (_mtrace_file) + { + fprintf (mallstream, "@ %s:%d ", _mtrace_file, _mtrace_line); + _mtrace_file = NULL; + } +} + static void tr_freehook __P ((__ptr_t)); static void tr_freehook (ptr) __ptr_t ptr; { + tr_where (); fprintf (mallstream, "- %p\n", ptr); /* Be sure to print it first. */ if (ptr == mallwatch) tr_break (); @@ -70,10 +87,10 @@ __free_hook = tr_freehook; } -static __ptr_t tr_mallochook __P ((size_t)); +static __ptr_t tr_mallochook __P ((__malloc_size_t)); static __ptr_t tr_mallochook (size) - size_t size; + __malloc_size_t size; { __ptr_t hdr; @@ -81,8 +98,9 @@ hdr = (__ptr_t) malloc (size); __malloc_hook = tr_mallochook; + tr_where (); /* We could be printing a NULL here; that's OK. */ - fprintf (mallstream, "+ %p %lx\n", hdr, size); + fprintf (mallstream, "+ %p %lx\n", hdr, (unsigned long)size); if (hdr == mallwatch) tr_break (); @@ -90,11 +108,11 @@ return hdr; } -static __ptr_t tr_reallochook __P ((__ptr_t, size_t)); +static __ptr_t tr_reallochook __P ((__ptr_t, __malloc_size_t)); static __ptr_t tr_reallochook (ptr, size) __ptr_t ptr; - size_t size; + __malloc_size_t size; { __ptr_t hdr; @@ -108,11 +126,12 @@ __free_hook = tr_freehook; __malloc_hook = tr_mallochook; __realloc_hook = tr_reallochook; + tr_where (); if (hdr == NULL) /* Failed realloc. */ - fprintf (mallstream, "! %p %lx\n", ptr, size); + fprintf (mallstream, "! %p %lx\n", ptr, (unsigned long)size); else - fprintf (mallstream, "< %p\n> %p %lx\n", ptr, hdr, size); + fprintf (mallstream, "< %p\n> %p %lx\n", ptr, hdr, (unsigned long)size); if (hdr == mallwatch) tr_break (); @@ -130,6 +149,10 @@ { char *mallfile; + /* Don't panic if we're called more than once. */ + if (mallstream != NULL) + return; + mallfile = getenv (mallenv); if (mallfile != NULL || mallwatch != NULL) { @@ -147,4 +170,18 @@ __realloc_hook = tr_reallochook; } } +} + +void +muntrace () +{ + if (mallstream == NULL) + return; + + fprintf (mallstream, "= End\n"); + fclose (mallstream); + mallstream = NULL; + __free_hook = tr_old_free_hook; + __malloc_hook = tr_old_malloc_hook; + __realloc_hook = tr_old_realloc_hook; } diff -ruN glibc-1.08.1/malloc/obstack.h glibc-1.09/malloc/obstack.h --- glibc-1.08.1/malloc/obstack.h Tue Apr 5 04:26:18 1994 +++ glibc-1.09/malloc/obstack.h Fri Oct 28 06:31:32 1994 @@ -301,7 +301,7 @@ _obstack_newchunk (__o, __len); \ if (!__o->alloc_failed) \ { \ - bcopy (where, __o->next_free, __len); \ + bcopy ((char *) (where), __o->next_free, __len); \ __o->next_free += __len; \ } \ (void) 0; }) @@ -314,7 +314,7 @@ _obstack_newchunk (__o, __len + 1); \ if (!__o->alloc_failed) \ { \ - bcopy (where, __o->next_free, __len); \ + bcopy ((char *) (where), __o->next_free, __len); \ __o->next_free += __len; \ *(__o->next_free)++ = 0; \ } \ @@ -432,7 +432,7 @@ (((h)->next_free + (h)->temp > (h)->chunk_limit) \ ? (_obstack_newchunk ((h), (h)->temp), 0) : 0), \ ((h)->alloc_failed ? 0 : \ - (bcopy (where, (h)->next_free, (h)->temp), \ + (bcopy ((char *) (where), (h)->next_free, (h)->temp), \ (h)->next_free += (h)->temp))) #define obstack_grow0(h,where,length) \ @@ -440,7 +440,7 @@ (((h)->next_free + (h)->temp + 1 > (h)->chunk_limit) \ ? (_obstack_newchunk ((h), (h)->temp + 1), 0) : 0), \ ((h)->alloc_failed ? 0 : \ - (bcopy (where, (h)->next_free, (h)->temp), \ + (bcopy ((char *) (where), (h)->next_free, (h)->temp), \ (h)->next_free += (h)->temp, \ *((h)->next_free)++ = 0))) diff -ruN glibc-1.08.1/malloc/ralloc.c glibc-1.09/malloc/ralloc.c --- glibc-1.08.1/malloc/ralloc.c Mon Nov 29 18:00:05 1993 +++ glibc-1.09/malloc/ralloc.c Fri Oct 28 06:31:38 1994 @@ -24,7 +24,7 @@ Only relocate the blocs necessary for SIZE in r_alloc_sbrk, rather than all of them. This means allowing for a possible - hole between the first bloc and the end of malloc storage. */ + hole between the first bloc and the end of malloc storage. */ #ifdef emacs @@ -90,18 +90,16 @@ /* Declarations for working with the malloc, ralloc, and system breaks. */ -/* Function to set the real break value. */ +/* Function to set the real break value. */ static POINTER (*real_morecore) (); -/* The break value, as seen by malloc (). */ +/* The break value, as seen by malloc. */ static POINTER virtual_break_value; -/* The break value, viewed by the relocatable blocs. */ +/* The address of the end of the last data in use by ralloc, + including relocatable blocs as well as malloc data. */ static POINTER break_value; -/* The REAL (i.e., page aligned) break value of the process. */ -static POINTER page_break_value; - /* This is the size of a page. We round memory requests to this boundary. */ static int page_size; @@ -110,110 +108,253 @@ static int extra_bytes; /* Macros for rounding. Note that rounding to any value is possible - by changing the definition of PAGE. */ + by changing the definition of PAGE. */ #define PAGE (getpagesize ()) #define ALIGNED(addr) (((unsigned long int) (addr) & (page_size - 1)) == 0) #define ROUNDUP(size) (((unsigned long int) (size) + page_size - 1) \ & ~(page_size - 1)) #define ROUND_TO_PAGE(addr) (addr & (~(page_size - 1))) + +#define MEM_ALIGN sizeof(double) +#define MEM_ROUNDUP(addr) (((unsigned long int)(addr) + MEM_ALIGN - 1) \ + & ~(MEM_ALIGN - 1)) -/* Functions to get and return memory from the system. */ +/* Data structures of heaps and blocs. */ -/* Obtain SIZE bytes of space. If enough space is not presently available - in our process reserve, (i.e., (page_break_value - break_value)), - this means getting more page-aligned space from the system. +/* The relocatable objects, or blocs, and the malloc data + both reside within one or more heaps. + Each heap contains malloc data, running from `start' to `bloc_start', + and relocatable objects, running from `bloc_start' to `free'. + + Relocatable objects may relocate within the same heap + or may move into another heap; the heaps themselves may grow + but they never move. + + We try to make just one heap and make it larger as necessary. + But sometimes we can't do that, because we can't get continguous + space to add onto the heap. When that happens, we start a new heap. */ + +typedef struct heap +{ + struct heap *next; + struct heap *prev; + /* Start of memory range of this heap. */ + POINTER start; + /* End of memory range of this heap. */ + POINTER end; + /* Start of relocatable data in this heap. */ + POINTER bloc_start; + /* Start of unused space in this heap. */ + POINTER free; + /* First bloc in this heap. */ + struct bp *first_bloc; + /* Last bloc in this heap. */ + struct bp *last_bloc; +} *heap_ptr; + +#define NIL_HEAP ((heap_ptr) 0) +#define HEAP_PTR_SIZE (sizeof (struct heap)) + +/* This is the first heap object. + If we need additional heap objects, each one resides at the beginning of + the space it covers. */ +static struct heap heap_base; - Return non-zero if all went well, or zero if we couldn't allocate - the memory. */ -static int -obtain (size) - SIZE size; +/* Head and tail of the list of heaps. */ +static heap_ptr first_heap, last_heap; + +/* These structures are allocated in the malloc arena. + The linked list is kept in order of increasing '.data' members. + The data blocks abut each other; if b->next is non-nil, then + b->data + b->size == b->next->data. */ +typedef struct bp { - SIZE already_available = page_break_value - break_value; + struct bp *next; + struct bp *prev; + POINTER *variable; + POINTER data; + SIZE size; + POINTER new_data; /* tmporarily used for relocation */ + /* Heap this bloc is in. */ + struct heap *heap; +} *bloc_ptr; - if (already_available < size) - { - SIZE get = ROUNDUP (size - already_available); - /* Get some extra, so we can come here less often. */ - get += extra_bytes; +#define NIL_BLOC ((bloc_ptr) 0) +#define BLOC_PTR_SIZE (sizeof (struct bp)) - if ((*real_morecore) (get) == 0) - return 0; +/* Head and tail of the list of relocatable blocs. */ +static bloc_ptr first_bloc, last_bloc; - page_break_value += get; - } + +/* Functions to get and return memory from the system. */ - break_value += size; +/* Find the heap that ADDRESS falls within. */ - return 1; +static heap_ptr +find_heap (address) + POINTER address; +{ + heap_ptr heap; + + for (heap = last_heap; heap; heap = heap->prev) + { + if (heap->start <= address && address <= heap->end) + return heap; + } + + return NIL_HEAP; } -/* Obtain SIZE bytes of space and return a pointer to the new area. - If we could not allocate the space, return zero. */ +/* Find SIZE bytes of space in a heap. + Try to get them at ADDRESS (which must fall within some heap's range) + if we can get that many within one heap. + + If enough space is not presently available in our reserve, this means + getting more page-aligned space from the system. If the retuned space + is not contiguos to the last heap, allocate a new heap, and append it + + obtain does not try to keep track of whether space is in use + or not in use. It just returns the address of SIZE bytes that + fall within a single heap. If you call obtain twice in a row + with the same arguments, you typically get the same value. + to the heap list. It's the caller's responsibility to keep + track of what space is in use. + + Return the address of the space if all went well, or zero if we couldn't + allocate the memory. */ static POINTER -get_more_space (size) - SIZE size; +obtain (address, size) + POINTER address; + SIZE size; { - POINTER ptr = break_value; - if (obtain (size)) - return ptr; - else - return 0; + heap_ptr heap; + SIZE already_available; + + /* Find the heap that ADDRESS falls within. */ + for (heap = last_heap; heap; heap = heap->prev) + { + if (heap->start <= address && address <= heap->end) + break; + } + + if (! heap) + abort (); + + /* If we can't fit SIZE bytes in that heap, + try successive later heaps. */ + while (heap && address + size > heap->end) + { + heap = heap->next; + if (heap == NIL_HEAP) + break; + address = heap->bloc_start; + } + + /* If we can't fit them within any existing heap, + get more space. */ + if (heap == NIL_HEAP) + { + POINTER new = (*real_morecore)(0); + SIZE get; + + already_available = (char *)last_heap->end - (char *)address; + + if (new != last_heap->end) + { + /* Someone else called sbrk. Make a new heap. */ + + heap_ptr new_heap = (heap_ptr) MEM_ROUNDUP (new); + POINTER bloc_start = (POINTER) MEM_ROUNDUP ((POINTER)(new_heap + 1)); + + if ((*real_morecore) (bloc_start - new) != new) + return 0; + + new_heap->start = new; + new_heap->end = bloc_start; + new_heap->bloc_start = bloc_start; + new_heap->free = bloc_start; + new_heap->next = NIL_HEAP; + new_heap->prev = last_heap; + new_heap->first_bloc = NIL_BLOC; + new_heap->last_bloc = NIL_BLOC; + last_heap->next = new_heap; + last_heap = new_heap; + + address = bloc_start; + already_available = 0; + } + + /* Add space to the last heap (which we may have just created). + Get some extra, so we can come here less often. */ + + get = size + extra_bytes - already_available; + get = (char *) ROUNDUP ((char *)last_heap->end + get) + - (char *) last_heap->end; + + if ((*real_morecore) (get) != last_heap->end) + return 0; + + last_heap->end += get; + } + + return address; } -/* Note that SIZE bytes of space have been relinquished by the process. - If SIZE is more than a page, return the space to the system. */ +/* Return unused heap space to the system + if there is a lot of unused space now. + This can make the last heap smaller; + it can also eliminate the last heap entirely. */ static void -relinquish (size) - SIZE size; +relinquish () { - POINTER new_page_break; - int excess; + register heap_ptr h; + int excess = 0; + + /* Add the amount of space beyond break_value + in all heaps which have extend beyond break_value at all. */ + + for (h = last_heap; h && break_value < h->end; h = h->prev) + { + excess += (char *) h->end - (char *) ((break_value < h->bloc_start) + ? h->bloc_start : break_value); + } - break_value -= size; - new_page_break = (POINTER) ROUNDUP (break_value); - excess = (char *) page_break_value - (char *) new_page_break; - - if (excess > extra_bytes * 2) + if (excess > extra_bytes * 2 && (*real_morecore) (0) == last_heap->end) { /* Keep extra_bytes worth of empty space. And don't free anything unless we can free at least extra_bytes. */ - if ((*real_morecore) (extra_bytes - excess) == 0) - abort (); + excess -= extra_bytes; - page_break_value += extra_bytes - excess; - } + if ((char *)last_heap->end - (char *)last_heap->bloc_start <= excess) + { + /* This heap should have no blocs in it. */ + if (last_heap->first_bloc != NIL_BLOC + || last_heap->last_bloc != NIL_BLOC) + abort (); + + /* Return the last heap, with its header, to the system. */ + excess = (char *)last_heap->end - (char *)last_heap->start; + last_heap = last_heap->prev; + last_heap->next = NIL_HEAP; + } + else + { + excess = (char *) last_heap->end + - (char *) ROUNDUP ((char *)last_heap->end - excess); + last_heap->end -= excess; + } - /* Zero the space from the end of the "official" break to the actual - break, so that bugs show up faster. */ - bzero (break_value, ((char *) page_break_value - (char *) break_value)); + if ((*real_morecore) (- excess) == 0) + abort (); + } } /* The meat - allocating, freeing, and relocating blocs. */ -/* These structures are allocated in the malloc arena. - The linked list is kept in order of increasing '.data' members. - The data blocks abut each other; if b->next is non-nil, then - b->data + b->size == b->next->data. */ -typedef struct bp -{ - struct bp *next; - struct bp *prev; - POINTER *variable; - POINTER data; - SIZE size; -} *bloc_ptr; - -#define NIL_BLOC ((bloc_ptr) 0) -#define BLOC_PTR_SIZE (sizeof (struct bp)) - -/* Head and tail of the list of relocatable blocs. */ -static bloc_ptr first_bloc, last_bloc; - /* Find the bloc referenced by the address in PTR. Returns a pointer - to that block. */ + to that block. */ static bloc_ptr find_bloc (ptr) @@ -241,9 +382,10 @@ SIZE size; { register bloc_ptr new_bloc; + register heap_ptr heap; if (! (new_bloc = (bloc_ptr) malloc (BLOC_PTR_SIZE)) - || ! (new_bloc->data = get_more_space (size))) + || ! (new_bloc->data = obtain (break_value, size))) { if (new_bloc) free (new_bloc); @@ -251,10 +393,24 @@ return 0; } + break_value = new_bloc->data + size; + new_bloc->size = size; new_bloc->next = NIL_BLOC; new_bloc->variable = (POINTER *) NIL; + new_bloc->new_data = 0; + /* Record in the heap that this space is in use. */ + heap = find_heap (new_bloc->data); + heap->free = break_value; + + /* Maintain the correspondence between heaps and blocs. */ + new_bloc->heap = heap; + heap->last_bloc = new_bloc; + if (heap->first_bloc == NIL_BLOC) + heap->first_bloc = new_bloc; + + /* Put this bloc on the doubly-linked list of blocs. */ if (first_bloc) { new_bloc->prev = last_bloc; @@ -269,45 +425,243 @@ return new_bloc; } + +/* Calculate new locations of blocs in the list beginning with BLOC, + relocating it to start at ADDRESS, in heap HEAP. If enough space is + not presently available in our reserve, call obtain for + more space. + + Store the new location of each bloc in its new_data field. + Do not touch the contents of blocs or break_value. */ -/* Relocate all blocs from BLOC on upward in the list to the zone - indicated by ADDRESS. Direction of relocation is determined by - the position of ADDRESS relative to BLOC->data. +static int +relocate_blocs (bloc, heap, address) + bloc_ptr bloc; + heap_ptr heap; + POINTER address; +{ + register bloc_ptr b = bloc; - If BLOC is NIL_BLOC, nothing is done. + while (b) + { + /* If bloc B won't fit within HEAP, + move to the next heap and try again. */ + while (heap && address + b->size > heap->end) + { + heap = heap->next; + if (heap == NIL_HEAP) + break; + address = heap->bloc_start; + } + + /* If BLOC won't fit in any heap, + get enough new space to hold BLOC and all following blocs. */ + if (heap == NIL_HEAP) + { + register bloc_ptr tb = b; + register SIZE s = 0; + + /* Add up the size of all the following blocs. */ + while (tb != NIL_BLOC) + { + s += tb->size; + tb = tb->next; + } + + /* Get that space. */ + address = obtain (address, s); + if (address == 0) + return 0; - Note that ordering of blocs is not affected by this function. */ + heap = last_heap; + } + + /* Record the new address of this bloc + and update where the next bloc can start. */ + b->new_data = address; + address += b->size; + b = b->next; + } + + return 1; +} + +/* Reorder the bloc BLOC to go before bloc BEFORE in the doubly linked list. + This is necessary if we put the memory of space of BLOC + before that of BEFORE. */ + +static void +reorder_bloc (bloc, before) + bloc_ptr bloc, before; +{ + bloc_ptr prev, next; + + /* Splice BLOC out from where it is. */ + prev = bloc->prev; + next = bloc->next; + + if (prev) + prev->next = next; + if (next) + next->prev = prev; + + /* Splice it in before BEFORE. */ + prev = before->prev; + + if (prev) + prev->next = bloc; + bloc->prev = prev; + + before->prev = bloc; + bloc->next = before; +} + +/* Update the records of which heaps contain which blocs, starting + with heap HEAP and bloc BLOC. */ static void -relocate_some_blocs (bloc, address) +update_heap_bloc_correspondence (bloc, heap) bloc_ptr bloc; - POINTER address; + heap_ptr heap; { - if (bloc != NIL_BLOC) + register bloc_ptr b; + + /* Initialize HEAP's status to reflect blocs before BLOC. */ + if (bloc != NIL_BLOC && bloc->prev != NIL_BLOC && bloc->prev->heap == heap) { - register SIZE offset = address - bloc->data; - register SIZE data_size = 0; - register bloc_ptr b; - - for (b = bloc; b != NIL_BLOC; b = b->next) + /* The previous bloc is in HEAP. */ + heap->last_bloc = bloc->prev; + heap->free = bloc->prev->data + bloc->prev->size; + } + else + { + /* HEAP contains no blocs before BLOC. */ + heap->first_bloc = NIL_BLOC; + heap->last_bloc = NIL_BLOC; + heap->free = heap->bloc_start; + } + + /* Advance through blocs one by one. */ + for (b = bloc; b != NIL_BLOC; b = b->next) + { + /* Advance through heaps, marking them empty, + till we get to the one that B is in. */ + while (heap) { - data_size += b->size; - b->data += offset; - *b->variable = b->data; + if (heap->bloc_start <= b->data && b->data <= heap->end) + break; + heap = heap->next; + /* We know HEAP is not null now, + because there has to be space for bloc B. */ + heap->first_bloc = NIL_BLOC; + heap->last_bloc = NIL_BLOC; + heap->free = heap->bloc_start; } - safe_bcopy (address - offset, address, data_size); + /* Update HEAP's status for bloc B. */ + heap->free = b->data + b->size; + heap->last_bloc = b; + if (heap->first_bloc == NIL_BLOC) + heap->first_bloc = b; + + /* Record that B is in HEAP. */ + b->heap = heap; + } + + /* If there are any remaining heaps and no blocs left, + mark those heaps as empty. */ + heap = heap->next; + while (heap) + { + heap->first_bloc = NIL_BLOC; + heap->last_bloc = NIL_BLOC; + heap->free = heap->bloc_start; + heap = heap->next; } } + +/* Resize BLOC to SIZE bytes. This relocates the blocs + that come after BLOC in memory. */ +static int +resize_bloc (bloc, size) + bloc_ptr bloc; + SIZE size; +{ + register bloc_ptr b; + heap_ptr heap; + POINTER address; + SIZE old_size; + + if (bloc == NIL_BLOC || size == bloc->size) + return 1; + + for (heap = first_heap; heap != NIL_HEAP; heap = heap->next) + { + if (heap->bloc_start <= bloc->data && bloc->data <= heap->end) + break; + } + + if (heap == NIL_HEAP) + abort (); + + old_size = bloc->size; + bloc->size = size; + + /* Note that bloc could be moved into the previous heap. */ + address = (bloc->prev ? bloc->prev->data + bloc->prev->size + : first_heap->bloc_start); + while (heap) + { + if (heap->bloc_start <= address && address <= heap->end) + break; + heap = heap->prev; + } -/* Free BLOC from the chain of blocs, relocating any blocs above it - and returning BLOC->size bytes to the free area. */ + if (! relocate_blocs (bloc, heap, address)) + { + bloc->size = old_size; + return 0; + } + + if (size > old_size) + { + for (b = last_bloc; b != bloc; b = b->prev) + { + safe_bcopy (b->data, b->new_data, b->size); + *b->variable = b->data = b->new_data; + } + safe_bcopy (bloc->data, bloc->new_data, old_size); + bzero (bloc->new_data + old_size, size - old_size); + *bloc->variable = bloc->data = bloc->new_data; + } + else + { + for (b = bloc; b != NIL_BLOC; b = b->next) + { + safe_bcopy (b->data, b->new_data, b->size); + *b->variable = b->data = b->new_data; + } + } + + update_heap_bloc_correspondence (bloc, heap); + + break_value = (last_bloc ? last_bloc->data + last_bloc->size + : first_heap->bloc_start); + return 1; +} + +/* Free BLOC from the chain of blocs, relocating any blocs above it. + This may return space to the system. */ static void free_bloc (bloc) bloc_ptr bloc; { + heap_ptr heap = bloc->heap; + + resize_bloc (bloc, 0); + if (bloc == first_bloc && bloc == last_bloc) { first_bloc = last_bloc = NIL_BLOC; @@ -328,14 +682,30 @@ bloc->prev->next = bloc->next; } - relocate_some_blocs (bloc->next, bloc->data); - relinquish (bloc->size); + /* Update the records of which blocs are in HEAP. */ + if (heap->first_bloc == bloc) + { + if (bloc->next->heap == heap) + heap->first_bloc = bloc->next; + else + heap->first_bloc = heap->last_bloc = NIL_BLOC; + } + if (heap->last_bloc == bloc) + { + if (bloc->prev->heap == heap) + heap->last_bloc = bloc->prev; + else + heap->first_bloc = heap->last_bloc = NIL_BLOC; + } + + relinquish (); free (bloc); } /* Interface routines. */ static int use_relocatable_buffers; +static int r_alloc_freeze_level; /* Obtain SIZE bytes of storage from the free pool, or the system, as necessary. If relocatable blocs are in use, this means relocating @@ -352,52 +722,131 @@ r_alloc_sbrk (size) long size; { - /* This is the first address not currently available for the heap. */ - POINTER top; - /* Amount of empty space below that. */ - /* It is not correct to use SIZE here, because that is usually unsigned. - ptrdiff_t would be okay, but is not always available. - `long' will work in all cases, in practice. */ - long already_available; - POINTER ptr; + register bloc_ptr b; + POINTER address; if (! use_relocatable_buffers) return (*real_morecore) (size); - top = first_bloc ? first_bloc->data : page_break_value; - already_available = (char *) top - (char *) virtual_break_value; + if (size == 0) + return virtual_break_value; - /* Do we not have enough gap already? */ - if (size > 0 && already_available < size) + if (size > 0) { - /* Get what we need, plus some extra so we can come here less often. */ - SIZE get = size - already_available + extra_bytes; + /* Allocate a page-aligned space. GNU malloc would reclaim an + extra space if we passed an unaligned one. But we could + not always find a space which is contiguos to the previous. */ + POINTER new_bloc_start; + heap_ptr h = first_heap; + SIZE get = ROUNDUP (size); - if (! obtain (get)) - return 0; + address = (POINTER) ROUNDUP (virtual_break_value); - if (first_bloc) - relocate_some_blocs (first_bloc, first_bloc->data + get); + /* Search the list upward for a heap which is large enough. */ + while ((char *) h->end < (char *) MEM_ROUNDUP ((char *)address + get)) + { + h = h->next; + if (h == NIL_HEAP) + break; + address = (POINTER) ROUNDUP (h->start); + } - /* Zero out the space we just allocated, to help catch bugs - quickly. */ - bzero (virtual_break_value, get); + /* If not found, obtain more space. */ + if (h == NIL_HEAP) + { + get += extra_bytes + page_size; + + if (r_alloc_freeze_level > 0 || ! obtain (address, get)) + return 0; + + if (first_heap == last_heap) + address = (POINTER) ROUNDUP (virtual_break_value); + else + address = (POINTER) ROUNDUP (last_heap->start); + h = last_heap; + } + + new_bloc_start = (POINTER) MEM_ROUNDUP ((char *)address + get); + + if (first_heap->bloc_start < new_bloc_start) + { + /* Move all blocs upward. */ + if (r_alloc_freeze_level > 0 + || ! relocate_blocs (first_bloc, h, new_bloc_start)) + return 0; + + /* Note that (POINTER)(h+1) <= new_bloc_start since + get >= page_size, so the following does not destroy the heap + header. */ + for (b = last_bloc; b != NIL_BLOC; b = b->prev) + { + safe_bcopy (b->data, b->new_data, b->size); + *b->variable = b->data = b->new_data; + } + + h->bloc_start = new_bloc_start; + + update_heap_bloc_correspondence (first_bloc, h); + } + + if (h != first_heap) + { + /* Give up managing heaps below the one the new + virtual_break_value points to. */ + first_heap->prev = NIL_HEAP; + first_heap->next = h->next; + first_heap->start = h->start; + first_heap->end = h->end; + first_heap->free = h->free; + first_heap->first_bloc = h->first_bloc; + first_heap->last_bloc = h->last_bloc; + first_heap->bloc_start = h->bloc_start; + + if (first_heap->next) + first_heap->next->prev = first_heap; + else + last_heap = first_heap; + } + + bzero (address, size); } - /* Can we keep extra_bytes of gap while freeing at least extra_bytes? */ - else if (size < 0 && already_available - size > 2 * extra_bytes) + else /* size < 0 */ { - /* Ok, do so. This is how many to free. */ - SIZE give_back = already_available - size - extra_bytes; + SIZE excess = (char *)first_heap->bloc_start + - ((char *)virtual_break_value + size); - if (first_bloc) - relocate_some_blocs (first_bloc, first_bloc->data - give_back); - relinquish (give_back); + address = virtual_break_value; + + if (r_alloc_freeze_level == 0 && excess > 2 * extra_bytes) + { + excess -= extra_bytes; + first_heap->bloc_start + = (POINTER) MEM_ROUNDUP ((char *)first_heap->bloc_start - excess); + + relocate_blocs (first_bloc, first_heap, first_heap->bloc_start); + + for (b = first_bloc; b != NIL_BLOC; b = b->next) + { + safe_bcopy (b->data, b->new_data, b->size); + *b->variable = b->data = b->new_data; + } + } + + if ((char *)virtual_break_value + size < (char *)first_heap->start) + { + /* We found an additional space below the first heap */ + first_heap->start = (POINTER) ((char *)virtual_break_value + size); + } } - ptr = virtual_break_value; - virtual_break_value += size; + virtual_break_value = (POINTER) ((char *)address + size); + break_value = (last_bloc + ? last_bloc->data + last_bloc->size + : first_heap->bloc_start); + if (size < 0) + relinquish (); - return ptr; + return address; } /* Allocate a relocatable bloc of storage of size SIZE. A pointer to @@ -417,7 +866,7 @@ if (! r_alloc_initialized) r_alloc_init (); - new_bloc = get_bloc (size); + new_bloc = get_bloc (MEM_ROUNDUP (size)); if (new_bloc) { new_bloc->variable = ptr; @@ -471,29 +920,50 @@ /* Wouldn't it be useful to actually resize the bloc here? */ return *ptr; - if (! obtain (size - bloc->size)) + if (! resize_bloc (bloc, MEM_ROUNDUP (size))) return 0; - relocate_some_blocs (bloc->next, bloc->data + size); + return *ptr; +} - /* Zero out the new space in the bloc, to help catch bugs faster. */ - bzero (bloc->data + bloc->size, size - bloc->size); +/* Disable relocations, after making room for at least SIZE bytes + of non-relocatable heap if possible. The relocatable blocs are + guaranteed to hold still until thawed, even if this means that + malloc must return a null pointer. */ - /* Indicate that this block has a new size. */ - bloc->size = size; +void +r_alloc_freeze (size) + long size; +{ + /* If already frozen, we can't make any more room, so don't try. */ + if (r_alloc_freeze_level > 0) + size = 0; + /* If we can't get the amount requested, half is better than nothing. */ + while (size > 0 && r_alloc_sbrk (size) == 0) + size /= 2; + ++r_alloc_freeze_level; + if (size > 0) + r_alloc_sbrk (-size); +} - return *ptr; +void +r_alloc_thaw () +{ + if (--r_alloc_freeze_level < 0) + abort (); } /* The hook `malloc' uses for the function which gets more space from the system. */ extern POINTER (*__morecore) (); -/* Initialize various things for memory allocation. */ +/* Initialize various things for memory allocation. */ static void r_alloc_init () { + POINTER end; + if (r_alloc_initialized) return; @@ -501,28 +971,118 @@ real_morecore = __morecore; __morecore = r_alloc_sbrk; - virtual_break_value = break_value = (*real_morecore) (0); + first_heap = last_heap = &heap_base; + first_heap->next = first_heap->prev = NIL_HEAP; + first_heap->start = first_heap->bloc_start + = virtual_break_value = break_value = (*real_morecore) (0); if (break_value == NIL) abort (); page_size = PAGE; extra_bytes = ROUNDUP (50000); - page_break_value = (POINTER) ROUNDUP (break_value); + first_heap->end = (POINTER) ROUNDUP (first_heap->start); /* The extra call to real_morecore guarantees that the end of the address space is a multiple of page_size, even if page_size is not really the page size of the system running the binary in which page_size is stored. This allows a binary to be built on a system with one page size and run on a system with a smaller page - size. */ - (*real_morecore) (page_break_value - break_value); + size. */ + (*real_morecore) (first_heap->end - first_heap->start); /* Clear the rest of the last page; this memory is in our address space even though it is after the sbrk value. */ /* Doubly true, with the additional call that explicitly adds the rest of that page to the address space. */ - bzero (break_value, (page_break_value - break_value)); - virtual_break_value = break_value = page_break_value; + bzero (first_heap->start, first_heap->end - first_heap->start); + virtual_break_value = break_value = first_heap->bloc_start = first_heap->end; use_relocatable_buffers = 1; } +#ifdef DEBUG +#include + +int +r_alloc_check () +{ + int found = 0; + heap_ptr h, ph = 0; + bloc_ptr b, pb = 0; + + if (!r_alloc_initialized) + return; + + assert (first_heap); + assert (last_heap->end <= (POINTER) sbrk (0)); + assert ((POINTER) first_heap < first_heap->start); + assert (first_heap->start <= virtual_break_value); + assert (virtual_break_value <= first_heap->end); + + for (h = first_heap; h; h = h->next) + { + assert (h->prev == ph); + assert ((POINTER) ROUNDUP (h->end) == h->end); + assert ((POINTER) MEM_ROUNDUP (h->start) == h->start); + assert ((POINTER) MEM_ROUNDUP (h->bloc_start) == h->bloc_start); + assert (h->start <= h->bloc_start && h->bloc_start <= h->end); + + if (ph) + { + assert (ph->end < h->start); + assert (h->start <= (POINTER)h && (POINTER)(h+1) <= h->bloc_start); + } + + if (h->bloc_start <= break_value && break_value <= h->end) + found = 1; + + ph = h; + } + + assert (found); + assert (last_heap == ph); + + for (b = first_bloc; b; b = b->next) + { + assert (b->prev == pb); + assert ((POINTER) MEM_ROUNDUP (b->data) == b->data); + assert ((SIZE) MEM_ROUNDUP (b->size) == b->size); + + ph = 0; + for (h = first_heap; h; h = h->next) + { + if (h->bloc_start <= b->data && b->data + b->size <= h->end) + break; + ph = h; + } + + assert (h); + + if (pb && pb->data + pb->size != b->data) + { + assert (ph && b->data == h->bloc_start); + while (ph) + { + if (ph->bloc_start <= pb->data + && pb->data + pb->size <= ph->end) + { + assert (pb->data + pb->size + b->size > ph->end); + break; + } + else + { + assert (ph->bloc_start + b->size > ph->end); + } + ph = ph->prev; + } + } + pb = b; + } + + assert (last_bloc == pb); + + if (last_bloc) + assert (last_bloc->data + last_bloc->size == break_value); + else + assert (first_heap->bloc_start == break_value); +} +#endif /* DEBUG */ diff -ruN glibc-1.08.1/malloc/realloc.c glibc-1.09/malloc/realloc.c --- glibc-1.08.1/malloc/realloc.c Thu Mar 3 17:55:29 1994 +++ glibc-1.09/malloc/realloc.c Mon Sep 5 23:22:36 1994 @@ -96,7 +96,7 @@ #define min(A, B) ((A) < (B) ? (A) : (B)) /* Debugging hook for realloc. */ -__ptr_t (*__realloc_hook) __P ((__ptr_t __ptr, size_t __size)); +__ptr_t (*__realloc_hook) __P ((__ptr_t __ptr, __malloc_size_t __size)); /* Resize the given region to the new size, returning a pointer to the (possibly moved) region. This is optimized for speed; @@ -107,11 +107,11 @@ __ptr_t realloc (ptr, size) __ptr_t ptr; - size_t size; + __malloc_size_t size; { __ptr_t result; int type; - size_t block, blocks, oldlimit; + __malloc_size_t block, blocks, oldlimit; if (size == 0) { @@ -198,7 +198,8 @@ default: /* Old size is a fragment; type is logarithm to base two of the fragment size. */ - if (size > (size_t) (1 << (type - 1)) && size <= (size_t) (1 << type)) + if (size > (__malloc_size_t) (1 << (type - 1)) && + size <= (__malloc_size_t) (1 << type)) /* The new size is the same kind of fragment. */ result = ptr; else @@ -208,7 +209,7 @@ result = malloc (size); if (result == NULL) return NULL; - memcpy (result, ptr, min (size, (size_t) 1 << type)); + memcpy (result, ptr, min (size, (__malloc_size_t) 1 << type)); free (ptr); } break; diff -ruN glibc-1.08.1/malloc/valloc.c glibc-1.09/malloc/valloc.c --- glibc-1.08.1/malloc/valloc.c Thu Aug 12 19:26:23 1993 +++ glibc-1.09/malloc/valloc.c Mon Sep 5 23:49:10 1994 @@ -1,5 +1,5 @@ /* Allocate memory on a page boundary. - Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. + Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as @@ -33,11 +33,11 @@ #include #endif -static size_t pagesize; +static __malloc_size_t pagesize; __ptr_t valloc (size) - size_t size; + __malloc_size_t size; { if (pagesize == 0) pagesize = __getpagesize (); diff -ruN glibc-1.08.1/manual/Makefile glibc-1.09/manual/Makefile --- glibc-1.08.1/manual/Makefile Thu Jan 27 17:17:23 1994 +++ glibc-1.09/manual/Makefile Fri Nov 4 16:51:46 1994 @@ -53,7 +53,7 @@ # Generate the summary from the Texinfo source files for each chapter. summary.texi: stamp-summary ; -stamp-summary: summary.awk $(chapters) +stamp-summary: summary.awk $(chapters) $(chapters-incl) awk -f $^ \ | sort -df +1 -2 | tr '\014' '\012' > summary-tmp ./move-if-change summary-tmp summary.texi @@ -113,10 +113,11 @@ -rm -f libc.dvi libc.info* clean: mostlyclean distclean: clean +indices = cp fn pg tp vr ky realclean: distclean -rm -f chapters chapters-incl summary.texi stamp-summary *.c.texi - -rm -f libc.cp libc.cps libc.fn libc.fns libc.pg libc.pgs \ - libc.tp libc.tps libc.vr libc.vrs libc.log libc.aux libc.toc + -rm -f $(foreach index,$(indices),libc.$(index) libc.$(index)s) + -rm -f libc.log libc.aux libc.toc .PHONY: install subdir_install installdirs install-data install-data subdir_install: install diff -ruN glibc-1.08.1/manual/arith.texi glibc-1.09/manual/arith.texi --- glibc-1.08.1/manual/arith.texi Mon Feb 7 18:28:22 1994 +++ glibc-1.09/manual/arith.texi Wed Oct 5 00:29:42 1994 @@ -286,13 +286,13 @@ @comment math.h @comment ANSI -@deftypefun double modf (double @var{value}, double *@var{integer_part}) +@deftypefun double modf (double @var{value}, double *@var{integer-part}) This function breaks the argument @var{value} into an integer part and a fractional part (between @code{-1} and @code{1}, exclusive). Their sum equals @var{value}. Each of the parts has the same sign as @var{value}, so the rounding of the integer part is towards zero. -@code{modf} stores the integer part in @code{*@var{integer_part}}, and +@code{modf} stores the integer part in @code{*@var{integer-part}}, and returns the fractional part. For example, @code{modf (2.5, &intpart)} returns @code{0.5} and stores @code{2.0} into @code{intpart}. @end deftypefun diff -ruN glibc-1.08.1/manual/chapters glibc-1.09/manual/chapters --- glibc-1.08.1/manual/chapters Fri Sep 10 00:30:38 1993 +++ glibc-1.09/manual/chapters Mon Oct 24 01:38:40 1994 @@ -21,7 +21,7 @@ setjmp.texi \ signal.texi \ startup.texi \ -child.texi \ +process.texi \ job.texi \ users.texi \ sysinfo.texi \ diff -ruN glibc-1.08.1/manual/chapters-incl glibc-1.09/manual/chapters-incl --- glibc-1.08.1/manual/chapters-incl Sun Jun 5 22:08:43 1994 +++ glibc-1.09/manual/chapters-incl Sun Nov 6 22:25:46 1994 @@ -1,4 +1,5 @@ chapters-incl := \ +creature.texi \ stpcpy.c.texi \ strncat.c.texi \ rprintf.c.texi \ diff -ruN glibc-1.08.1/manual/child.texi glibc-1.09/manual/child.texi --- glibc-1.08.1/manual/child.texi Mon Feb 7 18:28:27 1994 +++ glibc-1.09/manual/child.texi Wed Dec 31 19:00:00 1969 @@ -1,764 +0,0 @@ -@node Child Processes, Job Control, Process Startup, Top -@chapter Child Processes - -@cindex process -@dfn{Processes} are the primitive units for allocation of system -resources. Each process has its own address space and (usually) one -thread of control. A process executes a program; you can have multiple -processes executing the same program, but each process has its own copy -of the program within its own address space and executes it -independently of the other copies. - -@cindex child process -@cindex parent process -Processes are organized hierarchically. Each process has a @dfn{parent -process} which explicitly arranged to create it. The processes created -by a given parent are called its @dfn{child processes}. A child -inherits many of its attributes from the parent process. - -This chapter describes how a program can create, terminate, and control -child processes. Actually, there are three distinct operations -involved: creating a new child process, causing the new process to -execute a program, and coordinating the completion of the child process -with the original program. - -The @code{system} function provides a simple, portable mechanism for -running another program; it does all three steps automatically. If you -need more control over the details of how this is done, you can use the -primitive functions to do each step individually instead. - -@menu -* Running a Command:: The easy way to run another program. -* Process Creation Concepts:: An overview of the hard way to do it. -* Process Identification:: How to get the process ID of a process. -* Creating a Process:: How to fork a child process. -* Executing a File:: How to make a process execute another program. -* Process Completion:: How to tell when a child process has completed. -* Process Completion Status:: How to interpret the status value - returned from a child process. -* BSD Wait Functions:: More functions, for backward compatibility. -* Process Creation Example:: A complete example program. -@end menu - - -@node Running a Command -@section Running a Command -@cindex running a command - -The easy way to run another program is to use the @code{system} -function. This function does all the work of running a subprogram, but -it doesn't give you much control over the details: you have to wait -until the subprogram terminates before you can do anything else. - -@comment stdlib.h -@comment ANSI -@deftypefun int system (const char *@var{command}) -@pindex sh -This function executes @var{command} as a shell command. In the GNU C -library, it always uses the default shell @code{sh} to run the command. -In particular, it searches the directories in @code{PATH} to find -programs to execute. The return value is @code{-1} if it wasn't -possible to create the shell process, and otherwise is the status of the -shell process. @xref{Process Completion}, for details on how this -status code can be interpreted. - -@pindex stdlib.h -The @code{system} function is declared in the header file -@file{stdlib.h}. -@end deftypefun - -@strong{Portability Note:} Some C implementations may not have any -notion of a command processor that can execute other programs. You can -determine whether a command processor exists by executing -@w{@code{system (NULL)}}; if the return value is nonzero, a command -processor is available. - -The @code{popen} and @code{pclose} functions (@pxref{Pipe to a -Subprocess}) are closely related to the @code{system} function. They -allow the parent process to communicate with the standard input and -output channels of the command being executed. - -@node Process Creation Concepts -@section Process Creation Concepts - -This section gives an overview of processes and of the steps involved in -creating a process and making it run another program. - -@cindex process ID -@cindex process lifetime -Each process is named by a @dfn{process ID} number. A unique process ID -is allocated to each process when it is created. The @dfn{lifetime} of -a process ends when its termination is reported to its parent process; -at that time, all of the process resources, including its process ID, -are freed. - -@cindex creating a process -@cindex forking a process -@cindex child process -@cindex parent process -Processes are created with the @code{fork} system call (so the operation -of creating a new process is sometimes called @dfn{forking} a process). -The @dfn{child process} created by @code{fork} is an exact clone of the -original @dfn{parent process}, except that it has its own process ID. - -After forking a child process, both the parent and child processes -continue to execute normally. If you want your program to wait for a -child process to finish executing before continuing, you must do this -explicitly after the fork operation, by calling @code{wait} or -@code{waitpid} (@pxref{Process Completion}). These functions give you -limited information about why the child terminated---for example, its -exit status code. - -A newly forked child process continues to execute the same program as -its parent process, at the point where the @code{fork} call returns. -You can use the return value from @code{fork} to tell whether the program -is running in the parent process or the child. - -@cindex process image -Having several processes run the same program is only occasionally -useful. But the child can execute another program using one of the -@code{exec} functions; see @ref{Executing a File}. The program that the -process is executing is called its @dfn{process image}. Starting -execution of a new program causes the process to forget all about its -previous process image; when the new program exits, the process exits -too, instead of returning to the previous process image. - -@node Process Identification -@section Process Identification - -The @code{pid_t} data type represents process IDs. You can get the -process ID of a process by calling @code{getpid}. The function -@code{getppid} returns the process ID of the parent of the current -process (this is also known as the @dfn{parent process ID}). Your -program should include the header files @file{unistd.h} and -@file{sys/types.h} to use these functions. -@pindex sys/types.h -@pindex unistd.h - -@comment sys/types.h -@comment POSIX.1 -@deftp {Data Type} pid_t -The @code{pid_t} data type is a signed integer type which is capable -of representing a process ID. In the GNU library, this is an @code{int}. -@end deftp - -@comment unistd.h -@comment POSIX.1 -@deftypefun pid_t getpid (void) -The @code{getpid} function returns the process ID of the current process. -@end deftypefun - -@comment unistd.h -@comment POSIX.1 -@deftypefun pid_t getppid (void) -The @code{getppid} function returns the process ID of the parent of the -current process. -@end deftypefun - -@node Creating a Process -@section Creating a Process - -The @code{fork} function is the primitive for creating a process. -It is declared in the header file @file{unistd.h}. -@pindex unistd.h - -@comment unistd.h -@comment POSIX.1 -@deftypefun pid_t fork (void) -The @code{fork} function creates a new process. - -If the operation is successful, there are then both parent and child -processes and both see @code{fork} return, but with different values: it -returns a value of @code{0} in the child process and returns the child's -process ID in the parent process. - -If process creation failed, @code{fork} returns a value of @code{-1} in -the parent process. The following @code{errno} error conditions are -defined for @code{fork}: - -@table @code -@item EAGAIN -There aren't enough system resources to create another process, or the -user already has too many processes running. - -@item ENOMEM -The process requires more space than the system can supply. -@end table -@end deftypefun - -The specific attributes of the child process that differ from the -parent process are: - -@itemize @bullet -@item -The child process has its own unique process ID. - -@item -The parent process ID of the child process is the process ID of its -parent process. - -@item -The child process gets its own copies of the parent process's open file -descriptors. Subsequently changing attributes of the file descriptors -in the parent process won't affect the file descriptors in the child, -and vice versa. @xref{Control Operations}. - -@item -The elapsed processor times for the child process are set to zero; -see @ref{Processor Time}. - -@item -The child doesn't inherit file locks set by the parent process. -@xref{Control Operations}. - -@item -The child doesn't inherit alarms set by the parent process. -@xref{Setting an Alarm}. - -@item -The set of pending signals (@pxref{Delivery of Signal}) for the child -process is cleared. (The child process inherits its mask of blocked -signals and signal actions from the parent process.) -@end itemize - - -@comment unistd.h -@comment BSD -@deftypefun pid_t vfork (void) -The @code{vfork} function is similar to @code{fork} but more efficient; -however, there are restrictions you must follow to use it safely. - -While @code{fork} makes a complete copy of the calling process's address -space and allows both the parent and child to execute independently, -@code{vfork} does not make this copy. Instead, the child process -created with @code{vfork} shares its parent's address space until it calls -one of the @code{exec} functions. In the meantime, the parent process -suspends execution. - -You must be very careful not to allow the child process created with -@code{vfork} to modify any global data or even local variables shared -with the parent. Furthermore, the child process cannot return from (or -do a long jump out of) the function that called @code{vfork}! This -would leave the parent process's control information very confused. If -in doubt, use @code{fork} instead. - -Some operating systems don't really implement @code{vfork}. The GNU C -library permits you to use @code{vfork} on all systems, but actually -executes @code{fork} if @code{vfork} isn't available. If you follow -the proper precautions for using @code{vfork}, your program will still -work even if the system uses @code{fork} instead. -@end deftypefun - -@node Executing a File -@section Executing a File -@cindex executing a file -@cindex @code{exec} functions - -This section describes the @code{exec} family of functions, for executing -a file as a process image. You can use these functions to make a child -process execute a new program after it has been forked. - -@pindex unistd.h -The functions in this family differ in how you specify the arguments, -but otherwise they all do the same thing. They are declared in the -header file @file{unistd.h}. - -@comment unistd.h -@comment POSIX.1 -@deftypefun int execv (const char *@var{filename}, char *const @var{argv}@t{[]}) -The @code{execv} function executes the file named by @var{filename} as a -new process image. - -The @var{argv} argument is an array of null-terminated strings that is -used to provide a value for the @code{argv} argument to the @code{main} -function of the program to be executed. The last element of this array -must be a null pointer. By convention, the first element of this array -is the file name of the program sans directory names. @xref{Program -Arguments}, for full details on how programs can access these arguments. - -The environment for the new process image is taken from the -@code{environ} variable of the current process image; see -@ref{Environment Variables}, for information about environments. -@end deftypefun - -@comment unistd.h -@comment POSIX.1 -@deftypefun int execl (const char *@var{filename}, const char *@var{arg0}, @dots{}) -This is similar to @code{execv}, but the @var{argv} strings are -specified individually instead of as an array. A null pointer must be -passed as the last such argument. -@end deftypefun - -@comment unistd.h -@comment POSIX.1 -@deftypefun int execve (const char *@var{filename}, char *const @var{argv}@t{[]}, char *const @var{env}@t{[]}) -This is similar to @code{execv}, but permits you to specify the environment -for the new program explicitly as the @var{env} argument. This should -be an array of strings in the same format as for the @code{environ} -variable; see @ref{Environment Access}. -@end deftypefun - -@comment unistd.h -@comment POSIX.1 -@deftypefun int execle (const char *@var{filename}, const char *@var{arg0}, char *const @var{env}@t{[]}, @dots{}) -This is similar to @code{execl}, but permits you to specify the -environment for the new program explicitly. The environment argument is -passed following the null pointer that marks the last @var{argv} -argument, and should be an array of strings in the same format as for -the @code{environ} variable. -@end deftypefun - -@comment unistd.h -@comment POSIX.1 -@deftypefun int execvp (const char *@var{filename}, char *const @var{argv}@t{[]}) -The @code{execvp} function is similar to @code{execv}, except that it -searches the directories listed in the @code{PATH} environment variable -(@pxref{Standard Environment}) to find the full file name of a -file from @var{filename} if @var{filename} does not contain a slash. - -This function is useful for executing system utility programs, because -it looks for them in the places that the user has chosen. Shells use it -to run the commands that users type. -@end deftypefun - -@comment unistd.h -@comment POSIX.1 -@deftypefun int execlp (const char *@var{filename}, const char *@var{arg0}, @dots{}) -This function is like @code{execl}, except that it performs the same -file name searching as the @code{execvp} function. -@end deftypefun - -The size of the argument list and environment list taken together must -not be greater than @code{ARG_MAX} bytes. @xref{General Limits}. In -the GNU system, the size (which compares against @code{ARG_MAX}) -includes, for each string, the number of characters in the string, plus -the size of a @code{char *}, plus one, rounded up to a multiple of the -size of a @code{char *}. Other systems may have somewhat different -rules for counting. - -These functions normally don't return, since execution of a new program -causes the currently executing program to go away completely. A value -of @code{-1} is returned in the event of a failure. In addition to the -usual file name syntax errors (@pxref{File Name Errors}), the following -@code{errno} error conditions are defined for these functions: - -@table @code -@item E2BIG -The combined size of the new program's argument list and environment -list is larger than @code{ARG_MAX} bytes. The GNU system has no -specific limit on the argument list size, so this error code cannot -result, but you may get @code{ENOMEM} instead if the arguments are too -big for available memory. - -@item ENOEXEC -The specified file can't be executed because it isn't in the right format. - -@item ENOMEM -Executing the specified file requires more storage than is available. -@end table - -If execution of the new file succeeds, it updates the access time field -of the file as if the file had been read. @xref{File Times}, for more -details about access times of files. - -The point at which the file is closed again is not specified, but -is at some point before the process exits or before another process -image is executed. - -Executing a new process image completely changes the contents of memory, -copying only the argument and environment strings to new locations. But -many other attributes of the process are unchanged: - -@itemize @bullet -@item -The process ID and the parent process ID. @xref{Process Creation Concepts}. - -@item -Session and process group membership. @xref{Concepts of Job Control}. - -@item -Real user ID and group ID, and supplementary group IDs. @xref{Process -Persona}. - -@item -Pending alarms. @xref{Setting an Alarm}. - -@item -Current working directory and root directory. @xref{Working Directory}. - -@item -File mode creation mask. @xref{Setting Permissions}. - -@item -Process signal mask; see @ref{Process Signal Mask}. - -@item -Pending signals; see @ref{Blocking Signals}. - -@item -Elapsed processor time associated with the process; see @ref{Processor Time}. -@end itemize - -If the set-user-ID and set-group-ID mode bits of the process image file -are set, this affects the effective user ID and effective group ID -(respectively) of the process. These concepts are discussed in detail -in @ref{Process Persona}. - -Signals that are set to be ignored in the existing process image are -also set to be ignored in the new process image. All other signals are -set to the default action in the new process image. For more -information about signals, see @ref{Signal Handling}. - -File descriptors open in the existing process image remain open in the -new process image, unless they have the @code{FD_CLOEXEC} -(close-on-exec) flag set. The files that remain open inherit all -attributes of the open file description from the existing process image, -including file locks. File descriptors are discussed in @ref{Low-Level I/O}. - -Streams, by contrast, cannot survive through @code{exec} functions, -because they are located in the memory of the process itself. The new -process image has no streams except those it creates afresh. Each of -the streams in the pre-@code{exec} process image has a descriptor inside -it, and these descriptors do survive through @code{exec} (provided that -they do not have @code{FD_CLOEXEC} set. The new process image can -reconnect these to new streams using @code{fdopen} (@pxref{Descriptors -and Streams}). -@c ??? this is a bad thing to recommend. it won't work in GNU, where -@c fopen doesn't go thru a file descriptor. -@c ??? I think Posix.1 requires this to work -- rms. - -@node Process Completion -@section Process Completion -@cindex process completion -@cindex waiting for completion of child process -@cindex testing exit status of child process - -The functions described in this section are used to wait for a child -process to terminate or stop, and determine its status. These functions -are declared in the header file @file{sys/wait.h}. -@pindex sys/wait.h - -@comment sys/wait.h -@comment POSIX.1 -@deftypefun pid_t waitpid (pid_t @var{pid}, int *@var{status_ptr}, int @var{options}) -The @code{waitpid} function is used to request status information from a -child process whose process ID is @var{pid}. Normally, the calling -process is suspended until the child process makes status information -available by terminating. - -Other values for the @var{pid} argument have special interpretations. A -value of @code{-1} or @code{WAIT_ANY} requests status information for -any child process; a value of @code{0} or @code{WAIT_MYPGRP} requests -information for any child process in the same process group as the -calling process; and any other negative value @minus{} @var{pgid} -requests information for any child process whose process group ID is -@var{pgid}. - -If status information for a child process is available immediately, this -function returns immediately without waiting. If more than one eligible -child process has status information available, one of them is chosen -randomly, and its status is returned immediately. To get the status -from the other eligible child processes, you need to call @code{waitpid} -again. - -The @var{options} argument is a bit mask. Its value should be the -bitwise OR (that is, the @samp{|} operator) of zero or more of the -@code{WNOHANG} and @code{WUNTRACED} flags. You can use the -@code{WNOHANG} flag to indicate that the parent process shouldn't wait; -and the @code{WUNTRACED} flag to request status information from stopped -processes as well as processes that have terminated. - -The status information from the child process is stored in the object -that @var{status_ptr} points to, unless @var{status_ptr} is a null pointer. - -The return value is normally the process ID of the child process whose -status is reported. If the @code{WNOHANG} option was specified and no -child process is waiting to be noticed, the value is zero. A value of -@code{-1} is returned in case of error. The following @code{errno} -error conditions are defined for this function: - -@table @code -@item EINTR -The function was interrupted by delivery of a signal to the calling -process. @xref{Interrupted Primitives}. - -@item ECHILD -There are no child processes to wait for, or the specified @var{pid} -is not a child of the calling process. - -@item EINVAL -An invalid value was provided for the @var{options} argument. -@end table -@end deftypefun - -These symbolic constants are defined as values for the @var{pid} argument -to the @code{waitpid} function. - -@comment Extra blank lines make it look better. -@table @code -@item WAIT_ANY - -This constant macro (whose value is @code{-1}) specifies that -@code{waitpid} should return status information about any child process. - - -@item WAIT_MYPGRP -This constant (with value @code{0}) specifies that @code{waitpid} should -return status information about any child process in the same process -group as the calling process. -@end table - -These symbolic constants are defined as flags for the @var{options} -argument to the @code{waitpid} function. You can bitwise-OR the flags -together to obtain a value to use as the argument. - -@table @code -@item WNOHANG - -This flag specifies that @code{waitpid} should return immediately -instead of waiting, if there is no child process ready to be noticed. - -@item WUNTRACED - -This flag specifies that @code{waitpid} should report the status of any -child processes that have been stopped as well as those that have -terminated. -@end table - -@comment sys/wait.h -@comment POSIX.1 -@deftypefun pid_t wait (int *@var{status_ptr}) -This is a simplified version of @code{waitpid}, and is used to wait -until any one child process terminates. The call: - -@smallexample -wait (&status) -@end smallexample - -@noindent -is exactly equivalent to: - -@smallexample -waitpid (-1, &status, 0) -@end smallexample -@end deftypefun - -Here's an example of how to use @code{waitpid} to get the status from -all child processes that have terminated, without ever waiting. This -function is designed to be a handler for @code{SIGCHLD}, the signal that -indicates that at least one child process has terminated. - -@smallexample -@group -void -sigchld_handler (int signum) -@{ - int pid; - int status; - while (1) - @{ - pid = waitpid (WAIT_ANY, &status, WNOHANG); - if (pid < 0) - @{ - perror ("waitpid"); - break; - @} - if (pid == 0) - break; - notice_termination (pid, status); - @} -@} -@end group -@end smallexample - -@node Process Completion Status -@section Process Completion Status - -If the exit status value (@pxref{Program Termination}) of the child -process is zero, then the status value reported by @code{waitpid} or -@code{wait} is also zero. You can test for other kinds of information -encoded in the returned status value using the following macros. -These macros are defined in the header file @file{sys/wait.h}. -@pindex sys/wait.h - -@comment sys/wait.h -@comment POSIX.1 -@deftypefn Macro int WIFEXITED (int @var{status}) -This macro returns a nonzero value if the child process terminated -normally with @code{exit} or @code{_exit}. -@end deftypefn - -@comment sys/wait.h -@comment POSIX.1 -@deftypefn Macro int WEXITSTATUS (int @var{status}) -If @code{WIFEXITED} is true of @var{status}, this macro returns the -low-order 8 bits of the exit status value from the child process. -@xref{Exit Status}. -@end deftypefn - -@comment sys/wait.h -@comment POSIX.1 -@deftypefn Macro int WIFSIGNALED (int @var{status}) -This macro returns a nonzero value if the child process terminated -because it received a signal that was not handled. -@xref{Signal Handling}. -@end deftypefn - -@comment sys/wait.h -@comment POSIX.1 -@deftypefn Macro int WTERMSIG (int @var{status}) -If @code{WIFSIGNALED} is true of @var{status}, this macro returns the -signal number of the signal that terminated the child process. -@end deftypefn - -@comment sys/wait.h -@comment BSD -@deftypefn Macro int WCOREDUMP (int @var{status}) -This macro returns a nonzero value if the child process terminated -and produced a core dump. -@end deftypefn - -@comment sys/wait.h -@comment POSIX.1 -@deftypefn Macro int WIFSTOPPED (int @var{status}) -This macro returns a nonzero value if the child process is stopped. -@end deftypefn - -@comment sys/wait.h -@comment POSIX.1 -@deftypefn Macro int WSTOPSIG (int @var{status}) -If @code{WIFSTOPPED} is true of @var{status}, this macro returns the -signal number of the signal that caused the child process to stop. -@end deftypefn - - -@node BSD Wait Functions -@section BSD Process Wait Functions - -The GNU library also provides these related facilities for compatibility -with BSD Unix. BSD uses the @code{union wait} data type to represent -status values rather than an @code{int}. The two representations are -actually interchangeable; they describe the same bit patterns. The GNU -C Library defines macros such as @code{WEXITSTATUS} so that they will -work on either kind of object, and the @code{wait} function is defined -to accept either type of pointer as its @var{status_ptr} argument. - -These functions are declared in @file{sys/wait.h}. -@pindex sys/wait.h - -@comment sys/wait.h -@comment BSD -@deftp {Data Type} {union wait} -This data type represents program termination status values. It has -the following members: - -@table @code -@item int w_termsig -The value of this member is the same as the result of the -@code{WTERMSIG} macro. - -@item int w_coredump -The value of this member is the same as the result of the -@code{WCOREDUMP} macro. - -@item int w_retcode -The value of this member is the same as the result of the -@code{WEXITSTATUS} macro. - -@item int w_stopsig -The value of this member is the same as the result of the -@code{WSTOPSIG} macro. -@end table - -Instead of accessing these members directly, you should use the -equivalent macros. -@end deftp - -@comment sys/wait.h -@comment BSD -@deftypefun pid_t wait3 (union wait *@var{status_ptr}, int @var{options}, struct rusage *@var{usage}) -If @var{usage} is a null pointer, @code{wait3} is equivalent to -@code{waitpid (-1, @var{status_ptr}, @var{options})}. - -If @var{usage} is not null, @code{wait3} stores usage figures for the -child process in @code{*@var{rusage}} (but only if the child has -terminated, not if it has stopped). @xref{Resource Usage}. -@end deftypefun - -@comment sys/wait.h -@comment BSD -@deftypefun pid_t wait4 (pid_t @var{pid}, union wait *@var{status_ptr}, int @var{options}, struct rusage *@var{usage}) -If @var{usage} is a null pointer, @code{wait4} is equivalent to -@code{waitpid (@var{pid}, @var{status_ptr}, @var{options})}. - -If @var{usage} is not null, @code{wait4} stores usage figures for the -child process in @code{*@var{rusage}} (but only if the child has -terminated, not if it has stopped). @xref{Resource Usage}. -@end deftypefun - -@node Process Creation Example -@section Process Creation Example - -Here is an example program showing how you might write a function -similar to the built-in @code{system}. It executes its @var{command} -argument using the equivalent of @samp{sh -c @var{command}}. - -@smallexample -#include -#include -#include -#include -#include - -/* @r{Execute the command using this shell program.} */ -#define SHELL "/bin/sh" - -@group -int -my_system (const char *command) -@{ - int status; - pid_t pid; -@end group - - pid = fork (); - if (pid == 0) - @{ - /* @r{This is the child process. Execute the shell command.} */ - execl (SHELL, SHELL, "-c", command, NULL); - _exit (EXIT_FAILURE); - @} - else if (pid < 0) - /* @r{The fork failed. Report failure.} */ - status = -1; - else - /* @r{This is the parent process. Wait for the child to complete.} */ - if (waitpid (pid, &status, 0) != pid) - status = -1; - return status; -@} -@end smallexample - -@comment Yes, this example has been tested. - -There are a couple of things you should pay attention to in this -example. - -Remember that the first @code{argv} argument supplied to the program -represents the name of the program being executed. That is why, in the -call to @code{execl}, @code{SHELL} is supplied once to name the program -to execute and a second time to supply a value for @code{argv[0]}. - -The @code{execl} call in the child process doesn't return if it is -successful. If it fails, you must do something to make the child -process terminate. Just returning a bad status code with @code{return} -would leave two processes running the original program. Instead, the -right behavior is for the child process to report failure to its parent -process. - -Call @code{_exit} to accomplish this. The reason for using @code{_exit} -instead of @code{exit} is to avoid flushing fully buffered streams such -as @code{stdout}. The buffers of these streams probably contain data -that was copied from the parent process by the @code{fork}, data that -will be output eventually by the parent process. Calling @code{exit} in -the child would output the data twice. @xref{Termination Internals}. diff -ruN glibc-1.08.1/manual/conf.texi glibc-1.09/manual/conf.texi --- glibc-1.08.1/manual/conf.texi Tue Feb 8 20:23:13 1994 +++ glibc-1.09/manual/conf.texi Mon Oct 17 02:25:39 1994 @@ -67,7 +67,9 @@ @comment POSIX.1 @deftypevr Macro int CHILD_MAX If defined, the unvarying maximum number of processes that can exist -with the same real user ID at any one time. +with the same real user ID at any one time. In BSD and GNU, this is +controlled by the @code{RLIMIT_NPROC} resource limit; @pxref{Limits on +Resources}. @end deftypevr @cindex limits, number of open files @@ -75,7 +77,8 @@ @comment POSIX.1 @deftypevr Macro int OPEN_MAX If defined, the unvarying maximum number of files that a single process -can have open simultaneously. +can have open simultaneously. In BSD and GNU, this is controlled +by the @code{RLIMIT_NOFILE} resource limit; @pxref{Limits on Resources}. @end deftypevr @comment limits.h diff -ruN glibc-1.08.1/manual/creature.texi glibc-1.09/manual/creature.texi --- glibc-1.08.1/manual/creature.texi Wed Dec 31 19:00:00 1969 +++ glibc-1.09/manual/creature.texi Tue Oct 25 18:45:26 1994 @@ -0,0 +1,113 @@ +@node Feature Test Macros +@subsection Feature Test Macros + +@cindex feature test macros +The exact set of features available when you compile a source file +is controlled by which @dfn{feature test macros} you define. + +If you compile your programs using @samp{gcc -ansi}, you get only the +ANSI C library features, unless you explicitly request additional +features by defining one or more of the feature macros. +@xref{Invoking GCC,, GNU CC Command Options, gcc.info, The GNU CC Manual}, +for more information about GCC options.@refill + +You should define these macros by using @samp{#define} preprocessor +directives at the top of your source code files. These directives +@emph{must} come before any @code{#include} of a system header file. It +is best to make them the very first thing in the file, preceded only by +comments. You could also use the @samp{-D} option to GCC, but it's +better if you make the source files indicate their own meaning in a +self-contained way. + +@comment (none) +@comment POSIX.1 +@defvr Macro _POSIX_SOURCE +If you define this macro, then the functionality from the POSIX.1 +standard (IEEE Standard 1003.1) is available, as well as all of the +ANSI C facilities. +@end defvr + +@comment (none) +@comment POSIX.2 +@defvr Macro _POSIX_C_SOURCE +If you define this macro with a value of @code{1}, then the +functionality from the POSIX.1 standard (IEEE Standard 1003.1) is made +available. If you define this macro with a value of @code{2}, then both +the functionality from the POSIX.1 standard and the functionality from +the POSIX.2 standard (IEEE Standard 1003.2) are made available. This is +in addition to the ANSI C facilities. +@end defvr + +@comment (none) +@comment GNU +@defvr Macro _BSD_SOURCE +If you define this macro, functionality derived from 4.3 BSD Unix is +included as well as the ANSI C, POSIX.1, and POSIX.2 material. + +Some of the features derived from 4.3 BSD Unix conflict with the +corresponding features specified by the POSIX.1 standard. If this +macro is defined, the 4.3 BSD definitions take precedence over the +POSIX definitions. + +Due to the nature of some of the conflicts between 4.3 BSD and POSIX.1, +you need to use a special @dfn{BSD compatibility library} when linking +programs compiled for BSD compatibility. This is because some functions +must be defined in two different ways, one of them in the normal C +library, and one of them in the compatibility library. If your program +defines @code{_BSD_SOURCE}, you must give the option @samp{-lbsd-compat} +to the compiler or linker when linking the program, to tell it to find +functions in this special compatibility library before looking for them in +the normal C library. +@pindex -lbsd-compat +@pindex bsd-compat +@cindex BSD compatibility library. +@end defvr + +@comment (none) +@comment GNU +@defvr Macro _SVID_SOURCE +If you define this macro, functionality derived from SVID is +included as well as the ANSI C, POSIX.1, and POSIX.2 material. +@end defvr + +@comment (none) +@comment GNU +@defvr Macro _GNU_SOURCE +If you define this macro, everything is included: ANSI C, POSIX.1, +POSIX.2, BSD, SVID, and GNU extensions. In the cases where POSIX.1 +conflicts with BSD, the POSIX definitions take precedence. + +If you want to get the full effect of @code{_GNU_SOURCE} but make the +BSD definitions take precedence over the POSIX definitions, use this +sequence of definitions: + +@smallexample +#define _GNU_SOURCE +#define _BSD_SOURCE +#define _SVID_SOURCE +@end smallexample + +Note that if you do this, you must link your program with the BSD +compatibility library by passing the @samp{-lbsd-compat} option to the +compiler or linker. @strong{Note:} If you forget to do this, you may +get very strange errors at run time. +@end defvr + +We recommend you use @code{_GNU_SOURCE} in new programs. If you don't +specify the @samp{-ansi} option to GCC and don't define any of these macros +explicitly, the effect is the same as defining @code{_GNU_SOURCE}. + +When you define a feature test macro to request a larger class of features, +it is harmless to define in addition a feature test macro for a subset of +those features. For example, if you define @code{_POSIX_C_SOURCE}, then +defining @code{_POSIX_SOURCE} as well has no effect. Likewise, if you +define @code{_GNU_SOURCE}, then defining either @code{_POSIX_SOURCE} or +@code{_POSIX_C_SOURCE} or @code{_SVID_SOURCE} as well has no effect. + +Note, however, that the features of @code{_BSD_SOURCE} are not a subset of +any of the other feature test macros supported. This is because it defines +BSD features that take precedence over the POSIX features that are +requested by the other macros. For this reason, defining +@code{_BSD_SOURCE} in addition to the other feature test macros does have +an effect: it causes the BSD features to take priority over the conflicting +POSIX features. diff -ruN glibc-1.08.1/manual/errno.texi glibc-1.09/manual/errno.texi --- glibc-1.08.1/manual/errno.texi Mon Feb 7 14:48:34 1994 +++ glibc-1.09/manual/errno.texi Fri Oct 28 02:09:31 1994 @@ -101,6 +101,12 @@ happen on the GNU system, we have saved space by not mentioning @code{EFAULT} in the descriptions of individual functions. +In some Unix systems, many system calls can also return @code{EFAULT} if +given as an argument a pointer into the stack, and the kernel for some +obscure reason fails in its attempt to extend the stack. If this ever +happens, you should probably try using statically or dynamically +allocated memory instead of stack memory on that system. + @node Error Codes, Error Messages, Checking for Errors, Error Reporting @section Error Codes @@ -113,6 +119,7 @@ @comment errno.h @comment POSIX.1: Operation not permitted @deftypevr Macro int EPERM +@comment errno 1 @c DO NOT REMOVE Operation not permitted; only the owner of the file (or other resource) or processes with special privileges can perform the operation. @end deftypevr @@ -120,6 +127,7 @@ @comment errno.h @comment POSIX.1: No such file or directory @deftypevr Macro int ENOENT +@comment errno 2 @c DO NOT REMOVE No such file or directory. This is a ``file doesn't exist'' error for ordinary files that are referenced in contexts where they are expected to already exist. @@ -128,12 +136,14 @@ @comment errno.h @comment POSIX.1: No such process @deftypevr Macro int ESRCH +@comment errno 3 @c DO NOT REMOVE No process matches the specified process ID. @end deftypevr @comment errno.h @comment POSIX.1: Interrupted system call @deftypevr Macro int EINTR +@comment errno 4 @c DO NOT REMOVE Interrupted function call; an asynchronous signal occured and prevented completion of the call. When this happens, you should try the call again. @@ -146,12 +156,14 @@ @comment errno.h @comment POSIX.1: Input/output error @deftypevr Macro int EIO +@comment errno 5 @c DO NOT REMOVE Input/output error; usually used for physical read or write errors. @end deftypevr @comment errno.h @comment POSIX.1: Device not configured @deftypevr Macro int ENXIO +@comment errno 6 @c DO NOT REMOVE No such device or address. The system tried to use the device represented by a file you specified, and it couldn't find the device. This can mean that the device file was installed incorrectly, or that @@ -162,6 +174,7 @@ @comment errno.h @comment POSIX.1: Argument list too long @deftypevr Macro int E2BIG +@comment errno 7 @c DO NOT REMOVE Argument list too long; used when the arguments passed to a new program being executed with one of the @code{exec} functions (@pxref{Executing a File}) occupy too much memory space. This condition never arises in the @@ -171,6 +184,7 @@ @comment errno.h @comment POSIX.1: Exec format error @deftypevr Macro int ENOEXEC +@comment errno 8 @c DO NOT REMOVE Invalid executable file format. This condition is detected by the @code{exec} functions; see @ref{Executing a File}. @end deftypevr @@ -178,6 +192,7 @@ @comment errno.h @comment POSIX.1: Bad file descriptor @deftypevr Macro int EBADF +@comment errno 9 @c DO NOT REMOVE Bad file descriptor; for example, I/O on a descriptor that has been closed or reading from a descriptor open only for writing (or vice versa). @@ -186,6 +201,7 @@ @comment errno.h @comment POSIX.1: No child processes @deftypevr Macro int ECHILD +@comment errno 10 @c DO NOT REMOVE There are no child processes. This error happens on operations that are supposed to manipulate child processes, when there aren't any processes to manipulate. @@ -194,6 +210,7 @@ @comment errno.h @comment POSIX.1: Resource deadlock avoided @deftypevr Macro int EDEADLK +@comment errno 11 @c DO NOT REMOVE Deadlock avoided; allocating a system resource would have resulted in a deadlock situation. The system does not guarantee that it will notice all such situations. This error means you got lucky and the system @@ -203,6 +220,7 @@ @comment errno.h @comment POSIX.1: Cannot allocate memory @deftypevr Macro int ENOMEM +@comment errno 12 @c DO NOT REMOVE No memory available. The system cannot allocate more virtual memory because its capacity is full. @end deftypevr @@ -210,18 +228,21 @@ @comment errno.h @comment POSIX.1: Permission denied @deftypevr Macro int EACCES +@comment errno 13 @c DO NOT REMOVE Permission denied; the file permissions do not allow the attempted operation. @end deftypevr @comment errno.h @comment POSIX.1: Bad address @deftypevr Macro int EFAULT +@comment errno 14 @c DO NOT REMOVE Bad address; an invalid pointer was detected. @end deftypevr @comment errno.h @comment BSD: Block device required @deftypevr Macro int ENOTBLK +@comment errno 15 @c DO NOT REMOVE A file that isn't a block special file was given in a situation that requires one. For example, trying to mount an ordinary file as a file system in Unix gives this error. @@ -230,6 +251,7 @@ @comment errno.h @comment POSIX.1: Device busy @deftypevr Macro int EBUSY +@comment errno 16 @c DO NOT REMOVE Resource busy; a system resource that can't be shared is already in use. For example, if you try to delete a file that is the root of a currently mounted filesystem, you get this error. @@ -238,6 +260,7 @@ @comment errno.h @comment POSIX.1: File exists @deftypevr Macro int EEXIST +@comment errno 17 @c DO NOT REMOVE File exists; an existing file was specified in a context where it only makes sense to specify a new file. @end deftypevr @@ -245,6 +268,7 @@ @comment errno.h @comment POSIX.1: Invalid cross-device link @deftypevr Macro int EXDEV +@comment errno 18 @c DO NOT REMOVE An attempt to make an improper link across file systems was detected. This happens not only when you use @code{link} (@pxref{Hard Links}) but also when you rename a file with @code{rename} (@pxref{Renaming Files}). @@ -253,6 +277,7 @@ @comment errno.h @comment POSIX.1: Operation not supported by device @deftypevr Macro int ENODEV +@comment errno 19 @c DO NOT REMOVE The wrong type of device was given to a function that expects a particular sort of device. @end deftypevr @@ -260,12 +285,14 @@ @comment errno.h @comment POSIX.1: Not a directory @deftypevr Macro int ENOTDIR +@comment errno 20 @c DO NOT REMOVE A file that isn't a directory was specified when a directory is required. @end deftypevr @comment errno.h @comment POSIX.1: Is a directory @deftypevr Macro int EISDIR +@comment errno 21 @c DO NOT REMOVE File is a directory; attempting to open a directory for writing gives this error. @end deftypevr @@ -273,6 +300,7 @@ @comment errno.h @comment POSIX.1: Invalid argument @deftypevr Macro int EINVAL +@comment errno 22 @c DO NOT REMOVE Invalid argument. This is used to indicate various kinds of problems with passing the wrong argument to a library function. @end deftypevr @@ -280,15 +308,20 @@ @comment errno.h @comment POSIX.1: Too many open files @deftypevr Macro int EMFILE +@comment errno 24 @c DO NOT REMOVE The current process has too many files open and can't open any more. Duplicate descriptors do count toward this limit. -@c !!! In 4.4BSD and GNU, the number of open files is a resource limit -@c set with setrlimit. + +In BSD and GNU, the number of open files is controlled by a resource +limit that can usually be increased. If you get this error, you might +want to increase the @code{RLIMIT_NOFILE} limit or make it unlimited; +@pxref{Limits on Resources}. @end deftypevr @comment errno.h @comment POSIX.1: Too many open files in system @deftypevr Macro int ENFILE +@comment errno 23 @c DO NOT REMOVE There are too many distinct file openings in the entire system. Note that any number of linked channels count as just one file opening; see @ref{Linked Channels}. This error never occurs in the GNU system. @@ -297,6 +330,7 @@ @comment errno.h @comment POSIX.1: Inappropriate ioctl for device @deftypevr Macro int ENOTTY +@comment errno 25 @c DO NOT REMOVE Inappropriate I/O control operation, such as trying to set terminal modes on an ordinary file. @end deftypevr @@ -304,6 +338,7 @@ @comment errno.h @comment BSD: Text file busy @deftypevr Macro int ETXTBSY +@comment errno 26 @c DO NOT REMOVE An attempt to execute a file that is currently open for writing, or write to a file that is currently being executed. (The name stands for ``text file busy''.) This is not an error in the GNU system; the @@ -313,12 +348,14 @@ @comment errno.h @comment POSIX.1: File too large @deftypevr Macro int EFBIG +@comment errno 27 @c DO NOT REMOVE File too big; the size of a file would be larger than allowed by the system. @end deftypevr @comment errno.h @comment POSIX.1: No space left on device @deftypevr Macro int ENOSPC +@comment errno 28 @c DO NOT REMOVE No space left on device; write operation on a file failed because the disk is full. @end deftypevr @@ -326,18 +363,21 @@ @comment errno.h @comment POSIX.1: Illegal seek @deftypevr Macro int ESPIPE +@comment errno 29 @c DO NOT REMOVE Invalid seek operation (such as on a pipe). @end deftypevr @comment errno.h @comment POSIX.1: Read-only file system @deftypevr Macro int EROFS +@comment errno 30 @c DO NOT REMOVE An attempt was made to modify something on a read-only file system. @end deftypevr @comment errno.h @comment POSIX.1: Too many links @deftypevr Macro int EMLINK +@comment errno 31 @c DO NOT REMOVE Too many links; the link count of a single file is too large. @code{rename} can cause this error if the file being renamed already has as many links as it can take (@pxref{Renaming Files}). @@ -346,6 +386,7 @@ @comment errno.h @comment POSIX.1: Broken pipe @deftypevr Macro int EPIPE +@comment errno 32 @c DO NOT REMOVE Broken pipe; there is no process reading from the other end of a pipe. Every library function that returns this error code also generates a @code{SIGPIPE} signal; this signal terminates the program if not handled @@ -356,6 +397,7 @@ @comment errno.h @comment ANSI: Numerical argument out of domain @deftypevr Macro int EDOM +@comment errno 33 @c DO NOT REMOVE Domain error; used by mathematical functions when an argument value does not fall into the domain over which the function is defined. @end deftypevr @@ -363,6 +405,7 @@ @comment errno.h @comment ANSI: Numerical result out of range @deftypevr Macro int ERANGE +@comment errno 34 @c DO NOT REMOVE Range error; used by mathematical functions when the result value is not representable because of overflow or underflow. @end deftypevr @@ -370,33 +413,57 @@ @comment errno.h @comment POSIX.1: Resource temporarily unavailable @deftypevr Macro int EAGAIN +@comment errno 35 @c DO NOT REMOVE Resource temporarily unavailable; the call might work if you try again -later. Only @code{fork} returns error code @code{EAGAIN} for such a -reason. -@c !!! sysv uses it somehow? Don't say "only fork" when ==EWOULDBLOCK. +later. The macro @code{EWOULDBLOCK} is another name for @code{EAGAIN}; +they are always the same in the GNU C library. + +This error can happen in a few different situations: + +@itemize @bullet +@item +An operation that would block was attempted on an object that has +non-blocking mode selected. Trying the same operation again will block +until some external condition makes it possible to read, write, or +connect (whatever the operation). You can use @code{select} to find out +when the operation will be possible; @pxref{Waiting for I/O}. + +@strong{Portability Note:} In older Unix many systems, this condition +was indicated by @code{EWOULDBLOCK}, which was a distinct error code +different from @code{EAGAIN}. To make your program portable, you should +check for both codes and treat them the same. + +@item +A temporary resource shortage made an operation impossible. @code{fork} +can return this error. It indicates that the shortage is expected to +pass, so your program can try the call again later and it may succeed. +It is probably a good idea to delay for a few seconds before trying it +again, to allow time for other processes to release scarce resources. +Such shortages are usually fairly serious and affect the whole system, +so usually an interactive program should report the error to the user +and return to its command loop. +@end itemize @end deftypevr @comment errno.h @comment BSD: Operation would block @deftypevr Macro int EWOULDBLOCK -An operation that would block was attempted on an object that has -non-blocking mode selected. +@comment errno EAGAIN @c DO NOT REMOVE +In the GNU C library, this is another name for @code{EAGAIN} (above). +The values are always the same, on every operating system. -@strong{Portability Note:} In 4.4BSD and GNU, @code{EWOULDBLOCK} and -@code{EAGAIN} are the same. Earlier versions of BSD (@pxref{Berkeley -Unix}) have two distinct codes, and use @code{EWOULDBLOCK} to indicate -an I/O operation that would block on an object with non-blocking mode -set, and @code{EAGAIN} for other kinds of errors.@refill +C libraries in many older Unix systems have @code{EWOULDBLOCK} as a +separate error code. @end deftypevr @comment errno.h @comment BSD: Operation now in progress @deftypevr Macro int EINPROGRESS +@comment errno 36 @c DO NOT REMOVE An operation that cannot complete immediately was initiated on an object that has non-blocking mode selected. Some functions that must always block (such as @code{connect}; @pxref{Connecting}) never return -@code{EWOULDBLOCK}. -@c !!! EAGAIN? +@code{EAGAIN}. Instead, they return @code{EINPROGRESS} to indicate that the operation has begun and will take some time. Attempts to manipulate the object before the call completes return @code{EALREADY}. @@ -405,6 +472,7 @@ @comment errno.h @comment BSD: Operation already in progress @deftypevr Macro int EALREADY +@comment errno 37 @c DO NOT REMOVE An operation is already in progress on an object that has non-blocking mode selected. @end deftypevr @@ -412,18 +480,14 @@ @comment errno.h @comment BSD: Socket operation on non-socket @deftypevr Macro int ENOTSOCK +@comment errno 38 @c DO NOT REMOVE A file that isn't a socket was specified when a socket is required. @end deftypevr @comment errno.h -@comment BSD: Destination address required -@deftypevr Macro int EDESTADDRREQ -No destination address was supplied on a socket operation that needed one. -@end deftypevr - -@comment errno.h @comment BSD: Message too long @deftypevr Macro int EMSGSIZE +@comment errno 40 @c DO NOT REMOVE The size of a message sent on a socket was larger than the supported maximum size. @end deftypevr @@ -431,12 +495,14 @@ @comment errno.h @comment BSD: Protocol wrong type for socket @deftypevr Macro int EPROTOTYPE +@comment errno 41 @c DO NOT REMOVE The socket type does not support the requested communications protocol. @end deftypevr @comment errno.h @comment BSD: Protocol not available @deftypevr Macro int ENOPROTOOPT +@comment errno 42 @c DO NOT REMOVE You specified a socket option that doesn't make sense for the particular protocol being used by the socket. @xref{Socket Options}. @end deftypevr @@ -444,6 +510,7 @@ @comment errno.h @comment BSD: Protocol not supported @deftypevr Macro int EPROTONOSUPPORT +@comment errno 43 @c DO NOT REMOVE The socket domain does not support the requested communications protocol (perhaps because the requested protocol is completely invalid.) @xref{Creating a Socket}. @@ -452,12 +519,14 @@ @comment errno.h @comment BSD: Socket type not supported @deftypevr Macro int ESOCKTNOSUPPORT +@comment errno 44 @c DO NOT REMOVE The socket type is not supported. @end deftypevr @comment errno.h @comment BSD: Operation not supported @deftypevr Macro int EOPNOTSUPP +@comment errno 45 @c DO NOT REMOVE The operation you requested is not supported. Some socket functions don't make sense for all types of sockets, and others may not be implemented for all communications protocols. @@ -466,12 +535,14 @@ @comment errno.h @comment BSD: Protocol family not supported @deftypevr Macro int EPFNOSUPPORT +@comment errno 46 @c DO NOT REMOVE The socket communications protocol family you requested is not supported. @end deftypevr @comment errno.h @comment BSD: Address family not supported by protocol family @deftypevr Macro int EAFNOSUPPORT +@comment errno 47 @c DO NOT REMOVE The address family specified for a socket is not supported; it is inconsistent with the protocol being used on the socket. @xref{Sockets}. @end deftypevr @@ -479,12 +550,14 @@ @comment errno.h @comment BSD: Address already in use @deftypevr Macro int EADDRINUSE +@comment errno 48 @c DO NOT REMOVE The requested socket address is already in use. @xref{Socket Addresses}. @end deftypevr @comment errno.h @comment BSD: Can't assign requested address @deftypevr Macro int EADDRNOTAVAIL +@comment errno 49 @c DO NOT REMOVE The requested socket address is not available; for example, you tried to give a socket a name that doesn't match the local host name. @xref{Socket Addresses}. @@ -493,12 +566,14 @@ @comment errno.h @comment BSD: Network is down @deftypevr Macro int ENETDOWN +@comment errno 50 @c DO NOT REMOVE A socket operation failed because the network was down. @end deftypevr @comment errno.h @comment BSD: Network is unreachable @deftypevr Macro int ENETUNREACH +@comment errno 51 @c DO NOT REMOVE A socket operation failed because the subnet containing the remost host was unreachable. @end deftypevr @@ -506,18 +581,21 @@ @comment errno.h @comment BSD: Network dropped connection on reset @deftypevr Macro int ENETRESET +@comment errno 52 @c DO NOT REMOVE A network connection was reset because the remote host crashed. @end deftypevr @comment errno.h @comment BSD: Software caused connection abort @deftypevr Macro int ECONNABORTED +@comment errno 53 @c DO NOT REMOVE A network connection was aborted locally. @end deftypevr @comment errno.h @comment BSD: Connection reset by peer @deftypevr Macro int ECONNRESET +@comment errno 54 @c DO NOT REMOVE A network connection was closed for reasons outside the control of the local host, such as by the remote machine rebooting or an unrecoverable protocol violation. @@ -526,17 +604,16 @@ @comment errno.h @comment BSD: No buffer space available @deftypevr Macro int ENOBUFS -The kernel's buffers for I/O operations are all in use. -@c !!! this will probably never happen in GNU (I'm presuming the -@c eventual implementation of the network won't want to use it); you get -@c ENOMEM instead. -@c ??? I think the network code should convert ENOMEM into ENOBUFS -@c ??? just to be compatible--rms. +@comment errno 55 @c DO NOT REMOVE +The kernel's buffers for I/O operations are all in use. In GNU, this +error is always synonymous with @code{ENOMEM}; you may get one or the +other from network operations. @end deftypevr @comment errno.h @comment BSD: Socket is already connected @deftypevr Macro int EISCONN +@comment errno 56 @c DO NOT REMOVE You tried to connect a socket that is already connected. @xref{Connecting}. @end deftypevr @@ -544,20 +621,40 @@ @comment errno.h @comment BSD: Socket is not connected @deftypevr Macro int ENOTCONN +@comment errno 57 @c DO NOT REMOVE The socket is not connected to anything. You get this error when you -try to transmit data over a socket, without first specifying a destination -for the data. +try to transmit data over a socket, without first specifying a +destination for the data. For a connectionless socket (for datagram +protocols, such as UDP), you get @code{EDESTADDRREQ} instead. +@end deftypevr + +@comment errno.h +@comment BSD: Destination address required +@deftypevr Macro int EDESTADDRREQ +@comment errno 39 @c DO NOT REMOVE +No default destination address was set for the socket. You get this +error when you try to transmit data over a connectionless socket, +without first specifying a destination for the data with @code{connect}. @end deftypevr @comment errno.h @comment BSD: Can't send after socket shutdown @deftypevr Macro int ESHUTDOWN +@comment errno 58 @c DO NOT REMOVE The socket has already been shut down. @end deftypevr @comment errno.h +@comment BSD: Too many references: can't splice +@deftypevr Macro int ETOOMANYREFS +@comment errno 59 @c DO NOT REMOVE +??? +@end deftypevr + +@comment errno.h @comment BSD: Connection timed out @deftypevr Macro int ETIMEDOUT +@comment errno 60 @c DO NOT REMOVE A socket operation with a specified timeout received no response during the timeout period. @end deftypevr @@ -565,6 +662,7 @@ @comment errno.h @comment BSD: Connection refused @deftypevr Macro int ECONNREFUSED +@comment errno 61 @c DO NOT REMOVE A remote host refused to allow the network connection (typically because it is not running the requested service). @end deftypevr @@ -572,6 +670,7 @@ @comment errno.h @comment BSD: Too many levels of symbolic links @deftypevr Macro int ELOOP +@comment errno 62 @c DO NOT REMOVE Too many levels of symbolic links were encountered in looking up a file name. This often indicates a cycle of symbolic links. @end deftypevr @@ -579,6 +678,7 @@ @comment errno.h @comment POSIX.1: File name too long @deftypevr Macro int ENAMETOOLONG +@comment errno 63 @c DO NOT REMOVE Filename too long (longer than @code{PATH_MAX}; @pxref{Limits for Files}) or host name too long (in @code{gethostname} or @code{sethostname}; @pxref{Host Identification}). @@ -587,25 +687,36 @@ @comment errno.h @comment BSD: Host is down @deftypevr Macro int EHOSTDOWN +@comment errno 64 @c DO NOT REMOVE The remote host for a requested network connection is down. @end deftypevr @comment errno.h @comment BSD: No route to host @deftypevr Macro int EHOSTUNREACH +@comment errno 65 @c DO NOT REMOVE The remote host for a requested network connection is not reachable. @end deftypevr @comment errno.h @comment POSIX.1: Directory not empty @deftypevr Macro int ENOTEMPTY +@comment errno 66 @c DO NOT REMOVE Directory not empty, where an empty directory was expected. Typically, this error occurs when you are trying to delete a directory. @end deftypevr @comment errno.h +@comment BSD: Too many processes +@deftypevr Macro int EPROCLIM +@comment errno 67 @c DO NOT REMOVE +??? +@end deftypevr + +@comment errno.h @comment BSD: Too many users @deftypevr Macro int EUSERS +@comment errno 68 @c DO NOT REMOVE The file quota system is confused because there are too many users. @c This can probably happen in a GNU system when using NFS. @end deftypevr @@ -613,12 +724,14 @@ @comment errno.h @comment BSD: Disc quota exceeded @deftypevr Macro int EDQUOT +@comment errno 69 @c DO NOT REMOVE The user's disk quota was exceeded. @end deftypevr @comment errno.h @comment BSD: Stale NFS file handle @deftypevr Macro int ESTALE +@comment errno 70 @c DO NOT REMOVE Stale NFS file handle. This indicates an internal confusion in the NFS system which is due to file system rearrangements on the server host. Repairing this condition usually requires unmounting and remounting @@ -628,6 +741,7 @@ @comment errno.h @comment BSD: Too many levels of remote in path @deftypevr Macro int EREMOTE +@comment errno 71 @c DO NOT REMOVE An attempt was made to NFS-mount a remote file system with a file name that already specifies an NFS-mounted file. (This is an error on some operating systems, but we expect it to work @@ -635,16 +749,78 @@ @end deftypevr @comment errno.h +@comment BSD: RPC struct is bad +@deftypevr Macro int EBADRPC +@comment errno 72 @c DO NOT REMOVE +??? +@end deftypevr + +@comment errno.h +@comment BSD: RPC version wrong +@deftypevr Macro int ERPCMISMATCH +@comment errno 73 @c DO NOT REMOVE +??? +@end deftypevr + +@comment errno.h +@comment BSD: RPC program not available +@deftypevr Macro int EPROGUNAVAIL +@comment errno 74 @c DO NOT REMOVE +??? +@end deftypevr + +@comment errno.h +@comment BSD: RPC program version wrong +@deftypevr Macro int EPROGMISMATCH +@comment errno 75 @c DO NOT REMOVE +??? +@end deftypevr + +@comment errno.h +@comment BSD: RPC bad procedure for program +@deftypevr Macro int EPROCUNAVAIL +@comment errno 76 @c DO NOT REMOVE +??? +@end deftypevr + +@comment errno.h @comment POSIX.1: No locks available @deftypevr Macro int ENOLCK +@comment errno 77 @c DO NOT REMOVE No locks available. This is used by the file locking facilities; see @ref{File Locks}. This error never occurs in the GNU system. @end deftypevr @comment errno.h +@comment BSD: Inappropriate file type or format +@deftypevr Macro int EFTYPE +@comment errno 79 @c DO NOT REMOVE +Inappropriate file type or format. The file was the wrong type for the +operation, or a data file had the wrong format. + +On some systems @code{chmod} returns this error if you try to set the +sticky bit on a non-directory file; @pxref{Setting Permissions}. +@end deftypevr + +@comment errno.h +@comment BSD: Authentication error +@deftypevr Macro int EAUTH +@comment errno 80 @c DO NOT REMOVE +??? +@end deftypevr + +@comment errno.h +@comment BSD: Need authenticator +@deftypevr Macro int ENEEDAUTH +@comment errno 81 @c DO NOT REMOVE +??? +@end deftypevr + +@comment errno.h @comment POSIX.1: Function not implemented @deftypevr Macro int ENOSYS +@comment errno 78 @c DO NOT REMOVE Function not implemented. Some functions have commands or options defined that might not be supported in all implementations, and this is the kind of error you get if you request them and they are not supported. @@ -653,6 +829,7 @@ @comment errno.h @comment GNU: Inappropriate operation for background process @deftypevr Macro int EBACKGROUND +@comment errno 100 @c DO NOT REMOVE In the GNU system, servers supporting the @code{term} protocol return this error for certain operations when the caller is not in the foreground process group of the terminal. Users do not usually see this @@ -662,26 +839,39 @@ @end deftypevr @comment errno.h +@comment GNU: Translator died +@deftypevr Macro int EDIED +@comment errno 101 @c DO NOT REMOVE +In the GNU system, opening a file returns this error when the file is +translated by a program and the translator program dies while starting +up, before it has connected to the file. +@end deftypevr + +@comment errno.h @comment GNU: ? @deftypevr Macro int ED +@comment errno 102 @c DO NOT REMOVE The experienced user will know what is wrong. @end deftypevr @comment errno.h @comment GNU: You really blew it this time @deftypevr Macro int EGREGIOUS +@comment errno 103 @c DO NOT REMOVE You did @strong{what}? @end deftypevr @comment errno.h @comment GNU: Computer bought the farm @deftypevr Macro int EIEIO +@comment errno 104 @c DO NOT REMOVE Go home and have a glass of warm, dairy-fresh milk. @end deftypevr @comment errno.h @comment GNU: Gratuitous error @deftypevr Macro int EGRATUITOUS +@comment errno 105 @c DO NOT REMOVE This error code has no purpose. @end deftypevr diff -ruN glibc-1.08.1/manual/examples/inetsrv.c glibc-1.09/manual/examples/inetsrv.c --- glibc-1.08.1/manual/examples/inetsrv.c Sun Feb 13 22:18:16 1994 +++ glibc-1.09/manual/examples/inetsrv.c Wed Oct 5 01:03:16 1994 @@ -75,7 +75,9 @@ /* Connection request on original socket. */ int new; size = sizeof (clientname); - new = accept (sock, (struct sockaddr *) &clientname, &size); + new = accept (sock, + (struct sockaddr *) &clientname, + &size); if (new < 0) { perror ("accept"); diff -ruN glibc-1.08.1/manual/examples/memstrm.c glibc-1.09/manual/examples/memstrm.c --- glibc-1.08.1/manual/examples/memstrm.c Wed Feb 16 21:38:38 1994 +++ glibc-1.09/manual/examples/memstrm.c Mon Oct 10 23:47:13 1994 @@ -10,10 +10,10 @@ stream = open_memstream (&bp, &size); fprintf (stream, "hello"); fflush (stream); - printf ("buf = %s, size = %d\n", bp, size); + printf ("buf = `%s', size = %d\n", bp, size); fprintf (stream, ", world"); fclose (stream); - printf ("buf = %s, size = %d\n", bp, size); + printf ("buf = `%s', size = %d\n", bp, size); return 0; } diff -ruN glibc-1.08.1/manual/filesys.texi glibc-1.09/manual/filesys.texi --- glibc-1.08.1/manual/filesys.texi Mon Feb 7 18:28:15 1994 +++ glibc-1.09/manual/filesys.texi Fri Oct 21 15:03:07 1994 @@ -115,9 +115,15 @@ @comment unistd.h @comment BSD @deftypefun {char *} getwd (char *@var{buffer}) -This is similar to @code{getcwd}. The GNU library provides @code{getwd} -for backwards compatibility with BSD. The @var{buffer} should be a -pointer to an array at least @code{PATH_MAX} bytes long. +This is similar to @code{getcwd}, but has no way to specify the size of +the buffer. The GNU library provides @code{getwd} only +for backwards compatibility with BSD. + +The @var{buffer} argument should be a pointer to an array at least +@code{PATH_MAX} bytes long (@pxref{Limits for Files}). In the GNU +system there is no limit to the size of a file name, so this is not +necessarily enough space to contain the directory name. That is why +this function is deprecated. @end deftypefun @comment unistd.h @@ -177,17 +183,60 @@ entries. It contains the following fields: @table @code -@item char *d_name +@item char d_name[] This is the null-terminated file name component. This is the only field you can count on in all POSIX systems. @item ino_t d_fileno This is the file serial number. For BSD compatibility, you can also -refer to this member as @code{d_ino}. +refer to this member as @code{d_ino}. In the GNU system and most POSIX +systems, for most files this the same as the @code{st_ino} member that +@code{stat} will return for the file. @xref{File Attributes}. -@item size_t d_namlen +@item unsigned char d_namlen This is the length of the file name, not including the terminating null -character. +character. Its type is @code{unsigned char} because that is the integer +type of the appropriate size + +@item unsigned char d_type +This is the type of the file, possibly unknown. The following constants +are defined for its value: + +@table @code +@item DT_UNKNOWN +The type is unknown. On some systems this is the only value returned. + +@item DT_REG +A regular file. + +@item DT_DIR +A directory. + +@item DT_FIFO +A named pipe, or FIFO. @xref{FIFO Special Files}. + +@item DT_SOCK +A local-domain socket. @c !!! @xref{Local Domain}. + +@item DT_CHR +A character device. + +@item DT_BLK +A block device. +@end table + +This member is a BSD extension. Each value except DT_UNKNOWN +corresponds to the file type bits in the @code{st_mode} member of +@code{struct statbuf}. These two macros convert between @code{d_type} +values and @code{st_mode} values: + +@deftypefun int IFTODT (mode_t @var{mode}) +This returns the @code{d_type} value corresponding to @var{mode}. +@end deftypefun + +@deftypefun mode_t DTTOIF (int @var{dirtype}) +This returns the @code{st_mode} value corresponding to @var{dirtype}. +@end deftypefun @end table This structure may contain additional members in the future. @@ -370,10 +419,10 @@ One file can have names in several directories, so the the organization of the file system is not a strict hierarchy or tree. -Since a particular file exists within a single file system, all its -names must be in directories in that file system. @code{link} reports -an error if you try to make a hard link to the file from another file -system. +In most implementations, it is not possible to have hard links to the +same file in multiple file systems. @code{link} reports an error if you +try to make a hard link to the file from another file system when this +cannot be done. The prototype for the @code{link} function is declared in the header file @file{unistd.h}. @@ -421,8 +470,8 @@ and cannot be extended. @item EPERM -Some implementations only allow privileged users to make links to -directories, and others prohibit this operation entirely. This error +In the GNU system and some others, you cannot make links to directories. +many systems allow only privileged users to do so. This error is used to report the problem. @item EROFS @@ -457,13 +506,14 @@ you have specified the name of a link, reads the file name contained in the link, and opens that file name instead. The @code{stat} function likewise operates on the file that the symbolic link points to, instead -of on the link itself. So does @code{link}, the function that makes a -hard link. +of on the link itself. By contrast, other operations such as deleting or renaming the file -operate on the link itself. The functions @code{readlink} and -@code{lstat} also refrain from following symbolic links, because -their purpose is to obtain information about the link. +operate on the link itself. The functions @code{readlink} and +@code{lstat} also refrain from following symbolic links, because their +purpose is to obtain information about the link. So does @code{link}, +the function that makes a hard link--it makes a hard link to the +symbolic link, which one rarely wants. Prototypes for the functions listed in this section are in @file{unistd.h}. @@ -560,7 +610,6 @@ @cindex unlinking a file You can delete a file with the functions @code{unlink} or @code{remove}. -(These names are synonymous.) Deletion actually deletes a file name. If this is the file's only name, then the file is deleted as well. If the file has other names as well @@ -583,15 +632,15 @@ defined for this function: @table @code -@item EACCESS +@item EACCES Write permission is denied for the directory from which the file is to be removed. @item EBUSY This error indicates that the file is being used by the system in such a -way that it can't be unlinked. Examples of situations where you might -see this error are if the file name specifies the root directory or a -mount point for a file system. +way that it can't be unlinked. For example, you might see this error if +the file name specifies the root directory or a mount point for a file +system. @item ENOENT The file name to be deleted doesn't exist. @@ -600,6 +649,7 @@ On some systems, @code{unlink} cannot be used to delete the name of a directory, or can only be used this way by a privileged user. To avoid such problems, use @code{rmdir} to delete directories. +The GNU system @item EROFS The directory in which the file name is to be deleted is on a read-only @@ -607,15 +657,6 @@ @end table @end deftypefun -@comment stdio.h -@comment ANSI -@deftypefun int remove (const char *@var{filename}) -The @code{remove} function is another name for @code{unlink}. -@code{remove} is the ANSI C name, whereas @code{unlink} is the POSIX.1 -name. The name @code{remove} is declared in @file{stdio.h}. -@pindex stdio.h -@end deftypefun - @comment unistd.h @comment POSIX.1 @deftypefun int rmdir (const char *@var{filename}) @@ -630,19 +671,28 @@ @code{rmdir}: @table @code -@item EEXIST -@itemx ENOTEMPTY +@item ENOTEMPTY +@itemx EEXIST The directory to be deleted is not empty. @end table -These two error codes are synonymous; some systems use one, and some -use the other. +These two error codes are synonymous; some systems use one, and some use +the other. The GNU system always uses @code{ENOTEMPTY}. The prototype for this function is declared in the header file @file{unistd.h}. @pindex unistd.h @end deftypefun +@comment stdio.h +@comment ANSI +@deftypefun int remove (const char *@var{filename}) +This is the ANSI C function to remove a file. It works like +@code{unlink} for files and like @code{rmdir} for directories. +@code{remove} is declared in @file{stdio.h}. +@pindex stdio.h +@end deftypefun + @node Renaming Files @section Renaming Files @@ -663,12 +713,9 @@ One special case for @code{rename} is when @var{oldname} and @var{newname} are two names for the same file. The consistent way to -handle this case is to delete @var{oldname}. However, POSIX says that -in this case @code{rename} does nothing and reports success---which is -inconsistent. We don't know what your operating system will do. The -GNU system, when completed, will probably do the right thing (delete -@var{oldname}) unless you explicitly request strict POSIX compatibility -``even when it hurts''. +handle this case is to delete @var{oldname}. However, POSIX requires +that in this case @code{rename} do nothing and report success---which is +inconsistent. We don't know what your operating system will do. If the @var{oldname} is not a directory, then any existing file named @var{newname} is removed during the renaming operation. However, if @@ -685,7 +732,10 @@ @var{newname} changes ``atomically'' from any previously existing file by that name to its new meaning (the file that was called @var{oldname}). There is no instant at which @var{newname} is -nonexistent ``in between'' the old meaning and the new meaning. +nonexistent ``in between'' the old meaning and the new meaning. If +there is a system crash during the operation, it is possible for both +names to still exist; but @var{newname} will always be intact if it +exists at all. If @code{rename} fails, it returns @code{-1}. In addition to the usual file name syntax errors (@pxref{File Name Errors}), the following @@ -703,11 +753,10 @@ directories that are mount points for filesystems, and directories that are the current working directories of processes. -@item EEXIST -The directory @var{newname} isn't empty. - @item ENOTEMPTY -The directory @var{newname} isn't empty. +@itemx EEXIST +The directory @var{newname} isn't empty. The GNU system always returns +@code{ENOTEMPTY} for this, but some other systems return @code{EEXIST}. @item EINVAL The @var{oldname} is a directory that contains @var{newname}. @@ -857,7 +906,9 @@ @item dev_t st_dev Identifies the device containing the file. The @code{st_ino} and -@code{st_dev}, taken together, uniquely identify the file. +@code{st_dev}, taken together, uniquely identify the file. The +@code{st_dev} value is not necessarily consistent across reboots or +system crashes, however. @item nlink_t st_nlink The number of hard links to the file. This count keeps track of how many @@ -920,9 +971,9 @@ this is not a problem. @item unsigned int st_blksize -The optimal block size for reading of writing this file. You might use -this size for allocating the buffer space for reading of writing the -file. +The optimal block size for reading of writing this file, in bytes. You +might use this size for allocating the buffer space for reading of +writing the file. (This is unrelated to @code{st_blocks}.) @end table @end deftp @@ -1388,20 +1439,43 @@ @vindex S_ISVTX This is the @dfn{sticky} bit, usually 01000. -On an executable file, it modifies the swapping policies of the system. -Normally, when a program terminates, its pages in core are immediately -freed and reused. If the sticky bit is set on the executable file, the -system keeps the pages in core for a while as if the program were still -running. This is advantageous for a program that is likely to be run -many times in succession. -@c !!! obsolete in all modern systems (but ask mib to be sure) - -On a directory, the sticky bit gives permission to delete a file in the -directory if you can write the contents of that file. Ordinarily, a -user either can delete all the files in the directory or cannot delete -any of them (based on whether the user has write permission for the -directory). The sticky bit makes it possible to control deletion for -individual files. +On a directory, it gives permission to delete a file in the directory +only if you own that file. Ordinarily, a user either can delete all the +files in the directory or cannot delete any of them (based on whether +the user has write permission for the directory). The same restriction +applies---you must both have write permission for the directory and own +the file you want to delete. The one exception is that the owner of the +directory can delete any file in the directory, no matter who owns it +(provided the owner has given himself write permission for the +directory). This is commonly used for the @file{/tmp} directory, where +anyone may create files, but not delete files created by other users. + +Originally the sticky bit on an executable file modified the swapping +policies of the system. Normally, when a program terminated, its pages +in core were immediately freed and reused. If the sticky bit was set on +the executable file, the system kept the pages in core for a while as if +the program were still running. This was advantageous for a program +likely to be run many times in succession. This usage is obsolete in +modern systems. When a program terminates, its pages always remain in +core as long as there is no shortage of memory in the system. When the +program is next run, its pages will still be in core if no shortage +arose since the last run. + +On some modern systems where the sticky bit has no useful meaning for an +executable file, you cannot set the bit at all for a non-directory. +If you try, @code{chmod} fails with @code{EFTYPE}; +@pxref{Setting Permissions}. + +Some systems (particularly SunOS) have yet another use for the sticky +bit. If the sticky bit is set on a file that is @emph{not} executable, +it means the opposite: never cache the pages of this file at all. The +main use of this is for the files on an NFS server machine which are +used as the swap area of diskless client machines. The idea is that the +pages of the file will be cached in the client's memory, so it is a +waste of the server's memory to cache them a second time. In this use +the sticky bit also says that the filesystem may fail to record the +file's modification time onto disk reliably (the idea being that noone +cares for a swap file). @end table The actual bit values of the symbols are listed in the table above @@ -1465,7 +1539,7 @@ all classes of users. These permissions are then restricted as specified by the individual user's own file creation mask. -@pindex chmod +@findex chmod To change the permission of an existing file given its name, call @code{chmod}. This function ignores the file creation mask; it uses exactly the specified permission bits. @@ -1527,9 +1601,7 @@ If the @var{filename} names a symbolic link, @code{chmod} changes the permission of the file pointed to by the link, not those of the link -itself. There is actually no way to set the mode of a link, which is -always @code{-1}. -@c I verified this experimentally. It does not depend on umask. -- rms. +itself. This function returns @code{0} if successful and @code{-1} if not. In addition to the usual file name syntax errors (@pxref{File Name @@ -1547,6 +1619,17 @@ @item EROFS The file resides on a read-only file system. + +@item EFTYPE +@var{mode} has the @code{S_ISVTX} bit (the ``sticky bit'') set, +and the named file is not a directory. Some systems do not allow setting the +sticky bit on non-directory files, and some do (and only some of those +assign a useful meaning to the bit for non-directory files). + +You only get @code{EFTYPE} on systems where the sticky bit has no useful +meaning for non-directory files, so it is always safe to just clear the +bit in @var{mode} and call @code{chmod} again. @xref{Permission Bits}, +for full details on the sticky bit. @end table @end deftypefun @@ -1614,6 +1697,10 @@ have. Using @code{access} is simple and automatically does whatever is appropriate for the system you are using. +@code{access} is @emph{only} only appropriate to use in setuid programs. +A non-setuid program will always use the effective ID rather than the +real ID. + @pindex unistd.h The symbols in this section are declared in @file{unistd.h}. @@ -1918,8 +2005,10 @@ @comment SVID @deftypefun {char *} tempnam (const char *@var{dir}, const char *@var{prefix}) This function generates a unique temporary filename. If @var{prefix} is -not a null pointer, up to five characters of this string are used as -a prefix for the file name. +not a null pointer, up to five characters of this string are used as a +prefix for the file name. The return value is a string newly allocated +with @code{malloc}; you should release its storage with @code{free} when +it is no longer needed. The directory prefix for the temporary file name is determined by testing each of the following, in sequence. The directory must exist and be diff -ruN glibc-1.08.1/manual/inetsrv.c.texi glibc-1.09/manual/inetsrv.c.texi --- glibc-1.08.1/manual/inetsrv.c.texi Mon Feb 14 06:49:53 1994 +++ glibc-1.09/manual/inetsrv.c.texi Fri Oct 14 04:43:27 1994 @@ -75,7 +75,9 @@ /* @r{Connection request on original socket.} */ int new; size = sizeof (clientname); - new = accept (sock, (struct sockaddr *) &clientname, &size); + new = accept (sock, + (struct sockaddr *) &clientname, + &size); if (new < 0) @{ perror ("accept"); diff -ruN glibc-1.08.1/manual/intro.texi glibc-1.09/manual/intro.texi --- glibc-1.08.1/manual/intro.texi Sun Feb 13 18:10:03 1994 +++ glibc-1.09/manual/intro.texi Tue Oct 25 18:45:21 1994 @@ -142,7 +142,7 @@ the ANSI C facilities specified by this standard include file system interface primitives (@pxref{File System Interface}), device-specific terminal control functions (@pxref{Low-Level Terminal Interface}), and -process control functions (@pxref{Child Processes}). +process control functions (@pxref{Processes}). Some facilities from @cite{IEEE Std 1003.2-1992, the POSIX Shell and Utilities standard} (POSIX.2) are also implemented in the GNU library. @@ -515,120 +515,9 @@ @pindex termios.h @end itemize - -@node Feature Test Macros, , Reserved Names, Using the Library -@subsection Feature Test Macros - -@cindex feature test macros -The exact set of features available when you compile a source file -is controlled by which @dfn{feature test macros} you define. - -If you compile your programs using @samp{gcc -ansi}, you get only the -ANSI C library features, unless you explicitly request additional -features by defining one or more of the feature macros. -@xref{Invoking GCC,, GNU CC Command Options, gcc.info, The GNU CC Manual}, -for more information about GCC options.@refill - -You should define these macros by using @samp{#define} preprocessor -directives at the top of your source code files. These directives -@emph{must} come before any @code{#include} of a system header file. It -is best to make them the very first thing in the file, preceded only by -comments. You could also use the @samp{-D} option to GCC, but it's -better if you make the source files indicate their own meaning in a -self-contained way. - -@comment (none) -@comment POSIX.1 -@defvr Macro _POSIX_SOURCE -If you define this macro, then the functionality from the POSIX.1 -standard (IEEE Standard 1003.1) is available, as well as all of the -ANSI C facilities. -@end defvr - -@comment (none) -@comment POSIX.2 -@defvr Macro _POSIX_C_SOURCE -If you define this macro with a value of @code{1}, then the -functionality from the POSIX.1 standard (IEEE Standard 1003.1) is made -available. If you define this macro with a value of @code{2}, then both -the functionality from the POSIX.1 standard and the functionality from -the POSIX.2 standard (IEEE Standard 1003.2) are made available. This is -in addition to the ANSI C facilities. -@end defvr - -@comment (none) -@comment GNU -@defvr Macro _BSD_SOURCE -If you define this macro, functionality derived from 4.3 BSD Unix is -included as well as the ANSI C, POSIX.1, and POSIX.2 material. - -Some of the features derived from 4.3 BSD Unix conflict with the -corresponding features specified by the POSIX.1 standard. If this -macro is defined, the 4.3 BSD definitions take precedence over the -POSIX definitions. - -Due to the nature of some of the conflicts between 4.3 BSD and POSIX.1, -you need to use a special @dfn{BSD compatibility library} when linking -programs compiled for BSD compatibility. This is because some functions -must be defined in two different ways, one of them in the normal C -library, and one of them in the compatibility library. If your program -defines @code{_BSD_SOURCE}, you must give the option @samp{-lbsd-compat} -to the compiler or linker when linking the program, to tell it to find -functions in this special compatibility library before looking for them in -the normal C library. -@pindex -lbsd-compat -@pindex bsd-compat -@cindex BSD compatibility library. -@end defvr - -@comment (none) -@comment GNU -@defvr Macro _SVID_SOURCE -If you define this macro, functionality derived from SVID is -included as well as the ANSI C, POSIX.1, and POSIX.2 material. -@end defvr - -@comment (none) -@comment GNU -@defvr Macro _GNU_SOURCE -If you define this macro, everything is included: ANSI C, POSIX.1, -POSIX.2, BSD, SVID, and GNU extensions. In the cases where POSIX.1 -conflicts with BSD, the POSIX definitions take precedence. - -If you want to get the full effect of @code{_GNU_SOURCE} but make the -BSD definitions take precedence over the POSIX definitions, use this -sequence of definitions: - -@smallexample -#define _GNU_SOURCE -#define _BSD_SOURCE -#define _SVID_SOURCE -@end smallexample - -Note that if you do this, you must link your program with the BSD -compatibility library by passing the @samp{-lbsd-compat} option to the -compiler or linker. @strong{Note:} If you forget to do this, you may -get very strange errors at run time. -@end defvr - -We recommend you use @code{_GNU_SOURCE} in new programs. If you don't -specify the @samp{-ansi} option to GCC and don't define any of these macros -explicitly, the effect is the same as defining @code{_GNU_SOURCE}. - -When you define a feature test macro to request a larger class of features, -it is harmless to define in addition a feature test macro for a subset of -those features. For example, if you define @code{_POSIX_C_SOURCE}, then -defining @code{_POSIX_SOURCE} as well has no effect. Likewise, if you -define @code{_GNU_SOURCE}, then defining either @code{_POSIX_SOURCE} or -@code{_POSIX_C_SOURCE} or @code{_SVID_SOURCE} as well has no effect. - -Note, however, that the features of @code{_BSD_SOURCE} are not a subset of -any of the other feature test macros supported. This is because it defines -BSD features that take precedence over the POSIX features that are -requested by the other macros. For this reason, defining -@code{_BSD_SOURCE} in addition to the other feature test macros does have -an effect: it causes the BSD features to take priority over the conflicting -POSIX features. +@comment Include the section on Creature Nest Macros. +@comment It is in a separate file so it can be formatted into ../NOTES. +@include creature.texi @node Roadmap to the Manual, , Using the Library, Introduction @section Roadmap to the Manual @@ -756,7 +645,7 @@ command-line arguments and environment variables. @item -@ref{Child Processes}, contains information about how to start new processes +@ref{Processes}, contains information about how to start new processes and run programs. @item diff -ruN glibc-1.08.1/manual/io.texi glibc-1.09/manual/io.texi --- glibc-1.08.1/manual/io.texi Mon Feb 7 18:28:11 1994 +++ glibc-1.09/manual/io.texi Wed Oct 19 21:50:25 1994 @@ -253,8 +253,6 @@ processes on the system have the same root directory). Such a file name is called an @dfn{absolute file name}. @c !!! xref here to chroot, if we ever document chroot. -rm -@c ??? I don't like the idea of encouraging smoking--rms. -@c !!! What the hell is that bad pun supposed to mean? I don't get it. -rm @cindex relative file name Otherwise, the first component in the file name is located in the diff -ruN glibc-1.08.1/manual/job.texi glibc-1.09/manual/job.texi --- glibc-1.08.1/manual/job.texi Mon Feb 7 18:28:28 1994 +++ glibc-1.09/manual/job.texi Mon Oct 24 00:54:31 1994 @@ -1,4 +1,4 @@ -@node Job Control, Users and Groups, Child Processes, Top +@node Job Control @chapter Job Control @cindex process groups @@ -88,8 +88,9 @@ @dfn{background jobs}. @cindex stopped job -If a background job needs to read from or write to its controlling -terminal, it is @dfn{stopped} by the terminal driver. The user can stop +If a background job needs to read from its controlling +terminal, it is @dfn{stopped} by the terminal driver; if the +@code{TOSTOP} mode is set, likewise for writing. The user can stop a foreground job by typing the SUSP character (@pxref{Special Characters}) and a program can stop any job by sending it a @code{SIGSTOP} signal. It's the responsibility of the shell to notice @@ -194,9 +195,7 @@ To prevent problems, process groups that continue running even after the session leader has terminated are marked as @dfn{orphaned process -groups}. Processes in an orphaned process group cannot read from or -write to the controlling terminal. Attempts to do so will fail with an -@code{EIO} error. +groups}. When a process group becomes an orphan, its processes are sent a @code{SIGHUP} signal. Ordinarily, this causes the processes to @@ -1029,8 +1028,11 @@ use to open the controlling terminal. In the GNU library, it returns the same string all the time: @code{"/dev/tty"}. That is a special ``magic'' file name that refers to the controlling terminal of the -current process (if it has one). The function @code{ctermid} is -declared in the header file @file{stdio.h}. +current process (if it has one). To find the name of the specific +terminal device, use @code{ttyname}; @pxref{Is It a Terminal}. + +The function @code{ctermid} is declared in the header file +@file{stdio.h}. @pindex stdio.h @comment stdio.h diff -ruN glibc-1.08.1/manual/lang.texi glibc-1.09/manual/lang.texi --- glibc-1.08.1/manual/lang.texi Mon Feb 7 18:28:31 1994 +++ glibc-1.09/manual/lang.texi Wed Oct 5 00:29:40 1994 @@ -391,10 +391,10 @@ @comment stdarg.h @comment ANSI -@deftypefn {Macro} void va_start (va_list @var{ap}, @var{last_required}) +@deftypefn {Macro} void va_start (va_list @var{ap}, @var{last-required}) This macro initializes the argument pointer variable @var{ap} to point to the first of the optional arguments of the current function; -@var{last_required} must be the last required argument to the function. +@var{last-required} must be the last required argument to the function. @xref{Old Varargs}, for an alternate definition of @code{va_start} found in the header file @file{varargs.h}. diff -ruN glibc-1.08.1/manual/libc.texinfo glibc-1.09/manual/libc.texinfo --- glibc-1.08.1/manual/libc.texinfo Mon Aug 30 15:25:47 1993 +++ glibc-1.09/manual/libc.texinfo Mon Oct 24 01:33:35 1994 @@ -10,9 +10,11 @@ @set xref-automatic-section-title @smallbook -@set EDITION 0.05 -@set VERSION 1.07 Beta -@set UPDATED 30 August 1993 +@c I've already told people the printed edition will be 0.06 +@set EDITION 0.06 DRAFT +@set VERSION 1.09 Beta +@set UPDATED 24 October 1994 +@set ISBN 1-882114-53-1 @ifinfo This file documents the GNU C library. @@ -20,7 +22,7 @@ This is Edition @value{EDITION}, last updated @value{UPDATED}, of @cite{The GNU C Library Reference Manual}, for Version @value{VERSION}. -Copyright (C) 1993 Free Software Foundation, Inc. +Copyright (C) 1993, 1994 Free Software Foundation, Inc. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice @@ -57,7 +59,7 @@ @sp 2 @center Sandra Loosemore @center with -@center Roland McGrath, Andrew Oram, and Richard M. Stallman +@center Richard M. Stallman, Roland McGrath, and Andrew Oram @sp 3 @center Edition @value{EDITION} @sp 1 @@ -66,12 +68,13 @@ @center for version @value{VERSION} @page @vskip 0pt plus 1filll -Copyright @copyright{} 1993 Free Software Foundation, Inc. +Copyright @copyright{} 1993, 1994 Free Software Foundation, Inc. @sp 2 Published by the Free Software Foundation @* 675 Massachusetts Avenue, @* Cambridge, MA 02139 USA @* -Printed copies are available for $50 each. +Printed copies are available for $50 each. @* +ISBN @value{ISBN} @* Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice @@ -95,7 +98,9 @@ @ifinfo @node Top, Introduction, (dir), (dir) @top Main Menu -This is the reference manual for version @value{VERSION} of the GNU C Library. +This is Edition @value{EDITION}, last updated @value{UPDATED}, of +@cite{The GNU C Library Reference Manual}, for Version @value{VERSION} +of the GNU C Library. @end ifinfo @@ -132,7 +137,7 @@ * Signal Handling:: All about signals; how to send them, block them, and handle them. * Process Startup:: Writing the beginning and end of your program. -* Child Processes:: How to create processes and run other programs. +* Processes:: How to create processes and run other programs. * Job Control:: All about process groups and sessions. * Users and Groups:: How users are identified and classified. * System Information:: Getting information about the @@ -654,9 +659,9 @@ * Generating Signals:: How to send a signal to a process. * Blocking Signals:: Making the system hold signals temporarily. * Waiting for a Signal:: Suspending your program until a signal arrives. +* Signal Stack:: Using a Separate Signal Stack * BSD Signal Handling:: Additional functions for backward compatibility with BSD. -* BSD Handler:: BSD Function to Establish a Handler Basic Concepts of Signals @@ -671,8 +676,8 @@ * Alarm Signals:: Used to indicate expiration of timers. * Asynchronous I/O Signals:: Used to indicate input is available. * Job Control Signals:: Signals used to support job control. -* Miscellaneous Signals:: Miscellaneous Signals -* Nonstandard Signals:: Implementations can support other signals. +* Operation Error Signals:: Used to report operational system errors. +* Miscellaneous Signals:: Miscellaneous Signals. * Signal Messages:: Printing a message describing a signal. Specifying Signal Actions @@ -722,12 +727,8 @@ BSD Signal Handling -* POSIX vs BSD:: Comparison of BSD and POSIX signal functions. - -BSD Function to Establish a Handler - +* BSD Handler:: BSD Function to Establish a Handler. * Blocking in BSD:: BSD Functions for Blocking Signals -* Signal Stack:: Using a Separate Signal Stack Process Startup and Termination @@ -960,7 +961,7 @@ @include setjmp.texi @include signal.texi @include startup.texi -@include child.texi +@include process.texi @include job.texi @include users.texi @include sysinfo.texi diff -ruN glibc-1.08.1/manual/llio.texi glibc-1.09/manual/llio.texi --- glibc-1.08.1/manual/llio.texi Mon Feb 7 18:28:13 1994 +++ glibc-1.09/manual/llio.texi Fri Nov 4 17:16:36 1994 @@ -81,91 +81,7 @@ The @var{flags} argument controls how the file is to be opened. This is a bit mask; you create the value by the bitwise OR of the appropriate parameters (using the @samp{|} operator in C). - -The @var{flags} argument must include exactly one of these values to -specify the file access mode: - -@table @code -@comment fcntl.h -@comment POSIX.1 -@item O_RDONLY -@vindex O_RDONLY -Open the file for read access. - -@comment fcntl.h -@comment POSIX.1 -@item O_WRONLY -@vindex O_WRONLY -Open the file for write access. - -@comment fcntl.h -@comment POSIX.1 -@item O_RDWR -@vindex O_RDWR -Open the file for both reading and writing. -@end table - -The @var{flags} argument can also include any combination of these -flags: - -@table @code -@comment fcntl.h -@comment POSIX.1 -@item O_APPEND -@vindex O_APPEND -@cindex append mode (file status flag) -If set, then all @code{write} operations write the data at the end of -the file, extending it, regardless of the current file position. - -@comment fcntl.h -@comment POSIX.1 -@item O_CREAT -@vindex O_CREAT -If set, the file will be created if it doesn't already exist. -@cindex create on open (file status flag) - -@comment fcntl.h -@comment POSIX.1 -@item O_EXCL -@vindex O_EXCL -If both @code{O_CREAT} and @code{O_EXCL} are set, then @code{open} fails -if the specified file already exists. - -@comment fcntl.h -@comment POSIX.1 -@item O_NOCTTY -@vindex O_NOCTTY -If @var{filename} names a terminal device, don't make it the controlling -terminal for the process. @xref{Job Control}, for information about what -it means to be the controlling terminal. - -@comment fcntl.h -@comment POSIX.1 -@item O_NONBLOCK -@vindex O_NONBLOCK -@cindex non-blocking mode (file status flag) -This sets nonblocking mode. This option is usually only useful for -special files such as FIFOs (@pxref{Pipes and FIFOs}) and devices such -as terminals. Normally, for these files, @code{open} blocks until -the file is ``ready''. If @code{O_NONBLOCK} is set, @code{open} -returns immediately. - -The @code{O_NONBLOCK} bit also affects @code{read} and @code{write}: It -permits them to return immediately with a failure status if there is no -input immediately available (@code{read}), or if the output can't be -written immediately (@code{write}). - -@comment fcntl.h -@comment POSIX.1 -@item O_TRUNC -@vindex O_TRUNC -If the file exists and is opened for write access, truncate it to zero -length. This option is only useful for regular files, not special -files such as directories or FIFOs. -@end table - -For more information about these symbolic constants, see @ref{File -Status Flags}. +@xref{File Status Flags}, for the parameters available. The normal return value from @code{open} is a non-negative integer file descriptor. In the case of an error, a value of @code{-1} is returned @@ -198,7 +114,7 @@ (This problem cannot happen on the GNU system.) @item ENOENT -The named file does not exist, but @code{O_CREAT} is not specified. +The named file does not exist, and @code{O_CREAT} is not specified. @item ENOSPC The directory or file system that would contain the new file cannot be @@ -211,8 +127,8 @@ @item EROFS The file resides on a read-only file system and any of @code{O_WRONLY}, -@code{O_RDWR}, @code{O_CREAT}, and @code{O_TRUNC} are set in the -@var{flags} argument. +@code{O_RDWR}, and @code{O_TRUNC} are set in the @var{flags} argument, +or @code{O_CREAT} is set and the file does not already exist. @end table The @code{open} function is the underlying primitive for the @code{fopen} @@ -330,7 +246,6 @@ (@pxref{File Status Flags}), @code{read} returns immediately without reading any data, and reports this error. -@c ??? This is a change yet to be made in the library. @strong{Compatibility Note:} Most versions of BSD Unix use a different error code for this: @code{EWOULDBLOCK}. In the GNU library, @code{EWOULDBLOCK} is an alias for @code{EAGAIN}, so it doesn't matter @@ -343,6 +258,10 @@ which means it does not include terminals, since they always use separate buffers inside the kernel. +Any condition that could result in @code{EAGAIN} can instead result in a +successful @code{read} which returns fewer bytes than requested. +Calling @code{read} again immediately would result in @code{EAGAIN}. + @item EBADF The @var{filedes} argument is not a valid file descriptor. @@ -372,7 +291,7 @@ @deftypefun ssize_t write (int @var{filedes}, const void *@var{buffer}, size_t @var{size}) The @code{write} function writes up to @var{size} bytes from @var{buffer} to the file with descriptor @var{filedes}. The data in -@var{buffer} is not necessarily a character string and a null character +@var{buffer} is not necessarily a character string and a null character is output like any other character. The return value is the number of bytes actually written. This is @@ -392,7 +311,6 @@ flow control, where output has been suspended by receipt of a STOP character. -@c ??? This is a change yet to be made in the library. @strong{Compatibility Note:} Most versions of BSD Unix use a different error code for this: @code{EWOULDBLOCK}. In the GNU library, @code{EWOULDBLOCK} is an alias for @code{EAGAIN}, so it doesn't matter @@ -419,13 +337,6 @@ For many devices, and for disk files, this error code indicates a hardware error. -@code{EIO} also occurs when a background process tries to write to the -controlling terminal, and the normal action of stopping the process by -sending it a @code{SIGTTOU} signal isn't working. This might happen if -the signal is being blocked or ignored. @xref{Job Control}, for more -information about job control, and @ref{Signal Handling}, for -information about signals. - @item ENOSPC The device is full. @@ -500,8 +411,9 @@ You can set the file position past the current end of the file. This does not by itself make the file longer; @code{lseek} never changes the -file. But subsequent output at that position will extend the file's -size. +file. But subsequent output at that position will extend the file. +Characters between the previous end of file and the new position +are filled with zeros. If the file position cannot be changed, or the operation is in some way invalid, @code{lseek} returns a value of @code{-1}. The following @@ -580,8 +492,8 @@ In the GNU system, this is equivalent to @code{fpos_t} or @code{long int}. @end deftp -These three aliases for the @samp{SEEK_@dots{}} constants exist for the -sake of compatibility with older BSD systems. They are defined in two +These aliases for the @samp{SEEK_@dots{}} constants exist for the sake +of compatibility with older BSD systems. They are defined in two different header files: @file{fcntl.h} and @file{sys/file.h}. @table @code @@ -626,8 +538,6 @@ (for example, if the modes for the file indicated by the file descriptor do not permit the access specified by the @var{opentype} argument), a null pointer is returned instead. -@c ??? The library does not currently detect the mismatch. -@c ??? It ought to. It can check the descriptor using fcntl F_GETFL. @end deftypefun For an example showing the use of the @code{fdopen} function, @@ -838,10 +748,16 @@ A better solution is to use the @code{select} function. This blocks the program until input or output is ready on a specified set of file -descriptors, or until timer expires, whichever comes first. This +descriptors, or until a timer expires, whichever comes first. This facility is declared in the header file @file{sys/types.h}. @pindex sys/types.h +In the case of a server socket (@pxref{Listening}), we say that +``input'' is available when there are pending connections that could be +accepted (@pxref{Accepting Connections}). @code{accept} for server +sockets blocks and interacts with @code{select} just as @code{read} does +for normal input. + @cindex file descriptor sets, for @code{select} The file descriptor sets for the @code{select} function are specified as @code{fd_set} objects. Here is the description of the data type @@ -863,7 +779,6 @@ some systems, including GNU, there is no absolute limit on the number of descriptors open, but this macro still has a constant value which controls the number of bits in an @code{fd_set}. -@c ??? xref needed here to setrlimit once we document that. @end deftypevr @comment sys/types.h @@ -896,18 +811,18 @@ @comment sys/types.h @comment BSD -@deftypefun int select (int @var{nfds}, fd_set *@var{read_fds}, fd_set *@var{write_fds}, fd_set *@var{except_fds}, struct timeval *@var{timeout}) +@deftypefun int select (int @var{nfds}, fd_set *@var{read-fds}, fd_set *@var{write-fds}, fd_set *@var{except-fds}, struct timeval *@var{timeout}) The @code{select} function blocks the calling process until there is activity on any of the specified sets of file descriptors, or until the timeout period has expired. -The file descriptors specified by the @var{read_fds} argument are -checked to see if they are ready for reading; the @var{write_fds} file -descriptors are checked to see if they are ready for writing; and the -@var{except_fds} file descriptors are checked for exceptional -conditions. You can pass a null pointer for any of these arguments if -you are not interested in checking for that kind of condition. - +The file descriptors specified by the @var{read-fds} argument are +checked to see if they are ready for reading (or if a server socket, for +accepting a connection); the @var{write-fds} file descriptors are +checked to see if they are ready for writing; and the @var{except-fds} +file descriptors are checked for exceptional conditions. You can pass a +null pointer for any of these arguments if you are not interested in +checking for that kind of condition. ``Exceptional conditions'' does not mean errors---errors are reported immediately when an erroneous system call is executed, and do not constitute a state of the descriptor. Rather, they include conditions @@ -930,7 +845,7 @@ descriptors in all of the sets. Each of the argument sets is overwritten with information about the descriptors that are ready for the corresponding operation. Thus, to see if a particular descriptor @var{desc} has input, -use @code{FD_ISSET (@var{desc}, @var{read_fds})} after @code{select} returns. +use @code{FD_ISSET (@var{desc}, @var{read-fds})} after @code{select} returns. If @code{select} returns because the timeout period expires, it returns a value of zero. @@ -1107,10 +1022,10 @@ The form of the call in this case is: @smallexample -fcntl (@var{old}, F_DUPFD, @var{next_filedes}) +fcntl (@var{old}, F_DUPFD, @var{next-filedes}) @end smallexample -The @var{next_filedes} argument is of type @code{int} and specifies that +The @var{next-filedes} argument is of type @code{int} and specifies that the file descriptor returned should be the next available one greater than or equal to this value. @@ -1124,13 +1039,13 @@ The @var{old} argument is invalid. @item EINVAL -The @var{next_filedes} argument is invalid. +The @var{next-filedes} argument is invalid. @item EMFILE There are no more file descriptors available---your program is already -using the maximum. -@c !!! in GNU and 4.4, this can be fixed with setrlimit RLIM_OFILES; -@c xref to there. +using the maximum. In BSD and GNU, the maximum is controlled by a +resource limit that can be changed; @pxref{Limits on Resources}, for +more information about the @code{RLIMIT_NOFILE} limit. @end table @code{ENFILE} is not a possible error code for @code{dup2} because @@ -1218,7 +1133,7 @@ specify the new flags, so the form of the call is: @smallexample -fcntl (@var{filedes}, F_SETFD, @var{new_flags}) +fcntl (@var{filedes}, F_SETFD, @var{new-flags}) @end smallexample The normal return value from @code{fcntl} with this command is an @@ -1275,115 +1190,372 @@ @section File Status Flags @cindex file status flags -@dfn{File status flags} are used to specify attributes of the opening of -a file. Unlike the file descriptor flags discussed in @ref{Descriptor +@dfn{File status flags} are used to specify attributes of the opening of a +file. Unlike the file descriptor flags discussed in @ref{Descriptor Flags}, the file status flags are shared by duplicated file descriptors -resulting from a single opening of the file. +resulting from a single opening of the file. The file status flags are +specified with the @var{flags} argument to @code{open}; +@pxref{Opening and Closing Files}. + +File status flags fall into three categories, which are described in the +following sections. -The file status flags are initialized by the @code{open} function from -the @var{flags} argument of the @code{open} function. Some of the flags -are meaningful only in @code{open} and are not remembered subsequently; -many of the rest cannot subsequently be changed, though you can read -their values by examining the file status flags. +@itemize @bullet +@item +@ref{Access Modes}, specify what type of access is allowed to the +file: reading, writing, or both. They are set by @code{open} and are +returned by @code{fcntl}, but cannot be changed. -A few file status flags can be changed at any time using @code{fcntl}. -These include @code{O_APPEND} and @code{O_NONBLOCK}. +@item +@ref{Open-time Flags}, control details of what @code{open} will do. +These flags are not preserved after the @code{open} call. + +@item +@ref{Operating Modes}, affect how operations such as @code{read} and +@code{write} are done. They are set by @code{open}, and can be fetched or +changed with @code{fcntl}. +@end itemize The symbols in this section are defined in the header file @file{fcntl.h}. @pindex fcntl.h +@menu +* Access Modes:: Whether the descriptor can read or write. +* Open-time Flags:: Details of @code{open}. +* Operating Modes:: Special modes to control I/O operations. +* Getting File Status Flags:: Fetching and changing these flags. +@end menu + +@node Access Modes +@subsection File Access Modes + +The file access modes allow a file descriptor to be used for reading, +writing, or both. (In the GNU system, they can also allow none of these, +and allow execution of the file as a program.) The access modes are chosen +when the file is opened, and never change. + @comment fcntl.h @comment POSIX.1 -@deftypevr Macro int F_GETFL -This macro is used as the @var{command} argument to @code{fcntl}, to -read the file status flags for the open file with descriptor -@var{filedes}. +@deftypevr Macro int O_RDONLY +Open the file for read access. +@end deftypevr -The normal return value from @code{fcntl} with this command is a -nonnegative number which can be interpreted as the bitwise OR of the -individual flags. The flags are encoded like the @var{flags} argument -to @code{open} (@pxref{Opening and Closing Files}), but only the file -access modes and the @code{O_APPEND} and @code{O_NONBLOCK} flags are -meaningful here. Since the file access modes are not single-bit values, -you can mask off other bits in the returned flags with @code{O_ACCMODE} -to compare them. +@comment fcntl.h +@comment POSIX.1 +@deftypevr Macro int O_WRONLY +Open the file for write access. +@end deftypevr -In case of an error, @code{fcntl} returns @code{-1}. The following -@code{errno} error conditions are defined for this command: +@comment fcntl.h +@comment POSIX.1 +@deftypevr Macro int O_RDWR +Open the file for both reading and writing. +@end deftypevr -@table @code -@item EBADF -The @var{filedes} argument is invalid. -@end table +In the GNU system (and not in other systems), @code{O_RDONLY} and +@code{O_WRONLY} are independent bits that can be bitwise-ORed together, +and it is valid for either bit to be set or clear. This means that +@code{O_RDWR} is the same as @code{O_RDONLY|O_WRONLY}. A file access +mode of zero is permissible; it allows no operations that do input or +output to the file, but does allow other operations such as +@code{fchmod}. On the GNU system, since ``read-only'' or ``write-only'' +is a misnomer, @file{fcntl.h} defines additional names for the file +access modes. These names are preferred when writing GNU-specific code. +But most programs will want to be portable to other POSIX.1 systems and +should use the POSIX.1 names above instead. + +@comment fcntl.h +@comment GNU +@deftypevr Macro int O_READ +Open the file for reading. Same as @code{O_RDWR}; only defined on GNU. +@end deftypevr + +@comment fcntl.h +@comment GNU +@deftypevr Macro int O_WRITE +Open the file for reading. Same as @code{O_WRONLY}; only defined on GNU. @end deftypevr @comment fcntl.h +@comment GNU +@deftypevr Macro int O_EXEC +Open the file for executing. Only defined on GNU. +@end deftypevr + +To determine the file access mode with @code{fcntl}, you must extract +the access mode bits from the retrieved file status flags. In the GNU +system, you can just test the @code{O_READ} and @code{O_WRITE} bits in +the flags word. But in other POSIX.1 systems, reading and writing +access modes are not stored as distinct bit flags. The portable way to +extract the file access mode bits is with @code{O_ACCMODE}. + +@comment fcntl.h @comment POSIX.1 -@deftypevr Macro int F_SETFL -This macro is used as the @var{command} argument to @code{fcntl}, to set -the file status flags for the open file corresponding to the -@var{filedes} argument. This command requires a third @code{int} -argument to specify the new flags, so the call looks like this: +@deftypevr Macro int O_ACCMODE +This macro stands for a mask that can be bitwise-ANDed with the file +status flag value to produce a value representing the file access mode. +The mode will be @code{O_RDONLY}, @code{O_WRONLY}, or @code{O_RDWR}. +(In the GNU system it could also be zero.) +@end deftypevr -@smallexample -fcntl (@var{filedes}, F_SETFL, @var{new_flags}) -@end smallexample +@node Open-time Flags +@subsection Open-time Flags -You can't change the access mode for the file in this way; that is, -whether the file descriptor was opened for reading or writing. You can -only change the @code{O_APPEND} and @code{O_NONBLOCK} flags. +The open-time flags specify options affecting how @code{open} will behave. +These options are not preserved once the file is open. The exception to +this is @code{O_NONBLOCK}, which is also an I/O operating mode and so it +@emph{is} saved. @xref{Opening and Closing Files}, for how to call +@code{open}. -The normal return value from @code{fcntl} with this command is an -unspecified value other than @code{-1}, which indicates an error. The -error conditions are the same as for the @code{F_GETFL} command. +There are two sorts of options specified by open-time flags. + +@itemize @bullet +@item +@dfn{File name translation flags} affect how @code{open} looks up the +file name to locate the file, and whether the file can be created. +@cindex file name translation flags +@cindex flags, file name translation + +@item +@dfn{Open-time action flags} specify extra operations that @code{open} will +perform on the file once it is open. +@cindex open-time action flags +@cindex flags, open-time action +@end itemize + +Here are the file name translation flags. + +@comment fcntl.h +@comment POSIX.1 +@deftypevr Macro int O_CREAT +If set, the file will be created if it doesn't already exist. +@cindex create on open (file status flag) @end deftypevr -The following macros are defined for use in analyzing and constructing -file status flag values: +@comment fcntl.h +@comment POSIX.1 +@deftypevr Macro int O_EXCL +If both @code{O_CREAT} and @code{O_EXCL} are set, then @code{open} fails +if the specified file already exists. This is guaranteed to never +clobber an existing file. +@end deftypevr @comment fcntl.h @comment POSIX.1 -@table @code -@item O_APPEND +@deftypevr Macro int O_NONBLOCK +@cindex non-blocking open +This prevents @code{open} from blocking for a ``long time'' to open the +file. This is only meaningful for some kinds of files, usually devices +such as serial ports. Often opening a port to a modem blocks until the +modem reports carrier detection; if @code{O_NONBLOCK} is specified, +@code{open} will return immediately without a carrier. + +Note that the @code{O_NONBLOCK} flag is overloaded as both an I/O operating +mode and a file name translation flag. This means that specifying +@code{O_NONBLOCK} in @code{open} also sets nonblocking I/O mode; +@pxref{Operating Modes}. To open the file without blocking but do normal +I/O that blocks, you must call @code{open} with @code{O_NONBLOCK} set and +then call @code{fcntl} to turn the bit off. +@end deftypevr + +@comment fcntl.h +@comment POSIX.1 +@deftypevr Macro int O_NOCTTY +If the named file is a terminal device, don't make it the controlling +terminal for the process. @xref{Job Control}, for information about +what it means to be the controlling terminal. In the GNU system and 4.4 +BSD, opening a file never makes it the controlling terminal and +@code{O_NOCTTY} is zero. +@cindex controlling terminal, setting +@end deftypevr + +These three file name translation flags exist only in the GNU system. + +@comment fcntl.h +@comment GNU +@deftypevr Macro int O_IGNORE_CTTY +Do not recognize the named file as the controlling terminal, even if it +refers to the process's existing controlling terminal device. Operations +on the new file descriptor will never induce job control signals. +@xref{Job Control}. +@end deftypevr + +@comment fcntl.h +@comment GNU +@deftypevr Macro int O_NOLINK +If the named file is a symbolic link, open the link itself instead of +the file it refers to. (@code{fstat} on the new file descriptor will +return the information returned by @code{lstat} on the link's name.) +@cindex symbolic link, opening +@end deftypevr + +@comment fcntl.h +@comment GNU +@deftypevr Macro int O_NOTRANS +If the named file is specially translated, do not invoke the translator. +Open the bare file the translator itself sees. +@end deftypevr + + +The open-time action flags tell @code{open} to do additional operations +which are not really related to opening the file. The reason to do them +as part of @code{open} instead of in separate calls is that @code{open} +can do them @i{atomically}. + +@comment fcntl.h +@comment POSIX.1 +@deftypevr Macro int O_TRUNC +Truncate the file to zero length. This option is only useful for +regular files, not special files such as directories or FIFOs. POSIX.1 +requires that you open the file for writing to use @code{O_TRUNC}. In +BSD and GNU you must have permission to write the file to truncate it, +but you need not open for write access. + +This is the only open-time action flag specified by POSIX.1. There is +no good reason for truncation to be done by @code{open}, instead of by +calling @code{ftruncate} afterwards. The @code{O_TRUNC} flag existed in +Unix before @code{ftruncate} was invented, and is retained for backward +compatibility. +@end deftypevr + +@comment fcntl.h +@comment BSD +@deftypevr Macro int O_SHLOCK +Acquire a shared lock on the file, as with @code{flock}. +@xref{File Locks}. + +If @code{O_CREAT} is specified, the locking is done atomically when +creating the file. You are guaranteed that no other process will get +the lock on the new file first. +@end deftypevr + +@comment fcntl.h +@comment BSD +@deftypevr Macro int O_EXLOCK +Acquire an exclusive lock on the file, as with @code{flock}. +@xref{File Locks}. This is atomic like @code{O_SHLOCK}. +@end deftypevr + +@node Operating Modes +@subsection I/O Operating Modes + +The operating modes affect how input and output operations using a file +descriptor work. These flags are set by @code{open} and can be fetched +and changed with @code{fcntl}. + +@comment fcntl.h +@comment POSIX.1 +@deftypevr Macro int O_APPEND The bit that enables append mode for the file. If set, then all @code{write} operations write the data at the end of the file, extending it, regardless of the current file position. +@end deftypevr @comment fcntl.h @comment POSIX.1 -@item O_NONBLOCK +@deftypevr O_NONBLOCK The bit that enables nonblocking mode for the file. If this bit is set, @code{read} requests on the file can return immediately with a failure status if there is no input immediately available, instead of blocking. Likewise, @code{write} requests can also return immediately with a failure status if the output can't be written immediately. +Note that the @code{O_NONBLOCK} flag is overloaded as both an I/O +operating mode and a file name translation flag; @pxref{Open-time Flags}. +@end deftypevr + @comment fcntl.h @comment BSD -@item O_NDELAY -This is a synonym for @code{O_NONBLOCK}, provided for compatibility with -BSD. -@end table +@deftypevr Macro int O_NDELAY +This is an obsolete name for @code{O_NONBLOCK}, provided for +compatibility with BSD. It is not defined by the POSIX.1 standard. +@end deftypevr + +The remaining operating modes are BSD and GNU extensions. They exist only +on some systems. On other systems, these macros are not defined. @comment fcntl.h -@comment POSIX.1 -@deftypevr Macro int O_ACCMODE -This macro stands for a mask that can be bitwise-ANDed with the file -status flag value to produce a value representing the file access mode. -The mode will be @code{O_RDONLY}, @code{O_WRONLY}, or @code{O_RDWR}. +@comment BSD +@deftypevr Macro int O_ASYNC +The bit that enables asynchronous input mode. If set, then @code{SIGIO} +signals will be generated when input is available. @xref{Interrupt Input}. + +Asynchronous input mode is a BSD feature. @end deftypevr -@table @code -@item O_RDONLY -Open the file for read access. +@comment fcntl.h +@comment BSD +@deftypevr Macro int O_FSYNC +The bit that enables synchronous writing for the file. If set, each +@code{write} call will make sure the data is reliably stored on disk before +returning. @c !!! xref fsync -@item O_WRONLY -Open the file for write access. +Synchronous writing is a BSD feature. +@end deftypevr -@item O_RDWR -Open the file for both reading and writing. +@comment fcntl.h +@comment BSD +@deftypevr Macro int O_SYNC +This is another name for @code{O_FSYNC}. They have the same value. +@end deftypevr + +@comment fcntl.h +@comment GNU +@deftypevr Macro int O_NOATIME +If this bit is set, @code{read} will not update the access time of the +file. @xref{File Times}. This is used by programs that do backups, so +that backing a file up does not count as reading it. + +This is a GNU extension. +@end deftypevr + +@node Getting File Status Flags +@subsection Getting and Setting File Status Flags + +The @code{fcntl} function can fetch or change file status flags. + +@comment fcntl.h +@comment POSIX.1 +@deftypevr Macro int F_GETFL +This macro is used as the @var{command} argument to @code{fcntl}, to +read the file status flags for the open file with descriptor +@var{filedes}. + +The normal return value from @code{fcntl} with this command is a +nonnegative number which can be interpreted as the bitwise OR of the +individual flags. Since the file access modes are not single-bit values, +you can mask off other bits in the returned flags with @code{O_ACCMODE} +to compare them. + +In case of an error, @code{fcntl} returns @code{-1}. The following +@code{errno} error conditions are defined for this command: + +@table @code +@item EBADF +The @var{filedes} argument is invalid. @end table +@end deftypevr + +@comment fcntl.h +@comment POSIX.1 +@deftypevr Macro int F_SETFL +This macro is used as the @var{command} argument to @code{fcntl}, to set +the file status flags for the open file corresponding to the +@var{filedes} argument. This command requires a third @code{int} +argument to specify the new flags, so the call looks like this: + +@smallexample +fcntl (@var{filedes}, F_SETFL, @var{new-flags}) +@end smallexample + +You can't change the access mode for the file in this way; that is, +whether the file descriptor was opened for reading or writing. + +The normal return value from @code{fcntl} with this command is an +unspecified value other than @code{-1}, which indicates an error. The +error conditions are the same as for the @code{F_GETFL} command. +@end deftypevr If you want to modify the file status flags, you should get the current flags with @code{F_GETFL} and modify the value. Don't assume that the @@ -1403,8 +1575,8 @@ @{ int oldflags = fcntl (desc, F_GETFL, 0); /* @r{If reading the flags failed, return error indication now.} */ - if (oldflags < 0) - return oldflags; + if (oldflags == -1) + return -1; /* @r{Set just the flag we want to set.} */ if (value != 0) oldflags |= O_NONBLOCK; @@ -1583,6 +1755,13 @@ limitation on the number of locks. However, you must still take account of the possibility of this error, as it could result from network access to a file system on another machine. + +@item EDEADLK +The specified region is being locked by another process. But that +process is waiting to lock a region which the current process has +locked, so waiting for the lock would result in deadlock. The system +does not guarantee that it will detect all such conditions, but it lets +you know if it notices one. @end table @end deftypevr @@ -1664,14 +1843,16 @@ @section Interrupt-Driven Input @cindex interrupt-driven input -If you set the @code{FASYNC} status flag on a file descriptor +If you set the @code{O_ASYNC} status flag on a file descriptor (@pxref{File Status Flags}), a @code{SIGIO} signal is sent whenever input or output becomes possible on that file descriptor. The process or process group to receive the signal can be selected by using the @code{F_SETOWN} command to the @code{fcntl} function. If the file descriptor is a socket, this also selects the recipient of @code{SIGURG} signals that are delivered when out-of-band data arrives on that socket; -see @ref{Out-of-Band Data}. +see @ref{Out-of-Band Data}. (@code{SIGURG} is sent in any situation +where @code{select} would report the socket as having an ``exceptional +condition''. @xref{Waiting for I/O}.) If the file descriptor corresponds to a terminal device, then @code{SIGIO} signals are sent to the foreground process group of the terminal. diff -ruN glibc-1.08.1/manual/maint.texi glibc-1.09/manual/maint.texi --- glibc-1.08.1/manual/maint.texi Thu May 19 16:17:11 1994 +++ glibc-1.09/manual/maint.texi Sun Nov 6 22:00:02 1994 @@ -48,12 +48,18 @@ alpha-dec-osf1 i386-@var{anything}-bsd4.3 i386-@var{anything}-gnu +i386-@var{anything}-isc2.2 +i386-@var{anything}-isc3.@var{n} i386-@var{anything}-sco3.2 i386-@var{anything}-sco3.2v4 i386-@var{anything}-sysv i386-@var{anything}-sysv4 +i386-force_cpu386-none i386-sequent-bsd +i960-nindy960-none m68k-hp-bsd4.3 +m68k-mvme135-none +m68k-mvme136-none m68k-sony-newsos3 m68k-sony-newsos4 m68k-sun-sunos4.@var{n} @@ -153,6 +159,17 @@ from @file{Makeconfig} to your new @file{configparms} file, and change the value as appropriate for your system. +It is easy to configure the GNU C library for cross-compilation by +setting a few variables in @file{configparms}. Set @code{CC} to the +cross-compiler for the target you configured the library for; it is +important to use this same @code{CC} value when running +@code{configure}, like this: @samp{CC=@var{target}-gcc configure +@var{target}}. Set @code{BUILD_CC} to the compiler to use for for +programs run on the build system as part of compiling the library. You +may need to set @code{AR} and @code{RANLIB} to cross-compiling versions +of @code{ar} and @code{ranlib} if the native tools are not configured to +work with object files for the target you configured for. + Some of the machine-dependent code for some machines uses extensions in the GNU C compiler, so you may need to compile the library with GCC. (In fact, all of the existing complete ports require GCC.) @@ -212,6 +229,7 @@ @node Reporting Bugs @appendixsec Reporting Bugs @cindex reporting bugs +@cindex bugs, reporting There are probably bugs in the GNU C library. There are certainly errors and omissions in this manual. If you report them, they will get @@ -939,6 +957,10 @@ @item The port to SGI machines running Irix 4 (@code{mips-sgi-irix4}) was contributed by Tom Quinn. + +@item +The port of the Mach and Hurd code to the MIPS architecture +(@code{mips-@var{anything}-gnu}) was contribued by Kazumoto Kojima. @end itemize @c @bye diff -ruN glibc-1.08.1/manual/memory.texi glibc-1.09/manual/memory.texi --- glibc-1.08.1/manual/memory.texi Wed Feb 9 08:56:10 1994 +++ glibc-1.09/manual/memory.texi Wed Oct 26 03:24:33 1994 @@ -75,10 +75,10 @@ @itemize @bullet @item -@dfn{Static allocation} is what happens when you declare a static -variable. Each static variable defines one block of space, of a fixed -size. The space is allocated once, when your program is started, and -is never freed. +@dfn{Static allocation} is what happens when you declare a static or +global variable. Each static or global variable defines one block of +space, of a fixed size. The space is allocated once, when your program +is started, and is never freed. @item @dfn{Automatic allocation} happens when you declare an automatic @@ -490,14 +490,17 @@ @comment malloc.h @comment GNU -@deftypefun int mcheck (void (*@var{abortfn}) (void)) +@deftypefun int mcheck (void (*@var{abortfn}) (enum mcheck_status @var{status})) Calling @code{mcheck} tells @code{malloc} to perform occasional consistency checks. These will catch things such as writing past the end of a block that was allocated with @code{malloc}. The @var{abortfn} argument is the function to call when an inconsistency -is found. If you supply a null pointer, the @code{abort} function is -used. +is found. If you supply a null pointer, then @code{mcheck} uses a +default function which prints a message and calls @code{abort} +(@pxref{Aborting a Program}). The function you supply is called with +one argument, which says what sort of inconsistency was detected; its +type is described below. It is too late to begin allocation checking once you have allocated anything with @code{malloc}. So @code{mcheck} does nothing in that @@ -509,6 +512,41 @@ need to modify your program source at all. @end deftypefun +@deftypefun {enum mcheck_status} mprobe (void *@var{pointer}) +The @code{mprobe} function lets you explicitly check for inconsistencies +in a particular allocated block. You must have already called +@code{mcheck} at the beginning of the program, to do its occasional +checks; calling @code{mprobe} requests an additional consistency check +to be done at the time of the call. + +The argument @var{pointer} must be a pointer returned by @code{malloc} +or @code{realloc}. @code{mprobe} returns a value that says what +inconsistency, if any, was found. The values are described below. +@end deftypefun + +@deftp {Data Type} {enum mcheck_status} +This enumerated type describes what kind of inconsistency was detected +in an allocated block, if any. Here are the possible values: + +@table @code +@item MCHECK_DISABLED +@code{mcheck} was not called before the first allocation. +No consistency checking can be done. +@item MCHECK_OK +No inconsistency detected. +@item MCHECK_HEAD +The data immediately before the block was modified. +This commonly happens when an array index or pointer +is decremented too far. +@item MCHECK_TAIL +The data immediately after the block was modified. +This commonly happens when an array index or pointer +is incremented too far. +@item MCHECK_FREE +The block was already freed. +@end table +@end deftp + @node Hooks for Malloc @subsection Storage Allocation Hooks @cindex allocation hooks, for @code{malloc} @@ -777,10 +815,11 @@ @findex obstack_chunk_free Also, if the source file uses the macro @code{obstack_init}, it must declare or define two functions or macros that will be called by the -obstack library. One, @code{obstack_chunk_alloc}, is used to allocate the -chunks of memory into which objects are packed. The other, +obstack library. One, @code{obstack_chunk_alloc}, is used to allocate +the chunks of memory into which objects are packed. The other, @code{obstack_chunk_free}, is used to return chunks when the objects in -them are freed. +them are freed. These macros should appear before any use of obstacks +in the source file. Usually these are defined to use @code{malloc} via the intermediary @code{xmalloc} (@pxref{Unconstrained Allocation}). This is done with @@ -802,8 +841,8 @@ @comment obstack.h @comment GNU -@deftypefun int obstack_init (struct obstack *@var{obstack_ptr}) -Initialize obstack @var{obstack_ptr} for allocation of objects. This +@deftypefun int obstack_init (struct obstack *@var{obstack-ptr}) +Initialize obstack @var{obstack-ptr} for allocation of objects. This function calls the obstack's @code{obstack_chunk_alloc} function. It returns 0 if @code{obstack_chunk_alloc} returns a null pointer, meaning that it is out of memory. Otherwise, it returns 1. If you supply an @@ -841,12 +880,12 @@ @comment obstack.h @comment GNU -@deftypefun {void *} obstack_alloc (struct obstack *@var{obstack_ptr}, size_t @var{size}) +@deftypefun {void *} obstack_alloc (struct obstack *@var{obstack-ptr}, int @var{size}) This allocates an uninitialized block of @var{size} bytes in an obstack -and returns its address. Here @var{obstack_ptr} specifies which obstack +and returns its address. Here @var{obstack-ptr} specifies which obstack to allocate the block in; it is the address of the @code{struct obstack} object which represents the obstack. Each obstack function or macro -requires you to specify an @var{obstack_ptr} as the first argument. +requires you to specify an @var{obstack-ptr} as the first argument. This function calls the obstack's @code{obstack_chunk_alloc} function if it needs to allocate a new chunk of memory; it returns a null pointer if @@ -879,7 +918,7 @@ @comment obstack.h @comment GNU -@deftypefun {void *} obstack_copy (struct obstack *@var{obstack_ptr}, void *@var{address}, size_t @var{size}) +@deftypefun {void *} obstack_copy (struct obstack *@var{obstack-ptr}, void *@var{address}, int @var{size}) This allocates a block and initializes it by copying @var{size} bytes of data starting at @var{address}. It can return a null pointer under the same conditions as @code{obstack_alloc}. @@ -887,7 +926,7 @@ @comment obstack.h @comment GNU -@deftypefun {void *} obstack_copy0 (struct obstack *@var{obstack_ptr}, void *@var{address}, size_t @var{size}) +@deftypefun {void *} obstack_copy0 (struct obstack *@var{obstack-ptr}, void *@var{address}, int @var{size}) Like @code{obstack_copy}, but appends an extra byte containing a null character. This extra byte is not counted in the argument @var{size}. @end deftypefun @@ -898,7 +937,7 @@ @smallexample char * -obstack_savestring (char *addr, size_t size) +obstack_savestring (char *addr, int size) @{ return obstack_copy0 (&myobstack, addr, size); @} @@ -919,7 +958,7 @@ @comment obstack.h @comment GNU -@deftypefun void obstack_free (struct obstack *@var{obstack_ptr}, void *@var{object}) +@deftypefun void obstack_free (struct obstack *@var{obstack-ptr}, void *@var{object}) If @var{object} is a null pointer, everything allocated in the obstack is freed. Otherwise, @var{object} must be the address of an object allocated in the obstack. Then @var{object} is freed, along with @@ -1024,14 +1063,14 @@ @comment obstack.h @comment GNU -@deftypefun void obstack_blank (struct obstack *@var{obstack_ptr}, size_t @var{size}) +@deftypefun void obstack_blank (struct obstack *@var{obstack-ptr}, int @var{size}) The most basic function for adding to a growing object is @code{obstack_blank}, which adds space without initializing it. @end deftypefun @comment obstack.h @comment GNU -@deftypefun void obstack_grow (struct obstack *@var{obstack_ptr}, void *@var{data}, size_t @var{size}) +@deftypefun void obstack_grow (struct obstack *@var{obstack-ptr}, void *@var{data}, int @var{size}) To add a block of initialized space, use @code{obstack_grow}, which is the growing-object analogue of @code{obstack_copy}. It adds @var{size} bytes of data to the growing object, copying the contents from @@ -1040,7 +1079,7 @@ @comment obstack.h @comment GNU -@deftypefun void obstack_grow0 (struct obstack *@var{obstack_ptr}, void *@var{data}, size_t @var{size}) +@deftypefun void obstack_grow0 (struct obstack *@var{obstack-ptr}, void *@var{data}, int @var{size}) This is the growing-object analogue of @code{obstack_copy0}. It adds @var{size} bytes copied from @var{data}, followed by an additional null character. @@ -1048,14 +1087,14 @@ @comment obstack.h @comment GNU -@deftypefun void obstack_1grow (struct obstack *@var{obstack_ptr}, char @var{c}) +@deftypefun void obstack_1grow (struct obstack *@var{obstack-ptr}, char @var{c}) To add one character at a time, use the function @code{obstack_1grow}. It adds a single byte containing @var{c} to the growing object. @end deftypefun @comment obstack.h @comment GNU -@deftypefun {void *} obstack_finish (struct obstack *@var{obstack_ptr}) +@deftypefun {void *} obstack_finish (struct obstack *@var{obstack-ptr}) When you are finished growing the object, use the function @code{obstack_finish} to close it off and return its final address. @@ -1074,7 +1113,7 @@ @comment obstack.h @comment GNU -@deftypefun size_t obstack_object_size (struct obstack *@var{obstack_ptr}) +@deftypefun int obstack_object_size (struct obstack *@var{obstack-ptr}) This function returns the current size of the growing object, in bytes. Remember to call this function @emph{before} finishing the object. After it is finished, @code{obstack_object_size} will return zero. @@ -1117,7 +1156,7 @@ @comment obstack.h @comment GNU -@deftypefun size_t obstack_room (struct obstack *@var{obstack_ptr}) +@deftypefun int obstack_room (struct obstack *@var{obstack-ptr}) This returns the number of bytes that can be added safely to the current growing object (or to an object about to be started) in obstack @var{obstack} using the fast growth functions. @@ -1128,16 +1167,16 @@ @comment obstack.h @comment GNU -@deftypefun void obstack_1grow_fast (struct obstack *@var{obstack_ptr}, char @var{c}) +@deftypefun void obstack_1grow_fast (struct obstack *@var{obstack-ptr}, char @var{c}) The function @code{obstack_1grow_fast} adds one byte containing the -character @var{c} to the growing object in obstack @var{obstack_ptr}. +character @var{c} to the growing object in obstack @var{obstack-ptr}. @end deftypefun @comment obstack.h @comment GNU -@deftypefun void obstack_blank_fast (struct obstack *@var{obstack_ptr}, size_t @var{size}) +@deftypefun void obstack_blank_fast (struct obstack *@var{obstack-ptr}, int @var{size}) The function @code{obstack_blank_fast} adds @var{size} bytes to the -growing object in obstack @var{obstack_ptr} without initializing them. +growing object in obstack @var{obstack-ptr} without initializing them. @end deftypefun When you check for space using @code{obstack_room} and there is not @@ -1156,7 +1195,7 @@ @smallexample @group void -add_string (struct obstack *obstack, char *ptr, size_t len) +add_string (struct obstack *obstack, char *ptr, int len) @{ while (len > 0) @{ @@ -1189,9 +1228,9 @@ @comment obstack.h @comment GNU -@deftypefun {void *} obstack_base (struct obstack *@var{obstack_ptr}) +@deftypefun {void *} obstack_base (struct obstack *@var{obstack-ptr}) This function returns the tentative address of the beginning of the -currently growing object in @var{obstack_ptr}. If you finish the object +currently growing object in @var{obstack-ptr}. If you finish the object immediately, it will have that address. If you make it larger first, it may outgrow the current chunk---then its address will change! @@ -1202,21 +1241,21 @@ @comment obstack.h @comment GNU -@deftypefun {void *} obstack_next_free (struct obstack *@var{obstack_ptr}) +@deftypefun {void *} obstack_next_free (struct obstack *@var{obstack-ptr}) This function returns the address of the first free byte in the current -chunk of obstack @var{obstack_ptr}. This is the end of the currently +chunk of obstack @var{obstack-ptr}. This is the end of the currently growing object. If no object is growing, @code{obstack_next_free} returns the same value as @code{obstack_base}. @end deftypefun @comment obstack.h @comment GNU -@deftypefun size_t obstack_object_size (struct obstack *@var{obstack_ptr}) +@deftypefun int obstack_object_size (struct obstack *@var{obstack-ptr}) This function returns the size in bytes of the currently growing object. This is equivalent to @smallexample -obstack_next_free (@var{obstack_ptr}) - obstack_base (@var{obstack_ptr}) +obstack_next_free (@var{obstack-ptr}) - obstack_base (@var{obstack-ptr}) @end smallexample @end deftypefun @@ -1234,7 +1273,7 @@ @comment obstack.h @comment GNU -@deftypefn Macro int obstack_alignment_mask (struct obstack *@var{obstack_ptr}) +@deftypefn Macro int obstack_alignment_mask (struct obstack *@var{obstack-ptr}) The value is a bit mask; a bit that is 1 indicates that the corresponding bit in the address of an object should be 0. The mask value should be one less than a power of 2; the effect is that all object addresses are @@ -1299,7 +1338,7 @@ @comment obstack.h @comment GNU -@deftypefn Macro size_t obstack_chunk_size (struct obstack *@var{obstack_ptr}) +@deftypefn Macro int obstack_chunk_size (struct obstack *@var{obstack-ptr}) This returns the chunk size of the given obstack. @end deftypefn @@ -1312,8 +1351,8 @@ is how to do so cleanly: @smallexample -if (obstack_chunk_size (obstack_ptr) < @var{new_chunk_size}) - obstack_chunk_size (obstack_ptr) = @var{new_chunk_size}; +if (obstack_chunk_size (obstack_ptr) < @var{new-chunk-size}) + obstack_chunk_size (obstack_ptr) = @var{new-chunk-size}; @end smallexample @node Summary of Obstacks @@ -1324,75 +1363,75 @@ argument. @table @code -@item void obstack_init (struct obstack *@var{obstack_ptr}) +@item void obstack_init (struct obstack *@var{obstack-ptr}) Initialize use of an obstack. @xref{Creating Obstacks}. -@item void *obstack_alloc (struct obstack *@var{obstack_ptr}, size_t @var{size}) +@item void *obstack_alloc (struct obstack *@var{obstack-ptr}, int @var{size}) Allocate an object of @var{size} uninitialized bytes. @xref{Allocation in an Obstack}. -@item void *obstack_copy (struct obstack *@var{obstack_ptr}, void *@var{address}, size_t @var{size}) +@item void *obstack_copy (struct obstack *@var{obstack-ptr}, void *@var{address}, int @var{size}) Allocate an object of @var{size} bytes, with contents copied from @var{address}. @xref{Allocation in an Obstack}. -@item void *obstack_copy0 (struct obstack *@var{obstack_ptr}, void *@var{address}, size_t @var{size}) +@item void *obstack_copy0 (struct obstack *@var{obstack-ptr}, void *@var{address}, int @var{size}) Allocate an object of @var{size}+1 bytes, with @var{size} of them copied from @var{address}, followed by a null character at the end. @xref{Allocation in an Obstack}. -@item void obstack_free (struct obstack *@var{obstack_ptr}, void *@var{object}) +@item void obstack_free (struct obstack *@var{obstack-ptr}, void *@var{object}) Free @var{object} (and everything allocated in the specified obstack more recently than @var{object}). @xref{Freeing Obstack Objects}. -@item void obstack_blank (struct obstack *@var{obstack_ptr}, size_t @var{size}) +@item void obstack_blank (struct obstack *@var{obstack-ptr}, int @var{size}) Add @var{size} uninitialized bytes to a growing object. @xref{Growing Objects}. -@item void obstack_grow (struct obstack *@var{obstack_ptr}, void *@var{address}, size_t @var{size}) +@item void obstack_grow (struct obstack *@var{obstack-ptr}, void *@var{address}, int @var{size}) Add @var{size} bytes, copied from @var{address}, to a growing object. @xref{Growing Objects}. -@item void obstack_grow0 (struct obstack *@var{obstack_ptr}, void *@var{address}, size_t @var{size}) +@item void obstack_grow0 (struct obstack *@var{obstack-ptr}, void *@var{address}, int @var{size}) Add @var{size} bytes, copied from @var{address}, to a growing object, and then add another byte containing a null character. @xref{Growing Objects}. -@item void obstack_1grow (struct obstack *@var{obstack_ptr}, char @var{data_char}) -Add one byte containing @var{data_char} to a growing object. +@item void obstack_1grow (struct obstack *@var{obstack-ptr}, char @var{data-char}) +Add one byte containing @var{data-char} to a growing object. @xref{Growing Objects}. -@item void *obstack_finish (struct obstack *@var{obstack_ptr}) +@item void *obstack_finish (struct obstack *@var{obstack-ptr}) Finalize the object that is growing and return its permanent address. @xref{Growing Objects}. -@item size_t obstack_object_size (struct obstack *@var{obstack_ptr}) +@item int obstack_object_size (struct obstack *@var{obstack-ptr}) Get the current size of the currently growing object. @xref{Growing Objects}. -@item void obstack_blank_fast (struct obstack *@var{obstack_ptr}, size_t @var{size}) +@item void obstack_blank_fast (struct obstack *@var{obstack-ptr}, int @var{size}) Add @var{size} uninitialized bytes to a growing object without checking that there is enough room. @xref{Extra Fast Growing}. -@item void obstack_1grow_fast (struct obstack *@var{obstack_ptr}, char @var{data_char}) -Add one byte containing @var{data_char} to a growing object without +@item void obstack_1grow_fast (struct obstack *@var{obstack-ptr}, char @var{data-char}) +Add one byte containing @var{data-char} to a growing object without checking that there is enough room. @xref{Extra Fast Growing}. -@item size_t obstack_room (struct obstack *@var{obstack_ptr}) +@item int obstack_room (struct obstack *@var{obstack-ptr}) Get the amount of room now available for growing the current object. @xref{Extra Fast Growing}. -@item int obstack_alignment_mask (struct obstack *@var{obstack_ptr}) +@item int obstack_alignment_mask (struct obstack *@var{obstack-ptr}) The mask used for aligning the beginning of an object. This is an lvalue. @xref{Obstacks Data Alignment}. -@item size_t obstack_chunk_size (struct obstack *@var{obstack_ptr}) +@item int obstack_chunk_size (struct obstack *@var{obstack-ptr}) The size for allocating chunks. This is an lvalue. @xref{Obstack Chunks}. -@item void *obstack_base (struct obstack *@var{obstack_ptr}) +@item void *obstack_base (struct obstack *@var{obstack-ptr}) Tentative starting address of the currently growing object. @xref{Status of an Obstack}. -@item void *obstack_next_free (struct obstack *@var{obstack_ptr}) +@item void *obstack_next_free (struct obstack *@var{obstack-ptr}) Address just after the end of the currently growing object. @xref{Status of an Obstack}. @end table @@ -1688,7 +1727,7 @@ @comment malloc.h @comment GNU -@deftypefun void memory_warnings (void *@var{start}, void (*@var{warn_func}) (const char *)) +@deftypefun void memory_warnings (void *@var{start}, void (*@var{warn-func}) (const char *)) Call this function to request warnings for nearing exhaustion of virtual memory. @@ -1698,7 +1737,7 @@ use. If you supply zero for @var{start}, then a default value is used which is right in most circumstances. -For @var{warn_func}, supply a function that @code{malloc} can call to +For @var{warn-func}, supply a function that @code{malloc} can call to warn you. It is called with a string (a warning message) as argument. Normally it ought to display the string for the user to read. @end deftypefun diff -ruN glibc-1.08.1/manual/memstrm.c.texi glibc-1.09/manual/memstrm.c.texi --- glibc-1.08.1/manual/memstrm.c.texi Thu Feb 17 07:49:57 1994 +++ glibc-1.09/manual/memstrm.c.texi Fri Oct 14 04:43:15 1994 @@ -10,10 +10,10 @@ stream = open_memstream (&bp, &size); fprintf (stream, "hello"); fflush (stream); - printf ("buf = %s, size = %d\n", bp, size); + printf ("buf = `%s', size = %d\n", bp, size); fprintf (stream, ", world"); fclose (stream); - printf ("buf = %s, size = %d\n", bp, size); + printf ("buf = `%s', size = %d\n", bp, size); return 0; @} diff -ruN glibc-1.08.1/manual/pattern.texi glibc-1.09/manual/pattern.texi --- glibc-1.08.1/manual/pattern.texi Mon Feb 7 18:28:23 1994 +++ glibc-1.09/manual/pattern.texi Wed Oct 5 00:29:57 1994 @@ -161,11 +161,11 @@ @comment glob.h @comment POSIX.2 -@deftypefun int glob (const char *@var{pattern}, int @var{flags}, int (*@var{errfunc}) (const char *@var{filename}, int @var{error-code}), glob_t *@var{vector_ptr}) +@deftypefun int glob (const char *@var{pattern}, int @var{flags}, int (*@var{errfunc}) (const char *@var{filename}, int @var{error-code}), glob_t *@var{vector-ptr}) The function @code{glob} does globbing using the pattern @var{pattern} in the current directory. It puts the result in a newly allocated vector, and stores the size and address of this vector into -@code{*@var{vector_ptr}}. The argument @var{flags} is a combination of +@code{*@var{vector-ptr}}. The argument @var{flags} is a combination of bit flags; see @ref{Flags for Globbing}, for details of the flags. The result of globbing is a sequence of file names. The function @@ -176,7 +176,7 @@ To return this vector, @code{glob} stores both its address and its length (number of elements, not counting the terminating null pointer) -into @code{*@var{vector_ptr}}. +into @code{*@var{vector-ptr}}. Normally, @code{glob} sorts the file names alphabetically before returning them. You can turn this off with the flag @code{GLOB_NOSORT} @@ -218,7 +218,7 @@ @end table In the event of an error, @code{glob} stores information in -@code{*@var{vector_ptr}} about all the matches it has found so far. +@code{*@var{vector-ptr}} about all the matches it has found so far. @end deftypefun @node Flags for Globbing @@ -499,7 +499,7 @@ @comment regex.h @comment POSIX.2 @item REG_NOSUB -Don't bother storing the contents of the @var{matches_ptr} array. +Don't bother storing the contents of the @var{matches-ptr} array. @comment regex.h @comment POSIX.2 diff -ruN glibc-1.08.1/manual/pipe.texi glibc-1.09/manual/pipe.texi --- glibc-1.08.1/manual/pipe.texi Mon Feb 7 18:28:15 1994 +++ glibc-1.09/manual/pipe.texi Fri Oct 14 01:35:27 1994 @@ -200,7 +200,8 @@ Reading or writing a larger amount of data may not be atomic; for example, output data from other processes sharing the descriptor may be -interspersed. +interspersed. Also, once @code{PIPE_BUF} characters have been written, +further writes will block until some characters are read. @xref{Limits for Files}, for information about the @code{PIPE_BUF} parameter. diff -ruN glibc-1.08.1/manual/process.texi glibc-1.09/manual/process.texi --- glibc-1.08.1/manual/process.texi Wed Dec 31 19:00:00 1969 +++ glibc-1.09/manual/process.texi Wed Oct 19 21:16:04 1994 @@ -0,0 +1,775 @@ +@node Processes +@chapter Processes + +@cindex process +@dfn{Processes} are the primitive units for allocation of system +resources. Each process has its own address space and (usually) one +thread of control. A process executes a program; you can have multiple +processes executing the same program, but each process has its own copy +of the program within its own address space and executes it +independently of the other copies. + +@cindex child process +@cindex parent process +Processes are organized hierarchically. Each process has a @dfn{parent +process} which explicitly arranged to create it. The processes created +by a given parent are called its @dfn{child processes}. A child +inherits many of its attributes from the parent process. + +This chapter describes how a program can create, terminate, and control +child processes. Actually, there are three distinct operations +involved: creating a new child process, causing the new process to +execute a program, and coordinating the completion of the child process +with the original program. + +The @code{system} function provides a simple, portable mechanism for +running another program; it does all three steps automatically. If you +need more control over the details of how this is done, you can use the +primitive functions to do each step individually instead. + +@menu +* Running a Command:: The easy way to run another program. +* Process Creation Concepts:: An overview of the hard way to do it. +* Process Identification:: How to get the process ID of a process. +* Creating a Process:: How to fork a child process. +* Executing a File:: How to make a process execute another program. +* Process Completion:: How to tell when a child process has completed. +* Process Completion Status:: How to interpret the status value + returned from a child process. +* BSD Wait Functions:: More functions, for backward compatibility. +* Process Creation Example:: A complete example program. +@end menu + + +@node Running a Command +@section Running a Command +@cindex running a command + +The easy way to run another program is to use the @code{system} +function. This function does all the work of running a subprogram, but +it doesn't give you much control over the details: you have to wait +until the subprogram terminates before you can do anything else. + +@comment stdlib.h +@comment ANSI +@deftypefun int system (const char *@var{command}) +@pindex sh +This function executes @var{command} as a shell command. In the GNU C +library, it always uses the default shell @code{sh} to run the command. +In particular, it searches the directories in @code{PATH} to find +programs to execute. The return value is @code{-1} if it wasn't +possible to create the shell process, and otherwise is the status of the +shell process. @xref{Process Completion}, for details on how this +status code can be interpreted. + +@pindex stdlib.h +The @code{system} function is declared in the header file +@file{stdlib.h}. +@end deftypefun + +@strong{Portability Note:} Some C implementations may not have any +notion of a command processor that can execute other programs. You can +determine whether a command processor exists by executing +@w{@code{system (NULL)}}; if the return value is nonzero, a command +processor is available. + +The @code{popen} and @code{pclose} functions (@pxref{Pipe to a +Subprocess}) are closely related to the @code{system} function. They +allow the parent process to communicate with the standard input and +output channels of the command being executed. + +@node Process Creation Concepts +@section Process Creation Concepts + +This section gives an overview of processes and of the steps involved in +creating a process and making it run another program. + +@cindex process ID +@cindex process lifetime +Each process is named by a @dfn{process ID} number. A unique process ID +is allocated to each process when it is created. The @dfn{lifetime} of +a process ends when its termination is reported to its parent process; +at that time, all of the process resources, including its process ID, +are freed. + +@cindex creating a process +@cindex forking a process +@cindex child process +@cindex parent process +Processes are created with the @code{fork} system call (so the operation +of creating a new process is sometimes called @dfn{forking} a process). +The @dfn{child process} created by @code{fork} is a copy of the original +@dfn{parent process}, except that it has its own process ID. + +After forking a child process, both the parent and child processes +continue to execute normally. If you want your program to wait for a +child process to finish executing before continuing, you must do this +explicitly after the fork operation, by calling @code{wait} or +@code{waitpid} (@pxref{Process Completion}). These functions give you +limited information about why the child terminated---for example, its +exit status code. + +A newly forked child process continues to execute the same program as +its parent process, at the point where the @code{fork} call returns. +You can use the return value from @code{fork} to tell whether the program +is running in the parent process or the child. + +@cindex process image +Having several processes run the same program is only occasionally +useful. But the child can execute another program using one of the +@code{exec} functions; see @ref{Executing a File}. The program that the +process is executing is called its @dfn{process image}. Starting +execution of a new program causes the process to forget all about its +previous process image; when the new program exits, the process exits +too, instead of returning to the previous process image. + +@node Process Identification +@section Process Identification + +The @code{pid_t} data type represents process IDs. You can get the +process ID of a process by calling @code{getpid}. The function +@code{getppid} returns the process ID of the parent of the current +process (this is also known as the @dfn{parent process ID}). Your +program should include the header files @file{unistd.h} and +@file{sys/types.h} to use these functions. +@pindex sys/types.h +@pindex unistd.h + +@comment sys/types.h +@comment POSIX.1 +@deftp {Data Type} pid_t +The @code{pid_t} data type is a signed integer type which is capable +of representing a process ID. In the GNU library, this is an @code{int}. +@end deftp + +@comment unistd.h +@comment POSIX.1 +@deftypefun pid_t getpid (void) +The @code{getpid} function returns the process ID of the current process. +@end deftypefun + +@comment unistd.h +@comment POSIX.1 +@deftypefun pid_t getppid (void) +The @code{getppid} function returns the process ID of the parent of the +current process. +@end deftypefun + +@node Creating a Process +@section Creating a Process + +The @code{fork} function is the primitive for creating a process. +It is declared in the header file @file{unistd.h}. +@pindex unistd.h + +@comment unistd.h +@comment POSIX.1 +@deftypefun pid_t fork (void) +The @code{fork} function creates a new process. + +If the operation is successful, there are then both parent and child +processes and both see @code{fork} return, but with different values: it +returns a value of @code{0} in the child process and returns the child's +process ID in the parent process. + +If process creation failed, @code{fork} returns a value of @code{-1} in +the parent process. The following @code{errno} error conditions are +defined for @code{fork}: + +@table @code +@item EAGAIN +There aren't enough system resources to create another process, or the +user already has too many processes running. This means exceeding the +@code{RLIMIT_NPROC} resource limit, which can usually be increased; +@pxref{Limits on Resources}. + +@item ENOMEM +The process requires more space than the system can supply. +@end table +@end deftypefun + +The specific attributes of the child process that differ from the +parent process are: + +@itemize @bullet +@item +The child process has its own unique process ID. + +@item +The parent process ID of the child process is the process ID of its +parent process. + +@item +The child process gets its own copies of the parent process's open file +descriptors. Subsequently changing attributes of the file descriptors +in the parent process won't affect the file descriptors in the child, +and vice versa. @xref{Control Operations}. However, the file position +associated with each descriptor is shared by both processes; +@pxref{File Position}. + +@item +The elapsed processor times for the child process are set to zero; +see @ref{Processor Time}. + +@item +The child doesn't inherit file locks set by the parent process. +@c !!! flock locks shared +@xref{Control Operations}. + +@item +The child doesn't inherit alarms set by the parent process. +@xref{Setting an Alarm}. + +@item +The set of pending signals (@pxref{Delivery of Signal}) for the child +process is cleared. (The child process inherits its mask of blocked +signals and signal actions from the parent process.) +@end itemize + + +@comment unistd.h +@comment BSD +@deftypefun pid_t vfork (void) +The @code{vfork} function is similar to @code{fork} but on systems it +is more efficient; however, there are restrictions you must follow to +use it safely. + +While @code{fork} makes a complete copy of the calling process's +address space and allows both the parent and child to execute +independently, @code{vfork} does not make this copy. Instead, the +child process created with @code{vfork} shares its parent's address +space until it calls exits or one of the @code{exec} functions. In the +meantime, the parent process suspends execution. + +You must be very careful not to allow the child process created with +@code{vfork} to modify any global data or even local variables shared +with the parent. Furthermore, the child process cannot return from (or +do a long jump out of) the function that called @code{vfork}! This +would leave the parent process's control information very confused. If +in doubt, use @code{fork} instead. + +Some operating systems don't really implement @code{vfork}. The GNU C +library permits you to use @code{vfork} on all systems, but actually +executes @code{fork} if @code{vfork} isn't available. If you follow +the proper precautions for using @code{vfork}, your program will still +work even if the system uses @code{fork} instead. +@end deftypefun + +@node Executing a File +@section Executing a File +@cindex executing a file +@cindex @code{exec} functions + +This section describes the @code{exec} family of functions, for executing +a file as a process image. You can use these functions to make a child +process execute a new program after it has been forked. + +@pindex unistd.h +The functions in this family differ in how you specify the arguments, +but otherwise they all do the same thing. They are declared in the +header file @file{unistd.h}. + +@comment unistd.h +@comment POSIX.1 +@deftypefun int execv (const char *@var{filename}, char *const @var{argv}@t{[]}) +The @code{execv} function executes the file named by @var{filename} as a +new process image. + +The @var{argv} argument is an array of null-terminated strings that is +used to provide a value for the @code{argv} argument to the @code{main} +function of the program to be executed. The last element of this array +must be a null pointer. By convention, the first element of this array +is the file name of the program sans directory names. @xref{Program +Arguments}, for full details on how programs can access these arguments. + +The environment for the new process image is taken from the +@code{environ} variable of the current process image; see +@ref{Environment Variables}, for information about environments. +@end deftypefun + +@comment unistd.h +@comment POSIX.1 +@deftypefun int execl (const char *@var{filename}, const char *@var{arg0}, @dots{}) +This is similar to @code{execv}, but the @var{argv} strings are +specified individually instead of as an array. A null pointer must be +passed as the last such argument. +@end deftypefun + +@comment unistd.h +@comment POSIX.1 +@deftypefun int execve (const char *@var{filename}, char *const @var{argv}@t{[]}, char *const @var{env}@t{[]}) +This is similar to @code{execv}, but permits you to specify the environment +for the new program explicitly as the @var{env} argument. This should +be an array of strings in the same format as for the @code{environ} +variable; see @ref{Environment Access}. +@end deftypefun + +@comment unistd.h +@comment POSIX.1 +@deftypefun int execle (const char *@var{filename}, const char *@var{arg0}, char *const @var{env}@t{[]}, @dots{}) +This is similar to @code{execl}, but permits you to specify the +environment for the new program explicitly. The environment argument is +passed following the null pointer that marks the last @var{argv} +argument, and should be an array of strings in the same format as for +the @code{environ} variable. +@end deftypefun + +@comment unistd.h +@comment POSIX.1 +@deftypefun int execvp (const char *@var{filename}, char *const @var{argv}@t{[]}) +The @code{execvp} function is similar to @code{execv}, except that it +searches the directories listed in the @code{PATH} environment variable +(@pxref{Standard Environment}) to find the full file name of a +file from @var{filename} if @var{filename} does not contain a slash. + +This function is useful for executing system utility programs, because +it looks for them in the places that the user has chosen. Shells use it +to run the commands that users type. +@end deftypefun + +@comment unistd.h +@comment POSIX.1 +@deftypefun int execlp (const char *@var{filename}, const char *@var{arg0}, @dots{}) +This function is like @code{execl}, except that it performs the same +file name searching as the @code{execvp} function. +@end deftypefun + +The size of the argument list and environment list taken together must +not be greater than @code{ARG_MAX} bytes. @xref{General Limits}. In +the GNU system, the size (which compares against @code{ARG_MAX}) +includes, for each string, the number of characters in the string, plus +the size of a @code{char *}, plus one, rounded up to a multiple of the +size of a @code{char *}. Other systems may have somewhat different +rules for counting. + +These functions normally don't return, since execution of a new program +causes the currently executing program to go away completely. A value +of @code{-1} is returned in the event of a failure. In addition to the +usual file name syntax errors (@pxref{File Name Errors}), the following +@code{errno} error conditions are defined for these functions: + +@table @code +@item E2BIG +The combined size of the new program's argument list and environment +list is larger than @code{ARG_MAX} bytes. The GNU system has no +specific limit on the argument list size, so this error code cannot +result, but you may get @code{ENOMEM} instead if the arguments are too +big for available memory. + +@item ENOEXEC +The specified file can't be executed because it isn't in the right format. + +@item ENOMEM +Executing the specified file requires more storage than is available. +@end table + +If execution of the new file succeeds, it updates the access time field +of the file as if the file had been read. @xref{File Times}, for more +details about access times of files. + +The point at which the file is closed again is not specified, but +is at some point before the process exits or before another process +image is executed. + +Executing a new process image completely changes the contents of memory, +copying only the argument and environment strings to new locations. But +many other attributes of the process are unchanged: + +@itemize @bullet +@item +The process ID and the parent process ID. @xref{Process Creation Concepts}. + +@item +Session and process group membership. @xref{Concepts of Job Control}. + +@item +Real user ID and group ID, and supplementary group IDs. @xref{Process +Persona}. + +@item +Pending alarms. @xref{Setting an Alarm}. + +@item +Current working directory and root directory. @xref{Working +Directory}. In the GNU system, the root directory is not copied when +executing a setuid program; instead the system default root directory +is used for the new program. + +@item +File mode creation mask. @xref{Setting Permissions}. + +@item +Process signal mask; see @ref{Process Signal Mask}. + +@item +Pending signals; see @ref{Blocking Signals}. + +@item +Elapsed processor time associated with the process; see @ref{Processor Time}. +@end itemize + +If the set-user-ID and set-group-ID mode bits of the process image file +are set, this affects the effective user ID and effective group ID +(respectively) of the process. These concepts are discussed in detail +in @ref{Process Persona}. + +Signals that are set to be ignored in the existing process image are +also set to be ignored in the new process image. All other signals are +set to the default action in the new process image. For more +information about signals, see @ref{Signal Handling}. + +File descriptors open in the existing process image remain open in the +new process image, unless they have the @code{FD_CLOEXEC} +(close-on-exec) flag set. The files that remain open inherit all +attributes of the open file description from the existing process image, +including file locks. File descriptors are discussed in @ref{Low-Level I/O}. + +Streams, by contrast, cannot survive through @code{exec} functions, +because they are located in the memory of the process itself. The new +process image has no streams except those it creates afresh. Each of +the streams in the pre-@code{exec} process image has a descriptor inside +it, and these descriptors do survive through @code{exec} (provided that +they do not have @code{FD_CLOEXEC} set). The new process image can +reconnect these to new streams using @code{fdopen} (@pxref{Descriptors +and Streams}). + +@node Process Completion +@section Process Completion +@cindex process completion +@cindex waiting for completion of child process +@cindex testing exit status of child process + +The functions described in this section are used to wait for a child +process to terminate or stop, and determine its status. These functions +are declared in the header file @file{sys/wait.h}. +@pindex sys/wait.h + +@comment sys/wait.h +@comment POSIX.1 +@deftypefun pid_t waitpid (pid_t @var{pid}, int *@var{status-ptr}, int @var{options}) +The @code{waitpid} function is used to request status information from a +child process whose process ID is @var{pid}. Normally, the calling +process is suspended until the child process makes status information +available by terminating. + +Other values for the @var{pid} argument have special interpretations. A +value of @code{-1} or @code{WAIT_ANY} requests status information for +any child process; a value of @code{0} or @code{WAIT_MYPGRP} requests +information for any child process in the same process group as the +calling process; and any other negative value @minus{} @var{pgid} +requests information for any child process whose process group ID is +@var{pgid}. + +If status information for a child process is available immediately, this +function returns immediately without waiting. If more than one eligible +child process has status information available, one of them is chosen +randomly, and its status is returned immediately. To get the status +from the other eligible child processes, you need to call @code{waitpid} +again. + +The @var{options} argument is a bit mask. Its value should be the +bitwise OR (that is, the @samp{|} operator) of zero or more of the +@code{WNOHANG} and @code{WUNTRACED} flags. You can use the +@code{WNOHANG} flag to indicate that the parent process shouldn't wait; +and the @code{WUNTRACED} flag to request status information from stopped +processes as well as processes that have terminated. + +The status information from the child process is stored in the object +that @var{status-ptr} points to, unless @var{status-ptr} is a null pointer. + +The return value is normally the process ID of the child process whose +status is reported. If the @code{WNOHANG} option was specified and no +child process is waiting to be noticed, the value is zero. A value of +@code{-1} is returned in case of error. The following @code{errno} +error conditions are defined for this function: + +@table @code +@item EINTR +The function was interrupted by delivery of a signal to the calling +process. @xref{Interrupted Primitives}. + +@item ECHILD +There are no child processes to wait for, or the specified @var{pid} +is not a child of the calling process. + +@item EINVAL +An invalid value was provided for the @var{options} argument. +@end table +@end deftypefun + +These symbolic constants are defined as values for the @var{pid} argument +to the @code{waitpid} function. + +@comment Extra blank lines make it look better. +@table @code +@item WAIT_ANY + +This constant macro (whose value is @code{-1}) specifies that +@code{waitpid} should return status information about any child process. + + +@item WAIT_MYPGRP +This constant (with value @code{0}) specifies that @code{waitpid} should +return status information about any child process in the same process +group as the calling process. +@end table + +These symbolic constants are defined as flags for the @var{options} +argument to the @code{waitpid} function. You can bitwise-OR the flags +together to obtain a value to use as the argument. + +@table @code +@item WNOHANG + +This flag specifies that @code{waitpid} should return immediately +instead of waiting, if there is no child process ready to be noticed. + +@item WUNTRACED + +This flag specifies that @code{waitpid} should report the status of any +child processes that have been stopped as well as those that have +terminated. +@end table + +@comment sys/wait.h +@comment POSIX.1 +@deftypefun pid_t wait (int *@var{status-ptr}) +This is a simplified version of @code{waitpid}, and is used to wait +until any one child process terminates. The call: + +@smallexample +wait (&status) +@end smallexample + +@noindent +is exactly equivalent to: + +@smallexample +waitpid (-1, &status, 0) +@end smallexample +@end deftypefun + +@comment sys/wait.h +@comment BSD +@deftypefun pid_t wait4 (pid_t @var{pid}, int *@var{status-ptr}, int @var{options}, struct rusage *@var{usage}) +If @var{usage} is a null pointer, @code{wait4} is equivalent to +@code{waitpid (@var{pid}, @var{status-ptr}, @var{options})}. + +If @var{usage} is not null, @code{wait4} stores usage figures for the +child process in @code{*@var{rusage}} (but only if the child has +terminated, not if it has stopped). @xref{Resource Usage}. + +This function is a BSD extension. +@end deftypefun + +Here's an example of how to use @code{waitpid} to get the status from +all child processes that have terminated, without ever waiting. This +function is designed to be a handler for @code{SIGCHLD}, the signal that +indicates that at least one child process has terminated. + +@smallexample +@group +void +sigchld_handler (int signum) +@{ + int pid; + int status; + while (1) + @{ + pid = waitpid (WAIT_ANY, &status, WNOHANG); + if (pid < 0) + @{ + perror ("waitpid"); + break; + @} + if (pid == 0) + break; + notice_termination (pid, status); + @} +@} +@end group +@end smallexample + +@node Process Completion Status +@section Process Completion Status + +If the exit status value (@pxref{Program Termination}) of the child +process is zero, then the status value reported by @code{waitpid} or +@code{wait} is also zero. You can test for other kinds of information +encoded in the returned status value using the following macros. +These macros are defined in the header file @file{sys/wait.h}. +@pindex sys/wait.h + +@comment sys/wait.h +@comment POSIX.1 +@deftypefn Macro int WIFEXITED (int @var{status}) +This macro returns a nonzero value if the child process terminated +normally with @code{exit} or @code{_exit}. +@end deftypefn + +@comment sys/wait.h +@comment POSIX.1 +@deftypefn Macro int WEXITSTATUS (int @var{status}) +If @code{WIFEXITED} is true of @var{status}, this macro returns the +low-order 8 bits of the exit status value from the child process. +@xref{Exit Status}. +@end deftypefn + +@comment sys/wait.h +@comment POSIX.1 +@deftypefn Macro int WIFSIGNALED (int @var{status}) +This macro returns a nonzero value if the child process terminated +because it received a signal that was not handled. +@xref{Signal Handling}. +@end deftypefn + +@comment sys/wait.h +@comment POSIX.1 +@deftypefn Macro int WTERMSIG (int @var{status}) +If @code{WIFSIGNALED} is true of @var{status}, this macro returns the +signal number of the signal that terminated the child process. +@end deftypefn + +@comment sys/wait.h +@comment BSD +@deftypefn Macro int WCOREDUMP (int @var{status}) +This macro returns a nonzero value if the child process terminated +and produced a core dump. +@end deftypefn + +@comment sys/wait.h +@comment POSIX.1 +@deftypefn Macro int WIFSTOPPED (int @var{status}) +This macro returns a nonzero value if the child process is stopped. +@end deftypefn + +@comment sys/wait.h +@comment POSIX.1 +@deftypefn Macro int WSTOPSIG (int @var{status}) +If @code{WIFSTOPPED} is true of @var{status}, this macro returns the +signal number of the signal that caused the child process to stop. +@end deftypefn + + +@node BSD Wait Functions +@section BSD Process Wait Functions + +The GNU library also provides these related facilities for compatibility +with BSD Unix. BSD uses the @code{union wait} data type to represent +status values rather than an @code{int}. The two representations are +actually interchangeable; they describe the same bit patterns. The GNU +C Library defines macros such as @code{WEXITSTATUS} so that they will +work on either kind of object, and the @code{wait} function is defined +to accept either type of pointer as its @var{status-ptr} argument. + +These functions are declared in @file{sys/wait.h}. +@pindex sys/wait.h + +@comment sys/wait.h +@comment BSD +@deftp {Data Type} {union wait} +This data type represents program termination status values. It has +the following members: + +@table @code +@item int w_termsig +The value of this member is the same as the result of the +@code{WTERMSIG} macro. + +@item int w_coredump +The value of this member is the same as the result of the +@code{WCOREDUMP} macro. + +@item int w_retcode +The value of this member is the same as the result of the +@code{WEXITSTATUS} macro. + +@item int w_stopsig +The value of this member is the same as the result of the +@code{WSTOPSIG} macro. +@end table + +Instead of accessing these members directly, you should use the +equivalent macros. +@end deftp + +The @code{wait3} function is the predecessor to @code{wait4}, which is +more flexible. @code{wait3} is now obsolete. + +@comment sys/wait.h +@comment BSD +@deftypefun pid_t wait3 (union wait *@var{status-ptr}, int @var{options}, struct rusage *@var{usage}) +If @var{usage} is a null pointer, @code{wait3} is equivalent to +@code{waitpid (-1, @var{status-ptr}, @var{options})}. + +If @var{usage} is not null, @code{wait3} stores usage figures for the +child process in @code{*@var{rusage}} (but only if the child has +terminated, not if it has stopped). @xref{Resource Usage}. +@end deftypefun + +@node Process Creation Example +@section Process Creation Example + +Here is an example program showing how you might write a function +similar to the built-in @code{system}. It executes its @var{command} +argument using the equivalent of @samp{sh -c @var{command}}. + +@smallexample +#include +#include +#include +#include +#include + +/* @r{Execute the command using this shell program.} */ +#define SHELL "/bin/sh" + +@group +int +my_system (const char *command) +@{ + int status; + pid_t pid; +@end group + + pid = fork (); + if (pid == 0) + @{ + /* @r{This is the child process. Execute the shell command.} */ + execl (SHELL, SHELL, "-c", command, NULL); + _exit (EXIT_FAILURE); + @} + else if (pid < 0) + /* @r{The fork failed. Report failure.} */ + status = -1; + else + /* @r{This is the parent process. Wait for the child to complete.} */ + if (waitpid (pid, &status, 0) != pid) + status = -1; + return status; +@} +@end smallexample + +@comment Yes, this example has been tested. + +There are a couple of things you should pay attention to in this +example. + +Remember that the first @code{argv} argument supplied to the program +represents the name of the program being executed. That is why, in the +call to @code{execl}, @code{SHELL} is supplied once to name the program +to execute and a second time to supply a value for @code{argv[0]}. + +The @code{execl} call in the child process doesn't return if it is +successful. If it fails, you must do something to make the child +process terminate. Just returning a bad status code with @code{return} +would leave two processes running the original program. Instead, the +right behavior is for the child process to report failure to its parent +process. + +Call @code{_exit} to accomplish this. The reason for using @code{_exit} +instead of @code{exit} is to avoid flushing fully buffered streams such +as @code{stdout}. The buffers of these streams probably contain data +that was copied from the parent process by the @code{fork}, data that +will be output eventually by the parent process. Calling @code{exit} in +the child would output the data twice. @xref{Termination Internals}. diff -ruN glibc-1.08.1/manual/search.texi glibc-1.09/manual/search.texi --- glibc-1.08.1/manual/search.texi Mon Feb 7 18:28:22 1994 +++ glibc-1.09/manual/search.texi Sun Oct 16 19:34:00 1994 @@ -118,6 +118,8 @@ If you want the effect of a stable sort, you can get this result by writing the comparison function so that, lacking other reason distinguish between two elements, it compares them by their addresses. +Note that doing this may make the sorting algorithm less efficient, so +do it only if necessary. Here is a simple example of sorting an array of doubles in numerical order, using the comparison function defined above (@pxref{Comparison diff -ruN glibc-1.08.1/manual/setjmp.texi glibc-1.09/manual/setjmp.texi --- glibc-1.08.1/manual/setjmp.texi Mon Feb 7 18:28:26 1994 +++ glibc-1.09/manual/setjmp.texi Wed Oct 26 01:37:04 1994 @@ -136,7 +136,7 @@ @itemize @bullet @item As the test expression of a selection or iteration -statement (such as @samp{if} or @samp{while}). +statement (such as @samp{if}, @samp{switch}, or @samp{while}). @item As one operand of a equality or comparison operator that appears as the diff -ruN glibc-1.08.1/manual/signal.texi glibc-1.09/manual/signal.texi --- glibc-1.08.1/manual/signal.texi Sun Feb 6 16:05:24 1994 +++ glibc-1.09/manual/signal.texi Mon Oct 24 01:25:28 1994 @@ -35,9 +35,9 @@ * Blocking Signals:: Making the system hold signals temporarily. * Waiting for a Signal:: Suspending your program until a signal arrives. +* Signal Stack:: Using a Separate Signal Stack. * BSD Signal Handling:: Additional functions for backward compatibility with BSD. -* BSD Handler:: BSD Function to Establish a Handler. @end menu @node Concepts of Signals @@ -84,6 +84,12 @@ @item A call to @code{kill} from another process. Signals are a limited but useful form of interprocess communication. + +@item +An attempt to perform an I/O operation that cannot be done. Examples +are reading from a pipe that has no writer (@pxref{Pipes and FIFOs}), +and reading or writing to a terminal in certain situations (@pxref{Job +Control}). @end itemize Each of these kinds of events (excepting explicit calls to @code{kill} @@ -117,9 +123,12 @@ Signals may be generated @dfn{synchronously} or @dfn{asynchronously}. A synchronous signal pertains to a specific action in the program, and is -delivered (unless blocked) during that action. Errors generate signals -synchronously, and so do explicit requests by a process to generate a -signal for that same process. +delivered (unless blocked) during that action. Most errors generate +signals synchronously, and so do explicit requests by a process to +generate a signal for that same process. On some machines, certain +kinds of hardware errors (usually floating-point exceptions) are not +reported completely synchronously, but may arrive a few instructions +later. Asynchronous signals are generated by events outside the control of the process that receives them. These signals arrive at unpredictable times @@ -224,8 +233,8 @@ * Alarm Signals:: Used to indicate expiration of timers. * Asynchronous I/O Signals:: Used to indicate input is available. * Job Control Signals:: Signals used to support job control. +* Operation Error Signals:: Used to report operational system errors. * Miscellaneous Signals:: Miscellaneous Signals. -* Nonstandard Signals:: Implementations can support other signals. * Signal Messages:: Printing a message describing a signal. @end menu @@ -362,7 +371,7 @@ @comment ANSI @deftypevr Macro int SIGILL The name of this signal is derived from ``illegal instruction''; it -means your program is trying to execute garbage or a privileged +usually means your program is trying to execute garbage or a privileged instruction. Since the C compiler generates only valid instructions, @code{SIGILL} typically indicates that the executable file is corrupted, or that you are trying to execute data. Some common ways of getting @@ -371,6 +380,9 @@ automatic array (or similar problems with pointers to automatic variables) and corrupting other data on the stack such as the return address of a stack frame. + +@code{SIGILL} can also be generated when the stack overflows, or when +the system has trouble running the handler for a signal. @end deftypevr @cindex illegal instruction @@ -379,23 +391,16 @@ @deftypevr Macro int SIGSEGV @cindex segmentation violation This signal is generated when a program tries to read or write outside -the memory that is allocated for it. (Actually, the signals only occur -when the program goes far enough outside to be detected by the system's -memory protection mechanism.) The name is an abbreviation for -``segmentation violation''. - -The most common way of getting a @code{SIGSEGV} condition is by -dereferencing a null or uninitialized pointer. A null pointer refers to -the address 0, and most operating systems make sure this address is -always invalid precisely so that dereferencing a null pointer will cause -@code{SIGSEGV}. (Some operating systems place valid memory at address -0, and dereferencing a null pointer does not cause a signal on these -systems.) As for uninitialized pointer variables, they contain random -addresses which may or may not be valid. - -Another common way of getting into a @code{SIGSEGV} situation is when -you use a pointer to step through an array, but fail to check for the -end of the array. +the memory that is allocated for it, or to write memory that can only be +read. (Actually, the signals only occur when the program goes far +enough outside to be detected by the system's memory protection +mechanism.) The name is an abbreviation for ``segmentation violation''. + +Common ways of getting a @code{SIGSEGV} condition include dereferencing +a null or uninitialized pointer, or when you use a pointer to step +through an array, but fail to check for the end of the array. It varies +among systems whether dereferencing a null pointer generates +@code{SIGSEGV} or @code{SIGBUS}. @end deftypevr @comment signal.h @@ -423,6 +428,38 @@ reported by calling @code{abort}. @xref{Aborting a Program}. @end deftypevr +@comment signal.h +@comment Unix +@deftypevr Macro int SIGIOT +Generated by the PDP-11 ``iot'' instruction. On most machines, this is +just another name for @code{SIGABRT}. +@end deftypevr + +@comment signal.h +@comment BSD +@deftypevr Macro int SIGTRAP +Generated by the machine's breakpoint instruction, and possibly other +trap instructions. This signal is used by debuggers. Your program will +probably only see @code{SIGTRAP} if it is somehow executing bad +instructions. +@end deftypevr + +@comment signal.h +@comment BSD +@deftypevr Macro int SIGEMT +Emulator trap; this results from certain unimplemented instructions +which might be emulated in software, or the operating system's +failure to properly emulate them. +@end deftypevr + +@comment signal.h +@comment Unix +@deftypevr Macro int SIGSYS +Bad system call; that is to say, the instruction to trap to the +operating system was executed, but the code number for the system call +to perform was invalid. +@end deftypevr + @node Termination Signals @subsection Termination Signals @cindex program termination signals @@ -443,19 +480,16 @@ process to terminate. @comment signal.h -@comment POSIX.1 -@deftypevr Macro int SIGHUP -@cindex hangup signal -The @code{SIGHUP} (``hang-up'') signal is used to report that the user's -terminal is disconnected, perhaps because a network or telephone -connection was broken. For more information about this, see @ref{Control -Modes}. +@comment ANSI +@deftypevr Macro int SIGTERM +@cindex termination signal +The @code{SIGTERM} signal is a generic signal used to cause program +termination. Unlike @code{SIGKILL}, this signal can be blocked, +handled, and ignored. It is the normal way to politely ask a program to +terminate. -This signal is also used to report the termination of the controlling -process on a terminal to jobs associated with that session; this -termination effectively disconnects all processes in the session from -the controlling terminal. For more information, see @ref{Termination -Internals}. +The shell command @code{kill} generates @code{SIGTERM} by default. +@pindex kill @end deftypevr @comment signal.h @@ -491,35 +525,43 @@ @end deftypevr @comment signal.h -@comment ANSI -@deftypevr Macro int SIGTERM -@cindex termination signal -The @code{SIGTERM} signal is a generic signal used to cause program -termination. Unlike @code{SIGKILL}, this signal can be blocked, -handled, and ignored. - -The shell command @code{kill} generates @code{SIGTERM} by default. -@pindex kill -@end deftypevr - -@comment signal.h @comment POSIX.1 @deftypevr Macro int SIGKILL The @code{SIGKILL} signal is used to cause immediate program termination. It cannot be handled or ignored, and is therefore always fatal. It is also not possible to block this signal. -This signal is generated only by explicit request. Since it cannot be -handled, you should generate it only as a last resort, after first -trying a less drastic method such as @kbd{C-c} or @code{SIGTERM}. If a -process does not respond to any other termination signals, sending it a -@code{SIGKILL} signal will almost always cause it to go away. +This signal is usually generated only by explicit request. Since it +cannot be handled, you should generate it only as a last resort, after +first trying a less drastic method such as @kbd{C-c} or @code{SIGTERM}. +If a process does not respond to any other termination signals, sending +it a @code{SIGKILL} signal will almost always cause it to go away. In fact, if @code{SIGKILL} fails to terminate a process, that by itself constitutes an operating system bug which you should report. + +The system will generate @code{SIGKILL} for a process itself under some +unusual conditions where the program cannot possible continue to run +(even to run a signal handler). @end deftypevr @cindex kill signal +@comment signal.h +@comment POSIX.1 +@deftypevr Macro int SIGHUP +@cindex hangup signal +The @code{SIGHUP} (``hang-up'') signal is used to report that the user's +terminal is disconnected, perhaps because a network or telephone +connection was broken. For more information about this, see @ref{Control +Modes}. + +This signal is also used to report the termination of the controlling +process on a terminal to jobs associated with that session; this +termination effectively disconnects all processes in the session from +the controlling terminal. For more information, see @ref{Termination +Internals}. +@end deftypevr + @node Alarm Signals @subsection Alarm Signals @@ -580,6 +622,9 @@ On most operating systems, terminals and sockets are the only kinds of files that can generate @code{SIGIO}; other kinds, including ordinary files, never generate @code{SIGIO} even if you ask them to. + +In the GNU system @code{SIGIO} will always be generated properly +if you successfully set asynchronous mode with @code{fcntl}. @end deftypevr @comment signal.h @@ -590,6 +635,13 @@ socket. @xref{Out-of-Band Data}. @end deftypevr +@comment signal.h +@comment SVID +@deftypevr Macro int SIGPOLL +This is a System V signal name, more or less similar to @code{SIGIO}. +It is defined only for compatibility. +@end deftypevr + @node Job Control Signals @subsection Job Control Signals @cindex job control signals @@ -617,12 +669,20 @@ @end deftypevr @comment signal.h +@comment SVID +@deftypevr Macro int SIGCLD +This is an obsolete name for @code{SIGCHLD}. +@end deftypevr + +@comment signal.h @comment POSIX.1 @deftypevr Macro int SIGCONT @cindex continue signal You can send a @code{SIGCONT} signal to a process to make it continue. -The default behavior for this signal is to make the process continue if -it is stopped, and to ignore it otherwise. +This signal is special---it always makes the process continue if it is +stopped, before the signal is delivered. The default behavior is to do +nothing else. You cannot block this signal. You can set a handler, but +@code{SIGCONT} always makes the process continue regardless. Most programs have no reason to handle @code{SIGCONT}; they simply resume execution without realizing they were ever stopped. You can use @@ -673,27 +733,33 @@ @deftypevr Macro int SIGTTOU This is similar to @code{SIGTTIN}, but is generated when a process in a background job attempts to write to the terminal or set its modes. -Again, the default action is to stop the process. +Again, the default action is to stop the process. @code{SIGTTOU} is +only generated for an attempt to write to the terminal if the +@code{TOSTOP} output mode is set; @pxref{Output Modes}. @end deftypevr @cindex terminal output signal While a process is stopped, no more signals can be delivered to it until it is continued, except @code{SIGKILL} signals and (obviously) -@code{SIGCONT} signals. The @code{SIGKILL} signal always causes -termination of the process and can't be blocked or ignored. You can -block or ignore @code{SIGCONT}, but it always causes the process to -be continued anyway if it is stopped. Sending a @code{SIGCONT} signal -to a process causes any pending stop signals for that process to be -discarded. Likewise, any pending @code{SIGCONT} signals for a process -are discarded when it receives a stop signal. +@code{SIGCONT} signals. The signals are marked as pending, but not +delivered until the process is continued. The @code{SIGKILL} signal +always causes termination of the process and can't be blocked, handled +or ignored. You can ignore @code{SIGCONT}, but it always causes the +process to be continued anyway if it is stopped. Sending a +@code{SIGCONT} signal to a process causes any pending stop signals for +that process to be discarded. Likewise, any pending @code{SIGCONT} +signals for a process are discarded when it receives a stop signal. When a process in an orphaned process group (@pxref{Orphaned Process Groups}) receives a @code{SIGTSTP}, @code{SIGTTIN}, or @code{SIGTTOU} signal and does not handle it, the process does not stop. Stopping the -process would be unreasonable since there would be no way to continue -it. What happens instead depends on the operating system you are -using. Some systems may do nothing; others may deliver another signal -instead, such as @code{SIGKILL} or @code{SIGHUP}. +process would probably not be very useful, since there is no shell +program that will notice it stop and allow the user to continue it. +What happens instead depends on the operating system you are using. +Some systems may do nothing; others may deliver another signal instead, +such as @code{SIGKILL} or @code{SIGHUP}. In the GNU system, the process +dies with @code{SIGKILL}; this avoids the problem of many stopped, +orphaned processes lying around the system. @ignore On the GNU system, it is possible to reattach to the orphaned process @@ -702,23 +768,26 @@ hurts.'' @end ignore -@node Miscellaneous Signals -@subsection Miscellaneous Signals +@node Operation Error Signals +@subsection Operation Error Signals -These signals are used to report various other conditions. The default -action for all of them is to cause the process to terminate. +These signals are used to report various errors generated by an +operation done by the program. They do not necessarily indicate a +programming error in the program, but an error that prevents an +operating system call from completing. The default action for all of +them is to cause the process to terminate. @comment signal.h @comment POSIX.1 @deftypevr Macro int SIGPIPE @cindex pipe signal @cindex broken pipe signal -If you use pipes or FIFOs, you have to design your application so that -one process opens the pipe for reading before another starts writing. -If the reading process never starts, or terminates unexpectedly, writing -to the pipe or FIFO raises a @code{SIGPIPE} signal. If @code{SIGPIPE} -is blocked, handled or ignored, the offending call fails with -@code{EPIPE} instead. +Broken pipe. If you use pipes or FIFOs, you have to design your +application so that one process opens the pipe for reading before +another starts writing. If the reading process never starts, or +terminates unexpectedly, writing to the pipe or FIFO raises a +@code{SIGPIPE} signal. If @code{SIGPIPE} is blocked, handled or +ignored, the offending call fails with @code{EPIPE} instead. Pipes and FIFO special files are discussed in more detail in @ref{Pipes and FIFOs}. @@ -727,7 +796,39 @@ that isn't connected. @xref{Sending Data}. @end deftypevr -@need 245 +@comment signal.h +@comment GNU +@deftypevr Macro int SIGLOST +@cindex lost resource signal +Resource lost. This signal is generated when you have an advisory lock +on an NFS file, and the NFS server reboots and forgets about your lock. + +In the GNU system, @code{SIGLOST} is generated when any server program +dies unexpectedly. It is usually fine to ignore the signal; whatever +call was made to the server that died just returns an error. +@end deftypevr + +@comment signal.h +@comment BSD +@deftypevr Macro int SIGXCPU +CPU time limit exceeded. This signal is generated when the process +exceeds its soft resource limit on CPU time. @xref{Limits on Resources}. +@end deftypevr + +@comment signal.h +@comment BSD +@deftypevr Macro int SIGXFSZ +File size limit exceeded. This signal is generated when the process +attempts to extend a file so it exceeds the process's soft resource +limit on file size. @xref{Limits on Resources}. +@end deftypevr + +@node Miscellaneous Signals +@subsection Miscellaneous Signals + +These signals are used for various other purposes. In general, they +will not affect your program unless it explicitly uses them for something. + @comment signal.h @comment POSIX.1 @deftypevr Macro int SIGUSR1 @@ -735,79 +836,42 @@ @comment signal.h @comment POSIX.1 @deftypevr Macro int SIGUSR2 +@cindex user signals The @code{SIGUSR1} and @code{SIGUSR2} signals are set aside for you to -use any way you want. They're useful for interprocess communication. -Since these signals are normally fatal, you should write a signal handler -for them in the program that receives the signal. +use any way you want. They're useful for simple interprocess +communication, if you write a signal handler for them in the program +that receives the signal. There is an example showing the use of @code{SIGUSR1} and @code{SIGUSR2} in @ref{Signaling Another Process}. -@end deftypevr -@cindex user signals - -@node Nonstandard Signals -@subsection Nonstandard Signals -Particular operating systems support additional signals not listed -above. The ANSI C standard reserves all identifiers beginning with -@samp{SIG} followed by an uppercase letter for the names of signals. -You should consult the documentation or header files for your particular -operating system and processor type to find out about the specific -signals it supports. - -For example, some systems support extra signals which correspond to -hardware traps. Some other kinds of signals commonly supported are used -to implement limits on CPU time or file system usage, asynchronous -changes to terminal configuration, and the like. Systems may also -define signal names that are aliases for standard signal names. - -You can generally assume that the default action (or the action set up -by the shell) for implementation-defined signals is reasonable, and not -worry about them yourself. In fact, it's usually a bad idea to ignore -or block signals you don't know anything about, or try to establish a -handler for signals whose meanings you don't know. - -Here are some of the other signals found on commonly used operating -systems: - -@table @code -@item SIGCLD -Obsolete name for @code{SIGCHLD}. - -@item SIGTRAP -Generated by the machine's breakpoint instruction. Used by debuggers. -Default action is to dump core. - -@item SIGIOT -Generated by the PDP-11 ``iot'' instruction; equivalent to @code{SIGABRT}. -Default action is to dump core. - -@item SIGEMT -Emulator trap; this results from certain unimplemented instructions. -It is a program error signal. +The default action is to terminate the process. +@end deftypevr -@item SIGSYS -Bad system call; that is to say, the instruction to trap to the -operating system was executed, but the code number for the system call -to perform was invalid. This is a program error signal. +@comment signal.h +@comment BSD +@deftypevr Macro int SIGWINCH +Window size change. This is generated on some systems (including GNU) +when the terminal driver's record of the number of rows and columns on +the screen is changed. The default action is to ignore it. -@item SIGPOLL -This is a System V signal name, more or less similar to @code{SIGIO}. +If a program does full-screen display, it should handle @code{SIGWINCH}. +When the signal arrives, it should fetch the new screen size and +reformat its display accordingly. +@end deftypevr -@item SIGXCPU -CPU time limit exceeded. This is used for batch processing. -Default action is program termination. - -@item SIGXFSZ -File size limit exceeded. This is used for batch processing. -Default action is program termination. - -@item SIGWINCH -Window size change. This is generated on certain systems when the size -of the current window on the screen is changed. Default action is to -ignore it. -@end table +@comment signal.h +@comment BSD +@deftypevr Macro int SIGINFO +Information request. In 4.4 BSD and the GNU system, this signal is sent +to all the processes in the foreground process group of the controlling +terminal when the user types the STATUS character in canonical mode; +@pxref{Signal Characters}. +If the process is the leader of the process group, the default action is +to print some status information about the system and what the process +is doing. Otherwise the default is to do nothing. +@end deftypevr @node Signal Messages @subsection Signal Messages @@ -1082,17 +1146,17 @@ @comment signal.h @comment POSIX.1 -@deftypefun int sigaction (int @var{signum}, const struct sigaction *@var{action}, struct sigaction *@var{old_action}) +@deftypefun int sigaction (int @var{signum}, const struct sigaction *@var{action}, struct sigaction *@var{old-action}) The @var{action} argument is used to set up a new action for the signal -@var{signum}, while the @var{old_action} argument is used to return +@var{signum}, while the @var{old-action} argument is used to return information about the action previously associated with this symbol. -(In other words, @var{old_action} has the same purpose as the +(In other words, @var{old-action} has the same purpose as the @code{signal} function's return value---you can check to see what the old action in effect for the signal was, and restore it later if you want.) -Either @var{action} or @var{old_action} can be a null pointer. If -@var{old_action} is a null pointer, this simply suppresses the return +Either @var{action} or @var{old-action} can be a null pointer. If +@var{old-action} is a null pointer, this simply suppresses the return of information about the old action. If @var{action} is a null pointer, the action associated with the signal @var{signum} is unchanged; this allows you to inquire about how a signal is being handled without changing @@ -1129,11 +1193,12 @@ reestablish any action, regardless of whether it was established originally with @code{signal} or @code{sigaction}. -If you establish an action with @code{signal} and then examine it with -@code{sigaction}, the handler address that you get may not be the same -as what you specified with @code{signal}. It may not even be suitable -for use as an action argument with @code{signal}. But you can rely on -using it as an argument to @code{sigaction}. +On some systems if you establish an action with @code{signal} and then +examine it with @code{sigaction}, the handler address that you get may +not be the same as what you specified with @code{signal}. It may not +even be suitable for use as an action argument with @code{signal}. But +you can rely on using it as an argument to @code{sigaction}. This +problem never happens on the GNU system. So, you're better off using one or the other of the mechanisms consistently within a single program. @@ -1253,8 +1318,9 @@ @comment BSD @deftypevr Macro int SA_ONSTACK If this flag is set for a particular signal number, the system uses the -signal stack when delivering that kind of signal. @xref{BSD Signal -Handling}. +signal stack when delivering that kind of signal. @xref{Signal Stack}. +If a signal with this flag arrives and you have not set a signal stack, +the system terminates the program with @code{SIGILL}. @end deftypevr @comment signal.h @@ -1361,7 +1427,7 @@ @end menu @node Handler Returns -@subsection Signal Handlers That Return +@subsection Signal Handlers that Return Handlers which return normally are usually used for signals such as @code{SIGALRM} and the I/O and interprocess communication signals. But @@ -1513,11 +1579,11 @@ @subsection Signals Arriving While a Handler Runs @cindex race conditions, relating to signals -What happens if another signal arrives when your signal handler function -is running? +What happens if another signal arrives while your signal handler +function is running? When the handler for a particular signal is invoked, that signal is -normally blocked until the handler returns. That means that if two +automatically blocked until the handler returns. That means that if two signals of the same kind arrive close together, the second one will be held until the first has been handled. (The handler can explicitly unblock the signal using @code{sigprocmask}, if you want to allow more @@ -1531,6 +1597,11 @@ and any other signals that are normally blocked by the process. @xref{Blocking for Handler}. +When the handler returns, the set of blocked signals is restored to the +value it had before the handler ran. So using @code{sigprocmask} inside +the handler only affects what signals can arrive during the execution of +the handler itself, not what signals can arrive once the handler returns. + @strong{Portability Note:} Always use @code{sigaction} to establish a handler for a signal that you expect to receive asynchronously, if you want your program to work properly on System V Unix. On this system, @@ -1713,12 +1784,12 @@ write a handler that does nothing but set an external variable that the program checks regularly, and leave all serious work to the program. This is best because the handler can be called at asynchronously, at -unpredictable times---perhaps in the middle of a system call, or even -between the beginning and the end of a C operator that requires multiple -instructions. The data structures being manipulated might therefore be -in an inconsistent state when the handler function is invoked. Even -copying one @code{int} variable into another can take two instructions -on most machines. +unpredictable times---perhaps in the middle of a primitive function, or +even between the beginning and the end of a C operator that requires +multiple instructions. The data structures being manipulated might +therefore be in an inconsistent state when the handler function is +invoked. Even copying one @code{int} variable into another can take two +instructions on most machines. This means you have to be very careful about what you do in a signal handler. @@ -1795,11 +1866,14 @@ interrupted by another signal handler that does the same thing, you could ``lose'' one of the objects. +@ignore +!!! not true On the GNU system, @code{malloc} and @code{free} are safe to use in -signal handlers because it blocks signals. As a result, the library +signal handlers because they block signals. As a result, the library functions that allocate space for a result are also safe in signal handlers. The obstack allocation functions are safe as long as you don't use the same obstack both inside and outside of a signal handler. +@end ignore The relocating allocation functions (@pxref{Relocating Allocator}) are certainly not safe to use in a signal handler. @@ -1837,7 +1911,7 @@ have to be careful about the fact that access to a single datum is not necessarily @dfn{atomic}. This means that it can take more than one instruction to read or write a single object. In such cases, a signal -handler can run in the middle of reading or writing the object. +handler might in the middle of reading or writing the object. There are three ways you can cope with this problem. You can use data types that are always accessed atomically; you can carefully arrange @@ -2000,8 +2074,9 @@ that handler will cause @code{EINTR}. @xref{Flags for Sigaction}. Another way to specify the choice is with the @code{siginterrupt} -function. @xref{POSIX vs BSD}. +function. @xref{BSD Handler}. +@c !!! not true now about _BSD_SOURCE When you don't specify with @code{sigaction} or @code{siginterrupt} what a particular handler should do, it uses a default choice. The default choice in the GNU library depends on the feature test macros you have @@ -2011,11 +2086,14 @@ contains alternate versions of the @code{signal} function, and the feature test macros determine which one you really call.) @xref{Feature Test Macros}. +@cindex EINTR, and restarting interrupted primitives +@cindex restarting interrupted primitives +@cindex interrupting primitives +@cindex primitives, interrupting +@c !!! want to have @cindex system calls @i{see} primitives [no page #] -The primitives affected by this issue are @code{close}, @code{fcntl} -(operation @code{F_SETLK}), @code{open}, @code{read}, @code{recv}, -@code{recvfrom}, @code{select}, @code{send}, @code{sendto}, -@code{tcdrain}, @code{waitpid}, @code{wait}, and @code{write}. +The description of each primitive affected by this issue +lists @code{EINTR} among the error codes it can return. There is one situation where resumption never happens no matter which choice you make: when a data-transfer function such as @code{read} or @@ -2151,7 +2229,7 @@ @end itemize This section assumes that you know a little bit about how processes -work. For more information on this subject, see @ref{Child Processes}. +work. For more information on this subject, see @ref{Processes}. The @code{kill} function is declared in @file{signal.h}. @pindex signal.h @@ -2172,8 +2250,7 @@ The process whose identifier is @var{pid}. @item @var{pid} == 0 -All processes in the same process group as the sender. The sender -itself does not receive the signal. +All processes in the same process group as the sender. @item @var{pid} < -1 The process group whose identifier is @minus{}@var{pid}. @@ -2623,7 +2700,10 @@ your handler to block or unblock signals as you wish. In any case, when the handler returns, the system restores the mask that -was in place before the handler was entered. +was in place before the handler was entered. If any signals that become +unblocked by this restoration are pending, the process will receive +those signals immediately, before returning to the code that was +interrupted. @node Checking for Pending Signals @subsection Checking for Pending Signals @@ -2946,6 +3026,142 @@ just once for each kind of wait criterion you want to use. The code that actually waits is just four lines. +@node Signal Stack +@section Using a Separate Signal Stack + +A signal stack is a special area of memory to be used as the execution +stack during signal handlers. It should be fairly large, to avoid any +danger that it will overflow in turn; the macro @code{SIGSTKSZ} is +defined to a canonical size for signal stacks. You can use +@code{malloc} to allocate the space for the stack. Then call +@code{sigaltstack} or @code{sigstack} to tell the system to use that +space for the signal stack. + +You don't need to write signal handlers differently in order to use a +signal stack. Switching from one stack to the other happens +automatically. (Some non-GNU debuggers on some machines may get +confused if you examine a stack trace while a handler that uses the +signal stack is running.) + +There are two interfaces for telling the system to use a separate signal +stack. @code{sigstack} is the older interface, which comes from 4.2 +BSD. @code{sigaltstack} is the newer interface, and comes from 4.4 +BSD. The @code{sigaltstack} interface has the advantage that it does +not require your program to know which direction the stack grows, which +depends on the specific machine and operating system. + +@comment signal.h +@comment BSD +@deftp {Data Type} {struct sigaltstack} +This structure describes a signal stack. It contains the following members: + +@table @code +@item void *ss_sp +This points to the base of the signal stack. + +@item size_t ss_size +This is the size (in bytes) of the signal stack which @samp{ss_sp} points to. +You should set this to however much space you allocated for the stack. + +There are two macros defined in @file{signal.h} that you should use in +calculating this size: + +@vtable @code +@item SIGSTKSZ +This is the canonical size for a signal stack. It is judged to be +sufficient for normal uses. + +@item MINSIGSTKSZ +This is the amount of signal stack space the operating system needs just +to implement signal delivery. The size of a signal stack @strong{must} +be greater than this. + +For most cases, just using @code{SIGSTKSZ} for @code{ss_size} is +sufficient. But if you know how much stack space your program's signal +handlers will need, you may want to use a different size. In this case, +you should allocate @code{MINSIGSTKSZ} additional bytes for the signal +stack and increase @code{ss_size} accordinly. +@end vtable + +@item int ss_flags +This field contains the bitwise @sc{or} of these flags: + +@vtable @code +@item SA_DISABLE +This tells the system that it should not use the signal stack. + +@item SA_ONSTACK +This is set by the system, and indicates that the signal stack is +currently in use. If this bit is not set, then signals will be +delivered on the normal user stack. +@end vtable +@end table +@end deftp + +@comment signal.h +@comment BSD +@deftypefun int sigaltstack (const struct sigaltstack *@var{stack}, struct sigaltstack *@var{oldstack}) +The @code{sigaltstack} function specifies an alternate stack for use +during signal handling. When a signal is received by the process and +its action indicates that the signal stack is used, the system arranges +a switch to the currently installed signal stack while the handler for +that signal is executed. + +If @var{oldstack} is not a null pointer, information about the currently +installed signal stack is returned in the location it points to. If +@var{stack} is not a null pointer, then this is installed as the new +stack for use by signal handlers. + +The return value is @code{0} on success and @code{-1} on failure. If +@code{sigaltstack} fails, it sets @code{errno} to one of these values: + +@table @code +@item +@item EINVAL +You tried to disable a stack that was in fact currently in use. + +@item ENOMEM +The size of the alternate stack was too small. +It must be greater than @code{MINSIGSTKSZ}. +@end table +@end deftypefun + +Here is the older @code{sigstack} interface. You should use +@code{sigaltstack} instead on systems that have it. + +@comment signal.h +@comment BSD +@deftp {Data Type} {struct sigstack} +This structure describes a signal stack. It contains the following members: + +@table @code +@item void *ss_sp +This is the stack pointer. If the stack grows downwards on your +machine, this should point to the top of the area you allocated. If the +stack grows upwards, it should point to the bottom. + +@item int ss_onstack +This field is true if the process is currently using this stack. +@end table +@end deftp + +@comment signal.h +@comment BSD +@deftypefun int sigstack (const struct sigstack *@var{stack}, struct sigstack *@var{oldstack}) +The @code{sigstack} function specifies an alternate stack for use during +signal handling. When a signal is received by the process and its +action indicates that the signal stack is used, the system arranges a +switch to the currently installed signal stack while the handler for +that signal is executed. + +If @var{oldstack} is not a null pointer, information about the currently +installed signal stack is returned in the location it points to. If +@var{stack} is not a null pointer, then this is installed as the new +stack for use by signal handlers. + +The return value is @code{0} on success and @code{-1} on failure. +@end deftypefun + @node BSD Signal Handling @section BSD Signal Handling @@ -2954,19 +3170,6 @@ they are mostly obsolete, and supported mainly for compatibility with BSD Unix. -They do provide one feature that is not available through the POSIX -functions: You can specify a separate stack for use in certain signal -handlers. Using a signal stack is the only way you can handle a signal -caused by stack overflow. - -@menu -* POSIX vs BSD:: Overview comparing BSD and POSIX signal - functions. -@end menu - -@node POSIX vs BSD -@subsection POSIX and BSD Signal Facilities - There are many similarities between the BSD and POSIX signal handling facilities, because the POSIX facilities were inspired by the BSD facilities. Besides having different names for all the functions to @@ -2983,19 +3186,18 @@ calls fail unless you specify that they should resume. With the BSD facility, the default is to make system calls resume unless you say they should fail. @xref{Interrupted Primitives}. - -@item -BSD Unix has a concept of a @dfn{signal stack}. This is an alternate -stack that is used during the execution of signal handler functions, -instead of its normal execution stack. -@cindex signal stack @end itemize The BSD facilities are declared in @file{signal.h}. @pindex signal.h +@menu +* BSD Handler:: BSD Function to Establish a Handler. +* Blocking in BSD:: BSD Functions for Blocking Signals. +@end menu + @node BSD Handler -@section BSD Function to Establish a Handler +@subsection BSD Function to Establish a Handler @comment signal.h @comment BSD @@ -3050,11 +3252,11 @@ @comment signal.h @comment BSD -@deftypefun int sigvec (int @var{signum}, const struct sigvec *@var{action},struct sigvec *@var{old_action}) +@deftypefun int sigvec (int @var{signum}, const struct sigvec *@var{action},struct sigvec *@var{old-action}) This function is the equivalent of @code{sigaction} (@pxref{Advanced Signal Handling}); it installs the action @var{action} for the signal @var{signum}, returning information about the previous action in effect for that signal -in @var{old_action}. +in @var{old-action}. @end deftypefun @comment signal.h @@ -3067,11 +3269,6 @@ code @code{EINTR}. @xref{Interrupted Primitives}. @end deftypefun -@menu -* Blocking in BSD:: BSD Functions for Blocking Signals. -* Signal Stack:: Using a Separate Signal Stack. -@end menu - @node Blocking in BSD @subsection BSD Functions for Blocking Signals @@ -3116,140 +3313,4 @@ for a Signal}): it sets the calling process's signal mask to @var{mask}, and waits for a signal to arrive. On return the previous set of blocked signals is restored. -@end deftypefun - -@node Signal Stack -@subsection Using a Separate Signal Stack - -A signal stack is a special area of memory to be used as the execution -stack during signal handlers. It should be fairly large, to avoid any -danger that it will overflow in turn; the macro @code{SIGSTKSZ} is -defined to a canonical size for signal stacks. You can use -@code{malloc} to allocate the space for the stack. Then call -@code{sigaltstack} or @code{sigstack} to tell the system to use that -space for the signal stack. - -You don't need to write signal handlers differently in order to use a -signal stack. Switching from one stack to the other happens -automatically. However, some debuggers on some machines may get -confused if you examine a stack trace while a handler that uses the -signal stack is running. - -There are two interfaces for telling the system to use a separate signal -stack. @code{sigstack} is the older interface, which comes from 4.2 -BSD. @code{sigaltstack} is the newer interface, and comes from 4.4 -BSD. The @code{sigaltstack} interface has the advantage that it does -not require your program to know which direction the stack grows, which -depends on the specific machine and operating system. - -@comment signal.h -@comment BSD -@deftp {Data Type} {struct sigaltstack} -This structure describes a signal stack. It contains the following members: - -@table @code -@item void *ss_sp -This points to the base of the signal stack. - -@item size_t ss_size -This is the size (in bytes) of the signal stack which @samp{ss_sp} points to. -You should set this to however much space you allocated for the stack. - -There are two macros defined in @file{signal.h} that you should use in -calculating this size: - -@vtable @code -@item SIGSTKSZ -This is the canonical size for a signal stack. It is judged to be -sufficient for normal uses. - -@item MINSIGSTKSZ -This is the amount of signal stack space the operating system needs just -to implement signal delivery. The size of a signal stack @strong{must} -be greater than this. - -For most cases, just using @code{SIGSTKSZ} for @code{ss_size} is -sufficient. But if you know how much stack space your program's signal -handlers will need, you may want to use a different size. In this case, -you should allocate @code{MINSIGSTKSZ} additional bytes for the signal -stack and increase @code{ss_size} accordinly. -@end vtable - -@item int ss_flags -This field contains the bitwise @sc{or} of these flags: - -@vtable @code -@item SA_DISABLE -This tells the system that it should not use the signal stack. - -@item SA_ONSTACK -This is set by the system, and indicates that the signal stack is -currently in use. If this bit is not set, then signals will be -delivered on the normal user stack. -@end vtable -@end table -@end deftp - -@comment signal.h -@comment BSD -@deftypefun int sigaltstack (const struct sigaltstack *@var{stack}, struct sigaltstack *@var{oldstack}) -The @code{sigaltstack} function specifies an alternate stack for use -during signal handling. When a signal is received by the process and -its action indicates that the signal stack is used, the system arranges -a switch to the currently installed signal stack while the handler for -that signal is executed. - -If @var{oldstack} is not a null pointer, information about the currently -installed signal stack is returned in the location it points to. If -@var{stack} is not a null pointer, then this is installed as the new -stack for use by signal handlers. - -The return value is @code{0} on success and @code{-1} on failure. If -@code{sigaltstack} fails, it sets @code{errno} to one of these values: - -@table @code -@item -@item EINVAL -You tried to disable a stack that was in fact currently in use. - -@item ENOMEM -The size of the alternate stack was too small. -It must be greater than @code{MINSIGSTKSZ}. -@end table -@end deftypefun - -Here is the older @code{sigstack} interface. You should use -@code{sigaltstack} instead on systems that have it. - -@comment signal.h -@comment BSD -@deftp {Data Type} {struct sigstack} -This structure describes a signal stack. It contains the following members: - -@table @code -@item void *ss_sp -This is the stack pointer. If the stack grows downwards on your -machine, this should point to the top of the area you allocated. If the -stack grows upwards, it should point to the bottom. - -@item int ss_onstack -This field is true if the process is currently using this stack. -@end table -@end deftp - -@comment signal.h -@comment BSD -@deftypefun int sigstack (const struct sigstack *@var{stack}, struct sigstack *@var{oldstack}) -The @code{sigstack} function specifies an alternate stack for use during -signal handling. When a signal is received by the process and its -action indicates that the signal stack is used, the system arranges a -switch to the currently installed signal stack while the handler for -that signal is executed. - -If @var{oldstack} is not a null pointer, information about the currently -installed signal stack is returned in the location it points to. If -@var{stack} is not a null pointer, then this is installed as the new -stack for use by signal handlers. - -The return value is @code{0} on success and @code{-1} on failure. @end deftypefun diff -ruN glibc-1.08.1/manual/socket.texi glibc-1.09/manual/socket.texi --- glibc-1.08.1/manual/socket.texi Thu Feb 10 02:07:29 1994 +++ glibc-1.09/manual/socket.texi Thu Oct 6 01:42:13 1994 @@ -379,7 +379,7 @@ @item EINVAL The socket @var{socket} already has an address. -@item EACCESS +@item EACCES You do not have permission to access the requested address. (In the Internet domain, only the super-user is allowed to specify a port number in the range 0 through @code{IPPORT_RESERVED} minus one; see @@ -400,11 +400,11 @@ @comment sys/socket.h @comment BSD -@deftypefun int getsockname (int @var{socket}, struct sockaddr *@var{addr}, size_t *@var{length_ptr}) +@deftypefun int getsockname (int @var{socket}, struct sockaddr *@var{addr}, size_t *@var{length-ptr}) The @code{getsockname} function returns information about the address of the socket @var{socket} in the locations specified by the -@var{addr} and @var{length_ptr} arguments. Note that the -@var{length_ptr} is a pointer; you should initialize it to be the +@var{addr} and @var{length-ptr} arguments. Note that the +@var{length-ptr} is a pointer; you should initialize it to be the allocation size of @var{addr}, and on return it contains the actual size of the address data. @@ -1655,10 +1655,14 @@ @cindex sockets, listening Now let us consider what the server process must do to accept -connections on a socket. This involves the use of the @code{listen} -function to enable connection requests on the socket, and later using -the @code{accept} function (@pxref{Accepting Connections}) to act on a -request. The @code{listen} function is not allowed for sockets using +connections on a socket. First it must use the @code{listen} function +to enable connection requests on the socket, and then accept each +incoming connection with a call to @code{accept} (@pxref{Accepting +Connections}). Once connection requests are enabled on a server socket, +the @code{select} function reports when the socket has a connection +ready to be accepted (@pxref{Waiting for I/O}). + +The @code{listen} function is not allowed for sockets using connectionless communication styles. You can write a network server that does not even start running until a @@ -1677,11 +1681,13 @@ @comment sys/socket.h @comment BSD @deftypefun int listen (int @var{socket}, unsigned int @var{n}) -The @code{listen} function enables the socket @var{socket} to -accept connections, thus making it a server socket. +The @code{listen} function enables the socket @var{socket} to accept +connections, thus making it a server socket. The argument @var{n} specifies the length of the queue for pending -connections. +connections. When the queue fills, new clients attempting to connect +fail with @code{ECONNREFUSED} until the server calls @code{accept} to +accept a connection from the queue. The @code{listen} function returns @code{0} on success and @code{-1} on failure. The following @code{errno} error conditions are defined @@ -1726,7 +1732,7 @@ @comment sys/socket.h @comment BSD -@deftypefun int accept (int @var{socket}, struct sockaddr *@var{addr}, size_t *@var{length_ptr}) +@deftypefun int accept (int @var{socket}, struct sockaddr *@var{addr}, size_t *@var{length-ptr}) This function is used to accept a connection request on the server socket @var{socket}. @@ -1736,7 +1742,7 @@ socket.) @xref{File Status Flags}, for information about nonblocking mode. -The @var{addr} and @var{length_ptr} arguments are used to return +The @var{addr} and @var{length-ptr} arguments are used to return information about the name of the client socket that initiated the connection. @xref{Socket Addresses}, for information about the format of the information. @@ -1778,11 +1784,11 @@ @comment sys/socket.h @comment BSD -@deftypefun int getpeername (int @var{socket}, struct sockaddr *@var{addr}, size_t *@var{length_ptr}) +@deftypefun int getpeername (int @var{socket}, struct sockaddr *@var{addr}, size_t *@var{length-ptr}) The @code{getpeername} function returns the address of the socket that @var{socket} is connected to; it stores the address in the memory space -specified by @var{addr} and @var{length_ptr}. It stores the length of -the address in @code{*@var{length_ptr}}. +specified by @var{addr} and @var{length-ptr}. It stores the length of +the address in @code{*@var{length-ptr}}. @xref{Socket Addresses}, for information about the format of the address. In some operating systems, @code{getpeername} works only for @@ -2249,7 +2255,7 @@ @comment sys/socket.h @comment BSD -@deftypefun int recvfrom (int @var{socket}, void *@var{buffer}, size_t @var{size}, int @var{flags}, struct sockaddr *@var{addr}, size_t *@var{length_ptr}) +@deftypefun int recvfrom (int @var{socket}, void *@var{buffer}, size_t @var{size}, int @var{flags}, struct sockaddr *@var{addr}, size_t *@var{length-ptr}) The @code{recvfrom} function reads one packet from the socket @var{socket} into the buffer @var{buffer}. The @var{size} argument specifies the maximum number of bytes to be read. @@ -2259,7 +2265,7 @@ There's no way to read the rest of the packet. Thus, when you use a packet protocol, you must always know how long a packet to expect. -The @var{addr} and @var{length_ptr} arguments are used to return the +The @var{addr} and @var{length-ptr} arguments are used to return the address where the packet came from. @xref{Socket Addresses}. For a socket in the file domain, the address information won't be meaningful, since you can't read the address of such a socket (@pxref{File @@ -2476,12 +2482,12 @@ @comment sys/socket.h @comment BSD -@deftypefun int getsockopt (int @var{socket}, int @var{level}, int @var{optname}, void *@var{optval}, size_t *@var{optlen_ptr}) +@deftypefun int getsockopt (int @var{socket}, int @var{level}, int @var{optname}, void *@var{optval}, size_t *@var{optlen-ptr}) The @code{getsockopt} function gets information about the value of option @var{optname} at level @var{level} for socket @var{socket}. The option value is stored in a buffer that @var{optval} points to. -Before the call, you should supply in @code{*@var{optlen_ptr}} the +Before the call, you should supply in @code{*@var{optlen-ptr}} the size of this buffer; on return, it contains the number of bytes of information actually stored in the buffer. diff -ruN glibc-1.08.1/manual/stamp-summary glibc-1.09/manual/stamp-summary --- glibc-1.08.1/manual/stamp-summary Thu May 19 03:47:34 1994 +++ glibc-1.09/manual/stamp-summary Fri Nov 4 16:51:01 1994 @@ -1 +1 @@ -Thu May 19 03:47:31 EDT 1994 +Fri Nov 4 16:51:01 EST 1994 diff -ruN glibc-1.08.1/manual/startup.texi glibc-1.09/manual/startup.texi --- glibc-1.08.1/manual/startup.texi Mon Feb 7 18:28:26 1994 +++ glibc-1.09/manual/startup.texi Wed Oct 26 01:33:45 1994 @@ -1,4 +1,4 @@ -@node Process Startup, Child Processes, Signal Handling, Top +@node Process Startup @chapter Process Startup and Termination @cindex process @@ -25,15 +25,20 @@ @section Program Arguments @cindex program arguments @cindex command line arguments +@cindex arguments, to program +@cindex program startup +@cindex startup of program +@cindex invocation of program @cindex @code{main} function +@findex main The system starts a C program by calling the function @code{main}. It is up to you to write a function named @code{main}---otherwise, you won't even be able to link your program without errors. -You can define @code{main} either to take no arguments, or to take two -arguments that represent the command line arguments to the program, like -this: +In ANSI C you can define @code{main} either to take no arguments, or to +take two arguments that represent the command line arguments to the +program, like this: @smallexample int main (int @var{argc}, char *@var{argv}[]) @@ -65,6 +70,18 @@ arguments are interpreted in the same way (as file names, for example), you are usually better off using @code{getopt} to do the parsing. +In Unix systems you can define @code{main} a third way, using three arguments: + +@smallexample +int main (int @var{argc}, char *@var{argv}[], char *@var{envp}) +@end smallexample + +The first two arguments are just the same. The third argument +@var{envp} gives the process's environment; it is the same as the value +of @code{environ}. @xref{Environment Variables}. POSIX.1 does not +allow this three-argument form, so to be portable it is best to write +@code{main} to take two arguments, and use the value of @code{environ}. + @menu * Argument Syntax:: By convention, options start with a hyphen. * Parsing Options:: The @code{getopt} function. @@ -405,7 +422,7 @@ arguments specific to the particular program being invoked. The environment, on the other hand, keeps track of information that is shared by many programs, changes infrequently, and that is less -frequently accessed. +frequently used. The environment variables discussed in this section are the same environment variables that you set using assignments and the @@ -493,14 +510,18 @@ @code{getenv}. @end deftypevar +Unix systems, and the GNU system, pass the initial value of +@code{environ} as the third argument to @code{main}. +@xref{Program Arguments}. + @node Standard Environment @subsection Standard Environment Variables @cindex standard environment variables These environment variables have standard meanings. This doesn't mean that they are always present in the environment; but if these variables -@emph{are} present, they have these meanings, and that you shouldn't try -to use these environment variable names for some other purpose. +@emph{are} present, they have these meanings. You shouldn't try to use +these environment variable names for some other purpose. @comment Extra blank lines make it look better. @table @code @@ -857,6 +878,8 @@ @itemize @bullet @item All open file descriptors in the process are closed. @xref{Low-Level I/O}. +Note that streams are not flushed automatically when the process +terminates; @xref{I/O on Streams}. @item The low-order 8 bits of the return status code are saved to be reported @@ -865,7 +888,8 @@ @item Any child processes of the process being terminated are assigned a new -parent process. (This is the @code{init} process, with process ID 1.) +parent process. (On most systems, including GNU, this is the @code{init} +process, with process ID 1.) @item A @code{SIGCHLD} signal is sent to the parent process. diff -ruN glibc-1.08.1/manual/stdio.texi glibc-1.09/manual/stdio.texi --- glibc-1.08.1/manual/stdio.texi Mon May 23 20:17:12 1994 +++ glibc-1.09/manual/stdio.texi Thu Oct 20 00:39:54 1994 @@ -185,8 +185,10 @@ The GNU C library defines one additional character for use in @var{opentype}: the character @samp{x} insists on creating a new file---if a file @var{filename} already exists, @code{fopen} fails -rather than opening it. This is equivalent to the @code{O_EXCL} option -to the @code{open} function (@pxref{File Status Flags}). +rather than opening it. If you use @samp{x} you can are guaranteed that +you will not clobber an existing file. This is equivalent to the +@code{O_EXCL} option to the @code{open} function (@pxref{Opening and +Closing Files}). The character @samp{b} in @var{opentype} has a standard meaning; it requests a binary stream rather than a text stream. But this makes no @@ -217,7 +219,10 @@ guarantees can be open simultaneously. You might be able to open more than this many streams, but that is not guaranteed. The value of this constant is at least eight, which includes the three standard streams -@code{stdin}, @code{stdout}, and @code{stderr}. +@code{stdin}, @code{stdout}, and @code{stderr}. In POSIX.1 systems this +value is determined by the @code{OPEN_MAX} parameter; @pxref{General +Limits}. In BSD and GNU, it is controlled by the @code{RLIMIT_NOFILE} +resource limit; @pxref{Limits on Resources}. @end deftypevr @comment stdio.h @@ -275,9 +280,9 @@ automatically closed properly. If your program terminates in any other manner, such as by calling the @code{abort} function (@pxref{Aborting a Program}) or from a fatal signal (@pxref{Signal Handling}), open streams -might not be closed properly. Buffered output may not be flushed and -files may not be complete. For more information on buffering of -streams, see @ref{Stream Buffering}. +might not be closed properly. Buffered output might not be flushed and +files may be incomplete. For more information on buffering of streams, +see @ref{Stream Buffering}. @node Simple Output @section Simple Output by Characters or Lines @@ -859,6 +864,14 @@ individual conversions for information about the particular options that they use. +With the @samp{-Wformat} option, the GNU C compiler checks calls to +@code{printf} and related functions. It examines the format string and +verifies that the correct number and types of arguments are supplied. +There is also a GNU C syntax to tell the compiler that a function you +write uses a @code{printf}-style format string. +@xref{Function Attributes, , Declaring Attributes of Functions, +gcc.info, Using GNU CC}, for more information. + @node Table of Output Conversions @subsection Table of Output Conversions @cindex output conversions, for @code{printf} @@ -1002,13 +1015,20 @@ @item l Specifies that the argument is a @code{long int} or @code{unsigned long -int}, as appropriate. +int}, as appropriate. Two @samp{l} characters is like the @samp{L} +modifier, below. @item L +@itemx ll +@itemx q Specifies that the argument is a @code{long long int}. (This type is an extension supported by the GNU C compiler. On systems that don't support extra-long integers, this is the same as @code{long int}.) +The @samp{q} modifier is another name for the same thing, which comes +from 4.4 BSD; a @w{@code{long long int}} is sometimes called a ``quad'' +@code{int}. + @item Z Specifies that the argument is a @code{size_t}. This is a GNU extension. @end table @@ -1112,7 +1132,7 @@ the first digit before the decimal point, and all the digits after it. If the precision @code{0} or not specified for @samp{%g} or @samp{%G}, it is treated like a value of @code{1}. If the value being printed -cannot be expressed precisely in the specified number of digits, the +cannot be expressed accurately in the specified number of digits, the value is rounded to the nearest number that fits. Without a type modifier, the floating-point conversions use an argument @@ -1453,7 +1473,6 @@ This function is similar to @code{printf} except that, instead of taking a variable number of arguments directly, it takes an argument list pointer @var{ap}. - @end deftypefun @comment stdio.h @@ -1504,7 +1523,7 @@ #include void -eprintf (char *template, ...) +eprintf (const char *template, ...) @{ va_list ap; extern char *program_invocation_short_name; @@ -1524,6 +1543,25 @@ eprintf ("file `%s' does not exist\n", filename); @end smallexample +In GNU C, there is a special construct you can use to let the compiler +know that a function uses a @code{printf}-style format string. Then it +can check the number and types of arguments in each call to the +function, and warn you when they do not match the format string. +For example, take this declaration of @code{eprintf}: + +@smallexample +void eprintf (const char *template, ...) + __attribute__ ((format (printf, 1, 2))); +@end smallexample + +@noindent +This tells the compiler that @code{eprintf} uses a format string like +@code{printf} (as opposed to @code{scanf}; @pxref{Formatted Input}); +the format string appears as the first argument; +and the arguments to satisfy the format begin with the second. +@xref{Function Attributes, , Declaring Attributes of Functions, +gcc.info, Using GNU CC}, for more information. + @node Parsing a Template String @subsection Parsing a Template String @cindex parsing a template string @@ -1790,17 +1828,17 @@ @comment printf.h @comment GNU -@deftypefun int register_printf_function (int @var{spec}, printf_function @var{handler_function}, printf_arginfo_function @var{arginfo_function}) +@deftypefun int register_printf_function (int @var{spec}, printf_function @var{handler-function}, printf_arginfo_function @var{arginfo-function}) This function defines the conversion specifier character @var{spec}. Thus, if @var{spec} is @code{'q'}, it defines the conversion @samp{%q}. -The @var{handler_function} is the function called by @code{printf} and +The @var{handler-function} is the function called by @code{printf} and friends when this conversion appears in a template string. @xref{Defining the Output Handler}, for information about how to define a function to pass as this argument. If you specify a null pointer, any existing handler function for @var{spec} is removed. -The @var{arginfo_function} is the function called by +The @var{arginfo-function} is the function called by @code{parse_printf_format} when this conversion appears in a template string. @xref{Parsing a Template String}, for information about this. @@ -1825,7 +1863,7 @@ the handler when called needs to be able to get the options specified in the template. -Both the @var{handler_function} and @var{arginfo_function} arguments +Both the @var{handler-function} and @var{arginfo-function} arguments to @code{register_printf_function} accept an argument of type @code{struct printf_info}, which contains information about the options appearing in an instance of the conversion specifier. This data type @@ -1937,7 +1975,7 @@ If you are going to use @code{parse_printf_format} in your application, you should also define a function to pass as the -@var{arginfo_function} argument for each new conversion you install with +@var{arginfo-function} argument for each new conversion you install with @code{register_printf_function}. You should define these functions with a prototype like: @@ -2140,6 +2178,14 @@ individual conversions for information about the particular options that they allow. +With the @samp{-Wformat} option, the GNU C compiler checks calls to +@code{scanf} and related functions. It examines the format string and +verifies that the correct number and types of arguments are supplied. +There is also a GNU C syntax to tell the compiler that a function you +write uses a @code{scanf}-style format string. +@xref{Function Attributes, , Declaring Attributes of Functions, +gcc.info, Using GNU CC}, for more information. + @node Table of Input Conversions @subsection Table of Input Conversions @cindex input conversions, for @code{scanf} @@ -2250,12 +2296,18 @@ @item l Specifies that the argument is a @code{long int *} or @code{unsigned -long int *}. +long int *}. Two @samp{l} characters is like the @samp{L} modifier, below. -@item L +@item ll +@itemx L +@itemx q Specifies that the argument is a @code{long long int *} or @code{unsigned long long int *}. (The @code{long long} type is an extension supported by the GNU C compiler. For systems that don't provide extra-long integers, this is the same as @code{long int}.) + +The @samp{q} modifier is another name for the same thing, which comes +from 4.4 BSD; a @w{@code{long long int}} is sometimes called a ``quad'' +@code{int}. @end table All of the @samp{%e}, @samp{%f}, @samp{%g}, @samp{%E}, and @samp{%G} @@ -2530,6 +2582,13 @@ specified directly as for @code{vscanf}. @end deftypefun +In GNU C, there is a special construct you can use to let the compiler +know that a function uses a @code{scanf}-style format string. Then it +can check the number and types of arguments in each call to the +function, and warn you when they do not match the format string. +@xref{Function Attributes, , Declaring Attributes of Functions, +gcc.info, Using GNU CC}, for details. + @node Block Input/Output @section Block Input/Output @@ -2921,8 +2980,7 @@ streams, you need to understand how buffering works when you design the user interface to your program. Otherwise, you might find that output (such as progress or prompt messages) doesn't appear when you intended -it to, or that input typed by the user is made available by lines -instead of by single characters, or other unexpected behavior. +it to, or other unexpected behavior. This section deals only with controlling when characters are transmitted between the stream and the file or device, and @emph{not} with how @@ -2952,9 +3010,8 @@ @cindex unbuffered stream @item -Characters written to or read from a @dfn{line buffered} stream are -transmitted to or from the file in blocks when a newline character is -encountered. +Characters written to a @dfn{line buffered} stream are transmitted to +the file in blocks when a newline character is encountered. @cindex line buffered stream @item @@ -2966,7 +3023,9 @@ Newly opened streams are normally fully buffered, with one exception: a stream connected to an interactive device such as a terminal is initially line buffered. @xref{Controlling Buffering}, for information -on how to select a different kind of buffering. +on how to select a different kind of buffering. Usually the automatic +selection gives you the most convenient kind of buffering for the file +or device you open. The use of line buffering for interactive devices implies that output messages ending in a newline will appear immediately---which is usually @@ -2975,25 +3034,6 @@ should flush buffered output explicitly with @code{fflush}, as described in @ref{Flushing Buffers}. -Line buffering is a good default for terminal input as well, because -most interactive programs read commands that are normally single lines. -The program should be able to execute each line right away. A line -buffered stream permits this, whereas a fully buffered stream would -always read enough text to fill the buffer before allowing the program -to read any of it. Line buffering also fits in with the usual -input-editing facilities of most operating systems, which work within a -line of input. - -Some programs need an unbuffered terminal input stream. These include -programs that read single-character commands (like Emacs) and programs -that do their own input editing (such as those that use readline). In -order to read a character at a time, it is not enough to turn off -buffering in the input stream; you must also turn off input editing in -the operating system. This requires changing the terminal mode -(@pxref{Terminal Modes}). If you want to change the terminal modes, you -have to do this separately---merely using an unbuffered stream does not -change the modes. - @node Flushing Buffers @subsection Flushing Buffers @@ -3428,9 +3468,9 @@ @comment stdio.h @comment GNU -@deftypefun {FILE *} fopencookie (void *@var{cookie}, const char *@var{opentype}, cookie_io_functions_t @var{io_functions}) +@deftypefun {FILE *} fopencookie (void *@var{cookie}, const char *@var{opentype}, cookie_io_functions_t @var{io-functions}) This function actually creates the stream for communicating with the -@var{cookie} using the functions in the @var{io_functions} argument. +@var{cookie} using the functions in the @var{io-functions} argument. The @var{opentype} argument is interpreted as for @code{fopen}; see @ref{Opening Streams}. (But note that the ``truncate on open'' option is ignored.) The new stream is fully buffered. diff -ruN glibc-1.08.1/manual/string.texi glibc-1.09/manual/string.texi --- glibc-1.08.1/manual/string.texi Mon Feb 7 18:28:10 1994 +++ glibc-1.09/manual/string.texi Mon Oct 10 23:49:07 1994 @@ -265,7 +265,8 @@ @var{size} characters into @var{to}. If the length of @var{from} is more than @var{size}, then @code{strncpy} -copies just the first @var{size} characters. +copies just the first @var{size} characters. Note that in this case +there is no null terminator written into @var{to}. If the length of @var{from} is less than @var{size}, then @code{strncpy} copies all of @var{from}, followed by enough null characters to add up @@ -801,10 +802,10 @@ @comment string.h @comment GNU -@deftypefun {void *} memmem (const void *@var{needle}, size_t @var{needle_len},@*const void *@var{haystack}, size_t @var{haystack_len}) +@deftypefun {void *} memmem (const void *@var{needle}, size_t @var{needle-len},@*const void *@var{haystack}, size_t @var{haystack-len}) This is like @code{strstr}, but @var{needle} and @var{haystack} are byte -arrays rather than null-terminated strings. @var{needle_len} is the -length of @var{needle} and @var{haystack_len} is the length of +arrays rather than null-terminated strings. @var{needle-len} is the +length of @var{needle} and @var{haystack-len} is the length of @var{haystack}.@refill This function is a GNU extension. diff -ruN glibc-1.08.1/manual/summary.texi glibc-1.09/manual/summary.texi --- glibc-1.08.1/manual/summary.texi Thu May 19 03:47:31 1994 +++ glibc-1.09/manual/summary.texi Fri Nov 4 16:50:58 1994 @@ -9,7 +9,7 @@ @file{stdlib.h} (ANSI): @ref{Absolute Value}. @comment accept -@item int accept (int @var{socket}, struct sockaddr *@var{addr}, size_t *@var{length_ptr}) +@item int accept (int @var{socket}, struct sockaddr *@var{addr}, size_t *@var{length-ptr}) @file{sys/socket.h} (BSD): @ref{Accepting Connections}. @@ -64,7 +64,7 @@ @file{stdlib.h} (GNU, BSD): @ref{Variable Size Automatic}. @comment ALTWERASE -@item ALTWERASE +@item tcflag_t ALTWERASE @file{termios.h} (BSD): @ref{Local Modes}. @@ -254,15 +254,10 @@ @file{sys/socket.h} (BSD): @ref{Setting Address}. @comment BRKINT -@item BRKINT +@item tcflag_t BRKINT @file{termios.h} (POSIX.1): @ref{Input Modes}. -@comment _BSD_SOURCE -@item _BSD_SOURCE - -(GNU): @ref{Feature Test Macros,}. - @comment bsearch @item void * bsearch (const void *@var{key}, const void *@var{array}, size_t @var{count}, size_t @var{size}, comparison_fn_t @var{compare}) @@ -299,7 +294,7 @@ @file{termios.h} (POSIX.1): @ref{Mode Data Types}. @comment CCTS_OFLOW -@item CCTS_OFLOW +@item tcflag_t CCTS_OFLOW @file{termios.h} (BSD): @ref{Control Modes}. @@ -309,19 +304,19 @@ @file{math.h} (ANSI): @ref{Rounding and Remainders}. @comment cfgetispeed -@item speed_t cfgetispeed (const struct termios *@var{termios_p}) +@item speed_t cfgetispeed (const struct termios *@var{termios-p}) @file{termios.h} (POSIX.1): @ref{Line Speed}. @comment cfgetospeed -@item speed_t cfgetospeed (const struct termios *@var{termios_p}) +@item speed_t cfgetospeed (const struct termios *@var{termios-p}) @file{termios.h} (POSIX.1): @ref{Line Speed}. @comment cfmakeraw -@item int cfmakeraw (struct termios *@var{termios_p}) +@item int cfmakeraw (struct termios *@var{termios-p}) -@file{termios.h} (BSD): @ref{Line Speed}. +@file{termios.h} (BSD): @ref{Noncanonical Input}. @comment cfree @item void cfree (void *@var{ptr}) @@ -329,17 +324,17 @@ @file{stdlib.h} (Sun): @ref{Freeing after Malloc}. @comment cfsetispeed -@item int cfsetispeed (struct termios *@var{termios_p}, speed_t @var{speed}) +@item int cfsetispeed (struct termios *@var{termios-p}, speed_t @var{speed}) @file{termios.h} (POSIX.1): @ref{Line Speed}. @comment cfsetospeed -@item int cfsetospeed (struct termios *@var{termios_p}, speed_t @var{speed}) +@item int cfsetospeed (struct termios *@var{termios-p}, speed_t @var{speed}) @file{termios.h} (POSIX.1): @ref{Line Speed}. @comment cfsetspeed -@item int cfsetspeed (struct termios *@var{termios_p}, speed_t @var{speed}) +@item int cfsetspeed (struct termios *@var{termios-p}, speed_t @var{speed}) @file{termios.h} (BSD): @ref{Line Speed}. @@ -378,6 +373,11 @@ @file{unistd.h} (POSIX.1): @ref{File Owner}. +@comment CIGNORE +@item tcflag_t CIGNORE + +@file{termios.h} (BSD): @ref{Control Modes}. + @comment clearerr @item void clearerr (FILE *@var{stream}) @@ -389,7 +389,7 @@ @file{time.h} (POSIX.1): @ref{Basic CPU Time}. @comment CLOCAL -@item CLOCAL +@item tcflag_t CLOCAL @file{termios.h} (POSIX.1): @ref{Control Modes}. @@ -474,7 +474,7 @@ @file{math.h} (ANSI): @ref{Trig Functions}. @comment CREAD -@item CREAD +@item tcflag_t CREAD @file{termios.h} (POSIX.1): @ref{Control Modes}. @@ -484,32 +484,32 @@ @file{fcntl.h} (POSIX.1): @ref{Opening and Closing Files}. @comment CRTS_IFLOW -@item CRTS_IFLOW +@item tcflag_t CRTS_IFLOW @file{termios.h} (BSD): @ref{Control Modes}. @comment CS5 -@item CS5 +@item tcflag_t CS5 @file{termios.h} (POSIX.1): @ref{Control Modes}. @comment CS6 -@item CS6 +@item tcflag_t CS6 @file{termios.h} (POSIX.1): @ref{Control Modes}. @comment CS7 -@item CS7 +@item tcflag_t CS7 @file{termios.h} (POSIX.1): @ref{Control Modes}. @comment CS8 -@item CS8 +@item tcflag_t CS8 @file{termios.h} (POSIX.1): @ref{Control Modes}. @comment CSIZE -@item CSIZE +@item tcflag_t CSIZE @file{termios.h} (POSIX.1): @ref{Control Modes}. @@ -519,7 +519,7 @@ @file{unistd.h} (POSIX.2): @ref{String Parameters}. @comment CSTOPB -@item CSTOPB +@item tcflag_t CSTOPB @file{termios.h} (POSIX.1): @ref{Control Modes}. @@ -664,6 +664,11 @@ @file{errno.h} (BSD: Operation already in progress): @ref{Error Codes,}. +@comment EAUTH +@item int EAUTH + +@file{errno.h} (BSD: Authentication error): @ref{Error Codes,}. + @comment EBACKGROUND @item int EBACKGROUND @@ -674,6 +679,11 @@ @file{errno.h} (POSIX.1: Bad file descriptor): @ref{Error Codes,}. +@comment EBADRPC +@item int EBADRPC + +@file{errno.h} (BSD: RPC struct is bad): @ref{Error Codes,}. + @comment EBUSY @item int EBUSY @@ -685,37 +695,37 @@ @file{errno.h} (POSIX.1: No child processes): @ref{Error Codes,}. @comment ECHOCTL -@item ECHOCTL +@item tcflag_t ECHOCTL @file{termios.h} (BSD): @ref{Local Modes}. @comment ECHOE -@item ECHOE +@item tcflag_t ECHOE @file{termios.h} (POSIX.1): @ref{Local Modes}. @comment ECHO -@item ECHO +@item tcflag_t ECHO @file{termios.h} (POSIX.1): @ref{Local Modes}. @comment ECHOKE -@item ECHOKE +@item tcflag_t ECHOKE @file{termios.h} (BSD): @ref{Local Modes}. @comment ECHOK -@item ECHOK +@item tcflag_t ECHOK @file{termios.h} (POSIX.1): @ref{Local Modes}. @comment ECHONL -@item ECHONL +@item tcflag_t ECHONL @file{termios.h} (POSIX.1): @ref{Local Modes}. @comment ECHOPRT -@item ECHOPRT +@item tcflag_t ECHOPRT @file{termios.h} (BSD): @ref{Local Modes}. @@ -744,6 +754,11 @@ @file{errno.h} (BSD: Destination address required): @ref{Error Codes,}. +@comment EDIED +@item int EDIED + +@file{errno.h} (GNU: Translator died): @ref{Error Codes,}. + @comment ED @item int ED @@ -774,6 +789,11 @@ @file{errno.h} (POSIX.1: File too large): @ref{Error Codes,}. +@comment EFTYPE +@item int EFTYPE + +@file{errno.h} (BSD: Inappropriate file type or format): @ref{Error Codes,}. + @comment EGRATUITOUS @item int EGRATUITOUS @@ -884,6 +904,11 @@ @file{netdb.h} (BSD): @ref{Services Database}. +@comment ENEEDAUTH +@item int ENEEDAUTH + +@file{errno.h} (BSD: Need authenticator): @ref{Error Codes,}. + @comment ENETDOWN @item int ENETDOWN @@ -1014,6 +1039,26 @@ @file{errno.h} (POSIX.1: Broken pipe): @ref{Error Codes,}. +@comment EPROCLIM +@item int EPROCLIM + +@file{errno.h} (BSD: Too many processes): @ref{Error Codes,}. + +@comment EPROCUNAVAIL +@item int EPROCUNAVAIL + +@file{errno.h} (BSD: RPC bad procedure for program): @ref{Error Codes,}. + +@comment EPROGMISMATCH +@item int EPROGMISMATCH + +@file{errno.h} (BSD: RPC program version wrong): @ref{Error Codes,}. + +@comment EPROGUNAVAIL +@item int EPROGUNAVAIL + +@file{errno.h} (BSD: RPC program not available): @ref{Error Codes,}. + @comment EPROTONOSUPPORT @item int EPROTONOSUPPORT @@ -1044,6 +1089,11 @@ @file{errno.h} (POSIX.1: Read-only file system): @ref{Error Codes,}. +@comment ERPCMISMATCH +@item int ERPCMISMATCH + +@file{errno.h} (BSD: RPC version wrong): @ref{Error Codes,}. + @comment errno @item volatile int errno @@ -1079,6 +1129,11 @@ @file{errno.h} (BSD: Connection timed out): @ref{Error Codes,}. +@comment ETOOMANYREFS +@item int ETOOMANYREFS + +@file{errno.h} (BSD: Too many references: can't splice): @ref{Error Codes,}. + @comment ETXTBSY @item int ETXTBSY @@ -1267,7 +1322,7 @@ @comment F_GETFL @item int F_GETFL -@file{fcntl.h} (POSIX.1): @ref{File Status Flags}. +@file{fcntl.h} (POSIX.1): @ref{Getting File Status Flags}. @comment fgetgrent @item struct group * fgetgrent (FILE *@var{stream}) @@ -1380,7 +1435,7 @@ @file{float.h} (ANSI): @ref{Floating Point Parameters}. @comment FLUSHO -@item FLUSHO +@item tcflag_t FLUSHO @file{termios.h} (BSD): @ref{Local Modes}. @@ -1435,7 +1490,7 @@ @file{unistd.h} (POSIX.1): @ref{Testing File Access}. @comment fopencookie -@item FILE * fopencookie (void *@var{cookie}, const char *@var{opentype}, cookie_io_functions_t @var{io_functions}) +@item FILE * fopencookie (void *@var{cookie}, const char *@var{opentype}, cookie_io_functions_t @var{io-functions}) @file{stdio.h} (GNU): @ref{Streams and Cookies}. @@ -1577,7 +1632,7 @@ @comment F_SETFL @item int F_SETFL -@file{fcntl.h} (POSIX.1): @ref{File Status Flags}. +@file{fcntl.h} (POSIX.1): @ref{Getting File Status Flags}. @comment F_SETLK @item int F_SETLK @@ -1750,7 +1805,7 @@ @file{getopt.h} (GNU): @ref{Long Options}. @comment getpeername -@item int getpeername (int @var{socket}, struct sockaddr *@var{addr}, size_t *@var{length_ptr}) +@item int getpeername (int @var{socket}, struct sockaddr *@var{addr}, size_t *@var{length-ptr}) @file{sys/socket.h} (BSD): @ref{Who is Connected}. @@ -1840,12 +1895,12 @@ @file{stdio.h} (ANSI): @ref{Line Input}. @comment getsockname -@item int getsockname (int @var{socket}, struct sockaddr *@var{addr}, size_t *@var{length_ptr}) +@item int getsockname (int @var{socket}, struct sockaddr *@var{addr}, size_t *@var{length-ptr}) @file{sys/socket.h} (BSD): @ref{Reading Address}. @comment getsockopt -@item int getsockopt (int @var{socket}, int @var{level}, int @var{optname}, void *@var{optval}, size_t *@var{optlen_ptr}) +@item int getsockopt (int @var{socket}, int @var{level}, int @var{optname}, void *@var{optval}, size_t *@var{optlen-ptr}) @file{sys/socket.h} (BSD): @ref{Socket Option Functions}. @@ -1900,7 +1955,7 @@ @file{glob.h} (POSIX.2): @ref{Flags for Globbing}. @comment glob -@item int glob (const char *@var{pattern}, int @var{flags}, int (*@var{errfunc}) (const char *@var{filename}, int @var{error-code}), glob_t *@var{vector_ptr}) +@item int glob (const char *@var{pattern}, int @var{flags}, int (*@var{errfunc}) (const char *@var{filename}, int @var{error-code}), glob_t *@var{vector-ptr}) @file{glob.h} (POSIX.2): @ref{Calling Glob}. @@ -1944,11 +1999,6 @@ @file{time.h} (ANSI): @ref{Broken-down Time}. -@comment _GNU_SOURCE -@item _GNU_SOURCE - -(GNU): @ref{Feature Test Macros,}. - @comment gsignal @item int gsignal (int @var{signum}) @@ -1975,7 +2025,7 @@ @file{math.h} (ANSI): @ref{Domain and Range Errors}. @comment HUPCL -@item HUPCL +@item tcflag_t HUPCL @file{termios.h} (POSIX.1): @ref{Control Modes}. @@ -1985,37 +2035,37 @@ @file{math.h} (BSD): @ref{Exponents and Logarithms}. @comment ICANON -@item ICANON +@item tcflag_t ICANON @file{termios.h} (POSIX.1): @ref{Local Modes}. @comment ICRNL -@item ICRNL +@item tcflag_t ICRNL @file{termios.h} (POSIX.1): @ref{Input Modes}. @comment IEXTEN -@item IEXTEN +@item tcflag_t IEXTEN @file{termios.h} (POSIX.1): @ref{Local Modes}. @comment IGNBRK -@item IGNBRK +@item tcflag_t IGNBRK @file{termios.h} (POSIX.1): @ref{Input Modes}. @comment IGNCR -@item IGNCR +@item tcflag_t IGNCR @file{termios.h} (POSIX.1): @ref{Input Modes}. @comment IGNPAR -@item IGNPAR +@item tcflag_t IGNPAR @file{termios.h} (POSIX.1): @ref{Input Modes}. @comment IMAXBEL -@item IMAXBEL +@item tcflag_t IMAXBEL @file{termios.h} (BSD): @ref{Input Modes}. @@ -2095,7 +2145,7 @@ @file{stdlib.h} (BSD): @ref{BSD Random}. @comment INLCR -@item INLCR +@item tcflag_t INLCR @file{termios.h} (POSIX.1): @ref{Input Modes}. @@ -2105,7 +2155,7 @@ @file{sys/types.h} (POSIX.1): @ref{Attribute Meanings}. @comment INPCK -@item INPCK +@item tcflag_t INPCK @file{termios.h} (POSIX.1): @ref{Input Modes}. @@ -2190,7 +2240,7 @@ @file{ctype.h} (ANSI): @ref{Classification of Characters,}. @comment ISIG -@item ISIG +@item tcflag_t ISIG @file{termios.h} (POSIX.1): @ref{Local Modes}. @@ -2225,7 +2275,7 @@ @file{ctype.h} (ANSI): @ref{Classification of Characters,}. @comment ISTRIP -@item ISTRIP +@item tcflag_t ISTRIP @file{termios.h} (POSIX.1): @ref{Input Modes}. @@ -2244,6 +2294,11 @@ @file{time.h} (POSIX.1): @ref{Time Zone Functions}. +@comment +@item + +@file{fcntl.h} (POSIX.1): @ref{Operating Modes}. + @comment ITIMER_PROF @item ITIMER_PROF @@ -2260,17 +2315,17 @@ @file{sys/time.h} (BSD): @ref{Setting an Alarm}. @comment IXANY -@item IXANY +@item tcflag_t IXANY @file{termios.h} (BSD): @ref{Input Modes}. @comment IXOFF -@item IXOFF +@item tcflag_t IXOFF @file{termios.h} (POSIX.1): @ref{Input Modes}. @comment IXON -@item IXON +@item tcflag_t IXON @file{termios.h} (POSIX.1): @ref{Input Modes}. @@ -2515,12 +2570,12 @@ @file{stdlib.h} (ANSI): @ref{Converting One Char,}. @comment mcheck -@item int mcheck (void (*@var{abortfn}) (void)) +@item int mcheck (void (*@var{abortfn}) (enum mcheck_status @var{status})) @file{malloc.h} (GNU): @ref{Heap Consistency Checking}. @comment MDMBUF -@item MDMBUF +@item tcflag_t MDMBUF @file{termios.h} (BSD): @ref{Control Modes}. @@ -2550,7 +2605,7 @@ @file{string.h} (ANSI): @ref{Copying and Concatenation,}. @comment memmem -@item void * memmem (const void *@var{needle}, size_t @var{needle_len},@*const void *@var{haystack}, size_t @var{haystack_len}) +@item void * memmem (const void *@var{needle}, size_t @var{needle-len},@*const void *@var{haystack}, size_t @var{haystack-len}) @file{string.h} (GNU): @ref{Search Functions,}. @@ -2560,7 +2615,7 @@ @file{string.h} (ANSI): @ref{Copying and Concatenation,}. @comment memory_warnings -@item void memory_warnings (void *@var{start}, void (*@var{warn_func}) (const char *)) +@item void memory_warnings (void *@var{start}, void (*@var{warn-func}) (const char *)) @file{malloc.h} (GNU): @ref{Memory Warnings}. @@ -2605,7 +2660,7 @@ @file{sys/types.h} (POSIX.1): @ref{Attribute Meanings}. @comment modf -@item double modf (double @var{value}, double *@var{integer_part}) +@item double modf (double @var{value}, double *@var{integer-part}) @file{math.h} (ANSI): @ref{Rounding and Remainders}. @@ -2665,12 +2720,12 @@ @file{netdb.h} (BSD): @ref{Host Names}. @comment NOFLSH -@item NOFLSH +@item tcflag_t NOFLSH @file{termios.h} (POSIX.1): @ref{Local Modes}. @comment NOKERNINFO -@item NOKERNINFO +@item tcflag_t NOKERNINFO @file{termios.h} (BSD): @ref{Local Modes}. @@ -2702,105 +2757,105 @@ @comment O_ACCMODE @item int O_ACCMODE -@file{fcntl.h} (POSIX.1): @ref{File Status Flags}. +@file{fcntl.h} (POSIX.1): @ref{Access Modes}. @comment O_APPEND -@item O_APPEND +@item int O_APPEND -@file{fcntl.h} (POSIX.1): @ref{File Status Flags}. +@file{fcntl.h} (POSIX.1): @ref{Operating Modes}. -@comment O_APPEND -@item O_APPEND +@comment O_ASYNC +@item int O_ASYNC -@file{fcntl.h} (POSIX.1): @ref{Opening and Closing Files}. +@file{fcntl.h} (BSD): @ref{Operating Modes}. @comment obstack_1grow_fast -@item void obstack_1grow_fast (struct obstack *@var{obstack_ptr}, char @var{c}) +@item void obstack_1grow_fast (struct obstack *@var{obstack-ptr}, char @var{c}) @file{obstack.h} (GNU): @ref{Extra Fast Growing}. @comment obstack_1grow -@item void obstack_1grow (struct obstack *@var{obstack_ptr}, char @var{c}) +@item void obstack_1grow (struct obstack *@var{obstack-ptr}, char @var{c}) @file{obstack.h} (GNU): @ref{Growing Objects}. @comment obstack_alignment_mask -@item int obstack_alignment_mask (struct obstack *@var{obstack_ptr}) +@item int obstack_alignment_mask (struct obstack *@var{obstack-ptr}) @file{obstack.h} (GNU): @ref{Obstacks Data Alignment}. @comment obstack_alloc -@item void * obstack_alloc (struct obstack *@var{obstack_ptr}, size_t @var{size}) +@item void * obstack_alloc (struct obstack *@var{obstack-ptr}, int @var{size}) @file{obstack.h} (GNU): @ref{Allocation in an Obstack}. @comment obstack_base -@item void * obstack_base (struct obstack *@var{obstack_ptr}) +@item void * obstack_base (struct obstack *@var{obstack-ptr}) @file{obstack.h} (GNU): @ref{Status of an Obstack}. @comment obstack_blank_fast -@item void obstack_blank_fast (struct obstack *@var{obstack_ptr}, size_t @var{size}) +@item void obstack_blank_fast (struct obstack *@var{obstack-ptr}, int @var{size}) @file{obstack.h} (GNU): @ref{Extra Fast Growing}. @comment obstack_blank -@item void obstack_blank (struct obstack *@var{obstack_ptr}, size_t @var{size}) +@item void obstack_blank (struct obstack *@var{obstack-ptr}, int @var{size}) @file{obstack.h} (GNU): @ref{Growing Objects}. @comment obstack_chunk_size -@item size_t obstack_chunk_size (struct obstack *@var{obstack_ptr}) +@item int obstack_chunk_size (struct obstack *@var{obstack-ptr}) @file{obstack.h} (GNU): @ref{Obstack Chunks}. @comment obstack_copy0 -@item void * obstack_copy0 (struct obstack *@var{obstack_ptr}, void *@var{address}, size_t @var{size}) +@item void * obstack_copy0 (struct obstack *@var{obstack-ptr}, void *@var{address}, int @var{size}) @file{obstack.h} (GNU): @ref{Allocation in an Obstack}. @comment obstack_copy -@item void * obstack_copy (struct obstack *@var{obstack_ptr}, void *@var{address}, size_t @var{size}) +@item void * obstack_copy (struct obstack *@var{obstack-ptr}, void *@var{address}, int @var{size}) @file{obstack.h} (GNU): @ref{Allocation in an Obstack}. @comment obstack_finish -@item void * obstack_finish (struct obstack *@var{obstack_ptr}) +@item void * obstack_finish (struct obstack *@var{obstack-ptr}) @file{obstack.h} (GNU): @ref{Growing Objects}. @comment obstack_free -@item void obstack_free (struct obstack *@var{obstack_ptr}, void *@var{object}) +@item void obstack_free (struct obstack *@var{obstack-ptr}, void *@var{object}) @file{obstack.h} (GNU): @ref{Freeing Obstack Objects}. @comment obstack_grow0 -@item void obstack_grow0 (struct obstack *@var{obstack_ptr}, void *@var{data}, size_t @var{size}) +@item void obstack_grow0 (struct obstack *@var{obstack-ptr}, void *@var{data}, int @var{size}) @file{obstack.h} (GNU): @ref{Growing Objects}. @comment obstack_grow -@item void obstack_grow (struct obstack *@var{obstack_ptr}, void *@var{data}, size_t @var{size}) +@item void obstack_grow (struct obstack *@var{obstack-ptr}, void *@var{data}, int @var{size}) @file{obstack.h} (GNU): @ref{Growing Objects}. @comment obstack_init -@item int obstack_init (struct obstack *@var{obstack_ptr}) +@item int obstack_init (struct obstack *@var{obstack-ptr}) @file{obstack.h} (GNU): @ref{Preparing for Obstacks}. @comment obstack_next_free -@item void * obstack_next_free (struct obstack *@var{obstack_ptr}) +@item void * obstack_next_free (struct obstack *@var{obstack-ptr}) @file{obstack.h} (GNU): @ref{Status of an Obstack}. @comment obstack_object_size -@item size_t obstack_object_size (struct obstack *@var{obstack_ptr}) +@item int obstack_object_size (struct obstack *@var{obstack-ptr}) @file{obstack.h} (GNU): @ref{Growing Objects}. @comment obstack_object_size -@item size_t obstack_object_size (struct obstack *@var{obstack_ptr}) +@item int obstack_object_size (struct obstack *@var{obstack-ptr}) @file{obstack.h} (GNU): @ref{Status of an Obstack}. @@ -2810,7 +2865,7 @@ @file{stdio.h} (GNU): @ref{Dynamic Output}. @comment obstack_room -@item size_t obstack_room (struct obstack *@var{obstack_ptr}) +@item int obstack_room (struct obstack *@var{obstack-ptr}) @file{obstack.h} (GNU): @ref{Extra Fast Growing}. @@ -2820,14 +2875,24 @@ @file{stdio.h} (GNU): @ref{Variable Arguments Output}. @comment O_CREAT -@item O_CREAT +@item int O_CREAT -@file{fcntl.h} (POSIX.1): @ref{Opening and Closing Files}. +@file{fcntl.h} (POSIX.1): @ref{Open-time Flags}. @comment O_EXCL -@item O_EXCL +@item int O_EXCL -@file{fcntl.h} (POSIX.1): @ref{Opening and Closing Files}. +@file{fcntl.h} (POSIX.1): @ref{Open-time Flags}. + +@comment O_EXEC +@item int O_EXEC + +@file{fcntl.h} (GNU): @ref{Access Modes}. + +@comment O_EXLOCK +@item int O_EXLOCK + +@file{fcntl.h} (BSD): @ref{Open-time Flags}. @comment offsetof @item size_t offsetof (@var{type}, @var{member}) @@ -2839,10 +2904,20 @@ @file{sys/types.h} (POSIX.1): @ref{File Position Primitive}. +@comment O_FSYNC +@item int O_FSYNC + +@file{fcntl.h} (BSD): @ref{Operating Modes}. + +@comment O_IGNORE_CTTY +@item int O_IGNORE_CTTY + +@file{fcntl.h} (GNU): @ref{Open-time Flags}. + @comment O_NDELAY -@item O_NDELAY +@item int O_NDELAY -@file{fcntl.h} (BSD): @ref{File Status Flags}. +@file{fcntl.h} (BSD): @ref{Operating Modes}. @comment on_exit @item int on_exit (void (*@var{function})(int @var{status}, void *@var{arg}), void *@var{arg}) @@ -2850,29 +2925,39 @@ @file{stdlib.h} (SunOS): @ref{Cleanups on Exit}. @comment ONLCR -@item int ONLCR +@item tcflag_t ONLCR @file{termios.h} (BSD): @ref{Output Modes}. +@comment O_NOATIME +@item int O_NOATIME + +@file{fcntl.h} (GNU): @ref{Operating Modes}. + @comment O_NOCTTY -@item O_NOCTTY +@item int O_NOCTTY -@file{fcntl.h} (POSIX.1): @ref{Opening and Closing Files}. +@file{fcntl.h} (POSIX.1): @ref{Open-time Flags}. @comment ONOEOT -@item int ONOEOT +@item tcflag_t ONOEOT @file{termios.h} (BSD): @ref{Output Modes}. -@comment O_NONBLOCK -@item O_NONBLOCK +@comment O_NOLINK +@item int O_NOLINK -@file{fcntl.h} (POSIX.1): @ref{File Status Flags}. +@file{fcntl.h} (GNU): @ref{Open-time Flags}. @comment O_NONBLOCK -@item O_NONBLOCK +@item int O_NONBLOCK -@file{fcntl.h} (POSIX.1): @ref{Opening and Closing Files}. +@file{fcntl.h} (POSIX.1): @ref{Open-time Flags}. + +@comment O_NOTRANS +@item int O_NOTRANS + +@file{fcntl.h} (GNU): @ref{Open-time Flags}. @comment opendir @item DIR * opendir (const char *@var{dirname}) @@ -2900,7 +2985,7 @@ @file{stdio.h} (GNU): @ref{Obstack Streams}. @comment OPOST -@item int OPOST +@item tcflag_t OPOST @file{termios.h} (POSIX.1): @ref{Output Modes}. @@ -2925,27 +3010,47 @@ @file{unistd.h} (POSIX.2): @ref{Parsing Options}. @comment O_RDONLY -@item O_RDONLY +@item int O_RDONLY -@file{fcntl.h} (POSIX.1): @ref{Opening and Closing Files}. +@file{fcntl.h} (POSIX.1): @ref{Access Modes}. @comment O_RDWR -@item O_RDWR +@item int O_RDWR -@file{fcntl.h} (POSIX.1): @ref{Opening and Closing Files}. +@file{fcntl.h} (POSIX.1): @ref{Access Modes}. + +@comment O_READ +@item int O_READ + +@file{fcntl.h} (GNU): @ref{Access Modes}. + +@comment O_SHLOCK +@item int O_SHLOCK + +@file{fcntl.h} (BSD): @ref{Open-time Flags}. + +@comment O_SYNC +@item int O_SYNC + +@file{fcntl.h} (BSD): @ref{Operating Modes}. @comment O_TRUNC -@item O_TRUNC +@item int O_TRUNC -@file{fcntl.h} (POSIX.1): @ref{Opening and Closing Files}. +@file{fcntl.h} (POSIX.1): @ref{Open-time Flags}. + +@comment O_WRITE +@item int O_WRITE + +@file{fcntl.h} (GNU): @ref{Access Modes}. @comment O_WRONLY -@item O_WRONLY +@item int O_WRONLY -@file{fcntl.h} (POSIX.1): @ref{Opening and Closing Files}. +@file{fcntl.h} (POSIX.1): @ref{Access Modes}. @comment OXTABS -@item int OXTABS +@item tcflag_t OXTABS @file{termios.h} (BSD): @ref{Output Modes}. @@ -3010,17 +3115,17 @@ @file{printf.h} (GNU): @ref{Parsing a Template String}. @comment PARENB -@item PARENB +@item tcflag_t PARENB @file{termios.h} (POSIX.1): @ref{Control Modes}. @comment PARMRK -@item PARMRK +@item tcflag_t PARMRK @file{termios.h} (POSIX.1): @ref{Input Modes}. @comment PARODD -@item PARODD +@item tcflag_t PARODD @file{termios.h} (POSIX.1): @ref{Control Modes}. @@ -3100,7 +3205,7 @@ @file{unistd.h} (POSIX.1): @ref{Pathconf}. @comment PENDIN -@item PENDIN +@item tcflag_t PENDIN @file{termios.h} (BSD): @ref{Local Modes}. @@ -3234,11 +3339,6 @@ @file{unistd.h} (POSIX.1): @ref{Options for Files}. -@comment _POSIX_C_SOURCE -@item _POSIX_C_SOURCE - -(POSIX.2): @ref{Feature Test Macros,}. - @comment _POSIX_JOB_CONTROL @item int _POSIX_JOB_CONTROL @@ -3294,11 +3394,6 @@ @file{unistd.h} (POSIX.1): @ref{System Options}. -@comment _POSIX_SOURCE -@item _POSIX_SOURCE - -(POSIX.1): @ref{Feature Test Macros,}. - @comment _POSIX_SSIZE_MAX @item _POSIX_SSIZE_MAX @@ -3485,7 +3580,7 @@ @file{malloc.h}, @file{stdlib.h} (ANSI): @ref{Changing Block Size}. @comment recvfrom -@item int recvfrom (int @var{socket}, void *@var{buffer}, size_t @var{size}, int @var{flags}, struct sockaddr *@var{addr}, size_t *@var{length_ptr}) +@item int recvfrom (int @var{socket}, void *@var{buffer}, size_t @var{size}, int @var{flags}, struct sockaddr *@var{addr}, size_t *@var{length-ptr}) @file{sys/socket.h} (BSD): @ref{Receiving Datagrams}. @@ -3605,7 +3700,7 @@ @file{regex.h} (POSIX.2): @ref{Flags for POSIX Regexps}. @comment register_printf_function -@item int register_printf_function (int @var{spec}, printf_function @var{handler_function}, printf_arginfo_function @var{arginfo_function}) +@item int register_printf_function (int @var{spec}, printf_function @var{handler-function}, printf_arginfo_function @var{arginfo-function}) @file{printf.h} (GNU): @ref{Registering New Conversions}. @@ -3694,8 +3789,18 @@ @file{sys/resource.h} (BSD): @ref{Limits on Resources}. -@comment RLIMIT_OPEN_FILES -@item RLIMIT_OPEN_FILES +@comment RLIMIT_MEMLOCK +@item RLIMIT_MEMLOCK + +@file{sys/resource.h} (BSD): @ref{Limits on Resources}. + +@comment RLIMIT_NOFILE +@item RLIMIT_NOFILE + +@file{sys/resource.h} (BSD): @ref{Limits on Resources}. + +@comment RLIMIT_NPROC +@item RLIMIT_NPROC @file{sys/resource.h} (BSD): @ref{Limits on Resources}. @@ -3925,7 +4030,7 @@ @file{stdio.h} (ANSI): @ref{File Positioning}. @comment select -@item int select (int @var{nfds}, fd_set *@var{read_fds}, fd_set *@var{write_fds}, fd_set *@var{except_fds}, struct timeval *@var{timeout}) +@item int select (int @var{nfds}, fd_set *@var{read-fds}, fd_set *@var{write-fds}, fd_set *@var{except-fds}, struct timeval *@var{timeout}) @file{sys/types.h} (BSD): @ref{Waiting for I/O}. @@ -4150,7 +4255,7 @@ @file{signal.h} (ANSI): @ref{Program Error Signals}. @comment sigaction -@item int sigaction (int @var{signum}, const struct sigaction *@var{action}, struct sigaction *@var{old_action}) +@item int sigaction (int @var{signum}, const struct sigaction *@var{action}, struct sigaction *@var{old-action}) @file{signal.h} (POSIX.1): @ref{Advanced Signal Handling}. @@ -4194,6 +4299,11 @@ @file{signal.h} (POSIX.1): @ref{Job Control Signals}. +@comment SIGCLD +@item int SIGCLD + +@file{signal.h} (SVID): @ref{Job Control Signals}. + @comment SIGCONT @item int SIGCONT @@ -4209,6 +4319,11 @@ @file{signal.h} (POSIX.1): @ref{Signal Sets}. +@comment SIGEMT +@item int SIGEMT + +@file{signal.h} (BSD): @ref{Program Error Signals}. + @comment SIG_ERR @item sighandler_t SIG_ERR @@ -4239,6 +4354,11 @@ @file{signal.h} (ANSI): @ref{Program Error Signals}. +@comment SIGINFO +@item int SIGINFO + +@file{signal.h} (BSD): @ref{Miscellaneous Signals}. + @comment siginterrupt @item int siginterrupt (int @var{signum}, int @var{failflag}) @@ -4254,6 +4374,11 @@ @file{signal.h} (BSD): @ref{Asynchronous I/O Signals}. +@comment SIGIOT +@item int SIGIOT + +@file{signal.h} (Unix): @ref{Program Error Signals}. + @comment sigismember @item int sigismember (const sigset_t *@var{set}, int @var{signum}) @@ -4274,6 +4399,11 @@ @file{setjmp.h} (POSIX.1): @ref{Non-Local Exits and Signals,,}. +@comment SIGLOST +@item int SIGLOST + +@file{signal.h} (GNU): @ref{Operation Error Signals}. + @comment sigmask @item int sigmask (int @var{signum}) @@ -4297,7 +4427,12 @@ @comment SIGPIPE @item int SIGPIPE -@file{signal.h} (POSIX.1): @ref{Miscellaneous Signals}. +@file{signal.h} (POSIX.1): @ref{Operation Error Signals}. + +@comment SIGPOLL +@item int SIGPOLL + +@file{signal.h} (SVID): @ref{Asynchronous I/O Signals}. @comment sigprocmask @item int sigprocmask (int @var{how}, const sigset_t *@var{set}, sigset_t *@var{oldset}) @@ -4354,11 +4489,21 @@ @file{signal.h} (POSIX.1): @ref{Sigsuspend}. +@comment SIGSYS +@item int SIGSYS + +@file{signal.h} (Unix): @ref{Program Error Signals}. + @comment SIGTERM @item int SIGTERM @file{signal.h} (ANSI): @ref{Termination Signals}. +@comment SIGTRAP +@item int SIGTRAP + +@file{signal.h} (BSD): @ref{Program Error Signals}. + @comment SIGTSTP @item int SIGTSTP @@ -4395,7 +4540,7 @@ @file{signal.h} (POSIX.1): @ref{Miscellaneous Signals}. @comment sigvec -@item int sigvec (int @var{signum}, const struct sigvec *@var{action},struct sigvec *@var{old_action}) +@item int sigvec (int @var{signum}, const struct sigvec *@var{action},struct sigvec *@var{old-action}) @file{signal.h} (BSD): @ref{BSD Handler}. @@ -4404,6 +4549,21 @@ @file{signal.h} (BSD): @ref{Alarm Signals}. +@comment SIGWINCH +@item int SIGWINCH + +@file{signal.h} (BSD): @ref{Miscellaneous Signals}. + +@comment SIGXCPU +@item int SIGXCPU + +@file{signal.h} (BSD): @ref{Operation Error Signals}. + +@comment SIGXFSZ +@item int SIGXFSZ + +@file{signal.h} (BSD): @ref{Operation Error Signals}. + @comment sinh @item double sinh (double @var{x}) @@ -5034,11 +5194,6 @@ @file{string.h} (ANSI): @ref{Collation Functions,}. -@comment _SVID_SOURCE -@item _SVID_SOURCE - -(GNU): @ref{Feature Test Macros,}. - @comment SV_INTERRUPT @item int SV_INTERRUPT @@ -5100,7 +5255,7 @@ @file{termios.h} (POSIX.1): @ref{Line Control}. @comment tcgetattr -@item int tcgetattr (int @var{filedes}, struct termios *@var{termios_p}) +@item int tcgetattr (int @var{filedes}, struct termios *@var{termios-p}) @file{termios.h} (POSIX.1): @ref{Mode Functions}. @@ -5135,7 +5290,7 @@ @file{termios.h} (POSIX.1): @ref{Line Control}. @comment tcsetattr -@item int tcsetattr (int @var{filedes}, int @var{when}, const struct termios *@var{termios_p}) +@item int tcsetattr (int @var{filedes}, int @var{when}, const struct termios *@var{termios-p}) @file{termios.h} (POSIX.1): @ref{Mode Functions}. @@ -5211,7 +5366,7 @@ @file{ctype.h} (SVID): @ref{Case Conversion,}. @comment TOSTOP -@item TOSTOP +@item tcflag_t TOSTOP @file{termios.h} (POSIX.1): @ref{Local Modes}. @@ -5351,7 +5506,7 @@ @file{varargs.h} (Unix): @ref{Old Varargs}. @comment va_start -@item void va_start (va_list @var{ap}, @var{last_required}) +@item void va_start (va_list @var{ap}, @var{last-required}) @file{stdarg.h} (ANSI): @ref{Argument Macros}. @@ -5373,7 +5528,7 @@ @comment VEOL2 @item int VEOL2 -@file{termios.h} (BSD): @ref{BSD Editing}. +@file{termios.h} (BSD): @ref{Editing Characters}. @comment VEOL @item int VEOL @@ -5413,7 +5568,7 @@ @comment VLNEXT @item int VLNEXT -@file{termios.h} (BSD): @ref{BSD Editing}. +@file{termios.h} (BSD): @ref{Other Special}. @comment VMIN @item int VMIN @@ -5433,7 +5588,7 @@ @comment VREPRINT @item int VREPRINT -@file{termios.h} (BSD): @ref{BSD Editing}. +@file{termios.h} (BSD): @ref{Editing Characters}. @comment vscanf @item int vscanf (const char *@var{template}, va_list @var{ap}) @@ -5483,25 +5638,25 @@ @comment VWERASE @item int VWERASE -@file{termios.h} (BSD): @ref{BSD Editing}. +@file{termios.h} (BSD): @ref{Editing Characters}. @comment wait3 -@item pid_t wait3 (union wait *@var{status_ptr}, int @var{options}, struct rusage *@var{usage}) +@item pid_t wait3 (union wait *@var{status-ptr}, int @var{options}, struct rusage *@var{usage}) @file{sys/wait.h} (BSD): @ref{BSD Wait Functions}. @comment wait4 -@item pid_t wait4 (pid_t @var{pid}, union wait *@var{status_ptr}, int @var{options}, struct rusage *@var{usage}) +@item pid_t wait4 (pid_t @var{pid}, int *@var{status-ptr}, int @var{options}, struct rusage *@var{usage}) -@file{sys/wait.h} (BSD): @ref{BSD Wait Functions}. +@file{sys/wait.h} (BSD): @ref{Process Completion}. @comment wait -@item pid_t wait (int *@var{status_ptr}) +@item pid_t wait (int *@var{status-ptr}) @file{sys/wait.h} (POSIX.1): @ref{Process Completion}. @comment waitpid -@item pid_t waitpid (pid_t @var{pid}, int *@var{status_ptr}, int @var{options}) +@item pid_t waitpid (pid_t @var{pid}, int *@var{status-ptr}, int @var{options}) @file{sys/wait.h} (POSIX.1): @ref{Process Completion}. diff -ruN glibc-1.08.1/manual/sysinfo.texi glibc-1.09/manual/sysinfo.texi --- glibc-1.08.1/manual/sysinfo.texi Mon Feb 7 18:28:29 1994 +++ glibc-1.09/manual/sysinfo.texi Fri Oct 14 04:03:56 1994 @@ -18,7 +18,10 @@ This section explains how to identify the particular machine that your program is running on. The identification of a machine consists of its -Internet host name and Internet address; see @ref{Internet Namespace}. +Internet host name and Internet address; see @ref{Internet Namespace}. +The host name should always be a fully qualified domain name, like +@w{@samp{crispy-wheats-n-chicken.ai.mit.edu}}, not a simple name like +just @w{@samp{crispy-wheats-n-chicken}}. @pindex hostname @pindex hostid @@ -77,7 +80,7 @@ @deftypefun {long int} gethostid (void) This function returns the ``host ID'' of the machine the program is running on. By convention, this is usually the primary Internet address -of that machine, converted to a @w{@code{long int}}. But on some +of that machine, converted to a @w{@code{long int}}. However, some systems it is a meaningless but unique number which is hard-coded for each machine. @end deftypefun diff -ruN glibc-1.08.1/manual/terminal.texi glibc-1.09/manual/terminal.texi --- glibc-1.08.1/manual/terminal.texi Mon Feb 7 18:28:18 1994 +++ glibc-1.09/manual/terminal.texi Wed Oct 26 01:19:40 1994 @@ -1,4 +1,4 @@ -@node Low-Level Terminal Interface, Mathematics, Sockets, Top +@node Low-Level Terminal Interface @chapter Low-Level Terminal Interface This chapter describes functions that are specific to terminal devices. @@ -75,12 +75,16 @@ The size of the terminal's input queue is described by the @code{_POSIX_MAX_INPUT} and @code{MAX_INPUT} parameters; see @ref{Limits -for Files}. If input flow control is enabled by setting the -@code{IXOFF} input mode bit (@pxref{Input Modes}), the terminal driver -transmits STOP and START characters to the terminal when necessary to -prevent the queue from overflowing. Otherwise, input may be lost if it -comes in too fast from the terminal. (This is unlikely if you are -typing the input by hand!) +for Files}. You are guaranteed a queue size of at least +@code{MAX_INPUT}, but the queue might be larger, and might even +dynamically change size. If input flow control is enabled by setting +the @code{IXOFF} input mode bit (@pxref{Input Modes}), the terminal +driver transmits STOP and START characters to the terminal when +necessary to prevent the queue from overflowing. Otherwise, input may +be lost if it comes in too fast from the terminal. In canonical mode, +all input stays in the queue until a newline character is received, so +the terminal input queue can fill up when you type a very long line. +@xref{Canonical or Not}. @cindex terminal output queue The @dfn{terminal output queue} is like the input queue, but for output; @@ -109,14 +113,15 @@ single line of input, no matter how many bytes are requested. In canonical input mode, the operating system provides input editing -facilities: the ERASE and KILL characters are interpreted specially to -perform editing operations within the current line of text. +facilities: some characters are interpreted specially to perform editing +operations within the current line of text, such as ERASE and KILL. @xref{Editing Characters}. The constants @code{_POSIX_MAX_CANON} and @code{MAX_CANON} parameterize the maximum number of bytes which may appear in a single line of -canonical input. @xref{Limits for Files}. -@c !!! mihgt be unlimited in GNU? ask mib +canonical input. @xref{Limits for Files}. You are guaranteed a maximum +line length of at least @code{MAX_CANON} bytes, but the maximum might be +larger, and might even dynamically change size. @cindex noncanonical input processing In @dfn{noncanonical input processing} mode, characters are not grouped @@ -228,10 +233,10 @@ @comment termios.h @comment POSIX.1 -@deftypefun int tcgetattr (int @var{filedes}, struct termios *@var{termios_p}) +@deftypefun int tcgetattr (int @var{filedes}, struct termios *@var{termios-p}) This function is used to examine the attributes of the terminal device with file descriptor @var{filedes}. The attributes are returned -in the structure that @var{termios_p} points to. +in the structure that @var{termios-p} points to. If successful, @code{tcgetattr} returns @code{0}. A return value of @code{-1} indicates an error. The following @code{errno} error conditions are @@ -248,10 +253,10 @@ @comment termios.h @comment POSIX.1 -@deftypefun int tcsetattr (int @var{filedes}, int @var{when}, const struct termios *@var{termios_p}) +@deftypefun int tcsetattr (int @var{filedes}, int @var{when}, const struct termios *@var{termios-p}) This function sets the attributes of the terminal device with file descriptor @var{filedes}. The new attributes are taken from the -structure that @var{termios_p} points to. +structure that @var{termios-p} points to. The @var{when} argument specifies how to deal with input and output already queued. It can be one of the following values: @@ -283,7 +288,12 @@ @vindex TCSASOFT This is a flag bit that you can add to any of the above alternatives. Its meaning is to inhibit alteration of the state of the terminal -hardware. It is a BSD extension; it has no effect on non-BSD systems. +hardware. It is a BSD extension; it is only supported on BSD systems +and the GNU system. + +Using @code{TCSASOFT} is exactly the same as setting the @code{CIGNORE} +bit in the @code{c_cflag} member of the structure @var{termios-p} points +to. @xref{Control Modes}, for a description of @code{CIGNORE}. @end table If this function is called from a background process on its controlling @@ -306,7 +316,7 @@ @item EINVAL Either the value of the @code{when} argument is not valid, or there is -something wrong with the data in the @var{termios_p} argument. +something wrong with the data in the @var{termios-p} argument. @end table @end deftypefun @@ -364,17 +374,23 @@ @{ struct termios settings; int result; +@end group +@group result = tcgetattr (desc, &settings); if (result < 0) @{ perror ("error in tcgetattr"); return 0; @} +@end group +@group settings.c_iflag &= ~ISTRIP; if (value) settings.c_iflag |= ISTRIP; - result = tcgetattr (desc, &settings); +@end group +@group + result = tcsetattr (desc, TCSANOW, &settings); if (result < 0) @{ perror ("error in tcgetattr"); @@ -399,11 +415,9 @@ only specific flags and leave the rest untouched (@pxref{Setting Modes}). -@table @code @comment termios.h @comment POSIX.1 -@vindex INPCK -@item INPCK +@deftypevr Macro tcflag_t INPCK @cindex parity checking If this bit is set, input parity checking is enabled. If it is not set, no checking at all is done for parity errors on input; the @@ -419,18 +433,18 @@ on whether the @code{IGNPAR} or @code{PARMRK} bits are set. If neither of these bits are set, a byte with a parity error is passed to the application as a @code{'\0'} character. +@end deftypevr @comment termios.h @comment POSIX.1 -@vindex IGNPAR -@item IGNPAR +@deftypevr Macro tcflag_t IGNPAR If this bit is set, any byte with a framing or parity error is ignored. This is only useful if @code{INPCK} is also set. +@end deftypevr @comment termios.h @comment POSIX.1 -@vindex PARMRK -@item PARMRK +@deftypevr Macro tcflag_t PARMRK If this bit is set, input bytes with parity or framing errors are marked when passed to the program. This bit is meaningful only when @code{INPCK} is set and @code{IGNPAR} is not set. @@ -443,29 +457,29 @@ is not set, the program might confuse it with the prefix that marks a parity error. So a valid byte @code{0377} is passed to the program as two bytes, @code{0377} @code{0377}, in this case. +@end deftypevr @comment termios.h @comment POSIX.1 -@vindex ISTRIP -@item ISTRIP +@deftypevr Macro tcflag_t ISTRIP If this bit is set, valid input bytes are stripped to seven bits; otherwise, all eight bits are available for programs to read. +@end deftypevr @comment termios.h @comment POSIX.1 -@vindex IGNBRK -@item IGNBRK +@deftypevr Macro tcflag_t IGNBRK If this bit is set, break conditions are ignored. @cindex break condition, detecting A @dfn{break condition} is defined in the context of asynchronous serial data transmission as a series of zero-value bits longer than a single byte. +@end deftypevr @comment termios.h @comment POSIX.1 -@vindex BRKINT -@item BRKINT +@deftypevr Macro tcflag_t BRKINT If this bit is set and @code{IGNBRK} is not set, a break condition clears the terminal input and output queues and raises a @code{SIGINT} signal for the foreground process group associated with the terminal. @@ -474,46 +488,46 @@ passed to the application as a single @code{'\0'} character if @code{PARMRK} is not set, or otherwise as a three-character sequence @code{'\377'}, @code{'\0'}, @code{'\0'}. +@end deftypevr @comment termios.h @comment POSIX.1 -@vindex IGNCR -@item IGNCR +@deftypevr Macro tcflag_t IGNCR If this bit is set, carriage return characters (@code{'\r'}) are discarded on input. Discarding carriage return may be useful on terminals that send both carriage return and linefeed when you type the @key{RET} key. +@end deftypevr @comment termios.h @comment POSIX.1 -@vindex ICRNL -@item ICRNL +@deftypevr Macro tcflag_t ICRNL If this bit is set and @code{IGNCR} is not set, carriage return characters (@code{'\r'}) received as input are passed to the application as newline characters (@code{'\n'}). +@end deftypevr @comment termios.h @comment POSIX.1 -@vindex INLCR -@item INLCR +@deftypevr Macro tcflag_t INLCR If this bit is set, newline characters (@code{'\n'}) received as input are passed to the application as carriage return characters (@code{'\r'}). +@end deftypevr @comment termios.h @comment POSIX.1 -@vindex IXOFF -@item IXOFF +@deftypevr Macro tcflag_t IXOFF If this bit is set, start/stop control on input is enabled. In other words, the computer sends STOP and START characters as necessary to prevent input from coming in faster than programs are reading it. The idea is that the actual terminal hardware that is generating the input data responds to a STOP character by suspending transmission, and to a START character by resuming transmission. @xref{Start/Stop Characters}. +@end deftypevr @comment termios.h @comment POSIX.1 -@vindex IXON -@item IXON +@deftypevr Macro tcflag_t IXON If this bit is set, start/stop control on output is enabled. In other words, if the computer receives a STOP character, it suspends output until a START character is received. In this case, the STOP and START @@ -521,20 +535,26 @@ not set, then START and STOP can be read as ordinary characters. @xref{Start/Stop Characters}. @c !!! mention this interferes with using C-s and C-q for programs like emacs +@end deftypevr @comment termios.h @comment BSD -@item IXANY +@deftypevr Macro tcflag_t IXANY If this bit is set, any input character restarts output when output has been suspended with the STOP character. Otherwise, only the START character restarts output. +This is a BSD extension; it exists only on BSD systems and the GNU system. +@end deftypevr + @comment termios.h @comment BSD -@item IMAXBEL +@deftypevr Macro tcflag_t IMAXBEL If this bit is set, then filling up the terminal input buffer sends a BEL character (code @code{007}) to the terminal to ring the bell. -@end table + +This is a BSD extension. +@end deftypevr @node Output Modes @subsection Output Modes @@ -552,7 +572,7 @@ @comment termios.h @comment POSIX.1 -@deftypevr Macro int OPOST +@deftypevr Macro tcflag_t OPOST If this bit is set, output data is processed in some unspecified way so that it is displayed appropriately on the terminal device. This typically includes mapping newline characters (@code{'\n'}) onto @@ -561,27 +581,27 @@ If this bit isn't set, the characters are transmitted as-is. @end deftypevr -The following three bits are BSD features, and they have no effect on -non-BSD systems. On all systems, they are effective only if -@code{OPOST} is set. +The following three bits are BSD features, and they exist only BSD +systems and the GNU system. They are effective only if @code{OPOST} is +set. @comment termios.h @comment BSD -@deftypevr Macro int ONLCR +@deftypevr Macro tcflag_t ONLCR If this bit is set, convert the newline character on output into a pair of characters, carriage return followed by linefeed. @end deftypevr @comment termios.h @comment BSD -@deftypevr Macro int OXTABS +@deftypevr Macro tcflag_t OXTABS If this bit is set, convert tab characters on output into the appropriate number of spaces to emulate a tab stop every eight columns. @end deftypevr @comment termios.h @comment BSD -@deftypevr Macro int ONOEOT +@deftypevr Macro tcflag_t ONOEOT If this bit is set, discard @kbd{C-d} characters (code @code{004}) on output. These characters cause many dial-up terminals to disconnect. @end deftypevr @@ -602,19 +622,17 @@ only specific flags and leave the rest untouched (@pxref{Setting Modes}). -@table @code @comment termios.h @comment POSIX.1 -@vindex CLOCAL -@item CLOCAL +@deftypevr Macro tcflag_t CLOCAL If this bit is set, it indicates that the terminal is connected ``locally'' and that the modem status lines (such as carrier detect) should be ignored. @cindex modem status lines @cindex carrier detect -If this bit is not set and you call @code{open} without the -@code{O_NONBLOCK} flag set, @code{open} blocks until a modem +On many systems if this bit is not set and you call @code{open} without +the @code{O_NONBLOCK} flag set, @code{open} blocks until a modem connection is established. If this bit is not set and a modem disconnect is detected, a @@ -625,103 +643,118 @@ to be returned. The terminal device must be closed and reopened to clear the condition. @cindex modem disconnect +@end deftypevr @comment termios.h @comment POSIX.1 -@vindex HUPCL -@item HUPCL +@deftypevr Macro tcflag_t HUPCL If this bit is set, a modem disconnect is generated when all processes that have the terminal device open have either closed the file or exited. +@end deftypevr @comment termios.h @comment POSIX.1 -@vindex CREAD -@item CREAD +@deftypevr Macro tcflag_t CREAD If this bit is set, input can be read from the terminal. Otherwise, input is discarded when it arrives. +@end deftypevr @comment termios.h @comment POSIX.1 -@vindex CSTOPB -@item CSTOPB +@deftypevr Macro tcflag_t CSTOPB If this bit is set, two stop bits are used. Otherwise, only one stop bit is used. +@end deftypevr @comment termios.h @comment POSIX.1 -@vindex PARENB -@item PARENB +@deftypevr Macro tcflag_t PARENB If this bit is set, generation and detection of a parity bit are enabled. @xref{Input Modes}, for information on how input parity errors are handled. If this bit is not set, no parity bit is added to output characters, and input characters are not checked for correct parity. +@end deftypevr @comment termios.h @comment POSIX.1 -@vindex PARODD -@item PARODD +@deftypevr Macro tcflag_t PARODD This bit is only useful if @code{PARENB} is set. If @code{PARODD} is set, odd parity is used, otherwise even parity is used. -@end table +@end deftypevr The control mode flags also includes a field for the number of bits per character. You can use the @code{CSIZE} macro as a mask to extract the value, like this: @code{settings.c_cflag & CSIZE}. -@table @code @comment termios.h @comment POSIX.1 -@vindex CSIZE -@item CSIZE +@deftypevr Macro tcflag_t CSIZE This is a mask for the number of bits per character. +@end deftypevr @comment termios.h @comment POSIX.1 -@vindex CS5 -@item CS5 +@deftypevr Macro tcflag_t CS5 This specifies five bits per byte. +@end deftypevr @comment termios.h @comment POSIX.1 -@vindex CS6 -@item CS6 +@deftypevr Macro tcflag_t CS6 This specifies six bits per byte. +@end deftypevr @comment termios.h @comment POSIX.1 -@vindex CS7 -@item CS7 +@deftypevr Macro tcflag_t CS7 This specifies seven bits per byte. +@end deftypevr @comment termios.h @comment POSIX.1 -@vindex CS8 -@item CS8 +@deftypevr Macro tcflag_t CS8 This specifies eight bits per byte. +@end deftypevr + +The following four bits are BSD extensions; this exist only on BSD +systems and the GNU system. @comment termios.h @comment BSD -@vindex CCTS_OFLOW -@item CCTS_OFLOW +@deftypevr Macro tcflag_t CCTS_OFLOW If this bit is set, enable flow control of output based on the CTS wire (RS232 protocol). +@end deftypevr @comment termios.h @comment BSD -@vindex CRTS_IFLOW -@item CRTS_IFLOW +@deftypevr Macro tcflag_t CRTS_IFLOW If this bit is set, enable flow control of input based on the RTS wire (RS232 protocol). +@end deftypevr @comment termios.h @comment BSD -@vindex MDMBUF -@item MDMBUF +@deftypevr Macro tcflag_t MDMBUF If this bit is set, enable carrier-based flow control of output. -@end table +@end deftypevr + +@comment termios.h +@comment BSD +@deftypevr Macro tcflag_t CIGNORE +If this bit is set, it says to ignore the control modes and line speed +values entirely. This is only meaningful in a call to @code{tcsetattr}. + +The @code{c_cflag} member and the line speed values returned by +@code{cfgetispeed} and @code{cfgetospeed} will be unaffected by the +call. @code{CIGNORE} is useful if you want to set all the software +modes in the other members, but leave the hardware details in +@code{c_cflag} unchanged. (This is how the @code{TCSASOFT} flag to +@code{tcsettattr} works.) -@c !!! BSD also has CIGNORE +This bit is never set in the structure filled in by @code{tcgetattr}. +@end deftypevr @node Local Modes @subsection Local Modes @@ -738,26 +771,24 @@ only specific flags and leave the rest untouched (@pxref{Setting Modes}). -@table @code @comment termios.h @comment POSIX.1 -@vindex ICANON -@item ICANON +@deftypevr Macro tcflag_t ICANON This bit, if set, enables canonical input processing mode. Otherwise, input is processed in noncanonical mode. @xref{Canonical or Not}. +@end deftypevr @comment termios.h @comment POSIX.1 -@vindex ECHO -@item ECHO +@deftypevr Macro tcflag_t ECHO If this bit is set, echoing of input characters back to the terminal is enabled. @cindex echo of terminal input +@end deftypevr @comment termios.h @comment POSIX.1 -@vindex ECHOE -@item ECHOE +@deftypevr Macro tcflag_t ECHOE If this bit is set, echoing indicates erasure of input with the ERASE character by erasing the last character in the current line from the screen. Otherwise, the character erased is re-echoed to show what has @@ -766,16 +797,28 @@ This bit only controls the display behavior; the @code{ICANON} bit by itself controls actual recognition of the ERASE character and erasure of input, without which @code{ECHOE} is simply irrelevant. +@end deftypevr + +@comment termios.h +@comment BSD +@deftypevr Macro tcflag_t ECHOPRT +This bit is like @code{ECHOE}, enables display of the ERASE character in +a way that is geared to a hardcopy terminal. When you type the ERASE +character, a @samp{\} character is printed followed by the first +character erased. Typing the ERASE character again just prints the next +character erased. Then, the next time you type a normal character, a +@samp{/} character is printed before the character echoes. + +This is a BSD extension, and exists only in BSD systems and the +GNU system. +@end deftypevr @comment termios.h @comment POSIX.1 -@vindex ECHOK -@item ECHOK -This bit enables special display of the KILL character. There are two -ways this can be done. The better way is by erasing on the screen the -entire line that has been killed. The worse way is by moving to a new -line after echoing the KILL character normally. Some systems do one, -some systems do the other, and some let you choose either way. +@deftypevr Macro tcflag_t ECHOK +This bit enables special display of the KILL character by moving to a +new line after echoing the KILL character normally. The behavior of +@code{ECHOKE} (below) is nicer to look at. If this bit is not set, the KILL character echoes just as it would if it were not the KILL character. Then it is up to the user to remember that @@ -785,19 +828,41 @@ This bit only controls the display behavior; the @code{ICANON} bit by itself controls actual recognition of the KILL character and erasure of input, without which @code{ECHOK} is simply irrelevant. +@end deftypevr + +@comment termios.h +@comment BSD +@deftypevr Macro tcflag_t ECHOKE +This bit is similar to @code{ECHOK}. It enables special display of the +KILL character by erasing on the screen the entire line that has been +killed. This is a BSD extension, and exists only in BSD systems and the +GNU system. +@end deftypevr @comment termios.h @comment POSIX.1 -@vindex ECHONL -@item ECHONL +@deftypevr Macro tcflag_t ECHONL If this bit is set and the @code{ICANON} bit is also set, then the newline (@code{'\n'}) character is echoed even if the @code{ECHO} bit is not set. +@end deftypevr + +@comment termios.h +@comment BSD +@deftypevr Macro tcflag_t ECHOCTL +If this bit is set and the @code{ECHO} bit is also set, echo control +characters with @samp{^} followed by the corresponding text character. +Thus, control-A echoes as @samp{^A}. This is usually the preferred mode +for interactive input, because echoing a control character back to the +terminal could have some undesired effect on the terminal. + +This is a BSD extension, and exists only in BSD systems and the +GNU system. +@end deftypevr @comment termios.h @comment POSIX.1 -@vindex ISIG -@item ISIG +@deftypevr Macro tcflag_t ISIG This bit controls whether the INTR, QUIT, and SUSP characters are recognized. The functions associated with these characters are performed if and only if this bit is set. Being in canonical or noncanonical @@ -811,66 +876,40 @@ @cindex interactive signals, from terminal @xref{Signal Characters}. +@end deftypevr @comment termios.h @comment POSIX.1 -@vindex IEXTEN -@item IEXTEN -This bit is similar to @code{ISIG}, but controls implementation-defined -special characters. If it is set, it might override the default behavior -for the @code{ICANON} and @code{ISIG} local mode flags, and the @code{IXON} -and @code{IXOFF} input mode flags. +@deftypevr Macro tcflag_t IEXTEN +POSIX.1 gives @code{IEXTEN} implementation-defined meaning, +so you cannot rely on this interpretation on all systems. + +On BSD systems and the GNU system, it enables the LNEXT and DISCARD characters. +@xref{Other Special}. +@end deftypevr @comment termios.h @comment POSIX.1 -@vindex NOFLSH -@item NOFLSH +@deftypevr Macro tcflag_t NOFLSH Normally, the INTR, QUIT, and SUSP characters cause input and output queues for the terminal to be cleared. If this bit is set, the queues are not cleared. +@end deftypevr @comment termios.h @comment POSIX.1 -@vindex TOSTOP -@item TOSTOP +@deftypevr Macro tcflag_t TOSTOP If this bit is set and the system supports job control, then @code{SIGTTOU} signals are generated by background processes that attempt to write to the terminal. @xref{Access to the Terminal}. -@end table - -The following bits are BSD extensions; the GNU library defines these -symbols on any system if you ask for them, but the settings of the bits -have no effect except on BSD systems and on the GNU system. - -@table @code -@comment termios.h -@comment BSD -@vindex ECHOKE -@item ECHOKE -On BSD systems, this bit selects between the two alternative ways of -displaying the KILL character, when @code{ECHOK} is set. If -@code{ECHOKE} is set, then the KILL character erases the whole screen -line; otherwise, the KILL character moves to the next screen line. -The setting of @code{ECHOKE} has no effect when @code{ECHOK} is clear. - -@comment termios.h -@comment BSD -@item ECHOPRT -@vindex ECHOPRT -This bit enables display of the ERASE character in a way that is geared -to a hardcopy terminal. - -@comment termios.h -@comment BSD -@vindex ECHOCTL -@item ECHOCTL -If this bit is set, echo control characters with @samp{^} followed by -the corresponding text character. Thus, control-A echoes as @samp{^A}. +@end deftypevr +The following bits are BSD extensions; they exist only in BSD systems +and the GNU system. + @comment termios.h @comment BSD -@vindex ALTWERASE -@item ALTWERASE +@deftypevr Macro tcflag_t ALTWERASE This bit determines how far the WERASE character should erase. The WERASE character erases back to the beginning of a word; the question is, where do words begin? @@ -880,28 +919,32 @@ beginning of a word is an alphanumeric character or underscore following a character which is none of those. +@xref{Editing Characters}, for more information about the WERASE character. +@end deftypevr + @comment termios.h @comment BSD -@vindex FLUSHO -@item FLUSHO +@deftypevr Macro tcflag_t FLUSHO This is the bit that toggles when the user types the DISCARD character. While this bit is set, all output is discarded. @xref{Other Special}. +@end deftypevr @comment termios.h @comment BSD -@vindex NOKERNINFO -@item NOKERNINFO +@deftypevr Macro tcflag_t NOKERNINFO Setting this bit disables handling of the STATUS character. @xref{Other Special}. +@end deftypevr @comment termios.h @comment BSD -@vindex PENDIN -@item PENDIN +@deftypevr Macro tcflag_t PENDIN If this bit is set, it indicates that there is a line of input that needs to be reprinted. Typing the REPRINT character sets this bit; the -bit remains set until reprinting is finished. @xref{BSD Editing}. -@end table +bit remains set until reprinting is finished. @xref{Editing Characters}. +@end deftypevr + +@c EXTPROC is too obscure to document now. --roland @node Line Speed @subsection Line Speed @@ -939,22 +982,22 @@ @comment termios.h @comment POSIX.1 -@deftypefun speed_t cfgetospeed (const struct termios *@var{termios_p}) +@deftypefun speed_t cfgetospeed (const struct termios *@var{termios-p}) This function returns the output line speed stored in the structure -@code{*@var{termios_p}}. +@code{*@var{termios-p}}. @end deftypefun @comment termios.h @comment POSIX.1 -@deftypefun speed_t cfgetispeed (const struct termios *@var{termios_p}) +@deftypefun speed_t cfgetispeed (const struct termios *@var{termios-p}) This function returns the input line speed stored in the structure -@code{*@var{termios_p}}. +@code{*@var{termios-p}}. @end deftypefun @comment termios.h @comment POSIX.1 -@deftypefun int cfsetospeed (struct termios *@var{termios_p}, speed_t @var{speed}) -This function stores @var{speed} in @code{*@var{termios_p}} as the output +@deftypefun int cfsetospeed (struct termios *@var{termios-p}, speed_t @var{speed}) +This function stores @var{speed} in @code{*@var{termios-p}} as the output speed. The normal return value is @code{0}; a value of @code{-1} indicates an error. If @var{speed} is not a speed, @code{cfsetospeed} returns @code{-1}. @@ -962,8 +1005,8 @@ @comment termios.h @comment POSIX.1 -@deftypefun int cfsetispeed (struct termios *@var{termios_p}, speed_t @var{speed}) -This function stores @var{speed} in @code{*@var{termios_p}} as the input +@deftypefun int cfsetispeed (struct termios *@var{termios-p}, speed_t @var{speed}) +This function stores @var{speed} in @code{*@var{termios-p}} as the input speed. The normal return value is @code{0}; a value of @code{-1} indicates an error. If @var{speed} is not a speed, @code{cfsetospeed} returns @code{-1}. @@ -971,8 +1014,8 @@ @comment termios.h @comment BSD -@deftypefun int cfsetspeed (struct termios *@var{termios_p}, speed_t @var{speed}) -This function stores @var{speed} in @code{*@var{termios_p}} as both the +@deftypefun int cfsetspeed (struct termios *@var{termios-p}, speed_t @var{speed}) +This function stores @var{speed} in @code{*@var{termios-p}} as both the input and output speeds. The normal return value is @code{0}; a value of @code{-1} indicates an error. If @var{speed} is not a speed, @code{cfsetspeed} returns @code{-1}. This function is an extension in @@ -1065,21 +1108,6 @@ alias for @code{B19200} and @code{EXTB} is an alias for @code{B38400}. These aliases are obsolete. -@comment termios.h -@comment BSD -@deftypefun int cfmakeraw (struct termios *@var{termios_p}) -This function provides an easy way to set up @code{*@var{termios_p}} for -what has traditionally been called ``raw mode'' in BSD. It does exactly this: -@smallexample - @var{termios_p}->c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP - |INLCR|IGNCR|ICRNL|IXON); - @var{termios_p}->c_oflag &= ~OPOST; - @var{termios_p}->c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN); - @var{termios_p}->c_cflag &= ~(CSIZE|PARENB); - @var{termios_p}->c_cflag |= CS8; -@end smallexample -@end deftypefun - @node Special Characters @subsection Special Characters @@ -1109,7 +1137,6 @@ @menu * Editing Characters:: Special characters that terminate lines and delete text, and other editing functions. -* BSD Editing:: Special editing characters for BSD systems. * Signal Characters:: Special characters that send or raise signals to or for certain classes of processes. * Start/Stop Characters:: Special characters that suspend or resume @@ -1162,6 +1189,23 @@ @end deftypevr @comment termios.h +@comment BSD +@deftypevr Macro int VEOL2 +@cindex EOL2 character +This is the subscript for the EOL2 character in the special control +character array. @code{@var{termios}.c_cc[VEOL2]} holds the character +itself. + +The EOL2 character works just like the EOL character (see above), but it +can be a different character. Thus, you can specify two characters to +terminate an input line, by setting EOL to one of them and EOL2 to the +other. + +The EOL2 character is a BSD extension; it exists only on BSD systems +and the GNU system. +@end deftypevr + +@comment termios.h @comment POSIX.1 @deftypevr Macro int VERASE @cindex ERASE character @@ -1181,53 +1225,45 @@ @end deftypevr @comment termios.h -@comment POSIX.1 -@deftypevr Macro int VKILL -@cindex KILL character -This is the subscript for the KILL character in the special control -character array. @code{@var{termios}.c_cc[VKILL]} holds the character +@comment BSD +@deftypevr Macro int VWERASE +@cindex WERASE character +This is the subscript for the WERASE character in the special control +character array. @code{@var{termios}.c_cc[VWERASE]} holds the character itself. -The KILL character is recognized only in canonical input mode. When the -user types the kill character, the entire contents of the current line -of input are discarded. The kill character itself is discarded too. +The WERASE character is recognized only in canonical mode. It erases an +entire word of prior input, and any whitespace after it; whitespace +characters before the word are not erased. -The KILL character is usually @kbd{C-u}. -@end deftypevr +The definition of a ``word'' depends on the setting of the +@code{ALTWERASE} mode; @pxref{Local Modes}. -@node BSD Editing -@subsubsection BSD Extensions to Editing Characters +If the @code{ALTWERASE} mode is not set, a word is defined as a sequence +of any characters except space or tab. -These special characters are active only in canonical input mode. -@xref{Canonical or Not}. They are BSD extensions; the GNU library -defines the symbols on any system if you ask for them, but the -characters you specify don't actually @emph{do} anything except on a BSD -system. +If the @code{ALTWERASE} mode is set, a word is defined as a sequence of +characters containing only letters, numbers, and underscores, optionally +followed by one character that is not a letter, number, or underscore. -@comment termios.h -@comment BSD -@deftypevr Macro int VEOL2 -@cindex EOL2 character -This is the subscript for the EOL2 character in the special control -character array. @code{@var{termios}.c_cc[VEOL2]} holds the character -itself. +The WERASE character is usually @kbd{C-w}. -The EOL2 character works just like the EOL character (see above), but it -can be a different character. Thus, you can specify two characters to -terminate an input line, but setting EOL to one of them and EOL2 to the -other. +This is a BSD extension. @end deftypevr @comment termios.h -@comment BSD -@deftypevr Macro int VWERASE -@cindex WERASE character -This is the subscript for the WERASE character in the special control -character array. @code{@var{termios}.c_cc[VWERASE]} holds the character +@comment POSIX.1 +@deftypevr Macro int VKILL +@cindex KILL character +This is the subscript for the KILL character in the special control +character array. @code{@var{termios}.c_cc[VKILL]} holds the character itself. -The WERASE character is recognized only in canonical input mode. It -erases an entire word of prior input. +The KILL character is recognized only in canonical input mode. When the +user types the kill character, the entire contents of the current line +of input are discarded. The kill character itself is discarded too. + +The KILL character is usually @kbd{C-u}. @end deftypevr @comment termios.h @@ -1238,24 +1274,13 @@ character array. @code{@var{termios}.c_cc[VREPRINT]} holds the character itself. -The REPRINT character is recognized only in canonical input mode. It -reprints the current input line. -@end deftypevr +The REPRINT character is recognized only in canonical mode. It reprints +the current input line. If some asynchronous output has come while you +are typing, this lets you see the line you are typing clearly again. -@comment termios.h -@comment BSD -@deftypevr Macro int VLNEXT -@cindex LNEXT character -This is the subscript for the LNEXT character in the special control -character array. @code{@var{termios}.c_cc[VLNEXT]} holds the character -itself. - -The LNEXT character is recognized only when @code{IEXTEN} is set. It -disables the editing significance of the next character the user types. -It is the analogue of the @kbd{C-q} command in Emacs. ``LNEXT'' stands -for ``literal next.'' +The REPRINT character is usually @kbd{C-r}. -The LNEXT character is usually @kbd{C-v}. +This is a BSD extension. @end deftypevr @node Signal Characters @@ -1336,7 +1361,7 @@ supports job control (@pxref{Job Control}). It sends a @code{SIGTSTP} signal, like the SUSP character, but not right away---only when the program tries to read it as input. Not all systems with job control -support DSUSP; only BSD systems. +support DSUSP; only BSD-compatible systems (including the GNU system). @xref{Signal Handling}, for more information about signals. @@ -1361,8 +1386,10 @@ The START character is used to support the @code{IXON} and @code{IXOFF} input modes. If @code{IXON} is set, receiving a START character resumes suspended output; the START character itself is discarded. If -@code{IXOFF} is set, the system may also transmit START characters to -the terminal. +@code{IXANY} is set, receiving any character at all resumes suspended +output; the resuming character is not discarded unless it is the START +character. @code{IXOFF} is set, the system may also transmit START +characters to the terminal. The usual value for the START character is @kbd{C-q}. You may not be able to change this value---the hardware may insist on using @kbd{C-q} @@ -1391,8 +1418,25 @@ @node Other Special @subsubsection Other Special Characters -Here are two additional special characters that are meaningful on BSD -systems. +These special characters exist only in BSD systems and the GNU system. + +@comment termios.h +@comment BSD +@deftypevr Macro int VLNEXT +@cindex LNEXT character +This is the subscript for the LNEXT character in the special control +character array. @code{@var{termios}.c_cc[VLNEXT]} holds the character +itself. + +The LNEXT character is recognized only when @code{IEXTEN} is set, but in +both canonical and noncanonical mode. It disables any special +significance of the next character the user types. Even if the +character would normally perform some editting function or generate a +signal, it is read as a plain character. This is the analogue of the +@kbd{C-q} command in Emacs. ``LNEXT'' stands for ``literal next.'' + +The LNEXT character is usually @kbd{C-v}. +@end deftypevr @comment termios.h @comment BSD @@ -1402,10 +1446,11 @@ character array. @code{@var{termios}.c_cc[VDISCARD]} holds the character itself. -The DISCARD character is recognized only when @code{IEXTEN} is set. Its -effect is to toggle the discard-output flag. When this flag is set, all -program output is discarded. Setting the flag also discards all output -currently in the output buffer. +The DISCARD character is recognized only when @code{IEXTEN} is set, but +in both canonical and noncanonical mode. Its effect is to toggle the +discard-output flag. When this flag is set, all program output is +discarded. Setting the flag also discards all output currently in the +output buffer. Typing any other character resets the flag. @end deftypevr @comment termios.h @@ -1419,9 +1464,8 @@ The STATUS character's effect is to print out a status message about how the current process is running. -The STATUS character is recognized only when canonical mode. This is a -peculiar design decision, since the STATUS character's meaning has -nothing to do with input, but that's the way it was done. +The STATUS character is recognized only in canonical mode, and only if +@code{NOKERNINFO} is not set. @end deftypevr @node Noncanonical Input @@ -1476,6 +1520,18 @@ them are nonzero. There are four possible cases: @itemize @bullet +@item +Both TIME and MIN are nonzero. + +In this case, TIME specifies how long to wait after each input character +to see if more input arrives. After the first character received, +@code{read} keeps waiting until either MIN bytes have arrived in all, or +TIME elapses with no further input. + +@code{read} always blocks until the first character arrives, even if +TIME elapses first. @code{read} can return more than MIN characters if +more than MIN happen to be in the queue. + @item Both MIN and TIME are zero. @@ -1501,17 +1557,6 @@ in the queue. At that time, @code{read} returns as many characters as are available, up to the number requested. @code{read} can return more than MIN characters if more than MIN happen to be in the queue. - -@item -Both TIME and MIN are nonzero. - -In this case, TIME specifies how long to wait after each input character -to see if more input arrives. @code{read} keeps waiting until either -MIN bytes have arrived, or TIME elapses with no further input. - -@code{read} can return no input if TIME elapses before the first input -character arrives. @code{read} can return more than MIN characters if -more than MIN happen to be in the queue. @end itemize What happens if MIN is 50 and you ask to read just 10 bytes? @@ -1526,6 +1571,25 @@ input and the EOF and EOL slots are used only in canonical input, but it isn't very clean. The GNU library allocates separate slots for these uses. + +@comment termios.h +@comment BSD +@deftypefun int cfmakeraw (struct termios *@var{termios-p}) +This function provides an easy way to set up @code{*@var{termios-p}} for +what has traditionally been called ``raw mode'' in BSD. This uses +noncanonical input, and turns off most processing to give an unmodified +channel to the terminal. + +It does exactly this: +@smallexample + @var{termios-p}->c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP + |INLCR|IGNCR|ICRNL|IXON); + @var{termios-p}->c_oflag &= ~OPOST; + @var{termios-p}->c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN); + @var{termios-p}->c_cflag &= ~(CSIZE|PARENB); + @var{termios-p}->c_cflag |= CS8; +@end smallexample +@end deftypefun @node Line Control @section Line Control Functions diff -ruN glibc-1.08.1/manual/texinfo.tex glibc-1.09/manual/texinfo.tex --- glibc-1.08.1/manual/texinfo.tex Tue May 10 02:30:20 1994 +++ glibc-1.09/manual/texinfo.tex Sun Nov 6 19:07:39 1994 @@ -24,7 +24,7 @@ % This automatically updates the version number based on RCS. \def\deftexinfoversion$#1: #2 ${\def\texinfoversion{#2}} -\deftexinfoversion$Revision: 2.126 $ +\deftexinfoversion$Revision: 2.136 $ \message{Loading texinfo package [Version \texinfoversion]:} % Print the version number if in a .fmt file. @@ -47,7 +47,14 @@ \let\ptexl=\l \let\ptexL=\L -\def\tie{\penalty 10000\ } % Save plain tex definition of ~. +% Be sure we're in horizontal mode when doing a tie, since we make space +% equivalent to this in @example-like environments. Otherwise, a space +% at the beginning of a line will start with \penalty -- and +% since \penalty is valid in vertical mode, we'd end up putting the +% penalty on the vertical list instead of in the new paragraph. +{\catcode`@ = 11 + \gdef\tie{\leavevmode\penalty\@M\ } +} \let\~ = \tie % And make it available as @~. \message{Basics,} @@ -352,6 +359,15 @@ % @. is an end-of-sentence period. \def\.{.\spacefactor=3000 } +% @enddots{} is an end-of-sentence ellipsis. +\gdef\enddots{$\mathinner{\ldotp\ldotp\ldotp\ldotp}$\spacefactor=3000} + +% @! is an end-of-sentence bang. +\gdef\!{!\spacefactor=3000 } + +% @? is an end-of-sentence query. +\gdef\?{?\spacefactor=3000 } + % @w prevents a word break. Without the \leavevmode, @w at the % beginning of a paragraph, when TeX is still in vertical mode, would % produce a whole line of output instead of starting the paragraph. @@ -609,9 +625,11 @@ % \def\ignore{\doignore{ignore}} -% Also ignore @ifinfo, @menu, and @direntry text. +% Also ignore @ifinfo, @ifhtml, @html, @menu, and @direntry text. % \def\ifinfo{\doignore{ifinfo}} +\def\ifhtml{\doignore{ifhtml}} +\def\html{\doignore{html}} \def\menu{\doignore{menu}} \def\direntry{\doignore{direntry}} @@ -1657,6 +1675,159 @@ \vadjust{\penalty 1200}}% \flushcr} +% @multitable macros +% Amy Hendrickson, 8/18/94 +% +% @multitable ... @endmultitable will make as many columns as desired. +% Contents of each column will wrap at width given in preamble. Width +% can be specified either with sample text given in a template line, +% or in percent of \hsize, the current width of text on page. + +% Table can continue over pages but will only break between lines. + +% To make preamble: +% +% Either define widths of columns in terms of percent of \hsize: +% @multitable @percentofhsize .2 .3 .5 +% @item ... +% +% Numbers following @percentofhsize are the percent of the total +% current hsize to be used for each column. You may use as many +% columns as desired. + +% Or use a template: +% @multitable {Column 1 template} {Column 2 template} {Column 3 template} +% @item ... +% using the widest term desired in each column. + + +% Each new table line starts with @item, each subsequent new column +% starts with @tab. Empty columns may be produced by supplying @tab's +% with nothing between them for as many times as empty columns are needed, +% ie, @tab@tab@tab will produce two empty columns. + +% @item, @tab, @multicolumn or @endmulticolumn do not need to be on their +% own lines, but it will not hurt if they are. + +% Sample multitable: + +% @multitable {Column 1 template} {Column 2 template} {Column 3 template} +% @item first col stuff @tab second col stuff @tab third col +% @item +% first col stuff +% @tab +% second col stuff +% @tab +% third col +% @item first col stuff @tab second col stuff +% @tab Many paragraphs of text may be used in any column. +% +% They will wrap at the width determined by the template. +% @item@tab@tab This will be in third column. +% @endmultitable + +% Default dimensions may be reset by user. +% @intableparskip will set vertical space between paragraphs in table. +% @intableparindent will set paragraph indent in table. +% @spacebetweencols will set horizontal space to be left between columns. +% @spacebetweenlines will set vertical space to be left between lines. + +%%%% +% Dimensions + +\newdimen\intableparskip +\newdimen\intableparindent +\newdimen\spacebetweencols +\newdimen\spacebetweenlines +\intableparskip=0pt +\intableparindent=6pt +\spacebetweencols=12pt +\spacebetweenlines=12pt + +%%%% +% Macros used to set up halign preamble: +\let\endsetuptable\relax +\def\xendsetuptable{\endsetuptable} +\let\percentofhsize\relax +\def\xpercentofhsize{\percentofhsize} +\newif\ifsetpercent + +\newcount\colcount +\def\setuptable#1{\def\firstarg{#1}% +\ifx\firstarg\xendsetuptable\let\go\relax% +\else + \ifx\firstarg\xpercentofhsize\global\setpercenttrue% + \else + \ifsetpercent + \if#1.\else% + \global\advance\colcount by1 % + \expandafter\xdef\csname col\the\colcount\endcsname{.#1\hsize}% + \fi + \else + \global\advance\colcount by1 + \setbox0=\hbox{#1}% + \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}% + \fi% + \fi% + \let\go\setuptable% +\fi\go} +%%%% +% multitable syntax +\def\tab{&} + +%%%% +% @multitable ... @endmultitable definitions: + +\def\multitable#1\item{\bgroup +\let\item\cr +\tolerance=9500 +\hbadness=9500 +\parskip=\intableparskip +\parindent=\intableparindent +\overfullrule=0pt +\global\colcount=0\relax% +\def\Emultitable{\global\setpercentfalse\global\everycr{}\cr\egroup\egroup}% + % To parse everything between @multitable and @item : +\def\one{#1}\expandafter\setuptable\one\endsetuptable + % Need to reset this to 0 after \setuptable. +\global\colcount=0\relax% + % + % This preamble sets up a generic column definition, which will + % be used as many times as user calls for columns. + % \vtop will set a single line and will also let text wrap and + % continue for many paragraphs if desired. +\halign\bgroup&\global\advance\colcount by 1\relax% +\vtop{\hsize=\expandafter\csname col\the\colcount\endcsname + % In order to keep entries from bumping into each other + % we will add a \leftskip of \spacebetweencols to all columns after + % the first one. + % If a template has been used, we will add \spacebetweencols + % to the width of each template entry. + % If user has set preamble in terms of percent of \hsize + % we will use that dimension as the width of the column, and + % the \leftskip will keep entries from bumping into each other. + % Table will start at left margin and final column will justify at + % right margin. +\ifnum\colcount=1 +\else + \ifsetpercent + \else + % If user has set preamble in terms of percent of \hsize + % we will advance \hsize by \spacebetweencols + \advance\hsize by \spacebetweencols + \fi + % In either case we will make \leftskip=\spacebetweencols: +\leftskip=\spacebetweencols +\fi +\noindent##}\cr% + % \everycr will reset column counter, \colcount, at the end of + % each line. Every column entry will cause \colcount to advance by one. + % The table preamble + % looks at the current \colcount to find the correct column width. +\global\everycr{\noalign{\nointerlineskip\vskip\spacebetweenlines +\filbreak%% keeps underfull box messages off when table breaks over pages. +\global\colcount=0\relax}}} + \message{indexing,} % Index generation facilities @@ -2674,6 +2845,7 @@ \unnumbchapmacro{#1}\def\thischapter{}% \begingroup % Set up to handle contents files properly. \catcode`\\=0 \catcode`\{=1 \catcode`\}=2 \catcode`\@=11 + \catcode`\^=7 % to see ^^e4 as \"a etc. juha@piuha.ydi.vtt.fi \raggedbottom % Worry more about breakpoints than the bottom. \advance\hsize by -\contentsrightmargin % Don't use the full line length. } @@ -3095,23 +3267,26 @@ \advance\leftskip by 0pt plus 1fill \gobble} -% @quotation does normal linebreaking and narrows the margins. +% @quotation does normal linebreaking (hence we can't use \nonfillstart) +% and narrows the margins. % \def\quotation{% -\begingroup\inENV %This group ends at the end of the @quotation body -{\parskip=0pt % because we will skip by \parskip too, later -\aboveenvbreak}% -\singlespace -\parindent=0pt -\let\Equotation = \nonfillfinish -% @cartouche defines \nonarrowing to inhibit narrowing -% at next level down. -\ifx\nonarrowing\relax -\advance \leftskip by \lispnarrowing -\advance \rightskip by \lispnarrowing -\exdentamount=\lispnarrowing -\let\nonarrowing=\relax -\fi} + \begingroup\inENV %This group ends at the end of the @quotation body + {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip + \singlespace + \parindent=0pt + % We have retained a nonzero parskip for the environment, since we're + % doing normal filling. So to avoid extra space below the environment... + \def\Equotation{\parskip = 0pt \nonfillfinish}% + % + % @cartouche defines \nonarrowing to inhibit narrowing at next level down. + \ifx\nonarrowing\relax + \advance\leftskip by \lispnarrowing + \advance\rightskip by \lispnarrowing + \exdentamount = \lispnarrowing + \let\nonarrowing = \relax + \fi +} \message{defuns,} % Define formatter for defuns @@ -3388,7 +3563,7 @@ % #1 is the data type, #2 the name, #3 the args. \def\deftypefunheaderx #1#2 #3\relax{% \doind {fn}{\code{#2}}% Make entry in function index -\begingroup\defname {\code{#1} #2}{Function}% +\begingroup\defname {\defheaderxcond#1\relax$$$#2}{Function}% \deftypefunargs {#3}\endgroup % \catcode 61=\other % Turn off change made in \defparsebody } @@ -3397,6 +3572,10 @@ \def\deftypefn{\defmethparsebody\Edeftypefn\deftypefnx\deftypefnheader} +% \defheaderxcond#1\relax$$$ +% puts #1 in @code, followed by a space, but does nothing if #1 is null. +\def\defheaderxcond#1#2$$${\ifx#1\relax\else\code{#1#2} \fi} + % #1 is the classification. #2 is the data type. #3 is the name and args. \def\deftypefnheader #1#2#3{\deftypefnheaderx{#1}{#2}#3 \relax} % #1 is the classification, #2 the data type, #3 the name, #4 the args. @@ -3405,7 +3584,7 @@ \begingroup \normalparens % notably, turn off `&' magic, which prevents % at least some C++ text from working -\defname {\code{#2} #3}{#1}% +\defname {\defheaderxcond#2\relax$$$#3}{#1}% \deftypefunargs {#4}\endgroup % \catcode 61=\other % Turn off change made in \defparsebody } @@ -3533,7 +3712,7 @@ % #1 is the data type. #2 is the name. \def\deftypevarheader #1#2{% \doind {vr}{\code{#2}}% Make entry in variables index -\begingroup\defname {\code{#1} #2}{Variable}% +\begingroup\defname {\defheaderxcond#1\relax$$$#2}{Variable}% \interlinepenalty=10000 \endgraf\penalty 10000\vskip -\parskip\penalty 10000 \endgroup} @@ -3543,7 +3722,7 @@ \def\deftypevr{\defvrparsebody\Edeftypevr\deftypevrx\deftypevrheader} \def\deftypevrheader #1#2#3{\doind {vr}{\code{#3}}% -\begingroup\defname {\code{#2} #3}{#1} +\begingroup\defname {\defheaderxcond#2\relax$$$#3}{#1} \interlinepenalty=10000 \endgraf\penalty 10000\vskip -\parskip\penalty 10000 \endgroup} @@ -3607,44 +3786,53 @@ \def\pxref#1{\putwordsee{} \xrefX[#1,,,,,,,]} \def\xref#1{\putwordSee{} \xrefX[#1,,,,,,,]} \def\ref#1{\xrefX[#1,,,,,,,]} -\def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup% -\def\printedmanual{\ignorespaces #5}% -\def\printednodename{\ignorespaces #3}% -\def\correctnodename{{\normalturnoffactive\printednodename}}% -\setbox1=\hbox{\printedmanual}% -\setbox0=\hbox{\printednodename}% -\ifdim \wd0=0pt% -% No printed node name was explicitly given. -\ifx SETxref-automatic-section-title % -% This line should make the actual chapter or section title appear inside -% the square brackets. Use the real section title if we have it. -\ifdim \wd1>0pt% -% It is in another manual, so we don't have it. -\def\printednodename{\ignorespaces #1} \else% -% We know the real title if we have the xref values. -\ifhavexrefs \def\printednodename{\refx{#1-title}}% -% Otherwise just copy the Info node name. -\else \def\printednodename{\ignorespaces #1} \fi% -\fi\def\printednodename{#1-title}% -\else% This line just uses the node name. -\def\printednodename{\ignorespaces #1}% -\fi% ends \ifx SETxref-automatic-section-title -\fi% ends \ifdim \wd0 -% -% -% If we use \unhbox0 and \unhbox1 to print the node names, TeX does -% not insert empty discretionaries after hyphens, which means that it -% will not find a line break at a hyphen in a node names. Since some -% manuals are best written with fairly long node names, containing -% hyphens, this is a loss. Therefore, we simply give the text of -% the node name again, so it is as if TeX is seeing it for the first -% time. -\ifdim \wd1>0pt -\putwordsection{} ``\correctnodename'' in \cite{\printedmanual}% -\else% -\turnoffactive% -\refx{#1-snt}{} [\correctnodename], \putwordpage\tie\refx{#1-pg}{}% -\fi +\def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup + \def\printedmanual{\ignorespaces #5}% + \def\printednodename{\ignorespaces #3}% + \setbox1=\hbox{\printedmanual}% + \setbox0=\hbox{\printednodename}% + \ifdim \wd0 = 0pt + % No printed node name was explicitly given. + \ifx\SETxref-automatic-section-title\relax % + % Use the actual chapter/section title appear inside + % the square brackets. Use the real section title if we have it. + \ifdim \wd1>0pt% + % It is in another manual, so we don't have it. + \def\printednodename{\ignorespaces #1}% + \else + \ifhavexrefs + % We know the real title if we have the xref values. + \def\printednodename{\refx{#1-title}}% + \else + % Otherwise just copy the Info node name. + \def\printednodename{\ignorespaces #1}% + \fi% + \fi + \def\printednodename{#1-title}% + \else + % Use the node name inside the square brackets. + \def\printednodename{\ignorespaces #1}% + \fi + \fi + % + % If we use \unhbox0 and \unhbox1 to print the node names, TeX does not + % insert empty discretionaries after hyphens, which means that it will + % not find a line break at a hyphen in a node names. Since some manuals + % are best written with fairly long node names, containing hyphens, this + % is a loss. Therefore, we give the text of the node name again, so it + % is as if TeX is seeing it for the first time. + \ifdim \wd1 > 0pt + \putwordsection{} ``\printednodename'' in \cite{\printedmanual}% + \else + % _ (for example) has to be the character _ for the purposes of the + % control sequence corresponding to the node, but it has to expand + % into the usual \leavevmode...\vrule stuff for purposes of + % printing. So we \turnoffactive for the \refx-snt, back on for the + % printing, back off for the \refx-pg. + {\turnoffactive \refx{#1-snt}{}}% + \space [\printednodename],\space + \turnoffactive \putwordpage\tie\refx{#1-pg}{}% + \fi \endgroup} % \dosetq is the interface for calls from other macros @@ -3772,6 +3960,15 @@ \catcode `\&=\other % `\+ does not work, so use 43. \catcode 43=\other +% Make the characters 128-255 be printing characters +{% + \count 1=128 + \def\loop{% + \catcode\count 1=\other + \advance\count 1 by 1 + \ifnum \count 1<256 \loop \fi + }% +}% % the aux file uses ' as the escape. % Turn off \ as an escape so we do not lose on % entries which were dumped with control sequences in their names. @@ -3997,6 +4194,28 @@ \global\pagewidth=\hsize \global\pageheight=\vsize } + +% Allow control of the text dimensions. Parameters in order: textheight; +% textwidth; \voffset; \hoffset (!); binding offset. All require a dimension; +% header is additional; added length extends the bottom of the page. + +\def\changepagesizes#1#2#3#4#5 +{\global\vsize= #1 + \advance\vsize by \topskip + \global\voffset= #3 + \global\hsize= #2 + \global\outerhsize=\hsize + \global\advance\outerhsize by 0.5in + \global\outervsize=\vsize + \global\advance\outervsize by 0.6in + \global\pagewidth=\hsize + \global\pageheight=\vsize + \global\normaloffset= #4 + \global\bindingoffset= #5} + +% This layout is compatible with Latex on A4 paper. + +\def\afourlatex{\changepagesizes{22cm}{15cm}{7mm}{4.6mm}{5mm}} % Define macros to output various characters with catcode for normal text. \catcode`\"=\other diff -ruN glibc-1.08.1/manual/time.texi glibc-1.09/manual/time.texi --- glibc-1.08.1/manual/time.texi Tue Feb 22 18:49:35 1994 +++ glibc-1.09/manual/time.texi Mon Oct 24 01:44:21 1994 @@ -148,9 +148,11 @@ This is the sum of the @code{tms_utime} values and the @code{tms_cutime} values of all terminated child processes of the calling process, whose status has been reported to the parent process by @code{wait} or -@code{waitpid}; see @ref{Process Completion}. In other words, it represents -the total CPU time used in executing the instructions of all the terminated -child processes of the calling process. +@code{waitpid}; see @ref{Process Completion}. In other words, it +represents the total CPU time used in executing the instructions of all +the terminated child processes of the calling process, excluding child +processes which have not yet been reported by @code{wait} or +@code{waitpid}. @item clock_t tms_cstime This is similar to @code{tms_cutime}, but represents the total CPU time @@ -299,9 +301,9 @@ This is the fractional second value, represented as the number of microseconds. -Some times struct timeval values are user for time intervals. Then the +Some times struct timeval values are used for time intervals. Then the @code{tv_sec} member is the number of seconds in the interval, and -@code{tv_usec} is the number of addictional microseconds. +@code{tv_usec} is the number of additional microseconds. @end table @end deftp @@ -439,7 +441,7 @@ @cindex broken-down time @cindex calendar time and broken-down time -Calender time is represented as a number of seconds. This is convenient +Calendar time is represented as a number of seconds. This is convenient for calculation, but has no resemblance to the way people normally represent dates and times. By contrast, @dfn{broken-down time} is a binary representation separated into year, month, day, and so on. Broken down @@ -596,9 +598,9 @@ @comment time.h @comment ANSI @deftypefun {char *} ctime (const time_t *@var{time}) -The @code{ctime} function is similar to @code{asctime}, except that -the time value is specified in calendar time (rather than local time) -format. It is equivalent to +The @code{ctime} function is similar to @code{asctime}, except that the +time value is specified as a @code{time_t} calendar time value rather +than in broken-down local time format. It is equivalent to @smallexample asctime (localtime (@var{time})) @@ -716,16 +718,31 @@ @node TZ Variable @subsection Specifying the Time Zone with @code{TZ} -In the GNU system, a user can specify the time zone by means of the +In POSIX systems, a user can specify the time zone by means of the @code{TZ} environment variable. For information about how to set -environment variables, see @ref{Environment Variables}. The functions for -accessing the time zone are declared in @file{time.h}. +environment variables, see @ref{Environment Variables}. The functions +for accessing the time zone are declared in @file{time.h}. @pindex time.h @cindex time zone -The value of the @code{TZ} variable can be of one of three formats. The -first format is used when there is no Daylight Saving Time (or summer -time) in the local time zone: +You should not normally need to set @code{TZ}. If the system is +configured properly, the default timezone will be correct. You might +set @code{TZ} if you are using a computer over the network from a +different timezone, and would like times reported to you in the timezone +that local for you, rather than what is local for the computer. + +In POSIX.1 systems the value of the @code{TZ} variable can be of one of +three formats. With the GNU C library, the most common format is the +last one, which can specify a selection from a large database of time +zone information for many regions of the world. The first two formats +are used to describe the time zone information directly, which is both +more cumbersome and less precise. But the POSIX.1 standard only +specifies the details of the first two formats, so it is good to be +familiar with them in case you come across a POSIX.1 system that doesn't +support a time zone information database. + +The first format is used when there is no Daylight Saving Time (or +summer time) in the local time zone: @smallexample @r{@var{std} @var{offset}} @@ -800,14 +817,15 @@ EST+5EDT,M4.1.0/M10.5.0 @end smallexample -@c !!! this is not true if using the tzfile database The schedule of daylight savings time in any particular jurisdiction has changed over the years. To be strictly correct, the conversion of dates and times in the past should be based on the schedule that was in effect -then. However, the system has no facilities to let you specify how the +then. However, this format has no facilities to let you specify how the schedule has changed from year to year. The most you can do is specify one particular schedule---usually the present day schedule---and this is -used to convert any date, no matter when. +used to convert any date, no matter when. For precise time zone +specifications, it is best to use the time zone information database +(see below). The third format looks like this: @@ -819,15 +837,31 @@ library, @var{characters} is the name of a file which describes the time zone. +@pindex /etc/localtime +@pindex localtime If the @code{TZ} environment variable does not have a value, the -operation chooses a time zone by default. Each operating system has its -own rules for choosing the default time zone, so there is little we can -say about them. - -@c !!! this does not vary among operating systems in glibc. No variable -@c is like "TZ=:$(prefix)/etc/localtime". Should describe zic program. -@c If the name after the : doesn't start with a slash, it is relative to -@c $(datadir)/zoneinfo. +operation chooses a time zone by default. In the GNU C library, the +default time zone is like the specification @samp{TZ=:/etc/localtime} +(or @samp{TZ=:/usr/local/etc/localtime}, depending on how GNU C library +was configured; @pxref{Installation}). Other C libraries use their own +rule for choosing the default time zone, so there is little we can say +about them. + +@cindex time zone database +@pindex /share/lib/zoneinfo +@pindex zoneinfo +If @var{characters} begins with a slash, it is an absolute file name; +otherwise the library looks for the file +@w{@file{/share/lib/zoneinfo/@var{characters}}}. The @file{zoneinfo} +directory contains data files describing local time zones in many +different parts of the world. The names represent major cities, with +subdirectories for geographical areas; for example, +@file{America/New_York}, @file{Europe/London}, @file{Asia/Hong_Kong}. +These data files are installed by the system administrator, who also +sets @file{/etc/localtime} to point to the data file for the local time +zone. The GNU C library comes with a large database of time zone +information for most regions of the world, which is maintained by a +community of volunteers and put in the public domain. @node Time Zone Functions @subsection Functions and Variables for Time Zones @@ -913,17 +947,25 @@ A real-time timer that counts clock time. This timer sends a @code{SIGALRM} signal to the process when it expires. @cindex real-time timer +@cindex timer, real-time @item A virtual timer that counts CPU time used by the process. This timer sends a @code{SIGVTALRM} signal to the process when it expires. @cindex virtual timer +@cindex timer, virtual @item A profiling timer that counts both CPU time used by the process, and CPU time spent in system calls on behalf of the process. This timer sends a @code{SIGPROF} signal to the process when it expires. @cindex profiling timer +@cindex timer, profiling + +This timer is useful for profiling in interpreters. The interval timer +mechanism does not have the fine granularity necessary for profiling +native code. +@c @xref{profil} !!! @end itemize You can only have one timer of each kind set at any given time. If you @@ -1172,28 +1214,62 @@ @table @code @item struct timeval ru_utime -User time used. +Time spent executing user instructions. @item struct timeval ru_stime -System time used. +Time spent in operating system code on behalf of @var{processes}. + +@item long int ru_maxrss +The maximum resident set size used, in kilobytes. That is, the maximum +number of kilobytes that @var{processes} used in real memory simultaneously. + +@item long int ru_ixrss +An integral value expressed in kilobytes times ticks of execution, which +indicates the amount of memory used by text that was shared with other +processes. + +@item long int ru_idrss +An integral value expressed the same way, which is the amount of +unshared memory used in data. -@item long ru_majflt -Number of page faults. +@item long int ru_isrss +An integral value expressed the same way, which is the amount of +unshared memory used in stack space. -@item long ru_inblock -Number of block input operations. +@item long int ru_minflt +The number of page faults which were serviced without requiring any I/O. -@item long ru_oublock -Number of block output operations. +@item long int ru_majflt +The number of page faults which were serviced by doing I/O. -@item long ru_msgsnd -Number of messages sent. +@item long int ru_nswap +The number of times @var{processes} was swapped entirely out of main memory. + +@item long int ru_inblock +The number of times the file system had to read from the disk on behalf +of @var{processes}. + +@item long int ru_oublock +The number of times the file system had to write to the disk on behalf +of @var{processes}. + +@item long int ru_msgsnd +Number of IPC messages sent. @item long ru_msgrcv -Number of messages received. +Number of IPC messages received. -@item long ru_nsignals +@item long int ru_nsignals Number of signals received. + +@item long int ru_nvcsw +The number of times @var{processes} voluntarily invoked a context switch +(usually to wait for some service). + +@item long int ru_nivcsw +The number of times an involuntary context switch took place (because +the time slice expired, or another process of higher priority became +runnable). @end table @end deftp @@ -1251,11 +1327,15 @@ @table @code @item rlim_cur The current value of the limit in question. +This is also called the ``soft limit''. +@cindex soft limit @item rlim_max The maximum permissible value of the limit in question. You cannot set the current value of the limit to a larger number than this maximum. Only the super user can change the maximum permissible value. +This is also called the ``hard limit''. +@cindex hard limit @end table In @code{getrlimit}, the structure is an output; it receives the current @@ -1272,14 +1352,14 @@ @vindex RLIMIT_CPU The maximum amount of cpu time the process can use. If it runs for longer than this, it gets a signal: @code{SIGXCPU}. The value is -measured in seconds. @xref{Nonstandard Signals}. +measured in seconds. @xref{Operation Error Signals}. @comment sys/resource.h @comment BSD @item RLIMIT_FSIZE @vindex RLIMIT_FSIZE The maximum size of file the process can create. Trying to write a -larger file causes a signal: @code{SIGXFSZ}. @xref{Nonstandard +larger file causes a signal: @code{SIGXFSZ}. @xref{Operation Error Signals}. @comment sys/resource.h @@ -1303,8 +1383,9 @@ @item RLIMIT_CORE @vindex RLIMIT_CORE The maximum size core file that this process can create. If the process -terminates and a core file is made, and this maximum size is not enough, -the core file is truncated. +terminates and would dump a core file larger than this maximum size, +then no core file is created. So setting this limit to zero prevents +core files from ever being created. @comment sys/resource.h @comment BSD @@ -1317,11 +1398,27 @@ @comment sys/resource.h @comment BSD -@item RLIMIT_OPEN_FILES -@vindex RLIMIT_OPEN_FILES -The maximum number of files that the process can open. -If it tries to open more files than this, it gets error code -@code{EMFILE}. @xref{Error Codes}. +@item RLIMIT_MEMLOCK +The maximum amount of memory that can be locked into physical memory (so +it will never be paged out). + +@comment sys/resource.h +@comment BSD +@item RLIMIT_NPROC +The maximum number of processes that can be created with the same user ID. +If you have reached the limit for your user ID, @code{fork} will fail +with @code{EAGAIN}. @xref{Creating a Process}. + +@comment sys/resource.h +@comment BSD +@item RLIMIT_NOFILE +@vindex RLIMIT_NOFILE +@itemx RLIMIT_OFILE +@vindex RLIMIT_OFILE +The maximum number of files that the process can open. If it tries to +open more files than this, it gets error code @code{EMFILE}. +@xref{Error Codes}. Not all systems support this limit; GNU does, and +4.4 BSD does. @comment sys/resource.h @comment BSD @@ -1377,10 +1474,9 @@ @comment BSD @deftypefun int getpriority (int @var{class}, int @var{id}) Read the priority of a class of processes; @var{class} and @var{id} -specify which ones (see below). - -@c ??? What happens if class and id specify several processes -@c ??? whose priorities differ? +specify which ones (see below). If the processes specified do not all +have the same priority, this returns the smallest value that any of them +has. The return value is the priority value on success, and @code{-1} on failure. The following @code{errno} error condition are possible for @@ -1404,8 +1500,8 @@ @comment sys/resource.h @comment BSD @deftypefun int setpriority (int @var{class}, int @var{id}, int @var{priority}) -Read the priority of a class of processes; @var{class} and @var{id} -specify which ones (see below). +Set the priority of a class of processes to @var{priority}; @var{class} +and @var{id} specify which ones (see below). The return value is @code{0} on success and @code{-1} on failure. The following @code{errno} error condition are defined for this function: @@ -1463,8 +1559,7 @@ @comment dunno.h @deftypefun int nice (int @var{increment}) Increment the priority of the current process by @var{increment}. -The return value is not meaningful. -@c ??? What is it in GNU libc? +The return value is the same as for @code{setpriority}. Here is an equivalent definition for @code{nice}: @@ -1473,7 +1568,7 @@ nice (int increment) @{ int old = getpriority (PRIO_PROCESS, 0); - setpriority (PRIO_PROCESS, 0, old + increment); + return setpriority (PRIO_PROCESS, 0, old + increment); @} @end smallexample @end deftypefun diff -ruN glibc-1.08.1/manual/users.texi glibc-1.09/manual/users.texi --- glibc-1.08.1/manual/users.texi Mon Feb 7 18:28:29 1994 +++ glibc-1.09/manual/users.texi Fri Oct 14 03:59:32 1994 @@ -709,7 +709,7 @@ @cindex password database @pindex /etc/passwd -This section describes all about now to search and scan the database of +This section describes all about how to search and scan the database of registered users. The database itself is kept in the file @file{/etc/passwd} on most systems, but on some systems a special network server gives access to it. diff -ruN glibc-1.08.1/misc/Makefile glibc-1.09/misc/Makefile --- glibc-1.08.1/misc/Makefile Wed May 11 19:51:57 1994 +++ glibc-1.09/misc/Makefile Sat Oct 1 04:25:20 1994 @@ -25,7 +25,7 @@ headers := sys/uio.h sys/ioctl.h sys/ptrace.h ioctls.h sys/file.h \ a.out.h nlist.h stab.h stab.def sgtty.h sys/dir.h sys/cdefs.h \ ttyent.h syscall.h syslog.h sys/syslog.h paths.h sys/reboot.h \ - sys/mman.h sys/param.h + sys/mman.h sys/param.h fstab.h routines := brk sbrk sstk ioctl \ __brk __sbrk __ioctl \ @@ -37,7 +37,7 @@ __getpgsz \ getdtsz \ __getdtsz \ - __gethstnm gethstnm sethostnam \ + __gethstnm gethstnm sethostnam getdomain setdomain \ __select select \ acct chroot fsync sync reboot \ gethostid sethostid \ @@ -46,18 +46,17 @@ ualarm usleep \ gtty stty \ ptrace \ - nlist \ - utimes \ - __utimes \ + nlist fstab \ + utimes __utimes \ truncate ftruncate \ chflags fchflags \ insremque getttyent getusersh getpass ttyslot \ - syslog syscall \ + syslog syscall daemon \ mmap munmap mprotect msync madvise -aux := data_start progname +aux := data_start progname init-misc distribute := bsd-compat.c extra-objs := bsd-compat.o -install-lib := libbsd-compat.a +install-lib := libbsd-compat.a libg.a non-lib.a := libbsd-compat.a include ../Rules @@ -67,3 +66,6 @@ ln $< $@ lib: $(objpfx)libbsd-compat.a + +$(objpfx)libg.a: $(dep-dummy-lib); $(make-dummy-lib) +lib: $(objpfx)libg.a diff -ruN glibc-1.08.1/misc/daemon.c glibc-1.09/misc/daemon.c --- glibc-1.08.1/misc/daemon.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/misc/daemon.c Fri Sep 30 22:46:03 1994 @@ -0,0 +1,71 @@ +/*- + * 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[] = "@(#)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 -ruN glibc-1.08.1/misc/fstab.c glibc-1.09/misc/fstab.c --- glibc-1.08.1/misc/fstab.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/misc/fstab.c Tue Aug 30 21:31:34 1994 @@ -0,0 +1,205 @@ +/* + * 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. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)fstab.c 8.1 (Berkeley) 6/4/93"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include +#include +#include +#include +#include + +#ifndef EFTYPE +#define EFTYPE EINVAL +#endif + +static FILE *_fs_fp; +static struct fstab _fs_fstab; + +static void error __P((int)); + +static int +fstabscan __P((void)) +{ + register char *cp; +#define MAXLINELENGTH 1024 + static char line[MAXLINELENGTH]; + char subline[MAXLINELENGTH]; + int typexx; + + for (;;) { + if (!(cp = fgets(line, sizeof(line), _fs_fp))) + return(0); +/* OLD_STYLE_FSTAB */ + if (!strpbrk(cp, " \t")) { + _fs_fstab.fs_spec = strtok(cp, ":\n"); + _fs_fstab.fs_file = strtok((char *)NULL, ":\n"); + _fs_fstab.fs_type = strtok((char *)NULL, ":\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 = strtok((char *)NULL, ":\n")) { + _fs_fstab.fs_freq = atoi(cp); + if (cp = strtok((char *)NULL, ":\n")) { + _fs_fstab.fs_passno = atoi(cp); + return(1); + } + } + } + goto bad; + } +/* OLD_STYLE_FSTAB */ + _fs_fstab.fs_spec = strtok(cp, " \t\n"); + if (!_fs_fstab.fs_spec || *_fs_fstab.fs_spec == '#') + continue; + _fs_fstab.fs_file = strtok((char *)NULL, " \t\n"); + _fs_fstab.fs_vfstype = strtok((char *)NULL, " \t\n"); + _fs_fstab.fs_mntops = strtok((char *)NULL, " \t\n"); + if (_fs_fstab.fs_mntops == NULL) + goto bad; + _fs_fstab.fs_freq = 0; + _fs_fstab.fs_passno = 0; + if ((cp = strtok((char *)NULL, " \t\n")) != NULL) { + _fs_fstab.fs_freq = atoi(cp); + if ((cp = strtok((char *)NULL, " \t\n")) != NULL) + _fs_fstab.fs_passno = atoi(cp); + } + strcpy(subline, _fs_fstab.fs_mntops); + for (typexx = 0, cp = strtok(subline, ","); cp; + cp = strtok((char *)NULL, ",")) { + 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); +} + +setfsent() +{ + if (_fs_fp) { + rewind(_fs_fp); + return(1); + } + if (_fs_fp = fopen(_PATH_FSTAB, "r")) + 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; + + (void)write(STDERR_FILENO, "fstab: ", 7); + (void)write(STDERR_FILENO, _PATH_FSTAB, sizeof(_PATH_FSTAB) - 1); + (void)write(STDERR_FILENO, ": ", 1); + p = strerror(err); + (void)write(STDERR_FILENO, p, strlen(p)); + (void)write(STDERR_FILENO, "\n", 1); +} diff -ruN glibc-1.08.1/misc/fstab.h glibc-1.09/misc/fstab.h --- glibc-1.08.1/misc/fstab.h Wed Dec 31 19:00:00 1969 +++ glibc-1.09/misc/fstab.h Tue Aug 30 07:08:50 1994 @@ -0,0 +1,79 @@ +/* + * 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. + * + * @(#)fstab.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _FSTAB_H_ +#define _FSTAB_H_ + +/* + * File system table, see fstab(5). + * + * Used by dump, mount, umount, swapon, fsck, df, ... + * + * For ufs fs_spec field is the block special name. Programs that want to + * use the character special name must create that name by prepending a 'r' + * after the right most slash. Quota files are always named "quotas", so + * if type is "rq", then use concatenation of fs_file and "quotas" to locate + * quota file. + */ +#define _PATH_FSTAB "/etc/fstab" +#define FSTAB "/etc/fstab" /* deprecated */ + +#define FSTAB_RW "rw" /* read/write device */ +#define FSTAB_RQ "rq" /* read/write with quotas */ +#define FSTAB_RO "ro" /* read-only device */ +#define FSTAB_SW "sw" /* swap device */ +#define FSTAB_XX "xx" /* ignore totally */ + +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 dump */ +}; + +#include + +__BEGIN_DECLS +struct fstab *getfsent __P((void)); +struct fstab *getfsspec __P((const char *)); +struct fstab *getfsfile __P((const char *)); +int setfsent __P((void)); +void endfsent __P((void)); +__END_DECLS + +#endif /* !_FSTAB_H_ */ diff -ruN glibc-1.08.1/misc/getpass.c glibc-1.09/misc/getpass.c --- glibc-1.08.1/misc/getpass.c Sun Apr 11 19:09:01 1993 +++ glibc-1.09/misc/getpass.c Mon Jul 18 18:01:03 1994 @@ -1,4 +1,4 @@ -/* Copyright (C) 1992, 1993 Free Software Foundation, Inc. +/* Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -78,7 +78,7 @@ buf[0] = '\0'; else if (buf[nread - 1] == '\n') /* Remove the newline. */ - buf[nread] = '\0'; + buf[nread - 1] = '\0'; /* Restore echoing. */ if (echo_off) diff -ruN glibc-1.08.1/misc/getttyent.c glibc-1.09/misc/getttyent.c --- glibc-1.08.1/misc/getttyent.c Sat Sep 12 16:31:16 1992 +++ glibc-1.09/misc/getttyent.c Sun Jul 31 15:13:26 1994 @@ -1,6 +1,6 @@ /* - * Copyright (c) 1989 The Regents of the University of California. - * All rights reserved. + * 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 @@ -32,7 +32,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)getttyent.c 5.10 (Berkeley) 3/23/91"; +static char sccsid[] = "@(#)getttyent.c 8.1 (Berkeley) 6/4/93"; #endif /* LIBC_SCCS and not lint */ #include @@ -108,10 +108,6 @@ tty.ty_status |= TTY_ON; else if (scmp(_TTYS_SECURE)) tty.ty_status |= TTY_SECURE; - else if (scmp(_TTYS_TRUSTED)) - tty.ty_status |= TTY_TRUSTED; - else if (scmp(_TTYS_CONSOLE)) - tty.ty_status |= TTY_CONSOLE; else if (vcmp(_TTYS_WINDOW)) tty.ty_window = value(p); else diff -ruN glibc-1.08.1/misc/getusersh.c glibc-1.09/misc/getusersh.c --- glibc-1.08.1/misc/getusersh.c Mon Nov 16 14:50:37 1992 +++ glibc-1.09/misc/getusersh.c Sun Jul 31 15:26:32 1994 @@ -1,6 +1,6 @@ /* - * Copyright (c) 1985 Regents of the University of California. - * All rights reserved. + * 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 @@ -32,31 +32,29 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)getusershell.c 5.7 (Berkeley) 2/23/91"; +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 - -#define SHELLS "/etc/shells" +#include /* - * Do not add local shells here. They should be added in /etc/shells + * Local shells should NOT be added here. They should be added in + * /etc/shells. */ -static const char *okshells[] = - { "/bin/sh", "/bin/csh", 0 }; -static char **shells, *strings; -static char **curshell = NULL; -static char **initshells(); +static char *okshells[] = { _PATH_BSHELL, _PATH_CSHELL, NULL }; +static char **curshell, **shells, *strings; +static char **initshells __P((void)); /* - * Get a list of shells from SHELLS, if it exists. + * Get a list of shells from _PATH_SHELLS, if it exists. */ char * getusershell() @@ -76,7 +74,7 @@ { if (shells != NULL) - free((char *)shells); + free(shells); shells = NULL; if (strings != NULL) free(strings); @@ -99,31 +97,31 @@ struct stat statb; if (shells != NULL) - free((char *)shells); + free(shells); shells = NULL; if (strings != NULL) free(strings); strings = NULL; - if ((fp = fopen(SHELLS, "r")) == (FILE *)0) - return(okshells); + if ((fp = fopen(_PATH_SHELLS, "r")) == NULL) + return (okshells); if (fstat(fileno(fp), &statb) == -1) { (void)fclose(fp); - return(okshells); + return (okshells); } - if ((strings = malloc((unsigned)statb.st_size + 1)) == NULL) { + if ((strings = malloc((u_int)statb.st_size + 1)) == NULL) { (void)fclose(fp); - return(okshells); + return (okshells); } - shells = (char **)calloc((unsigned)statb.st_size / 3, sizeof (char *)); + shells = calloc((unsigned)statb.st_size / 3, sizeof (char *)); if (shells == NULL) { (void)fclose(fp); free(strings); strings = NULL; - return(okshells); + return (okshells); } sp = shells; cp = strings; - while (fgets(cp, strings + statb.st_size - cp, fp) != NULL) { + while (fgets(cp, statb.st_size - (cp - strings), fp) != NULL) { while (*cp != '#' && *cp != '/' && *cp != '\0') cp++; if (*cp == '#' || *cp == '\0') @@ -133,7 +131,7 @@ cp++; *cp++ = '\0'; } - *sp = (char *)0; + *sp = NULL; (void)fclose(fp); return (shells); } diff -ruN glibc-1.08.1/misc/init-misc.c glibc-1.09/misc/init-misc.c --- glibc-1.08.1/misc/init-misc.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/misc/init-misc.c Mon Oct 10 00:35:49 1994 @@ -0,0 +1,43 @@ +/* Define and initialize `__progname'. +Copyright (C) 1994 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include + +char *__progname = (char *) ""; + +void +__init_misc (argc, argv, envp) + int argc; + char **argv; + char **envp; +{ + if (argv && argv[0]) + { + char *p = strrchr (argv[0], '/'); + if (p == NULL) + __progname = argv[0]; + else + __progname = p + 1; + } +} + +#ifdef HAVE_GNU_LD +#include +text_set_element (__libc_subinit, __init_misc); +#endif diff -ruN glibc-1.08.1/misc/paths.h glibc-1.09/misc/paths.h --- glibc-1.08.1/misc/paths.h Wed Sep 16 17:43:55 1992 +++ glibc-1.09/misc/paths.h Sun Jul 31 15:15:35 1994 @@ -1,6 +1,6 @@ /* - * Copyright (c) 1989 The Regents of the University of California. - * All rights reserved. + * 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 @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)paths.h 5.15 (Berkeley) 5/29/91 + * @(#)paths.h 8.1 (Berkeley) 6/2/93 */ #ifndef _PATHS_H_ @@ -38,6 +38,9 @@ /* Default search path. */ #define _PATH_DEFPATH "/usr/bin:/bin" +/* All standard utilities path. */ +#define _PATH_STDPATH \ + "/usr/bin:/bin:/usr/sbin:/sbin:/usr/contrib/bin:/usr/old/bin" #define _PATH_BSHELL "/bin/sh" #define _PATH_CONSOLE "/dev/console" @@ -51,6 +54,7 @@ #define _PATH_MEM "/dev/mem" #define _PATH_NOLOGIN "/etc/nologin" #define _PATH_SENDMAIL "/usr/sbin/sendmail" +#define _PATH_SHELLS "/etc/shells" #define _PATH_TTY "/dev/tty" #define _PATH_UNIX "/vmunix" #define _PATH_VI "/usr/bin/vi" @@ -58,6 +62,7 @@ /* Provide trailing slash, since mostly used for building pathnames. */ #define _PATH_DEV "/dev/" #define _PATH_TMP "/tmp/" +#define _PATH_VARDB "/var/db/" #define _PATH_VARRUN "/var/run/" #define _PATH_VARTMP "/var/tmp/" diff -ruN glibc-1.08.1/misc/sys/cdefs.h glibc-1.09/misc/sys/cdefs.h --- glibc-1.08.1/misc/sys/cdefs.h Sun Nov 14 18:48:21 1993 +++ glibc-1.09/misc/sys/cdefs.h Mon Oct 24 14:16:11 1994 @@ -1,4 +1,4 @@ -/* Copyright (C) 1992, 1993 Free Software Foundation, Inc. +/* Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -21,23 +21,29 @@ #define _SYS_CDEFS_H 1 #include +/* Some user header file might have defined this before. */ +#undef __P + #ifdef __GNUC__ #define __P(args) args /* GCC can always grok prototypes. */ #define __DOTS , ... /* In GCC versions before 2.5, the `volatile' and `const' keywords have - special meanings when applied to functions. In version 2.5, the - `__attribute__' syntax used below does not work properly. */ -#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 6) + special meanings when applied to functions. In versions 2.5 and 2.6, + the `__attribute__' syntax used below does not work properly. */ +#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) #define __NORETURN __volatile #define __CONSTVALUE __const -#else -/* In GCC 2.6 and later, these keywords are meaningless when applied to + #elif __GNUC__ > 2 || __GNUC_MINOR__ >= 7 /* Faith. */ +/* In GCC 2.5 and later, these keywords are meaningless when applied to functions, as ANSI requires. Instead, we use GCC's special `__attribute__' syntax. */ -#define __NORETURN __attribute__ ((noreturn)) -#define __CONSTVALUE __attribute__ ((const)) +#define __NORETURN __attribute__ ((__volatile__)) +#define __CONSTVALUE __attribute__ ((__const__)) +#else +#define __NORETURN +#define __CONSTVALUE #endif #else /* Not GCC. */ diff -ruN glibc-1.08.1/misc/sys/syslog.h glibc-1.09/misc/sys/syslog.h --- glibc-1.08.1/misc/sys/syslog.h Sat Sep 12 17:16:02 1992 +++ glibc-1.09/misc/sys/syslog.h Sun Jul 31 15:10:39 1994 @@ -1,6 +1,6 @@ /* - * Copyright (c) 1982, 1986, 1988 Regents of the University of California. - * All rights reserved. + * Copyright (c) 1982, 1986, 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 @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)syslog.h 7.20 (Berkeley) 2/23/91 + * @(#)syslog.h 8.1 (Berkeley) 6/2/93 */ #define _PATH_LOG "/dev/log" @@ -96,6 +96,7 @@ #define LOG_UUCP (8<<3) /* UUCP subsystem */ #define LOG_CRON (9<<3) /* clock daemon */ #define LOG_AUTHPRIV (10<<3) /* security/authorization messages (private) */ +#define LOG_FTP (11<<3) /* ftp daemon */ /* other codes through 15 reserved for system use */ #define LOG_LOCAL0 (16<<3) /* reserved for local use */ @@ -118,6 +119,7 @@ "authpriv", LOG_AUTHPRIV, "cron", LOG_CRON, "daemon", LOG_DAEMON, + "ftp", LOG_FTP, "kern", LOG_KERN, "lpr", LOG_LPR, "mail", LOG_MAIL, @@ -164,15 +166,31 @@ #ifndef KERNEL -#include +#if 0 +/* + * Don't use va_list in the vsyslog() prototype. Va_list is typedef'd in two + * places ( and ), so if we include one + * of them here we may collide with the utility's includes. It's unreasonable + * for utilities to have to include one of them to include syslog.h, so we get + * _BSD_VA_LIST_ from and use it. + */ +#include +#elif !defined (_BSD_VA_LIST_) +/* In GNU we don't have a and it would be too painful to + emulate one. */ +#define __need_va_list #include +#define _BSD_VA_LIST_ __gnuc_va_list +#endif + +#include __BEGIN_DECLS void closelog __P((void)); void openlog __P((const char *, int, int)); int setlogmask __P((int)); void syslog __P((int, const char *, ...)); -void vsyslog __P((int, const char *, va_list)); +void vsyslog __P((int, const char *, _BSD_VA_LIST_)); __END_DECLS #endif /* !KERNEL */ diff -ruN glibc-1.08.1/misc/syslog.c glibc-1.09/misc/syslog.c --- glibc-1.08.1/misc/syslog.c Sat Sep 12 17:14:23 1992 +++ glibc-1.09/misc/syslog.c Sun Jul 31 15:16:59 1994 @@ -1,6 +1,6 @@ /* - * Copyright (c) 1983, 1988 Regents of the University of California. - * All rights reserved. + * 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 @@ -32,33 +32,36 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)syslog.c 5.34 (Berkeley) 6/26/91"; +static char sccsid[] = "@(#)syslog.c 8.4 (Berkeley) 3/18/94"; #endif /* LIBC_SCCS and not lint */ #include #include -#include #include #include -#include #include + +#include +#include +#include +#include #include +#include +#include + #if __STDC__ #include #else #include #endif -#include -#include -#include -#include static int LogFile = -1; /* fd for log */ static int connected; /* have done connect */ static int LogStat = 0; /* status bits, set by openlog() */ -static const char *LogTag = "syslog"; /* string to tag the entry with */ +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. */ /* * syslog, vsyslog -- @@ -92,62 +95,60 @@ va_list ap; { register int cnt; - register char *p; - time_t now, time(); + register char ch, *p, *t; + time_t now; int fd, saved_errno; - char tbuf[2048], fmt_cpy[1024], *stdp, *ctime(); + char *stdp, tbuf[2048], fmt_cpy[1024]; - /* check for invalid bits or no priority set */ - if (!LOG_PRI(pri) || (pri &~ (LOG_PRIMASK|LOG_FACMASK)) || - !(LOG_MASK(pri) & LogMask)) +#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 */ + /* Set default facility if none specified. */ if ((pri & LOG_FACMASK) == 0) pri |= LogFacility; - /* build the message */ + /* Build the message. */ (void)time(&now); - (void)sprintf(tbuf, "<%d>%.15s ", pri, ctime(&now) + 4); - for (p = tbuf; *p; ++p); + p = tbuf + sprintf(tbuf, "<%d>", pri); + p += strftime(p, sizeof (tbuf) - (p - tbuf), "%h %e %T ", + localtime(&now)); if (LogStat & LOG_PERROR) stdp = p; - if (LogTag) { - (void)strcpy(p, LogTag); - for (; *p; ++p); - } - if (LogStat & LOG_PID) { - (void)sprintf(p, "[%d]", getpid()); - for (; *p; ++p); - } - if (LogTag) { + if (LogTag == NULL) + LogTag = __progname; + if (LogTag != NULL) + p += sprintf(p, "%s", LogTag); + if (LogStat & LOG_PID) + p += sprintf(p, "[%d]", getpid()); + if (LogTag != NULL) { *p++ = ':'; *p++ = ' '; } - /* substitute error message for %m */ - { - register char ch, *t1, *t2; - char *strerror(); - - for (t1 = fmt_cpy; ch = *fmt; ++fmt) - if (ch == '%' && fmt[1] == 'm') { - ++fmt; - for (t2 = strerror(saved_errno); - *t1 = *t2++; ++t1); - } - else - *t1++ = ch; - *t1 = '\0'; - } - - (void)vsprintf(p, fmt_cpy, ap); + /* Substitute error message for %m. */ + for (t = fmt_cpy; ch = *fmt; ++fmt) + if (ch == '%' && fmt[1] == 'm') { + ++fmt; + t += sprintf(t, "%s", strerror(saved_errno)); + } else + *t++ = ch; + *t = '\0'; - cnt = strlen(tbuf); + p += vsprintf(p, fmt_cpy, ap); + cnt = p - tbuf; - /* output to stderr if requested */ + /* Output to stderr if requested. */ if (LogStat & LOG_PERROR) { struct iovec iov[2]; register struct iovec *v = iov; @@ -160,22 +161,19 @@ (void)writev(STDERR_FILENO, iov, 2); } - /* get connected, output the message to the local logger */ + /* Get connected, output the message to the local logger. */ if (!connected) openlog(LogTag, LogStat | LOG_NDELAY, 0); if (send(LogFile, tbuf, cnt, 0) >= 0) return; - /* see if should attempt the console */ - if (!(LogStat&LOG_CONS)) - 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 ((fd = open(_PATH_CONSOLE, O_WRONLY, 0)) >= 0) { + if (LogStat & LOG_CONS && + (fd = open(_PATH_CONSOLE, O_WRONLY, 0)) >= 0) { (void)strcat(tbuf, "\r\n"); cnt += 2; p = index(tbuf, '>') + 1; @@ -224,6 +222,7 @@ } /* setlogmask -- set the log mask level */ +int setlogmask(pmask) int pmask; { diff -ruN glibc-1.08.1/misc/ttyent.h glibc-1.09/misc/ttyent.h --- glibc-1.08.1/misc/ttyent.h Sat Sep 12 16:31:17 1992 +++ glibc-1.09/misc/ttyent.h Sun Jul 31 15:17:36 1994 @@ -1,6 +1,6 @@ /* - * Copyright (c) 1989 The Regents of the University of California. - * All rights reserved. + * 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 @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)ttyent.h 5.7 (Berkeley) 4/3/91 + * @(#)ttyent.h 8.1 (Berkeley) 6/2/93 */ #ifndef _TTYENT_H_ @@ -42,8 +42,6 @@ #define _TTYS_ON "on" #define _TTYS_SECURE "secure" #define _TTYS_WINDOW "window" -#define _TTYS_TRUSTED "trusted" -#define _TTYS_CONSOLE "console" struct ttyent { char *ty_name; /* terminal device name */ @@ -51,8 +49,6 @@ 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_TRUSTED 0x04 /* allow login without password */ -#define TTY_CONSOLE 0x08 /* allow uid of 0 to login without password */ int ty_status; /* status flags */ char *ty_window; /* command to start up window manager */ char *ty_comment; /* comment field */ diff -ruN glibc-1.08.1/misc/ttyslot.c glibc-1.09/misc/ttyslot.c --- glibc-1.08.1/misc/ttyslot.c Sat Sep 12 17:11:29 1992 +++ glibc-1.09/misc/ttyslot.c Sun Jul 31 15:18:28 1994 @@ -1,6 +1,6 @@ /* - * Copyright (c) 1988 The Regents of the University of California. - * All rights reserved. + * 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 @@ -32,7 +32,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)ttyslot.c 5.6 (Berkeley) 2/23/91"; +static char sccsid[] = "@(#)ttyslot.c 8.1 (Berkeley) 6/4/93"; #endif /* LIBC_SCCS and not lint */ #include diff -ruN glibc-1.08.1/posix/Makefile glibc-1.09/posix/Makefile --- glibc-1.08.1/posix/Makefile Tue Mar 8 18:44:50 1994 +++ glibc-1.09/posix/Makefile Mon Jul 25 19:47:57 1994 @@ -47,7 +47,7 @@ aux := init-posix environ tests := tstgetopt testfnm others := getconf -install := getconf +install-bin := getconf install-lib := libposix.a gpl2lgpl := getopt.c getopt1.c getopt.h # Frob these guys' copying notices. @@ -59,7 +59,7 @@ # Make the standalone glob/fnmatch package. glob.tar: glob/ChangeLog glob/COPYING.LIB \ - glob/Makefile.in glob/configure glob/configure.in \ + glob/Makefile.in glob/configure glob/configure.in glob/configure.bat\ glob/fnmatch.h glob/glob.h glob/fnmatch.c glob/glob.c tar cho$(verbose)f $@ $^ glob/%.c: %.c diff -ruN glibc-1.08.1/posix/execl.c glibc-1.09/posix/execl.c --- glibc-1.08.1/posix/execl.c Fri Mar 13 16:36:14 1992 +++ glibc-1.09/posix/execl.c Mon Aug 22 12:34:20 1994 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1992 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1992, 1994 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -28,21 +28,21 @@ /* Execute PATH with all arguments after PATH until a NULL pointer and environment from `environ'. */ int -DEFUN(execl, (path), CONST char *path AND CONST char *arg DOTS) +DEFUN(execl, (path, arg), CONST char *path AND CONST char *arg DOTS) { CONST char *argv[1024]; register unsigned int i; va_list args; - va_start(args, path); argv[0] = arg; + + va_start (args, arg); i = 1; do { - argv[i] = va_arg(args, CONST char *); + argv[i] = va_arg (args, CONST char *); } while (argv[i++] != NULL); + va_end (args); - va_end(args); - - return __execve(path, (char *CONST *) argv, __environ); + return __execve (path, (char *CONST *) argv, __environ); } diff -ruN glibc-1.08.1/posix/fnmatch.c glibc-1.09/posix/fnmatch.c --- glibc-1.08.1/posix/fnmatch.c Tue Oct 12 11:18:06 1993 +++ glibc-1.09/posix/fnmatch.c Sun Oct 9 01:20:13 1994 @@ -16,14 +16,7 @@ Cambridge, MA 02139, USA. */ #ifdef HAVE_CONFIG_H -#if defined (CONFIG_BROKETS) -/* We use instead of "config.h" so that a compilation - using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h - (which it would do because it found this file in $srcdir). */ #include -#else -#include "config.h" -#endif #endif #include diff -ruN glibc-1.08.1/posix/fnmatch.h glibc-1.09/posix/fnmatch.h --- glibc-1.08.1/posix/fnmatch.h Tue Dec 14 15:02:10 1993 +++ glibc-1.09/posix/fnmatch.h Sun Oct 2 18:34:36 1994 @@ -25,10 +25,10 @@ #if defined (__cplusplus) || (defined (__STDC__) && __STDC__) #undef __P -#define __P(args) args +#define __P(protos) protos #else /* Not C++ or ANSI C. */ #undef __P -#define __P(args) () +#define __P(protos) () /* We can get away without defining `const' here only because in this file it is used only inside the prototype for `fnmatch', which is elided in non-ANSI C where `const' is problematical. */ diff -ruN glibc-1.08.1/posix/getopt.c glibc-1.09/posix/getopt.c --- glibc-1.08.1/posix/getopt.c Tue May 10 15:53:58 1994 +++ glibc-1.09/posix/getopt.c Thu Nov 3 20:07:25 1994 @@ -31,17 +31,10 @@ #endif #ifdef HAVE_CONFIG_H -#if defined (emacs) || defined (CONFIG_BROKETS) -/* We use instead of "config.h" so that a compilation - using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h - (which it would do because it found this file in $srcdir). */ #include -#else -#include "config.h" -#endif #endif -#ifndef __STDC__ +#if !defined (__STDC__) || !__STDC__ /* This is a separate conditional since some stdc systems reject `defined (const)'. */ #ifndef const @@ -162,6 +155,9 @@ { REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER } ordering; + +/* Value of POSIXLY_CORRECT environment variable. */ +static char *posixly_correct; #ifdef __GNU_LIBRARY__ /* We want to avoid inclusion of string.h with non-GNU libraries @@ -196,7 +192,7 @@ #ifdef __GNUC__ /* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h. That was relevant to code that was here before. */ -#ifndef __STDC__ +#if !defined (__STDC__) || !__STDC__ /* gcc with -traditional declares the built-in strlen to return int, and has done so at least since version 2.4.5. -- rms. */ extern int strlen (const char *); @@ -293,6 +289,8 @@ nextchar = NULL; + posixly_correct = getenv ("POSIXLY_CORRECT"); + /* Determine how to handle the ordering of options and nonoptions. */ if (optstring[0] == '-') @@ -305,7 +303,7 @@ ordering = REQUIRE_ORDER; ++optstring; } - else if (getenv ("POSIXLY_CORRECT") != NULL) + else if (posixly_correct != NULL) ordering = REQUIRE_ORDER; else ordering = PERMUTE; @@ -609,8 +607,11 @@ { if (opterr) { - /* 1003.2 specifies the format of this message. */ - fprintf (stderr, "%s: illegal option -- %c\n", argv[0], c); + if (posixly_correct) + /* 1003.2 specifies the format of this message. */ + fprintf (stderr, "%s: illegal option -- %c\n", argv[0], c); + else + fprintf (stderr, "%s: invalid option -- %c\n", argv[0], c); } optopt = c; return '?'; diff -ruN glibc-1.08.1/posix/getopt.h glibc-1.09/posix/getopt.h --- glibc-1.08.1/posix/getopt.h Tue May 10 15:53:48 1994 +++ glibc-1.09/posix/getopt.h Thu Nov 3 20:07:16 1994 @@ -1,5 +1,5 @@ /* Declarations for getopt. - Copyright (C) 1989, 1990, 1991, 1992, 1993 Free Software Foundation, Inc. + Copyright (C) 1989, 90, 91, 92, 93, 94 Free Software Foundation, Inc. This file is part of the GNU C Library. Its master source is NOT part of the C library, however. The master source lives in /gd/gnu/lib. @@ -80,7 +80,7 @@ struct option { -#if __STDC__ +#if defined (__STDC__) && __STDC__ const char *name; #else char *name; @@ -98,15 +98,15 @@ #define required_argument 1 #define optional_argument 2 -#if __STDC__ -#if defined(__GNU_LIBRARY__) +#if defined (__STDC__) && __STDC__ +#ifdef __GNU_LIBRARY__ /* Many other libraries have conflicting prototypes for getopt, with differences in the consts, in stdlib.h. To avoid compilation errors, only prototype getopt for the GNU C library. */ extern int getopt (int argc, char *const *argv, const char *shortopts); #else /* not __GNU_LIBRARY__ */ extern int getopt (); -#endif /* not __GNU_LIBRARY__ */ +#endif /* __GNU_LIBRARY__ */ extern int getopt_long (int argc, char *const *argv, const char *shortopts, const struct option *longopts, int *longind); extern int getopt_long_only (int argc, char *const *argv, @@ -124,7 +124,7 @@ extern int getopt_long_only (); extern int _getopt_internal (); -#endif /* not __STDC__ */ +#endif /* __STDC__ */ #ifdef __cplusplus } diff -ruN glibc-1.08.1/posix/getopt1.c glibc-1.09/posix/getopt1.c --- glibc-1.08.1/posix/getopt1.c Tue May 10 15:53:46 1994 +++ glibc-1.09/posix/getopt1.c Thu Nov 3 20:07:13 1994 @@ -1,5 +1,5 @@ /* getopt_long and getopt_long_only entry points for GNU getopt. - Copyright (C) 1987, 88, 89, 90, 91, 92, 1993 + Copyright (C) 1987, 88, 89, 90, 91, 92, 1993, 1994 Free Software Foundation, Inc. This file is part of the GNU C Library. Its master source is NOT part of @@ -21,19 +21,12 @@ Cambridge, MA 02139, USA. */ #ifdef HAVE_CONFIG_H -#if defined (emacs) || defined (CONFIG_BROKETS) -/* We use instead of "config.h" so that a compilation - using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h - (which it would do because it found this file in $srcdir). */ #include -#else -#include "config.h" -#endif #endif #include "getopt.h" -#ifndef __STDC__ +#if !defined (__STDC__) || !__STDC__ /* This is a separate conditional since some stdc systems reject `defined (const)'. */ #ifndef const diff -ruN glibc-1.08.1/posix/glob.c glibc-1.09/posix/glob.c --- glibc-1.08.1/posix/glob.c Thu Aug 12 18:15:21 1993 +++ glibc-1.09/posix/glob.c Tue Sep 6 19:03:42 1994 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as @@ -344,7 +344,7 @@ /* No matches. */ if (flags & GLOB_NOCHECK) { - const size_t len = strlen (pattern) + 1; + size_t len = strlen (pattern) + 1; char *patcopy = (char *) malloc (len); if (patcopy == NULL) return GLOB_NOSPACE; @@ -458,7 +458,7 @@ for (i = 0; i < n; ++i) { - const size_t eltlen = strlen (array[i]) + 1; + size_t eltlen = strlen (array[i]) + 1; char *new = (char *) malloc (dirlen + 1 + eltlen); if (new == NULL) { diff -ruN glibc-1.08.1/posix/glob.h glibc-1.09/posix/glob.h --- glibc-1.08.1/posix/glob.h Sun Oct 11 20:47:05 1992 +++ glibc-1.09/posix/glob.h Sun Oct 2 18:35:50 1994 @@ -27,11 +27,11 @@ #undef __ptr_t #if defined (__cplusplus) || (defined (__STDC__) && __STDC__) #undef __P -#define __P(args) args +#define __P(protos) protos #define __ptr_t void * #else /* Not C++ or ANSI C. */ #undef __P -#define __P(args) () +#define __P(protos) () #undef const #define const #define __ptr_t char * diff -ruN glibc-1.08.1/posix/gnu/types.h glibc-1.09/posix/gnu/types.h --- glibc-1.08.1/posix/gnu/types.h Tue Dec 29 17:20:56 1992 +++ glibc-1.09/posix/gnu/types.h Mon Jul 18 18:01:11 1994 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1992 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1992, 1994 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -26,29 +26,30 @@ typedef unsigned short __u_short; typedef unsigned int __u_int; typedef unsigned long __u_long; +#ifdef __GNUC__ +typedef unsigned long long int __u_quad_t; +typedef long long int __quad_t; +typedef __quad_t *__qaddr_t; +#else typedef struct { long val[2]; -} __quad; +} __quad_t; typedef struct { __u_long val[2]; -} __u_quad; - +} __u_quad_t; +#endif typedef int __dev_t; /* Type of device numbers. */ typedef unsigned int __uid_t; /* Type of user identifications. */ typedef unsigned int __gid_t; /* Type of group identifications. */ -typedef unsigned long int __ino_t; /* Type of file serial numbers. */ +typedef unsigned int __ino_t; /* Type of file serial numbers. */ typedef unsigned int __mode_t; /* Type of file attribute bitmasks. */ -typedef unsigned short int __nlink_t; /* Type of file link counts. */ +typedef unsigned short int __nlink_t; /* Type of file link counts. */ typedef long int __off_t; /* Type of file sizes and offsets. */ typedef int __pid_t; /* Type of process identifications. */ typedef int __ssize_t; /* Type of a byte count, or error. */ -#ifdef __GNUC__ -typedef unsigned long long int __fsid_t; /* Type of file system IDs. */ -#else -typedef __quad __fsid_t; /* Type of file system IDs. */ -#endif +typedef __u_quad_t __fsid_t; /* Type of file system IDs. */ /* Everythin' else. */ typedef long int __daddr_t; /* The type of a disk address. */ diff -ruN glibc-1.08.1/posix/sys/types.h glibc-1.09/posix/sys/types.h --- glibc-1.08.1/posix/sys/types.h Sun Feb 6 17:35:05 1994 +++ glibc-1.09/posix/sys/types.h Mon Jul 18 18:01:12 1994 @@ -34,8 +34,8 @@ #define u_short __u_short #define u_int __u_int #define u_long __u_long -#define quad __quad -#define u_quad __u_quad +#define quad_t __quad_t +#define u_quad_t __u_quad_t #define fsid_t __fsid_t #endif diff -ruN glibc-1.08.1/posix/sys/utsname.h glibc-1.09/posix/sys/utsname.h --- glibc-1.08.1/posix/sys/utsname.h Thu Feb 24 20:00:03 1994 +++ glibc-1.09/posix/sys/utsname.h Wed Sep 28 18:43:25 1994 @@ -50,6 +50,10 @@ char machine[_UTSNAME_LENGTH]; }; +#ifdef __USE_SVID +#define SYS_NMLN _UTSNAME_LENGTH +#endif + /* Put information about the system in NAME. */ extern int uname __P ((struct utsname *__name)); diff -ruN glibc-1.08.1/posix/sys/wait.h glibc-1.09/posix/sys/wait.h --- glibc-1.08.1/posix/sys/wait.h Mon Jan 24 17:26:36 1994 +++ glibc-1.09/posix/sys/wait.h Thu Oct 13 22:06:26 1994 @@ -46,19 +46,27 @@ #define __WAIT_INT(status) (*(int *) &(status)) #endif -/* This is the type of the argument to `wait'. With GCC 2.4 and later, the - funky union causes redeclarations with either `int *' or `union wait *' - to be allowed without complaint. (__GNUC_MINOR__ is in fact only - defined in later versions, after 2.5.0; and versions prior to 2.6 have a - bug that produces bad code on some machines when using the union.) - __WAIT_STATUS_DEFN is the type used in the actual function definitions. */ +/* This is the type of the argument to `wait'. + + NOTE: Since this functionality is volatile, I'm disabling the use of it for + now. + +With GCC 2.6.1 and later, the funky union causes redeclarations with either + `int *' or `union wait *' to be allowed without complaint. + __WAIT_STATUS_DEFN is the type used in the actual function + definitions. */ #if (!defined (__GNUC__) || __GNUC__ < 2 || \ - (__GNUC__ == 2 && __GNUC_MINOR__ < 6)) + /*(__GNUC__ == 2 && __GNUC_MINOR__ < 6)*/ 1) #define __WAIT_STATUS __ptr_t #define __WAIT_STATUS_DEFN __ptr_t #else -#define __WAIT_STATUS union { union wait *__uptr; int *__iptr; } +/* This works in GCC 2.6.1 and later. */ +typedef union + { + union wait *__uptr; + int *__iptr; + } __WAIT_STATUS __attribute__ ((transparent_union)); #define __WAIT_STATUS_DEFN int * #endif diff -ruN glibc-1.08.1/resolv/Makefile glibc-1.09/resolv/Makefile --- glibc-1.08.1/resolv/Makefile Wed Dec 31 19:00:00 1969 +++ glibc-1.09/resolv/Makefile Sun Sep 4 22:05:54 1994 @@ -0,0 +1,31 @@ +# Copyright (C) 1994 Free Software Foundation, Inc. +# This file is part of the GNU C Library. + +# The GNU C Library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Library General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. + +# The GNU C Library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Library General Public License for more details. + +# You should have received a copy of the GNU Library General Public +# License along with the GNU C Library; see the file COPYING.LIB. If +# not, write to the Free Software Foundation, Inc., 675 Mass Ave, +# Cambridge, MA 02139, USA. + +# +# Sub-makefile for resolv portion of the library. +# +subdir := resolv + +headers := resolv.h arpa/nameser.h sys/bitypes.h +distribute := ../conf/portability.h + +routines := gethnamaddr getnetbyaddr getnetbyname getnetent getnetnamadr \ + herror nsap_addr res_comp res_debug res_init res_mkquery \ + res_query res_send sethostent + +include ../Rules diff -ruN glibc-1.08.1/resolv/arpa/nameser.h glibc-1.09/resolv/arpa/nameser.h --- glibc-1.08.1/resolv/arpa/nameser.h Wed Dec 31 19:00:00 1969 +++ glibc-1.09/resolv/arpa/nameser.h Thu Jul 28 18:01:27 1994 @@ -0,0 +1,332 @@ +/* + * ++Copyright++ 1983, 1989, 1993 + * - + * Copyright (c) 1983, 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * - + * 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-- + */ + +/* + * @(#)nameser.h 8.1 (Berkeley) 6/2/93 + * $Id: nameser.h,v 1.4 1994/07/28 22:01:26 roland Exp $ + */ + +#ifndef _NAMESER_H_ +#define _NAMESER_H_ + +#include +#if (!defined(BSD)) || (BSD < 199306) +# include +#else +# include +#endif +#include + +/* + * revision information. this is the release date in YYYYMMDD format. + * it can change every day so the right thing to do with it is use it + * in preprocessor commands such as "#if (__BIND > 19931104)". do not + * compare for equality; rather, use it to determine whether your resolver + * is new enough to contain a certain feature. + */ + +#define __BIND 19940417 /* interface version stamp */ + +/* + * Define constants based on rfc883 + */ +#define PACKETSZ 512 /* maximum packet size */ +#define MAXDNAME 256 /* maximum domain name */ +#define MAXCDNAME 255 /* maximum compressed domain name */ +#define MAXLABEL 63 /* maximum length of domain label */ +#define HFIXEDSZ 12 /* #/bytes of fixed data in header */ +#define QFIXEDSZ 4 /* #/bytes of fixed data in query */ +#define RRFIXEDSZ 10 /* #/bytes of fixed data in r record */ +#define INT32SZ 4 /* for systems without 32-bit ints */ +#define INT16SZ 2 /* for systems without 16-bit ints */ +#define INADDRSZ 4 /* for sizeof(struct inaddr) != 4 */ + +/* + * Internet nameserver port number + */ +#define NAMESERVER_PORT 53 + +/* + * Currently defined opcodes + */ +#define QUERY 0x0 /* standard query */ +#define IQUERY 0x1 /* inverse query */ +#define STATUS 0x2 /* nameserver status query */ +/*#define xxx 0x3 /* 0x3 reserved */ + /* non standard - supports ALLOW_UPDATES stuff from Mike Schwartz */ +#define UPDATEA 0x9 /* add resource record */ +#define UPDATED 0xa /* delete a specific resource record */ +#define UPDATEDA 0xb /* delete all named resource record */ +#define UPDATEM 0xc /* modify a specific resource record */ +#define UPDATEMA 0xd /* modify all named resource record */ + +#define ZONEINIT 0xe /* initial zone transfer */ +#define ZONEREF 0xf /* incremental zone referesh */ + +/* + * Currently defined response codes + */ +#define NOERROR 0 /* no error */ +#define FORMERR 1 /* format error */ +#define SERVFAIL 2 /* server failure */ +#define NXDOMAIN 3 /* non existent domain */ +#define NOTIMP 4 /* not implemented */ +#define REFUSED 5 /* query refused */ + /* non standard */ +#define NOCHANGE 0xf /* update failed to change db */ + +/* + * Type values for resources and queries + */ +#define T_A 1 /* host address */ +#define T_NS 2 /* authoritative server */ +#define T_MD 3 /* mail destination */ +#define T_MF 4 /* mail forwarder */ +#define T_CNAME 5 /* connonical name */ +#define T_SOA 6 /* start of authority zone */ +#define T_MB 7 /* mailbox domain name */ +#define T_MG 8 /* mail group member */ +#define T_MR 9 /* mail rename name */ +#define T_NULL 10 /* null resource record */ +#define T_WKS 11 /* well known service */ +#define T_PTR 12 /* domain name pointer */ +#define T_HINFO 13 /* host information */ +#define T_MINFO 14 /* mailbox information */ +#define T_MX 15 /* mail routing information */ +#define T_TXT 16 /* text strings */ +#define T_RP 17 /* responsible person */ +#define T_AFSDB 18 /* AFS cell database */ +#define T_X25 19 /* X_25 calling address */ +#define T_ISDN 20 /* ISDN calling address */ +#define T_RT 21 /* router */ +#define T_NSAP 22 /* NSAP address */ +#define T_NSAP_PTR 23 /* reverse NSAP lookup (deprecated) */ + /* non standard */ +#define T_UINFO 100 /* user (finger) information */ +#define T_UID 101 /* user ID */ +#define T_GID 102 /* group ID */ +#define T_UNSPEC 103 /* Unspecified format (binary data) */ +#define T_SA 200 /* shuffle address */ + /* Query type values which do not appear in resource records */ +#define T_AXFR 252 /* transfer zone of authority */ +#define T_MAILB 253 /* transfer mailbox records */ +#define T_MAILA 254 /* transfer mail agent records */ +#define T_ANY 255 /* wildcard match */ + +/* + * Values for class field + */ + +#define C_IN 1 /* the arpa internet */ +#define C_CHAOS 3 /* for chaos net (MIT) */ +#define C_HS 4 /* for Hesiod name server (MIT) (XXX) */ + /* Query class values which do not appear in resource records */ +#define C_ANY 255 /* wildcard match */ + +/* + * Status return codes for T_UNSPEC conversion routines + */ +#define CONV_SUCCESS 0 +#define CONV_OVERFLOW (-1) +#define CONV_BADFMT (-2) +#define CONV_BADCKSUM (-3) +#define CONV_BADBUFLEN (-4) + +#ifndef BYTE_ORDER +#if (BSD >= 199103) +# include +#else +#ifdef linux +# include +#else +#define LITTLE_ENDIAN 1234 /* least-significant byte first (vax, pc) */ +#define BIG_ENDIAN 4321 /* most-significant byte first (IBM, net) */ +#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long (pdp)*/ + +#if defined(vax) || defined(ns32000) || defined(sun386) || defined(i386) || \ + defined(MIPSEL) || defined(_MIPSEL) || defined(BIT_ZERO_ON_RIGHT) || \ + defined(__alpha__) || defined(__alpha) +#define BYTE_ORDER LITTLE_ENDIAN +#endif + +#if defined(sel) || defined(pyr) || defined(mc68000) || defined(sparc) || \ + defined(is68k) || defined(tahoe) || defined(ibm032) || defined(ibm370) || \ + defined(MIPSEB) || defined(_MIPSEB) || defined(_IBMR2) || defined(DGUX) ||\ + defined(apollo) || defined(__convex__) || defined(_CRAY) || \ + defined(__hppa) || defined(__hp9000) || \ + defined(__hp9000s300) || defined(__hp9000s700) || \ + defined (BIT_ZERO_ON_LEFT) +#define BYTE_ORDER BIG_ENDIAN +#endif +#endif /* linux */ +#endif /* BSD */ +#endif /* BYTE_ORDER */ + +#if !defined(BYTE_ORDER) || \ + (BYTE_ORDER != BIG_ENDIAN && BYTE_ORDER != LITTLE_ENDIAN && \ + BYTE_ORDER != PDP_ENDIAN) + /* you must determine what the correct bit order is for + * your compiler - the next line is an intentional error + * which will force your compiles to bomb until you fix + * the above macros. + */ + error "Undefined or invalid BYTE_ORDER"; +#endif + +/* + * Structure for query header. The order of the fields is machine- and + * compiler-dependent, depending on the byte/bit order and the layout + * of bit fields. We use bit fields only in int variables, as this + * is all ANSI requires. This requires a somewhat confusing rearrangement. + */ + +typedef struct { + unsigned id :16; /* query identification number */ +#if BYTE_ORDER == BIG_ENDIAN + /* fields in third byte */ + unsigned qr: 1; /* response flag */ + unsigned opcode: 4; /* purpose of message */ + unsigned aa: 1; /* authoritive answer */ + unsigned tc: 1; /* truncated message */ + unsigned rd: 1; /* recursion desired */ + /* fields in fourth byte */ + unsigned ra: 1; /* recursion available */ + unsigned pr: 1; /* primary server req'd (!standard) */ + unsigned unused :2; /* unused bits (MBZ as of 4.9.3a3) */ + unsigned rcode :4; /* response code */ +#endif +#if BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == PDP_ENDIAN + /* fields in third byte */ + unsigned rd :1; /* recursion desired */ + unsigned tc :1; /* truncated message */ + unsigned aa :1; /* authoritive answer */ + unsigned opcode :4; /* purpose of message */ + unsigned qr :1; /* response flag */ + /* fields in fourth byte */ + unsigned rcode :4; /* response code */ + unsigned unused :2; /* unused bits (MBZ as of 4.9.3a3) */ + unsigned pr :1; /* primary server req'd (!standard) */ + unsigned ra :1; /* recursion available */ +#endif + /* remaining bytes */ + unsigned qdcount :16; /* number of question entries */ + unsigned ancount :16; /* number of answer entries */ + unsigned nscount :16; /* number of authority entries */ + unsigned arcount :16; /* number of resource entries */ +} HEADER; + +/* + * Defines for handling compressed domain names + */ +#define INDIR_MASK 0xc0 + +/* + * Structure for passing resource records around. + */ +struct rrec { + int16_t r_zone; /* zone number */ + int16_t r_class; /* class number */ + int16_t r_type; /* type number */ + u_int32_t r_ttl; /* time to live */ + int r_size; /* size of data area */ + char *r_data; /* pointer to data */ +}; + +extern u_int16_t _getshort __P((const u_char *)); +extern u_int32_t _getlong __P((const u_char *)); + +/* + * Inline versions of get/put short/long. Pointer is advanced. + * + * These macros demonstrate the property of C whereby it can be + * portable or it can be elegant but rarely both. + */ +#define GETSHORT(s, cp) { \ + register u_char *t_cp = (u_char *)(cp); \ + (s) = ((u_int16_t)t_cp[0] << 8) \ + | ((u_int16_t)t_cp[1]) \ + ; \ + (cp) += INT16SZ; \ +} + +#define GETLONG(l, cp) { \ + register u_char *t_cp = (u_char *)(cp); \ + (l) = ((u_int32_t)t_cp[0] << 24) \ + | ((u_int32_t)t_cp[1] << 16) \ + | ((u_int32_t)t_cp[2] << 8) \ + | ((u_int32_t)t_cp[3]) \ + ; \ + (cp) += INT32SZ; \ +} + +#define PUTSHORT(s, cp) { \ + register u_int16_t t_s = (u_int16_t)(s); \ + register u_char *t_cp = (u_char *)(cp); \ + *t_cp++ = t_s >> 8; \ + *t_cp = t_s; \ + (cp) += INT16SZ; \ +} + +#define PUTLONG(l, cp) { \ + register u_int32_t t_l = (u_int32_t)(l); \ + register u_char *t_cp = (u_char *)(cp); \ + *t_cp++ = t_l >> 24; \ + *t_cp++ = t_l >> 16; \ + *t_cp++ = t_l >> 8; \ + *t_cp = t_l; \ + (cp) += INT32SZ; \ +} + +#endif /* !_NAMESER_H_ */ diff -ruN glibc-1.08.1/resolv/gethnamaddr.c glibc-1.09/resolv/gethnamaddr.c --- glibc-1.08.1/resolv/gethnamaddr.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/resolv/gethnamaddr.c Thu Jul 28 17:50:35 1994 @@ -0,0 +1,705 @@ +/* + * ++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[] = "$Id: gethnamaddr.c,v 1.3 1994/07/28 21:50:33 roland Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#ifndef LOG_AUTH +# define LOG_AUTH 0 +#endif + +#define MULTI_PTRS_ARE_ALIASES 1 /* XXX - experimental */ + +#if defined(BSD) && (BSD >= 199103) +# include +#else +# include "../conf/portability.h" +#endif +#if defined(USE_OPTIONS_H) +# include <../conf/options.h> +#endif + +#define MAXALIASES 35 +#define MAXADDRS 35 + +static const char AskedForGot[] = + "gethostby*.getanswer: 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 struct in_addr host_addr; +static FILE *hostf = NULL; +static int stayopen = 0; + +#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; + +static struct hostent * +getanswer(answer, anslen, qname, qclass, qtype) + const querybuf *answer; + int anslen; + const char *qname; + int qclass, qtype; +{ + register const HEADER *hp; + register const u_char *cp; + register int n; + const u_char *eom; + char *bp, **ap, **hap; + int type, class, buflen, ancount, qdcount; + int haveanswer, had_error; + int toobig = 0; + char tbuf[MAXDNAME+1]; + + host.h_name = NULL; + eom = answer->buf + anslen; + /* + * find first satisfactory answer + */ + hp = &answer->hdr; + ancount = ntohs(hp->ancount); + qdcount = ntohs(hp->qdcount); + bp = hostbuf; + buflen = sizeof hostbuf; + cp = answer->buf + HFIXEDSZ; + if (qdcount != 1) { + h_errno = NO_RECOVERY; + return (NULL); + } + if ((n = dn_expand(answer->buf, eom, cp, bp, buflen)) < 0) { + h_errno = NO_RECOVERY; + return (NULL); + } + cp += n + QFIXEDSZ; + if (qtype == T_A) { + /* 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 */ + 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; +#if BSD >= 43 || defined(h_addr) /* new-style hostent structure */ + host.h_addr_list = h_addr_ptrs; +#endif + haveanswer = 0; + had_error = 0; + while (ancount-- > 0 && cp < eom && !had_error) { + n = dn_expand(answer->buf, eom, cp, bp, buflen); + if (n < 0) { + had_error++; + continue; + } + cp += n; /* name */ + type = _getshort(cp); + cp += INT16SZ; /* type */ + class = _getshort(cp); + cp += INT16SZ + INT32SZ; /* class, TTL */ + n = _getshort(cp); + cp += INT16SZ; /* len */ + if (class != qclass) { + /* XXX - debug? syslog? */ + cp += n; + continue; /* XXX - had_error++ ? */ + } + if (qtype == T_A && type == T_CNAME) { + if (ap >= &host_aliases[MAXALIASES-1]) + continue; + n = dn_expand(answer->buf, eom, cp, tbuf, sizeof tbuf); + if (n < 0) { + had_error++; + continue; + } + cp += n; + if (host.h_name && strcasecmp(host.h_name, bp) != 0) { + syslog(LOG_NOTICE|LOG_AUTH, + "gethostby*.getanswer: asked for \"%s\", got CNAME for \"%s\"", + host.h_name, bp); + continue; /* XXX - had_error++ ? */ + } + /* Store alias. */ + *ap++ = bp; + n = strlen(bp) + 1; /* for the \0 */ + bp += n; + buflen -= n; + /* Get canonical name. */ + n = strlen(tbuf) + 1; /* for the \0 */ + if (n > buflen) { + had_error++; + continue; + } + strcpy(bp, tbuf); + host.h_name = bp; + bp += n; + buflen -= n; + continue; + } + if (type != qtype) { + syslog(LOG_NOTICE|LOG_AUTH, + "gethostby*.getanswer: asked for type %d(%s), got %d(%s)", + qtype, qname, type, bp); + cp += n; + continue; /* XXX - had_error++ ? */ + } + switch (type) { + case T_PTR: + if (strcasecmp(qname, 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) { + had_error++; + break; + } +#if MULTI_PTRS_ARE_ALIASES + cp += n; + 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 */ + bp += n; + buflen -= n; + } + break; +#else + host.h_name = bp; + return (&host); +#endif + case T_A: + if (strcasecmp(host.h_name, bp) != 0) { + syslog(LOG_NOTICE|LOG_AUTH, + AskedForGot, host.h_name, bp); + cp += n; + continue; /* XXX - had_error++ ? */ + } + if (haveanswer) { + if (n != host.h_length) { + cp += n; + continue; + } + } else { + register int nn; + + host.h_length = n; + host.h_addrtype = (class == C_IN) + ? AF_INET + : AF_UNSPEC; + 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]) { +#ifdef DEBUG + if (_res.options & RES_DEBUG) + printf("size (%d) too big\n", n); +#endif + had_error++; + continue; + } + if (hap >= &h_addr_ptrs[MAXADDRS-1]) { + if (_res.options & RES_DEBUG && !toobig++) + printf("Too many addresses (%d)\n", + MAXADDRS); + cp += n; + continue; + } + bcopy(cp, *hap++ = bp, n); + bp += n; + cp += n; + break; + default: + abort(); + } /*switch*/ + if (!had_error) + haveanswer++; + } /*while*/ + 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 && + qclass == C_IN && qtype == T_A) + addrsort(h_addr_ptrs, haveanswer); +# endif /*RESOLVSORT*/ +#if BSD >= 43 || defined(h_addr) /* new-style hostent structure */ + /* nothing */ +#else + host.h_addr = h_addr_ptrs[0]; +#endif /*BSD*/ + if (!host.h_name) { + n = strlen(qname) + 1; /* for the \0 */ + strcpy(bp, qname); + host.h_name = bp; + } + return (&host); + } else { + h_errno = TRY_AGAIN; + return (NULL); + } +} + +struct hostent * +gethostbyname(name) + const char *name; +{ + querybuf buf; + register const char *cp; + int n; + extern struct hostent *_gethtbyname(); + + /* + * disallow names consisting only of digits/dots, unless + * they end in a dot. + */ + if (isdigit(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_aton(name, &host_addr)) { + h_errno = HOST_NOT_FOUND; + return (NULL); + } + host.h_name = (char *)name; + host.h_aliases = host_aliases; + host_aliases[0] = NULL; + host.h_addrtype = AF_INET; + host.h_length = INT32SZ; + h_addr_ptrs[0] = (char *)&host_addr; + h_addr_ptrs[1] = NULL; +#if BSD >= 43 || defined(h_addr) /* new-style hostent structure */ + host.h_addr_list = h_addr_ptrs; +#else + host.h_addr = h_addr_ptrs[0]; +#endif + return (&host); + } + if (!isdigit(*cp) && *cp != '.') + break; + } + + if ((n = res_search(name, C_IN, T_A, buf.buf, sizeof(buf))) < 0) { +#ifdef DEBUG + if (_res.options & RES_DEBUG) + printf("res_search failed\n"); +#endif + if (errno == ECONNREFUSED) + return (_gethtbyname(name)); + else + return (NULL); + } + return (getanswer(&buf, n, name, C_IN, T_A)); +} + +struct hostent * +gethostbyaddr(addr, len, type) + const char *addr; + int len, type; +{ + int n; + querybuf buf; + register struct hostent *hp; + char qbuf[MAXDNAME+1]; +#ifdef SUNSECURITY + register struct hostent *rhp; + char **haddr; + u_long old_options; +#endif /*SUNSECURITY*/ + extern struct hostent *_gethtbyaddr(); + + if (type != AF_INET) + return (NULL); + (void)sprintf(qbuf, "%u.%u.%u.%u.in-addr.arpa", + ((unsigned)addr[3] & 0xff), + ((unsigned)addr[2] & 0xff), + ((unsigned)addr[1] & 0xff), + ((unsigned)addr[0] & 0xff)); + n = res_query(qbuf, C_IN, T_PTR, (u_char *)buf.buf, sizeof buf.buf); + if (n < 0) { +#ifdef DEBUG + if (_res.options & RES_DEBUG) + printf("res_query failed\n"); +#endif + if (errno == ECONNREFUSED) + return (_gethtbyaddr(addr, len, type)); + return (NULL); + } + if (!(hp = getanswer(&buf, n, qbuf, C_IN, T_PTR))) + return (NULL); +#ifdef SUNSECURITY + /* + * turn off search as the name should be absolute, + * 'localhost' should be matched by defnames + */ + old_options = _res.options; + _res.options &= ~RES_DNSRCH; + _res.options |= RES_DEFNAMES; + if (!(rhp = gethostbyname(hp->h_name))) { + syslog(LOG_NOTICE|LOG_AUTH, + "gethostbyaddr: No A record for %s (verifying [%s])", + hp->h_name, inet_ntoa(*((struct in_addr *)addr))); + _res.options = old_options; + 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]", + hp->h_name, inet_ntoa(*((struct in_addr *)addr))); + h_errno = HOST_NOT_FOUND; + return (NULL); + } +#endif /*SUNSECURITY*/ + hp->h_addrtype = type; + hp->h_length = len; + h_addr_ptrs[0] = (char *)&host_addr; + h_addr_ptrs[1] = NULL; + host_addr = *(struct in_addr *)addr; +#if BSD < 43 && !defined(h_addr) /* new-style hostent structure */ + hp->h_addr = h_addr_ptrs[0]; +#endif + return (hp); +} + +void +_sethtent(f) + int f; +{ + if (!hostf) + hostf = fopen(_PATH_HOSTS, "r" ); + else + rewind(hostf); + stayopen = f; +} + +void +_endhtent() +{ + if (hostf && !stayopen) { + (void) fclose(hostf); + hostf = NULL; + } +} + +struct hostent * +_gethtent() +{ + char *p; + register char *cp, **q; + + if (!hostf && !(hostf = fopen(_PATH_HOSTS, "r" ))) + return (NULL); +again: + if (!(p = fgets(hostbuf, sizeof hostbuf, hostf))) + return (NULL); + if (*p == '#') + goto again; + if (!(cp = strpbrk(p, "#\n"))) + goto again; + *cp = '\0'; + if (!(cp = strpbrk(p, " \t"))) + goto again; + *cp++ = '\0'; + /* THIS STUFF IS INTERNET SPECIFIC */ + if (!inet_aton(p, &host_addr)) + goto again; + h_addr_ptrs[0] = (char *)&host_addr; + h_addr_ptrs[1] = NULL; +#if BSD >= 43 || defined(h_addr) /* new-style hostent structure */ + host.h_addr_list = h_addr_ptrs; +#else + host.h_addr = h_addr_ptrs[0]; +#endif + host.h_length = INT32SZ; + host.h_addrtype = AF_INET; + while (*cp == ' ' || *cp == '\t') + cp++; + host.h_name = cp; + q = host.h_aliases = host_aliases; + if (cp = strpbrk(cp, " \t")) + *cp++ = '\0'; + while (cp && *cp) { + if (*cp == ' ' || *cp == '\t') { + cp++; + continue; + } + if (q < &host_aliases[MAXALIASES - 1]) + *q++ = cp; + if (cp = strpbrk(cp, " \t")) + *cp++ = '\0'; + } + *q = NULL; + return (&host); +} + +struct hostent * +_gethtbyname(name) + char *name; +{ + register struct hostent *p; + register char **cp; + + _sethtent(0); + while (p = _gethtent()) { + if (strcasecmp(p->h_name, name) == 0) + break; + for (cp = p->h_aliases; *cp != 0; cp++) + if (strcasecmp(*cp, name) == 0) + goto found; + } +found: + _endhtent(); + return (p); +} + +struct hostent * +_gethtbyaddr(addr, len, type) + const char *addr; + int len, type; +{ + register struct hostent *p; + + _sethtent(0); + while (p = _gethtent()) + if (p->h_addrtype == type && !bcmp(p->h_addr, addr, len)) + break; + _endhtent(); + return (p); +} + +#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 ; 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 + +#if defined(BSD43_BSD43_NFS) || defined(sun) +/* some libc's out there are bound internally to these names (UMIPS) */ +void +ht_sethostent(stayopen) + int stayopen; +{ + _sethtent(stayopen); +} + +void +ht_endhostent() +{ + _endhtent(); +} + +struct hostent * +ht_gethostbyname(name) + char *name; +{ + return (_gethtbyname(name)); +} + +struct hostent * +ht_gethostbyaddr(addr, len, type) + const char *addr; + int len, type; +{ + return (_gethtbyaddr(addr, len, type)); +} + +struct hostent * +gethostent() +{ + return (_gethtent()); +} + +void +dns_service() +{ + return; +} + +#undef dn_skipname +dn_skipname(comp_dn, eom) + const u_char *comp_dn, *eom; +{ + return (__dn_skipname(comp_dn, eom)); +} +#endif /*old-style libc with yp junk in it*/ + +#ifdef ultrix +/* more icky libc packaging in ultrix */ +int +local_hostname_length(hostname) + const char *hostname; +{ + int len_host, len_domain; + + if (!*_res.defdname) + res_init(); + len_host = strlen(hostname); + len_domain = strlen(_res.defdname); + if (len_host > len_domain && + !strcasecmp(hostname + len_host - len_domain, _res.defdname) && + hostname[len_host - len_domain - 1] == '.') + return (len_host - len_domain - 1); + return (0); +} +#endif diff -ruN glibc-1.08.1/resolv/getnetbyaddr.c glibc-1.09/resolv/getnetbyaddr.c --- glibc-1.08.1/resolv/getnetbyaddr.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/resolv/getnetbyaddr.c Thu Jul 28 17:50:36 1994 @@ -0,0 +1,57 @@ +/* + * Copyright (c) 1983 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)getnetbyaddr.c 1.1 (Coimbra) 93/06/02"; +static char rcsid[] = "$Id: getnetbyaddr.c,v 1.3 1994/07/28 21:50:35 roland Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include + +extern int _net_stayopen; + +struct netent * +_getnetbyaddr(net, type) + register 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 -ruN glibc-1.08.1/resolv/getnetbyname.c glibc-1.09/resolv/getnetbyname.c --- glibc-1.08.1/resolv/getnetbyname.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/resolv/getnetbyname.c Thu Jul 28 17:50:38 1994 @@ -0,0 +1,68 @@ +/* + * Copyright (c) 1983 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)getnetbyname.c 1.1 (Coimbra) 93/06/02"; +static char rcsid[] = "$Id: getnetbyname.c,v 1.2 1994/07/28 21:50:37 roland Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include + +extern int _net_stayopen; + +struct netent * +_getnetbyname(name) +#if (defined(sun) || defined(DGUX)) + register char *name; +#else + register const char *name; +#endif +{ + 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); +} diff -ruN glibc-1.08.1/resolv/getnetent.c glibc-1.09/resolv/getnetent.c --- glibc-1.08.1/resolv/getnetent.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/resolv/getnetent.c Thu Jul 28 17:50:39 1994 @@ -0,0 +1,155 @@ +/* + * Copyright (c) 1983 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* 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 rcsid[] = "$Id: getnetent.c,v 1.2 1994/07/28 21:50:39 roland Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#ifndef _PATH_NETWORKS +#define _PATH_NETWORKS "/etc/networks" +#endif + +#define MAXALIASES 35 + +static FILE *netf; +static char line[BUFSIZ+1]; +static struct netent net; +static char *net_aliases[MAXALIASES]; +int _net_stayopen; + +void _setnetent __P((int)), _endnetent __P((void)); + +void +setnetent(stayopen) +int stayopen; +{ + sethostent(stayopen); + _setnetent(stayopen); +} + +void +endnetent() +{ + endhostent(); + _endnetent(); +} + +void +_setnetent(f) +int f; +{ + if (netf == NULL) + netf = fopen(_PATH_NETWORKS, "r" ); + else + rewind(netf); + _net_stayopen |= f; +} + +void +_endnetent() +{ + 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, BUFSIZ, 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); +} diff -ruN glibc-1.08.1/resolv/getnetnamadr.c glibc-1.09/resolv/getnetnamadr.c --- glibc-1.08.1/resolv/getnetnamadr.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/resolv/getnetnamadr.c Mon Sep 5 13:24:24 1994 @@ -0,0 +1,295 @@ +/* Copyright (c) 1993 Carlos Leandro and Rui Salgueiro + * Dep. Matematica Universidade de Coimbra, Portugal, Europe + */ +/* + * Copyright (c) 1983 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)getnetnamadr.c 1.4 (Coimbra) 93/06/03"; +static char rcsid[] = "$Id: getnetnamadr.c,v 1.2 1994/09/05 17:24:23 roland Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +extern int h_errno; + +#if defined(mips) && defined(SYSTYPE_BSD43) +extern int errno; +#endif + +struct netent *_getnetbyaddr __P((long net, int type)); +struct netent *_getnetbyname __P((const char *name)); + +#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, + getclass = C_ANY, + net_length = 0; + char aux1[30], aux2[30], ans[30], + *in, *st, *pauxt, *bp, **ap, + *paux1 = &aux1[0], + *paux2 = &aux2[0], + flag = 0; +static struct netent net_entry; +static char *net_aliases[MAXALIASES], + netbuf[BUFSIZ+1]; + + /* + * 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 ((struct netent *) 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) + break; + cp += n; + ans[0] = '\0'; + (void)strcpy(&ans[0], bp); + 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) { + 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); + } + net_entry.n_aliases++; + return (&net_entry); + } else { + h_errno = TRY_AGAIN; + return ((struct netent *) NULL); + } +} + +struct netent * +getnetbyaddr(net, net_type) + register 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 (_getnetbyaddr(net, net_type)); + + for (nn = 4, net2 = net; net2; net2 >>= 8) { + netbr[--nn] = net2 & 0xff; + } + switch (nn) { + case 3: /* Class A */ + (void)sprintf(qbuf, "0.0.0.%u.in-addr.arpa", + netbr[3]); + break; + case 2: /* Class B */ + (void)sprintf(qbuf, "0.0.%u.%u.in-addr.arpa", + netbr[3], netbr[2]); + break; + case 1: /* Class C */ + (void)sprintf(qbuf, "0.%u.%u.%u.in-addr.arpa", + netbr[3], netbr[2], netbr[1]); + break; + case 0: /* Class D - E */ + (void)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, buf.buf, sizeof buf.buf); + if (anslen < 0) { +#ifdef DEBUG + if (_res.options & RES_DEBUG) + printf("res_query failed\n"); +#endif + if (errno == ECONNREFUSED) + return (_getnetbyaddr(net, net_type)); + return (_getnetbyaddr(net, net_type)); + } + 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); + } else { + return (_getnetbyaddr(net, net_type)); + } +} + +struct netent * +getnetbyname(net) + register const char *net; +{ + unsigned int netbr[4]; + int anslen; + querybuf buf; + char qbuf[MAXDNAME]; + struct netent *net_entry; + + (void)strcpy(&qbuf[0],net); + anslen = res_search(qbuf, C_IN, T_PTR, buf.buf, sizeof buf.buf); + if (anslen < 0) { +#ifdef DEBUG + if (_res.options & RES_DEBUG) + printf("res_query failed\n"); +#endif + if (errno == ECONNREFUSED) + return (_getnetbyname(net)); + return (_getnetbyname(net)); + } + net_entry = getnetanswer(&buf, anslen, BYNAME); + if (net_entry) + return (net_entry); + else + return (_getnetbyname(net)); +} diff -ruN glibc-1.08.1/resolv/herror.c glibc-1.09/resolv/herror.c --- glibc-1.08.1/resolv/herror.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/resolv/herror.c Thu Jul 28 17:52:59 1994 @@ -0,0 +1,115 @@ +/* + * ++Copyright++ 1987, 1993 + * - + * 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) 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[] = "@(#)herror.c 8.1 (Berkeley) 6/4/93"; +static char rcsid[] = "$Id: herror.c,v 1.3 1994/07/28 21:52:58 roland Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include +#include +#if defined(BSD) && (BSD >= 199103) +# include +# include +#else +# include "../conf/portability.h" +#endif + +char *h_errlist[] = { + "Error 0", + "Unknown host", /* 1 HOST_NOT_FOUND */ + "Host name lookup failure", /* 2 TRY_AGAIN */ + "Unknown server error", /* 3 NO_RECOVERY */ + "No address associated with name", /* 4 NO_ADDRESS */ +}; +int h_nerr = { sizeof(h_errlist)/sizeof(h_errlist[0]) }; + +extern 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 = (u_int)h_errno < h_nerr ? + h_errlist[h_errno] : "Unknown error"; + v->iov_len = strlen(v->iov_base); + v++; + v->iov_base = "\n"; + v->iov_len = 1; + writev(STDERR_FILENO, iov, (v - iov) + 1); +} + +char * +hstrerror(err) + int err; +{ + return (u_int)err < h_nerr ? h_errlist[err] : "Unknown resolver error"; +} diff -ruN glibc-1.08.1/resolv/nsap_addr.c glibc-1.09/resolv/nsap_addr.c --- glibc-1.08.1/resolv/nsap_addr.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/resolv/nsap_addr.c Thu Jul 28 17:56:20 1994 @@ -0,0 +1,97 @@ +#if defined(LIBC_SCCS) && !defined(lint) +static char rcsid[] = "$Id: nsap_addr.c,v 1.1 1994/07/28 21:53:01 roland Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include +#include +#include +#include +#include + +#include "../conf/portability.h" + +#if !defined(isxdigit) /* XXX - could be a function */ +static int +isxdigit(c) + register int c; +{ + return ((c >= '0') && (c <= '9')) || ((c >= 'A') && (c <= 'F')); +} +#endif + +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; +{ + register u_char c, nib; + u_char *start = binary; + u_int len = 0; + + while ((c = *ascii++) != '\0' && len < maxlen) { + if (c == '.' || c == '+' || c == '/') + continue; + if (!isascii(c)) + return (0); + if (islower(c)) + c = toupper(c); + if (isxdigit(c)) { + nib = xtob(c); + if (c = *ascii++) { + 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); +} diff -ruN glibc-1.08.1/resolv/res_comp.c glibc-1.09/resolv/res_comp.c --- glibc-1.08.1/resolv/res_comp.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/resolv/res_comp.c Thu Jul 28 17:56:21 1994 @@ -0,0 +1,420 @@ +/* + * ++Copyright++ 1985, 1993 + * - + * 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. + * - + * --Copyright-- + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)res_comp.c 8.1 (Berkeley) 6/4/93"; +static char rcsid[] = "$Id: res_comp.c,v 1.2 1994/07/28 21:56:20 roland Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include +#include + +#include +#include +#include + +#if defined(BSD) && (BSD >= 199103) +# include +# include +#else +# include "../conf/portability.h" +#endif + +static int dn_find __P((u_char *exp_dn, u_char *msg, + u_char **dnptrs, u_char **lastdnptr)); + +/* + * 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(msg, eomorig, comp_dn, exp_dn, length) + const u_char *msg, *eomorig, *comp_dn; + char *exp_dn; + int length; +{ + register const u_char *cp; + register char *dn; + register int n, c; + char *eom; + int len = -1, checked = 0; + + dn = exp_dn; + cp = comp_dn; + eom = exp_dn + length; + /* + * fetch next label in domain name + */ + while (n = *cp++) { + /* + * Check for indirection + */ + switch (n & INDIR_MASK) { + case 0: + if (dn != exp_dn) { + if (dn >= eom) + return (-1); + *dn++ = '.'; + } + if (dn+n >= eom) + return (-1); + checked += n + 1; + while (--n >= 0) { + if ((c = *cp++) == '.') { + if (dn + n + 2 >= eom) + return (-1); + *dn++ = '\\'; + } + *dn++ = c; + if (cp >= eomorig) /* out of range */ + return(-1); + } + break; + + case INDIR_MASK: + if (len < 0) + len = cp - comp_dn + 1; + cp = msg + (((n & 0x3f) << 8) | (*cp & 0xff)); + if (cp < msg || cp >= eomorig) /* out of range */ + return(-1); + checked += 2; + /* + * Check for loops in the compressed name; + * if we've looked at the whole message, + * there must be a loop. + */ + if (checked >= eomorig - msg) + return (-1); + break; + + default: + return (-1); /* flag error */ + } + } + *dn = '\0'; + for (dn = exp_dn; (c = *dn) != '\0'; dn++) + if (isascii(c) && isspace(c)) + return (-1); + if (len < 0) + len = cp - comp_dn; + return (len); +} + +/* + * Compress domain name 'exp_dn' into 'comp_dn'. + * Return the size of the compressed name or -1. + * 'length' is the size of the array pointed to by 'comp_dn'. + * 'dnptrs' is a list of pointers to previous compressed names. dnptrs[0] + * is a pointer to the beginning of the message. The list ends with NULL. + * 'lastdnptr' is a pointer to the end of the arrary pointed to + * by 'dnptrs'. Side effect is to update the list of pointers for + * labels inserted into the message as we compress the name. + * If 'dnptr' is NULL, we don't try to compress names. If 'lastdnptr' + * is NULL, we don't update the list. + */ +int +dn_comp(exp_dn, comp_dn, length, dnptrs, lastdnptr) + const char *exp_dn; + u_char *comp_dn, **dnptrs, **lastdnptr; + int length; +{ + register u_char *cp, *dn; + register int c, l; + u_char **cpp, **lpp, *sp, *eob; + u_char *msg; + + dn = (u_char *)exp_dn; + cp = comp_dn; + eob = cp + length; + lpp = cpp = NULL; + if (dnptrs != NULL) { + if ((msg = *dnptrs++) != NULL) { + for (cpp = dnptrs; *cpp != NULL; cpp++) + ; + lpp = cpp; /* end of list to search */ + } + } else + msg = NULL; + for (c = *dn++; c != '\0'; ) { + /* look to see if we can use pointers */ + if (msg != NULL) { + if ((l = dn_find(dn-1, msg, dnptrs, lpp)) >= 0) { + if (cp+1 >= eob) + return (-1); + *cp++ = (l >> 8) | INDIR_MASK; + *cp++ = l % 256; + return (cp - comp_dn); + } + /* not found, save it */ + if (lastdnptr != NULL && cpp < lastdnptr-1) { + *cpp++ = cp; + *cpp = NULL; + } + } + sp = cp++; /* save ptr to length byte */ + do { + if (c == '.') { + c = *dn++; + break; + } + if (c == '\\') { + if ((c = *dn++) == '\0') + break; + } + if (cp >= eob) { + if (msg != NULL) + *lpp = NULL; + return (-1); + } + *cp++ = c; + } while ((c = *dn++) != '\0'); + /* catch trailing '.'s but not '..' */ + if ((l = cp - sp - 1) == 0 && c == '\0') { + cp--; + break; + } + if (l <= 0 || l > MAXLABEL) { + if (msg != NULL) + *lpp = NULL; + return (-1); + } + *sp = l; + } + if (cp >= eob) { + if (msg != NULL) + *lpp = NULL; + return (-1); + } + *cp++ = '\0'; + return (cp - comp_dn); +} + +/* + * Skip over a compressed domain name. Return the size or -1. + */ +int +__dn_skipname(comp_dn, eom) + const u_char *comp_dn, *eom; +{ + register const u_char *cp; + register int n; + + cp = comp_dn; + while (cp < eom && (n = *cp++)) { + /* + * check for indirection + */ + switch (n & INDIR_MASK) { + case 0: /* normal case, n == len */ + cp += n; + continue; + case INDIR_MASK: /* indirection */ + cp++; + break; + default: /* illegal type */ + return -1; + } + break; + } + if (cp > eom) + return -1; + return (cp - comp_dn); +} + +static int +mklower(ch) + register int ch; +{ + if (isascii(ch) && isupper(ch)) + return (tolower(ch)); + return (ch); +} + +/* + * Search for expanded name from a list of previously compressed names. + * Return the offset from msg if found or -1. + * dnptrs is the pointer to the first name on the list, + * not the pointer to the start of the message. + */ +static int +dn_find(exp_dn, msg, dnptrs, lastdnptr) + u_char *exp_dn, *msg; + u_char **dnptrs, **lastdnptr; +{ + register u_char *dn, *cp, **cpp; + register int n; + u_char *sp; + + for (cpp = dnptrs; cpp < lastdnptr; cpp++) { + dn = exp_dn; + sp = cp = *cpp; + while (n = *cp++) { + /* + * check for indirection + */ + switch (n & INDIR_MASK) { + case 0: /* normal case, n == len */ + while (--n >= 0) { + if (*dn == '.') + goto next; + if (*dn == '\\') + dn++; + if (mklower(*dn++) != mklower(*cp++)) + goto next; + } + if ((n = *dn++) == '\0' && *cp == '\0') + return (sp - msg); + if (n == '.') + continue; + goto next; + + default: /* illegal type */ + return (-1); + + case INDIR_MASK: /* indirection */ + cp = msg + (((n & 0x3f) << 8) | *cp); + } + } + if (*dn == '\0') + return (sp - msg); + next: ; + } + return (-1); +} + +/* + * Routines to insert/extract short/long's. Must account for byte + * order and non-alignment problems. This code at least has the + * advantage of being portable. + * + * used by sendmail. + */ + +u_int16_t +_getshort(msgp) + register const u_char *msgp; +{ + register u_int16_t u; + + GETSHORT(u, msgp); + return (u); +} + +u_int32_t +_getlong(msgp) + register const u_char *msgp; +{ + register u_int32_t u; + + GETLONG(u, msgp); + return (u); +} + +void +#if defined(__STDC__) || defined(__cplusplus) +__putshort(register u_int16_t s, register u_char *msgp) /* must match proto */ +#else +__putshort(s, msgp) + register u_int16_t s; + register u_char *msgp; +#endif +{ + PUTSHORT(s, msgp); +} + +void +__putlong(l, msgp) + register u_int32_t l; + register u_char *msgp; +{ + PUTLONG(l, msgp); +} + +#ifdef ultrix +/* ultrix 4.0 had some icky packaging in its libc.a. alias for it here. + * there is more gunk of this kind over in res_debug.c. + */ +#undef putshort +void +#if defined(__STDC__) || defined(__cplusplus) +putshort(register u_short s, register u_char *msgp) +#else +putshort(s, msgp) + register u_short s; + register u_char *msgp; +#endif +{ + __putshort(s, msgp); +} +#undef putlong +void +putlong(l, msgp) + register u_int32_t l; + register u_char *msgp; +{ + __putlong(l, msgp); +} + +#undef dn_skipname +dn_skipname(comp_dn, eom) + const u_char *comp_dn, *eom; +{ + return __dn_skipname(comp_dn, eom); +} +#endif /* Ultrix 4.0 hackery */ diff -ruN glibc-1.08.1/resolv/res_debug.c glibc-1.09/resolv/res_debug.c --- glibc-1.08.1/resolv/res_debug.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/resolv/res_debug.c Thu Jul 28 17:56:23 1994 @@ -0,0 +1,778 @@ +/* + * ++Copyright++ 1985, 1990, 1993 + * - + * Copyright (c) 1985, 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * - + * Portions Copyright (c) 1993 by Digital Equipment Corporation. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies, and that + * the name of Digital Equipment Corporation not be used in advertising or + * publicity pertaining to distribution of the document or software without + * specific, written prior permission. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL + * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT + * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS + * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * - + * --Copyright-- + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)res_debug.c 8.1 (Berkeley) 6/4/93"; +static char rcsid[] = "$Id: res_debug.c,v 1.2 1994/07/28 21:56:22 roland Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include +#include +#include + +#include +#include +#if defined(BSD) && (BSD >= 199103) +# include +#else +# include "../conf/portability.h" +#endif + +#if defined(USE_OPTIONS_H) +# include "../conf/options.h" +#endif + +const char *_res_opcodes[] = { + "QUERY", + "IQUERY", + "CQUERYM", + "CQUERYU", + "4", + "5", + "6", + "7", + "8", + "UPDATEA", + "UPDATED", + "UPDATEDA", + "UPDATEM", + "UPDATEMA", + "ZONEINIT", + "ZONEREF", +}; + +const char *_res_resultcodes[] = { + "NOERROR", + "FORMERR", + "SERVFAIL", + "NXDOMAIN", + "NOTIMP", + "REFUSED", + "6", + "7", + "8", + "9", + "10", + "11", + "12", + "13", + "14", + "NOCHANGE", +}; + +static char retbuf[16]; + +static const char * +dewks(wks) + int wks; +{ + switch (wks) { + case 5: return "rje"; + case 7: return "echo"; + case 9: return "discard"; + case 11: return "systat"; + case 13: return "daytime"; + case 15: return "netstat"; + case 17: return "qotd"; + case 19: return "chargen"; + case 20: return "ftp-data"; + case 21: return "ftp"; + case 23: return "telnet"; + case 25: return "smtp"; + case 37: return "time"; + case 39: return "rlp"; + case 42: return "name"; + case 43: return "whois"; + case 53: return "domain"; + case 57: return "apts"; + case 59: return "apfs"; + case 67: return "bootps"; + case 68: return "bootpc"; + case 69: return "tftp"; + case 77: return "rje"; + case 79: return "finger"; + case 87: return "link"; + case 95: return "supdup"; + case 100: return "newacct"; + case 101: return "hostnames"; + case 102: return "iso-tsap"; + case 103: return "x400"; + case 104: return "x400-snd"; + case 105: return "csnet-ns"; + case 109: return "pop-2"; + case 111: return "sunrpc"; + case 113: return "auth"; + case 115: return "sftp"; + case 117: return "uucp-path"; + case 119: return "nntp"; + case 121: return "erpc"; + case 123: return "ntp"; + case 133: return "statsrv"; + case 136: return "profile"; + case 144: return "NeWS"; + case 161: return "snmp"; + case 162: return "snmp-trap"; + case 170: return "print-srv"; + default: (void) sprintf(retbuf, "%d", wks); return (retbuf); + } +} + +static const char * +deproto(protonum) + int protonum; +{ + switch (protonum) { + case 1: return "icmp"; + case 2: return "igmp"; + case 3: return "ggp"; + case 5: return "st"; + case 6: return "tcp"; + case 7: return "ucl"; + case 8: return "egp"; + case 9: return "igp"; + case 11: return "nvp-II"; + case 12: return "pup"; + case 16: return "chaos"; + case 17: return "udp"; + default: (void) sprintf(retbuf, "%d", protonum); return (retbuf); + } +} + +static const u_char * +do_rrset(msg, cp, cnt, pflag, file, hs) + int cnt, pflag; + const u_char *cp, *msg; + const char *hs; + FILE *file; +{ + int n; + int sflag; + + /* + * Print answer records. + */ + sflag = (_res.pfcode & pflag); + if (n = ntohs(cnt)) { + if ((!_res.pfcode) || + ((sflag) && (_res.pfcode & RES_PRF_HEAD1))) + fprintf(file, hs); + while (--n >= 0) { + cp = p_rr(cp, msg, file); + if ((cp - msg) > PACKETSZ) + return (NULL); + } + if ((!_res.pfcode) || + ((sflag) && (_res.pfcode & RES_PRF_HEAD1))) + putc('\n', file); + } + return (cp); +} + +void +__p_query(msg) + const u_char *msg; +{ + __fp_query(msg, stdout); +} + +#ifdef ultrix +/* ultrix 4.0's packaging has some icky packaging. alias for it here. + * there is more junk of this kind over in res_comp.c. + */ +void +p_query(msg) + const u_char *msg; +{ + __p_query(msg); +} +#endif + +/* + * Print the current options. + * This is intended to be primarily a debugging routine. + */ +void +__fp_resstat(statp, file) + struct __res_state *statp; + FILE *file; +{ + register u_long mask; + + fprintf(file, ";; res options:"); + if (!statp) + statp = &_res; + for (mask = 1; mask != 0; mask <<= 1) + if (statp->options & mask) + fprintf(file, " %s", p_option(mask)); + putc('\n', file); +} + +/* + * Print the contents of a query. + * This is intended to be primarily a debugging routine. + */ +void +__fp_nquery(msg, len, file) + const u_char *msg; + int len; + FILE *file; +{ + register const u_char *cp, *endMark; + register const HEADER *hp; + register int n; + +#define TruncTest(x) if (x >= endMark) goto trunc +#define ErrorTest(x) if (x == NULL) goto error + + /* + * Print header fields. + */ + hp = (HEADER *)msg; + cp = msg + HFIXEDSZ; + endMark = cp + len; + if ((!_res.pfcode) || (_res.pfcode & RES_PRF_HEADX) || hp->rcode) { + fprintf(file, ";; ->>HEADER<<- opcode: %s, status: %s, id: %d", + _res_opcodes[hp->opcode], + _res_resultcodes[hp->rcode], + ntohs(hp->id)); + putc('\n', file); + } + putc(';', file); + if ((!_res.pfcode) || (_res.pfcode & RES_PRF_HEAD2)) { + fprintf(file,"; flags:"); + if (hp->qr) + fprintf(file, " qr"); + if (hp->aa) + fprintf(file, " aa"); + if (hp->tc) + fprintf(file, " tc"); + if (hp->rd) + fprintf(file, " rd"); + if (hp->ra) + fprintf(file, " ra"); + if (hp->pr) + fprintf(file, " pr"); + } + if ((!_res.pfcode) || (_res.pfcode & RES_PRF_HEAD1)) { + fprintf(file, "; Ques: %d", ntohs(hp->qdcount)); + fprintf(file, ", Ans: %d", ntohs(hp->ancount)); + fprintf(file, ", Auth: %d", ntohs(hp->nscount)); + fprintf(file, ", Addit: %d", ntohs(hp->arcount)); + } + if ((!_res.pfcode) || (_res.pfcode & + (RES_PRF_HEADX | RES_PRF_HEAD2 | RES_PRF_HEAD1))) { + putc('\n',file); + } + /* + * Print question records. + */ + if (n = ntohs(hp->qdcount)) { + if ((!_res.pfcode) || (_res.pfcode & RES_PRF_QUES)) + fprintf(file,";; QUESTIONS:\n"); + while (--n >= 0) { + fprintf(file,";;\t"); + TruncTest(cp); + cp = p_cdname(cp, msg, file); + ErrorTest(cp); + TruncTest(cp); + if ((!_res.pfcode) || (_res.pfcode & RES_PRF_QUES)) + fprintf(file, ", type = %s", + __p_type(_getshort((u_char*)cp))); + cp += INT16SZ; + TruncTest(cp); + if ((!_res.pfcode) || (_res.pfcode & RES_PRF_QUES)) + fprintf(file, ", class = %s\n", + __p_class(_getshort((u_char*)cp))); + cp += INT16SZ; + putc('\n', file); + } + } + /* + * Print authoritative answer records + */ + TruncTest(cp); + cp = do_rrset(msg, cp, hp->ancount, RES_PRF_ANS, file, + ";; ANSWERS:\n"); + ErrorTest(cp); + + /* + * print name server records + */ + TruncTest(cp); + cp = do_rrset(msg, cp, hp->nscount, RES_PRF_AUTH, file, + ";; AUTHORITY RECORDS:\n"); + ErrorTest(cp); + + TruncTest(cp); + /* + * print additional records + */ + cp = do_rrset(msg, cp, hp->arcount, RES_PRF_ADD, file, + ";; ADDITIONAL RECORDS:\n"); + ErrorTest(cp); + return; + trunc: + fprintf(file, "\n;; ...truncated\n"); + return; + error: + fprintf(file, "\n;; ...malformed\n"); +} + +void +__fp_query(msg, file) + const u_char *msg; + FILE *file; +{ + fp_nquery(msg, PACKETSZ, file); +} + +const u_char * +__p_cdnname(cp, msg, len, file) + const u_char *cp, *msg; + int len; + FILE *file; +{ + char name[MAXDNAME]; + int n; + + if ((n = dn_expand(msg, msg + len, cp, name, sizeof name)) < 0) + return (NULL); + if (name[0] == '\0') + putc('.', file); + else + fputs(name, file); + return (cp + n); +} + +const u_char * +__p_cdname(cp, msg, file) + const u_char *cp, *msg; + FILE *file; +{ + return (p_cdnname(cp, msg, PACKETSZ, file)); +} + +/* XXX: the rest of these functions need to become length-limited, too. (vix) + */ + +const u_char * +__p_fqname(cp, msg, file) + const u_char *cp, *msg; + FILE *file; +{ + char name[MAXDNAME]; + int n, len; + + if ((n = dn_expand(msg, cp + MAXCDNAME, cp, name, sizeof name)) < 0) + return (NULL); + if (name[0] == '\0') { + putc('.', file); + } else { + fputs(name, file); + if (name[strlen(name) - 1] != '.') + putc('.', file); + } + return (cp + n); +} + +/* + * Print resource record fields in human readable form. + */ +const u_char * +__p_rr(cp, msg, file) + const u_char *cp, *msg; + FILE *file; +{ + int type, class, dlen, n, c; + struct in_addr inaddr; + const u_char *cp1, *cp2; + u_int32_t tmpttl, t; + int lcnt; + + if ((cp = p_fqname(cp, msg, file)) == NULL) + return (NULL); /* compression error */ + type = _getshort((u_char*)cp); + cp += INT16SZ; + class = _getshort((u_char*)cp); + cp += INT16SZ; + tmpttl = _getlong((u_char*)cp); + cp += INT32SZ; + dlen = _getshort((u_char*)cp); + cp += INT16SZ; + cp1 = cp; + if ((!_res.pfcode) || (_res.pfcode & RES_PRF_TTLID)) + fprintf(file, "\t%lu", tmpttl); + if ((!_res.pfcode) || (_res.pfcode & RES_PRF_CLASS)) + fprintf(file, "\t%s", __p_class(class)); + fprintf(file, "\t%s", __p_type(type)); + /* + * Print type specific data, if appropriate + */ + switch (type) { + case T_A: + switch (class) { + case C_IN: + case C_HS: + bcopy(cp, (char *)&inaddr, INADDRSZ); + if (dlen == 4) { + fprintf(file,"\t%s", inet_ntoa(inaddr)); + cp += dlen; + } else if (dlen == 7) { + char *address; + u_char protocol; + u_short port; + + address = inet_ntoa(inaddr); + cp += INADDRSZ; + protocol = *(u_char*)cp; + cp += sizeof(u_char); + port = _getshort((u_char*)cp); + cp += INT16SZ; + fprintf(file, "\t%s\t; proto %d, port %d", + address, protocol, port); + } + break; + default: + cp += dlen; + } + break; + case T_CNAME: + case T_MB: + case T_MG: + case T_MR: + case T_NS: + case T_PTR: + putc('\t', file); + cp = p_fqname(cp, msg, file); + break; + + case T_HINFO: + case T_ISDN: + if (n = *cp++) { + fprintf(file,"\t%.*s", n, cp); + cp += n; + } + if (n = *cp++) { + fprintf(file,"\t%.*s", n, cp); + cp += n; + } + break; + + case T_SOA: + putc('\t', file); + cp = p_fqname(cp, msg, file); /* origin */ + putc(' ', file); + cp = p_fqname(cp, msg, file); /* mail addr */ + fputs(" (\n", file); + t = _getlong((u_char*)cp); cp += INT32SZ; + fprintf(file,"\t\t\t%lu\t; serial\n", t); + t = _getlong((u_char*)cp); cp += INT32SZ; + fprintf(file,"\t\t\t%lu\t; refresh (%s)\n", t, __p_time(t)); + t = _getlong((u_char*)cp); cp += INT32SZ; + fprintf(file,"\t\t\t%lu\t; retry (%s)\n", t, __p_time(t)); + t = _getlong((u_char*)cp); cp += INT32SZ; + fprintf(file,"\t\t\t%lu\t; expire (%s)\n", t, __p_time(t)); + t = _getlong((u_char*)cp); cp += INT32SZ; + fprintf(file,"\t\t\t%lu )\t; minimum (%s)", t, __p_time(t)); + break; + + case T_MX: + case T_AFSDB: + case T_RT: + fprintf(file,"\t%d ", _getshort((u_char*)cp)); + cp += INT16SZ; + cp = p_fqname(cp, msg, file); + break; + + case T_TXT: + case T_X25: + (void) fputs("\t\"", file); + cp2 = cp1 + dlen; + while (cp < cp2) { + if (n = (unsigned char) *cp++) { + for (c = n; c > 0 && cp < cp2; c--) + if (*cp == '\n') { + (void) putc('\\', file); + (void) putc(*cp++, file); + } else + (void) putc(*cp++, file); + } + } + putc('"', file); + break; + + case T_NSAP: + (void) fprintf(file, "\t%s", inet_nsap_ntoa(dlen, cp, NULL)); + cp += dlen; + break; + + case T_MINFO: + case T_RP: + putc('\t', file); + cp = p_fqname(cp, msg, file); + putc(' ', file); + cp = p_fqname(cp, msg, file); + break; + + case T_UINFO: + putc('\t', file); + fputs((char *)cp, file); + cp += dlen; + break; + + case T_UID: + case T_GID: + if (dlen == 4) { + fprintf(file,"\t%u", _getlong((u_char*)cp)); + cp += INT32SZ; + } + break; + + case T_WKS: + if (dlen < INT32SZ + 1) + break; + bcopy(cp, (char *)&inaddr, INADDRSZ); + cp += INT32SZ; + fprintf(file, "\t%s %s ( ", + inet_ntoa(inaddr), + deproto((int) *cp)); + cp += sizeof(u_char); + n = 0; + lcnt = 0; + while (cp < cp1 + dlen) { + c = *cp++; + do { + if (c & 0200) { + if (lcnt == 0) { + fputs("\n\t\t\t", file); + lcnt = 5; + } + fputs(dewks(n), file); + putc(' ', file); + lcnt--; + } + c <<= 1; + } while (++n & 07); + } + putc(')', file); + break; + +#ifdef ALLOW_T_UNSPEC + case T_UNSPEC: + { + int NumBytes = 8; + u_char *DataPtr; + int i; + + if (dlen < NumBytes) NumBytes = dlen; + fprintf(file, "\tFirst %d bytes of hex data:", + NumBytes); + for (i = 0, DataPtr = cp; i < NumBytes; i++, DataPtr++) + fprintf(file, " %x", *DataPtr); + cp += dlen; + } + break; +#endif /* ALLOW_T_UNSPEC */ + + default: + fprintf(file,"\t?%d?", type); + cp += dlen; + } +#if 0 + fprintf(file, "\t; dlen=%d, ttl %s\n", dlen, __p_time(tmpttl)); +#else + putc('\n', file); +#endif + if (cp - cp1 != dlen) { + fprintf(file,";; packet size error (found %d, dlen was %d)\n", + cp - cp1, dlen); + cp = NULL; + } + return (cp); +} + +static char nbuf[40]; + +/* + * Return a string for the type + */ +const char * +__p_type(type) + int type; +{ + switch (type) { + case T_A: return "A"; + case T_NS: return "NS"; + case T_CNAME: return "CNAME"; + case T_SOA: return "SOA"; + case T_MB: return "MB"; + case T_MG: return "MG"; + case T_MR: return "MR"; + case T_NULL: return "NULL"; + case T_WKS: return "WKS"; + case T_PTR: return "PTR"; + case T_HINFO: return "HINFO"; + case T_MINFO: return "MINFO"; + case T_MX: return "MX"; + case T_TXT: return "TXT"; + case T_NSAP: return "NSAP"; + case T_RP: return "RP"; + case T_AFSDB: return "AFSDB"; + case T_X25: return "X25"; + case T_ISDN: return "ISDN"; + case T_RT: return "RT"; + case T_AXFR: return "AXFR"; + case T_MAILB: return "MAILB"; + case T_MAILA: return "MAILA"; + case T_ANY: return "ANY"; + case T_UINFO: return "UINFO"; + case T_UID: return "UID"; + case T_GID: return "GID"; +#ifdef ALLOW_T_UNSPEC + case T_UNSPEC: return "UNSPEC"; +#endif /* ALLOW_T_UNSPEC */ + default: (void)sprintf(nbuf, "%d", type); return (nbuf); + } +} + +/* + * Return a mnemonic for class + */ +const char * +__p_class(class) + int class; +{ + switch (class) { + case C_IN: return("IN"); + case C_HS: return("HS"); + case C_ANY: return("ANY"); + default: (void)sprintf(nbuf, "%d", class); return (nbuf); + } +} + +/* + * Return a mnemonic for an option + */ +const char * +__p_option(option) + u_long option; +{ + switch (option) { + case RES_INIT: return "init"; + case RES_DEBUG: return "debug"; + case RES_AAONLY: return "aaonly"; + case RES_USEVC: return "usevc"; + case RES_PRIMARY: return "primry"; + case RES_IGNTC: return "igntc"; + case RES_RECURSE: return "recurs"; + case RES_DEFNAMES: return "defnam"; + case RES_STAYOPEN: return "styopn"; + case RES_DNSRCH: return "dnsrch"; + case RES_INSECURE1: return "insecure1"; + case RES_INSECURE2: return "insecure2"; + default: sprintf(nbuf, "?0x%x?", option); return nbuf; + } +} + +/* + * Return a mnemonic for a time to live + */ +char * +__p_time(value) + u_int32_t value; +{ + int secs, mins, hours, days; + register char *p; + + if (value == 0) { + strcpy(nbuf, "0 secs"); + return (nbuf); + } + + secs = value % 60; + value /= 60; + mins = value % 60; + value /= 60; + hours = value % 24; + value /= 24; + days = value; + value = 0; + +#define PLURALIZE(x) x, (x == 1) ? "" : "s" + p = nbuf; + if (days) { + (void)sprintf(p, "%d day%s", PLURALIZE(days)); + while (*++p); + } + if (hours) { + if (days) + *p++ = ' '; + (void)sprintf(p, "%d hour%s", PLURALIZE(hours)); + while (*++p); + } + if (mins) { + if (days || hours) + *p++ = ' '; + (void)sprintf(p, "%d min%s", PLURALIZE(mins)); + while (*++p); + } + if (secs || ! (days || hours || mins)) { + if (days || hours || mins) + *p++ = ' '; + (void)sprintf(p, "%d sec%s", PLURALIZE(secs)); + } + return (nbuf); +} diff -ruN glibc-1.08.1/resolv/res_init.c glibc-1.09/resolv/res_init.c --- glibc-1.08.1/resolv/res_init.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/resolv/res_init.c Thu Jul 28 17:56:24 1994 @@ -0,0 +1,439 @@ +/* + * ++Copyright++ 1985, 1989, 1993 + * - + * 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. + * - + * 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[] = "@(#)res_init.c 8.1 (Berkeley) 6/7/93"; +static char rcsid[] = "$Id: res_init.c,v 1.2 1994/07/28 21:56:23 roland Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include +#include +#include +#include + +#include +#include +#include +#if defined(BSD) && (BSD >= 199103) +# include +# include +# include +#else +# include "../conf/portability.h" +#endif + +#if defined(USE_OPTIONS_H) +# include "../conf/options.h" +#endif + +static void res_setoptions __P((char *, char *)); + +#ifdef RESOLVSORT +static u_int32_t net_mask __P((struct in_addr)); +#endif + +#if !defined(isascii) /* XXX - could be a function */ +# define isascii(c) (!(c & 0200)) +#endif + +/* + * Resolver state default settings. + */ + +struct __res_state _res; + +/* + * Set up default settings. If the configuration file exist, the values + * there will have precedence. Otherwise, the server address is set to + * INADDR_ANY and the default domain name comes from the gethostname(). + * + * An interrim version of this code (BIND 4.9, pre-4.4BSD) used 127.0.0.1 + * rather than INADDR_ANY ("0.0.0.0") as the default name server address + * since it was noted that INADDR_ANY actually meant ``the first interface + * you "ifconfig"'d at boot time'' and if this was a SLIP or PPP interface, + * it had to be "up" in order for you to reach your own name server. It + * was later decided that since the recommended practice is to always + * install local static routes through 127.0.0.1 for all your network + * interfaces, that we could solve this problem without a code change. + * + * The configuration file should always be used, since it is the only way + * to specify a default domain. If you are running a server on your local + * machine, you should say "nameserver 0.0.0.0" or "nameserver 127.0.0.1" + * in the configuration file. + * + * Return 0 if completes successfully, -1 on error + */ +res_init() +{ + register FILE *fp; + register char *cp, **pp; + register int n, dots; + char buf[BUFSIZ]; + int nserv = 0; /* number of nameserver records read from file */ + int haveenv = 0; + int havesearch = 0; +#ifdef RESOLVSORT + int nsort = 0; + char *net; +#endif + + /* + * These four fields used to be statically initialized. This made + * it hard to use this code in a shared library. It is necessary, + * now that we're doing dynamic initialization here, that we preserve + * the old semantics: if an application modifies one of these three + * fields of _res before res_init() is called, res_init() will not + * alter them. Of course, if an application is setting them to + * _zero_ before calling res_init(), hoping to override what used + * to be the static default, we can't detect it and unexpected results + * will follow. Zero for any of these fields would make no sense, + * so one can safely assume that the applications were already getting + * unexpected results. + */ + if (!_res.retrans) + _res.retrans = RES_TIMEOUT; + if (!_res.retry) + _res.retry = 4; + if (!_res.options) + _res.options = RES_DEFAULT; + +#ifdef USELOOPBACK + _res.nsaddr.sin_addr = inet_makeaddr(IN_LOOPBACKNET, 1); +#else + _res.nsaddr.sin_addr.s_addr = INADDR_ANY; +#endif + _res.nsaddr.sin_family = AF_INET; + _res.nsaddr.sin_port = htons(NAMESERVER_PORT); + _res.nscount = 1; + _res.ndots = 1; + _res.pfcode = 0; + + /* Allow user to override the local domain definition */ + if ((cp = getenv("LOCALDOMAIN")) != NULL) { + (void)strncpy(_res.defdname, cp, sizeof(_res.defdname) - 1); + haveenv++; + + /* + * Set search list to be blank-separated strings + * from rest of env value. Permits users of LOCALDOMAIN + * to still have a search list, and anyone to set the + * one that they want to use as an individual (even more + * important now that the rfc1535 stuff restricts searches) + */ + cp = _res.defdname; + pp = _res.dnsrch; + *pp++ = cp; + for (n = 0; *cp && pp < _res.dnsrch + MAXDNSRCH; cp++) { + if (*cp == '\n') /* silly backwards compat */ + break; + else if (*cp == ' ' || *cp == '\t') { + *cp = 0; + n = 1; + } else if (n) { + *pp++ = cp; + n = 0; + havesearch = 1; + } + } + /* null terminate last domain if there are excess */ + while (*cp != '\0' && *cp != ' ' && *cp != '\t' && *cp != '\n') + cp++; + *cp = '\0'; + *pp++ = 0; + } + + if ((fp = fopen(_PATH_RESCONF, "r")) != NULL) { + /* read the config file */ + while (fgets(buf, sizeof(buf), fp) != NULL) { + /* skip comments */ + if ((*buf == ';') || (*buf == '#')) + continue; + /* read default domain name */ + if (!strncmp(buf, "domain", sizeof("domain") - 1)) { + if (haveenv) /* skip if have from environ */ + continue; + cp = buf + sizeof("domain") - 1; + while (*cp == ' ' || *cp == '\t') + cp++; + if ((*cp == '\0') || (*cp == '\n')) + continue; + (void)strncpy(_res.defdname, cp, + sizeof(_res.defdname) - 1); + if ((cp = strpbrk(_res.defdname, " \t\n")) != NULL) + *cp = '\0'; + havesearch = 0; + continue; + } + /* set search list */ + if (!strncmp(buf, "search", sizeof("search") - 1)) { + if (haveenv) /* skip if have from environ */ + continue; + cp = buf + sizeof("search") - 1; + while (*cp == ' ' || *cp == '\t') + cp++; + if ((*cp == '\0') || (*cp == '\n')) + continue; + (void)strncpy(_res.defdname, cp, + sizeof(_res.defdname) - 1); + if ((cp = strchr(_res.defdname, '\n')) != NULL) + *cp = '\0'; + /* + * Set search list to be blank-separated strings + * on rest of line. + */ + cp = _res.defdname; + pp = _res.dnsrch; + *pp++ = cp; + for (n = 0; + *cp && pp < _res.dnsrch + MAXDNSRCH; + cp++) { + if (*cp == ' ' || *cp == '\t') { + *cp = 0; + n = 1; + } else if (n) { + *pp++ = cp; + n = 0; + } + } + /* null terminate last domain if there are excess */ + while (*cp != '\0' && *cp != ' ' && *cp != '\t') + cp++; + *cp = '\0'; + *pp++ = 0; + havesearch = 1; + continue; + } + /* read nameservers to query */ + if (!strncmp(buf, "nameserver", sizeof("nameserver") - 1) && + nserv < MAXNS) { + struct in_addr a; + + cp = buf + sizeof("nameserver") - 1; + while (*cp == ' ' || *cp == '\t') + cp++; + if ((*cp != '\0') && (*cp != '\n') && inet_aton(cp, &a)) { + _res.nsaddr_list[nserv].sin_addr = a; + _res.nsaddr_list[nserv].sin_family = AF_INET; + _res.nsaddr_list[nserv].sin_port = + htons(NAMESERVER_PORT); + nserv++; + } + continue; + } +#ifdef RESOLVSORT + if (!strncmp(buf, "sortlist", sizeof("sortlist") -1)) { + struct in_addr a; + + cp = buf + sizeof("sortlist") - 1; + while (nsort < MAXRESOLVSORT) { + while (*cp == ' ' || *cp == '\t') + cp++; + if (*cp == '\0' || *cp == '\n' || *cp == ';') + break; + net = cp; + while (*cp && *cp != '/' && + isascii(*cp) && !isspace(*cp)) + cp++; + n = *cp; + *cp = 0; + if (inet_aton(net, &a)) { + _res.sort_list[nsort].addr = a; + if (n == '/') { + *cp++ = n; + net = cp; + while (*cp && isascii(*cp) && !isspace(*cp)) + cp++; + n = *cp; + *cp = 0; + if (inet_aton(net, &a)) { + _res.sort_list[nsort].mask = a.s_addr; + } else { + _res.sort_list[nsort].mask = + net_mask(_res.sort_list[nsort].addr); + } + } else { + _res.sort_list[nsort].mask = + net_mask(_res.sort_list[nsort].addr); + } + nsort++; + } + *cp++ = n; + } + continue; + } +#endif + if (!strncmp(buf, "options", sizeof("options") -1)) { + res_setoptions(buf + sizeof("options") - 1, "conf"); + continue; + } + } + if (nserv > 1) + _res.nscount = nserv; +#ifdef RESOLVSORT + _res.nsort = nsort; +#endif + (void) fclose(fp); + } /*if(fopen)*/ + if (_res.defdname[0] == 0) { + if (gethostname(buf, sizeof(_res.defdname) - 1) == 0 && + (cp = strchr(buf, '.'))) { + (void)strcpy(_res.defdname, cp + 1); + } + } + + /* find components of local domain that might be searched */ + if (havesearch == 0) { + pp = _res.dnsrch; + *pp++ = _res.defdname; + *pp = NULL; + +#ifndef RFC1535 + dots = 0; + for (cp = _res.defdname; *cp; cp++) + dots += (*cp == '.'); + + cp = _res.defdname; + while (pp < _res.dnsrch + MAXDFLSRCH) { + if (dots < LOCALDOMAINPARTS) { + break; + } + cp = strchr(cp, '.') + 1; /* we know there is one */ + *pp++ = cp; + dots--; + } + *pp = NULL; +#ifdef DEBUG + if (_res.options & RES_DEBUG) { + printf(";; res_init()... default dnsrch list:\n"); + for (pp = _res.dnsrch; *pp; pp++) { + printf(";;\t%s\n", *pp); + } + printf(";;\t..END..\n"); + } +#endif /*DEBUG*/ +#endif /*!RFC1535*/ + } + + if ((cp = getenv("RES_OPTIONS")) != NULL) { + res_setoptions(cp, "env"); + } + _res.options |= RES_INIT; + return (0); +} + + +static void +res_setoptions(options, source) + char *options, *source; +{ + char *cp = options; + int i; + +#ifdef DEBUG + if (_res.options & RES_DEBUG) { + printf(";; res_setoptions(\"%s\", \"%s\")...\n", + options, source); + } +#endif + while (*cp) { + /* skip leading and inner runs of spaces */ + while (*cp == ' ' || *cp == '\t') + cp++; + /* search for and process individual options */ + if (!strncmp(cp, "ndots:", sizeof("ndots:")-1)) { + i = atoi(cp + sizeof("ndots:") - 1); + if (i <= RES_MAXNDOTS) + _res.ndots = i; + else + _res.ndots = RES_MAXNDOTS; +#ifdef DEBUG + if (_res.options & RES_DEBUG) { + printf(";;\tndots=%d\n", _res.ndots); + } +#endif + } else if (!strncmp(cp, "debug", sizeof("debug")-1)) { +#ifdef DEBUG + if (!(_res.options & RES_DEBUG)) { + printf(";; res_setoptions(\"%s\", \"%s\")..\n", + options, source); + _res.options |= RES_DEBUG; + } + printf(";;\tdebug\n"); +#endif + } else { + /* XXX - print a warning here? */ + } + /* skip to next run of spaces */ + while (*cp && *cp != ' ' && *cp != '\t') + cp++; + } +} + +#ifdef RESOLVSORT +static u_int32_t +net_mask(in) /* XXX - should really use system's version of this */ + struct in_addr in; +{ + register u_int32_t i = ntohl(in.s_addr); + + if (IN_CLASSA(i)) + return (htonl(IN_CLASSA_NET)); + else if (IN_CLASSB(i)) + return (htonl(IN_CLASSB_NET)); + else + return (htonl(IN_CLASSC_NET)); +} +#endif diff -ruN glibc-1.08.1/resolv/res_mkquery.c glibc-1.09/resolv/res_mkquery.c --- glibc-1.08.1/resolv/res_mkquery.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/resolv/res_mkquery.c Thu Jul 28 17:56:26 1994 @@ -0,0 +1,241 @@ +/* + * ++Copyright++ 1985, 1993 + * - + * 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. + * - + * --Copyright-- + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)res_mkquery.c 8.1 (Berkeley) 6/4/93"; +static char rcsid[] = "$Id: res_mkquery.c,v 1.2 1994/07/28 21:56:26 roland Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include +#include + +#include +#include +#if defined(BSD) && (BSD >= 199103) +# include +#else +# include "../conf/portability.h" +#endif + +#if defined(USE_OPTIONS_H) +# include <../conf/options.h> +#endif + +/* + * Form all types of queries. + * Returns the size of the result or -1. + */ +int +res_mkquery(op, dname, class, type, data, datalen, newrr_in, buf, buflen) + int op; /* opcode of query */ + const char *dname; /* domain name */ + int class, type; /* class and type of query */ + const u_char *data; /* resource record data */ + int datalen; /* length of data */ + const u_char *newrr_in; /* new rr for modify or append */ + u_char *buf; /* buffer to put query */ + int buflen; /* size of buffer */ +{ + register HEADER *hp; + register u_char *cp; + register int n; + struct rrec *newrr = (struct rrec *) newrr_in; + u_char *dnptrs[20], **dpp, **lastdnptr; + +#ifdef DEBUG + if (_res.options & RES_DEBUG) + printf(";; res_mkquery(%d, %s, %d, %d)\n", + op, dname, class, type); +#endif + /* + * Initialize header fields. + */ + if ((buf == NULL) || (buflen < HFIXEDSZ)) + return(-1); + bzero(buf, HFIXEDSZ); + hp = (HEADER *) buf; + hp->id = htons(++_res.id); + hp->opcode = op; + hp->pr = (_res.options & RES_PRIMARY) != 0; + hp->rd = (_res.options & RES_RECURSE) != 0; + hp->rcode = NOERROR; + cp = buf + HFIXEDSZ; + buflen -= HFIXEDSZ; + dpp = dnptrs; + *dpp++ = buf; + *dpp++ = NULL; + lastdnptr = dnptrs + sizeof dnptrs / sizeof dnptrs[0]; + /* + * perform opcode specific processing + */ + switch (op) { + case QUERY: + if ((buflen -= QFIXEDSZ) < 0) + return(-1); + if ((n = dn_comp(dname, cp, buflen, dnptrs, lastdnptr)) < 0) + return (-1); + cp += n; + buflen -= n; + __putshort(type, cp); + cp += INT16SZ; + __putshort(class, cp); + cp += INT16SZ; + hp->qdcount = htons(1); + if (op == QUERY || data == NULL) + break; + /* + * Make an additional record for completion domain. + */ + buflen -= RRFIXEDSZ; + n = dn_comp((char *)data, cp, buflen, dnptrs, lastdnptr); + if (n < 0) + return (-1); + cp += n; + buflen -= n; + __putshort(T_NULL, cp); + cp += INT16SZ; + __putshort(class, cp); + cp += INT16SZ; + __putlong(0, cp); + cp += INT32SZ; + __putshort(0, cp); + cp += INT16SZ; + hp->arcount = htons(1); + break; + + case IQUERY: + /* + * Initialize answer section + */ + if (buflen < 1 + RRFIXEDSZ + datalen) + return (-1); + *cp++ = '\0'; /* no domain name */ + __putshort(type, cp); + cp += INT16SZ; + __putshort(class, cp); + cp += INT16SZ; + __putlong(0, cp); + cp += INT32SZ; + __putshort(datalen, cp); + cp += INT16SZ; + if (datalen) { + bcopy(data, cp, datalen); + cp += datalen; + } + hp->ancount = htons(1); + break; + +#ifdef ALLOW_UPDATES + /* + * For UPDATEM/UPDATEMA, do UPDATED/UPDATEDA followed by UPDATEA + * (Record to be modified is followed by its replacement in msg.) + */ + case UPDATEM: + case UPDATEMA: + + case UPDATED: + /* + * The res code for UPDATED and UPDATEDA is the same; user + * calls them differently: specifies data for UPDATED; server + * ignores data if specified for UPDATEDA. + */ + case UPDATEDA: + buflen -= RRFIXEDSZ + datalen; + if ((n = dn_comp(dname, cp, buflen, dnptrs, lastdnptr)) < 0) + return (-1); + cp += n; + __putshort(type, cp); + cp += INT16SZ; + __putshort(class, cp); + cp += INT16SZ; + __putlong(0, cp); + cp += INT32SZ; + __putshort(datalen, cp); + cp += INT16SZ; + if (datalen) { + bcopy(data, cp, datalen); + cp += datalen; + } + if ( (op == UPDATED) || (op == UPDATEDA) ) { + hp->ancount = htons(0); + break; + } + /* Else UPDATEM/UPDATEMA, so drop into code for UPDATEA */ + + case UPDATEA: /* Add new resource record */ + buflen -= RRFIXEDSZ + datalen; + if ((n = dn_comp(dname, cp, buflen, dnptrs, lastdnptr)) < 0) + return (-1); + cp += n; + __putshort(newrr->r_type, cp); + cp += INT16SZ; + __putshort(newrr->r_class, cp); + cp += INT16SZ; + __putlong(0, cp); + cp += INT32SZ; + __putshort(newrr->r_size, cp); + cp += INT16SZ; + if (newrr->r_size) { + bcopy(newrr->r_data, cp, newrr->r_size); + cp += newrr->r_size; + } + hp->ancount = htons(0); + break; + +#endif /* ALLOW_UPDATES */ + } + return (cp - buf); +} diff -ruN glibc-1.08.1/resolv/res_query.c glibc-1.09/resolv/res_query.c --- glibc-1.08.1/resolv/res_query.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/resolv/res_query.c Thu Jul 28 17:56:28 1994 @@ -0,0 +1,382 @@ +/* + * ++Copyright++ 1988, 1993 + * - + * 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. + * - + * 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[] = "@(#)res_query.c 8.1 (Berkeley) 6/4/93"; +static char rcsid[] = "$Id: res_query.c,v 1.2 1994/07/28 21:56:27 roland Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#if defined(BSD) && (BSD >= 199306) +# include +# include +#else +# include "../conf/portability.h" +#endif + +#if defined(USE_OPTIONS_H) +# include <../conf/options.h> +#endif + +#if PACKETSZ > 1024 +#define MAXPACKET PACKETSZ +#else +#define MAXPACKET 1024 +#endif + +char *__hostalias __P((const char *)); +int h_errno; + +/* + * Formulate a normal query, send, and await answer. + * Returned answer is placed in supplied buffer "answer". + * Perform preliminary check of answer, returning success only + * if no error is indicated and the answer count is nonzero. + * Return the size of the response on success, -1 on error. + * Error number is left in h_errno. + * + * Caller must parse answer and determine whether it answers the question. + */ +int +res_query(name, class, type, answer, anslen) + const char *name; /* domain name */ + int class, type; /* class and type of query */ + u_char *answer; /* buffer to put answer */ + int anslen; /* size of answer buffer */ +{ + u_char buf[MAXPACKET]; + register HEADER *hp = (HEADER *) answer; + int n; + + hp->rcode = NOERROR; /* default */ + + if ((_res.options & RES_INIT) == 0 && res_init() == -1) + return (-1); +#ifdef DEBUG + if (_res.options & RES_DEBUG) + printf(";; res_query(%s, %d, %d)\n", name, class, type); +#endif + + n = res_mkquery(QUERY, name, class, type, NULL, 0, NULL, + buf, sizeof(buf)); + if (n <= 0) { +#ifdef DEBUG + if (_res.options & RES_DEBUG) + printf(";; res_query: mkquery failed\n"); +#endif + h_errno = NO_RECOVERY; + return (n); + } + n = res_send(buf, n, answer, anslen); + if (n < 0) { +#ifdef DEBUG + if (_res.options & RES_DEBUG) + printf(";; res_query: send error\n"); +#endif + h_errno = TRY_AGAIN; + return (n); + } + + if (hp->rcode != NOERROR || ntohs(hp->ancount) == 0) { +#ifdef DEBUG + if (_res.options & RES_DEBUG) + printf(";; rcode = %d, ancount=%d\n", hp->rcode, + ntohs(hp->ancount)); +#endif + switch (hp->rcode) { + case NXDOMAIN: + h_errno = HOST_NOT_FOUND; + break; + case SERVFAIL: + h_errno = TRY_AGAIN; + break; + case NOERROR: + h_errno = NO_DATA; + break; + case FORMERR: + case NOTIMP: + case REFUSED: + default: + h_errno = NO_RECOVERY; + break; + } + return (-1); + } + return (n); +} + +/* + * Formulate a normal query, send, and retrieve answer in supplied buffer. + * Return the size of the response on success, -1 on error. + * If enabled, implement search rules until answer or unrecoverable failure + * is detected. Error code, if any, is left in h_errno. + */ +int +res_search(name, class, type, answer, anslen) + const char *name; /* domain name */ + int class, type; /* class and type of query */ + u_char *answer; /* buffer to put answer */ + int anslen; /* size of answer */ +{ + register const char *cp, * const *domain; + HEADER *hp = (HEADER *) answer; + u_int dots; + int trailing_dot, ret, saved_herrno; + int got_nodata = 0, got_servfail = 0, tried_as_is = 0; + + if ((_res.options & RES_INIT) == 0 && res_init() == -1) + return (-1); + + errno = 0; + h_errno = HOST_NOT_FOUND; /* default, if we never query */ + dots = 0; + for (cp = name; *cp; cp++) + dots += (*cp == '.'); + trailing_dot = 0; + if ((cp > name) && (*--cp == '.')) + trailing_dot++; + + /* + * if there aren't any dots, it could be a user-level alias + */ + if ((!dots) && (cp = __hostalias(name))) + return (res_query(cp, class, type, answer, anslen)); + + /* + * If there are dots in the name already, let's just give it a try + * 'as is'. The threshold can be set with the "ndots" option. + */ + saved_herrno = -1; + if (dots >= _res.ndots) { + ret = res_querydomain(name, NULL, class, type, answer, anslen); + if (ret > 0) + return (ret); + saved_herrno = h_errno; + tried_as_is++; + } + + /* + * We do at least one level of search if + * - there is no dot and RES_DEFNAME is set, or + * - there is at least one dot, there is no trailing dot, + * and RES_DNSRCH is set. + */ + if (((!dots) && _res.options & RES_DEFNAMES) || + (dots && (!trailing_dot) && _res.options & RES_DNSRCH) + ) { + int done = 0; + + for (domain = (const char * const *)_res.dnsrch; + *domain && !done; + domain++) { + + ret = res_querydomain(name, *domain, class, type, + answer, anslen); + if (ret > 0) + return (ret); + + /* + * If no server present, give up. + * If name isn't found in this domain, + * keep trying higher domains in the search list + * (if that's enabled). + * On a NO_DATA error, keep trying, otherwise + * a wildcard entry of another type could keep us + * from finding this entry higher in the domain. + * If we get some other error (negative answer or + * server failure), then stop searching up, + * but try the input name below in case it's + * fully-qualified. + */ + if (errno == ECONNREFUSED) { + h_errno = TRY_AGAIN; + return (-1); + } + + switch (h_errno) { + case NO_DATA: + got_nodata++; + /* FALLTHROUGH */ + case HOST_NOT_FOUND: + /* keep trying */ + break; + case TRY_AGAIN: + if (hp->rcode == SERVFAIL) { + /* try next search element, if any */ + got_servfail++; + break; + } + /* FALLTHROUGH */ + default: + /* anything else implies that we're done */ + done++; + } + + /* if we got here for some reason other than DNSRCH, + * we only wanted one iteration of the loop, so stop. + */ + if (!(_res.options & RES_DNSRCH)) + done++; + } + } + + /* if we have not already tried the name "as is", do that now. + * note that we do this regardless of how many dots were in the + * name or whether it ends with a dot. + */ + if (!tried_as_is) { + ret = res_querydomain(name, NULL, class, type, answer, anslen); + if (ret > 0) + return (ret); + saved_herrno = h_errno; + } + + /* if we got here, we didn't satisfy the search. + * if we did an initial full query, return that query's h_errno + * (note that we wouldn't be here if that query had succeeded). + * else if we ever got a nodata, send that back as the reason. + * else send back meaningless h_errno, that being the one from + * the last DNSRCH we did. + */ + if (saved_herrno != -1) + h_errno = saved_herrno; + else if (got_nodata) + h_errno = NO_DATA; + else if (got_servfail) + h_errno = TRY_AGAIN; + return (-1); +} + +/* + * Perform a call on res_query on the concatenation of name and domain, + * removing a trailing dot from name if domain is NULL. + */ +int +res_querydomain(name, domain, class, type, answer, anslen) + const char *name, *domain; + int class, type; /* class and type of query */ + u_char *answer; /* buffer to put answer */ + int anslen; /* size of answer */ +{ + char nbuf[2*MAXDNAME+2]; + const char *longname = nbuf; + int n; + +#ifdef DEBUG + if (_res.options & RES_DEBUG) + printf(";; res_querydomain(%s, %s, %d, %d)\n", + name, domain?domain:"", class, type); +#endif + if (domain == NULL) { + /* + * Check for trailing '.'; + * copy without '.' if present. + */ + n = strlen(name) - 1; + if (n != (0 - 1) && name[n] == '.' && n < sizeof(nbuf) - 1) { + bcopy(name, nbuf, n); + nbuf[n] = '\0'; + } else + longname = name; + } else { + sprintf(nbuf, "%.*s.%.*s", + MAXDNAME, name, MAXDNAME, domain); + } + + return (res_query(longname, class, type, answer, anslen)); +} + +char * +__hostalias(name) + register const char *name; +{ + register char *cp1, *cp2; + FILE *fp; + char *file; + char buf[BUFSIZ]; + static char abuf[MAXDNAME]; + + file = getenv("HOSTALIASES"); + if (file == NULL || (fp = fopen(file, "r")) == NULL) + return (NULL); + buf[sizeof(buf) - 1] = '\0'; + while (fgets(buf, sizeof(buf), fp)) { + for (cp1 = buf; *cp1 && !isspace(*cp1); ++cp1); + if (!*cp1) + break; + *cp1 = '\0'; + if (!strcasecmp(buf, name)) { + while (isspace(*++cp1)); + if (!*cp1) + break; + for (cp2 = cp1 + 1; *cp2 && !isspace(*cp2); ++cp2); + abuf[sizeof(abuf) - 1] = *cp2 = '\0'; + (void)strncpy(abuf, cp1, sizeof(abuf) - 1); + fclose(fp); + return (abuf); + } + } + fclose(fp); + return (NULL); +} diff -ruN glibc-1.08.1/resolv/res_send.c glibc-1.09/resolv/res_send.c --- glibc-1.08.1/resolv/res_send.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/resolv/res_send.c Thu Jul 28 17:56:29 1994 @@ -0,0 +1,757 @@ +/* + * ++Copyright++ 1985, 1989, 1993 + * - + * 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. + * - + * 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[] = "@(#)res_send.c 8.1 (Berkeley) 6/4/93"; +static char rcsid[] = "$Id: res_send.c,v 1.2 1994/07/28 21:56:28 roland Exp $"; +#endif /* LIBC_SCCS and not lint */ + + /* change this to "0" + * if you talk to a lot + * of multi-homed SunOS + * ("broken") name servers. + */ +#define CHECK_SRVR_ADDR 1 /* XXX - should be in options.h */ + +/* + * Send query to name server and wait for reply. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#if defined(BSD) && (BSD >= 199306) +# include +# include +#else +# include "../conf/portability.h" +#endif + +#if defined(USE_OPTIONS_H) +# include <../conf/options.h> +#endif + +void _res_close __P((void)); + +static int s = -1; /* socket used for communications */ +static int connected = 0; /* is the socket connected */ +static int vc = 0; /* is the socket a virtual ciruit? */ + +#ifndef FD_SET +/* XXX - should be in portability.h */ +#define NFDBITS 32 +#define FD_SETSIZE 32 +#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS))) +#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS))) +#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS))) +#define FD_ZERO(p) bzero((char *)(p), sizeof(*(p))) +#endif + +#ifndef DEBUG +# define Dprint(cond, args) /*empty*/ +# define DprintQ(cond, args, query) /*empty*/ +# define Aerror(file, string, error, address) /*empty*/ +# define Perror(file, string, error) /*empty*/ +#else +# define Dprint(cond, args) if (cond) {fprintf args;} else {} +# define DprintQ(cond, args, query) if (cond) {\ + fprintf args;\ + __p_query(query);\ + } else {} + static void + Aerror(file, string, error, address) + FILE *file; + char *string; + int error; + struct sockaddr_in address; + { + int save = errno; + + if (_res.options & RES_DEBUG) { + fprintf(file, "res_send: %s ([%s].%d): %s\n", + string, + inet_ntoa(address.sin_addr), + address.sin_port, + strerror(error)); + } + errno = save; + } + static void + Perror(file, string, error) + FILE *file; + char *string; + int error; + { + int save = errno; + + if (_res.options & RES_DEBUG) { + fprintf(file, "res_send: %s: %s\n", + string, strerror(error)); + } + errno = save; + } +#endif + +static res_send_qhook Qhook = NULL; +static res_send_rhook Rhook = NULL; + +void +res_send_setqhook(hook) + res_send_qhook hook; +{ + Qhook = hook; +} + +void +res_send_setrhook(hook) + res_send_rhook hook; +{ + Rhook = hook; +} + +/* int + * our_server(ina) + * looks up "ina" in _res.ns_addr_list[] + * returns: + * 0 : not found + * >0 : found + * author: + * paul vixie, 29may94 + */ +static int +our_server(inp) + const struct sockaddr_in *inp; +{ + struct sockaddr_in ina; + register int ns, ret; + + ina = *inp; + ret = 0; + for (ns = 0; ns < _res.nscount; ns++) { + register const struct sockaddr_in *srv = &_res.nsaddr_list[ns]; + + if (srv->sin_family == ina.sin_family && + srv->sin_port == ina.sin_port && + (srv->sin_addr.s_addr == INADDR_ANY || + srv->sin_addr.s_addr == ina.sin_addr.s_addr)) { + ret++; + break; + } + } + return (ret); +} + +/* int + * name_in_query(name, type, class, buf, eom) + * look for (name,type,class) in the query section of packet (buf,eom) + * returns: + * -1 : format error + * 0 : not found + * >0 : found + */ +static int +name_in_query(name, type, class, buf, eom) + const char *name; + register int type, class; + const u_char *buf, *eom; +{ + register const u_char *cp = buf + HFIXEDSZ; + int qdcount = ntohs(((HEADER*)buf)->qdcount); + + while (qdcount-- > 0) { + char tname[MAXDNAME+1]; + register int n, ttype, tclass; + + n = dn_expand(buf, eom, cp, tname, sizeof tname); + if (n < 0) + return (-1); + cp += n; + ttype = _getshort(cp); cp += INT16SZ; + tclass = _getshort(cp); cp += INT16SZ; + if (ttype == type && + tclass == class && + strcasecmp(tname, name) == 0) + return (1); + } + return (0); +} + +/* int + * queries_match(buf1, eom1, buf2, eom2) + * is there a 1:1 mapping of (name,type,class) + * in (buf1,eom1) and (buf2,eom2)? + * returns: + * -1 : format error + * 0 : not a 1:1 mapping + * >0 : is a 1:1 mapping + */ +static int +queries_match(buf1, eom1, buf2, eom2) + const u_char *buf1, *eom1; + const u_char *buf2, *eom2; +{ + register const u_char *cp = buf1 + HFIXEDSZ; + int qdcount = ntohs(((HEADER*)buf1)->qdcount); + + if (qdcount != ntohs(((HEADER*)buf2)->qdcount)) + return (0); + while (qdcount-- > 0) { + char tname[MAXDNAME+1]; + register int n, ttype, tclass; + + n = dn_expand(buf1, eom1, cp, tname, sizeof tname); + if (n < 0) + return (-1); + cp += n; + ttype = _getshort(cp); cp += INT16SZ; + tclass = _getshort(cp); cp += INT16SZ; + if (!name_in_query(tname, ttype, tclass, buf2, eom2)) + return (0); + } + return (1); +} + +int +res_send(buf, buflen, ans, anssiz) + const u_char *buf; + int buflen; + u_char *ans; + int anssiz; +{ + HEADER *hp = (HEADER *) buf; + HEADER *anhp = (HEADER *) ans; + int gotsomewhere = 0, + connreset = 0, + terrno = ETIMEDOUT; + + register int n; + int try, v_circuit, resplen, ns; + u_int badns; /* XXX NSMAX can't exceed #/bits in this var */ + + DprintQ((_res.options & RES_DEBUG) || (_res.pfcode & RES_PRF_QUERY), + (stdout, ";; res_send()\n"), buf); + if (!(_res.options & RES_INIT)) { + if (res_init() == -1) + return (-1); + } + v_circuit = (_res.options & RES_USEVC) || buflen > PACKETSZ; + badns = 0; + + /* + * Send request, RETRY times, or until successful + */ + for (try = 0; try < _res.retry; try++) { + for (ns = 0; ns < _res.nscount; ns++) { + struct sockaddr_in *nsap = &_res.nsaddr_list[ns]; + same_ns: + if (badns & (1<sin_addr))); + + if (v_circuit) { + int truncated; + struct iovec iov[2]; + u_short len; + u_char *cp; + + /* + * Use virtual circuit; + * at most one attempt per server. + */ + try = _res.retry; + truncated = 0; + if ((s < 0) || (!vc)) { + if (s >= 0) + _res_close(); + + s = socket(AF_INET, SOCK_STREAM, PF_UNSPEC); + if (s < 0) { + terrno = errno; + Perror(stderr, "socket(vc)", errno); + return (-1); + } + if (connect(s, + (struct sockaddr *)nsap, + sizeof(struct sockaddr)) + < 0) { + terrno = errno; + Aerror(stderr, "connect/vc", + errno, *nsap); + badns |= (1< 0) { + cp += n; + if ((len -= n) <= 0) + break; + } + if (n <= 0) { + terrno = errno; + Perror(stderr, "read failed", errno); + _res_close(); + /* + * A long running process might get its TCP + * connection reset if the remote server was + * restarted. Requery the server instead of + * trying a new one. When there is only one + * server, this means that a query might work + * instead of failing. We only allow one reset + * per query to prevent looping. + */ + if (terrno == ECONNRESET && !connreset) { + connreset = 1; + _res_close(); + goto same_ns; + } + _res_close(); + goto next_ns; + } + resplen = _getshort(ans); + if (resplen > anssiz) { + Dprint(_res.options & RES_DEBUG, + (stdout, ";; response truncated\n") + ); + truncated = 1; + len = anssiz; + } else + len = resplen; + cp = ans; + while (len != 0 && + (n = read(s, (char *)cp, (int)len)) > 0 + ) { + cp += n; + len -= n; + } + if (n <= 0) { + terrno = errno; + Perror(stderr, "read(vc)", errno); + _res_close(); + goto next_ns; + } + if (truncated) { + /* + * Flush rest of answer + * so connection stays in synch. + */ + anhp->tc = 1; + len = resplen - anssiz; + while (len != 0) { + char junk[512]; + + n = (len > sizeof(junk) + ? sizeof(junk) + : len); + if ((n = read(s, junk, n)) > 0) + len -= n; + else + break; + } + } + } else { + /* + * Use datagrams. + */ + struct timeval timeout; + fd_set dsmask; + struct sockaddr_in from; + int fromlen; + + if ((s < 0) || vc) { + if (vc) + _res_close(); + s = socket(AF_INET, SOCK_DGRAM, PF_UNSPEC); + if (s < 0) { + bad_dg_sock: terrno = errno; + Perror(stderr, "socket(dg)", errno); + return (-1); + } + connected = 0; + } + /* + * On a 4.3BSD+ machine (client and server, + * actually), sending to a nameserver datagram + * port with no nameserver will cause an + * ICMP port unreachable message to be returned. + * If our datagram socket is "connected" to the + * server, we get an ECONNREFUSED error on the next + * socket operation, and select returns if the + * error message is received. We can thus detect + * the absence of a nameserver without timing out. + * If we have sent queries to at least two servers, + * however, we don't want to remain connected, + * as we wish to receive answers from the first + * server to respond. + */ + if (_res.nscount == 1 || (try == 0 && ns == 0)) { + /* + * Connect only if we are sure we won't + * receive a response from another server. + */ + if (!connected) { + if (connect(s, + (struct sockaddr *)nsap, + sizeof(struct sockaddr) + ) < 0 + ) { + Aerror(stderr, + "connect(dg)", + errno, *nsap); + badns |= (1<= 199103) + struct sockaddr_in no_addr; + + no_addr.sin_family = AF_INET; + no_addr.sin_addr.s_addr = INADDR_ANY; + no_addr.sin_port = 0; + (void) connect(s, + (struct sockaddr *) + &no_addr, + sizeof(no_addr)); +#else + int s1 = socket(AF_INET, SOCK_DGRAM, + PF_UNSPEC); + if (s1 < 0) + goto bad_dg_sock; + (void) dup2(s1, s); + (void) close(s1); + Dprint(_res.options & RES_DEBUG, + (stdout, ";; new DG socket\n")) +#endif + connected = 0; + errno = 0; + } + if (sendto(s, buf, buflen, 0, + (struct sockaddr *)nsap, + sizeof(struct sockaddr)) + != buflen) { + Aerror(stderr, "sendto", errno, *nsap); + badns |= (1< 0) + timeout.tv_sec /= _res.nscount; + if ((long) timeout.tv_sec <= 0) + timeout.tv_sec = 1; + timeout.tv_usec = 0; + wait: + FD_ZERO(&dsmask); + FD_SET(s, &dsmask); + n = select(s+1, &dsmask, (fd_set *)NULL, + (fd_set *)NULL, &timeout); + if (n < 0) { + Perror(stderr, "select", errno); + _res_close(); + goto next_ns; + } + if (n == 0) { + /* + * timeout + */ + Dprint(_res.options & RES_DEBUG, + (stdout, ";; timeout\n") + ); + gotsomewhere = 1; + _res_close(); + goto next_ns; + } + fromlen = sizeof(struct sockaddr_in); + resplen = recvfrom(s, ans, anssiz, 0, + (struct sockaddr *)&from, &fromlen); + if (resplen <= 0) { + Perror(stderr, "recvfrom", errno); + _res_close(); + goto next_ns; + } + gotsomewhere = 1; + if (hp->id != anhp->id) { + /* + * response from old query, ignore it. + * XXX - potential security hazard could + * be detected here. + */ + DprintQ((_res.options & RES_DEBUG) || + (_res.pfcode & RES_PRF_REPLY), + (stdout, ";; old answer:\n"), + ans); + goto wait; + } +#if CHECK_SRVR_ADDR + if (!(_res.options & RES_INSECURE1) && + !our_server(&from)) { + /* + * response from wrong server? ignore it. + * XXX - potential security hazard could + * be detected here. + */ + DprintQ((_res.options & RES_DEBUG) || + (_res.pfcode & RES_PRF_REPLY), + (stdout, ";; not our server:\n"), + ans); + goto wait; + } +#endif + if (!(_res.options & RES_INSECURE2) && + !queries_match(buf, buf + buflen, + ans, ans + anssiz)) { + /* + * response contains wrong query? ignore it. + * XXX - potential security hazard could + * be detected here. + */ + DprintQ((_res.options & RES_DEBUG) || + (_res.pfcode & RES_PRF_REPLY), + (stdout, ";; wrong query name:\n"), + ans); + goto wait; + } + if (anhp->rcode == SERVFAIL || + anhp->rcode == NOTIMP || + anhp->rcode == REFUSED) { + DprintQ(_res.options & RES_DEBUG, + (stdout, "server rejected query:\n"), + ans); + badns |= (1<tc) { + /* + * get rest of answer; + * use TCP with same server. + */ + Dprint(_res.options & RES_DEBUG, + (stdout, ";; truncated answer\n") + ); + v_circuit = 1; + _res_close(); + goto same_ns; + } + } /*if vc/dg*/ + DprintQ((_res.options & RES_DEBUG) || + (_res.pfcode & RES_PRF_REPLY), + (stdout, ";; got answer:\n"), + ans); + /* + * If using virtual circuits, we assume that the first server + * is preferred over the rest (i.e. it is on the local + * machine) and only keep that one open. + * If we have temporarily opened a virtual circuit, + * or if we haven't been asked to keep a socket open, + * close the socket. + */ + if ((v_circuit && (!(_res.options & RES_USEVC) || ns != 0)) || + !(_res.options & RES_STAYOPEN)) { + _res_close(); + } + if (Rhook) { + int done = 0, loops = 0; + + do { + res_sendhookact act; + + act = (*Rhook)(nsap, + buf, + buflen, + ans, + anssiz, + &resplen); + switch (act) { + case res_goahead: + case res_done: + done = 1; + break; + case res_nextns: + _res_close(); + goto next_ns; + case res_modified: + /* give the hook another try */ + if (++loops < 42) /*doug adams*/ + break; + /*FALLTHROUGH*/ + case res_error: + /*FALLTHROUGH*/ + default: + return (-1); + } + } while (!done); + + } + return (resplen); + next_ns: ; + } /*foreach ns*/ + } /*foreach retry*/ + _res_close(); + if (!v_circuit) { + if (!gotsomewhere) + errno = ECONNREFUSED; /* no nameservers found */ + else + errno = ETIMEDOUT; /* no answer obtained */ + } else { + errno = terrno; + } + return (-1); +} + +/* + * This routine is for closing the socket if a virtual circuit is used and + * the program wants to close it. This provides support for endhostent() + * which expects to close the socket. + * + * This routine is not expected to be user visible. + */ +void +_res_close() +{ + if (s >= 0) { + (void) close(s); + s = -1; + connected = 0; + vc = 0; + } +} diff -ruN glibc-1.08.1/resolv/resolv.h glibc-1.09/resolv/resolv.h --- glibc-1.08.1/resolv/resolv.h Wed Dec 31 19:00:00 1969 +++ glibc-1.09/resolv/resolv.h Thu Jul 28 17:56:31 1994 @@ -0,0 +1,232 @@ +/* + * ++Copyright++ 1983, 1987, 1989, 1993 + * - + * Copyright (c) 1983, 1987, 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. + * - + * 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-- + */ + +/* + * @(#)resolv.h 8.1 (Berkeley) 6/2/93 + * $Id: resolv.h,v 1.4 1994/07/28 21:56:30 roland Exp $ + */ + +#ifndef _RESOLV_H_ +#define _RESOLV_H_ + +#include +#if (!defined(BSD)) || (BSD < 199306) +# include +#else +# include +#endif +#include +#include + +/* + * revision information. this is the release date in YYYYMMDD format. + * it can change every day so the right thing to do with it is use it + * in preprocessor commands such as "#if (__RES > 19931104)". do not + * compare for equality; rather, use it to determine whether your resolver + * is new enough to contain a certain feature. + */ + +#define __RES 19940415 + +/* + * Resolver configuration file. + * Normally not present, but may contain the address of the + * inital name server(s) to query and the domain search list. + */ + +#ifndef _PATH_RESCONF +#define _PATH_RESCONF "/etc/resolv.conf" +#endif + +/* + * Global defines and variables for resolver stub. + */ +#define MAXNS 3 /* max # name servers we'll track */ +#define MAXDFLSRCH 3 /* # default domain levels to try */ +#define MAXDNSRCH 6 /* max # domains in search path */ +#define LOCALDOMAINPARTS 2 /* min levels in name that is "local" */ + +#define RES_TIMEOUT 5 /* min. seconds between retries */ +#define MAXRESOLVSORT 10 /* number of net to sort on */ +#define RES_MAXNDOTS 15 /* should reflect bit field size */ + +struct __res_state { + int retrans; /* retransmition time interval */ + int retry; /* number of times to retransmit */ + u_long options; /* option flags - see below. */ + int nscount; /* number of name servers */ + struct sockaddr_in + nsaddr_list[MAXNS]; /* address of name server */ +#define nsaddr nsaddr_list[0] /* for backward compatibility */ + u_short id; /* current packet id */ + char *dnsrch[MAXDNSRCH+1]; /* components of domain to search */ + char defdname[MAXDNAME]; /* default domain */ + u_long pfcode; /* RES_PRF_ flags - see below. */ + unsigned ndots:4; /* threshold for initial abs. query */ + unsigned nsort:4; /* number of elements in sort_list[] */ + char unused[3]; + struct { + struct in_addr addr; + u_int32_t mask; + } sort_list[MAXRESOLVSORT]; +}; + +/* + * Resolver options (keep these in synch with res_debug.c, please) + */ +#define RES_INIT 0x00000001 /* address initialized */ +#define RES_DEBUG 0x00000002 /* print debug messages */ +#define RES_AAONLY 0x00000004 /* authoritative answers only */ +#define RES_USEVC 0x00000008 /* use virtual circuit */ +#define RES_PRIMARY 0x00000010 /* query primary server only */ +#define RES_IGNTC 0x00000020 /* ignore trucation errors */ +#define RES_RECURSE 0x00000040 /* recursion desired */ +#define RES_DEFNAMES 0x00000080 /* use default domain name */ +#define RES_STAYOPEN 0x00000100 /* Keep TCP socket open */ +#define RES_DNSRCH 0x00000200 /* search up local domain tree */ +#define RES_INSECURE1 0x00000400 /* type 1 security disabled */ +#define RES_INSECURE2 0x00000800 /* type 2 security disabled */ + +#define RES_DEFAULT (RES_RECURSE | RES_DEFNAMES | RES_DNSRCH) + +/* + * Resolver "pfcode" values. Used by dig. + */ +#define RES_PRF_STATS 0x00000001 +/* 0x00000002 */ +#define RES_PRF_CLASS 0x00000004 +#define RES_PRF_CMD 0x00000008 +#define RES_PRF_QUES 0x00000010 +#define RES_PRF_ANS 0x00000020 +#define RES_PRF_AUTH 0x00000040 +#define RES_PRF_ADD 0x00000080 +#define RES_PRF_HEAD1 0x00000100 +#define RES_PRF_HEAD2 0x00000200 +#define RES_PRF_TTLID 0x00000400 +#define RES_PRF_HEADX 0x00000800 +#define RES_PRF_QUERY 0x00001000 +#define RES_PRF_REPLY 0x00002000 +#define RES_PRF_INIT 0x00004000 +/* 0x00008000 */ + +/* hooks are still experimental as of 4.9.2 */ +typedef enum { res_goahead, res_nextns, res_modified, res_done, res_error } + res_sendhookact; + +typedef res_sendhookact (*res_send_qhook)__P((struct sockaddr_in * const *ns, + const u_char **query, + int *querylen, + u_char *ans, + int anssiz, + int *resplen)); + +typedef res_sendhookact (*res_send_rhook)__P((const struct sockaddr_in *ns, + const u_char *query, + int querylen, + u_char *ans, + int anssiz, + int *resplen)); + +extern struct __res_state _res; + +/* Private routines shared between libc/net, named, nslookup and others. */ +#define dn_skipname __dn_skipname +#define fp_query __fp_query +#define fp_nquery __fp_nquery +#define hostalias __hostalias +#define putlong __putlong +#define putshort __putshort +#define p_class __p_class +#define p_time __p_time +#define p_type __p_type +#define p_cdnname __p_cdnname +#define p_cdname __p_cdname +#define p_fqname __p_fqname +#define p_rr __p_rr +#define p_option __p_option +__BEGIN_DECLS +int __dn_skipname __P((const u_char *, const u_char *)); +void __fp_resstat __P((struct __res_state *, FILE *)); +void __fp_query __P((const u_char *, FILE *)); +void __fp_nquery __P((const u_char *, int, FILE *)); +char *__hostalias __P((const char *)); +void __putlong __P((u_int32_t, u_char *)); +void __putshort __P((u_int16_t, u_char *)); +char *__p_time __P((u_int32_t)); +void __p_query __P((const u_char *)); +const u_char *__p_cdnname __P((const u_char *, const u_char *, int, FILE *)); +const u_char *__p_cdname __P((const u_char *, const u_char *, FILE *)); +const u_char *__p_fqname __P((const u_char *, const u_char *, FILE *)); +const u_char *__p_rr __P((const u_char *, const u_char *, FILE *)); +const char *__p_type __P((int)); +const char *__p_class __P((int)); +const char *__p_option __P((u_long option)); +int dn_comp __P((const char *, u_char *, int, u_char **, u_char **)); +int dn_expand __P((const u_char *, const u_char *, const u_char *, + char *, int)); +int res_init __P((void)); +int res_query __P((const char *, int, int, u_char *, int)); +int res_search __P((const char *, int, int, u_char *, int)); +int res_querydomain __P((const char *, const char *, int, int, + u_char *, int)); +int res_mkquery __P((int, const char *, int, int, const u_char *, int, + const u_char *, u_char *, int)); +int res_send __P((const u_char *, int, u_char *, int)); +/* XXX - these last two don't belong in the resolver */ +u_int inet_nsap_addr __P((const char *, u_char *, int maxlen)); +char *inet_nsap_ntoa __P((int, const u_char *, char *ascii)); +__END_DECLS + +#endif /* !_RESOLV_H_ */ diff -ruN glibc-1.08.1/resolv/sethostent.c glibc-1.09/resolv/sethostent.c --- glibc-1.08.1/resolv/sethostent.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/resolv/sethostent.c Thu Jul 28 17:56:32 1994 @@ -0,0 +1,80 @@ +/* + * ++Copyright++ 1985, 1993 + * - + * 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. + * - + * --Copyright-- + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)sethostent.c 8.1 (Berkeley) 6/4/93"; +static char rcsid[] = "$Id: sethostent.c,v 1.2 1994/07/28 21:56:31 roland Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include +#include +#include +#include + +void +sethostent(stayopen) + int stayopen; +{ + if (stayopen) + _res.options |= RES_STAYOPEN | RES_USEVC; +} + +void +endhostent() +{ + _res.options &= ~(RES_STAYOPEN | RES_USEVC); + _res_close(); +} diff -ruN glibc-1.08.1/resolv/sys/bitypes.h glibc-1.09/resolv/sys/bitypes.h --- glibc-1.08.1/resolv/sys/bitypes.h Wed Dec 31 19:00:00 1969 +++ glibc-1.09/resolv/sys/bitypes.h Mon Jul 18 18:00:32 1994 @@ -0,0 +1,3 @@ +/* The GNU defines all the necessary types. */ + +#include diff -ruN glibc-1.08.1/signal/signal.h glibc-1.09/signal/signal.h --- glibc-1.08.1/signal/signal.h Sat May 21 16:15:07 1994 +++ glibc-1.09/signal/signal.h Wed Aug 17 15:59:39 1994 @@ -238,8 +238,8 @@ #include /* Restore the state saved in SCP. */ -extern int __sigreturn __P ((__const struct sigcontext *__scp)); -extern int sigreturn __P ((__const struct sigcontext *__scp)); +extern int __sigreturn __P ((struct sigcontext *__scp)); +extern int sigreturn __P ((struct sigcontext *__scp)); #endif /* signal.h included and use BSD. */ diff -ruN glibc-1.08.1/signal/sigret.c glibc-1.09/signal/sigret.c --- glibc-1.08.1/signal/sigret.c Thu Apr 9 22:10:30 1992 +++ glibc-1.09/signal/sigret.c Thu Aug 25 23:56:18 1994 @@ -1,4 +1,4 @@ -/* Copyright (C) 1992 Free Software Foundation, Inc. +/* Copyright (C) 1992, 1994 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -23,4 +23,4 @@ #undef sigreturn function_alias(sigreturn, __sigreturn, int, (context), - DEFUN(sigreturn, (context), CONST struct sigcontext *context)) + DEFUN(sigreturn, (context), struct sigcontext *context)) diff -ruN glibc-1.08.1/socket/sys/socket.h glibc-1.09/socket/sys/socket.h --- glibc-1.08.1/socket/sys/socket.h Fri May 27 01:35:14 1994 +++ glibc-1.09/socket/sys/socket.h Thu Oct 13 22:07:44 1994 @@ -44,7 +44,6 @@ #define PF_UNSPEC 0 /* Unspecified. */ #define PF_LOCAL 1 /* Local to host (pipes and file-domain). */ #define PF_UNIX PF_LOCAL /* Old BSD name for PF_LOCAL. */ -#define PF_FILE PF_LOCAL /* XXX old GNU name for PF_LOCAL. */ #define PF_INET 2 /* IP protocol family. */ #define PF_IMPLINK 3 /* ARPAnet IMP protocol. */ #define PF_PUP 4 /* PUP protocols. */ @@ -63,11 +62,18 @@ #define PF_APPLETALK 16 /* Don't use this. */ #define PF_ROUTE 17 /* Internal Routing Protocol. */ #define PF_LINK 18 /* Link layer interface. */ -#define PF_MAX 19 +#define PF_XTP 19 /* eXpress Transfer Protocol (no AF). */ +#define PF_COIP 20 /* Connection-oriented IP, aka ST II. */ +#define PF_CNT 21 /* Computer Network Technology. */ +#define PF_RTIP 22 /* Help Identify RTIP packets. **/ +#define PF_IPX 23 /* Novell Internet Protocol. */ +#define PF_SIP 24 /* Simple Internet Protocol. */ +#define PF_PIP 25 /* Help Identify PIP packets. */ +#define PF_MAX 26 /* Address families. */ #define AF_UNSPEC PF_UNSPEC -#define AF_FILE PF_FILE +#define AF_LOCAL PF_LOCAL #define AF_UNIX PF_UNIX #define AF_INET PF_INET #define AF_IMPLINK PF_IMPLINK @@ -87,6 +93,13 @@ #define AF_APPLETALK PF_APPLETALK #define AF_ROUTE PF_ROUTE #define AF_LINK PF_LINK +#define pseudo_AF_XTP PF_XTP +#define AF_COIP PF_COIP +#define AF_CNT PF_CNT +#define pseudo_AF_RTIP PF_RTIP +#define AF_IPX PF_IPX +#define AF_SIP PF_SIP +#define pseudo_AF_PIP PF_PIP #define AF_MAX PF_MAX @@ -97,6 +110,29 @@ char sa_data[14]; /* Address data. */ }; +/* This is the type we use for generic socket address arguments. + + NOTE: Since this functionality is volatile, I'm disabling the use of it for + now. + + With GCC 2.6 and later, the funky union causes redeclarations or uses with + any of the listed types to be allowed without complaint. */ +#if (!defined (__GNUC__) || __GNUC__ < 2 || \ + /*(__GNUC__ == 2 && __GNUC_MINOR__ < 6)*/ 1) +#define __SOCKADDR_ARG struct sockaddr * +#else +/* Bring these names into being at top-level scope, in case they have not been + defined yet. Add more `struct sockaddr_AF' types here as necessary. */ +struct sockaddr_in; +struct sockaddr_un; +struct sockaddr_ns; +typedef union { struct sockaddr *__sa; + struct sockaddr_in *__sa_in; + struct sockaddr_un *__sa_un; + struct sockaddr_ns *__sa_ns; + } __SOCKADDR_ARG __attribute__ ((transparent_union)); +#endif + /* Create a new socket of type TYPE in domain DOMAIN, using protocol PROTOCOL. If PROTOCOL is zero, one is chosen automatically. @@ -112,30 +148,35 @@ int __protocol, int __fds[2])); /* Give the socket FD the local address ADDR (which is LEN bytes long). */ -extern int bind __P ((int __fd, struct sockaddr * __addr, size_t __len)); +extern int bind __P ((int __fd, __SOCKADDR_ARG __addr, size_t __len)); /* Put the local address of FD into *ADDR and its length in *LEN. */ -extern int getsockname __P ((int __fd, struct sockaddr * __addr, - size_t * __len)); +extern int getsockname __P ((int __fd, __SOCKADDR_ARG __addr, + size_t *__len)); /* Open a connection on socket FD to peer at ADDR (which LEN bytes long). For connectionless socket types, just set the default address to send to and the only address from which to accept transmissions. Return 0 on success, -1 for errors. */ -extern int connect __P ((int __fd, struct sockaddr * __addr, size_t __len)); +extern int connect __P ((int __fd, __SOCKADDR_ARG __addr, size_t __len)); /* Put the address of the peer connected to socket FD into *ADDR (which is *LEN bytes long), and its actual length into *LEN. */ -extern int getpeername __P ((int __fd, struct sockaddr * __addr, - size_t * __len)); +extern int getpeername __P ((int __fd, __SOCKADDR_ARG __addr, + size_t *__len)); /* Bits in the FLAGS argument to `send', `recv', et al. */ enum { - MSG_OOB = 1, /* Process out-of-band data. */ - MSG_PEEK = 2, /* Peek at incoming messages. */ - MSG_DONTROUTE = 4, /* Don't use local routing. */ + MSG_OOB = 0x01, /* Process out-of-band data. */ + MSG_PEEK = 0x02, /* Peek at incoming messages. */ + MSG_DONTROUTE = 0x04, /* Don't use local routing. */ + MSG_EOR = 0x08, /* Data completes record. */ + MSG_TRUNC = 0x10, /* Data discarded before delivery. */ + MSG_CTRUNC = 0x20, /* Control data lost before delivery. */ + MSG_WAITALL = 0x40, /* Wait for full request or error. */ + MSG_DONTWAIT = 0x80, /* This message should be nonblocking. */ }; /* Send N bytes of BUF to socket FD. Returns the number sent or -1. */ @@ -148,14 +189,14 @@ /* Send N bytes of BUF on socket FD to peer at address ADDR (which is ADDR_LEN bytes long). Returns the number sent, or -1 for errors. */ extern int sendto __P ((int __fd, __ptr_t __buf, size_t __n, int __flags, - struct sockaddr * __addr, size_t __addr_len)); + __SOCKADDR_ARG __addr, size_t __addr_len)); /* Read N bytes into BUF through socket FD. If ADDR is not NULL, fill in *ADDR_LEN bytes of it with tha address of the sender, and store the actual size of the address in *ADDR_LEN. Returns the number of bytes read or -1 for errors. */ extern int recvfrom __P ((int __fd, __ptr_t __buf, size_t __n, int __flags, - struct sockaddr * __addr, size_t * __addr_len)); + __SOCKADDR_ARG __addr, size_t *__addr_len)); @@ -175,12 +216,12 @@ /* Send a message described MESSAGE on socket FD. Returns the number of bytes sent, or -1 for errors. */ -extern int sendmsg __P ((int __fd, __const struct msghdr * __message, +extern int sendmsg __P ((int __fd, __const struct msghdr *__message, int __flags)); /* Receive a message as described by MESSAGE from socket FD. Returns the number of bytes read or -1 for errors. */ -extern int recvmsg __P ((int __fd, struct msghdr * __message, int __flags)); +extern int recvmsg __P ((int __fd, struct msghdr *__message, int __flags)); /* Protocol number used to manipulate socket-level options @@ -204,6 +245,8 @@ socket to transmit pending data. */ SO_OOBINLINE = 0x0100, /* Receive out-of-band data in-band. */ + SO_REUSEPORT = 0x0200, /* Allow local address and port reuse. */ + SO_SNDBUF = 0x1001, /* Send buffer size. */ SO_RCVBUF = 0x1002, /* Receive buffer. */ SO_SNDLOWAT = 0x1003, /* Send low-water mark. */ @@ -228,7 +271,7 @@ into OPTVAL (which is *OPTLEN bytes long), and set *OPTLEN to the value's actual length. Returns 0 on success, -1 for errors. */ extern int getsockopt __P ((int __fd, int __level, int __optname, - __ptr_t __optval, size_t * __optlen)); + __ptr_t __optval, size_t *__optlen)); /* Set socket FD's option OPTNAME at protocol level LEVEL to *OPTVAL (which is OPTLEN bytes long). @@ -247,8 +290,8 @@ set *ADDR (which is *ADDR_LEN bytes long) to the address of the connecting peer and *ADDR_LEN to the address's actual length, and return the new socket's descriptor, or -1 for errors. */ -extern int accept __P ((int __fd, struct sockaddr * __addr, - size_t * __addr_len)); +extern int accept __P ((int __fd, __SOCKADDR_ARG __addr, + size_t *__addr_len)); /* Shut down all or part of the connection open on socket FD. HOW determines what to shut down: diff -ruN glibc-1.08.1/stddef.h glibc-1.09/stddef.h --- glibc-1.08.1/stddef.h Mon Apr 25 14:13:23 1994 +++ glibc-1.09/stddef.h Fri Oct 7 19:22:35 1994 @@ -35,9 +35,13 @@ #ifndef _PTRDIFF_T_ #define _PTRDIFF_T #endif +/* On BSD/386 1.1, at least, machine/ansi.h defines _BSD_WCHAR_T_ + instead of _WCHAR_T_. */ #ifndef _WCHAR_T_ +#ifndef _BSD_WCHAR_T_ #define _WCHAR_T #endif +#endif /* Undef _FOO_T_ if we are supposed to define foo_t. */ #if defined (__need_ptrdiff_t) || defined (_STDDEF_H_) #undef _PTRDIFF_T_ @@ -109,6 +113,7 @@ #ifndef _T_SIZE #ifndef __SIZE_T #ifndef _SIZE_T_ +#ifndef _SIZE_T_DEFINED_ #ifndef ___int_size_t_h #ifndef _GCC_SIZE_T #ifndef _SIZET_ @@ -119,6 +124,7 @@ #define _T_SIZE #define __SIZE_T #define _SIZE_T_ +#define _SIZE_T_DEFINED_ #define ___int_size_t_h #define _GCC_SIZE_T #define _SIZET_ @@ -133,6 +139,7 @@ #endif /* _SIZET_ */ #endif /* _GCC_SIZE_T */ #endif /* ___int_size_t_h */ +#endif /* _SIZE_T_DEFINED_ */ #endif /* _SIZE_T_ */ #endif /* __SIZE_T */ #endif /* _T_SIZE */ @@ -156,6 +163,7 @@ #ifndef _T_WCHAR #ifndef __WCHAR_T #ifndef _WCHAR_T_ +#ifndef _WCHAR_T_DEFINED_ #ifndef _WCHAR_T_H #ifndef ___int_wchar_t_h #ifndef __INT_WCHAR_T_H @@ -165,10 +173,31 @@ #define _T_WCHAR #define __WCHAR_T #define _WCHAR_T_ +#define _WCHAR_T_DEFINED_ #define _WCHAR_T_H #define ___int_wchar_t_h #define __INT_WCHAR_T_H #define _GCC_WCHAR_T + +/* On BSD/386 1.1, at least, machine/ansi.h defines _BSD_WCHAR_T_ + instead of _WCHAR_T_, and _BSD_RUNE_T_ (which, unlike the other + symbols in the _FOO_T_ family, stays defined even after its + corresponding type is defined). If we define wchar_t, then we + must undef _WCHAR_T_; for BSD/386 1.1 (and perhaps others), if + we undef _WCHAR_T_, then we must also define rune_t, since + headers like runetype.h assume that if machine/ansi.h is included, + and _BSD_WCHAR_T_ is not defined, then rune_t is available. + machine/ansi.h says, "Note that _WCHAR_T_ and _RUNE_T_ must be of + the same type." */ +#ifdef _BSD_WCHAR_T_ +#undef _BSD_WCHAR_T_ +#ifdef _BSD_RUNE_T_ +#if !defined (_ANSI_SOURCE) && !defined (_POSIX_SOURCE) +typedef _BSD_RUNE_T_ rune_t; +#endif +#endif +#endif + #ifndef __WCHAR_TYPE__ #define __WCHAR_TYPE__ int #endif @@ -182,12 +211,15 @@ #endif #endif #endif +#endif #undef __need_wchar_t #endif /* _STDDEF_H or __need_wchar_t. */ /* In 4.3bsd-net2, leave these undefined to indicate that size_t, etc. are already defined. */ #ifdef _ANSI_H_ +/* The references to _GCC_PTRDIFF_T_, _GCC_SIZE_T_, and _GCC_WCHAR_T_ + are probably typos and should be removed before 2.7 is released. */ #ifdef _GCC_PTRDIFF_T_ #undef _PTRDIFF_T_ #endif @@ -195,6 +227,16 @@ #undef _SIZE_T_ #endif #ifdef _GCC_WCHAR_T_ +#undef _WCHAR_T_ +#endif +/* The following ones are the real ones. */ +#ifdef _GCC_PTRDIFF_T +#undef _PTRDIFF_T_ +#endif +#ifdef _GCC_SIZE_T +#undef _SIZE_T_ +#endif +#ifdef _GCC_WCHAR_T #undef _WCHAR_T_ #endif #endif /* _ANSI_H_ */ diff -ruN glibc-1.08.1/stdio/Makefile glibc-1.09/stdio/Makefile --- glibc-1.08.1/stdio/Makefile Mon May 23 19:35:36 1994 +++ glibc-1.09/stdio/Makefile Fri Oct 28 01:44:31 1994 @@ -51,7 +51,7 @@ # Several mpn functions from GNU MP are used by the printf_fp function. mpn-routines := add_1 add_n addmul_1 cmp divmod divmod_1 udiv_qrnnd \ lshift rshift mod_1 mul mul_1 mul_n sub_n submul_1 -mpn-headers = longlong.h gmp.h gmp-impl.h gmp-mparam.h asm.h +mpn-headers = longlong.h gmp.h gmp-impl.h gmp-mparam.h asm-syntax.h routines := $(strip $(routines) $(mpn-routines)) dbl2mpn aux := errlist siglist defs syms-stdio glue mp_clz_tab @@ -74,7 +74,7 @@ mpn-sysdep := $(addsuffix .c,$(mpn-routines)) \ $(addsuffix .S,$(mpn-routines)) \ - $(addsuffix .s,$(mpn-routines)) gmp-mparam.h asm.h + $(addsuffix .s,$(mpn-routines)) gmp-mparam.h asm-syntax.h mpn-try := $(addprefix $(gmp-srcdir)/mpn/*/,$(mpn-sysdep)) mpn-found := $(wildcard $(mpn-try)) diff -ruN glibc-1.08.1/stdio/__vfscanf.c glibc-1.09/stdio/__vfscanf.c --- glibc-1.08.1/stdio/__vfscanf.c Thu Feb 3 21:11:03 1994 +++ glibc-1.09/stdio/__vfscanf.c Mon Oct 10 05:25:32 1994 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -162,7 +162,7 @@ /* Check for type modifiers. */ is_short = is_long = is_long_double = malloc_string = 0; - while (*f == 'h' || *f == 'l' || *f == 'L') + while (*f == 'h' || *f == 'l' || *f == 'L' || *f == 'a' || *f == 'q') switch (*f++) { case 'h': @@ -177,6 +177,7 @@ /* int's are long int's. */ is_long = 1; break; + case 'q': case 'L': /* double's are long double's, and int's are long long int's. */ is_long_double = 1; diff -ruN glibc-1.08.1/stdio/_itoa.c glibc-1.09/stdio/_itoa.c --- glibc-1.08.1/stdio/_itoa.c Sat Feb 5 15:39:04 1994 +++ glibc-1.09/stdio/_itoa.c Mon Jul 18 18:01:59 1994 @@ -27,7 +27,7 @@ char * DEFUN(_itoa, (value, buflim, base, upper_case), - unsigned long int value AND char *buflim AND + unsigned long long int value AND char *buflim AND unsigned int base AND int upper_case) { /* Base-36 digits for numbers. */ diff -ruN glibc-1.08.1/stdio/_itoa.h glibc-1.09/stdio/_itoa.h --- glibc-1.08.1/stdio/_itoa.h Thu Feb 3 21:06:45 1994 +++ glibc-1.09/stdio/_itoa.h Mon Jul 18 18:01:59 1994 @@ -28,12 +28,12 @@ Return the address of the first (left-to-right) character in the number. Use upper case letters iff UPPER_CASE is nonzero. */ -extern char *_itoa __P ((unsigned long int value, char *buflim, +extern char *_itoa __P ((unsigned long long int value, char *buflim, unsigned int base, int upper_case)); #if defined (__GNUC__) && defined (__OPTIMIZE__) extern __inline char * -_itoa (unsigned long int value, char *buflim, +_itoa (unsigned long long int value, char *buflim, unsigned int base, int upper_case) { /* Base-36 digits for numbers. */ diff -ruN glibc-1.08.1/stdio/freopen.c glibc-1.09/stdio/freopen.c --- glibc-1.08.1/stdio/freopen.c Tue May 31 20:10:52 1994 +++ glibc-1.09/stdio/freopen.c Mon Jul 18 18:02:10 1994 @@ -24,6 +24,9 @@ /* Defined in fopen.c. */ extern int __getmode __P ((const char *, __io_mode *)); +/* Defined in sysd-stdio.c. */ +extern int __stdio_reopen __P ((const char *filename, __io_mode mode, + PTR *cookieptr, __io_close_fn closefn)); /* Replace STREAM, opening it on FILENAME. */ FILE * @@ -46,7 +49,10 @@ /* Open the file, attempting to preserve the old cookie value. */ cookie = stream->__cookie; - if (__stdio_reopen (filename, m, &cookie, stream->__io_funcs.__close)) + if (__stdio_reopen (filename, m, &cookie, + stream->__seen ? + stream->__io_funcs.__close : + __stdio_close)) { int save = errno; (void) fclose (stream); diff -ruN glibc-1.08.1/stdio/ftell.c glibc-1.09/stdio/ftell.c --- glibc-1.08.1/stdio/ftell.c Fri Oct 2 18:13:45 1992 +++ glibc-1.09/stdio/ftell.c Tue Oct 25 21:35:31 1994 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1992 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1992, 1994 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -36,13 +36,19 @@ if (__stdio_check_offset (stream) == EOF) return -1L; - pos = stream->__target + (stream->__bufp - stream->__buffer); + /* Start with the file position associated with the beginning + of our buffer. */ + pos = stream->__target; if (stream->__pushed_back) - /* Calling ungetc is supposed to decrement the file position. - ANSI says the file position is unspecified if you ungetc when - the position is zero; -1 seems as good as anything to me. */ - --pos; + /* ungetc was just called, so our real buffer pointer is squirreled + away in STREAM->__pushback_bufp, not in STREAM->__bufp as normal. + Calling ungetc is supposed to decrement the file position. ANSI + says the file position is unspecified if you ungetc when the + position is zero; -1 seems as good as anything to me. */ + pos += stream->__pushback_bufp - stream->__buffer - 1; + else + pos += stream->__bufp - stream->__buffer; return pos; } diff -ruN glibc-1.08.1/stdio/fwrite.c glibc-1.09/stdio/fwrite.c --- glibc-1.08.1/stdio/fwrite.c Wed Apr 21 17:23:19 1993 +++ glibc-1.09/stdio/fwrite.c Thu Oct 27 23:59:37 1994 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -33,7 +33,7 @@ register size_t written = 0; int newlinep; size_t buffer_space; - char default_func; + int default_func; if (!__validfp (stream) || !stream->__mode.__write) { @@ -157,6 +157,10 @@ /* We've filled the buffer, so flush it. */ if (fflush (stream) == EOF) break; + /* Reset our record of the space available in the buffer, + since we have just flushed it. */ + buffer_space = (stream->__bufsize - + (stream->__bufp - stream->__buffer)); } } else diff -ruN glibc-1.08.1/stdio/gmp-impl.h glibc-1.09/stdio/gmp-impl.h --- glibc-1.08.1/stdio/gmp-impl.h Mon May 16 21:58:03 1994 +++ glibc-1.09/stdio/gmp-impl.h Tue Aug 2 20:59:06 1994 @@ -28,9 +28,7 @@ #define NULL 0L #endif -#if defined (__GNUC__) -volatile void abort (void); -#else +#if ! defined (__GNUC__) #define inline /* Empty */ void *alloca(); #endif diff -ruN glibc-1.08.1/stdio/gmp.h glibc-1.09/stdio/gmp.h --- glibc-1.08.1/stdio/gmp.h Sat May 21 18:25:17 1994 +++ glibc-1.09/stdio/gmp.h Tue Aug 2 20:59:05 1994 @@ -142,6 +142,8 @@ /**************** Integer (i.e. Z) routines. ****************/ +void *_mpz_realloc _PROTO ((mpz_ptr, mp_size_t)); + void mpz_abs _PROTO ((mpz_ptr, mpz_srcptr)); void mpz_add _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr)); void mpz_add_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int)); @@ -152,19 +154,12 @@ int mpz_cmp_si _PROTO ((mpz_srcptr, signed long int)); int mpz_cmp_ui _PROTO ((mpz_srcptr, unsigned long int)); void mpz_com _PROTO ((mpz_ptr, mpz_srcptr)); -void mpz_div _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr)); void mpz_div_2exp _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int)); -void mpz_div_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int)); -void mpz_divmod _PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr)); -void mpz_divmod_floor _PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr)); -void mpz_divmod_floor_ui _PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int)); -void mpz_divmod_trunc _PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr)); -void mpz_divmod_ui _PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int)); void mpz_fac_ui _PROTO ((mpz_ptr, unsigned long int)); void mpz_gcd _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr)); -void mpz_gcd_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int)); +unsigned long int mpz_gcd_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int)); void mpz_gcdext _PROTO ((mpz_ptr, mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr)); -signed long int mpz_get_si _PROTO ((mpz_srcptr)); +/* signed */ long int mpz_get_si _PROTO ((mpz_srcptr)); char *mpz_get_str _PROTO ((char *, int, mpz_srcptr)); unsigned long int mpz_get_ui _PROTO ((mpz_srcptr)); mp_limb mpz_getlimbn _PROTO ((mpz_srcptr, mp_size_t)); @@ -180,15 +175,7 @@ int mpz_init_set_str _PROTO ((mpz_ptr, const char *, int)); void mpz_init_set_ui _PROTO ((mpz_ptr, unsigned long int)); void mpz_lcm _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr)); -void mpz_mdiv _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr)); -void mpz_mdiv_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int)); -void mpz_mdivmod _PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr)); -unsigned long int mpz_mdivmod_ui _PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int)); -void mpz_mmod _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr)); -unsigned long int mpz_mmod_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int)); -void mpz_mod _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr)); void mpz_mod_2exp _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int)); -void mpz_mod_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int)); void mpz_mul _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr)); void mpz_mul_2exp _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int)); void mpz_mul_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int)); @@ -217,6 +204,20 @@ void mpz_sub_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int)); void mpz_ui_pow_ui _PROTO ((mpz_ptr, unsigned long int, unsigned long int)); +void mpz_fdiv_q _PROTO((mpz_ptr, mpz_srcptr, mpz_srcptr)); +unsigned long int mpz_fdiv_q_ui _PROTO((mpz_ptr, mpz_srcptr, unsigned long int)); +void mpz_fdiv_qr _PROTO((mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr)); +unsigned long int mpz_fdiv_qr_ui _PROTO((mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int)); +void mpz_fdiv_r _PROTO((mpz_ptr, mpz_srcptr, mpz_srcptr)); +unsigned long int mpz_fdiv_r_ui _PROTO((mpz_ptr, mpz_srcptr, unsigned long int)); +unsigned long int mpz_fdiv_ui _PROTO((mpz_srcptr, unsigned long int)); +void mpz_tdiv_q _PROTO((mpz_ptr, mpz_srcptr, mpz_srcptr)); +void mpz_tdiv_q_ui _PROTO((mpz_ptr, mpz_srcptr, unsigned long int)); +void mpz_tdiv_qr _PROTO((mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr)); +void mpz_tdiv_qr_ui _PROTO((mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int)); +void mpz_tdiv_r _PROTO((mpz_ptr, mpz_srcptr, mpz_srcptr)); +void mpz_tdiv_r_ui _PROTO((mpz_ptr, mpz_srcptr, unsigned long int)); + /**************** Rational (i.e. Q) routines. ****************/ void mpq_init _PROTO ((mpq_ptr)); @@ -493,8 +494,32 @@ return 0; } +/* Compatibility with GMP 1. */ + +#define mpz_mdiv mpz_fdiv_q +#define mpz_mdivmod mpz_fdiv_qr +#define mpz_mmod mpz_fdiv_r +#define mpz_mdiv_ui mpz_fdiv_q_ui +#define mpz_mdivmod_ui(q,r,n,d) \ + ((r == 0) ? mpz_fdiv_q_ui (q,n,d) : mpz_fdiv_qr_ui (q,r,n,d)) +#define mpz_mmod_ui(r,n,d) \ + ((r == 0) ? mpz_fdiv_ui (n,d) : mpz_fdiv_r_ui (r,n,d)) +/* ??? Before release... +#define mpz_div_2exp mpz_fdiv_q_2exp +#define mpz_mod_2exp mpz_fdiv_r_2exp +*/ + +/* Useful synonyms, but not quite compatible with GMP 1. */ +#define mpz_div mpz_fdiv_q +#define mpz_divmod mpz_fdiv_qr +#define mpz_mod mpz_fdiv_r +#define mpz_div_ui mpz_fdiv_q_ui +#define mpz_divmod_ui mpz_fdiv_qr_ui +#define mpz_mod_ui mpz_fdiv_r_ui + + #define __GNU_MP__ 2 #define __GNU_MP_VERSION 2 -#define __GNU_MP_VERSION_MINOR -100 +#define __GNU_MP_VERSION_MINOR -900 /* ??? */ #define __GMP_H__ #endif /* __GMP_H__ */ diff -ruN glibc-1.08.1/stdio/internals.c glibc-1.09/stdio/internals.c --- glibc-1.08.1/stdio/internals.c Mon Jan 17 17:31:19 1994 +++ glibc-1.09/stdio/internals.c Wed Nov 2 15:03:26 1994 @@ -370,7 +370,8 @@ size_t buffer_offset = 0; register char *buffer; register size_t to_read, nread = 0; - char c; + /* This must be unsigned to avoid sign extension in return. */ + unsigned char c; if (fp->__io_funcs.__read == NULL) { @@ -382,7 +383,7 @@ if (fp->__buffer == NULL) { /* We're unbuffered, so we want to read only one character. */ - buffer = &c; + buffer = (char *) &c; to_read = 1; } else @@ -455,7 +456,7 @@ fp->__put_limit = fp->__buffer; /* Return the first character in the buffer. */ - return (unsigned char) *fp->__bufp++; + return *((unsigned char *) (fp->__bufp++)); } diff -ruN glibc-1.08.1/stdio/longlong.h glibc-1.09/stdio/longlong.h --- glibc-1.08.1/stdio/longlong.h Tue Apr 26 22:01:54 1994 +++ glibc-1.09/stdio/longlong.h Tue Aug 2 20:59:04 1994 @@ -598,7 +598,7 @@ #define UDIV_TIME 100 #endif /* __mips__ */ -#if (defined (__mips__) && defined (__r4000)) && W_TYPE_SIZE == 64 +#if (defined (__mips) && __mips >= 3) && W_TYPE_SIZE == 64 #define umul_ppmm(w1, w0, u, v) \ __asm__ ("dmultu %2,%3 mflo %0 diff -ruN glibc-1.08.1/stdio/mpn-copy.mk glibc-1.09/stdio/mpn-copy.mk --- glibc-1.08.1/stdio/mpn-copy.mk Tue Apr 26 21:58:23 1994 +++ glibc-1.09/stdio/mpn-copy.mk Thu Sep 1 20:48:36 1994 @@ -54,3 +54,17 @@ $(mpn-copy-1): $(sysdep_dir)/mips/r4000/%: \ $(ignore gmp2glibc.sed) $(gmp-srcdir)/mpn/r4000/% $(gmp2glibc) +mpn-found-1 := $(filter $(gmp-srcdir)/mpn/hppa1_0/%,$(mpn-found)) +mpn-copy-1 := $(patsubst $(gmp-srcdir)/mpn/hppa1_0/%,$(sysdep_dir)/hppa/hppa1.0/%,$(mpn-found-1)) +mpn-found := $(filter-out $(mpn-found-1),$(mpn-found)) +mpn-copy-sysdep := $(mpn-copy-sysdep) $(mpn-copy-1) +$(mpn-copy-1): $(sysdep_dir)/hppa/hppa1.0/%: \ + $(ignore gmp2glibc.sed) $(gmp-srcdir)/mpn/hppa1_0/% + $(gmp2glibc) +mpn-found-1 := $(filter $(gmp-srcdir)/mpn/hppa1_1/%,$(mpn-found)) +mpn-copy-1 := $(patsubst $(gmp-srcdir)/mpn/hppa1_1/%,$(sysdep_dir)/hppa/hppa1.1/%,$(mpn-found-1)) +mpn-found := $(filter-out $(mpn-found-1),$(mpn-found)) +mpn-copy-sysdep := $(mpn-copy-sysdep) $(mpn-copy-1) +$(mpn-copy-1): $(sysdep_dir)/hppa/hppa1.1/%: \ + $(ignore gmp2glibc.sed) $(gmp-srcdir)/mpn/hppa1_1/% + $(gmp2glibc) diff -ruN glibc-1.08.1/stdio/printf_fp.c glibc-1.09/stdio/printf_fp.c --- glibc-1.08.1/stdio/printf_fp.c Tue May 10 17:49:30 1994 +++ glibc-1.09/stdio/printf_fp.c Fri Aug 19 17:31:02 1994 @@ -67,11 +67,11 @@ int *expt, int *is_neg, double value); -/* 1000 words is an arbitrarily chosen size that is big enough. Some day I - should figure out how big it actually needs to be (which should be - computable from the parameters). The size initialization is - just a notable random number to catch uninitialized variable bugs. */ -#define MPN_VAR(name) mp_limb name[1000]; mp_size_t name##size /*= 314159265*/ +/* We believe that these variables need as many bits as the largest binary + exponent of a double. But we are not confident, so we add a few words. */ +#define MPNSIZE ((DBL_MAX_EXP + BITS_PER_MP_LIMB - 1) / BITS_PER_MP_LIMB) + 3 + +#define MPN_VAR(name) mp_limb name[MPNSIZE]; mp_size_t name##size #define MPN_ASSIGN(dst,src) \ memcpy (dst, src, (dst##size = src##size) * sizeof (mp_limb)) #define MPN_POW2(dst, power) \ diff -ruN glibc-1.08.1/stdio/vfprintf.c glibc-1.09/stdio/vfprintf.c --- glibc-1.08.1/stdio/vfprintf.c Mon May 23 20:14:37 1994 +++ glibc-1.09/stdio/vfprintf.c Fri Sep 9 15:54:45 1994 @@ -276,7 +276,7 @@ /* Check for type modifiers. */ is_short = is_long = is_long_double = 0; - while (*f == 'h' || *f == 'l' || *f == 'L') + while (*f == 'h' || *f == 'l' || *f == 'L' || *f == 'q') switch (*f++) { case 'h': @@ -305,6 +305,15 @@ is_longlong = sizeof(size_t) > sizeof(unsigned long int); #endif is_long = sizeof(size_t) > sizeof(unsigned int); + break; + + case 'q': + /* 4.4 uses this for long long. */ +#ifdef HAVE_LONGLONG + is_longlong = 1; +#else + is_long = 1; +#endif break; } diff -ruN glibc-1.08.1/stdio/xbug.c glibc-1.09/stdio/xbug.c --- glibc-1.08.1/stdio/xbug.c Mon Jun 6 12:26:20 1994 +++ glibc-1.09/stdio/xbug.c Mon Jul 18 18:02:38 1994 @@ -1,24 +1,63 @@ #include - -int -main() + +typedef struct _Buffer { + char *buff; + int room, used; +} Buffer; + +#define INIT_BUFFER_SIZE 10000 + +void InitBuffer(b) + Buffer *b; { - char * filename = "xbug.c"; - FILE *input; - int i; - char buf[256]; - - - if (!freopen (filename, "r", stdin)) - fprintf(stderr, "cannot open file\n"); - - if (!(input = popen("/bin/cat", "r"))) - fprintf(stderr, "cannot run \n"); + b->room = INIT_BUFFER_SIZE; + b->used = 0; + b->buff = (char *)malloc(INIT_BUFFER_SIZE*sizeof(char)); +} + +void AppendToBuffer(b, str, len) + register Buffer *b; + char *str; + register int len; +{ + while (b->used + len > b->room) { + b->buff = (char *)realloc(b->buff, 2*b->room*(sizeof(char))); + b->room *= 2; + } + strncpy(b->buff + b->used, str, len); + b->used += len; +} + +void ReadFile(buffer, input) + register Buffer *buffer; + FILE *input; +{ + char buf[BUFSIZ + 1]; + register int bytes; + + buffer->used = 0; + while (!feof(input) && (bytes = fread(buf, 1, BUFSIZ, input)) > 0) { + AppendToBuffer(buffer, buf, bytes); + } + AppendToBuffer(buffer, "", 1); +} + +main() +{ + char * filename = "xbug.c"; + FILE *input; + Buffer buffer; + + InitBuffer(&buffer); + + if (!freopen (filename, "r", stdin)) + fprintf(stderr, "cannot open file\n"); + if (!(input = popen("/bin/cat", "r"))) + fprintf(stderr, "cannot run \n"); - while(gets(buf) != NULL) { - fprintf(stdout, "read: %s\n", buf); - } + ReadFile(&buffer, input); + pclose(input); return 0; } diff -ruN glibc-1.08.1/stdlib/stdlib.h glibc-1.09/stdlib/stdlib.h --- glibc-1.08.1/stdlib/stdlib.h Mon Nov 16 13:55:29 1992 +++ glibc-1.09/stdlib/stdlib.h Mon Aug 15 20:13:43 1994 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -82,11 +82,14 @@ extern unsigned long int strtoul __P ((__const char *__nptr, char **__endptr, int __base)); -#ifdef __OPTIMIZE__ -#define atof(nptr) strtod((nptr), (char **) NULL) -#define atoi(nptr) ((int) atol(nptr)) -#define atol(nptr) strtol((nptr), (char **) NULL, 10) -#endif /* Optimizing. */ +#if defined (__OPTIMIZE__) && __GNUC__ >= 2 +extern __inline double atof (__const char *__nptr) +{ return strtod(__nptr, (char **) NULL); } +extern __inline int atoi (__const char *__nptr) +{ return (int) strtol (__nptr, (char **) NULL, 10); } +extern __inline long int atol (__const char *__nptr) +{ return strtol (__nptr, (char **) NULL, 10); } +#endif /* Optimizing GCC >=2. */ /* Return a random integer between 0 and RAND_MAX inclusive. */ @@ -120,19 +123,19 @@ size_t __statelen)); extern __ptr_t setstate __P ((__ptr_t __statebuf)); -#ifdef __OPTIMIZE__ -#define random() __random() -#define srandom(seed) __srandom(seed) -#define initstate(s, b, n) __initstate((s), (b), (n)) -#define setstate(state) __setstate(state) -#endif /* Optimizing. */ +#if defined (__OPTIMIZE__) && __GNUC__ >= 2 +extern __inline long int random (void) +{ return __random(); } +extern __inline void srandom (unsigned int __seed) +{ __srandom(__seed); } +extern __inline __ptr_t initstate (unsigned int __seed, + __ptr_t __statebuf, size_t __statelen) +{ return __initstate (__seed, __statebuf, __statelen); } +extern __inline __ptr_t setstate (__ptr_t __statebuf) +{ return __setstate (__statebuf); } +#endif /* Optimizing GCC >=2. */ #endif /* Use BSD. */ -#ifdef __OPTIMIZE__ -#define rand() ((int) __random()) -#define srand(seed) __srandom(seed) -#endif /* Optimizing. */ - /* Allocate SIZE bytes of memory. */ extern __ptr_t malloc __P ((size_t __size)); @@ -147,10 +150,6 @@ #ifdef __USE_MISC /* Free a block. An alias for `free'. (Sun Unices). */ extern void cfree __P ((__ptr_t __ptr)); - -#ifdef __OPTIMIZE__ -#define cfree(ptr) free(ptr) -#endif /* Optimizing. */ #endif /* Use misc. */ #if defined(__USE_GNU) || defined(__USE_BSD) || defined(__USE_MISC) @@ -255,9 +254,10 @@ by WCHAR in S, returning its length. */ extern int wctomb __P ((char *__s, wchar_t __wchar)); -#ifdef __OPTIMIZE__ -#define mblen(s, n) mbtowc((wchar_t *) NULL, (s), (n)) -#endif /* Optimizing. */ +#if defined (__OPTIMIZE__) && __GNUC__ >= 2 +extern __inline int mblen (__const char *__s, size_t __n) +{ return mbtowc ((wchar_t *) NULL, __s, __n); } +#endif /* Optimizing GCC >=2. */ /* Convert a multibyte string to a wide char string. */ diff -ruN glibc-1.08.1/stdlib/strtol.c glibc-1.09/stdlib/strtol.c --- glibc-1.08.1/stdlib/strtol.c Fri Aug 7 16:09:48 1992 +++ glibc-1.09/stdlib/strtol.c Mon Oct 17 00:09:25 1994 @@ -1,4 +1,5 @@ -/* Copyright (C) 1991, 1992 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1992, 1994 Free Software Foundation, Inc. + This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -16,7 +17,6 @@ not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include #include #include #include @@ -39,16 +39,18 @@ #else long int #endif -DEFUN(strtol, (nptr, endptr, base), - CONST char *nptr AND char **endptr AND int base) +strtol (nptr, endptr, base) + const char *nptr; + char **endptr; + int base; { int negative; register unsigned long int cutoff; register unsigned int cutlim; register unsigned long int i; - register CONST char *s; + register const char *s; register unsigned char c; - CONST char *save; + const char *save; int overflow; if (base < 0 || base == 1 || base > 36) @@ -57,7 +59,7 @@ s = nptr; /* Skip white space. */ - while (isspace(*s)) + while (isspace (*s)) ++s; if (*s == '\0') goto noconv; @@ -76,14 +78,14 @@ else negative = 0; - if (base == 16 && s[0] == '0' && toupper(s[1]) == 'X') + if (base == 16 && s[0] == '0' && toupper (s[1]) == 'X') s += 2; /* If BASE is zero, figure it out ourselves. */ if (base == 0) if (*s == '0') { - if (toupper(s[1]) == 'X') + if (toupper (s[1]) == 'X') { s += 2; base = 16; @@ -104,10 +106,10 @@ i = 0; for (c = *s; c != '\0'; c = *++s) { - if (isdigit(c)) + if (isdigit (c)) c -= '0'; - else if (isalpha(c)) - c = toupper(c) - 'A' + 10; + else if (isalpha (c)) + c = toupper (c) - 'A' + 10; else break; if (c >= base) @@ -135,7 +137,7 @@ /* Check for a value that is within the range of `unsigned long int', but outside the range of `long int'. */ if (i > (negative ? - - (unsigned long int) LONG_MIN : (unsigned long int) LONG_MAX)) + -(unsigned long int) LONG_MIN : (unsigned long int) LONG_MAX)) overflow = 1; #endif @@ -150,9 +152,9 @@ } /* Return the result of the appropriate sign. */ - return (negative ? - i : i); + return (negative ? -i : i); - noconv: +noconv: /* There was no number to convert. */ if (endptr != NULL) *endptr = (char *) nptr; diff -ruN glibc-1.08.1/string/Makefile glibc-1.09/string/Makefile --- glibc-1.08.1/string/Makefile Thu Nov 18 05:49:35 1993 +++ glibc-1.09/string/Makefile Wed Aug 31 01:16:11 1994 @@ -1,4 +1,4 @@ -# Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. +# Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc. # This file is part of the GNU C Library. # The GNU C Library is free software; you can redistribute it and/or @@ -32,7 +32,7 @@ rindex index bcmp memccpy memcpy wordcopy strsep \ swab strfry memfrob memmem -tests := tester testcopy +tests := tester testcopy test-ffs distribute := memcopy.h diff -ruN glibc-1.08.1/string/test-ffs.c glibc-1.09/string/test-ffs.c --- glibc-1.08.1/string/test-ffs.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/string/test-ffs.c Sat Sep 3 12:22:32 1994 @@ -0,0 +1,54 @@ +/* Copyright (C) 1994 Free Software Foundation, Inc. + Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil), + On-Line Applications Research Corporation. + +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include +#include + +int +DEFUN(main, (argc, argv), + int argc AND char **argv) +{ + int failures = 0; + int i; + void try (int value, int expected) + { + if (ffs (value) != expected) + { + fprintf (stderr, "%#x expected %d got %d\n", + value, expected, ffs (value)); + ++failures; + } + } + + try (0, 0); + for (i=0 ; i<32 ; i++) + try (1< #include #include +#undef _POSIX_SOURCE /* Ultrix needs --roland@gnu */ +#include /* Ultrix needs before net/if --roland@gnu */ #include #include /* Order of following two #includes reversed by roland@gnu */ diff -ruN glibc-1.08.1/sunrpc/pm_getmaps.c glibc-1.09/sunrpc/pm_getmaps.c --- glibc-1.08.1/sunrpc/pm_getmaps.c Sun Feb 6 16:42:43 1994 +++ glibc-1.09/sunrpc/pm_getmaps.c Mon Oct 24 16:09:22 1994 @@ -46,6 +46,8 @@ #include #include #include +#undef _POSIX_SOURCE /* Ultrix needs --roland@gnu */ +#include /* Ultrix needs before net/if --roland@gnu */ #include #include #define NAMELEN 255 diff -ruN glibc-1.08.1/sunrpc/pm_getport.c glibc-1.09/sunrpc/pm_getport.c --- glibc-1.08.1/sunrpc/pm_getport.c Sun Feb 6 16:42:43 1994 +++ glibc-1.09/sunrpc/pm_getport.c Mon Oct 24 16:10:07 1994 @@ -42,6 +42,8 @@ #include #include #include +#undef _POSIX_SOURCE /* Ultrix needs --roland@gnu */ +#include /* Ultrix needs before net/if --roland@gnu */ #include static struct timeval timeout = { 5, 0 }; diff -ruN glibc-1.08.1/sunrpc/pmap_rmt.c glibc-1.09/sunrpc/pmap_rmt.c --- glibc-1.08.1/sunrpc/pmap_rmt.c Sun Feb 6 17:35:33 1994 +++ glibc-1.09/sunrpc/pmap_rmt.c Mon Oct 24 16:09:49 1994 @@ -46,6 +46,8 @@ #include #include #include +#undef _POSIX_SOURCE /* Ultrix needs --roland@gnu */ +#include /* Ultrix needs before net/if --roland@gnu */ #include #include #include diff -ruN glibc-1.08.1/sys/bitypes.h glibc-1.09/sys/bitypes.h --- glibc-1.08.1/sys/bitypes.h Wed May 19 15:33:58 1993 +++ glibc-1.09/sys/bitypes.h Wed Aug 10 16:49:22 1994 @@ -1 +1 @@ -#include +#include diff -ruN glibc-1.08.1/sysdeps/generic/Makefile glibc-1.09/sysdeps/generic/Makefile --- glibc-1.08.1/sysdeps/generic/Makefile Tue Mar 8 20:40:19 1994 +++ glibc-1.09/sysdeps/generic/Makefile Mon Aug 15 20:35:48 1994 @@ -19,9 +19,8 @@ ifeq ($(subdir),math) ifndef math-twiddled -routines:= $(filter-out acos asin cos sin hypot,$(routines)) \ - sincos asincos -aux := $(aux) exp__E log__L +elided-routines := $(elided-routines) acos asin cos sin hypot +sysdep_routines := $(sysdep_routines) sincos asincos exp__E log__L math-twiddled := t endif diff -ruN glibc-1.08.1/sysdeps/generic/__expm1.c glibc-1.09/sysdeps/generic/__expm1.c --- glibc-1.08.1/sysdeps/generic/__expm1.c Sat May 15 18:01:03 1993 +++ glibc-1.09/sysdeps/generic/__expm1.c Sun Jul 31 15:19:48 1994 @@ -1,6 +1,6 @@ /* - * Copyright (c) 1985 Regents of the University of California. - * All rights reserved. + * 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 @@ -32,7 +32,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)expm1.c 5.6 (Berkeley) 10/9/90"; +static char sccsid[] = "@(#)expm1.c 8.1 (Berkeley) 6/4/93"; #endif /* not lint */ /* EXPM1(X) @@ -108,7 +108,7 @@ double expm1(x) double x; { - static const double one=1.0, half=1.0/2.0; + const static double one=1.0, half=1.0/2.0; double z,hi,lo,c; int k; #if defined(vax)||defined(tahoe) @@ -130,21 +130,21 @@ z=hi-(lo=k*ln2lo); c=(hi-z)-lo; - if(k==0) return(z+exp__E(z,c)); + if(k==0) return(z+__exp__E(z,c)); if(k==1) if(z< -0.25) - {x=z+half;x +=exp__E(z,c); return(x+x);} + {x=z+half;x +=__exp__E(z,c); return(x+x);} else - {z+=exp__E(z,c); x=half+z; return(x+x);} + {z+=__exp__E(z,c); x=half+z; return(x+x);} /* end of k=1 */ else { if(k<=prec) - { x=one-scalb(one,-k); z += exp__E(z,c);} + { x=one-scalb(one,-k); z += __exp__E(z,c);} else if(k<100) - { x = exp__E(z,c)-scalb(one,-k); x+=z; z=one;} + { x = __exp__E(z,c)-scalb(one,-k); x+=z; z=one;} else - { x = exp__E(z,c)+z; z=one;} + { x = __exp__E(z,c)+z; z=one;} return (scalb(x+z,k)); } diff -ruN glibc-1.08.1/sysdeps/generic/__sbrk.c glibc-1.09/sysdeps/generic/__sbrk.c --- glibc-1.08.1/sysdeps/generic/__sbrk.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/generic/__sbrk.c Fri Aug 26 01:54:47 1994 @@ -0,0 +1,40 @@ +/* Copyright (C) 1991 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with the GNU C Library; see the file COPYING. If not, write to +the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include + +/* Defined in brk.c. */ +extern PTR __curbrk; +extern int EXFUN(__brk, (PTR addr)); + +/* Extend the process's data space by INCREMENT. + If INCREMENT is negative, shrink data space by - INCREMENT. + Return start of new space allocated, or -1 for errors. */ +PTR +DEFUN(__sbrk, (increment), int increment) +{ + char *oldbrk; + + if (increment == 0) + return __curbrk; + + oldbrk = __curbrk; + if (__brk(oldbrk + increment) < 0) + return (PTR) -1; + + return oldbrk; +} diff -ruN glibc-1.08.1/sysdeps/generic/acosh.c glibc-1.09/sysdeps/generic/acosh.c --- glibc-1.08.1/sysdeps/generic/acosh.c Thu Jul 30 18:50:23 1992 +++ glibc-1.09/sysdeps/generic/acosh.c Sun Jul 31 15:23:45 1994 @@ -1,6 +1,6 @@ /* - * Copyright (c) 1985 Regents of the University of California. - * All rights reserved. + * 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 @@ -32,7 +32,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)acosh.c 5.6 (Berkeley) 10/9/90"; +static char sccsid[] = "@(#)acosh.c 8.1 (Berkeley) 6/4/93"; #endif /* not lint */ /* ACOSH(X) diff -ruN glibc-1.08.1/sysdeps/generic/asincos.c glibc-1.09/sysdeps/generic/asincos.c --- glibc-1.08.1/sysdeps/generic/asincos.c Thu Jul 30 18:50:27 1992 +++ glibc-1.09/sysdeps/generic/asincos.c Sun Jul 31 15:27:49 1994 @@ -1,6 +1,6 @@ /* - * Copyright (c) 1985 Regents of the University of California. - * All rights reserved. + * 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 @@ -32,7 +32,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)asincos.c 5.5 (Berkeley) 10/9/90"; +static char sccsid[] = "@(#)asincos.c 8.1 (Berkeley) 6/4/93"; #endif /* not lint */ /* ASIN(X) diff -ruN glibc-1.08.1/sysdeps/generic/asinh.c glibc-1.09/sysdeps/generic/asinh.c --- glibc-1.08.1/sysdeps/generic/asinh.c Sat May 15 18:01:03 1993 +++ glibc-1.09/sysdeps/generic/asinh.c Sun Jul 31 15:28:16 1994 @@ -1,6 +1,6 @@ /* - * Copyright (c) 1985 Regents of the University of California. - * All rights reserved. + * 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 @@ -32,7 +32,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)asinh.c 5.6 (Berkeley) 10/9/90"; +static char sccsid[] = "@(#)asinh.c 8.1 (Berkeley) 6/4/93"; #endif /* not lint */ /* ASINH(X) @@ -84,7 +84,7 @@ double x; { double t,s; - static const double small=1.0E-10, /* fl(1+small*small) == 1 */ + const static double small=1.0E-10, /* fl(1+small*small) == 1 */ big =1.0E20, /* fl(1+big) == big */ one =1.0 ; diff -ruN glibc-1.08.1/sysdeps/generic/atan2.c glibc-1.09/sysdeps/generic/atan2.c --- glibc-1.08.1/sysdeps/generic/atan2.c Thu Jul 30 18:50:14 1992 +++ glibc-1.09/sysdeps/generic/atan2.c Sun Jul 31 15:29:24 1994 @@ -1,6 +1,6 @@ /* - * Copyright (c) 1985 Regents of the University of California. - * All rights reserved. + * 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 @@ -32,7 +32,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)atan2.c 5.6 (Berkeley) 10/9/90"; +static char sccsid[] = "@(#)atan2.c 8.1 (Berkeley) 6/4/93"; #endif /* not lint */ /* ATAN2(Y,X) diff -ruN glibc-1.08.1/sysdeps/generic/atanh.c glibc-1.09/sysdeps/generic/atanh.c --- glibc-1.08.1/sysdeps/generic/atanh.c Thu Jul 30 18:50:31 1992 +++ glibc-1.09/sysdeps/generic/atanh.c Sun Jul 31 15:30:04 1994 @@ -1,6 +1,6 @@ /* - * Copyright (c) 1985 Regents of the University of California. - * All rights reserved. + * 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 @@ -32,7 +32,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)atanh.c 5.6 (Berkeley) 10/9/90"; +static char sccsid[] = "@(#)atanh.c 8.1 (Berkeley) 6/4/93"; #endif /* not lint */ /* ATANH(X) diff -ruN glibc-1.08.1/sysdeps/generic/configure glibc-1.09/sysdeps/generic/configure --- glibc-1.08.1/sysdeps/generic/configure Thu May 19 16:15:23 1994 +++ glibc-1.09/sysdeps/generic/configure Fri Jul 29 02:39:39 1994 @@ -7,11 +7,8 @@ for ac_func in psignal do ac_tr_func=HAVE_`echo $ac_func | tr '[a-z]' '[A-Z]'` -echo "checking for ${ac_func}" 1>&4 -if eval "test \"`echo '${'ac_cv_func_${ac_func}'+set}'`\" = set"; then - echo " using cached value for ac_cv_func_${ac_func}" 1>&5 -else - cat > conftest.${ac_ext} < conftest.${ac_ext} < int main() { return 0; } @@ -29,24 +26,16 @@ EOF if eval $ac_compile; then rm -rf conftest* - eval "ac_cv_func_${ac_func}=yes" -else - rm -rf conftest* - eval "ac_cv_func_${ac_func}=no" -fi -rm -f conftest* - -fi -if eval "test \"`echo '$ac_cv_func_'${ac_func}`\" = yes"; then - -{ -test "$verbose" = yes && \ + { +test -n "$verbose" && \ echo " defining ${ac_tr_func}" echo "#define" ${ac_tr_func} "1" >> confdefs.h DEFS="$DEFS -D${ac_tr_func}=1" } + fi +rm -f conftest* done fi diff -ruN glibc-1.08.1/sysdeps/generic/cosh.c glibc-1.09/sysdeps/generic/cosh.c --- glibc-1.08.1/sysdeps/generic/cosh.c Thu Jul 30 18:50:33 1992 +++ glibc-1.09/sysdeps/generic/cosh.c Sun Jul 31 15:31:51 1994 @@ -1,6 +1,6 @@ /* - * Copyright (c) 1985 Regents of the University of California. - * All rights reserved. + * 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 @@ -32,7 +32,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)cosh.c 5.6 (Berkeley) 10/9/90"; +static char sccsid[] = "@(#)cosh.c 8.1 (Berkeley) 6/4/93"; #endif /* not lint */ /* COSH(X) @@ -117,7 +117,7 @@ if((x=copysign(x,one)) <= 22) if(x<0.3465) if(x dX || __mpn_cmp (num_ptr - den_size, den_ptr - den_size, - den_size - 1) >= 0) + den_size - 1) >= 0) { __mpn_sub_n (num_ptr - den_size, - num_ptr - den_size, den_ptr - den_size, - den_size); + num_ptr - den_size, den_ptr - den_size, + den_size); most_significant_q_limb = 1; } @@ -211,13 +211,14 @@ could make this loop make two iterations less. */ cy_limb = __mpn_submul_1 (num_ptr - den_size, - den_ptr - den_size, den_size, q); + den_ptr - den_size, den_size, q); if (num_ptr[0] != cy_limb) { mp_limb cy; cy = __mpn_add_n (num_ptr - den_size, - num_ptr - den_size, den_ptr - den_size, den_size); + num_ptr - den_size, + den_ptr - den_size, den_size); if (cy == 0) abort (); q--; diff -ruN glibc-1.08.1/sysdeps/generic/exp.c glibc-1.09/sysdeps/generic/exp.c --- glibc-1.08.1/sysdeps/generic/exp.c Thu Jul 30 18:50:35 1992 +++ glibc-1.09/sysdeps/generic/exp.c Sun Jul 31 15:32:42 1994 @@ -1,6 +1,6 @@ /* - * Copyright (c) 1985 Regents of the University of California. - * All rights reserved. + * 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 @@ -32,7 +32,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)exp.c 5.6 (Berkeley) 10/9/90"; +static char sccsid[] = "@(#)exp.c 8.1 (Berkeley) 6/4/93"; #endif /* not lint */ /* EXP(X) @@ -140,6 +140,51 @@ c= x - z*(p1+z*(p2+z*(p3+z*(p4+z*p5)))); return scalb(1.0+(hi-(lo-(x*c)/(2.0-c))),k); + } + /* end of x > lntiny */ + + else + /* exp(-big#) underflows to zero */ + if(finite(x)) return(scalb(1.0,-5000)); + + /* exp(-INF) is zero */ + else return(0.0); + } + /* end of x < lnhuge */ + + else + /* exp(INF) is INF, exp(+big#) overflows to INF */ + return( finite(x) ? scalb(1.0,5000) : x); +} + +/* returns exp(r = x + c) for |c| < |x| with no overlap. */ + +double __exp__D(x, c) +double x, c; +{ + double z,hi,lo, t; + int k; + +#if !defined(vax)&&!defined(tahoe) + if (x!=x) return(x); /* x is NaN */ +#endif /* !defined(vax)&&!defined(tahoe) */ + if ( x <= lnhuge ) { + if ( x >= lntiny ) { + + /* argument reduction : x --> x - k*ln2 */ + z = invln2*x; + k = z + copysign(.5, x); + + /* express (x+c)-k*ln2 as hi-lo and let x=hi-lo rounded */ + + hi=(x-k*ln2hi); /* Exact. */ + x= hi - (lo = k*ln2lo-c); + /* return 2^k*[1+x+x*c/(2+c)] */ + z=x*x; + c= x - z*(p1+z*(p2+z*(p3+z*(p4+z*p5)))); + c = (x*c)/(2.0-c); + + return scalb(1.+(hi-(lo - c)), k); } /* end of x > lntiny */ diff -ruN glibc-1.08.1/sysdeps/generic/exp__E.c glibc-1.09/sysdeps/generic/exp__E.c --- glibc-1.08.1/sysdeps/generic/exp__E.c Sat May 15 18:01:03 1993 +++ glibc-1.09/sysdeps/generic/exp__E.c Sun Jul 31 15:33:17 1994 @@ -1,6 +1,6 @@ /* - * Copyright (c) 1985 Regents of the University of California. - * All rights reserved. + * 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 @@ -32,7 +32,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)exp__E.c 5.6 (Berkeley) 10/9/90"; +static char sccsid[] = "@(#)exp__E.c 8.1 (Berkeley) 6/4/93"; #endif /* not lint */ /* exp__E(x,c) @@ -107,10 +107,10 @@ #define q3 vccast(q3) #endif -double exp__E(x,c) +double __exp__E(x,c) double x,c; { - static const double zero=0.0, one=1.0, half=1.0/2.0, small=1.0E-19; + const static double zero=0.0, one=1.0, half=1.0/2.0, small=1.0E-19; double z,p,q,xp,xh,w; if(copysign(x,one)>small) { z = x*x ; diff -ruN glibc-1.08.1/sysdeps/generic/fmod.c glibc-1.09/sysdeps/generic/fmod.c --- glibc-1.08.1/sysdeps/generic/fmod.c Thu Jul 30 18:50:41 1992 +++ glibc-1.09/sysdeps/generic/fmod.c Sun Jul 31 15:34:26 1994 @@ -1,6 +1,6 @@ /* - * Copyright (c) 1989 The Regents of the University of California. - * All rights reserved. + * 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 @@ -32,7 +32,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)fmod.c 5.2 (Berkeley) 6/1/90"; +static char sccsid[] = "@(#)fmod.c 8.1 (Berkeley) 6/4/93"; #endif /* not lint */ /* fmod.c diff -ruN glibc-1.08.1/sysdeps/generic/getenv.c glibc-1.09/sysdeps/generic/getenv.c --- glibc-1.08.1/sysdeps/generic/getenv.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/generic/getenv.c Mon Jul 18 18:04:32 1994 @@ -0,0 +1,44 @@ +/* Copyright (C) 1991, 1992, 1994 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include +#include +#include + +#ifndef HAVE_GNU_LD +#define __environ environ +#endif + +/* Return the value of the environment variable NAME. */ +char * +DEFUN(getenv, (name), register CONST char *name) +{ + register CONST size_t len = strlen(name); + register char **ep; + + if (__environ == NULL) + return NULL; + + for (ep = __environ; *ep != NULL; ++ep) + if (!strncmp(*ep, name, len) && (*ep)[len] == '=') + return &(*ep)[len + 1]; + + return NULL; +} diff -ruN glibc-1.08.1/sysdeps/generic/log.c glibc-1.09/sysdeps/generic/log.c --- glibc-1.08.1/sysdeps/generic/log.c Sat May 15 18:01:04 1993 +++ glibc-1.09/sysdeps/generic/log.c Sun Jul 31 15:36:09 1994 @@ -1,6 +1,6 @@ /* - * Copyright (c) 1985 Regents of the University of California. - * All rights reserved. + * 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 @@ -32,132 +32,455 @@ */ #ifndef lint -static char sccsid[] = "@(#)log.c 5.6 (Berkeley) 10/9/90"; +static char sccsid[] = "@(#)log.c 8.2 (Berkeley) 11/30/93"; #endif /* not lint */ -/* LOG(X) - * RETURN THE LOGARITHM OF x - * DOUBLE PRECISION (VAX D FORMAT 56 bits or IEEE DOUBLE 53 BITS) - * CODED IN C BY K.C. NG, 1/19/85; - * REVISED BY K.C. NG on 2/7/85, 3/7/85, 3/24/85, 4/16/85. - * - * Required system supported functions: - * scalb(x,n) - * copysign(x,y) - * logb(x) - * finite(x) - * - * Required kernel function: - * log__L(z) - * - * Method : - * 1. Argument Reduction: find k and f such that - * x = 2^k * (1+f), - * where sqrt(2)/2 < 1+f < sqrt(2) . - * - * 2. Let s = f/(2+f) ; based on log(1+f) = log(1+s) - log(1-s) - * = 2s + 2/3 s**3 + 2/5 s**5 + ....., - * log(1+f) is computed by - * - * log(1+f) = 2s + s*log__L(s*s) - * where - * log__L(z) = z*(L1 + z*(L2 + z*(... (L6 + z*L7)...))) - * - * See log__L() for the values of the coefficients. - * - * 3. Finally, log(x) = k*ln2 + log(1+f). (Here n*ln2 will be stored - * in two floating point number: n*ln2hi + n*ln2lo, n*ln2hi is exact - * since the last 20 bits of ln2hi is 0.) - * - * Special cases: - * log(x) is NaN with signal if x < 0 (including -INF) ; - * log(+INF) is +INF; log(0) is -INF with signal; - * log(NaN) is that NaN with no signal. - * - * Accuracy: - * log(x) returns the exact log(x) nearly rounded. In a test run with - * 1,536,000 random arguments on a VAX, the maximum observed error was - * .826 ulps (units in the last place). - * - * Constants: - * The hexadecimal values are the intended ones for the following constants. - * The decimal values may be used, provided that the compiler will convert - * from decimal to binary accurately enough to produce the hexadecimal values - * shown. - */ - +#include #include + #include "mathimpl.h" -vc(ln2hi, 6.9314718055829871446E-1 ,7217,4031,0000,f7d0, 0, .B17217F7D00000) -vc(ln2lo, 1.6465949582897081279E-12 ,bcd5,2ce7,d9cc,e4f1, -39, .E7BCD5E4F1D9CC) -vc(sqrt2, 1.4142135623730950622E0 ,04f3,40b5,de65,33f9, 1, .B504F333F9DE65) - -ic(ln2hi, 6.9314718036912381649E-1, -1, 1.62E42FEE00000) -ic(ln2lo, 1.9082149292705877000E-10, -33, 1.A39EF35793C76) -ic(sqrt2, 1.4142135623730951455E0, 0, 1.6A09E667F3BCD) - -#ifdef vccast -#define ln2hi vccast(ln2hi) -#define ln2lo vccast(ln2lo) -#define sqrt2 vccast(sqrt2) +/* Table-driven natural logarithm. + * + * This code was derived, with minor modifications, from: + * Peter Tang, "Table-Driven Implementation of the + * Logarithm in IEEE Floating-Point arithmetic." ACM Trans. + * Math Software, vol 16. no 4, pp 378-400, Dec 1990). + * + * Calculates log(2^m*F*(1+f/F)), |f/j| <= 1/256, + * where F = j/128 for j an integer in [0, 128]. + * + * log(2^m) = log2_hi*m + log2_tail*m + * since m is an integer, the dominant term is exact. + * m has at most 10 digits (for subnormal numbers), + * and log2_hi has 11 trailing zero bits. + * + * log(F) = logF_hi[j] + logF_lo[j] is in tabular form in log_table.h + * logF_hi[] + 512 is exact. + * + * log(1+f/F) = 2*f/(2*F + f) + 1/12 * (2*f/(2*F + f))**3 + ... + * the leading term is calculated to extra precision in two + * parts, the larger of which adds exactly to the dominant + * m and F terms. + * There are two cases: + * 1. when m, j are non-zero (m | j), use absolute + * precision for the leading term. + * 2. when m = j = 0, |1-x| < 1/256, and log(x) ~= (x-1). + * In this case, use a relative precision of 24 bits. + * (This is done differently in the original paper) + * + * Special cases: + * 0 return signalling -Inf + * neg return signalling NaN + * +Inf return +Inf +*/ + +#if defined(vax) || defined(tahoe) +#define _IEEE 0 +#define TRUNC(x) x = (double) (float) (x) +#else +#define _IEEE 1 +#define endian (((*(int *) &one)) ? 1 : 0) +#define TRUNC(x) *(((int *) &x) + endian) &= 0xf8000000 +#define infnan(x) 0.0 #endif +#define N 128 -double log(x) -double x; +/* Table of log(Fj) = logF_head[j] + logF_tail[j], for Fj = 1+j/128. + * Used for generation of extend precision logarithms. + * The constant 35184372088832 is 2^45, so the divide is exact. + * It ensures correct reading of logF_head, even for inaccurate + * decimal-to-binary conversion routines. (Everybody gets the + * right answer for integers less than 2^53.) + * Values for log(F) were generated using error < 10^-57 absolute + * with the bc -l package. +*/ +static double A1 = .08333333333333178827; +static double A2 = .01250000000377174923; +static double A3 = .002232139987919447809; +static double A4 = .0004348877777076145742; + +static double logF_head[N+1] = { + 0., + .007782140442060381246, + .015504186535963526694, + .023167059281547608406, + .030771658666765233647, + .038318864302141264488, + .045809536031242714670, + .053244514518837604555, + .060624621816486978786, + .067950661908525944454, + .075223421237524235039, + .082443669210988446138, + .089612158689760690322, + .096729626458454731618, + .103796793681567578460, + .110814366340264314203, + .117783035656430001836, + .124703478501032805070, + .131576357788617315236, + .138402322859292326029, + .145182009844575077295, + .151916042025732167530, + .158605030176659056451, + .165249572895390883786, + .171850256926518341060, + .178407657472689606947, + .184922338493834104156, + .191394852999565046047, + .197825743329758552135, + .204215541428766300668, + .210564769107350002741, + .216873938300523150246, + .223143551314024080056, + .229374101064877322642, + .235566071312860003672, + .241719936886966024758, + .247836163904594286577, + .253915209980732470285, + .259957524436686071567, + .265963548496984003577, + .271933715484010463114, + .277868451003087102435, + .283768173130738432519, + .289633292582948342896, + .295464212893421063199, + .301261330578199704177, + .307025035294827830512, + .312755710004239517729, + .318453731118097493890, + .324119468654316733591, + .329753286372579168528, + .335355541920762334484, + .340926586970454081892, + .346466767346100823488, + .351976423156884266063, + .357455888922231679316, + .362905493689140712376, + .368325561158599157352, + .373716409793814818840, + .379078352934811846353, + .384411698910298582632, + .389716751140440464951, + .394993808240542421117, + .400243164127459749579, + .405465108107819105498, + .410659924985338875558, + .415827895143593195825, + .420969294644237379543, + .426084395310681429691, + .431173464818130014464, + .436236766774527495726, + .441274560805140936281, + .446287102628048160113, + .451274644139630254358, + .456237433481874177232, + .461175715122408291790, + .466089729924533457960, + .470979715219073113985, + .475845904869856894947, + .480688529345570714212, + .485507815781602403149, + .490303988045525329653, + .495077266798034543171, + .499827869556611403822, + .504556010751912253908, + .509261901790523552335, + .513945751101346104405, + .518607764208354637958, + .523248143765158602036, + .527867089620485785417, + .532464798869114019908, + .537041465897345915436, + .541597282432121573947, + .546132437597407260909, + .550647117952394182793, + .555141507540611200965, + .559615787935399566777, + .564070138285387656651, + .568504735352689749561, + .572919753562018740922, + .577315365035246941260, + .581691739635061821900, + .586049045003164792433, + .590387446602107957005, + .594707107746216934174, + .599008189645246602594, + .603290851438941899687, + .607555250224322662688, + .611801541106615331955, + .616029877215623855590, + .620240409751204424537, + .624433288012369303032, + .628608659422752680256, + .632766669570628437213, + .636907462236194987781, + .641031179420679109171, + .645137961373620782978, + .649227946625615004450, + .653301272011958644725, + .657358072709030238911, + .661398482245203922502, + .665422632544505177065, + .669430653942981734871, + .673422675212350441142, + .677398823590920073911, + .681359224807238206267, + .685304003098281100392, + .689233281238557538017, + .693147180560117703862 +}; + +static double logF_tail[N+1] = { + 0., + -.00000000000000543229938420049, + .00000000000000172745674997061, + -.00000000000001323017818229233, + -.00000000000001154527628289872, + -.00000000000000466529469958300, + .00000000000005148849572685810, + -.00000000000002532168943117445, + -.00000000000005213620639136504, + -.00000000000001819506003016881, + .00000000000006329065958724544, + .00000000000008614512936087814, + -.00000000000007355770219435028, + .00000000000009638067658552277, + .00000000000007598636597194141, + .00000000000002579999128306990, + -.00000000000004654729747598444, + -.00000000000007556920687451336, + .00000000000010195735223708472, + -.00000000000017319034406422306, + -.00000000000007718001336828098, + .00000000000010980754099855238, + -.00000000000002047235780046195, + -.00000000000008372091099235912, + .00000000000014088127937111135, + .00000000000012869017157588257, + .00000000000017788850778198106, + .00000000000006440856150696891, + .00000000000016132822667240822, + -.00000000000007540916511956188, + -.00000000000000036507188831790, + .00000000000009120937249914984, + .00000000000018567570959796010, + -.00000000000003149265065191483, + -.00000000000009309459495196889, + .00000000000017914338601329117, + -.00000000000001302979717330866, + .00000000000023097385217586939, + .00000000000023999540484211737, + .00000000000015393776174455408, + -.00000000000036870428315837678, + .00000000000036920375082080089, + -.00000000000009383417223663699, + .00000000000009433398189512690, + .00000000000041481318704258568, + -.00000000000003792316480209314, + .00000000000008403156304792424, + -.00000000000034262934348285429, + .00000000000043712191957429145, + -.00000000000010475750058776541, + -.00000000000011118671389559323, + .00000000000037549577257259853, + .00000000000013912841212197565, + .00000000000010775743037572640, + .00000000000029391859187648000, + -.00000000000042790509060060774, + .00000000000022774076114039555, + .00000000000010849569622967912, + -.00000000000023073801945705758, + .00000000000015761203773969435, + .00000000000003345710269544082, + -.00000000000041525158063436123, + .00000000000032655698896907146, + -.00000000000044704265010452446, + .00000000000034527647952039772, + -.00000000000007048962392109746, + .00000000000011776978751369214, + -.00000000000010774341461609578, + .00000000000021863343293215910, + .00000000000024132639491333131, + .00000000000039057462209830700, + -.00000000000026570679203560751, + .00000000000037135141919592021, + -.00000000000017166921336082431, + -.00000000000028658285157914353, + -.00000000000023812542263446809, + .00000000000006576659768580062, + -.00000000000028210143846181267, + .00000000000010701931762114254, + .00000000000018119346366441110, + .00000000000009840465278232627, + -.00000000000033149150282752542, + -.00000000000018302857356041668, + -.00000000000016207400156744949, + .00000000000048303314949553201, + -.00000000000071560553172382115, + .00000000000088821239518571855, + -.00000000000030900580513238244, + -.00000000000061076551972851496, + .00000000000035659969663347830, + .00000000000035782396591276383, + -.00000000000046226087001544578, + .00000000000062279762917225156, + .00000000000072838947272065741, + .00000000000026809646615211673, + -.00000000000010960825046059278, + .00000000000002311949383800537, + -.00000000000058469058005299247, + -.00000000000002103748251144494, + -.00000000000023323182945587408, + -.00000000000042333694288141916, + -.00000000000043933937969737844, + .00000000000041341647073835565, + .00000000000006841763641591466, + .00000000000047585534004430641, + .00000000000083679678674757695, + -.00000000000085763734646658640, + .00000000000021913281229340092, + -.00000000000062242842536431148, + -.00000000000010983594325438430, + .00000000000065310431377633651, + -.00000000000047580199021710769, + -.00000000000037854251265457040, + .00000000000040939233218678664, + .00000000000087424383914858291, + .00000000000025218188456842882, + -.00000000000003608131360422557, + -.00000000000050518555924280902, + .00000000000078699403323355317, + -.00000000000067020876961949060, + .00000000000016108575753932458, + .00000000000058527188436251509, + -.00000000000035246757297904791, + -.00000000000018372084495629058, + .00000000000088606689813494916, + .00000000000066486268071468700, + .00000000000063831615170646519, + .00000000000025144230728376072, + -.00000000000017239444525614834 +}; + +double +#ifdef _ANSI_SOURCE +log(double x) +#else +log(x) double x; +#endif { - static const double zero=0.0, negone= -1.0, half=1.0/2.0; - double s,z,t; - int k,n; - -#if !defined(vax)&&!defined(tahoe) - if(x!=x) return(x); /* x is NaN */ -#endif /* !defined(vax)&&!defined(tahoe) */ - if(finite(x)) { - if( x > zero ) { - - /* argument reduction */ - k=logb(x); x=scalb(x,-k); - if(k == -1022) /* subnormal no. */ - {n=logb(x); x=scalb(x,-n); k+=n;} - if(x >= sqrt2 ) {k += 1; x *= half;} - x += negone ; - - /* compute log(1+x) */ - s=x/(2+x); t=x*x*half; - z=k*ln2lo+s*(t+log__L(s*s)); - x += (z - t) ; - - return(k*ln2hi+x); - } - /* end of if (x > zero) */ - - else { -#if defined(vax)||defined(tahoe) - if ( x == zero ) - return (infnan(-ERANGE)); /* -INF */ + int m, j; + double F, f, g, q, u, u2, v, zero = 0.0, one = 1.0; + volatile double u1; + + /* Catch special cases */ + if (x <= 0) + if (_IEEE && x == zero) /* log(0) = -Inf */ + return (-one/zero); + else if (_IEEE) /* log(neg) = NaN */ + return (zero/zero); + else if (x == zero) /* NOT REACHED IF _IEEE */ + return (infnan(-ERANGE)); else - return (infnan(EDOM)); /* NaN */ -#else /* defined(vax)||defined(tahoe) */ - /* zero argument, return -INF with signal */ - if ( x == zero ) - return( negone/zero ); - - /* negative argument, return NaN with signal */ - else - return ( zero / zero ); -#endif /* defined(vax)||defined(tahoe) */ - } + return (infnan(EDOM)); + else if (!finite(x)) + if (_IEEE) /* x = NaN, Inf */ + return (x+x); + else + return (infnan(ERANGE)); + + /* Argument reduction: 1 <= g < 2; x/2^m = g; */ + /* y = F*(1 + f/F) for |f| <= 2^-8 */ + + m = logb(x); + g = ldexp(x, -m); + if (_IEEE && m == -1022) { + j = logb(g), m += j; + g = ldexp(g, -j); } - /* end of if (finite(x)) */ - /* NOTREACHED if defined(vax)||defined(tahoe) */ - - /* log(-INF) is NaN with signal */ - else if (x<0) - return(zero/zero); - - /* log(+INF) is +INF */ - else return(x); - + j = N*(g-1) + .5; + F = (1.0/N) * j + 1; /* F*128 is an integer in [128, 512] */ + f = g - F; + + /* Approximate expansion for log(1+f/F) ~= u + q */ + g = 1/(2*F+f); + u = 2*f*g; + v = u*u; + q = u*v*(A1 + v*(A2 + v*(A3 + v*A4))); + + /* case 1: u1 = u rounded to 2^-43 absolute. Since u < 2^-8, + * u1 has at most 35 bits, and F*u1 is exact, as F has < 8 bits. + * It also adds exactly to |m*log2_hi + log_F_head[j] | < 750 + */ + if (m | j) + u1 = u + 513, u1 -= 513; + + /* case 2: |1-x| < 1/256. The m- and j- dependent terms are zero; + * u1 = u to 24 bits. + */ + else + u1 = u, TRUNC(u1); + u2 = (2.0*(f - F*u1) - u1*f) * g; + /* u1 + u2 = 2f/(2F+f) to extra precision. */ + + /* log(x) = log(2^m*F*(1+f/F)) = */ + /* (m*log2_hi+logF_head[j]+u1) + (m*log2_lo+logF_tail[j]+q); */ + /* (exact) + (tiny) */ + + u1 += m*logF_head[N] + logF_head[j]; /* exact */ + u2 = (u2 + logF_tail[j]) + q; /* tiny */ + u2 += logF_tail[N]*m; + return (u1 + u2); +} + +/* + * Extra precision variant, returning struct {double a, b;}; + * log(x) = a+b to 63 bits, with a is rounded to 26 bits. + */ +struct Double +#ifdef _ANSI_SOURCE +__log__D(double x) +#else +__log__D(x) double x; +#endif +{ + int m, j; + double F, f, g, q, u, v, u2, one = 1.0; + volatile double u1; + struct Double r; + + /* Argument reduction: 1 <= g < 2; x/2^m = g; */ + /* y = F*(1 + f/F) for |f| <= 2^-8 */ + + m = logb(x); + g = ldexp(x, -m); + if (_IEEE && m == -1022) { + j = logb(g), m += j; + g = ldexp(g, -j); + } + j = N*(g-1) + .5; + F = (1.0/N) * j + 1; + f = g - F; + + g = 1/(2*F+f); + u = 2*f*g; + v = u*u; + q = u*v*(A1 + v*(A2 + v*(A3 + v*A4))); + if (m | j) + u1 = u + 513, u1 -= 513; + else + u1 = u, TRUNC(u1); + u2 = (2.0*(f - F*u1) - u1*f) * g; + + u1 += m*logF_head[N] + logF_head[j]; + + u2 += logF_tail[j]; u2 += q; + u2 += logF_tail[N]*m; + r.a = u1 + u2; /* Only difference is here */ + TRUNC(r.a); + r.b = (u1 - r.a) + u2; + return (r); } diff -ruN glibc-1.08.1/sysdeps/generic/log1p.c glibc-1.09/sysdeps/generic/log1p.c --- glibc-1.08.1/sysdeps/generic/log1p.c Sat May 15 18:01:06 1993 +++ glibc-1.09/sysdeps/generic/log1p.c Sun Jul 31 15:37:07 1994 @@ -1,6 +1,6 @@ /* - * Copyright (c) 1985 Regents of the University of California. - * All rights reserved. + * 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 @@ -32,7 +32,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)log1p.c 5.6 (Berkeley) 10/9/90"; +static char sccsid[] = "@(#)log1p.c 8.1 (Berkeley) 6/4/93"; #endif /* not lint */ /* LOG1P(x) @@ -114,7 +114,7 @@ double log1p(x) double x; { - static const double zero=0.0, negone= -1.0, one=1.0, + const static double zero=0.0, negone= -1.0, one=1.0, half=1.0/2.0, small=1.0E-20; /* 1+small == 1 */ double z,s,t,c; int k; @@ -137,7 +137,7 @@ /* compute log(1+x) */ s = x/(2+x); t = x*x*half; c += (k*ln2lo-c*x); - z = c+s*(t+log__L(s*s)); + z = c+s*(t+__log__L(s*s)); x += (z - t) ; return(k*ln2hi+x); diff -ruN glibc-1.08.1/sysdeps/generic/log__L.c glibc-1.09/sysdeps/generic/log__L.c --- glibc-1.08.1/sysdeps/generic/log__L.c Thu Jul 30 18:50:46 1992 +++ glibc-1.09/sysdeps/generic/log__L.c Sun Jul 31 15:37:42 1994 @@ -1,6 +1,6 @@ /* - * Copyright (c) 1985 Regents of the University of California. - * All rights reserved. + * 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 @@ -32,7 +32,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)log__L.c 5.6 (Berkeley) 10/9/90"; +static char sccsid[] = "@(#)log__L.c 8.1 (Berkeley) 6/4/93"; #endif /* not lint */ /* log__L(Z) @@ -99,7 +99,7 @@ #define L8 vccast(L8) #endif -double log__L(z) +double __log__L(z) double z; { #if defined(vax)||defined(tahoe) diff -ruN glibc-1.08.1/sysdeps/generic/make_siglist.c glibc-1.09/sysdeps/generic/make_siglist.c --- glibc-1.08.1/sysdeps/generic/make_siglist.c Sat May 22 23:10:53 1993 +++ glibc-1.09/sysdeps/generic/make_siglist.c Thu Sep 15 16:55:25 1994 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify @@ -23,6 +23,8 @@ #undef HAVE_SYS_SIGLIST +#define sys_siglist my_siglist /* Avoid clash with signal.h. */ + #include "signame.c" diff -ruN glibc-1.08.1/sysdeps/generic/mathimpl.h glibc-1.09/sysdeps/generic/mathimpl.h --- glibc-1.08.1/sysdeps/generic/mathimpl.h Sat May 15 18:01:06 1993 +++ glibc-1.09/sysdeps/generic/mathimpl.h Sun Jul 31 15:39:40 1994 @@ -27,13 +27,9 @@ #undef expm1 #define expm1 __expm1 -#define exp__E __exp__E -#define log__L __log__L - - /* - * Copyright (c) 1988 The Regents of the University of California. - * All rights reserved. + * 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 @@ -63,7 +59,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)mathimpl.h 5.4 (Berkeley) 3/5/91 + * @(#)mathimpl.h 8.1 (Berkeley) 6/4/93 */ #include @@ -104,7 +100,7 @@ * We define "vccast" if this needs doing. */ # define vc(name, value, x1,x2,x3,x4, bexp, xval) \ - static const long cat3(name,,x)[] = {cat3t(0x,x1,x2), cat3t(0x,x3,x4)}; + const static long cat3(name,,x)[] = {cat3t(0x,x1,x2), cat3t(0x,x3,x4)}; # define ic(name, value, bexp, xval) ; @@ -115,7 +111,7 @@ # define vc(name, value, x1,x2,x3,x4, bexp, xval) ; # define ic(name, value, bexp, xval) \ - static const double name = value; + const static double name = value; #endif /* defined(vax)||defined(tahoe) */ @@ -123,6 +119,9 @@ /* * Functions internal to the math package, yet not static. */ -extern double exp__E(); -extern double log__L(); +extern double __exp__E(); +extern double __log__L(); +struct Double {double a, b;}; +double __exp__D __P((double, double)); +struct Double __log__D __P((double)); diff -ruN glibc-1.08.1/sysdeps/generic/memcmp.c glibc-1.09/sysdeps/generic/memcmp.c --- glibc-1.08.1/sysdeps/generic/memcmp.c Mon Jan 17 17:26:47 1994 +++ glibc-1.09/sysdeps/generic/memcmp.c Sat Sep 24 13:40:28 1994 @@ -61,6 +61,11 @@ #endif /* In the GNU C library. */ +#ifdef WORDS_BIGENDIAN +#define CMP_LT_OR_GT(a, b) ((a) > (b) ? 1 : -1) +#else +#define CMP_LT_OR_GT(a, b) memcmp_bytes ((a), (b)) +#endif /* BE VERY CAREFUL IF YOU CHANGE THIS CODE! */ @@ -155,41 +160,25 @@ a0 = ((op_t *) srcp1)[0]; b0 = ((op_t *) srcp2)[0]; if (a1 != b1) -#ifdef WORDS_BIGENDIAN - return a1 > b1 ? 1 : -1; -#else - return memcmp_bytes (a1, b1); -#endif + return CMP_LT_OR_GT (a1, b1); do3: a1 = ((op_t *) srcp1)[1]; b1 = ((op_t *) srcp2)[1]; if (a0 != b0) -#ifdef WORDS_BIGENDIAN - return a0 > b0 ? 1 : -1; -#else - return memcmp_bytes (a0, b0); -#endif + return CMP_LT_OR_GT (a0, b0); do2: a0 = ((op_t *) srcp1)[2]; b0 = ((op_t *) srcp2)[2]; if (a1 != b1) -#ifdef WORDS_BIGENDIAN - return a1 > b1 ? 1 : -1; -#else - return memcmp_bytes (a1, b1); -#endif + return CMP_LT_OR_GT (a1, b1); do1: a1 = ((op_t *) srcp1)[3]; b1 = ((op_t *) srcp2)[3]; if (a0 != b0) -#ifdef WORDS_BIGENDIAN - return a0 > b0 ? 1 : -1; -#else - return memcmp_bytes (a0, b0); -#endif + return CMP_LT_OR_GT (a0, b0); srcp1 += 4 * OPSIZ; srcp2 += 4 * OPSIZ; @@ -201,11 +190,7 @@ it into the loop. */ do0: if (a1 != b1) -#ifdef WORDS_BIGENDIAN - return a1 > b1 ? 1 : -1; -#else - return memcmp_bytes (a1, b1); -#endif + return CMP_LT_OR_GT (a1, b1); return 0; } @@ -279,44 +264,28 @@ b0 = ((op_t *) srcp2)[0]; x = MERGE(a2, shl, a3, shr); if (x != b3) -#ifdef WORDS_BIGENDIAN - return x > b3 ? 1 : -1; -#else - return memcmp_bytes (x, b3); -#endif + return CMP_LT_OR_GT (x, b3); do3: a1 = ((op_t *) srcp1)[1]; b1 = ((op_t *) srcp2)[1]; x = MERGE(a3, shl, a0, shr); if (x != b0) -#ifdef WORDS_BIGENDIAN - return x > b0 ? 1 : -1; -#else - return memcmp_bytes (x, b0); -#endif + return CMP_LT_OR_GT (x, b0); do2: a2 = ((op_t *) srcp1)[2]; b2 = ((op_t *) srcp2)[2]; x = MERGE(a0, shl, a1, shr); if (x != b1) -#ifdef WORDS_BIGENDIAN - return x > b1 ? 1 : -1; -#else - return memcmp_bytes (x, b1); -#endif + return CMP_LT_OR_GT (x, b1); do1: a3 = ((op_t *) srcp1)[3]; b3 = ((op_t *) srcp2)[3]; x = MERGE(a1, shl, a2, shr); if (x != b2) -#ifdef WORDS_BIGENDIAN - return x > b2 ? 1 : -1; -#else - return memcmp_bytes (x, b2); -#endif + return CMP_LT_OR_GT (x, b2); srcp1 += 4 * OPSIZ; srcp2 += 4 * OPSIZ; @@ -329,11 +298,7 @@ do0: x = MERGE(a2, shl, a3, shr); if (x != b3) -#ifdef WORDS_BIGENDIAN - return x > b3 ? 1 : -1; -#else - return memcmp_bytes (x, b3); -#endif + return CMP_LT_OR_GT (x, b3); return 0; } diff -ruN glibc-1.08.1/sysdeps/generic/morecore.c glibc-1.09/sysdeps/generic/morecore.c --- glibc-1.08.1/sysdeps/generic/morecore.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/generic/morecore.c Thu Sep 8 17:17:35 1994 @@ -0,0 +1,52 @@ +/* Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with the GNU C Library; see the file COPYING. If not, write to +the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef _MALLOC_INTERNAL +#define _MALLOC_INTERNAL +#include +#endif + +#ifndef __GNU_LIBRARY__ +#define __sbrk sbrk +#endif + +#ifdef __GNU_LIBRARY__ +/* It is best not to declare this and cast its result on foreign operating + systems with potentially hostile include files. */ +extern __ptr_t __sbrk __P ((int increment)); +#endif + +#ifndef NULL +#define NULL 0 +#endif + +/* Allocate INCREMENT more bytes of data space, + and return the start of data space, or NULL on errors. + If INCREMENT is negative, shrink data space. */ +__ptr_t +__default_morecore (increment) +#ifdef __STDC__ + ptrdiff_t increment; +#else + int increment; +#endif +{ + __ptr_t result = (__ptr_t) __sbrk ((int) increment); + if (result == (__ptr_t) -1) + return NULL; + return result; +} diff -ruN glibc-1.08.1/sysdeps/generic/mul_n.c glibc-1.09/sysdeps/generic/mul_n.c --- glibc-1.08.1/sysdeps/generic/mul_n.c Tue Apr 26 22:00:43 1994 +++ glibc-1.09/sysdeps/generic/mul_n.c Tue Aug 2 20:58:41 1994 @@ -321,7 +321,6 @@ { mp_size_t hsize = size >> 1; mp_limb cy; - int negflg; /*** Product H. ________________ ________________ |_____U1 x U1____||____U0 x U0_____| */ diff -ruN glibc-1.08.1/sysdeps/generic/pow.c glibc-1.09/sysdeps/generic/pow.c --- glibc-1.08.1/sysdeps/generic/pow.c Sat May 15 18:01:06 1993 +++ glibc-1.09/sysdeps/generic/pow.c Sun Jul 31 15:42:42 1994 @@ -1,6 +1,6 @@ /* - * Copyright (c) 1985 Regents of the University of California. - * All rights reserved. + * 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 @@ -32,7 +32,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)pow.c 5.7 (Berkeley) 10/9/90"; +static char sccsid[] = "@(#)pow.c 8.1 (Berkeley) 6/4/93"; #endif /* not lint */ /* POW(X,Y) @@ -40,7 +40,7 @@ * DOUBLE PRECISION (VAX D format 56 bits, IEEE DOUBLE 53 BITS) * CODED IN C BY K.C. NG, 1/8/85; * REVISED BY K.C. NG on 7/10/85. - * + * KERNEL pow_P() REPLACED BY P. McILROY 7/22/92. * Required system supported functions: * scalb(x,n) * logb(x) @@ -49,9 +49,8 @@ * drem(x,y) * * Required kernel functions: - * exp__E(a,c) ...return exp(a+c) - 1 - a*a/2 - * log__L(x) ...return (log(1+x) - 2s)/s, s=x/(2+x) - * pow_p(x,y) ...return +(anything)**(finite non zero) + * exp__D(a,c) exp(a + c) for |a| << |c| + * struct d_double dlog(x) r.a + r.b, |r.b| < |r.a| * * Method * 1. Compute and return log(x) in three pieces: @@ -69,10 +68,12 @@ * (anything) ** 1 is itself; * (anything) ** NaN is NaN; * NaN ** (anything except 0) is NaN; - * +-(anything > 1) ** +INF is +INF; + * +(anything > 1) ** +INF is +INF; + * -(anything > 1) ** +INF is NaN; * +-(anything > 1) ** -INF is +0; * +-(anything < 1) ** +INF is +0; - * +-(anything < 1) ** -INF is +INF; + * +(anything < 1) ** -INF is +INF; + * -(anything < 1) ** -INF is NaN; * +-1 ** +-INF is NaN and signal INVALID; * +0 ** +(anything except 0, NaN) is +0; * -0 ** +(anything except 0, NaN, odd integer) is +0; @@ -104,151 +105,111 @@ */ #include +#include + #include "mathimpl.h" -#include -vc(ln2hi, 6.9314718055829871446E-1 ,7217,4031,0000,f7d0, 0, .B17217F7D00000) -vc(ln2lo, 1.6465949582897081279E-12 ,bcd5,2ce7,d9cc,e4f1, -39, .E7BCD5E4F1D9CC) -vc(invln2, 1.4426950408889634148E0 ,aa3b,40b8,17f1,295c, 1, .B8AA3B295C17F1) -vc(sqrt2, 1.4142135623730950622E0 ,04f3,40b5,de65,33f9, 1, .B504F333F9DE65) - -ic(ln2hi, 6.9314718036912381649E-1, -1, 1.62E42FEE00000) -ic(ln2lo, 1.9082149292705877000E-10, -33, 1.A39EF35793C76) -ic(invln2, 1.4426950408889633870E0, 0, 1.71547652B82FE) -ic(sqrt2, 1.4142135623730951455E0, 0, 1.6A09E667F3BCD) - -#ifdef vccast -#define ln2hi vccast(ln2hi) -#define ln2lo vccast(ln2lo) -#define invln2 vccast(invln2) -#define sqrt2 vccast(sqrt2) -#endif +#if (defined(vax) || defined(tahoe)) +#define TRUNC(x) x = (double) (float) x +#define _IEEE 0 +#else +#define _IEEE 1 +#define endian (((*(int *) &one)) ? 1 : 0) +#define TRUNC(x) *(((int *) &x)+endian) &= 0xf8000000 +#define infnan(x) 0.0 +#endif /* vax or tahoe */ -static const double zero=0.0, half=1.0/2.0, one=1.0, two=2.0, negone= -1.0; +const static double zero=0.0, one=1.0, two=2.0, negone= -1.0; -static double pow_p(); +static double pow_P __P((double, double)); double pow(x,y) double x,y; { double t; - - if (y==zero) return(one); - else if(y==one -#if !defined(vax)&&!defined(tahoe) - || __isnan (x) /* BSD code did `x!=x' */ -#endif /* !defined(vax)&&!defined(tahoe) */ - ) return( x ); /* if x is NaN or y=1 */ -#if !defined(vax)&&!defined(tahoe) - else if(__isnan(y)) return( y ); /* if y is NaN */ -#endif /* !defined(vax)&&!defined(tahoe) */ - else if(!finite(y)) /* if y is INF */ - if((t=copysign(x,one))==one) return(zero/zero); - else if(t>one) return((y>zero)?y:zero); - else return((yone) + return ((y<0)? zero : ((x0)? zero : ((x<0)? y-y : -y)); + else if (y==two) + return (x*x); + else if (y==negone) + return (one/x); + /* x > 0, x == +0 */ + else if (copysign(one, x) == one) + return (pow_P(x, y)); /* sign(x)= -1 */ /* if y is an even integer */ - else if ( (t=drem(y,two)) == zero) return( pow_p(-x,y) ); + else if ( (t=drem(y,two)) == zero) + return (pow_P(-x, y)); /* if y is an odd integer */ - else if (copysign(t,one) == one) return( -pow_p(-x,y) ); + else if (copysign(t,one) == one) + return (-pow_P(-x, y)); /* Henceforth y is not an integer */ - else if(x==zero) /* x is -0 */ - return((y>zero)?-x:one/(-x)); - else { /* return NaN */ -#if defined(vax)||defined(tahoe) - return (infnan(EDOM)); /* NaN */ -#else /* defined(vax)||defined(tahoe) */ - return(zero/zero); -#endif /* defined(vax)||defined(tahoe) */ - } + else if (x==zero) /* x is -0 */ + return ((y>zero)? -x : one/(-x)); + else if (_IEEE) + return (zero/zero); + else + return (infnan(EDOM)); } - -#ifndef mc68881 -/* pow_p(x,y) return x**y for x with sign=1 and finite y */ -static double pow_p(x,y) -double x,y; +/* kernel function for x >= 0 */ +static double +#ifdef _ANSI_SOURCE +pow_P(double x, double y) +#else +pow_P(x, y) double x, y; +#endif { - double c,s,t,z,tx,ty; -#ifdef tahoe - double tahoe_tmp; -#endif /* tahoe */ - float sx,sy; - long k; - int n,m; - - if(x==zero||!finite(x)) { /* if x is +INF or +0 */ -#if defined(vax)||defined(tahoe) - return((y>zero)?x:infnan(ERANGE)); /* if yzero)?x:one/x); -#endif /* defined(vax)||defined(tahoe) */ - } - if(x==1.0) return(x); /* if x=1.0, return 1 since y is finite */ - - /* reduce x to z in [sqrt(1/2)-1, sqrt(2)-1] */ - z=scalb(x,-(n=logb(x))); -#if !defined(vax)&&!defined(tahoe) /* IEEE double; subnormal number */ - if(n <= -1022) {n += (m=logb(z)); z=scalb(z,-m);} -#endif /* !defined(vax)&&!defined(tahoe) */ - if(z >= sqrt2 ) {n += 1; z *= half;} z -= one ; - - /* log(x) = nlog2+log(1+z) ~ nlog2 + t + tx */ - s=z/(two+z); c=z*z*half; tx=s*(c+log__L(s*s)); - t= z-(c-tx); tx += (z-t)-c; - - /* if y*log(x) is neither too big nor too small */ - if((s=logb(y)+logb(n+t)) < 12.0) - if(s>-60.0) { - - /* compute y*log(x) ~ mlog2 + t + c */ - s=y*(n+invln2*t); - m=s+copysign(half,s); /* m := nint(y*log(x)) */ - /* (long int) (double) LONG_MIN overflows on some systems. */ - if (y >= (double) LONG_MIN + 1 && y <= (double) LONG_MAX && - (double) (long int) y == y) - { - /* Y is an integer */ - k = m - (long int) y * n; - sx=t; tx+=(t-sx); } - else { /* if y is not an integer */ - k =m; - tx+=n*ln2lo; - sx=(c=n*ln2hi)+t; tx+=(c-sx)+t; } - /* end of reductions for integral/nonintegral y */ - - sy=y; ty=y-sy; /* y ~ sy + ty */ -#ifdef tahoe - s = (tahoe_tmp = sx)*sy-k*ln2hi; -#else /* tahoe */ - s=(double)sx*sy-k*ln2hi; /* (sy+ty)*(sx+tx)-kln2 */ -#endif /* tahoe */ - z=(tx*ty-k*ln2lo); - tx=tx*sy; ty=sx*ty; - t=ty+z; t+=tx; t+=s; - c= -((((t-s)-tx)-ty)-z); - - /* return exp(y*log(x)) */ - t += exp__E(t,c); return(scalb(one+t,m)); - } - /* end of if log(y*log(x)) > -60.0 */ - - else - /* exp(+- tiny) = 1 with inexact flag */ - {ln2hi+ln2lo; return(one);} - else if(copysign(one,y)*(n+invln2*t) zero) + return (zero); + else if (_IEEE) + return (huge*huge); + else + return (infnan(ERANGE)); + if (x == one) + return (one); + if (!finite(x)) + if (y < zero) + return (zero); + else if (_IEEE) + return (huge*huge); + else + return (infnan(ERANGE)); + if (y >= 7e18) /* infinity */ + if (x < 1) + return(tiny*tiny); + else if (_IEEE) + return (huge*huge); + else + return (infnan(ERANGE)); + + /* Return exp(y*log(x)), using simulated extended */ + /* precision for the log and the multiply. */ + + s = __log__D(x); + t.a = y; + TRUNC(t.a); + t.b = y - t.a; + t.b = s.b*y + t.b*s.a; + t.a *= s.a; + s.a = t.a + t.b; + s.b = (t.a - s.a) + t.b; + return (__exp__D(s.a, s.b)); } -#endif /* mc68881 */ diff -ruN glibc-1.08.1/sysdeps/generic/putenv.c glibc-1.09/sysdeps/generic/putenv.c --- glibc-1.08.1/sysdeps/generic/putenv.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/generic/putenv.c Mon Oct 17 00:05:38 1994 @@ -0,0 +1,101 @@ +/* Copyright (C) 1991, 1994 Free Software Foundation, Inc. + +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include + +#ifdef HAVE_CONFIG_H +#include +#endif + +#if defined (__GNU_LIBRARY__) || defined (HAVE_STDLIB_H) +#include +#endif +#if defined (__GNU_LIBRARY__) || defined (HAVE_STRING_H) +#include +#endif +#if defined (__GNU_LIBRARY__) || defined (HAVE_UNISTD_H) +#include +#endif + +#if !defined (__GNU_LIBRARY__) && !defined (HAVE_STRCHR) +#define strchr index +#endif +#if !defined (__GNU_LIBRARY__) && !defined (HAVE_MEMCPY) +#define memcpy(d,s,n) bcopy ((s), (d), (n)) +#endif + +#ifndef HAVE_GNU_LD +#define __environ environ +#endif + + +/* Put STRING, which is of the form "NAME=VALUE", in the environment. */ +int +putenv (string) + const char *string; +{ + const char *const name_end = strchr (string, '='); + register size_t size; + register char **ep; + + if (name_end == NULL) + { + /* Remove the variable from the environment. */ + size = strlen (string); + for (ep = __environ; *ep != NULL; ++ep) + if (!strncmp (*ep, string, size) && (*ep)[size] == '=') + { + while (ep[1] != NULL) + { + ep[0] = ep[1]; + ++ep; + } + *ep = NULL; + return 0; + } + } + + size = 0; + for (ep = __environ; *ep != NULL; ++ep) + if (!strncmp (*ep, string, name_end - string) && + (*ep)[name_end - string] == '=') + break; + else + ++size; + + if (*ep == NULL) + { + static char **last_environ = NULL; + char **new_environ = (char **) malloc ((size + 2) * sizeof (char *)); + if (new_environ == NULL) + return -1; + (void) memcpy ((void *) new_environ, (void *) __environ, + size * sizeof (char *)); + new_environ[size] = (char *) string; + new_environ[size + 1] = NULL; + if (last_environ != NULL) + free ((void *) last_environ); + last_environ = new_environ; + __environ = new_environ; + } + else + *ep = (char *) string; + + return 0; +} diff -ruN glibc-1.08.1/sysdeps/generic/resourcebits.h glibc-1.09/sysdeps/generic/resourcebits.h --- glibc-1.08.1/sysdeps/generic/resourcebits.h Mon May 30 20:47:31 1994 +++ glibc-1.09/sysdeps/generic/resourcebits.h Mon Oct 17 02:14:09 1994 @@ -42,7 +42,7 @@ RLIMIT_RSS, /* Locked-in-memory address space. */ RLIMIT_MEMLOCK, - /* Number of processes, */ + /* Number of processes. */ RLIMIT_NPROC, /* Number of open files. */ RLIMIT_OFILE, diff -ruN glibc-1.08.1/sysdeps/generic/setenv.c glibc-1.09/sysdeps/generic/setenv.c --- glibc-1.08.1/sysdeps/generic/setenv.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/generic/setenv.c Mon Jul 18 18:04:36 1994 @@ -0,0 +1,86 @@ +/* Copyright (C) 1992 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include +#include + +#ifndef HAVE_GNU_LD +#define __environ environ +#endif + +int +DEFUN(setenv, (name, value, replace), + CONST char *name AND CONST char *value AND int replace) +{ + register char **ep; + register size_t size; + CONST size_t namelen = strlen (name); + CONST size_t vallen = strlen (value); + + size = 0; + for (ep = __environ; *ep != NULL; ++ep) + if (!strncmp (*ep, name, namelen) && (*ep)[namelen] == '=') + break; + else + ++size; + + if (*ep == NULL) + { + static char **last_environ = NULL; + char **new_environ = (char **) malloc((size + 2) * sizeof(char *)); + if (new_environ == NULL) + return -1; + (void) memcpy((PTR) new_environ, (PTR) __environ, size * sizeof(char *)); + + new_environ[size] = malloc (namelen + 1 + vallen + 1); + if (new_environ[size] == NULL) + { + free (new_environ); + errno = ENOMEM; + return -1; + } + memcpy (new_environ[size], name, namelen); + new_environ[size][namelen] = '='; + memcpy (&new_environ[size][namelen + 1], value, vallen + 1); + + new_environ[size + 1] = NULL; + + if (last_environ != NULL) + free ((PTR) last_environ); + last_environ = new_environ; + __environ = new_environ; + } + else if (replace) + { + size_t len = strlen (*ep); + if (len < namelen + 1 + vallen) + { + char *new = malloc (namelen + 1 + vallen); + if (new == NULL) + return -1; + *ep = new; + } + memcpy (*ep, name, namelen); + (*ep)[namelen] = '='; + memcpy (&(*ep)[namelen + 1], value, vallen + 1); + } + + return 0; +} diff -ruN glibc-1.08.1/sysdeps/generic/signame.c glibc-1.09/sysdeps/generic/signame.c --- glibc-1.08.1/sysdeps/generic/signame.c Mon May 9 22:12:40 1994 +++ glibc-1.09/sysdeps/generic/signame.c Mon Sep 26 17:57:40 1994 @@ -20,14 +20,7 @@ #include #ifdef HAVE_CONFIG_H -#if defined (emacs) || defined (CONFIG_BROKETS) -/* We use instead of "config.h" so that a compilation - using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h - (which it would do because it found this file in $srcdir). */ #include -#else -#include "config.h" -#endif #endif /* Some systems do not define NSIG in . */ diff -ruN glibc-1.08.1/sysdeps/generic/sigset.h glibc-1.09/sysdeps/generic/sigset.h --- glibc-1.08.1/sysdeps/generic/sigset.h Sat May 21 20:01:15 1994 +++ glibc-1.09/sysdeps/generic/sigset.h Thu Nov 3 21:45:48 1994 @@ -41,14 +41,14 @@ overflow if `sigset_t' is wider than `int'. */ #define __sigmask(sig) (((__sigset_t) 1) << ((sig) - 1)) -#define __sigemptyset(set) ((*(set) = 0L), 0) -#define __sigfillset(set) ((*(set) = -1L), 0) +#define __sigemptyset(set) ((*(set) = (__sigset_t) 0), 0) +#define __sigfillset(set) ((*(set) = ~(__sigset_t) 0), 0) /* These functions must check for a bogus signal number. We detect it by a zero sigmask, since a number too low or too high will have shifted the 1 - off the high end of the mask. If we find an error, we punt to the - real-function version of the same function, so as to avoid referring to - `errno' in this file (sigh). */ + off the high end of the mask. If we find an error, we punt to a random + call we know fails with EINVAL (kludge city!), so as to avoid referring + to `errno' in this file (sigh). */ #ifndef _EXTERN_INLINE #define _EXTERN_INLINE extern __inline @@ -57,9 +57,16 @@ _EXTERN_INLINE int \ __##NAME (CONST __sigset_t *__set, int __sig) \ { \ - extern int NAME (CONST __sigset_t *, int); \ - __sigset_t __mask = __sigmask (__sig); \ - return __mask ? (BODY) : (NAME) (__set, __sig); \ + if (__sig < 1 || __sig > sizeof (__sigset_t) * 8) \ + { \ + extern int raise (int); \ + return raise (-1); \ + } \ + else \ + { \ + __sigset_t __mask = __sigmask (__sig); \ + return BODY; \ + } \ } __SIGSETFN (sigismember, (*__set & __mask) ? 1 : 0, __const) diff -ruN glibc-1.08.1/sysdeps/generic/sincos.c glibc-1.09/sysdeps/generic/sincos.c --- glibc-1.08.1/sysdeps/generic/sincos.c Thu Jul 30 18:50:16 1992 +++ glibc-1.09/sysdeps/generic/sincos.c Sun Jul 31 15:43:25 1994 @@ -1,6 +1,6 @@ /* - * Copyright (c) 1987 Regents of the University of California. - * All rights reserved. + * 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 @@ -32,7 +32,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)sincos.c 5.5 (Berkeley) 10/9/90"; +static char sccsid[] = "@(#)sincos.c 8.1 (Berkeley) 6/4/93"; #endif /* not lint */ #include "trig.h" diff -ruN glibc-1.08.1/sysdeps/generic/sinh.c glibc-1.09/sysdeps/generic/sinh.c --- glibc-1.08.1/sysdeps/generic/sinh.c Thu Jul 30 18:50:50 1992 +++ glibc-1.09/sysdeps/generic/sinh.c Sun Jul 31 15:44:08 1994 @@ -1,6 +1,6 @@ /* - * Copyright (c) 1985 Regents of the University of California. - * All rights reserved. + * 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 @@ -32,7 +32,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)sinh.c 5.6 (Berkeley) 10/9/90"; +static char sccsid[] = "@(#)sinh.c 8.1 (Berkeley) 6/4/93"; #endif /* not lint */ /* SINH(X) diff -ruN glibc-1.08.1/sysdeps/generic/strchr.c glibc-1.09/sysdeps/generic/strchr.c --- glibc-1.08.1/sysdeps/generic/strchr.c Mon Jun 28 02:05:21 1993 +++ glibc-1.09/sysdeps/generic/strchr.c Wed Oct 26 20:43:19 1994 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1993 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1993, 1994 Free Software Foundation, Inc. Based on strlen implemention by Torbjorn Granlund (tege@sics.se), with help from Dan Sahlin (dan@sics.se) and bug fix and commentary by Jim Blandy (jimb@ai.mit.edu); @@ -154,7 +154,7 @@ return NULL; if (sizeof (longword) > 4) { - if (*cp == c) + if (*++cp == c) return (char *) cp; else if (*cp == '\0') return NULL; diff -ruN glibc-1.08.1/sysdeps/generic/strcspn.c glibc-1.09/sysdeps/generic/strcspn.c --- glibc-1.08.1/sysdeps/generic/strcspn.c Wed Jun 12 14:24:16 1991 +++ glibc-1.09/sysdeps/generic/strcspn.c Mon Oct 17 00:08:01 1994 @@ -1,4 +1,5 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1994 Free Software Foundation, Inc. + This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -16,20 +17,19 @@ not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include #include - /* Return the length of the maximum inital segment of S which contains no characters from REJECT. */ size_t -DEFUN(strcspn, (s, reject), - register CONST char *s AND register CONST char *reject) +strcspn (s, reject) + register const char *s; + register const char *reject; { register size_t count = 0; while (*s != '\0') - if (strchr(reject, *s++) == NULL) + if (strchr (reject, *s++) == NULL) ++count; else return count; diff -ruN glibc-1.08.1/sysdeps/generic/sysd-stdio.c glibc-1.09/sysdeps/generic/sysd-stdio.c --- glibc-1.08.1/sysdeps/generic/sysd-stdio.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/generic/sysd-stdio.c Mon Jul 18 18:04:39 1994 @@ -0,0 +1,189 @@ +/* Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* Read N bytes into BUF from COOKIE. */ +int +DEFUN(__stdio_read, (cookie, buf, n), + PTR cookie AND register char *buf AND register size_t n) +{ + CONST int fd = (int) cookie; +#if defined (EINTR) && defined (EINTR_REPEAT) + int save = errno; + int nread; + + try:; + errno = 0; + nread = __read (fd, buf, (int) n); + if (nread < 0) + { + if (errno == EINTR) + goto try; + return -1; + } + errno = save; + return nread; + +#else /* No EINTR. */ + return __read (fd, buf, n); +#endif +} + + +/* Write N bytes from BUF to COOKIE. */ +int +DEFUN(__stdio_write, (cookie, buf, n), + PTR cookie AND register CONST char *buf AND register size_t n) +{ + CONST int fd = (int) cookie; + register size_t written = 0; + + while (n > 0) + { + int count = __write (fd, buf, (int) n); + if (count > 0) + { + buf += count; + written += count; + n -= count; + } + else if (count < 0 +#if defined (EINTR) && defined (EINTR_REPEAT) + && errno != EINTR +#endif + ) + /* Write error. */ + return -1; + } + + return (int) written; +} + + +/* Move COOKIE's file position *POS bytes, according to WHENCE. + The new file position is stored in *POS. + Returns zero if successful, nonzero if not. */ +int +DEFUN(__stdio_seek, (cookie, pos, whence), + PTR cookie AND fpos_t *pos AND int whence) +{ + off_t new; + new = __lseek ((int) cookie, (off_t) *pos, whence); + if (new < 0) + return 1; + *pos = (fpos_t) new; + return 0; +} + + +/* Close COOKIE. */ +int +DEFUN(__stdio_close, (cookie), PTR cookie) +{ + return __close ((int) cookie); +} + +/* Return the POSIX.1 file descriptor associated with COOKIE, + or -1 for errors. If COOKIE does not relate to any POSIX.1 file + descriptor, this should return -1 with errno set to EOPNOTSUPP. */ +int +DEFUN(__stdio_fileno, (cookie), PTR cookie) +{ + return (int) cookie; +} + + +/* Open the given file with the mode given in the __io_mode argument. */ +int +DEFUN(__stdio_open, (filename, m, cookieptr), + CONST char *filename AND __io_mode m AND PTR *cookieptr) +{ + int fd; + int mode; + + if (m.__read && m.__write) + mode = O_RDWR; + else + mode = m.__read ? O_RDONLY : O_WRONLY; + + if (m.__append) + mode |= O_APPEND; + if (m.__exclusive) + mode |= O_EXCL; + if (m.__truncate) + mode |= O_TRUNC; + + if (m.__create) + fd = __open (filename, mode | O_CREAT, + S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH); + else + fd = __open (filename, mode); + + if (fd < 0) + return -1; + + *cookieptr = (PTR) fd; + return 0; +} + + +/* Open FILENAME with the mode in M. Use the same magic cookie + already in *COOKIEPTR if possible, closing the old cookie with CLOSEFN. */ +int +DEFUN(__stdio_reopen, (filename, m, cookieptr), + CONST char *filename AND __io_mode m AND + PTR *cookieptr AND __io_close_fn closefn) +{ + PTR newcookie; + + /* We leave the old descriptor open while we open the file. + That way ``freopen ("/dev/stdin", "r", stdin)'' works. */ + + if (__stdio_open (filename, m, &newcookie)) + { + if (errno == ENFILE || errno == EMFILE) + { + /* We are out of file descriptors. Try closing the old one and + retrying the open. */ + (void) (*closefn) (*cookieptr); + if (__stdio_open (filename, m, &newcookie)) + return -1; + } + } + + if (newcookie != *cookieptr) + { + if (closefn != __stdio_close || + /* Try to move the descriptor to the desired one. */ + __dup2 ((int) newcookie, (int) *cookieptr) < 0) + /* Didn't work. Give the caller the new cookie. */ + *cookieptr = newcookie; + } + + return 0; +} diff -ruN glibc-1.08.1/sysdeps/generic/tan.c glibc-1.09/sysdeps/generic/tan.c --- glibc-1.08.1/sysdeps/generic/tan.c Thu Jul 30 18:50:17 1992 +++ glibc-1.09/sysdeps/generic/tan.c Sun Jul 31 15:45:11 1994 @@ -1,6 +1,6 @@ /* - * Copyright (c) 1987 Regents of the University of California. - * All rights reserved. + * 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 @@ -32,7 +32,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)tan.c 5.5 (Berkeley) 10/9/90"; +static char sccsid[] = "@(#)tan.c 8.1 (Berkeley) 6/4/93"; #endif /* not lint */ #include "trig.h" diff -ruN glibc-1.08.1/sysdeps/generic/tanh.c glibc-1.09/sysdeps/generic/tanh.c --- glibc-1.08.1/sysdeps/generic/tanh.c Thu Jul 30 18:50:52 1992 +++ glibc-1.09/sysdeps/generic/tanh.c Sun Jul 31 15:45:43 1994 @@ -1,6 +1,6 @@ /* - * Copyright (c) 1985 Regents of the University of California. - * All rights reserved. + * 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 @@ -32,7 +32,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)tanh.c 5.5 (Berkeley) 10/9/90"; +static char sccsid[] = "@(#)tanh.c 8.1 (Berkeley) 6/4/93"; #endif /* not lint */ /* TANH(X) diff -ruN glibc-1.08.1/sysdeps/generic/termbits.h glibc-1.09/sysdeps/generic/termbits.h --- glibc-1.08.1/sysdeps/generic/termbits.h Tue May 10 17:23:14 1994 +++ glibc-1.09/sysdeps/generic/termbits.h Wed Oct 26 01:11:34 1994 @@ -87,7 +87,7 @@ /* Local modes. */ tcflag_t c_lflag; #ifdef __USE_BSD - #define ECHOKE (1 << 0) /* Visual erase for KILL. */ +#define ECHOKE (1 << 0) /* Visual erase for KILL. */ #endif #define _ECHOE (1 << 1) /* Visual erase for ERASE. */ #define ECHOE _ECHOE diff -ruN glibc-1.08.1/sysdeps/generic/trig.h glibc-1.09/sysdeps/generic/trig.h --- glibc-1.08.1/sysdeps/generic/trig.h Thu Jul 30 18:50:20 1992 +++ glibc-1.09/sysdeps/generic/trig.h Sun Jul 31 15:46:24 1994 @@ -1,6 +1,6 @@ /* - * Copyright (c) 1987 Regents of the University of California. - * All rights reserved. + * 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 @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)trig.h 5.6 (Berkeley) 10/9/90 + * @(#)trig.h 8.1 (Berkeley) 6/4/93 */ #include "mathimpl.h" diff -ruN glibc-1.08.1/sysdeps/generic/utsnamelen.h glibc-1.09/sysdeps/generic/utsnamelen.h --- glibc-1.08.1/sysdeps/generic/utsnamelen.h Mon May 25 19:33:00 1992 +++ glibc-1.09/sysdeps/generic/utsnamelen.h Mon Oct 3 02:09:28 1994 @@ -1,3 +1,3 @@ /* The size of the character arrays used to hold the information in a `struct utsname'. Enlarge this as necessary. */ -#define _UTSNAME_LENGTH 100 +#define _UTSNAME_LENGTH 1024 diff -ruN glibc-1.08.1/sysdeps/i386/add_n.S glibc-1.09/sysdeps/i386/add_n.S --- glibc-1.08.1/sysdeps/i386/add_n.S Mon May 16 21:57:46 1994 +++ glibc-1.09/sysdeps/i386/add_n.S Thu Sep 1 23:42:41 1994 @@ -26,8 +26,8 @@ # s2_ptr (sp + 12) # size (sp + 16) -#include "asm.h" #include "sysdep.h" +#include "asm-syntax.h" .text .align 2 diff -ruN glibc-1.08.1/sysdeps/i386/addmul_1.S glibc-1.09/sysdeps/i386/addmul_1.S --- glibc-1.08.1/sysdeps/i386/addmul_1.S Mon May 16 21:57:48 1994 +++ glibc-1.09/sysdeps/i386/addmul_1.S Thu Sep 1 23:42:36 1994 @@ -27,8 +27,8 @@ s2_limb (sp + 16) */ -#include "asm.h" #include "sysdep.h" +#include "asm-syntax.h" #define res_ptr edi #define s1_ptr esi diff -ruN glibc-1.08.1/sysdeps/i386/asm-syntax.h glibc-1.09/sysdeps/i386/asm-syntax.h --- glibc-1.08.1/sysdeps/i386/asm-syntax.h Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/i386/asm-syntax.h Fri Sep 2 00:43:20 1994 @@ -0,0 +1,50 @@ +/* asm.h -- Definitions for x86 syntax variations. + +Copyright (C) 1992, 1994 Free Software Foundation, Inc. + +This file is part of the GNU MP Library. + +The GNU MP Library is free software; you can redistribute it and/or modify +it under the terms of the GNU Library General Public License as published by +the Free Software Foundation; either version 2 of the License, or (at your +option) any later version. + +The GNU MP Library is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public +License for more details. + +You should have received a copy of the GNU Library General Public License +along with the GNU MP Library; see the file COPYING.LIB. If not, write to +the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#undef ALIGN + +#ifdef GAS_SYNTAX +#define R(r) %r +#define MEM(base)(base) +#define MEM_DISP(base,displacement)displacement(R(base)) +#define MEM_INDEX(base,index,size)(R(base),R(index),size) +#ifdef __STDC__ +#define INSN1(mnemonic,size_suffix,dst)mnemonic##size_suffix dst +#define INSN2(mnemonic,size_suffix,dst,src)mnemonic##size_suffix src,dst +#else +#define INSN1(mnemonic,size_suffix,dst)mnemonic/**/size_suffix dst +#define INSN2(mnemonic,size_suffix,dst,src)mnemonic/**/size_suffix src,dst +#endif +#define TEXT .text +#define ALIGN .align 4 +#define GLOBL .globl +#endif + +#ifdef INTEL_SYNTAX +#define R(r) r +#define MEM(base)[base] +#define MEM_DISP(base,displacement)[base+(displacement)] +#define MEM_INDEX(base,index,size)[base+index*size] +#define INSN1(mnemonic,size_suffix,dst)mnemonic dst +#define INSN2(mnemonic,size_suffix,dst,src)mnemonic dst,src +#define TEXT .text +#define ALIGN .align 4 +#define GLOBL .globl +#endif diff -ruN glibc-1.08.1/sysdeps/i386/asm.h glibc-1.09/sysdeps/i386/asm.h --- glibc-1.08.1/sysdeps/i386/asm.h Tue Apr 26 23:03:32 1994 +++ glibc-1.09/sysdeps/i386/asm.h Wed Dec 31 19:00:00 1969 @@ -1,51 +0,0 @@ -/* asm.h -- Definitions for x86 syntax variations. - -Copyright (C) 1992, 1994 Free Software Foundation, Inc. - -This file is part of the GNU MP Library. - -The GNU MP Library is free software; you can redistribute it and/or modify -it under the terms of the GNU Library General Public License as published by -the Free Software Foundation; either version 2 of the License, or (at your -option) any later version. - -The GNU MP Library is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -#ifdef GAS_SYNTAX -#define R(r) %r -#define MEM(base)(base) -#define MEM_DISP(base,displacement)displacement(R(base)) -#define MEM_INDEX(base,index,size)(R(base),R(index),size) -#ifdef __STDC__ -#define INSN1(mnemonic,size_suffix,dst)mnemonic##size_suffix dst -#define INSN2(mnemonic,size_suffix,dst,src)mnemonic##size_suffix src,dst -#else -#define INSN1(mnemonic,size_suffix,dst)mnemonic/**/size_suffix dst -#define INSN2(mnemonic,size_suffix,dst,src)mnemonic/**/size_suffix src,dst -#endif -#define TEXT .text -#define ALIGN .align 4 -#define GLOBL .globl -#define LAB(label) label: -#endif - -#ifdef INTEL_SYNTAX -#define R(r) r -#define MEM(base)[base] -#define MEM_DISP(base,displacement)[base+(displacement)] -#define MEM_INDEX(base,index,size)[base+index*size] -#define INSN1(mnemonic,size_suffix,dst)mnemonic dst -#define INSN2(mnemonic,size_suffix,dst,src)mnemonic dst,src -#define TEXT .text -#define ALIGN .align 4 -#define GLOBL .globl -#endif - diff -ruN glibc-1.08.1/sysdeps/i386/ffs.c glibc-1.09/sysdeps/i386/ffs.c --- glibc-1.08.1/sysdeps/i386/ffs.c Mon May 17 16:29:26 1993 +++ glibc-1.09/sysdeps/i386/ffs.c Mon Oct 10 00:30:32 1994 @@ -1,6 +1,6 @@ /* ffs -- find first set bit in a word, counted from least significant end. For Intel 80x86, x>=3. - Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. + Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc. Contributed by Torbjorn Granlund (tege@sics.se). The GNU C Library is free software; you can redistribute it and/or @@ -34,8 +34,8 @@ asm ("xorl %0,%0\n" /* Set CNT to zero. */ "bsfl %2,%1\n" /* Count low bits in X and store in %1. */ "jz nonzero\n" /* Jump if OK, i.e. X was non-zero. */ - "leal 1(%3),%0\n" /* Return bsfl-result plus one on %0. */ - "nonzero:" : "=a" (cnt), "=r" (tmp) : "rm" (x), "1" (tmp)); + "leal 1(%1),%0\n" /* Return bsfl-result plus one on %0. */ + "nonzero:" : "=&a" (cnt), "=r" (tmp) : "rm" (x)); return cnt; } diff -ruN glibc-1.08.1/sysdeps/i386/i586/memcopy.h glibc-1.09/sysdeps/i386/i586/memcopy.h --- glibc-1.08.1/sysdeps/i386/i586/memcopy.h Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/i386/i586/memcopy.h Mon Jul 18 18:03:47 1994 @@ -0,0 +1,94 @@ +/* memcopy.h -- definitions for memory copy functions. Pentium version. + Copyright (C) 1994 Free Software Foundation, Inc. + Contributed by Torbjorn Granlund (tege@sics.se). + +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +/* Get the i386 definitions. We will override some of them below. */ +#include_next + + +/* Written like this, the Pentium pipeline can execute the loop at a + sustained rate of 2 instructions/clock, or asymptotically 480 + Mbytes/second at 60Mhz. */ + +#undef WORD_COPY_FWD +#define WORD_COPY_FWD(dst_bp, src_bp, nbytes_left, nbytes) \ + do \ + { \ + asm volatile ("subl $32,%2\n" \ + "js 2f\n" \ + "1:\n" \ + "movl 0(%1),%%eax\n" \ + "movl 4(%1),%%edx\n" \ + "movl %%eax,0(%0)\n" \ + "movl %%edx,4(%0)\n" \ + "movl 8(%1),%%eax\n" \ + "movl 12(%1),%%edx\n" \ + "movl %%eax,8(%0)\n" \ + "movl %%edx,12(%0)\n" \ + "movl 16(%1),%%eax\n" \ + "movl 20(%1),%%edx\n" \ + "movl %%eax,16(%0)\n" \ + "movl %%edx,20(%0)\n" \ + "movl 24(%1),%%eax\n" \ + "movl 28(%1),%%edx\n" \ + "movl %%eax,24(%0)\n" \ + "movl %%edx,28(%0)\n" \ + "addl $32,%1\n" \ + "addl $32,%0\n" \ + "subl $32,%2\n" \ + "jns 1b\n" \ + "2: addl $32,%2" : \ + "=r" (dst_bp), "=r" (src_bp), "=r" (nbytes_left) : \ + "0" (dst_bp), "1" (src_bp), "2" (nbytes) : \ + "ax", "dx"); \ + } while (0) + +#undef WORD_COPY_BWD +#define WORD_COPY_BWD(dst_ep, src_ep, nbytes_left, nbytes) \ + do \ + { \ + asm volatile ("subl $32,%2\n" \ + "js 2f\n" \ + "1:\n" \ + "movl -4(%1),%%eax\n" \ + "movl -8(%1),%%edx\n" \ + "movl %%eax,-4(%0)\n" \ + "movl %%edx,-8(%0)\n" \ + "movl -12(%1),%%eax\n" \ + "movl -16(%1),%%edx\n" \ + "movl %%eax,-12(%0)\n" \ + "movl %%edx,-16(%0)\n" \ + "movl -20(%1),%%eax\n" \ + "movl -24(%1),%%edx\n" \ + "movl %%eax,-20(%0)\n" \ + "movl %%edx,-24(%0)\n" \ + "movl -28(%1),%%eax\n" \ + "movl -32(%1),%%edx\n" \ + "movl %%eax,-28(%0)\n" \ + "movl %%edx,-32(%0)\n" \ + "subl $32,%1\n" \ + "subl $32,%0\n" \ + "subl $32,%2\n" \ + "jns 1b\n" \ + "2: addl $32,%2" : \ + "=r" (dst_bp), "=r" (src_bp), "=r" (nbytes_left) : \ + "0" (dst_bp), "1" (src_bp), "2" (nbytes) : \ + "ax", "dx"); \ + } while (0) diff -ruN glibc-1.08.1/sysdeps/i386/lshift.S glibc-1.09/sysdeps/i386/lshift.S --- glibc-1.08.1/sysdeps/i386/lshift.S Mon May 16 21:57:53 1994 +++ glibc-1.09/sysdeps/i386/lshift.S Thu Sep 1 23:42:28 1994 @@ -25,8 +25,8 @@ # size (sp + 12) # cnt (sp + 16) -#include "asm.h" #include "sysdep.h" +#include "asm-syntax.h" .text .align 2 diff -ruN glibc-1.08.1/sysdeps/i386/mul_1.S glibc-1.09/sysdeps/i386/mul_1.S --- glibc-1.08.1/sysdeps/i386/mul_1.S Mon May 16 21:57:55 1994 +++ glibc-1.09/sysdeps/i386/mul_1.S Thu Sep 1 23:42:19 1994 @@ -27,8 +27,8 @@ s2_limb (sp + 16) */ -#include "asm.h" #include "sysdep.h" +#include "asm-syntax.h" #define res_ptr edi #define s1_ptr esi diff -ruN glibc-1.08.1/sysdeps/i386/pentium/memcopy.h glibc-1.09/sysdeps/i386/pentium/memcopy.h --- glibc-1.08.1/sysdeps/i386/pentium/memcopy.h Wed Apr 27 03:17:57 1994 +++ glibc-1.09/sysdeps/i386/pentium/memcopy.h Wed Dec 31 19:00:00 1969 @@ -1,94 +0,0 @@ -/* memcopy.h -- definitions for memory copy functions. Pentium version. - Copyright (C) 1994 Free Software Foundation, Inc. - Contributed by Torbjorn Granlund (tege@sics.se). - -This file is part of the GNU C Library. - -The GNU C Library is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. - -The GNU C Library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with the GNU C Library; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA. */ - -/* Get the i386 definitions. We will override some of them below. */ -#include_next - - -/* Written like this, the Pentium pipeline can execute the loop at a - sustained rate of 2 instructions/clock, or asymptotically 480 - Mbytes/second at 60Mhz. */ - -#undef WORD_COPY_FWD -#define WORD_COPY_FWD(dst_bp, src_bp, nbytes_left, nbytes) \ - do \ - { \ - asm volatile ("subl $32,%2\n" \ - "js 2f\n" \ - "1:\n" \ - "movl 0(%1),%%eax\n" \ - "movl 4(%1),%%edx\n" \ - "movl %%eax,0(%0)\n" \ - "movl %%edx,4(%0)\n" \ - "movl 8(%1),%%eax\n" \ - "movl 12(%1),%%edx\n" \ - "movl %%eax,8(%0)\n" \ - "movl %%edx,12(%0)\n" \ - "movl 16(%1),%%eax\n" \ - "movl 20(%1),%%edx\n" \ - "movl %%eax,16(%0)\n" \ - "movl %%edx,20(%0)\n" \ - "movl 24(%1),%%eax\n" \ - "movl 28(%1),%%edx\n" \ - "movl %%eax,24(%0)\n" \ - "movl %%edx,28(%0)\n" \ - "addl $32,%1\n" \ - "addl $32,%0\n" \ - "subl $32,%2\n" \ - "jns 1b\n" \ - "2: addl $32,%2" : \ - "=r" (dst_bp), "=r" (src_bp), "=r" (nbytes_left) : \ - "0" (dst_bp), "1" (src_bp), "2" (nbytes) : \ - "ax", "dx"); \ - } while (0) - -#undef WORD_COPY_BWD -#define WORD_COPY_BWD(dst_ep, src_ep, nbytes_left, nbytes) \ - do \ - { \ - asm volatile ("subl $32,%2\n" \ - "js 2f\n" \ - "1:\n" \ - "movl -4(%1),%%eax\n" \ - "movl -8(%1),%%edx\n" \ - "movl %%eax,-4(%0)\n" \ - "movl %%edx,-8(%0)\n" \ - "movl -12(%1),%%eax\n" \ - "movl -16(%1),%%edx\n" \ - "movl %%eax,-12(%0)\n" \ - "movl %%edx,-16(%0)\n" \ - "movl -20(%1),%%eax\n" \ - "movl -24(%1),%%edx\n" \ - "movl %%eax,-20(%0)\n" \ - "movl %%edx,-24(%0)\n" \ - "movl -28(%1),%%eax\n" \ - "movl -32(%1),%%edx\n" \ - "movl %%eax,-28(%0)\n" \ - "movl %%edx,-32(%0)\n" \ - "subl $32,%1\n" \ - "subl $32,%0\n" \ - "subl $32,%2\n" \ - "jns 1b\n" \ - "2: addl $32,%2" : \ - "=r" (dst_bp), "=r" (src_bp), "=r" (nbytes_left) : \ - "0" (dst_bp), "1" (src_bp), "2" (nbytes) : \ - "ax", "dx"); \ - } while (0) diff -ruN glibc-1.08.1/sysdeps/i386/rshift.S glibc-1.09/sysdeps/i386/rshift.S --- glibc-1.08.1/sysdeps/i386/rshift.S Mon May 16 21:57:54 1994 +++ glibc-1.09/sysdeps/i386/rshift.S Thu Sep 1 23:42:24 1994 @@ -25,8 +25,8 @@ # size (sp + 12) # cnt (sp + 16) -#include "asm.h" #include "sysdep.h" +#include "asm-syntax.h" .text .align 2 diff -ruN glibc-1.08.1/sysdeps/i386/sub_n.S glibc-1.09/sysdeps/i386/sub_n.S --- glibc-1.08.1/sysdeps/i386/sub_n.S Mon May 16 21:57:57 1994 +++ glibc-1.09/sysdeps/i386/sub_n.S Thu Sep 1 23:42:14 1994 @@ -26,8 +26,8 @@ # s2_ptr (sp + 12) # size (sp + 16) -#include "asm.h" #include "sysdep.h" +#include "asm-syntax.h" .text .align 2 diff -ruN glibc-1.08.1/sysdeps/i386/submul_1.S glibc-1.09/sysdeps/i386/submul_1.S --- glibc-1.08.1/sysdeps/i386/submul_1.S Mon May 16 21:57:59 1994 +++ glibc-1.09/sysdeps/i386/submul_1.S Thu Sep 1 23:42:08 1994 @@ -27,8 +27,8 @@ s2_limb (sp + 16) */ -#include "asm.h" #include "sysdep.h" +#include "asm-syntax.h" #define res_ptr edi #define s1_ptr esi diff -ruN glibc-1.08.1/sysdeps/i960/Implies glibc-1.09/sysdeps/i960/Implies --- glibc-1.08.1/sysdeps/i960/Implies Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/i960/Implies Wed Aug 17 18:40:27 1994 @@ -0,0 +1,2 @@ +# i960 family uses IEEE 754 floating point. +ieee754 diff -ruN glibc-1.08.1/sysdeps/i960/ffs.c glibc-1.09/sysdeps/i960/ffs.c --- glibc-1.08.1/sysdeps/i960/ffs.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/i960/ffs.c Thu Aug 25 14:17:18 1994 @@ -0,0 +1,43 @@ +/* ffs -- find first set bit in a word, counted from least significant end. + For i960 Core architecture + Copyright (C) 1994 Free Software Foundation, Inc. + Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil), + On-Line Applications Research Corporation. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include + +#undef ffs + +#if defined (__GNUC__) && defined (__i960__) + +int +DEFUN(ffs, (x), int x) +{ + int cnt; + + asm("scanbit %1,%0" : "=d" (cnt) : "rm" (x & -x)); + + return cnt; +} + +#else + +#include + +#endif diff -ruN glibc-1.08.1/sysdeps/ieee754/cbrt.c glibc-1.09/sysdeps/ieee754/cbrt.c --- glibc-1.08.1/sysdeps/ieee754/cbrt.c Thu Jul 30 19:17:56 1992 +++ glibc-1.09/sysdeps/ieee754/cbrt.c Sun Jul 31 15:48:02 1994 @@ -1,6 +1,6 @@ /* - * Copyright (c) 1985 Regents of the University of California. - * All rights reserved. + * 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 @@ -32,7 +32,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)cbrt.c 5.9 (Berkeley) 2/13/91"; +static char sccsid[] = "@(#)cbrt.c 8.1 (Berkeley) 6/4/93"; #endif /* not lint */ #include diff -ruN glibc-1.08.1/sysdeps/ieee754/support.c glibc-1.09/sysdeps/ieee754/support.c --- glibc-1.08.1/sysdeps/ieee754/support.c Thu Jul 30 19:17:58 1992 +++ glibc-1.09/sysdeps/ieee754/support.c Sun Jul 31 15:49:57 1994 @@ -1,6 +1,6 @@ /* - * Copyright (c) 1985 Regents of the University of California. - * All rights reserved. + * 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 @@ -32,7 +32,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)support.c 5.6 (Berkeley) 10/9/90"; +static char sccsid[] = "@(#)support.c 8.1 (Berkeley) 6/4/93"; #endif /* not lint */ /* diff -ruN glibc-1.08.1/sysdeps/m68k/fpu/__math.h glibc-1.09/sysdeps/m68k/fpu/__math.h --- glibc-1.08.1/sysdeps/m68k/fpu/__math.h Wed Nov 10 05:56:33 1993 +++ glibc-1.09/sysdeps/m68k/fpu/__math.h Mon Aug 15 20:42:19 1994 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -28,7 +28,7 @@ #endif #define __inline_mathop2(func, op) \ - extern __inline __const double \ + extern __inline __CONSTVALUE double \ __m81_u(func)(double __mathop_x) \ { \ double __result; \ @@ -63,7 +63,7 @@ __inline_mathop(atanh) #endif -extern __inline __const double +extern __inline __CONSTVALUE double __m81_u(__drem)(double __x, double __y) { double __result; @@ -71,7 +71,7 @@ return __result; } -extern __inline __const double +extern __inline __CONSTVALUE double __m81_u(ldexp)(double __x, int __e) { double __result; @@ -80,7 +80,7 @@ return __result; } -extern __inline __const double +extern __inline __CONSTVALUE double __m81_u(fmod)(double __x, double __y) { double __result; @@ -98,7 +98,7 @@ return __mantissa; } -extern __inline __const double +extern __inline __CONSTVALUE double __m81_u(pow)(double __x, double __y) { double __result; @@ -117,7 +117,7 @@ return __result; } -extern __inline __const double +extern __inline __CONSTVALUE double __m81_u(ceil)(double __x) { double __result; diff -ruN glibc-1.08.1/sysdeps/m68k/m68020/add_n.S glibc-1.09/sysdeps/m68k/m68020/add_n.S --- glibc-1.08.1/sysdeps/m68k/m68020/add_n.S Tue Apr 26 21:59:53 1994 +++ glibc-1.09/sysdeps/m68k/m68020/add_n.S Tue Aug 30 08:02:51 1994 @@ -27,7 +27,7 @@ size (sp + 12) */ -#include "asm.h" +#include "asm-syntax.h" TEXT ALIGN diff -ruN glibc-1.08.1/sysdeps/m68k/m68020/addmul_1.S glibc-1.09/sysdeps/m68k/m68020/addmul_1.S --- glibc-1.08.1/sysdeps/m68k/m68020/addmul_1.S Tue Apr 26 21:59:54 1994 +++ glibc-1.09/sysdeps/m68k/m68020/addmul_1.S Tue Aug 30 08:02:53 1994 @@ -27,7 +27,7 @@ s2_limb (sp + 16) */ -#include "asm.h" +#include "asm-syntax.h" TEXT ALIGN diff -ruN glibc-1.08.1/sysdeps/m68k/m68020/asm-syntax.h glibc-1.09/sysdeps/m68k/m68020/asm-syntax.h --- glibc-1.08.1/sysdeps/m68k/m68020/asm-syntax.h Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/m68k/m68020/asm-syntax.h Tue Aug 30 08:04:32 1994 @@ -0,0 +1,105 @@ +/* asm.h -- Definitions for 68k syntax variations. + +Copyright (C) 1992, 1994 Free Software Foundation, Inc. + +This file is part of the GNU MP Library. + +The GNU MP Library is free software; you can redistribute it and/or modify +it under the terms of the GNU Library General Public License as published by +the Free Software Foundation; either version 2 of the License, or (at your +option) any later version. + +The GNU MP Library is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public +License for more details. + +You should have received a copy of the GNU Library General Public License +along with the GNU MP Library; see the file COPYING.LIB. If not, write to +the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifdef MIT_SYNTAX +#define MEM(base)base@ +#define MEM_DISP(base,displacement)base@(displacement) +#define MEM_PREDEC(memory_base)memory_base@- +#define MEM_POSTINC(memory_base)memory_base@+ +#ifdef __STDC__ +#define INSN1(mnemonic,size_suffix,dst)mnemonic##size_suffix dst +#define INSN2(mnemonic,size_suffix,dst,src)mnemonic##size_suffix src,dst +#else +#define INSN1(mnemonic,size_suffix,dst)mnemonic/**/size_suffix dst +#define INSN2(mnemonic,size_suffix,dst,src)mnemonic/**/size_suffix src,dst +#endif +#define LAB(label) label: +#define TEXT .text +#define ALIGN .even +#define GLOBL .globl +#endif + +#ifdef SONY_SYNTAX +#define MEM(base)(base) +#define MEM_DISP(base,displacement)(displacement,base) +#define MEM_PREDEC(memory_base)-(memory_base) +#define MEM_POSTINC(memory_base)(memory_base)+ +#define INSN1(mnemonic,size_suffix,dst)mnemonic.size_suffix dst +#ifdef __STDC__ +#define INSN2(mnemonic,size_suffix,dst,src)mnemonic.size_suffix src##,dst +#else +#define INSN2(mnemonic,size_suffix,dst,src)mnemonic.size_suffix src/**/,dst +#endif +#define LAB(label) label: +#define TEXT .text +#define ALIGN .even +#define GLOBL .globl +#endif + +#ifdef MOTOROLA_SYNTAX +#define MEM(base)(base) +#define MEM_DISP(base,displacement)(displacement,base) +#define MEM_PREDEC(memory_base)-(memory_base) +#define MEM_POSTINC(memory_base)(memory_base)+ +#define INSN1(mnemonic,size_suffix,dst)mnemonic.size_suffix dst +#ifdef __STDC__ +#define INSN2(mnemonic,size_suffix,dst,src)mnemonic.size_suffix src##,dst +#else +#define INSN2(mnemonic,size_suffix,dst,src)mnemonic.size_suffix src/**/,dst +#endif +#define LAB(label) label +#define TEXT +#define ALIGN +#define GLOBL XDEF +#define l L +#define w W +#define move MOVE +#define eor EOR +#define lsr LSR +#define add ADD +#define addx ADDX +#define addq ADDQ +#define sub SUB +#define subx SUBX +#define subq SUBQ +#define neg NEG +#define bcc BCC +#define bcs BCS +#define bra BRA +#define dbf DBF +#define rts RTS +#define d0 D0 +#define d1 D1 +#define d2 D2 +#define d3 D3 +#define d4 D4 +#define d5 D5 +#define d6 D6 +#define d7 D7 +#define a0 A0 +#define a1 A1 +#define a2 A2 +#define a3 A3 +#define a4 A4 +#define a5 A5 +#define a6 A6 +#define a7 A7 +#define sp SP +#endif diff -ruN glibc-1.08.1/sysdeps/m68k/m68020/asm.h glibc-1.09/sysdeps/m68k/m68020/asm.h --- glibc-1.08.1/sysdeps/m68k/m68020/asm.h Tue Apr 26 22:00:01 1994 +++ glibc-1.09/sysdeps/m68k/m68020/asm.h Wed Dec 31 19:00:00 1969 @@ -1,105 +0,0 @@ -/* asm.h -- Definitions for 68k syntax variations. - -Copyright (C) 1992, 1994 Free Software Foundation, Inc. - -This file is part of the GNU MP Library. - -The GNU MP Library is free software; you can redistribute it and/or modify -it under the terms of the GNU Library General Public License as published by -the Free Software Foundation; either version 2 of the License, or (at your -option) any later version. - -The GNU MP Library is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifdef MIT_SYNTAX -#define MEM(base)base@ -#define MEM_DISP(base,displacement)base@(displacement) -#define MEM_PREDEC(memory_base)memory_base@- -#define MEM_POSTINC(memory_base)memory_base@+ -#ifdef __STDC__ -#define INSN1(mnemonic,size_suffix,dst)mnemonic##size_suffix dst -#define INSN2(mnemonic,size_suffix,dst,src)mnemonic##size_suffix src,dst -#else -#define INSN1(mnemonic,size_suffix,dst)mnemonic/**/size_suffix dst -#define INSN2(mnemonic,size_suffix,dst,src)mnemonic/**/size_suffix src,dst -#endif -#define LAB(label) label: -#define TEXT .text -#define ALIGN .even -#define GLOBL .globl -#endif - -#ifdef SONY_SYNTAX -#define MEM(base)(base) -#define MEM_DISP(base,displacement)(displacement,base) -#define MEM_PREDEC(memory_base)-(memory_base) -#define MEM_POSTINC(memory_base)(memory_base)+ -#define INSN1(mnemonic,size_suffix,dst)mnemonic.size_suffix dst -#ifdef __STDC__ -#define INSN2(mnemonic,size_suffix,dst,src)mnemonic.size_suffix src##,dst -#else -#define INSN2(mnemonic,size_suffix,dst,src)mnemonic.size_suffix src/**/,dst -#endif -#define LAB(label) label: -#define TEXT .text -#define ALIGN .even -#define GLOBL .globl -#endif - -#ifdef MOTOROLA_SYNTAX -#define MEM(base)(base) -#define MEM_DISP(base,displacement)(displacement,base) -#define MEM_PREDEC(memory_base)-(memory_base) -#define MEM_POSTINC(memory_base)(memory_base)+ -#define INSN1(mnemonic,size_suffix,dst)mnemonic.size_suffix dst -#ifdef __STDC__ -#define INSN2(mnemonic,size_suffix,dst,src)mnemonic.size_suffix src##,dst -#else -#define INSN2(mnemonic,size_suffix,dst,src)mnemonic.size_suffix src/**/,dst -#endif -#define LAB(label) label -#define TEXT -#define ALIGN -#define GLOBL XDEF -#define l L -#define w W -#define move MOVE -#define eor EOR -#define lsr LSR -#define add ADD -#define addx ADDX -#define addq ADDQ -#define sub SUB -#define subx SUBX -#define subq SUBQ -#define neg NEG -#define bcc BCC -#define bcs BCS -#define bra BRA -#define dbf DBF -#define rts RTS -#define d0 D0 -#define d1 D1 -#define d2 D2 -#define d3 D3 -#define d4 D4 -#define d5 D5 -#define d6 D6 -#define d7 D7 -#define a0 A0 -#define a1 A1 -#define a2 A2 -#define a3 A3 -#define a4 A4 -#define a5 A5 -#define a6 A6 -#define a7 A7 -#define sp SP -#endif diff -ruN glibc-1.08.1/sysdeps/m68k/m68020/mul_1.S glibc-1.09/sysdeps/m68k/m68020/mul_1.S --- glibc-1.08.1/sysdeps/m68k/m68020/mul_1.S Tue Apr 26 21:59:56 1994 +++ glibc-1.09/sysdeps/m68k/m68020/mul_1.S Tue Aug 30 08:02:54 1994 @@ -27,7 +27,7 @@ s2_limb (sp + 16) */ -#include "asm.h" +#include "asm-syntax.h" TEXT ALIGN diff -ruN glibc-1.08.1/sysdeps/m68k/m68020/sub_n.S glibc-1.09/sysdeps/m68k/m68020/sub_n.S --- glibc-1.08.1/sysdeps/m68k/m68020/sub_n.S Tue Apr 26 21:59:57 1994 +++ glibc-1.09/sysdeps/m68k/m68020/sub_n.S Tue Aug 30 08:02:56 1994 @@ -27,7 +27,7 @@ size (sp + 12) */ -#include "asm.h" +#include "asm-syntax.h" TEXT ALIGN diff -ruN glibc-1.08.1/sysdeps/m68k/m68020/submul_1.S glibc-1.09/sysdeps/m68k/m68020/submul_1.S --- glibc-1.08.1/sysdeps/m68k/m68020/submul_1.S Tue Apr 26 21:59:59 1994 +++ glibc-1.09/sysdeps/m68k/m68020/submul_1.S Tue Aug 30 08:02:58 1994 @@ -27,7 +27,7 @@ s2_limb (sp + 16) */ -#include "asm.h" +#include "asm-syntax.h" TEXT ALIGN diff -ruN glibc-1.08.1/sysdeps/mach/hurd/Dist glibc-1.09/sysdeps/mach/hurd/Dist --- glibc-1.08.1/sysdeps/mach/hurd/Dist Thu Feb 3 02:08:27 1994 +++ glibc-1.09/sysdeps/mach/hurd/Dist Wed Sep 14 18:15:39 1994 @@ -1,2 +1,3 @@ errnos.awk errlist.awk err_hurd.sub +libc-ldscript diff -ruN glibc-1.08.1/sysdeps/mach/hurd/Makefile glibc-1.09/sysdeps/mach/hurd/Makefile --- glibc-1.08.1/sysdeps/mach/hurd/Makefile Mon May 30 19:41:18 1994 +++ glibc-1.09/sysdeps/mach/hurd/Makefile Wed Sep 14 18:15:08 1994 @@ -52,7 +52,12 @@ includes += -I$(..)hurd # When compiling, use the Hurd header files directly from the sources. -includes += -I$(hurd-srcdir) -I$(hurd-srcdir)/libthreads +includes += -I$(hurd-srcdir) + +# When compiling, find cthreads.h in the Hurd cthreads source. +# This directory has some other (private) header file with +# conflicting names, so we put it last. +last-includes += -I$(hurd-srcdir)/libthreads # Find the Hurd header files in the Hurd source. vpath hurd/%.h $(hurd-srcdir) @@ -105,6 +110,17 @@ $(hurd)/errlist.c: $(hurd)/errlist.awk $(errno.texinfo) gawk -f $^ > $@-tmp - mv $@-tmp $@ + mv -f $@-tmp $@ + +# We install the real libc.a as libcrt.a and as libc.a we install a linker +# script which does -( -lcrt -lmachuser -lhurduser -). + +libc-name = crt + +ifeq (,$(subdir)) +install-others += $(libdir)/libc.a +$(libdir)/libc.a: $(hurd)/libc-ldscript; $(do-install) +endif + endif # in-Makerules diff -ruN glibc-1.08.1/sysdeps/mach/hurd/__access.c glibc-1.09/sysdeps/mach/hurd/__access.c --- glibc-1.08.1/sysdeps/mach/hurd/__access.c Thu May 19 13:53:57 1994 +++ glibc-1.09/sysdeps/mach/hurd/__access.c Tue Aug 30 10:59:30 1994 @@ -30,7 +30,8 @@ error_t err; file_t crdir, cwdir, rcrdir, rcwdir, io; struct hurd_userlink crdir_ulink, cwdir_ulink; - int flags; + int flags, allowed; + mach_port_t ref; HURD_CRITICAL_BEGIN; @@ -69,22 +70,30 @@ /* Get a port to our root directory, authenticated with the real IDs. */ crdir = _hurd_port_get (&_hurd_ports[INIT_PORT_CRDIR], &crdir_ulink); - err = __io_reauthenticate (crdir, _hurd_pid); + ref = __mach_reply_port (); + err = __io_reauthenticate (crdir, ref, MACH_MSG_TYPE_MAKE_SEND); if (!err) err = __auth_user_authenticate (_hurd_id.rid_auth, - crdir, _hurd_pid, &rcrdir); + crdir, + ref, MACH_MSG_TYPE_MAKE_SEND, + &rcrdir); _hurd_port_free (&_hurd_ports[INIT_PORT_CRDIR], &crdir_ulink, crdir); + __mach_port_destroy (__mach_task_self (), ref); if (!err) { /* Get a port to our current working directory, authenticated with the real IDs. */ cwdir = _hurd_port_get (&_hurd_ports[INIT_PORT_CWDIR], &cwdir_ulink); - err = __io_reauthenticate (cwdir, _hurd_pid); + ref = __mach_reply_port (); + err = __io_reauthenticate (cwdir, ref, MACH_MSG_TYPE_MAKE_SEND); if (!err) err = __auth_user_authenticate (_hurd_id.rid_auth, - cwdir, _hurd_pid, &rcwdir); + cwdir, + ref, MACH_MSG_TYPE_MAKE_SEND, + &rcwdir); _hurd_port_free (&_hurd_ports[INIT_PORT_CWDIR], &cwdir_ulink, cwdir); + __mach_port_destroy (__mach_task_self (), ref); } /* We are done with _hurd_id.rid_auth now. */ @@ -99,6 +108,18 @@ /* Now do a path lookup on FILE, using the crdir and cwdir reauthenticated with _hurd_id.rid_auth. */ + err = __hurd_file_name_lookup (rcrdir, rcwdir, file, 0, 0, &io); + __mach_port_deallocate (__mach_task_self (), rcrdir); + __mach_port_deallocate (__mach_task_self (), rcwdir); + if (err) + return __hurd_fail (err); + + /* Find out what types of access we are allowed to this file. */ + err = __file_check_access (io, &allowed); + __mach_port_deallocate (__mach_task_self (), io); + if (err) + return __hurd_fail (err); + flags = 0; if (type & R_OK) flags |= O_READ; @@ -107,12 +128,9 @@ if (type & X_OK) flags |= O_EXEC; - err = __hurd_path_lookup (rcrdir, rcwdir, file, flags, 0, &io); - __mach_port_deallocate (__mach_task_self (), rcrdir); - __mach_port_deallocate (__mach_task_self (), rcwdir); - if (err) - return __hurd_fail (err); + if (flags & ~allowed) + /* We are not allowed all the requested types of access. */ + return __hurd_fail (EACCES); - __mach_port_deallocate (__mach_task_self (), io); return 0; } diff -ruN glibc-1.08.1/sysdeps/mach/hurd/__chdir.c glibc-1.09/sysdeps/mach/hurd/__chdir.c --- glibc-1.08.1/sysdeps/mach/hurd/__chdir.c Tue Feb 1 19:28:33 1994 +++ glibc-1.09/sysdeps/mach/hurd/__chdir.c Tue Aug 30 08:43:50 1994 @@ -22,19 +22,22 @@ #include #include -/* Change the current directory to PATH. */ +/* Change the current directory to FILE_NAME. */ int -DEFUN(__chdir, (path), CONST char *path) +DEFUN(__chdir, (file_name), CONST char *file_name) { - file_t cwdir; + file_t file, dir; + error_t err; -/* XXX make sure it's a directory */ - - cwdir = __path_lookup (path, O_EXEC, 0); - if (cwdir == MACH_PORT_NULL) + file = __file_name_lookup (file_name, O_EXEC, 0); + if (file == MACH_PORT_NULL) return -1; + err = __USEPORT (CRDIR, __hurd_file_name_lookup (port, file, "", + O_EXEC, 0, &dir)); + __mach_port_deallocate (__mach_task_self (), file); + if (err) + return __hurd_fail (err); - _hurd_port_set (&_hurd_ports[INIT_PORT_CWDIR], cwdir); - + _hurd_port_set (&_hurd_ports[INIT_PORT_CWDIR], dir); return 0; } diff -ruN glibc-1.08.1/sysdeps/mach/hurd/__chmod.c glibc-1.09/sysdeps/mach/hurd/__chmod.c --- glibc-1.08.1/sysdeps/mach/hurd/__chmod.c Sat Mar 21 21:03:30 1992 +++ glibc-1.09/sysdeps/mach/hurd/__chmod.c Tue Aug 30 05:07:21 1994 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1992 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1992, 1994 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -27,7 +27,7 @@ DEFUN(__chmod, (file, mode), CONST char *file AND mode_t mode) { error_t err; - file_t port = __path_lookup (file, 0, 0); + file_t port = __file_name_lookup (file, 0, 0); if (port == MACH_PORT_NULL) return -1; err = __file_chmod (port, mode); diff -ruN glibc-1.08.1/sysdeps/mach/hurd/__chown.c glibc-1.09/sysdeps/mach/hurd/__chown.c --- glibc-1.08.1/sysdeps/mach/hurd/__chown.c Sat Mar 21 21:03:26 1992 +++ glibc-1.09/sysdeps/mach/hurd/__chown.c Tue Aug 30 05:06:56 1994 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1992 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1992, 1994 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -28,7 +28,7 @@ CONST char *file AND uid_t owner AND gid_t group) { error_t err; - file_t port = __path_lookup (file, 0, 0); + file_t port = __file_name_lookup (file, 0, 0); if (port == MACH_PORT_NULL) return -1; err = __file_chown (port, owner, group); diff -ruN glibc-1.08.1/sysdeps/mach/hurd/__execve.c glibc-1.09/sysdeps/mach/hurd/__execve.c --- glibc-1.08.1/sysdeps/mach/hurd/__execve.c Tue Feb 1 19:27:51 1994 +++ glibc-1.09/sysdeps/mach/hurd/__execve.c Tue Aug 30 07:28:49 1994 @@ -21,14 +21,14 @@ #include #include -/* Replace the current process, executing PATH with arguments ARGV and +/* Replace the current process, executing FILE_NAME with arguments ARGV and environment ENVP. ARGV and ENVP are terminated by NULL pointers. */ int -DEFUN(__execve, (path, argv, envp), - CONST char *path AND char *CONST argv[] AND char *CONST envp[]) +DEFUN(__execve, (file_name, argv, envp), + CONST char *file_name AND char *CONST argv[] AND char *CONST envp[]) { error_t err; - file_t file = __path_lookup (path, O_EXEC, 0); + file_t file = __file_name_lookup (file_name, O_EXEC, 0); if (file == MACH_PORT_NULL) return -1; diff -ruN glibc-1.08.1/sysdeps/mach/hurd/__fork.c glibc-1.09/sysdeps/mach/hurd/__fork.c --- glibc-1.08.1/sysdeps/mach/hurd/__fork.c Sun Jun 5 06:54:09 1994 +++ glibc-1.09/sysdeps/mach/hurd/__fork.c Thu Nov 3 19:51:13 1994 @@ -24,13 +24,15 @@ #include "thread_state.h" #include /* For stack growth direction. */ #include "set-hooks.h" +#include +#include "hurdmalloc.h" /* XXX */ extern void _hurd_longjmp_thread_state (struct machine_thread_state *, jmp_buf env, int value); /* Things that want to be locked while forking. */ -const struct +struct { size_t n; struct mutex *locks[0]; @@ -66,18 +68,25 @@ thread_t thread_self = __mach_thread_self (); struct hurd_sigstate *volatile ss; + void unlockss (void) + { + ss->critical_section = 0; + /* XXX Copying mutex into child and calling mutex_unlock lossy. */ + __mutex_unlock (&ss->lock); + __mutex_unlock (&_hurd_siglock); + ss = NULL; /* Make sure we crash if we use it again. */ + } + + ss = _hurd_self_sigstate (); + ss->critical_section = 1; __mutex_lock (&_hurd_siglock); - for (ss = _hurd_sigstates; ss != NULL; ss = ss->next) - if (ss->thread == thread_self) - break; - if (ss) - ss->critical_section = 1; if (! setjmp (env)) { process_t newproc; task_t newtask; thread_t thread, sigthread; + mach_port_urefs_t thread_refs, sigthread_refs; struct machine_thread_state state; unsigned int statecount; mach_port_t *portnames = NULL; @@ -86,6 +95,7 @@ unsigned int nporttypes = 0; thread_t *threads = NULL; unsigned int nthreads = 0; + int ports_locked = 0; /* Run things that prepare for forking before we create the task. */ RUN_HOOK (_hurd_fork_prepare_hook, ()); @@ -103,6 +113,7 @@ child with the same names. */ for (i = 0; i < _hurd_nports; ++i) __spin_lock (&_hurd_ports[i].lock); + ports_locked = 1; /* Create the child task. It will inherit a copy of our memory. */ if (err = __task_create (__mach_task_self (), 1, &newtask)) @@ -124,11 +135,6 @@ if (err = __task_threads (__mach_task_self (), &threads, &nthreads)) goto lose; - /* Create the child main user thread and signal thread. */ - if ((err = __thread_create (newtask, &thread)) || - (err = __thread_create (newtask, &sigthread))) - goto lose; - /* Get the child process's proc server port. We will insert it into the child with the same name as we use for our own proc server port; and we will need it to set the child's message port. */ @@ -137,17 +143,47 @@ goto lose; /* Insert all our port rights into the child task. */ + thread_refs = sigthread_refs = 0; for (i = 0; i < nportnames; ++i) { - if (MACH_PORT_TYPE (porttypes[i]) & MACH_PORT_TYPE_RECEIVE) + if (porttypes[i] & MACH_PORT_TYPE_RECEIVE) { /* This is a receive right. We want to give the child task its own new receive right under the same name. */ - if (err = __mach_port_allocate_name (newtask, - MACH_PORT_RIGHT_RECEIVE, - portnames[i])) + err = __mach_port_allocate_name (newtask, + MACH_PORT_RIGHT_RECEIVE, + portnames[i]); + if (err == KERN_NAME_EXISTS) + { + /* It already has a right under this name (?!). Well, + there is this bizarre old Mach IPC feature (in #ifdef + MACH_IPC_COMPAT in the ukernel) which results in new + tasks getting a new receive right for task special + port number 2. What else might be going on I'm not + sure. So let's check. */ +#if !MACH_IPC_COMPAT +#define TASK_NOTIFY_PORT 2 +#endif + assert (({ mach_port_t thisport, notify_port; + mach_msg_type_name_t poly; + (__task_get_special_port (newtask, + TASK_NOTIFY_PORT, + ¬ify_port) == 0 && + __mach_port_extract_right + (newtask, + portnames[i], + MACH_MSG_TYPE_MAKE_SEND, + &thisport, &poly) == 0 && + (thisport == notify_port) && + __mach_port_deallocate (__mach_task_self (), + thisport) == 0 && + __mach_port_deallocate (__mach_task_self (), + notify_port) == 0); + })); + } + else if (err) goto lose; - if (MACH_PORT_TYPE (porttypes[i]) & MACH_PORT_TYPE_SEND) + if (porttypes[i] & MACH_PORT_TYPE_SEND) { /* Give the child as many send rights for its receive right as we have for ours. */ @@ -189,7 +225,7 @@ refs - 1))) goto lose; } - if (MACH_PORT_TYPE (porttypes[i]) & MACH_PORT_TYPE_SEND_ONCE) + if (porttypes[i] & MACH_PORT_TYPE_SEND_ONCE) { /* Give the child a send-once right for its receive right, since we have one for ours. */ @@ -208,12 +244,11 @@ goto lose; } } - else if (MACH_PORT_TYPE (porttypes[i]) & - (MACH_PORT_TYPE_SEND|MACH_PORT_TYPE_DEAD_NAME)) + else if (porttypes[i] & MACH_PORT_TYPE_SEND) { /* This is a send right or a dead name. Give the child as many references for it as we have. */ - mach_port_urefs_t refs; + mach_port_urefs_t refs, *record_refs = NULL; mach_port_t insert; if (portnames[i] == newtask) /* Skip the name we use for the child's task port. */ @@ -225,23 +260,36 @@ else if (portnames[i] == _hurd_ports[INIT_PORT_PROC].port) { /* Get the proc server port for the new task. */ - if (err = __USEPORT (PROC, __proc_task2proc (port, newtask, - &insert))) + if (err = __proc_task2proc (portnames[i], newtask, &insert)) goto lose; } else if (portnames[i] == thread_self) - /* For the name we use for our own thread port, insert the - thread port for the child main user thread. We have one - extra user reference created at the beginning of this - function, accounted for by mach_port_names (and which - will thus be accounted for in the child below). This - extra right gets consumed in the child by the store into - _hurd_sigthread in the child fork. */ - insert = thread; + { + /* For the name we use for our own thread port, we will + insert the thread port for the child main user thread + after we create it. */ + insert = MACH_PORT_NULL; + record_refs = &thread_refs; + /* Allocate a dead name right for this name as a + placeholder, so the kernel will not chose this name + for any other new port (it might use it for one of the + rights created when a thread is created). */ + if (err = __mach_port_allocate_name + (newtask, MACH_PORT_RIGHT_DEAD_NAME, portnames[i])) + goto lose; + } else if (portnames[i] == _hurd_msgport_thread) /* For the name we use for our signal thread's thread port, - insert the thread port for the child's signal thread. */ - insert = sigthread; + we will insert the thread port for the child's signal + thread after we create it. */ + { + insert = MACH_PORT_NULL; + record_refs = &sigthread_refs; + /* Allocate a dead name right as a placeholder. */ + if (err = __mach_port_allocate_name + (newtask, MACH_PORT_RIGHT_DEAD_NAME, portnames[i])) + goto lose; + } else { /* Skip the name we use for any of our own thread ports. */ @@ -259,13 +307,31 @@ if (err = __mach_port_get_refs (__mach_task_self (), portnames[i], MACH_PORT_RIGHT_SEND, - &refs)) + record_refs ?: &refs)) goto lose; + if (insert == MACH_PORT_NULL) + continue; /* Insert the chosen send right into the child. */ - if (err = __mach_port_insert_right (newtask, - portnames[i], - insert, - MACH_MSG_TYPE_COPY_SEND)) + err = __mach_port_insert_right (newtask, + portnames[i], + insert, + MACH_MSG_TYPE_COPY_SEND); + if (err == KERN_NAME_EXISTS) + { + /* It already has a send right under this name (?!). + Well, it starts out with a send right for its task + port, and inherits the bootstrap and exception ports + from us. */ + mach_port_t childport; + mach_msg_type_name_t poly; + assert (__mach_port_extract_right (newtask, portnames[i], + MACH_MSG_TYPE_COPY_SEND, + &childport, &poly) == 0 && + childport == insert && + __mach_port_deallocate (__mach_task_self (), + childport) == 0); + } + else if (err) goto lose; /* Give the child as many user references as we have. */ if (refs > 1 && @@ -281,20 +347,64 @@ copies too. */ for (i = 0; i < _hurd_nports; ++i) __spin_unlock (&_hurd_ports[i].lock); + ports_locked = 0; + /* Unlock the signal state. The child must unlock its own copy too. */ + unlockss (); + /* Create the child main user thread and signal thread. */ + if ((err = __thread_create (newtask, &thread)) || + (err = __thread_create (newtask, &sigthread))) + goto lose; - /* Register the child with the proc server. */ - if (err = __USEPORT (PROC, __proc_child (port, newtask))) + /* Insert send rights for those threads. We previously allocated + dead name rights with the names we want to give the thread ports + in the child as placeholders. Now deallocate them so we can use + the names. */ + if ((err = __mach_port_deallocate (newtask, thread_self)) || + (err = __mach_port_insert_right (newtask, thread_self, + thread, MACH_MSG_TYPE_COPY_SEND))) + goto lose; + /* We have one extra user reference created at the beginning of this + function, accounted for by mach_port_names (and which will thus be + accounted for in the child below). This extra right gets consumed + in the child by the store into _hurd_sigthread in the child fork. */ + if (thread_refs > 1 && + (err = __mach_port_mod_refs (newtask, thread_self, + MACH_PORT_RIGHT_SEND, + thread_refs - 1))) + goto lose; + if ((_hurd_msgport_thread != MACH_PORT_NULL) /* Let user have none. */ + && ((err = __mach_port_deallocate (newtask, _hurd_msgport_thread)) || + (err = __mach_port_insert_right (newtask, _hurd_msgport_thread, + sigthread, + MACH_MSG_TYPE_COPY_SEND)))) + goto lose; + if (sigthread_refs > 1 && + (err = __mach_port_mod_refs (newtask, _hurd_msgport_thread, + MACH_PORT_RIGHT_SEND, + sigthread_refs - 1))) goto lose; + /* This seems like a convenient juncture to copy the proc server's + idea of what addresses our argv and envp are found at from the + parent into the child. Since we happen to know that the child + shares our memory image, it is we who should do this copying. */ + { + vm_address_t argv, envp; + err = (__USEPORT (PROC, __proc_get_arg_locations (port, &argv, &envp)) + ?: __proc_set_arg_locations (newproc, argv, envp)); + if (err) + goto lose; + } + /* Set the child signal thread up to run the msgport server function using the same signal thread stack copied from our address space. We fetch the state before longjmp'ing it so that miscellaneous registers not affected by longjmp (such as i386 segment registers) are in their normal default state. */ statecount = MACHINE_THREAD_STATE_COUNT; - if (err = __thread_get_state (thread, MACHINE_THREAD_STATE_FLAVOR, + if (err = __thread_get_state (sigthread, MACHINE_THREAD_STATE_FLAVOR, (int *) &state, &statecount)) goto lose; #if STACK_GROWTH_UP @@ -302,7 +412,8 @@ #else state.SP = __hurd_sigthread_stack_end; #endif - state.PC = (unsigned long int) _hurd_msgport_receive; + MACHINE_THREAD_STATE_SET_PC (&state, + (unsigned long int) _hurd_msgport_receive); if (err = __thread_set_state (sigthread, MACHINE_THREAD_STATE_FLAVOR, (int *) &state, statecount)) goto lose; @@ -314,13 +425,36 @@ (int *) &state, &statecount)) goto lose; _hurd_longjmp_thread_state (&state, env, 1); - if (err = __thread_resume (thread)) + if (err = __thread_set_state (thread, MACHINE_THREAD_STATE_FLAVOR, + (int *) &state, statecount)) + goto lose; + + /* Get the PID of the child from the proc server. We must do this + before calling proc_child below, because at that point any + authorized POSIX.1 process may kill the child task with SIGKILL. */ + if (err = __USEPORT (PROC, __proc_task2pid (port, newtask, &pid))) + goto lose; + + /* Register the child with the proc server. It is important that + this be that last thing we do before starting the child thread + running. Once proc_child has been done for the task, it appears + as a POSIX.1 process. Any errors we get must be detected before + this point, and the child must have a message port so it responds + to POSIX.1 signals. */ + if (err = __USEPORT (PROC, __proc_child (port, newtask))) goto lose; - /* Get the PID of the child from the proc server. */ - err = __USEPORT (PROC, __proc_task2pid (port, newtask, &pid)); + /* This must be the absolutely last thing we do; we can't assume that + the child will remain alive for even a moment once we do this. We + ignore errors because we have committed to the fork and are not + allowed to return them after the process becomes visible to + POSIX.1 (which happened right above when we called proc_child). */ + (void) __thread_resume (thread); lose: + if (ports_locked) + for (i = 0; i < _hurd_nports; ++i) + __spin_unlock (&_hurd_ports[i].lock); if (newtask != MACH_PORT_NULL) { @@ -363,6 +497,8 @@ } else { + struct hurd_sigstate *oldstates; + /* We are the child task. Unlock the standard port cells, which were locked in the parent when we copied its memory. The parent has inserted send rights with the names that were in the cells then. */ @@ -373,23 +509,31 @@ take the task-global signals. */ _hurd_sigthread = thread_self; - /* Free the sigstate structures for threads that existed in the - parent task but don't exist in this task (the child process). */ - while (_hurd_sigstates != NULL) + /* Unchain the sigstate structures for threads that existed in the + parent task but don't exist in this task (the child process). + Delay freeing them until later because some of the further setup + and unlocking might be required for free to work. */ + oldstates = _hurd_sigstates; + if (oldstates == ss) + oldstates = ss->next; + else { - struct hurd_sigstate *next = _hurd_sigstates->next; - if (ss != _hurd_sigstates) - free (_hurd_sigstates); - _hurd_sigstates = next; + while (_hurd_sigstates->next != ss) + _hurd_sigstates = _hurd_sigstates->next; + _hurd_sigstates->next = ss->next; } + ss->next = NULL; _hurd_sigstates = ss; - _hurd_sigstates->next = NULL; - /* Fetch our various new process IDs from the proc server. */ + /* Unlock our copies of the signal state locks. */ + unlockss (); + + /* Fetch our new process IDs from the proc server. No need to + refetch our pgrp; it is always inherited from the parent (so + _hurd_pgrp is already correct), and the proc server will send us a + proc_newids notification when it changes. */ err = __USEPORT (PROC, __proc_getpids (port, &_hurd_pid, &_hurd_ppid, &_hurd_orphaned)); - if (!err) - err = __USEPORT (PROC, __proc_getpgrp (port, _hurd_pid, &_hurd_pgrp)); /* Run things that want to run in the child task to set up. */ RUN_HOOK (_hurd_fork_child_hook, ()); @@ -401,6 +545,15 @@ if (!err) err = __thread_resume (_hurd_msgport_thread); + /* Free the old sigstate structures. */ + while (oldstates != NULL) + { + struct hurd_sigstate *next = oldstates->next; + free (oldstates); + oldstates = next; + } + /* XXX what to do if we have any errors here? */ + pid = 0; } @@ -408,10 +561,6 @@ They are locked in both the parent and child tasks. */ for (i = 0; i < _hurd_fork_locks.n; ++i) __mutex_unlock (_hurd_fork_locks.locks[i]); - - if (ss) - ss->critical_section = 0; - __mutex_unlock (&_hurd_siglock); return err ? __hurd_fail (err) : pid; } diff -ruN glibc-1.08.1/sysdeps/mach/hurd/__getdents.c glibc-1.09/sysdeps/mach/hurd/__getdents.c --- glibc-1.08.1/sysdeps/mach/hurd/__getdents.c Tue Feb 1 22:07:10 1994 +++ glibc-1.09/sysdeps/mach/hurd/__getdents.c Mon Jul 18 18:11:11 1994 @@ -1,4 +1,5 @@ -/* Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc. +/* Copyright (C) 1992, 1993, 1994 Free Software Foundation, Ince + This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -28,17 +29,30 @@ int fd AND PTR buf AND size_t nbytes AND off_t *basep) { error_t err; - mach_msg_type_number_t amount; + int entriesread; + char *data = buf; + mach_msg_type_number_t bytesread = nbytes; /* Fault before taking any locks. */ *(volatile off_t *) basep = *basep; - amount = nbytes; - err = HURD_DPORT_USE (fd, - __dir_readdir (port, buf, &amount, *basep, - basep, nbytes)); + err = HURD_DPORT_USE (fd, __dir_readdir (port, &data, &bytesread, + *basep, -1, nbytes, &entriesread)); if (err) return __hurd_dfail (fd, err); - return amount; + if (data != buf) + { + size_t copy = bytesread; + if (copy > nbytes) + /* The server has a violated the dir_readdir protocol. */ + copy = nbytes; + memcpy (buf, data, copy); + __vm_deallocate (__mach_task_self (), (vm_address_t) data, bytesread); + bytesread = copy; + } + + *basep += entriesread; + + return bytesread; } diff -ruN glibc-1.08.1/sysdeps/mach/hurd/__ioctl.c glibc-1.09/sysdeps/mach/hurd/__ioctl.c --- glibc-1.08.1/sysdeps/mach/hurd/__ioctl.c Sun Jun 5 22:58:47 1994 +++ glibc-1.09/sysdeps/mach/hurd/__ioctl.c Fri Sep 30 17:30:16 1994 @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -29,11 +30,14 @@ handlers, one of these lists will contain them. The other lists are handlers built into the library. The definition of the set comes from hurdioctl.c. */ -extern const struct +extern struct { size_t n; struct ioctl_handler *v[0]; - } _hurd_ioctl_handler_lists; + } *const _hurd_ioctl_handlers; + + +#define typesize(type) (1 << (type)) /* Perform the I/O control operation specified by REQUEST on FD. @@ -46,6 +50,8 @@ static const int mach_types[] = { MACH_MSG_TYPE_CHAR, MACH_MSG_TYPE_INTEGER_16, MACH_MSG_TYPE_INTEGER_32, -1 }; +#define io2mach_type(count, type) \ + ((mach_msg_type_t) { mach_types[type], typesize (type) * 8, count, 1, 0, 0 }) /* Extract the type information encoded in the request. */ unsigned int type = _IOC_TYPE (request); @@ -54,12 +60,13 @@ struct { mig_reply_header_t header; - char data[_IOT_COUNT0 (type) * (_IOT_TYPE0 (request) << 1) + - _IOT_COUNT1 (type) * (_IOT_TYPE1 (request) << 1) + - _IOT_COUNT2 (type) * (_IOT_TYPE2 (request) << 1)]; + char data[3 * sizeof (mach_msg_type_t) + + _IOT_COUNT0 (type) * typesize (_IOT_TYPE0 (type)) + + _IOT_COUNT1 (type) * typesize (_IOT_TYPE1 (type)) + + _IOT_COUNT2 (type) * typesize (_IOT_TYPE2 (type))]; } msg; mach_msg_header_t *const m = &msg.header.Head; - mach_msg_type_t *t = (mach_msg_type_t *) msg.data; + mach_msg_type_t *t = &msg.header.RetCodeType; mach_msg_id_t msgid; unsigned int reply_size; @@ -67,41 +74,60 @@ error_t err; -#define io2mach_type(count, type) \ - ((mach_msg_type_t) { mach_types[type], (type << 1) * 8, count, 1, 0, 0 }) + struct hurd_sigstate *ss; + int noctty; - /* Pack an argument into the message buffer. */ - inline void in (unsigned int count, enum __ioctl_datum type) + /* Send the RPC already packed up in MSG to IOPORT + and decode the return value. */ + inline error_t send_rpc (io_t ioport) { - if (count > 0) + error_t err; + + m->msgh_size = (char *) t - (char *) &msg; + m->msgh_remote_port = ioport; + m->msgh_local_port = __mig_get_reply_port (); + m->msgh_seqno = 0; + m->msgh_id = msgid; + m->msgh_bits = MACH_MSGH_BITS (MACH_MSG_TYPE_COPY_SEND, + MACH_MSG_TYPE_MAKE_SEND_ONCE); + err = HURD_EINTR_RPC (ioport, __mach_msg (m, MACH_SEND_MSG|MACH_RCV_MSG, + m->msgh_size, sizeof (msg), + m->msgh_local_port, + MACH_MSG_TIMEOUT_NONE, + MACH_PORT_NULL)); + switch (err) { - void *const p = &t[1]; - const size_t len = count * ((unsigned int) type << 1); - *t = io2mach_type (count, type); - memcpy (p, arg, len); - arg += len; - t = p + ((len + sizeof (*t) - 1) / sizeof (*t) * sizeof (*t)); + case MACH_MSG_SUCCESS: + break; + case MACH_SEND_INVALID_REPLY: + case MACH_RCV_INVALID_NAME: + __mig_dealloc_reply_port (); + default: + return err; } - } - /* Unpack the message buffer into the argument location. */ - inline int out (unsigned int count, unsigned int type, - void *store, void **update) - { - if (count > 0) + if ((m->msgh_bits & MACH_MSGH_BITS_COMPLEX)) { - const size_t len = count * (type << 1); - union { mach_msg_type_t t; int i; } ipctype; - ipctype.t = io2mach_type (count, type); - if (*(int *) t != ipctype.i) - return 1; - ++t; - memcpy (store, t, len); - if (update != NULL) - *update += len; - t = (void *) t + ((len + sizeof (*t) - 1) / sizeof (*t) * sizeof *t); + /* Allow no ports or VM. */ + __mach_msg_destroy (m); + /* Want to return a different error below for a different msgid. */ + if (m->msgh_id == msgid + 100) + return MIG_TYPE_ERROR; } - return 0; + + if (m->msgh_id != msgid + 100) + return (m->msgh_id == MACH_NOTIFY_SEND_ONCE ? + MIG_SERVER_DIED : MIG_REPLY_MISMATCH); + + if (m->msgh_size != reply_size && + m->msgh_size != sizeof (mig_reply_header_t)) + return MIG_TYPE_ERROR; + + if (*(int *) &msg.header.RetCodeType != + ((union { mach_msg_type_t t; int i; }) + { t: io2mach_type (1, _IOTS (sizeof msg.header.RetCode)) }).i) + return MIG_TYPE_ERROR; + return msg.header.RetCode; } va_list ap; @@ -116,8 +142,8 @@ size_t i; const struct ioctl_handler *h; - for (i = 0; i < _hurd_ioctl_handler_lists.n; ++i) - for (h = _hurd_ioctl_handler_lists.v[i]; h != NULL; h = h->next) + for (i = 0; i < _hurd_ioctl_handlers->n; ++i) + for (h = _hurd_ioctl_handlers->v[i]; h != NULL; h = h->next) if (request >= h->first_request && request <= h->last_request) /* This handler groks REQUEST. Se lo puntamonos. */ return (*h->handler) (fd, request, arg); @@ -125,11 +151,37 @@ /* Compute the Mach message ID for the RPC from the group and command parts of the ioctl request. */ - msgid = (100000 + - ((_IOC_GROUP (request) - 'f') * 4000) + _IOC_COMMAND (request)); + msgid = 100000 + ((_IOC_GROUP (request) - 'f') * 4000); /* Base subsystem */ + /* Because of MiG's poorly chosen algorithm of adding 100 to a request + msgid to produce the reply msgid, we cannot just add the command part + of the ioctl request to the subsystem base msgid. For ioctl requests + past 99, we must skip blocks of 100 msgids to allow for the reply + msgids corresponding to the earlier requests. */ + if (_IOC_COMMAND (request) >= 100) + msgid += 100; + if (_IOC_COMMAND (request) >= 200) + msgid += 100; + msgid += _IOC_COMMAND (request); if (_IOC_INOUT (request) & IOC_IN) { + /* Pack an argument into the message buffer. */ + void in (unsigned int count, enum __ioctl_datum type) + { + if (count > 0) + { + void *p = &t[1]; + const size_t len = count * typesize ((unsigned int) type); + *t = io2mach_type (count, type); + memcpy (p, arg, len); + arg += len; + p += len; + p = (void *) (((unsigned long int) p + sizeof (*t) - 1) + & ~(sizeof (*t) - 1)); + t = p; + } + } + /* Pack the argument data. */ in (_IOT_COUNT0 (type), _IOT_TYPE0 (type)); in (_IOT_COUNT1 (type), _IOT_TYPE1 (type)); @@ -148,83 +200,90 @@ if (count > 0) { /* Add the size of the type and data. */ - reply_size += sizeof (mach_msg_type_t) + (type << 1) * count; + reply_size += sizeof (mach_msg_type_t) + typesize (type) * count; /* Align it to word size. */ reply_size += sizeof (mach_msg_type_t) - 1; reply_size &= ~(sizeof (mach_msg_type_t) - 1); } } - figure_reply (_IOT_COUNT0 (request), _IOT_TYPE0 (request)); - figure_reply (_IOT_COUNT1 (request), _IOT_TYPE1 (request)); - figure_reply (_IOT_COUNT2 (request), _IOT_TYPE2 (request)); + figure_reply (_IOT_COUNT0 (type), _IOT_TYPE0 (type)); + figure_reply (_IOT_COUNT1 (type), _IOT_TYPE1 (type)); + figure_reply (_IOT_COUNT2 (type), _IOT_TYPE2 (type)); } - /* Send the RPC. */ + /* Note that fd-write.c implements the same SIGTTOU behavior. + Any changes here should be done there as well. */ + + /* Don't use the ctty io port if we are blocking or ignoring SIGTTOU. */ + ss = _hurd_self_sigstate (); + noctty = (__sigismember (&ss->blocked, SIGTTOU) || + ss->actions[SIGTTOU].sa_handler == SIG_IGN); + __mutex_unlock (&ss->lock); err = HURD_DPORT_USE (fd, ({ - m->msgh_size = (char *) t - (char *) &msg; - m->msgh_remote_port = port; - m->msgh_local_port = __mig_get_reply_port (); - m->msgh_seqno = 0; - m->msgh_id = msgid; - m->msgh_bits = MACH_MSGH_BITS (MACH_MSG_TYPE_COPY_SEND, - MACH_MSG_TYPE_MAKE_SEND_ONCE); -#ifdef notyet - HURD_EINTR_RPC (port, __mach_msg (m, MACH_SEND_MSG|MACH_RCV_MSG, - m->msgh_size, sizeof (msg), - m->msgh_local_port, - MACH_MSG_TIMEOUT_NONE, - MACH_PORT_NULL)); -#else - __mach_msg (m, MACH_SEND_MSG|MACH_RCV_MSG, m->msgh_size, sizeof (msg), - m->msgh_local_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); -#endif + const io_t ioport = (!noctty && ctty != MACH_PORT_NULL) ? ctty : port; + do + { + /* The actual hair to send the RPC is in the inline `send_rpc' + function (above), to avoid horrendous indentation. */ + err = send_rpc (ioport); + if (ioport == ctty && err == EBACKGROUND) + { + if (_hurd_orphaned) + /* Our process group is orphaned, so we never generate a + signal; we just fail. */ + err = EIO; + else + { + /* Send a SIGTTOU signal to our process group. */ + err = __USEPORT (CTTYID, _hurd_sig_post (0, SIGTTOU, port)); + /* XXX what to do if error here? */ + /* At this point we should have just run the handler for + SIGTTOU or resumed after being stopped. Now this is + still a "system call", so check to see if we should + restart it. */ + __mutex_lock (&ss->lock); + if (!(ss->actions[SIGTTOU].sa_flags & SA_RESTART)) + err = EINTR; + __mutex_unlock (&ss->lock); + } + } + } while (err == EBACKGROUND); + err; })); - switch (err) - { - case MACH_MSG_SUCCESS: - break; - case MACH_SEND_INVALID_REPLY: - case MACH_RCV_INVALID_NAME: - __mig_dealloc_reply_port (); - default: - return __hurd_fail (err); - } - - if ((m->msgh_bits & MACH_MSGH_BITS_COMPLEX)) - { - /* Allow no ports or VM. */ - __mach_msg_destroy (m); - /* Want to return a different error below for a different msgid. */ - if (m->msgh_id == msgid + 100) - return __hurd_fail (MIG_TYPE_ERROR); - } - - if (m->msgh_id != msgid + 100) - return __hurd_fail (m->msgh_id == MACH_NOTIFY_SEND_ONCE ? - MIG_SERVER_DIED : MIG_REPLY_MISMATCH); - - if (m->msgh_size != reply_size && - m->msgh_size != sizeof (mig_reply_header_t)) - return __hurd_fail (MIG_TYPE_ERROR); - - if (*(int *) &msg.header.RetCodeType != - ((union { mach_msg_type_t t; int i; }) - { t: io2mach_type (1, _IOTS (sizeof msg.header.RetCode)) }).i) - return __hurd_fail (MIG_TYPE_ERROR); - err = msg.header.RetCode; - t = (mach_msg_type_t *) msg.data; switch (err) { + /* Unpack the message buffer into the argument location. */ + int out (unsigned int count, unsigned int type, + void *store, void **update) + { + if (count > 0) + { + const size_t len = count * typesize (type); + union { mach_msg_type_t t; int i; } ipctype; + ipctype.t = io2mach_type (count, type); + if (*(int *) t != ipctype.i) + return 1; + ++t; + memcpy (store, t, len); + if (update != NULL) + *update += len; + t = (void *) (((unsigned long int) t + len + sizeof (*t) - 1) + & ~(sizeof (*t) - 1)); + } + return 0; + } + case 0: if (m->msgh_size != reply_size || - out (_IOT_COUNT0 (type), _IOT_TYPE0 (type), arg, &arg) || - out (_IOT_COUNT1 (type), _IOT_TYPE1 (type), arg, &arg) || - out (_IOT_COUNT2 (type), _IOT_TYPE2 (type), arg, &arg)) + ((_IOC_INOUT (request) & IOC_OUT) && + (out (_IOT_COUNT0 (type), _IOT_TYPE0 (type), arg, &arg) || + out (_IOT_COUNT1 (type), _IOT_TYPE1 (type), arg, &arg) || + out (_IOT_COUNT2 (type), _IOT_TYPE2 (type), arg, &arg)))) return __hurd_fail (MIG_TYPE_ERROR); return 0; diff -ruN glibc-1.08.1/sysdeps/mach/hurd/__kill.c glibc-1.09/sysdeps/mach/hurd/__kill.c --- glibc-1.08.1/sysdeps/mach/hurd/__kill.c Wed Apr 27 07:09:57 1994 +++ glibc-1.09/sysdeps/mach/hurd/__kill.c Fri Aug 19 15:42:49 1994 @@ -55,8 +55,8 @@ err = __task_terminate (refport); __mach_port_deallocate (__mach_task_self (), refport); } - } while (err != MACH_SEND_INVALID_DEST && - err != MIG_SERVER_DIED); + } while (err == MACH_SEND_INVALID_DEST || + err == MIG_SERVER_DIED); else err = HURD_MSGPORT_RPC (__proc_getmsgport (proc, pid, &msgport), ({ err = __proc_pid2task (proc, pid, @@ -64,6 +64,8 @@ if (err) err = __proc_getsidport (proc, &refport); err; }), + /* If no msgport, we cannot send a signal. */ + msgport == MACH_PORT_NULL ? EPERM : __sig_post (msgport, sig, refport)); if (! err) delivered = 1; @@ -74,16 +76,22 @@ if (pid <= 0) { /* Send SIG to each process in pgrp (- PID). */ - mach_msg_type_number_t npids, i; - pid_t *pids; + pid_t pidbuf[10], *pids = pidbuf; + mach_msg_type_number_t i, npids = sizeof (pidbuf) / sizeof (pidbuf[0]); err = __proc_getpgrppids (proc, - pid, &pids, &npids); if (!err) { for (i = 0; i < npids; ++i) - kill_pid (pids[i]); - __vm_deallocate (__mach_task_self (), - (vm_address_t) pids, npids * sizeof (pids[0])); + { + kill_pid (pids[i]); + if (err == ESRCH) + /* The process died already. Ignore it. */ + err = 0; + } + if (pids != pidbuf) + __vm_deallocate (__mach_task_self (), + (vm_address_t) pids, npids * sizeof (pids[0])); } } else @@ -91,5 +99,9 @@ _hurd_port_free (&_hurd_ports[INIT_PORT_PROC], &ulink, proc); - return delivered ? 0 : __hurd_fail (err); + /* If we delivered no signals, but ERR is clear, this must mean that + every kill_pid call failed with ESRCH, meaning all the processes in + the pgrp died between proc_getpgrppids and kill_pid; in that case we + fail with ESRCH. */ + return delivered ? 0 : __hurd_fail (err ?: ESRCH); } diff -ruN glibc-1.08.1/sysdeps/mach/hurd/__link.c glibc-1.09/sysdeps/mach/hurd/__link.c --- glibc-1.08.1/sysdeps/mach/hurd/__link.c Fri Mar 25 17:35:49 1994 +++ glibc-1.09/sysdeps/mach/hurd/__link.c Tue Aug 30 05:06:25 1994 @@ -30,7 +30,7 @@ file_t oldfile, linknode, todir; char *toname; - oldfile = __path_lookup (from, 0, 0); + oldfile = __file_name_lookup (from, 0, 0); if (oldfile == MACH_PORT_NULL) return -1; @@ -42,7 +42,7 @@ if (err) return __hurd_fail (err); - todir = __path_split (to, &toname); + todir = __file_name_split (to, &toname); if (todir != MACH_PORT_NULL) { err = __dir_link (linknode, todir, toname); diff -ruN glibc-1.08.1/sysdeps/mach/hurd/__lstat.c glibc-1.09/sysdeps/mach/hurd/__lstat.c --- glibc-1.08.1/sysdeps/mach/hurd/__lstat.c Thu May 5 17:03:51 1994 +++ glibc-1.09/sysdeps/mach/hurd/__lstat.c Tue Aug 30 05:06:17 1994 @@ -27,7 +27,7 @@ DEFUN(__lstat, (file, buf), CONST char *file AND struct stat *buf) { error_t err; - file_t port = __path_lookup (file, O_NOLINK, 0); + file_t port = __file_name_lookup (file, O_NOLINK, 0); if (port == MACH_PORT_NULL) return -1; err = __io_stat (port, buf); diff -ruN glibc-1.08.1/sysdeps/mach/hurd/__mkdir.c glibc-1.09/sysdeps/mach/hurd/__mkdir.c --- glibc-1.08.1/sysdeps/mach/hurd/__mkdir.c Thu Jan 6 01:37:36 1994 +++ glibc-1.09/sysdeps/mach/hurd/__mkdir.c Tue Aug 30 08:45:53 1994 @@ -22,13 +22,13 @@ #include #include -/* Create a directory named PATH with protections MODE. */ +/* Create a directory named FILE_NAME with protections MODE. */ int -DEFUN(__mkdir, (path, mode), CONST char *path AND mode_t mode) +DEFUN(__mkdir, (file_name, mode), CONST char *file_name AND mode_t mode) { error_t err; const char *name; - file_t parent = __path_split (path, (char **) &name); + file_t parent = __file_name_split (file_name, (char **) &name); if (parent == MACH_PORT_NULL) return -1; err = __dir_mkdir (parent, name, mode); diff -ruN glibc-1.08.1/sysdeps/mach/hurd/__mknod.c glibc-1.09/sysdeps/mach/hurd/__mknod.c --- glibc-1.08.1/sysdeps/mach/hurd/__mknod.c Mon May 2 17:56:42 1994 +++ glibc-1.09/sysdeps/mach/hurd/__mknod.c Sat Sep 3 00:25:58 1994 @@ -29,12 +29,12 @@ #define minor(x) ((int)((x) & 0xff)) -/* Create a device file named PATH, with permission and special bits MODE +/* Create a device file named FILE_NAME, with permission and special bits MODE and device number DEV (which can be constructed from major and minor device numbers with the `makedev' macro above). */ int -DEFUN(__mknod, (path, mode, dev), - CONST char *path AND mode_t mode AND dev_t dev) +DEFUN(__mknod, (file_name, mode, dev), + CONST char *file_name AND mode_t mode AND dev_t dev) { error_t err; file_t dir, node; @@ -78,13 +78,12 @@ bp = _itoa (minor (dev), bp, 10, 0); *--bp = '\0'; bp = _itoa (major (dev), bp, 10, 0); - *--bp = '\0'; memcpy (bp - len, translator, len); - translator = buf; - len += buf + sizeof (buf) - bp; + translator = bp - len; + len = buf + sizeof (buf) - translator; } - dir = __path_split (path, &name); + dir = __file_name_split (file_name, &name); if (dir == MACH_PORT_NULL) return -1; @@ -93,9 +92,11 @@ if (! err) /* Set the node's translator to make it a device. */ - err = __file_set_translator (node, FS_TRANS_EXCL, 0, - translator, len, - MACH_PORT_NULL, MACH_MSG_TYPE_COPY_SEND); + err = __file_set_translator (node, + FS_TRANS_EXCL | FS_TRANS_SET, + FS_TRANS_EXCL | FS_TRANS_SET, 0, + translator, len, + MACH_PORT_NULL, MACH_MSG_TYPE_COPY_SEND); if (! err) /* Link the node, now a valid device, into the target directory. */ diff -ruN glibc-1.08.1/sysdeps/mach/hurd/__open.c glibc-1.09/sysdeps/mach/hurd/__open.c --- glibc-1.08.1/sysdeps/mach/hurd/__open.c Tue Feb 1 20:53:00 1994 +++ glibc-1.09/sysdeps/mach/hurd/__open.c Tue Aug 30 05:04:58 1994 @@ -41,7 +41,7 @@ else mode = 0; - port = __path_lookup (file, oflag, mode); + port = __file_name_lookup (file, oflag, mode); if (port == MACH_PORT_NULL) return -1; diff -ruN glibc-1.08.1/sysdeps/mach/hurd/__pipe.c glibc-1.09/sysdeps/mach/hurd/__pipe.c --- glibc-1.08.1/sysdeps/mach/hurd/__pipe.c Thu Feb 3 21:18:24 1994 +++ glibc-1.09/sysdeps/mach/hurd/__pipe.c Thu Oct 6 18:56:23 1994 @@ -40,14 +40,24 @@ if (fds == NULL) return __hurd_fail (EINVAL); - /* Find the file domain socket server. */ - server = _hurd_socket_server (AF_FILE); + /* Find the local domain socket server. */ + server = _hurd_socket_server (PF_LOCAL, 0); if (server == MACH_PORT_NULL) return -1; - /* Create two file domain sockets and connect them together. */ + /* Create two local domain sockets and connect them together. */ - if (err = __socket_create (server, SOCK_STREAM, 0, &sock1)) + err = __socket_create (server, SOCK_STREAM, 0, &sock1); + if (err == MACH_SEND_INVALID_DEST || err == MIG_SERVER_DIED) + { + /* On the first use of the socket server during the operation, + allow for the old server port dying. */ + server = _hurd_socket_server (PF_LOCAL, 1); + if (server == MACH_PORT_NULL) + return -1; + err = __socket_create (server, SOCK_STREAM, 0, &sock1); + } + if (err) return __hurd_fail (err); if (err = __socket_create (server, SOCK_STREAM, 0, &sock2)) { @@ -82,6 +92,6 @@ } fds[0] = d1; - fds[2] = d2; + fds[1] = d2; return 0; } diff -ruN glibc-1.08.1/sysdeps/mach/hurd/__readlink.c glibc-1.09/sysdeps/mach/hurd/__readlink.c --- glibc-1.08.1/sysdeps/mach/hurd/__readlink.c Thu May 12 07:51:19 1994 +++ glibc-1.09/sysdeps/mach/hurd/__readlink.c Sun Sep 11 23:38:24 1994 @@ -23,19 +23,19 @@ #include #include -/* Read the contents of the symbolic link PATH into no more than +/* Read the contents of the symbolic link FILE_NAME into no more than LEN bytes of BUF. The contents are not null-terminated. Returns the number of characters read, or -1 for errors. */ ssize_t -DEFUN(__readlink, (path, buf, len), - CONST char *path AND char *buf AND size_t len) +DEFUN(__readlink, (file_name, buf, len), + CONST char *file_name AND char *buf AND size_t len) { error_t err; file_t file; char mybuf[2048], *transp = mybuf; unsigned int translen = sizeof (mybuf); - file = __path_lookup (path, O_NOTRANS, 0); + file = __file_name_lookup (file_name, O_NOTRANS, 0); if (file == MACH_PORT_NULL) return -1; @@ -52,12 +52,19 @@ else { /* This is a symlink; its translator is "/hurd/symlink\0target\0". */ - if (len > translen - sizeof (_HURD_SYMLINK)) - len = translen - sizeof (_HURD_SYMLINK); - if (transp[translen - 1] == '\0') - /* Remove the null terminator. */ - --len; - memcpy (buf, transp + sizeof (_HURD_SYMLINK), len); + if (len >= translen - sizeof (_HURD_SYMLINK)) + { + len = translen - sizeof (_HURD_SYMLINK); + if (transp[translen - 1] == '\0') + /* Remove the null terminator. */ + --len; + } + if (buf == NULL) + /* This call is just to find out how large a buffer is required. */ + len = translen - sizeof (_HURD_SYMLINK) - 1; + else + /* Copy into the user's buffer. */ + memcpy (buf, transp + sizeof (_HURD_SYMLINK), len); } if (transp != mybuf) diff -ruN glibc-1.08.1/sysdeps/mach/hurd/__rmdir.c glibc-1.09/sysdeps/mach/hurd/__rmdir.c --- glibc-1.08.1/sysdeps/mach/hurd/__rmdir.c Thu Jan 6 01:37:59 1994 +++ glibc-1.09/sysdeps/mach/hurd/__rmdir.c Tue Aug 30 08:50:59 1994 @@ -22,13 +22,13 @@ #include #include -/* Remove the directory PATH. */ +/* Remove the directory FILE_NAME. */ int -DEFUN(__rmdir, (path), CONST char *path) +DEFUN(__rmdir, (file_name), CONST char *file_name) { error_t err; const char *name; - file_t parent = __path_split (path, (char **) &name); + file_t parent = __file_name_split (file_name, (char **) &name); if (parent == MACH_PORT_NULL) return -1; err = __dir_rmdir (parent, name); diff -ruN glibc-1.08.1/sysdeps/mach/hurd/__select.c glibc-1.09/sysdeps/mach/hurd/__select.c --- glibc-1.08.1/sysdeps/mach/hurd/__select.c Tue May 24 13:06:04 1994 +++ glibc-1.09/sysdeps/mach/hurd/__select.c Thu Aug 18 02:27:39 1994 @@ -23,7 +23,7 @@ #include #include -#define SELECT_DONE_MSGID 23016 /* XXX */ +#define SELECT_DONE_MSGID 23020 /* XXX */ /* Check the first NFDS descriptors each in READFDS (if not NULL) for read readiness, in WRITEFDS (if not NULL) for write readiness, and in EXCEPTFDS @@ -53,13 +53,6 @@ if (exceptfds != NULL) *(volatile fd_set *) exceptfds = *exceptfds; - if (timeout != NULL && timeout->tv_sec == 0 && timeout->tv_usec == 0) - /* We just want to poll, so we don't need a receive right. */ - port = MACH_PORT_NULL; - else - /* Get a port to receive the io_select_done message on. */ - port = __mach_reply_port (); - HURD_CRITICAL_BEGIN; __mutex_lock (&_hurd_dtable_lock); @@ -102,6 +95,13 @@ if (i < nfds) return -1; + if (timeout != NULL && timeout->tv_sec == 0 && timeout->tv_usec == 0) + /* We just want to poll, so we don't need a receive right. */ + port = MACH_PORT_NULL; + else + /* Get a port to receive the io_select_done message on. */ + port = __mach_reply_port (); + /* Send them all io_select calls. */ got = 0; err = 0; @@ -110,7 +110,9 @@ { if (!err) { - err = __io_select (ports[i], types[i], port, i, &types[i]); + err = __io_select (ports[i], types[i], + port, MACH_MSG_TYPE_MAKE_SEND_ONCE, + i, &types[i]); if (types[i]) ++got; } @@ -123,20 +125,32 @@ /* Now wait for select_done messages on PORT, timing out as appropriate. */ - struct + union { mach_msg_header_t head; - mach_msg_type_t result_type; - int result; - mach_msg_type_t tag_type; - int tag; + struct + { + mach_msg_header_t head; + mach_msg_type_t result_type; + int result; + mach_msg_type_t tag_type; + int tag; + } request; + struct + { + mach_msg_header_t head; + mach_msg_type_t err_type; + error_t err; + } reply; } msg; const mach_msg_timeout_t to = (timeout != NULL ? (timeout->tv_sec * 1000 + timeout->tv_usec / 1000) : 0); mach_msg_option_t options = (timeout == NULL ? 0 : MACH_RCV_TIMEOUT); - while ((err = __mach_msg (&msg, MACH_RCV_MSG | options, 0, sizeof (msg), + while ((err = __mach_msg (&msg.head, + MACH_RCV_MSG | options, + sizeof (msg.reply), sizeof (msg.request), port, to, MACH_PORT_NULL)) == MACH_MSG_SUCCESS) { /* We got a message. Decode it. */ @@ -144,34 +158,38 @@ { MACH_MSG_TYPE_INTEGER_32, 32, 1, 1, 0, 0 }; if (msg.head.msgh_id == SELECT_DONE_MSGID && !(msg.head.msgh_bits & MACH_MSGH_BITS_COMPLEX) && - *(int *) &msg.result_type == *(int *) &inttype && - *(int *) &msg.tag_type == *(int *) &inttype && - (msg.result & (SELECT_READ|SELECT_WRITE|SELECT_URG)) && - msg.tag >= 0 && msg.tag < nfds) + *(int *) &msg.request.result_type == *(int *) &inttype && + *(int *) &msg.request.tag_type == *(int *) &inttype && + (msg.request.result & (SELECT_READ|SELECT_WRITE|SELECT_URG)) && + msg.request.tag >= 0 && msg.request.tag < nfds) { /* This is a winning io_select_done message! Record the readiness it indicates and send a reply. */ - if (types[msg.tag] == 0) + if (types[msg.request.tag] == 0) /* This descriptor is ready and it was not before, so we increment our count of ready descriptors. */ ++got; - types[msg.tag] |= msg.result; + types[msg.request.tag] |= msg.request.result; if (msg.head.msgh_remote_port != MACH_PORT_NULL) { msg.head.msgh_id += 100; - msg.result_type = inttype; - msg.result = 0; - /* When we loop below, send this reply message - in the same operation that polls for another - io_select_done request message. */ + msg.reply.err_type = inttype; + msg.reply.err = 0; + /* When we loop below, send this reply message in the + same operation that polls for another io_select_done + request message. */ options |= MACH_SEND_MSG; + /* The reply message has no reply port of its own. */ + msg.head.msgh_bits &= ~MACH_MSGH_BITS_LOCAL_MASK; + msg.head.msgh_local_port = MACH_PORT_NULL; } } else { /* Randomness. */ __mach_msg_destroy (msg); + continue; } /* Poll for another message. */ diff -ruN glibc-1.08.1/sysdeps/mach/hurd/__setitmr.c glibc-1.09/sysdeps/mach/hurd/__setitmr.c --- glibc-1.08.1/sysdeps/mach/hurd/__setitmr.c Tue May 24 05:15:44 1994 +++ glibc-1.09/sysdeps/mach/hurd/__setitmr.c Mon Jul 18 18:11:25 1994 @@ -310,3 +310,21 @@ /* Continue with normal delivery of SIGALRM. */ return SIG_DFL; } + +#include + +static void +fork_itimer (void) +{ + /* We must restart the itimer in the child. */ + + struct itimerval it; + + __spin_lock (&_hurd_itimer_lock); + _hurd_itimer_thread = MACH_PORT_NULL; + it = _hurd_itimerval; + it.it_value = it.it_interval; + + setitimer_locked (&it, NULL, NULL); +} +text_set_element (_hurd_fork_child_hook, fork_itimer); diff -ruN glibc-1.08.1/sysdeps/mach/hurd/__setpgrp.c glibc-1.09/sysdeps/mach/hurd/__setpgrp.c --- glibc-1.08.1/sysdeps/mach/hurd/__setpgrp.c Tue Feb 1 22:07:08 1994 +++ glibc-1.09/sysdeps/mach/hurd/__setpgrp.c Fri Aug 19 18:36:03 1994 @@ -28,6 +28,27 @@ int DEFUN(__setpgrp, (pid, pgid), pid_t pid AND pid_t pgid) { - error_t err = __USEPORT (PROC, __proc_setpgrp (port, pid, pgid)); - return err ? __hurd_fail (err) : 0; + error_t err; + unsigned int stamp; + + stamp = _hurd_pids_changed_stamp; /* Atomic fetch. */ + + if (err = __USEPORT (PROC, __proc_setpgrp (port, pid, pgid))) + return __hurd_fail (err); + + if (pid == 0 || pid == _hurd_pid) + /* Synchronize with the signal thread to make sure we have + received and processed proc_newids before returning to the user. */ + while (_hurd_pids_changed_stamp == stamp) + { +#ifdef noteven + /* XXX we have no need for a mutex, but cthreads demands one. */ + __condition_wait (&_hurd_pids_changed_sync, NULL); +#else + swtch(); +#endif + } + + return 0; + } diff -ruN glibc-1.08.1/sysdeps/mach/hurd/__setregid.c glibc-1.09/sysdeps/mach/hurd/__setregid.c --- glibc-1.08.1/sysdeps/mach/hurd/__setregid.c Thu May 12 07:58:12 1994 +++ glibc-1.09/sysdeps/mach/hurd/__setregid.c Wed Nov 2 23:05:57 1994 @@ -48,7 +48,7 @@ memcpy (&newaux[1], _hurd_id.aux.gids, (naux - 1) * sizeof (gid_t)); err = __USEPORT (AUTH, __auth_makeauth - (port, NULL, 0, MACH_MSG_TYPE_COPY_SEND, + (port, NULL, MACH_MSG_TYPE_COPY_SEND, 0, _hurd_id.gen.gids, _hurd_id.gen.ngids, _hurd_id.aux.gids, _hurd_id.aux.ngids, newgen, ngen, diff -ruN glibc-1.08.1/sysdeps/mach/hurd/__setreuid.c glibc-1.09/sysdeps/mach/hurd/__setreuid.c --- glibc-1.08.1/sysdeps/mach/hurd/__setreuid.c Thu May 12 07:58:56 1994 +++ glibc-1.09/sysdeps/mach/hurd/__setreuid.c Wed Nov 2 23:05:08 1994 @@ -48,7 +48,7 @@ memcpy (&newaux[1], _hurd_id.aux.uids, (naux - 1) * sizeof (uid_t)); err = __USEPORT (AUTH, __auth_makeauth - (port, NULL, 0, MACH_MSG_TYPE_COPY_SEND, + (port, NULL, MACH_MSG_TYPE_COPY_SEND, 0, newgen, ngen, newaux, naux, _hurd_id.gen.gids, _hurd_id.gen.ngids, diff -ruN glibc-1.08.1/sysdeps/mach/hurd/__setsid.c glibc-1.09/sysdeps/mach/hurd/__setsid.c --- glibc-1.08.1/sysdeps/mach/hurd/__setsid.c Tue Feb 1 22:07:07 1994 +++ glibc-1.09/sysdeps/mach/hurd/__setsid.c Fri Sep 30 17:43:02 1994 @@ -29,6 +29,29 @@ int DEFUN_VOID(__setsid) { - error_t err = __USEPORT (PROC, __proc_setsid (port)); - return err ? __hurd_fail (err) : 0; + error_t err; + unsigned int stamp; + + stamp = _hurd_pids_changed_stamp; /* Atomic fetch. */ + + /* Tell the proc server we want to start a new session. */ + if (err = __USEPORT (PROC, __proc_setsid (port))) + return __hurd_fail (err); + + /* Punt our current ctty. */ + _hurd_setcttyid (MACH_PORT_NULL); + + /* Synchronize with the signal thread to make sure we have + received and processed proc_newids before returning to the user. */ + while (_hurd_pids_changed_stamp == stamp) + { +#ifdef noteven + /* XXX we have no need for a mutex, but cthreads demands one. */ + __condition_wait (&_hurd_pids_changed_sync, NULL); +#else + swtch(); +#endif + } + + return 0; } diff -ruN glibc-1.08.1/sysdeps/mach/hurd/__stat.c glibc-1.09/sysdeps/mach/hurd/__stat.c --- glibc-1.08.1/sysdeps/mach/hurd/__stat.c Sat Oct 30 15:34:32 1993 +++ glibc-1.09/sysdeps/mach/hurd/__stat.c Tue Aug 30 05:04:18 1994 @@ -1,4 +1,4 @@ -/* Copyright (C) 1992, 1993 Free Software Foundation, Inc. +/* Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -27,7 +27,7 @@ DEFUN(__stat, (file, buf), CONST char *file AND struct stat *buf) { error_t err; - file_t port = __path_lookup (file, 0, 0); + file_t port = __file_name_lookup (file, 0, 0); if (port == MACH_PORT_NULL) return -1; err = __io_stat (port, buf); diff -ruN glibc-1.08.1/sysdeps/mach/hurd/__symlink.c glibc-1.09/sysdeps/mach/hurd/__symlink.c --- glibc-1.08.1/sysdeps/mach/hurd/__symlink.c Tue May 3 15:18:10 1994 +++ glibc-1.09/sysdeps/mach/hurd/__symlink.c Tue Aug 30 05:03:55 1994 @@ -38,16 +38,18 @@ memcpy (buf, _HURD_SYMLINK, sizeof (_HURD_SYMLINK)); memcpy (&buf[sizeof (_HURD_SYMLINK)], from, len); - dir = __path_split (to, &name); + dir = __file_name_split (to, &name); if (dir == MACH_PORT_NULL) return -1; /* Create a new, unlinked node in the target directory. */ - err = __dir_mkfile (dir, O_WRITE, 0777 & _hurd_umask, &node); + err = __dir_mkfile (dir, O_WRITE, 0777 & ~_hurd_umask, &node); if (! err) /* Set the node's translator to make it a symlink. */ - err = __file_set_translator (node, FS_TRANS_EXCL, 0, + err = __file_set_translator (node, + FS_TRANS_EXCL|FS_TRANS_SET, + FS_TRANS_EXCL|FS_TRANS_SET, 0, buf, sizeof (_HURD_SYMLINK) + len, MACH_PORT_NULL, MACH_MSG_TYPE_COPY_SEND); diff -ruN glibc-1.08.1/sysdeps/mach/hurd/__unlink.c glibc-1.09/sysdeps/mach/hurd/__unlink.c --- glibc-1.08.1/sysdeps/mach/hurd/__unlink.c Thu Jan 6 01:38:23 1994 +++ glibc-1.09/sysdeps/mach/hurd/__unlink.c Tue Aug 30 05:03:35 1994 @@ -31,7 +31,7 @@ file_t dir; CONST char *file; - dir = __path_split (name, (char **) &file); + dir = __file_name_split (name, (char **) &file); if (dir == MACH_PORT_NULL) return -1; diff -ruN glibc-1.08.1/sysdeps/mach/hurd/__utimes.c glibc-1.09/sysdeps/mach/hurd/__utimes.c --- glibc-1.08.1/sysdeps/mach/hurd/__utimes.c Wed Dec 22 16:46:52 1993 +++ glibc-1.09/sysdeps/mach/hurd/__utimes.c Tue Aug 30 05:03:21 1994 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -29,7 +29,7 @@ CONST char *file AND struct timeval tvp[2]) { error_t err; - file_t f = __path_lookup (file, 0, 0); + file_t f = __file_name_lookup (file, 0, 0); if (f == MACH_PORT_NULL) return -1; err = __file_utimes (f, diff -ruN glibc-1.08.1/sysdeps/mach/hurd/bind.c glibc-1.09/sysdeps/mach/hurd/bind.c --- glibc-1.08.1/sysdeps/mach/hurd/bind.c Tue Apr 26 20:18:10 1994 +++ glibc-1.09/sysdeps/mach/hurd/bind.c Tue Aug 30 05:02:46 1994 @@ -22,6 +22,12 @@ #include #include #include +#include +#include +#include +#include +#include +#include /* Give the socket FD the local address ADDR (which is LEN bytes long). */ int @@ -31,12 +37,58 @@ addr_port_t aport; error_t err; + if (addr->sa_family == AF_LOCAL) + { + /* For the local domain, we must create a node in the filesystem + using the ifsock translator and then fetch the address from it. */ + struct sockaddr_un *unaddr = (struct sockaddr_un *) addr; + file_t dir, node; + char name[len - offsetof (struct sockaddr_un, sun_path)], *n; + strncpy (name, unaddr->sun_path, sizeof name); + dir = __file_name_split (name, &n); + if (dir == MACH_PORT_NULL) + return -1; + + /* Create a new, unlinked node in the target directory. */ + err = __dir_mkfile (dir, O_CREAT, 0666 & ~_hurd_umask, &node); + + if (! err) + { + file_t ifsock; + /* Set the node's translator to make it a local-domain socket. */ + err = __file_set_translator (node, + FS_TRANS_EXCL | FS_TRANS_SET, + FS_TRANS_EXCL | FS_TRANS_SET, 0, + _HURD_IFSOCK, sizeof _HURD_IFSOCK, + MACH_PORT_NULL, + MACH_MSG_TYPE_COPY_SEND); + if (! err) + /* Get a port to the ifsock translator. */ + err = __hurd_invoke_translator (node, 0, &ifsock); + if (! err) + /* Get the address port. */ + err = __ifsock_getsockaddr (ifsock, &aport); + __mach_port_deallocate (__mach_task_self (), ifsock); + if (! err) + /* Link the node, now a socket, into the target directory. */ + err = __dir_link (node, dir, name); + __mach_port_deallocate (__mach_task_self (), node); + } + __mach_port_deallocate (__mach_task_self (), dir); + + if (err) + return __hurd_fail (err); + } + else + err = EIEIO; + err = HURD_DPORT_USE (fd, ({ - err = __socket_create_address (port, - addr->sa_family, - (char *) addr, len, - &aport, 1); + if (err) + err = __socket_create_address (port, + addr->sa_family, + (char *) addr, len, + &aport, 1); if (! err) { err = __socket_bind (port, aport); diff -ruN glibc-1.08.1/sysdeps/mach/hurd/chflags.c glibc-1.09/sysdeps/mach/hurd/chflags.c --- glibc-1.08.1/sysdeps/mach/hurd/chflags.c Tue Dec 21 01:04:17 1993 +++ glibc-1.09/sysdeps/mach/hurd/chflags.c Tue Aug 30 05:02:14 1994 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -27,7 +27,7 @@ DEFUN(chflags, (file, flags), CONST char *file AND int flags) { error_t err; - file_t port = __path_lookup (file, 0, 0); + file_t port = __file_name_lookup (file, 0, 0); if (port == MACH_PORT_NULL) return -1; err = __file_chflags (port, flags); diff -ruN glibc-1.08.1/sysdeps/mach/hurd/chroot.c glibc-1.09/sysdeps/mach/hurd/chroot.c --- glibc-1.08.1/sysdeps/mach/hurd/chroot.c Tue Feb 1 21:56:57 1994 +++ glibc-1.09/sysdeps/mach/hurd/chroot.c Tue Aug 30 20:30:16 1994 @@ -24,28 +24,22 @@ #include #include -/* Change the current root to PATH. */ +/* Change the current root to FILE_NAME. */ int -DEFUN(chroot, (path), CONST char *path) +DEFUN(chroot, (file_name), CONST char *file_name) { - file_t crdir; + file_t file, dir; error_t err; - struct stat st; - crdir = __path_lookup (path, O_EXEC, 0); - if (crdir == MACH_PORT_NULL) + file = __file_name_lookup (file_name, O_EXEC, 0); + if (file == MACH_PORT_NULL) return -1; - - err = __io_stat (crdir, &st); - if (! err && ! S_ISDIR (st.st_mode)) - err = ENOTDIR; + err = __USEPORT (CRDIR, __hurd_file_name_lookup (port, file, "", + O_EXEC, 0, &dir)); + __mach_port_deallocate (__mach_task_self (), file); if (err) - { - __mach_port_deallocate (__mach_task_self (), crdir); - return __hurd_fail (err); - } - - _hurd_port_set (&_hurd_ports[INIT_PORT_CRDIR], crdir); + return __hurd_fail (err); + _hurd_port_set (&_hurd_ports[INIT_PORT_CRDIR], dir); return 0; } diff -ruN glibc-1.08.1/sysdeps/mach/hurd/connect.c glibc-1.09/sysdeps/mach/hurd/connect.c --- glibc-1.08.1/sysdeps/mach/hurd/connect.c Tue Apr 26 20:18:08 1994 +++ glibc-1.09/sysdeps/mach/hurd/connect.c Thu Sep 1 23:24:08 1994 @@ -22,6 +22,8 @@ #include #include #include +#include +#include /* Open a connection on socket FD to peer at ADDR (which LEN bytes long). For connectionless socket types, just set the default address to send to @@ -33,13 +35,33 @@ { error_t err; addr_port_t aport; - + + if (addr->sa_family == AF_LOCAL) + { + /* For the local domain, we must look up the name as a file and talk + to it with the ifsock protocol. */ + struct sockaddr_un *unaddr = (struct sockaddr_un *) addr; + file_t file = __file_name_lookup (unaddr->sun_path, 0, 0); + if (file == MACH_PORT_NULL) + return -1; + err = __ifsock_getsockaddr (file, &aport); + __mach_port_deallocate (__mach_task_self (), file); + if (err == MIG_BAD_ID || err == EOPNOTSUPP) + /* The file did not grok the ifsock protocol. */ + err = ENOTSOCK; + if (err) + return __hurd_fail (err); + } + else + err = EIEIO; + err = HURD_DPORT_USE (fd, ({ - err = __socket_create_address (port, - addr->sa_family, - (char *) addr, len, - &aport, 0); + if (err) + err = __socket_create_address (port, + addr->sa_family, + (char *) addr, len, + &aport, 0); if (! err) { err = __socket_connect (port, aport); diff -ruN glibc-1.08.1/sysdeps/mach/hurd/dirstream.h glibc-1.09/sysdeps/mach/hurd/dirstream.h --- glibc-1.08.1/sysdeps/mach/hurd/dirstream.h Thu Jan 6 01:34:11 1994 +++ glibc-1.09/sysdeps/mach/hurd/dirstream.h Mon Jul 18 18:11:35 1994 @@ -20,8 +20,6 @@ #define _DIRSTREAM_H 1 -#include - /* Directory stream type. The Hurd directory format is the same as `struct dirent', so `readdir' @@ -31,12 +29,12 @@ { /* XXX we need a namespace-clean name for mach_port_t! */ unsigned int __port; /* Port to the directory. */ - __off_t __filepos; /* Current file position. */ - __off_t __block_size; /* Size to read chunks in (st_blksize). */ char *__data; /* Directory block. */ + int __entry_data; /* Entry number `__data' corresponds to. */ + char *__ptr; /* Current pointer into the block. */ + int __entry_ptr; /* Entry number `__ptr' corresponds to. */ unsigned int __allocation; /* Space allocated for the block. */ unsigned int __size; /* Total valid data in the block. */ - __off_t __offset; /* Current offset into the block. */ } DIR; #endif /* dirstream.h */ diff -ruN glibc-1.08.1/sysdeps/mach/hurd/errlist.awk glibc-1.09/sysdeps/mach/hurd/errlist.awk --- glibc-1.08.1/sysdeps/mach/hurd/errlist.awk Thu Feb 3 21:13:44 1994 +++ glibc-1.09/sysdeps/mach/hurd/errlist.awk Fri Oct 28 02:33:09 1994 @@ -20,6 +20,7 @@ # @comment errno.h # @comment POSIX.1: Function not implemented # @deftypevr Macro int ENOSYS +# @comment errno 78 BEGIN { print "/* This file is generated from errno.texi by errlist.awk. */" @@ -31,7 +32,7 @@ print "" print "const char *_sys_errlist[] ="; print " {"; - errno = 0; + maxerrno = 0; print " \"Success\"," } $1 == "@comment" && $2 == "errno.h" { errnoh=1; next } @@ -43,21 +44,32 @@ etext = etext " " $i; next; } -errnoh == 2 && $1 == "@deftypevr" && $2 == "Macro" && $3 == "int" \ +errnoh == 2 && $1 == "@deftypevr" && $2 == "Macro" && $3 == "int" \ { - e = $4; - if (e != "EAGAIN") - printf "%-40s/* %d = %s */\n", " \"" etext "\",", ++errno, e; + e = $4; errnoh++; next; + } +errnoh == 3 && $1 == "@comment" && $2 == "errno" \ + { + errno = $3 + 0; + msgs[errno] = etext; + names[errno] = e; + if (errno > maxerrno) maxerrno = errno; next; } { errnoh=0 } END { + for (i = 1; i <= maxerrno; ++i) + { + if (names[i] == "") + print " \"Reserved error " i "\","; + else + printf "%-40s/* %d = %s */\n", " \"" msgs[i] "\",", i, names[i]; + } print " };"; print ""; print "#include "; - ++errno; - printf "#if _HURD_ERRNOS != %d\n", errno; + printf "#if _HURD_ERRNOS != %d\n", maxerrno+1; print "#error errlist/errnos generation bug"; print "#endif" - printf "const int _sys_nerr = %d;\n", errno; + printf "const int _sys_nerr = %d;\n", maxerrno+1; } diff -ruN glibc-1.08.1/sysdeps/mach/hurd/errlist.c glibc-1.09/sysdeps/mach/hurd/errlist.c --- glibc-1.08.1/sysdeps/mach/hurd/errlist.c Tue Feb 8 00:03:35 1994 +++ glibc-1.09/sysdeps/mach/hurd/errlist.c Fri Oct 28 02:35:33 1994 @@ -30,8 +30,8 @@ "Not a directory", /* 20 = ENOTDIR */ "Is a directory", /* 21 = EISDIR */ "Invalid argument", /* 22 = EINVAL */ - "Too many open files", /* 23 = EMFILE */ - "Too many open files in system", /* 24 = ENFILE */ + "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 */ @@ -42,7 +42,7 @@ "Broken pipe", /* 32 = EPIPE */ "Numerical argument out of domain", /* 33 = EDOM */ "Numerical result out of range", /* 34 = ERANGE */ - "Operation would block", /* 35 = EWOULDBLOCK */ + "Resource temporarily unavailable", /* 35 = EAGAIN */ "Operation now in progress", /* 36 = EINPROGRESS */ "Operation already in progress", /* 37 = EALREADY */ "Socket operation on non-socket", /* 38 = ENOTSOCK */ @@ -66,28 +66,57 @@ "Socket is already connected", /* 56 = EISCONN */ "Socket is not connected", /* 57 = ENOTCONN */ "Can't send after socket shutdown", /* 58 = ESHUTDOWN */ - "Connection timed out", /* 59 = ETIMEDOUT */ - "Connection refused", /* 60 = ECONNREFUSED */ - "Too many levels of symbolic links",/* 61 = ELOOP */ - "File name too long", /* 62 = ENAMETOOLONG */ - "Host is down", /* 63 = EHOSTDOWN */ - "No route to host", /* 64 = EHOSTUNREACH */ - "Directory not empty", /* 65 = ENOTEMPTY */ - "Too many users", /* 66 = EUSERS */ - "Disc quota exceeded", /* 67 = EDQUOT */ - "Stale NFS file handle", /* 68 = ESTALE */ - "Too many levels of remote in path",/* 69 = EREMOTE */ - "No locks available", /* 70 = ENOLCK */ - "Function not implemented", /* 71 = ENOSYS */ - "Inappropriate operation for background process",/* 72 = EBACKGROUND */ - "?", /* 73 = ED */ - "You really blew it this time", /* 74 = EGREGIOUS */ - "Computer bought the farm", /* 75 = EIEIO */ - "Gratuitous error", /* 76 = EGRATUITOUS */ + "Too many references: can't splice",/* 59 = ETOOMANYREFS */ + "Connection timed out", /* 60 = ETIMEDOUT */ + "Connection refused", /* 61 = ECONNREFUSED */ + "Too many levels of symbolic links",/* 62 = ELOOP */ + "File name too long", /* 63 = ENAMETOOLONG */ + "Host is down", /* 64 = EHOSTDOWN */ + "No route to host", /* 65 = EHOSTUNREACH */ + "Directory not empty", /* 66 = ENOTEMPTY */ + "Too many processes", /* 67 = EPROCLIM */ + "Too many users", /* 68 = EUSERS */ + "Disc quota exceeded", /* 69 = EDQUOT */ + "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 program not available", /* 74 = EPROGUNAVAIL */ + "RPC program version wrong", /* 75 = EPROGMISMATCH */ + "RPC 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 */ + "Reserved error 82", + "Reserved error 83", + "Reserved error 84", + "Reserved error 85", + "Reserved error 86", + "Reserved error 87", + "Reserved error 88", + "Reserved error 89", + "Reserved error 90", + "Reserved error 91", + "Reserved error 92", + "Reserved error 93", + "Reserved error 94", + "Reserved error 95", + "Reserved error 96", + "Reserved error 97", + "Reserved error 98", + "Reserved error 99", + "Inappropriate operation for background process",/* 100 = EBACKGROUND */ + "Translator died", /* 101 = EDIED */ + "?", /* 102 = ED */ + "You really blew it this time", /* 103 = EGREGIOUS */ + "Computer bought the farm", /* 104 = EIEIO */ + "Gratuitous error", /* 105 = EGRATUITOUS */ }; #include -#if _HURD_ERRNOS != 77 +#if _HURD_ERRNOS != 106 #error errlist/errnos generation bug #endif -const int _sys_nerr = 77; +const int _sys_nerr = 106; diff -ruN glibc-1.08.1/sysdeps/mach/hurd/errnos.awk glibc-1.09/sysdeps/mach/hurd/errnos.awk --- glibc-1.08.1/sysdeps/mach/hurd/errnos.awk Thu May 12 08:33:23 1994 +++ glibc-1.09/sysdeps/mach/hurd/errnos.awk Fri Oct 28 02:28:38 1994 @@ -34,8 +34,8 @@ print ""; print "#ifdef _ERRNO_H\n"; print "enum __error_t_codes\n{"; - errno = 0; errnoh = 0; + maxerrno = 0; in_mach_errors = 0; in_math = 0; edom = erange = ""; @@ -53,21 +53,24 @@ } errnoh == 2 && $1 == "@deftypevr" && $2 == "Macro" && $3 == "int" \ - { - e = $4; + { ++errnoh; e = $4; next; } + +errnoh == 3 && $1 == "@comment" && $2 == "errno" { + errno = $3 + 0; + if (errno > maxerrno) maxerrno = errno; if (e == "EWOULDBLOCK") { print "#define EWOULDBLOCK EAGAIN /* Operation would block */"; next; } x = sprintf ("%-40s/*%s */", sprintf ("%-24s%s", "#define\t" e, - "_HURD_ERRNO (" errno+1 ")"), + "_HURD_ERRNO (" errno ")"), etext); if (e == "EDOM") edom = x; else if (e == "ERANGE") erange = x; - printf "\t%-16s= _HURD_ERRNO (%d),\n", e, ++errno; + printf "\t%-16s= _HURD_ERRNO (%d),\n", e, errno; print x; next; } @@ -132,7 +135,7 @@ print ""; print "};"; print ""; - printf "#define\t_HURD_ERRNOS\t%d\n", ++errno; + printf "#define\t_HURD_ERRNOS\t%d\n", maxerrno+1; print ""; print "\ /* User-visible type of error codes. It is ok to use `int' or\n\ diff -ruN glibc-1.08.1/sysdeps/mach/hurd/errnos.h glibc-1.09/sysdeps/mach/hurd/errnos.h --- glibc-1.08.1/sysdeps/mach/hurd/errnos.h Thu May 12 08:34:42 1994 +++ glibc-1.09/sysdeps/mach/hurd/errnos.h Fri Oct 28 02:34:26 1994 @@ -1,4 +1,4 @@ -/* This file generated by gawk manual/errno.texi ../mach/mach/message.h ../mach/mach/kern_return.h ../mach/mach/mig_errors.h ../mach/device/device_types.h. */ +/* This file generated by gawk ../manual/errno.texi ../../mach/mach/message.h ../../mach/mach/kern_return.h ../../mach/mach/mig_errors.h ../../mach/device/device_types.h. */ /* The Hurd uses Mach error system 0x10, currently only subsystem 0. */ #ifndef _HURD_ERRNO @@ -55,10 +55,10 @@ #define EISDIR _HURD_ERRNO (21)/* Is a directory */ EINVAL = _HURD_ERRNO (22), #define EINVAL _HURD_ERRNO (22)/* Invalid argument */ - EMFILE = _HURD_ERRNO (23), -#define EMFILE _HURD_ERRNO (23)/* Too many open files */ - ENFILE = _HURD_ERRNO (24), -#define ENFILE _HURD_ERRNO (24)/* Too many open files in system */ + EMFILE = _HURD_ERRNO (24), +#define EMFILE _HURD_ERRNO (24)/* Too many open files */ + ENFILE = _HURD_ERRNO (23), +#define ENFILE _HURD_ERRNO (23)/* Too many open files in system */ ENOTTY = _HURD_ERRNO (25), #define ENOTTY _HURD_ERRNO (25)/* Inappropriate ioctl for device */ ETXTBSY = _HURD_ERRNO (26), @@ -88,8 +88,6 @@ #define EALREADY _HURD_ERRNO (37)/* Operation already in progress */ ENOTSOCK = _HURD_ERRNO (38), #define ENOTSOCK _HURD_ERRNO (38)/* Socket operation on non-socket */ - EDESTADDRREQ = _HURD_ERRNO (39), -#define EDESTADDRREQ _HURD_ERRNO (39)/* Destination address required */ EMSGSIZE = _HURD_ERRNO (40), #define EMSGSIZE _HURD_ERRNO (40)/* Message too long */ EPROTOTYPE = _HURD_ERRNO (41), @@ -126,44 +124,68 @@ #define EISCONN _HURD_ERRNO (56)/* Socket is already connected */ ENOTCONN = _HURD_ERRNO (57), #define ENOTCONN _HURD_ERRNO (57)/* Socket is not connected */ + EDESTADDRREQ = _HURD_ERRNO (39), +#define EDESTADDRREQ _HURD_ERRNO (39)/* Destination address required */ ESHUTDOWN = _HURD_ERRNO (58), #define ESHUTDOWN _HURD_ERRNO (58)/* Can't send after socket shutdown */ - ETIMEDOUT = _HURD_ERRNO (59), -#define ETIMEDOUT _HURD_ERRNO (59)/* Connection timed out */ - ECONNREFUSED = _HURD_ERRNO (60), -#define ECONNREFUSED _HURD_ERRNO (60)/* Connection refused */ - ELOOP = _HURD_ERRNO (61), -#define ELOOP _HURD_ERRNO (61)/* Too many levels of symbolic links */ - ENAMETOOLONG = _HURD_ERRNO (62), -#define ENAMETOOLONG _HURD_ERRNO (62)/* File name too long */ - EHOSTDOWN = _HURD_ERRNO (63), -#define EHOSTDOWN _HURD_ERRNO (63)/* Host is down */ - EHOSTUNREACH = _HURD_ERRNO (64), -#define EHOSTUNREACH _HURD_ERRNO (64)/* No route to host */ - ENOTEMPTY = _HURD_ERRNO (65), -#define ENOTEMPTY _HURD_ERRNO (65)/* Directory not empty */ - EUSERS = _HURD_ERRNO (66), -#define EUSERS _HURD_ERRNO (66)/* Too many users */ - EDQUOT = _HURD_ERRNO (67), -#define EDQUOT _HURD_ERRNO (67)/* Disc quota exceeded */ - ESTALE = _HURD_ERRNO (68), -#define ESTALE _HURD_ERRNO (68)/* Stale NFS file handle */ - EREMOTE = _HURD_ERRNO (69), -#define EREMOTE _HURD_ERRNO (69)/* Too many levels of remote in path */ - ENOLCK = _HURD_ERRNO (70), -#define ENOLCK _HURD_ERRNO (70)/* No locks available */ - ENOSYS = _HURD_ERRNO (71), -#define ENOSYS _HURD_ERRNO (71)/* Function not implemented */ - EBACKGROUND = _HURD_ERRNO (72), -#define EBACKGROUND _HURD_ERRNO (72)/* Inappropriate operation for background process */ - ED = _HURD_ERRNO (73), -#define ED _HURD_ERRNO (73)/* ? */ - EGREGIOUS = _HURD_ERRNO (74), -#define EGREGIOUS _HURD_ERRNO (74)/* You really blew it this time */ - EIEIO = _HURD_ERRNO (75), -#define EIEIO _HURD_ERRNO (75)/* Computer bought the farm */ - EGRATUITOUS = _HURD_ERRNO (76), -#define EGRATUITOUS _HURD_ERRNO (76)/* Gratuitous error */ + ETOOMANYREFS = _HURD_ERRNO (59), +#define ETOOMANYREFS _HURD_ERRNO (59)/* Too many references: can't splice */ + ETIMEDOUT = _HURD_ERRNO (60), +#define ETIMEDOUT _HURD_ERRNO (60)/* Connection timed out */ + ECONNREFUSED = _HURD_ERRNO (61), +#define ECONNREFUSED _HURD_ERRNO (61)/* Connection refused */ + ELOOP = _HURD_ERRNO (62), +#define ELOOP _HURD_ERRNO (62)/* Too many levels of symbolic links */ + ENAMETOOLONG = _HURD_ERRNO (63), +#define ENAMETOOLONG _HURD_ERRNO (63)/* File name too long */ + EHOSTDOWN = _HURD_ERRNO (64), +#define EHOSTDOWN _HURD_ERRNO (64)/* Host is down */ + EHOSTUNREACH = _HURD_ERRNO (65), +#define EHOSTUNREACH _HURD_ERRNO (65)/* No route to host */ + ENOTEMPTY = _HURD_ERRNO (66), +#define ENOTEMPTY _HURD_ERRNO (66)/* Directory not empty */ + EPROCLIM = _HURD_ERRNO (67), +#define EPROCLIM _HURD_ERRNO (67)/* Too many processes */ + EUSERS = _HURD_ERRNO (68), +#define EUSERS _HURD_ERRNO (68)/* Too many users */ + EDQUOT = _HURD_ERRNO (69), +#define EDQUOT _HURD_ERRNO (69)/* Disc quota exceeded */ + ESTALE = _HURD_ERRNO (70), +#define ESTALE _HURD_ERRNO (70)/* Stale NFS file handle */ + EREMOTE = _HURD_ERRNO (71), +#define EREMOTE _HURD_ERRNO (71)/* Too many levels of remote in path */ + EBADRPC = _HURD_ERRNO (72), +#define EBADRPC _HURD_ERRNO (72)/* RPC struct is bad */ + ERPCMISMATCH = _HURD_ERRNO (73), +#define ERPCMISMATCH _HURD_ERRNO (73)/* RPC version wrong */ + EPROGUNAVAIL = _HURD_ERRNO (74), +#define EPROGUNAVAIL _HURD_ERRNO (74)/* RPC program not available */ + EPROGMISMATCH = _HURD_ERRNO (75), +#define EPROGMISMATCH _HURD_ERRNO (75)/* RPC program version wrong */ + EPROCUNAVAIL = _HURD_ERRNO (76), +#define EPROCUNAVAIL _HURD_ERRNO (76)/* RPC bad procedure for program */ + ENOLCK = _HURD_ERRNO (77), +#define ENOLCK _HURD_ERRNO (77)/* No locks available */ + EFTYPE = _HURD_ERRNO (79), +#define EFTYPE _HURD_ERRNO (79)/* Inappropriate file type or format */ + EAUTH = _HURD_ERRNO (80), +#define EAUTH _HURD_ERRNO (80)/* Authentication error */ + ENEEDAUTH = _HURD_ERRNO (81), +#define ENEEDAUTH _HURD_ERRNO (81)/* Need authenticator */ + ENOSYS = _HURD_ERRNO (78), +#define ENOSYS _HURD_ERRNO (78)/* Function not implemented */ + EBACKGROUND = _HURD_ERRNO (100), +#define EBACKGROUND _HURD_ERRNO (100)/* Inappropriate operation for background process */ + EDIED = _HURD_ERRNO (101), +#define EDIED _HURD_ERRNO (101)/* Translator died */ + ED = _HURD_ERRNO (102), +#define ED _HURD_ERRNO (102)/* ? */ + EGREGIOUS = _HURD_ERRNO (103), +#define EGREGIOUS _HURD_ERRNO (103)/* You really blew it this time */ + EIEIO = _HURD_ERRNO (104), +#define EIEIO _HURD_ERRNO (104)/* Computer bought the farm */ + EGRATUITOUS = _HURD_ERRNO (105), +#define EGRATUITOUS _HURD_ERRNO (105)/* Gratuitous error */ /* Errors from . */ EMACH_SEND_IN_PROGRESS = 0x10000001, @@ -245,7 +267,7 @@ }; -#define _HURD_ERRNOS 77 +#define _HURD_ERRNOS 106 /* User-visible type of error codes. It is ok to use `int' or `kern_return_t' for these, but with `error_t' the debugger prints diff -ruN glibc-1.08.1/sysdeps/mach/hurd/fchdir.c glibc-1.09/sysdeps/mach/hurd/fchdir.c --- glibc-1.08.1/sysdeps/mach/hurd/fchdir.c Tue Feb 1 22:14:20 1994 +++ glibc-1.09/sysdeps/mach/hurd/fchdir.c Tue Aug 30 04:59:13 1994 @@ -22,7 +22,6 @@ #include #include #include -#include /* Change the current directory to FD. */ int @@ -31,23 +30,16 @@ error_t err; file_t cwdir; - err = HURD_DPORT_USE - (fd, - ({ struct stat st; - cwdir = port; - err = __io_stat (cwdir, &st); - if (! err && ! S_ISDIR (st.st_mode)) - err = ENOTDIR; - if (! err) - __mach_port_mod_refs (__mach_task_self (), - cwdir, MACH_PORT_RIGHT_SEND, 1); - err; - })); + err = __USEPORT (CRDIR, + ({ file_t crdir = port; + HURD_DPORT_USE (fd, + __hurd_file_name_lookup (crdir, port, "", + 0, 0, &cwdir)); + })); if (err) return __hurd_fail (err); _hurd_port_set (&_hurd_ports[INIT_PORT_CWDIR], cwdir); - return 0; } diff -ruN glibc-1.08.1/sysdeps/mach/hurd/fcntlbits.h glibc-1.09/sysdeps/mach/hurd/fcntlbits.h --- glibc-1.08.1/sysdeps/mach/hurd/fcntlbits.h Mon Dec 13 19:08:25 1993 +++ glibc-1.09/sysdeps/mach/hurd/fcntlbits.h Tue Oct 25 03:52:43 1994 @@ -1,5 +1,5 @@ /* O_*, F_*, FD_* bit values for GNU. -Copyright (C) 1993 Free Software Foundation, Inc. +Copyright (C) 1993, 1994 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -23,9 +23,10 @@ /* File access modes. These are understood by io servers; they can be - passed in `dir_pathtrans', and are returned by `io_get_openmodes'. - Consequently they can be passed to `open', `hurd_path_lookup', and - `path_lookup'; and are returned by `fcntl' with the F_GETFL command. */ + passed in `dir_lookup', and are returned by `io_get_openmodes'. + Consequently they can be passed to `open', `hurd_file_name_lookup', and + `file_name_lookup'; and are returned by `fcntl' with the F_GETFL + command. */ /* In GNU, read and write are bits (unlike BSD). */ #ifdef __USE_GNU @@ -42,8 +43,8 @@ /* File name translation flags. These are understood by io servers; - they can be passed in `dir_pathtrans', and consequently to `open', - `hurd_path_lookup', and `path_lookup'. */ + they can be passed in `dir_lookup', and consequently to `open', + `hurd_file_name_lookup', and `file_name_lookup'. */ #define O_CREAT 0x0010 /* Create file if it doesn't exist. */ #define O_EXCL 0x0020 /* Fail if file already exists. */ @@ -53,29 +54,32 @@ #endif -/* File status flags. These are understood by io servers; they can be - passed in `dir_pathtrans' and set or fetched with `io_*_openmodes'. - Consequently they can be passed to `open', `hurd_path_lookup', - `path_lookup', and `fcntl' with the F_SETFL command; and are returned - by `fcntl' with the F_GETFL command. */ +/* I/O operating modes. These are understood by io servers; they can be + passed in `dir_lookup' and set or fetched with `io_*_openmodes'. + Consequently they can be passed to `open', `hurd_file_name_lookup', + `file_name_lookup', and `fcntl' with the F_SETFL command; and are + returned by `fcntl' with the F_GETFL command. */ #define O_APPEND 0x0100 /* Writes always append to the file. */ +#ifdef __USE_BSD #define O_ASYNC 0x0200 /* Send SIGIO to owner when data is ready. */ #define O_FSYNC 0x0400 /* Synchronous writes. */ #define O_SYNC O_FSYNC +#endif #ifdef __USE_GNU -#define O_NOATIME 0x0800 /* Don't set access time on read by owner. */ +#define O_NOATIME 0x0800 /* Don't set access time on read (owner). */ #endif /* The name O_NONBLOCK is unfortunately overloaded; it is both a file name - translation flag and a file status flag. O_NDELAY is the deprecated BSD - name for the same flag, overloaded in the same way. + translation flag and an I/O operating mode. O_NDELAY is the deprecated + BSD name for the same flag, overloaded in the same way. - When used in `dir_pathtrans' (and consequently `open', `hurd_path_lookup', - or `path_lookup'), O_NONBLOCK says the open should fail with EAGAIN - instead of blocking for any significant length of time (e.g., to wait for - DTR on a serial line). + When used in `dir_lookup' (and consequently `open', `hurd_file_name_lookup', + or `file_name_lookup'), O_NONBLOCK says the open should return immediately + instead of blocking for any significant length of time (e.g., to wait + for carrier detect on a serial line). It is also saved as an I/O + operating mode, and after open has the following meaning. When used in `io_*_openmodes' (and consequently `fcntl' with the F_SETFL command), the O_NONBLOCK flag means to do nonblocking i/o: any i/o @@ -84,7 +88,7 @@ #define O_NONBLOCK 0x0008 /* Non-blocking open or non-blocking I/O. */ #ifdef __USE_BSD -#define O_NDELAY O_NONBLOCK +#define O_NDELAY O_NONBLOCK /* Deprecated. */ #endif @@ -94,14 +98,14 @@ #endif -/* Open-time action flags. These are understood by `hurd_path_lookup' - and consequently by `open' and `path_lookup'. They are not preserved +/* Open-time action flags. These are understood by `hurd_file_name_lookup' + and consequently by `open' and `file_name_lookup'. They are not preserved once the file has been opened. */ #define O_TRUNC 0x00010000 /* Truncate file to zero length. */ #ifdef __USE_MISC #define O_SHLOCK 0x00020000 /* Open with shared file lock. */ -#define O_EXLOCK 0x00040000 /* Open with shared exclusive lock. */ +#define O_EXLOCK 0x00040000 /* Open with exclusive file lock. */ #endif diff -ruN glibc-1.08.1/sysdeps/mach/hurd/getcwd.c glibc-1.09/sysdeps/mach/hurd/getcwd.c --- glibc-1.08.1/sysdeps/mach/hurd/getcwd.c Thu May 19 18:08:19 1994 +++ glibc-1.09/sysdeps/mach/hurd/getcwd.c Tue Aug 30 08:55:11 1994 @@ -41,8 +41,8 @@ error_t err; dev_t rootdev, thisdev; ino_t rootino, thisino; - char *path; - register char *pathp; + char *file_name; + register char *file_namep; struct stat st; file_t parent; char *dirbuf = NULL; @@ -73,16 +73,16 @@ } if (buf != NULL) - path = buf; + file_name = buf; else { - path = malloc (size); - if (path == NULL) + file_name = malloc (size); + if (file_name == NULL) return NULL; } - pathp = path + size; - *--pathp = '\0'; + file_namep = file_name + size; + *--file_namep = '\0'; /* Get a port to our root directory and stat it. */ @@ -127,10 +127,10 @@ file_t newp; char *dirdata; unsigned int dirdatasize; - off_t dirpos; + int direntry, nentries; /* Look at the parent directory. */ - if (err = __hurd_path_lookup (crdir, parent, "..", O_READ, 0, &newp)) + if (err = __hurd_file_name_lookup (crdir, parent, "..", O_READ, 0, &newp)) goto lose; __mach_port_deallocate (__mach_task_self (), parent); parent = newp; @@ -143,17 +143,19 @@ mount_point = dotdev != thisdev; /* Search for the last directory. */ - dirpos = 0; + direntry = 0; dirdata = dirbuf; dirdatasize = dirbufsize; while (!(err = __dir_readdir (parent, &dirdata, &dirdatasize, - dirpos, &dirpos, st.st_blksize)) && - dirdatasize != 0) + direntry, -1, 0, &nentries)) && + nentries != 0) { /* We have a block of directory entries. */ unsigned int offset; + direntry += nentries; + if (dirdata != dirbuf) { /* The data was passed out of line, so our old buffer is no @@ -162,7 +164,7 @@ __vm_deallocate (__mach_task_self (), (vm_address_t) dirbuf, dirbufsize); dirbuf = dirdata; - dirbufsize = dirdatasize; + dirbufsize = round_page (dirdatasize); } /* Iterate over the returned directory entries, looking for one @@ -183,8 +185,8 @@ if (mount_point || d->d_ino == thisino) { file_t try; - if (err = __hurd_path_lookup (crdir, parent, d->d_name, - O_NOLINK, 0, &try)) + if (err = __hurd_file_name_lookup (crdir, parent, d->d_name, + O_NOLINK, 0, &try)) goto lose; err = __io_stat (try, &st); __mach_port_deallocate (__mach_task_self (), try); @@ -202,7 +204,7 @@ { /* Prepend the directory name just discovered. */ - if (pathp - path < d->d_namlen + 1) + if (file_namep - file_name < d->d_namlen + 1) { if (buf != NULL) { @@ -212,19 +214,19 @@ else { size *= 2; - buf = realloc (path, size); + buf = realloc (file_name, size); if (buf == NULL) { - free (path); + free (file_name); return NULL; } - pathp = &buf[pathp - path]; - path = buf; + file_namep = &buf[file_namep - file_name]; + file_name = buf; } } - pathp -= d->d_namlen; - (void) memcpy (pathp, d->d_name, d->d_namlen); - *--pathp = '/'; + file_namep -= d->d_namlen; + (void) memcpy (file_namep, d->d_name, d->d_namlen); + *--file_namep = '/'; } /* The next iteration will find the name of the directory we @@ -233,14 +235,14 @@ thisino = dotino; } - if (pathp == &path[size - 1]) + if (file_namep == &file_name[size - 1]) /* We found nothing and got all the way to the root. So the root is our current directory. */ - *--pathp = '/'; + *--file_namep = '/'; - memmove (path, pathp, path + size - pathp); + memmove (file_name, file_namep, file_name + size - file_namep); cleanup (); - return path; + return file_name; lose: cleanup (); diff -ruN glibc-1.08.1/sysdeps/mach/hurd/getprio.c glibc-1.09/sysdeps/mach/hurd/getprio.c --- glibc-1.08.1/sysdeps/mach/hurd/getprio.c Fri Dec 17 18:29:13 1993 +++ glibc-1.09/sysdeps/mach/hurd/getprio.c Fri Oct 28 15:08:24 1994 @@ -1,4 +1,4 @@ -/* Copyright (C) 1993 Free Software Foundation, Inc. +/* Copyright (C) 1994 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -16,18 +16,58 @@ not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include -#include -#include +#include #include +#include /* Return the highest priority of any process specified by WHICH and WHO (see ); if WHO is zero, the current process, process group, or user (as specified by WHO) is used. A lower priority number means higher priority. Priorities range from PRIO_MIN to PRIO_MAX. */ int -DEFUN(getpriority, (which, who), - enum __priority_which which AND int who) +getpriority (enum __priority_which which, int who) { - return ENOSYS; /* XXX */ + error_t err, onerr; + int maxpri = INT_MIN; + struct procinfo *pip; /* Just for sizeof. */ + int pibuf[sizeof *pip + 2 * sizeof (pip->threadinfos[0])], *pi = pibuf; + unsigned int pisize = sizeof pibuf / sizeof int; + + error_t getonepriority (pid_t pid, struct procinfo *pip) + { + if (pip) + onerr = 0; + else + { + int *oldpi = pi; + unsigned int oldpisize = pisize; + onerr = __USEPORT (PROC, __proc_getprocinfo (port, + pid, + &pi, &pisize)); + if (pi != oldpi && oldpi != pibuf) + /* Old buffer from last call was not reused; free it. */ + __vm_deallocate (__mach_task_self (), + (vm_address_t) oldpi, oldpisize * sizeof pi[0]); + pip = (struct procinfo *) pi; + } + if (!onerr && pip->taskinfo.base_priority > maxpri) + maxpri = pip->taskinfo.base_priority; + return 0; + } + + onerr = 0; + err = _hurd_priority_which_map (which, who, getonepriority); + + if (pi != pibuf) + __vm_deallocate (__mach_task_self (), + (vm_address_t) pi, pisize * sizeof pi[0]); + + if (!err && maxpri == INT_MIN) + /* No error, but no pids found. */ + err = onerr ?: ESRCH; + + if (err) + return __hurd_fail (err); + + return MACH_PRIORITY_TO_NICE (maxpri); } diff -ruN glibc-1.08.1/sysdeps/mach/hurd/i386/__sigret.c glibc-1.09/sysdeps/mach/hurd/i386/__sigret.c --- glibc-1.08.1/sysdeps/mach/hurd/i386/__sigret.c Sun May 1 16:22:32 1994 +++ glibc-1.09/sysdeps/mach/hurd/i386/__sigret.c Mon Aug 22 11:16:56 1994 @@ -16,29 +16,59 @@ not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +register int *sp asm ("%esp"); + #include #include #include +#include +#include int -__sigreturn (register const struct sigcontext *scp) +__sigreturn (struct sigcontext *scp) { struct hurd_sigstate *ss; - register int *usp asm ("%eax"); /* Force it into a register. */ mach_port_t *reply_port; - if (scp == NULL) + if (scp == NULL || (scp->sc_mask & _SIG_CANT_MASK)) { errno = EINVAL; return -1; } - ss = _hurd_self_sigstate (); + ss = _hurd_self_sigstate (); /* SS->lock now locked. */ + + /* Restore the set of blocked signals, and the intr_port slot. */ ss->blocked = scp->sc_mask; ss->intr_port = scp->sc_intr_port; + + /* Check for pending signals that were blocked by the old set. */ + if (ss->pending & ~ss->blocked) + { + /* There are pending signals that just became unblocked. Wake up the + signal thread to deliver them. But first, squirrel away SCP where + the signal thread will notice it if it runs another handler, and + arrange to have us called over again in the new reality. */ + ss->context = scp; + /* Clear the intr_port slot, since we are not in fact doing + an interruptible RPC right now. If SS->intr_port is not null, + the SCP context is doing an interruptible RPC, but the signal + thread will examine us while we are blocked in the sig_post RPC. */ + ss->intr_port = MACH_PORT_NULL; + __mutex_unlock (&ss->lock); + __sig_post (_hurd_msgport, 0, __mach_task_self ()); + /* If a pending signal was handled, sig_post never returned. */ + __mutex_lock (&ss->lock); + } + if (scp->sc_onstack) - ss->sigaltstack.ss_flags &= ~SA_ONSTACK; /* XXX threadvars */ - __mutex_unlock (&ss->lock); + { + ss->sigaltstack.ss_flags &= ~SA_ONSTACK; /* XXX threadvars */ + /* XXX cannot unlock until off sigstack */ + abort (); + } + else + __mutex_unlock (&ss->lock); /* Destroy the MiG reply port used by the signal handler, and restore the reply port in use by the thread when interrupted. */ @@ -48,34 +78,45 @@ __mach_port_destroy (__mach_task_self (), *reply_port); *reply_port = scp->sc_reply_port; - /* Push the flags and registers onto the stack we're returning to. */ - usp = (int *) scp->sc_uesp; + if (scp->sc_fpused) + { + /* XXX should restore FPU state here XXX roland needs 387 manual */ + abort (); + } - /* The last thing popped will be the PC being restored, so push it first. */ - *--usp = scp->sc_eip; - *--usp = scp->sc_efl; /* Second to last, processor flags. */ - - /* Segment registers??? XXX */ - - /* Now push the general registers in the reverse of the order they will - be popped off by the `popa' instruction. The instruction passes over - a word corresponding to %esp, but does not use the value. */ - *--usp = scp->sc_eax; - *--usp = scp->sc_ecx; - *--usp = scp->sc_edx; - *--usp = scp->sc_ebx; - *--usp = 0; /* Ignored by `popa'. */ - *--usp = scp->sc_ebp; - *--usp = scp->sc_esi; - *--usp = scp->sc_edi; - - asm volatile - ("movl %0, %%esp\n" /* Switch to the target stack. */ - "popa\n" /* Pop all the general registers. */ - "popf\n" /* Pop the flags. */ - "ret\n" /* Pop the target PC and jump to it. */ - "hlt" : : /* Firewall. */ - "g" (usp)); + { + /* There are convenient instructions to pop state off the stack, so we + copy the registers onto the user's stack, switch there, pop and + return. */ + + int *usp = (int *) scp->sc_uesp; + + *--usp = scp->sc_eip; + *--usp = scp->sc_efl; + memcpy (usp -= 12, &scp->sc_i386_thread_state, 12 * sizeof (int)); + + sp = usp; + +#define A(line) asm volatile (#line) + /* The members in the sigcontext are arranged in this order + so we can pop them easily. */ + + /* Pop the segment registers (except %cs and %ss, done last). */ + A (popl %gs); + A (popl %fs); + A (popl %es); + A (popl %ds); + /* Pop the general registers. */ + A (popa); + /* Pop the processor flags. */ + A (popf); + /* Return to the saved PC. */ + A (ret); + + /* Firewall. */ + A (hlt); +#undef A + } /* NOTREACHED */ return -1; diff -ruN glibc-1.08.1/sysdeps/mach/hurd/i386/exc2signal.c glibc-1.09/sysdeps/mach/hurd/i386/exc2signal.c --- glibc-1.08.1/sysdeps/mach/hurd/i386/exc2signal.c Thu May 5 13:43:04 1994 +++ glibc-1.09/sysdeps/mach/hurd/i386/exc2signal.c Mon Aug 8 18:54:04 1994 @@ -26,8 +26,10 @@ void _hurd_exception2signal (int exception, int code, int subcode, - int *signo, int *sigcode) + int *signo, int *sigcode, int *error) { + *error = 0; + switch (exception) { default: @@ -41,6 +43,7 @@ else *signo = SIGBUS; *sigcode = subcode; + *error = code; break; case EXC_BAD_INSTRUCTION: diff -ruN glibc-1.08.1/sysdeps/mach/hurd/i386/init-fault.c glibc-1.09/sysdeps/mach/hurd/i386/init-fault.c --- glibc-1.08.1/sysdeps/mach/hurd/i386/init-fault.c Thu Feb 3 03:43:22 1994 +++ glibc-1.09/sysdeps/mach/hurd/i386/init-fault.c Wed Dec 31 19:00:00 1969 @@ -1,41 +0,0 @@ -/* Set up a thread_state for proc_handle_exceptions. i386 version. -Copyright (C) 1994 Free Software Foundation, Inc. -This file is part of the GNU C Library. - -The GNU C Library is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. - -The GNU C Library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with the GNU C Library; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA. */ - -#include -#include -#include -#include - -extern jmp_buf _hurd_sigthread_fault_env; - -static char fault_stack[32]; -static volatile void -faulted (void) -{ - __longjmp (_hurd_sigthread_fault_env, 1); -} - -void -_hurd_initialize_fault_recovery_state (void *state) -{ - struct i386_thread_state *ts = state; - memset (ts, 0, sizeof (*ts)); - ts->uesp = (int) &fault_stack[sizeof (fault_stack)]; - ts->eip = (int) &faulted; -} diff -ruN glibc-1.08.1/sysdeps/mach/hurd/i386/longjmp-ts.c glibc-1.09/sysdeps/mach/hurd/i386/longjmp-ts.c --- glibc-1.08.1/sysdeps/mach/hurd/i386/longjmp-ts.c Thu Feb 3 03:38:43 1994 +++ glibc-1.09/sysdeps/mach/hurd/i386/longjmp-ts.c Mon Jul 18 18:11:00 1994 @@ -33,6 +33,7 @@ ts->esi = env[0].__si; ts->edi = env[0].__di; ts->ebp = (int) env[0].__bp; - ts->esp = (int) env[0].__sp; + ts->uesp = (int) env[0].__sp; + ts->eip = (int) env[0].__pc; ts->eax = val == 0 ? 1 : val; } diff -ruN glibc-1.08.1/sysdeps/mach/hurd/i386/msging-p.c glibc-1.09/sysdeps/mach/hurd/i386/msging-p.c --- glibc-1.08.1/sysdeps/mach/hurd/i386/msging-p.c Thu Apr 21 18:55:17 1994 +++ glibc-1.09/sysdeps/mach/hurd/i386/msging-p.c Wed Dec 31 19:00:00 1969 @@ -1,67 +0,0 @@ -/* Test a Mach thread_state for being in a mach_msg syscall. i386 version. -Copyright (C) 1994 Free Software Foundation, Inc. -This file is part of the GNU C Library. - -The GNU C Library is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. - -The GNU C Library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with the GNU C Library; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA. */ - -#include -#include -#include -#include - -extern jmp_buf _hurd_sigthread_fault_env; - -/* Return nonzero if STATE indicates a thread - that is blocked in a mach_msg system call. */ -int -_hurd_thread_state_msging_p (void *state, mach_port_t *port) -{ - if (setjmp (_hurd_sigthread_fault_env)) - /* The PC or SP pointed at bogus memory. */ - return 0; - else - { - struct i386_thread_state *ts = state; - const unsigned char *pc = (void *) ts->eip; - static const unsigned char lcall[] = { 0x9a, 0, 0, 0, 0, 7, 0 }; - if (ts->eax == -25 && /* mach_msg_trap XXX */ - !memcmp (pc - sizeof (lcall), lcall, sizeof (lcall))) - { - /* We are blocked in a mach_msg_trap system call. - Examine the parameters to find the receive right. */ - struct mach_msg_trap_args - { - /* This is the order of arguments to mach_msg_trap. */ - mach_msg_header_t *msg; - mach_msg_option_t option; - mach_msg_size_t send_size; - mach_msg_size_t rcv_size; - mach_port_t rcv_name; - mach_msg_timeout_t timeout; - mach_port_t notify; - } *args; - /* The arguments begin after one word at the top of stack - that is the address mach_msg_trap will return to. */ - args = (void *) &((int **) ts->uesp)[1]; - /* Now ARGS points just past the end of the arguments; - decrement it to point at the beginning of the arguments. */ - --args; - *port = args->rcv_name; - return 1; - } - return 0; - } -} diff -ruN glibc-1.08.1/sysdeps/mach/hurd/i386/sigcontext.h glibc-1.09/sysdeps/mach/hurd/i386/sigcontext.h --- glibc-1.08.1/sysdeps/mach/hurd/i386/sigcontext.h Sun May 1 16:03:09 1994 +++ glibc-1.09/sysdeps/mach/hurd/i386/sigcontext.h Thu Sep 15 16:47:30 1994 @@ -19,50 +19,68 @@ /* Signal handlers are actually called: void handler (int sig, int code, struct sigcontext *scp); */ +#include + /* State of this thread when the signal was taken. */ struct sigcontext -{ - /* The first four members are machine-independent. */ + { + /* These first members are machine-independent. */ - int sc_onstack; /* Nonzero if running on sigstack. */ - sigset_t sc_mask; /* Blocked signals to restore. */ + int sc_onstack; /* Nonzero if running on sigstack. */ + sigset_t sc_mask; /* Blocked signals to restore. */ - /* MiG reply port this thread is using. */ - unsigned int sc_reply_port; + /* MiG reply port this thread is using. */ + unsigned int sc_reply_port; - /* Port this thread is doing an interruptible RPC on. */ - unsigned int sc_intr_port; - - /* All following members are machine-dependent. */ - - /* Segment registers. */ - int sc_gs; - int sc_fs; - int sc_es; - int sc_ds; - int sc_ss; - - /* "General" registers. These members are in the order that the i386 - `pusha' and `popa' instructions use (`popa' ignores %esp). */ - int sc_edi; - int sc_esi; - int sc_ebp; - int sc_esp; /* Not used; sc_uesp is used instead. */ - int sc_ebx; - int sc_edx; - int sc_ecx; - int sc_eax; + /* Port this thread is doing an interruptible RPC on. */ + unsigned int sc_intr_port; + + /* Error code associated with this signal (interpreted as `error_t'). */ + int sc_error; + + /* All following members are machine-dependent. The rest of this + structure is written to be laid out identically to: + { + struct i386_thread_state basic; + struct i386_float_state fpu; + } + trampoline.c knows this, so it must be changed if this changes. */ + +#define sc_i386_thread_state sc_gs /* Beginning of correspondence. */ + /* Segment registers. */ + int sc_gs; + int sc_fs; + int sc_es; + int sc_ds; - int sc_trapno; /* Not used. */ - int sc_err; /* Not used. */ + /* "General" registers. These members are in the order that the i386 + `pusha' and `popa' instructions use (`popa' ignores %esp). */ + int sc_edi; + int sc_esi; + int sc_ebp; + int sc_esp; /* Not used; sc_uesp is used instead. */ + int sc_ebx; + int sc_edx; + int sc_ecx; + int sc_eax; - int sc_eip; /* Instruction pointer. */ - - int sc_cs; /* Not used. */ + int sc_eip; /* Instruction pointer. */ + int sc_cs; /* Code segment register. */ - int sc_efl; /* Processor flags. */ - int sc_uesp; /* This stack pointer is used. */ -}; + int sc_efl; /* Processor flags. */ + + int sc_uesp; /* This stack pointer is used. */ + int sc_ss; /* Stack segment register. */ + + /* Following mimics struct i386_float_state. Structures and symbolic + values can be found in . */ +#define sc_i386_float_state sc_fpkind + int sc_fpkind; /* FP_NO, FP_387, etc. */ + int sc_fpused; /* If zero, ignore rest of float state. */ + struct i386_fp_save sc_fpsave; + struct i386_fp_regs sc_fpregs; + int sc_fpexcsr; /* FPSR including exception bits. */ + }; /* Codes for SIGFPE. */ diff -ruN glibc-1.08.1/sysdeps/mach/hurd/i386/trampoline.c glibc-1.09/sysdeps/mach/hurd/i386/trampoline.c --- glibc-1.08.1/sysdeps/mach/hurd/i386/trampoline.c Sun May 1 17:08:05 1994 +++ glibc-1.09/sysdeps/mach/hurd/i386/trampoline.c Sun Sep 4 15:30:31 1994 @@ -18,84 +18,254 @@ Cambridge, MA 02139, USA. */ #include -#include - -static void -trampoline (void (*handler) (int signo, int sigcode, struct sigcontext *scp), - int signo, int sigcode, struct sigcontext *scp) -{ - (*handler) (signo, sigcode, scp); - (void) __sigreturn (scp); /* Does not return. */ - while (1) - asm volatile ("hlt"); /* Firewall. */ -} +#include "thread_state.h" +#include +#include +#include "hurdfault.h" + + +struct mach_msg_trap_args + { + void *retaddr; /* Address mach_msg_trap will return to. */ + /* This is the order of arguments to mach_msg_trap. */ + mach_msg_header_t *msg; + mach_msg_option_t option; + mach_msg_size_t send_size; + mach_msg_size_t rcv_size; + mach_port_t rcv_name; + mach_msg_timeout_t timeout; + mach_port_t notify; + }; struct sigcontext * -_hurd_setup_sighandler (int flags, - __sighandler_t handler, - struct sigaltstack *sigaltstack, +_hurd_setup_sighandler (struct hurd_sigstate *ss, __sighandler_t handler, int signo, int sigcode, - void *state) + volatile int rpc_wait, + struct machine_thread_all_state *state) { - struct i386_thread_state *ts; - void *sigsp; + __label__ trampoline, rpc_wait_trampoline; + void *volatile sigsp; struct sigcontext *scp; struct { - void *retaddr; /* Never used. */ - __sighandler_t handler; int signo; int sigcode; struct sigcontext *scp; /* Points to ctx, below. */ + struct sigcontext *return_scp; /* Same; arg to sigreturn. */ struct sigcontext ctx; } *stackframe; - ts = state; + if (ss->context) + { + /* We have a previous sigcontext that sigreturn was about + to restore when another signal arrived. We will just base + our setup on that. */ + if (_hurdsig_catch_fault (SIGSEGV)) + assert (_hurdsig_fault_sigcode >= (int) ss->context && + _hurdsig_fault_sigcode < (int) (ss->context + 1)); + else + { + memcpy (&state->basic, &ss->context->sc_i386_thread_state, + sizeof (state->basic)); + memcpy (&state->fpu, &ss->context->sc_i386_float_state, + sizeof (state->fpu)); + state->set = (1 << i386_THREAD_STATE) | (1 << i386_FLOAT_STATE); + assert (! rpc_wait); + /* The intr_port slot was cleared before sigreturn sent us the + sig_post that made us notice this pending signal, so + _hurd_internal_post_signal wouldn't do interrupt_operation. + After we return, our caller will set SCP->sc_intr_port (in the + new context) from SS->intr_port and clear SS->intr_port. Now + that we are restoring this old context recorded by sigreturn, + we want to restore its intr_port too; so store it in + SS->intr_port now, so it will end up in SCP->sc_intr_port + later. */ + ss->intr_port = ss->context->sc_intr_port; + } + /* If the sigreturn context was bogus, just ignore it. */ + ss->context = NULL; + } + else if (! machine_get_basic_state (ss->thread, state)) + return NULL; - if ((flags & SA_ONSTACK) && - !(sigaltstack->ss_flags & (SA_DISABLE|SA_ONSTACK))) + if ((ss->actions[signo].sa_flags & SA_ONSTACK) && + !(ss->sigaltstack.ss_flags & (SA_DISABLE|SA_ONSTACK))) { - sigsp = sigaltstack->ss_sp + sigaltstack->ss_size; - sigaltstack->ss_flags |= SA_ONSTACK; + sigsp = ss->sigaltstack.ss_sp + ss->sigaltstack.ss_size; + ss->sigaltstack.ss_flags |= SA_ONSTACK; /* XXX need to set up base of new stack for per-thread variables, cthreads. */ } else - sigsp = (char *) ts->uesp; + sigsp = (char *) state->basic.uesp; /* Push the arguments to call `trampoline' on the stack. */ sigsp -= sizeof (*stackframe); stackframe = sigsp; - stackframe->handler = handler; - stackframe->signo = signo; - stackframe->sigcode = sigcode; - stackframe->scp = scp = &stackframe->ctx; - - /* Set up the sigcontext from the current state of the thread. */ - - scp->sc_onstack = sigaltstack->ss_flags & SA_ONSTACK ? 1 : 0; - - scp->sc_gs = ts->gs; - scp->sc_fs = ts->fs; - scp->sc_es = ts->es; - scp->sc_ds = ts->ds; - - scp->sc_edi = ts->edi; - scp->sc_esi = ts->esi; - scp->sc_ebp = ts->ebp; - - scp->sc_ebx = ts->ebx; - scp->sc_edx = ts->edx; - scp->sc_ecx = ts->ecx; - scp->sc_eax = ts->eax; - - scp->sc_eip = ts->eip; - scp->sc_uesp = ts->uesp; - scp->sc_efl = ts->efl; - - /* Modify the thread state to call `trampoline' on the new stack. */ - ts->uesp = (int) sigsp; - ts->eip = (int) &trampoline; + + if (_hurdsig_catch_fault (SIGSEGV)) + { + assert (_hurdsig_fault_sigcode >= (int) stackframe && + _hurdsig_fault_sigcode <= (int) (stackframe + 1)); + /* We got a fault trying to write the stack frame. + We cannot set up the signal handler. + Returning NULL tells our caller, who will nuke us with a SIGILL. */ + return NULL; + } + else + { + int ok; + + /* Set up the arguments for the signal handler. */ + stackframe->signo = signo; + stackframe->sigcode = sigcode; + stackframe->scp = stackframe->return_scp = scp = &stackframe->ctx; + + /* Set up the sigcontext from the current state of the thread. */ + + scp->sc_onstack = ss->sigaltstack.ss_flags & SA_ONSTACK ? 1 : 0; + + /* struct sigcontext is laid out so that starting at sc_gs mimics a + struct i386_thread_state. */ + memcpy (&scp->sc_i386_thread_state, + &state->basic, sizeof (state->basic)); + + /* struct sigcontext is laid out so that starting at sc_fpkind mimics + a struct i386_float_state. */ + ok = machine_get_state (ss->thread, state, i386_FLOAT_STATE, + &state->fpu, &scp->sc_i386_float_state, + sizeof (state->fpu)); + + _hurdsig_end_catch_fault (); + + if (! ok) + return NULL; + } + + /* Modify the thread state to call the trampoline code on the new stack. */ + if (rpc_wait) + { + /* The signalee thread was blocked in a mach_msg_trap system call, + still waiting for a reply. We will have it run the special + trampoline code which retries the message receive before running + the signal handler. + + To do this we change the OPTION argument on its stack to enable only + message reception, since the request message has already been + sent. */ + + struct mach_msg_trap_args *args = (void *) state->basic.uesp; + + if (_hurdsig_catch_fault (SIGSEGV)) + { + assert (_hurdsig_fault_sigcode >= (int) args && + _hurdsig_fault_sigcode < (int) (args + 1)); + /* Faulted accessing ARGS. Bomb. */ + return NULL; + } + + assert (args->option & MACH_RCV_MSG); + /* Disable the message-send, since it has already completed. The + calls we retry need only wait to receive the reply message. */ + args->option &= ~MACH_SEND_MSG; + + _hurdsig_end_catch_fault (); + + state->basic.eip = (int) &&rpc_wait_trampoline; + /* The reply-receiving trampoline code runs initially on the original + user stack. We pass it the signal stack pointer in %ebx. */ + state->basic.ebx = (int) sigsp; + /* After doing the message receive, the trampoline code will need to + update the %eax value to be restored by sigreturn. To simplify + the assembly code, we pass the address of its slot in SCP to the + trampoline code in %ecx. */ + state->basic.ecx = (int) &scp->sc_eax; + } + else + { + state->basic.eip = (int) &&trampoline; + state->basic.uesp = (int) sigsp; + } + /* We pass the handler function to the trampoline code in %edx. */ + state->basic.edx = (int) handler; return scp; + + /* The trampoline code follows. This is not actually executed as part of + this function, it is just convenient to write it that way. */ + + rpc_wait_trampoline: + /* This is the entry point when we have an RPC reply message to receive + before running the handler. The MACH_MSG_SEND bit has already been + cleared in the OPTION argument on our stack. The interrupted user + stack pointer has not been changed, so the system call can find its + arguments; the signal stack pointer is in %ebx. For our convenience, + %ecx points to the sc_eax member of the sigcontext. */ + asm volatile + (/* Retry the interrupted mach_msg system call. */ + "movl $-25, %eax\n" /* mach_msg_trap */ + "lcall $7, $0\n" + /* When the sigcontext was saved, %eax was MACH_RCV_INTERRUPTED. But + now the message receive has completed and the original caller of + the RPC (i.e. the code running when the signal arrived) needs to + see the final return value of the message receive in %eax. So + store the new %eax value into the sc_eax member of the sigcontext + (whose address is in %ecx to make this code simpler). */ + "movl %eax, (%ecx)\n" + /* Switch to the signal stack. */ + "movl %ebx, %esp\n"); + + trampoline: + /* Entry point for running the handler normally. The arguments to the + handler function are already on the top of the stack: + + 0(%esp) SIGNO + 4(%esp) SIGCODE + 8(%esp) SCP + */ + asm volatile + ("call %*%%edx\n" /* Call the handler function. */ + "addl $12, %%esp\n" /* Pop its args. */ + "call %P0\n" /* Call __sigreturn (SCP); never returns. */ + "hlt" /* Just in case. */ + : : "i" (&__sigreturn)); + + /* NOTREACHED */ + return NULL; +} + +/* STATE describes a thread that had intr_port set (meaning it was inside + HURD_EINTR_RPC), after it has been thread_abort'd. It it looks to have + just completed a mach_msg_trap system call that returned + MACH_RCV_INTERRUPTED, return nonzero and set *PORT to the receive right + being waited on. */ +int +_hurdsig_rcv_interrupted_p (struct machine_thread_all_state *state, + mach_port_t *port) +{ + static const unsigned char syscall[] = { 0x9a, 0, 0, 0, 0, 7, 0 }; + const unsigned char *volatile pc + = (void *) state->basic.eip - sizeof syscall; + + if (_hurdsig_catch_fault (SIGSEGV)) + assert (_hurdsig_fault_sigcode >= (int) pc && + _hurdsig_fault_sigcode < (int) pc + sizeof syscall); + else + { + int rcving = (state->basic.eax == MACH_RCV_INTERRUPTED && + !memcmp (pc, &syscall, sizeof syscall)); + _hurdsig_end_catch_fault (); + if (rcving) + { + /* We did just return from a mach_msg_trap system call + doing a message receive that was interrupted. + Examine the parameters to find the receive right. */ + struct mach_msg_trap_args *args = (void *) state->basic.uesp; + + *port = args->rcv_name; + return 1; + } + } + + return 0; } diff -ruN glibc-1.08.1/sysdeps/mach/hurd/libc-ldscript glibc-1.09/sysdeps/mach/hurd/libc-ldscript --- glibc-1.08.1/sysdeps/mach/hurd/libc-ldscript Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/mach/hurd/libc-ldscript Wed Sep 14 17:42:13 1994 @@ -0,0 +1,5 @@ +/* This linker script is installed as /lib/libc.a. + It makes -lc become just like -( -lcrt -lmachuser -lhurduser -). + */ + +GROUP ( libcrt.a libmachuser.a libhurduser.a ) diff -ruN glibc-1.08.1/sysdeps/mach/hurd/mig-reply.c glibc-1.09/sysdeps/mach/hurd/mig-reply.c --- glibc-1.08.1/sysdeps/mach/hurd/mig-reply.c Mon May 30 20:56:02 1994 +++ glibc-1.09/sysdeps/mach/hurd/mig-reply.c Thu Sep 29 18:28:58 1994 @@ -43,7 +43,7 @@ /* Called by MiG to deallocate the reply port. */ void -__mig_dealloc_reply_port (void) +__mig_dealloc_reply_port (mach_port_t arg) { mach_port_t port; @@ -53,6 +53,14 @@ reply_port = MACH_PORT_NULL; /* So the mod_refs RPC won't use it. */ __mach_port_mod_refs (__mach_task_self (), port, MACH_PORT_RIGHT_RECEIVE, -1); +} + +/* Called by mig interfaces when done with a port. Used to provide the + same interface as needed when a custom allocator is used. */ +void +__mig_put_reply_port(mach_port_t port) +{ + /* Do nothing. */ } diff -ruN glibc-1.08.1/sysdeps/mach/hurd/mips/__sigret.c glibc-1.09/sysdeps/mach/hurd/mips/__sigret.c --- glibc-1.08.1/sysdeps/mach/hurd/mips/__sigret.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/mach/hurd/mips/__sigret.c Fri Sep 2 22:31:38 1994 @@ -0,0 +1,166 @@ +/* Copyright (C) 1991, 1992, 1994 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include +#include + +int +__sigreturn (struct sigcontext *scp) +{ + struct hurd_sigstate *ss; + mach_port_t *reply_port; + + if (scp == NULL || (scp->sc_mask & _SIG_CANT_MASK)) + { + errno = EINVAL; + return -1; + } + + ss = _hurd_self_sigstate (); /* SS->lock now locked. */ + + /* Restore the set of blocked signals, and the intr_port slot. */ + ss->blocked = scp->sc_mask; + ss->intr_port = scp->sc_intr_port; + + /* Check for pending signals that were blocked by the old set. */ + if (ss->pending & ~ss->blocked) + { + /* There are pending signals that just became unblocked. Wake up the + signal thread to deliver them. But first, squirrel away SCP where + the signal thread will notice it if it runs another handler, and + arrange to have us called over again in the new reality. */ + ss->context = scp; + /* Clear the intr_port slot, since we are not in fact doing + an interruptible RPC right now. If SS->intr_port is not null, + the SCP context is doing an interruptible RPC, but the signal + thread will examine us while we are blocked in the sig_post RPC. */ + ss->intr_port = MACH_PORT_NULL; + __mutex_unlock (&ss->lock); + __sig_post (_hurd_msgport, 0, __mach_task_self ()); + /* If a pending signal was handled, sig_post never returned. */ + __mutex_lock (&ss->lock); + } + + if (scp->sc_onstack) + { + ss->sigaltstack.ss_flags &= ~SA_ONSTACK; /* XXX threadvars */ + /* XXX cannot unlock until off sigstack */ + abort (); + } + else + __mutex_unlock (&ss->lock); + + /* Destroy the MiG reply port used by the signal handler, and restore the + reply port in use by the thread when interrupted. */ + reply_port = + (mach_port_t *) __hurd_threadvar_location (_HURD_THREADVAR_MIG_REPLY); + if (*reply_port) + __mach_port_destroy (__mach_task_self (), *reply_port); + *reply_port = scp->sc_reply_port; + + if (scp->sc_coproc_used & SC_COPROC_USE_FPU) + { + /* Restore FPU state. */ +#define restore_fpr(n) \ + asm volatile ("l.d $f" #n ",%0" : : "m" (scp->sc_fpr[n])) + + /* Restore floating-point registers. */ + restore_fpr (0); + restore_fpr (2); + restore_fpr (4); + restore_fpr (6); + restore_fpr (8); + restore_fpr (10); + restore_fpr (12); + restore_fpr (14); + restore_fpr (16); + restore_fpr (18); + restore_fpr (20); + restore_fpr (22); + restore_fpr (24); + restore_fpr (26); + restore_fpr (28); + restore_fpr (30); + + /* Restore the floating-point control/status register ($f31). */ + asm volatile ("ctc1 %0,$f31" : : "r" (scp->sc_fpcsr)); + } + + /* Load all the registers from the sigcontext. */ +#define restore_gpr(n) \ + asm volatile ("lw $" #n ",%0" : : "m" (scpreg->sc_gpr[n - 1])) + + { + register const struct sigcontext *const scpreg asm ("$1") = scp; + register int *at asm ("$1"); + + /* First restore the multiplication result registers. The compiler + will use some temporary registers, so we do this before restoring + the general registers. */ + asm volatile ("mtlo %0" : : "r" (scpreg->sc_mdlo)); + asm volatile ("mthi %0" : : "r" (scpreg->sc_mdhi)); + + /* In the word after the saved PC, store the saved $1 value. */ + (&scpreg->sc_pc)[1] = scpreg->sc_gpr[0]; + + asm volatile (".set noreorder; .set noat;"); + + /* Restore the normal registers. */ + restore_gpr (2); + restore_gpr (3); + restore_gpr (4); + restore_gpr (5); + restore_gpr (6); + restore_gpr (7); + restore_gpr (8); + restore_gpr (9); + restore_gpr (10); + restore_gpr (11); + restore_gpr (12); + restore_gpr (13); + restore_gpr (14); + restore_gpr (15); + restore_gpr (16); + restore_gpr (17); + restore_gpr (18); + restore_gpr (19); + restore_gpr (20); + restore_gpr (21); + restore_gpr (22); + restore_gpr (23); + restore_gpr (24); + restore_gpr (25); + /* Registers 26-27 are kernel-only. */ + restore_gpr (28); + restore_gpr (29); /* Stack pointer. */ + restore_gpr (30); /* Frame pointer. */ + restore_gpr (31); /* Return address. */ + + at = &scpreg->sc_pc; + /* This is an emulated instruction that will find at the address in $1 + two words: the PC value to restore, and the $1 value to restore. */ + asm volatile (".word op_sigreturn"); + + asm volatile (".set reorder; .set at;"); + } + + /* NOTREACHED */ + return -1; +} diff -ruN glibc-1.08.1/sysdeps/mach/hurd/mips/exc2signal.c glibc-1.09/sysdeps/mach/hurd/mips/exc2signal.c --- glibc-1.08.1/sysdeps/mach/hurd/mips/exc2signal.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/mach/hurd/mips/exc2signal.c Mon Aug 8 18:54:38 1994 @@ -0,0 +1,98 @@ +/* Translate Mach exception codes into signal numbers. MIPS version. +Copyright (C) 1991, 1992, 1994 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include + +/* Translate the Mach exception codes, as received in an `exception_raise' RPC, + into a signal number and signal subcode. */ + +void +_hurd_exception2signal (int exception, int code, int subcode, + int *signo, int *sigcode, int *error) +{ + *error = 0; + + switch (exception) + { + default: + *signo = SIGIOT; + *sigcode = exception; + break; + + case EXC_BAD_ACCESS: + if (code == KERN_PROTECTION_FAILURE) + *signo = SIGSEGV; + else + *signo = SIGBUS; + *sigcode = subcode; + *error = code; + break; + + case EXC_BAD_INSTRUCTION: + *signo = SIGILL; + if (code == EXC_MIPS_II) + *sigcode = code; + else + *sigcode = 0; + break; + + case EXC_ARITHMETIC: + switch (code) + { + case EXC_MIPS_OV: /* integer overflow */ + *signo = SIGFPE; + *sigcode = EXC_MIPS_FLT_OVERFLOW; + break; + + default: + *signo = SIGFPE; + *sigcode = 0; + break; + + case EXC_MIPS_INT: + /* Subcode is the fp_status word saved by the hardware. + Give an error code corresponding to the first bit set. */ + if (subcode == EXC_MIPS_FLT_UNIMP) + *signo = SIGILL; + else + *signo = SIGFPE; + *sigcode = subcode; + break; + } + break; + + case EXC_EMULATION: + /* 3.0 doesn't give this one, why, I don't know. */ + *signo = SIGEMT; + *sigcode = 0; + break; + + case EXC_SOFTWARE: + *signo = SIGEMT; + *sigcode = 0; + break; + + case EXC_BREAKPOINT: + *signo = SIGTRAP; + *sigcode = code; + break; + } +} diff -ruN glibc-1.08.1/sysdeps/mach/hurd/mips/longjmp-ctx.c glibc-1.09/sysdeps/mach/hurd/mips/longjmp-ctx.c --- glibc-1.08.1/sysdeps/mach/hurd/mips/longjmp-ctx.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/mach/hurd/mips/longjmp-ctx.c Mon Jul 18 18:12:04 1994 @@ -0,0 +1,41 @@ +/* Perform a `longjmp' on a `struct sigcontext'. MIPS version. +Copyright (C) 1994 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include + +void +_hurd_longjmp_sigcontext (struct sigcontext *scp, jmp_buf env, int retval) +{ + scp->sc_gpr[16] = env[0].__regs[0]; + scp->sc_gpr[17] = env[0].__regs[1]; + scp->sc_gpr[18] = env[0].__regs[2]; + scp->sc_gpr[19] = env[0].__regs[3]; + scp->sc_gpr[20] = env[0].__regs[4]; + scp->sc_gpr[21] = env[0].__regs[5]; + scp->sc_gpr[22] = env[0].__regs[6]; + scp->sc_gpr[23] = env[0].__regs[7]; + + scp->sc_gpr[28] = (int) env[0].__gp; + scp->sc_fp = (int) env[0].__fp; + scp->sc_sp = (int) env[0].__sp; + scp->sc_pc = (int) env[0].__pc; + scp->sc_gpr[2] = retval ?: 1; +} diff -ruN glibc-1.08.1/sysdeps/mach/hurd/mips/longjmp-ts.c glibc-1.09/sysdeps/mach/hurd/mips/longjmp-ts.c --- glibc-1.08.1/sysdeps/mach/hurd/mips/longjmp-ts.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/mach/hurd/mips/longjmp-ts.c Mon Jul 18 18:12:04 1994 @@ -0,0 +1,45 @@ +/* Perform a `longjmp' on a Mach thread_state. MIPS version. +Copyright (C) 1991, 1994 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include + + +/* Set up STATE to do the equivalent of `longjmp (ENV, VAL);'. */ + +void +_hurd_longjmp_thread_state (void *state, jmp_buf env, int val) +{ + struct mips_thread_state *ts = state; + + ts->r16 = env[0].__regs[0]; + ts->r17 = env[0].__regs[1]; + ts->r18 = env[0].__regs[2]; + ts->r19 = env[0].__regs[3]; + ts->r20 = env[0].__regs[4]; + ts->r21 = env[0].__regs[5]; + ts->r22 = env[0].__regs[6]; + ts->r23 = env[0].__regs[7]; + ts->r28 = (int) env[0].__gp; + ts->r29 = (int) env[0].__sp; + ts->r30 = (int) env[0].__fp; + ts->pc = (int) env[0].__pc; + ts->r2 = val ?: 1; +} diff -ruN glibc-1.08.1/sysdeps/mach/hurd/mips/sigcontext.h glibc-1.09/sysdeps/mach/hurd/mips/sigcontext.h --- glibc-1.08.1/sysdeps/mach/hurd/mips/sigcontext.h Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/mach/hurd/mips/sigcontext.h Tue Aug 16 01:57:37 1994 @@ -0,0 +1,71 @@ +/* Copyright (C) 1994 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +/* Signal handlers are actually called: + void handler (int sig, int code, struct sigcontext *scp); */ + +/* State of this thread when the signal was taken. */ +struct sigcontext + { + /* These first members are machine-independent. */ + + int sc_onstack; /* Nonzero if running on sigstack. */ + sigset_t sc_mask; /* Blocked signals to restore. */ + + /* MiG reply port this thread is using. */ + unsigned int sc_reply_port; + + /* Port this thread is doing an interruptible RPC on. */ + unsigned int sc_intr_port; + + /* Error code associated with this signal (interpreted as `error_t'). */ + int sc_error; + + /* All following members are machine-dependent. The rest of this + structure is written to be laid out identically to: + { + struct mips_thread_state ts; + struct mips_exc_state es; + struct mips_float_state fs; + } + trampoline.c knows this, so it must be changed if this changes. */ +#define sc_mips_thread_state sc_gpr /* Beginning of correspondence. */ + int sc_gpr[31]; /* "General" registers; [0] is r1. */ + int sc_mdlo, sc_mdhi; /* Low and high multiplication results. */ + int sc_pc; /* Instruction pointer. */ + + /* struct mips_exc_state */ +#define sc_mips_exc_state sc_cause + unsigned int sc_cause; /* Machine-level trap code. */ +#define SC_CAUSE_SST 0x00000044 + unsigned int sc_badvaddr; + unsigned int sc_coproc_used; /* Which coprocessors the thread has used. */ +#define SC_COPROC_USE_COP0 1 /* (by definition) */ +#define SC_COPROC_USE_COP1 2 /* FPA */ +#define SC_COPROC_USE_FPU SC_COPROC_USE_COP1 +#define SC_COPROC_USE_COP2 4 +#define SC_COPROC_USE_COP3 8 + + /* struct mips_float_state + This is only filled in if the SC_COPROC_USE_FPU bit + is set in sc_coproc_used. */ +#define sc_mips_float_state sc_fpr + int sc_fpr[32]; /* FP registers. */ + int sc_fpcsr; /* FPU status register. */ + int sc_fpeir; /* FP exception instruction register. */ + }; diff -ruN glibc-1.08.1/sysdeps/mach/hurd/mips/trampoline.c glibc-1.09/sysdeps/mach/hurd/mips/trampoline.c --- glibc-1.08.1/sysdeps/mach/hurd/mips/trampoline.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/mach/hurd/mips/trampoline.c Mon Aug 22 01:01:39 1994 @@ -0,0 +1,257 @@ +/* Set thread_state for sighandler, and sigcontext to recover. MIPS version. +Copyright (C) 1994 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include "thread_state.h" + + +struct mach_msg_trap_args + { + /* This is the order of arguments to mach_msg_trap. */ + mach_msg_header_t *msg; + mach_msg_option_t option; + mach_msg_size_t send_size; + mach_msg_size_t rcv_size; + mach_port_t rcv_name; + mach_msg_timeout_t timeout; + mach_port_t notify; + }; + + +struct sigcontext * +_hurd_setup_sighandler (struct hurd_sigstate *ss, __sighandler_t handler, + int signo, int sigcode, + int rpc_wait, + struct machine_thread_all_state *state) +{ + + __label__ trampoline, rpc_wait_trampoline; + void *sigsp; + struct sigcontext *scp; + + if (ss->context) + { + /* We have a previous sigcontext that sigreturn was about + to restore when another signal arrived. We will just base + our setup on that. */ + if (! setjmp (_hurd_sigthread_fault_env)) + { + memcpy (&state->basic, &ss->context->sc_mips_thread_state, + sizeof (state->basic)); + memcpy (&state->exc, &ss->context->sc_mips_exc_state, + sizeof (state->exc)); + state->set = (1 << MIPS_THREAD_STATE) | (1 << MIPS_EXC_STATE); + if (state->exc.coproc_state & SC_COPROC_USE_FPU) + { + memcpy (&state->fpu, &ss->context->sc_mips_loat_state, + sizeof (state->fpu)); + state->set |= (1 << MIPS_FLOAT_STATE); + } + assert (! rpc_wait); + /* The intr_port slot was cleared before sigreturn sent us the + sig_post that made us notice this pending signal, so + _hurd_internal_post_signal wouldn't do interrupt_operation. + After we return, our caller will set SCP->sc_intr_port (in the + new context) from SS->intr_port and clear SS->intr_port. Now + that we are restoring this old context recorded by sigreturn, + we want to restore its intr_port too; so store it in + SS->intr_port now, so it will end up in SCP->sc_intr_port + later. */ + ss->intr_port = ss->context->sc_intr_port; + } + /* If the sigreturn context was bogus, just ignore it. */ + ss->context = NULL; + } + else if (! machine_get_basic_state (ss->thread, state)) + return NULL; + + if ((ss->actions[signo].sa_flags & SA_ONSTACK) && + !(ss->sigaltstack.ss_flags & (SA_DISABLE|SA_ONSTACK))) + { + sigsp = ss->sigaltstack.ss_sp + ss->sigaltstack.ss_size; + ss->sigaltstack.ss_flags |= SA_ONSTACK; + /* XXX need to set up base of new stack for + per-thread variables, cthreads. */ + } + else + sigsp = (char *) state->basic.r29; + + /* Set up the sigcontext structure on the stack. This is all the stack + needs, since the args are passed in registers (below). */ + sigsp -= sizeof (*scp); + scp = sigsp; + + if (! setjmp (_hurd_sigthread_fault_env)) + { + /* Set up the sigcontext from the current state of the thread. */ + + scp->sc_onstack = ss->sigaltstack.ss_flags & SA_ONSTACK ? 1 : 0; + + /* struct sigcontext is laid out so that starting at sc_gpr + mimics a struct mips_thread_state. */ + memcpy (&scp->sc_mips_thread_state, + &state->basic, sizeof (state->basic)); + + /* struct sigcontext is laid out so that starting at sc_cause + mimics a struct mips_exc_state. */ + if (! machine_get_state (ss->thread, state, MIPS_EXC_STATE, + &state->exc, &scp->sc_cause, + sizeof (state->exc))) + return NULL; + if ((scp->sc_coproc_used & SC_COPROC_USE_FPU) && + /* struct sigcontext is laid out so that starting at sc_fpr + mimics a struct mips_float_state. This state + is only meaningful if the coprocessor was used. */ + ! machine_get_state (ss->thread, state, MIPS_FLOAT_STATE, + &state->fpu, + &scp->sc_mips_float_state, sizeof (state->fpu))) + return NULL; + } + else + /* We got a fault trying to write the stack frame. + We cannot set up the signal handler. + Returning NULL tells our caller, who will nuke us with a SIGILL. */ + return NULL; + + /* Modify the thread state to call the trampoline code on the new stack. */ + if (rpc_wait) + { + /* The signalee thread was blocked in a mach_msg_trap system call, + still waiting for a reply. We will have it run the special + trampoline code which retries the message receive before running + the signal handler. + + To do this we change the OPTION argument in its registers to + enable only message reception, since the request message has + already been sent. */ + + /* The system call arguments are stored in consecutive registers + starting with a0 ($4). */ + struct mach_msg_trap_args *args = (void *) &state->basic.r4; + + assert (args->option & MACH_RCV_MSG); + /* Disable the message-send, since it has already completed. The + calls we retry need only wait to receive the reply message. */ + args->option &= ~MACH_SEND_MSG; + + state->basic.pc = (int) &&rpc_wait_trampoline; + state->basic.r29 = (int) sigsp; /* $29 is the stack pointer register. */ + /* After doing the message receive, the trampoline code will need to + update the v0 ($2) value to be restored by sigreturn. To simplify + the assembly code, we pass the address of its slot in SCP to the + trampoline code in v1 ($3). */ + state->basic.r3 = (int) &scp->sc_gpr[1]; + /* We must preserve the mach_msg_trap args in a0..t2 ($4..$10). + Pass the handler args to the trampoline code in s1..s3 ($17..$19). */ + state->basic.r17 = signo; + state->basic.r18 = sigcode; + state->basic.r19 = (int) scp; + } + else + { + state->basic.pc = (int) &&trampoline; + state->basic.r29 = (int) sigsp; + state->basic.r4 = signo; + state->basic.r5 = sigcode; + state->basic.r6 = (int) scp; + } + + /* We pass the handler function to the trampoline code in at ($1). */ + state->basic.r1 = (int) handler; + /* In the callee-saved register s0 ($16), we save the SCP value to pass + to __sigreturn after the handler returns. */ + state->basic.r16 = (int) scp; + + return scp; + + /* The trampoline code follows. This is not actually executed as part of + this function, it is just convenient to write it that way. */ + + rpc_wait_trampoline: + /* This is the entry point when we have an RPC reply message to receive + before running the handler. The MACH_MSG_SEND bit has already been + cleared in the OPTION argument in our registers. For our convenience, + $3 points to the sc_gpr[1] member of the sigcontext (saved v0 ($2)). */ + asm volatile + (".set noat; .set noreorder; .set nomacro\n" + /* Retry the interrupted mach_msg system call. */ + "li v0, -25\n" /* mach_msg_trap */ + "syscall\n" + /* When the sigcontext was saved, v0 was MACH_RCV_INTERRUPTED. But + now the message receive has completed and the original caller of + the RPC (i.e. the code running when the signal arrived) needs to + see the final return value of the message receive in v0. So + store the new v0 value into the sc_gpr[1] member of the sigcontext + (whose address is in v1 to make this code simpler). */ + "sw v0, (v1)\n" + /* Since the argument registers needed to have the mach_msg_trap + arguments, we've stored the arguments to the handler function + in registers s1..s3 ($17..$19). */ + "move a0, s1\n" + "move a1, s2\n" + "move a2, s3\n"); + + trampoline: + /* Entry point for running the handler normally. The arguments to the + handler function are already in the standard registers: + + a0 SIGNO + a1 SIGCODE + a2 SCP + */ + asm volatile + ("jal $1; nop\n" /* Call the handler function. */ + /* Call __sigreturn (SCP); this cannot return. */ + "j %0\n" + "move a0, s0" /* Set up arg from saved SCP in delay slot. */ + : : "i" (&__sigreturn)); + + /* NOTREACHED */ + asm volatile (".set reorder; .set at; .set macro"); + + return NULL; +} + +/* STATE describes a thread that had intr_port set (meaning it was inside + HURD_EINTR_RPC), after it has been thread_abort'd. It it looks to have + just completed a mach_msg_trap system call that returned + MACH_RCV_INTERRUPTED, return nonzero and set *PORT to the receive right + being waited on. */ +int +_hurdsig_rcv_interrupted_p (struct machine_thread_all_state *state, + mach_port_t *port) +{ + if (! setjmp (_hurd_sigthread_fault_env)) + { + const unsigned int *pc = (void *) state->basic.pc; + if (state->basic.r2 == MACH_RCV_INTERRUPTED && + pc[-1] == 0xc) /* syscall */ + { + /* We did just return from a mach_msg_trap system call + doing a message receive that was interrupted. + Examine the parameters to find the receive right. */ + struct mach_msg_trap_args *args = (void *) &state->basic.r4; + + *port = args->rcv_name; + return 1; + } + } + + return 0; +} diff -ruN glibc-1.08.1/sysdeps/mach/hurd/opendir.c glibc-1.09/sysdeps/mach/hurd/opendir.c --- glibc-1.08.1/sysdeps/mach/hurd/opendir.c Tue Dec 21 02:58:51 1993 +++ glibc-1.09/sysdeps/mach/hurd/opendir.c Tue Aug 30 04:58:41 1994 @@ -1,4 +1,4 @@ -/* Copyright (C) 1993 Free Software Foundation, Inc. +/* Copyright (C) 1993, 1994 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -35,35 +35,26 @@ DEFUN(opendir, (name), CONST char *name) { DIR *dirp; - struct stat statbuf; file_t port; - error_t err; - port = __path_lookup (name, O_RDONLY, 0); + port = __file_name_lookup (name, O_RDONLY, 0); if (port == MACH_PORT_NULL) return NULL; /* XXX this port should be deallocated on exec */ - if (err = __io_stat (port, &statbuf)) + dirp = (DIR *) malloc (sizeof (DIR)); + if (dirp == NULL) { - errno = err; - lose: __mach_port_deallocate (__mach_task_self (), port); return NULL; } - dirp = (DIR *) malloc (sizeof (DIR)); - if (dirp == NULL) - goto lose; - dirp->__port = port; - dirp->__filepos = 0; - dirp->__block_size = statbuf.st_blksize; - dirp->__data = NULL; + dirp->__data = dirp->__ptr = NULL; + dirp->__entry_data = dirp->__entry_ptr = 0; dirp->__allocation = 0; dirp->__size = 0; - dirp->__offset = 0; return dirp; } diff -ruN glibc-1.08.1/sysdeps/mach/hurd/readdir.c glibc-1.09/sysdeps/mach/hurd/readdir.c --- glibc-1.08.1/sysdeps/mach/hurd/readdir.c Tue Apr 12 00:10:00 1994 +++ glibc-1.09/sysdeps/mach/hurd/readdir.c Mon Jul 18 18:11:47 1994 @@ -41,23 +41,20 @@ do { - if (dirp->__offset >= dirp->__size) + if (dirp->__ptr - dirp->__data >= dirp->__size) { /* We've emptied out our buffer. Refill it. */ char *data = dirp->__data; - error_t err = __dir_readdir (dirp->__port, - &data, &dirp->__size, - dirp->__filepos, &dirp->__filepos, - dirp->__block_size); - if (err) - { - errno = err; - return NULL; - } + int nentries; + error_t err; - if (!dirp->__size) - return NULL; + if (err = __dir_readdir (dirp->__port, &data, &dirp->__size, + dirp->__entry_ptr, -1, 0, &nentries)) + return __hurd_fail (err), NULL; + + /* DATA now corresponds to entry index DIRP->__entry_ptr. */ + dirp->__entry_data = dirp->__entry_ptr; if (data != dirp->__data) { @@ -68,15 +65,23 @@ (vm_address_t) dirp->__data, dirp->__allocation); dirp->__data = data; - dirp->__allocation = dirp->__size; + dirp->__allocation = round_page (dirp->__size); } - /* Reset the offset into the buffer. */ - dirp->__offset = 0; + /* Reset the pointer into the buffer. */ + dirp->__ptr = dirp->__data; + + if (nentries == 0) + /* End of file. */ + return NULL; + + /* We trust the filesystem to return correct data and so we + ignore NENTRIES. */ } - dp = (struct dirent *) &dirp->__data[dirp->__offset]; - dirp->__offset += dp->d_reclen; + dp = (struct dirent *) dirp->__ptr; + dirp->__ptr += dp->d_reclen; + ++dirp->__entry_ptr; /* Loop to ignore deleted files. */ } while (dp->d_fileno == 0); diff -ruN glibc-1.08.1/sysdeps/mach/hurd/recv.c glibc-1.09/sysdeps/mach/hurd/recv.c --- glibc-1.08.1/sysdeps/mach/hurd/recv.c Tue Apr 26 20:14:01 1994 +++ glibc-1.09/sysdeps/mach/hurd/recv.c Mon Jul 18 18:11:48 1994 @@ -39,7 +39,7 @@ unsigned int clen = 0; if (err = HURD_DPORT_USE (fd, __socket_recv (port, &addrport, - flags, bufp, &nread, + flags, &bufp, &nread, &ports, &nports, &cdata, &clen, &flags, diff -ruN glibc-1.08.1/sysdeps/mach/hurd/recvfrom.c glibc-1.09/sysdeps/mach/hurd/recvfrom.c --- glibc-1.08.1/sysdeps/mach/hurd/recvfrom.c Tue Apr 26 20:18:05 1994 +++ glibc-1.09/sysdeps/mach/hurd/recvfrom.c Mon Jul 18 18:11:48 1994 @@ -41,7 +41,7 @@ unsigned int clen = 0; if (err = HURD_DPORT_USE (fd, __socket_recv (port, &addrport, - flags, bufp, &nread, + flags, &bufp, &nread, &ports, &nports, &cdata, &clen, &flags, diff -ruN glibc-1.08.1/sysdeps/mach/hurd/rename.c glibc-1.09/sysdeps/mach/hurd/rename.c --- glibc-1.08.1/sysdeps/mach/hurd/rename.c Thu Jan 6 01:32:22 1994 +++ glibc-1.09/sysdeps/mach/hurd/rename.c Tue Aug 30 04:55:12 1994 @@ -28,10 +28,10 @@ file_t olddir, newdir; const char *oldname, *newname; - olddir = __path_split (old, (char **) &oldname); + olddir = __file_name_split (old, (char **) &oldname); if (olddir == MACH_PORT_NULL) return -1; - newdir = __path_split (new, (char **) &newname); + newdir = __file_name_split (new, (char **) &newname); if (newdir == MACH_PORT_NULL) { __mach_port_deallocate (__mach_task_self (), olddir); diff -ruN glibc-1.08.1/sysdeps/mach/hurd/seekdir.c glibc-1.09/sysdeps/mach/hurd/seekdir.c --- glibc-1.08.1/sysdeps/mach/hurd/seekdir.c Wed Apr 20 17:43:45 1994 +++ glibc-1.09/sysdeps/mach/hurd/seekdir.c Mon Jul 18 18:11:49 1994 @@ -26,13 +26,10 @@ void DEFUN(seekdir, (dirp, pos), DIR *dirp AND __off_t pos) { - if (pos == dirp->__filepos + dirp->__offset) - return; - - dirp->__filepos = pos; - dirp->__offset = 0; - - /* The block we have read is no longer appropriate; it corresponds to - a different position in the file than our offset now indicates. */ + /* Change our entry index pointer to POS and discard any data already + read. The next `readdir' call will notice the empty block and read + anew from the location in DIRP->__entry_ptr and reset the other state + variables. */ + dirp->__entry_ptr = pos; dirp->__size = 0; } diff -ruN glibc-1.08.1/sysdeps/mach/hurd/send.c glibc-1.09/sysdeps/mach/hurd/send.c --- glibc-1.08.1/sysdeps/mach/hurd/send.c Tue Apr 26 20:18:03 1994 +++ glibc-1.09/sysdeps/mach/hurd/send.c Mon Jul 18 18:11:50 1994 @@ -33,7 +33,7 @@ err = HURD_DPORT_USE (fd, __socket_send (port, MACH_PORT_NULL, flags, buf, n, - NULL, NULL, 0, + NULL, MACH_MSG_TYPE_COPY_SEND, 0, NULL, 0, &wrote)); return err ? __hurd_dfail (fd, err) : wrote; diff -ruN glibc-1.08.1/sysdeps/mach/hurd/sendto.c glibc-1.09/sysdeps/mach/hurd/sendto.c --- glibc-1.08.1/sysdeps/mach/hurd/sendto.c Tue Apr 26 20:16:49 1994 +++ glibc-1.09/sysdeps/mach/hurd/sendto.c Mon Jul 18 18:11:50 1994 @@ -47,7 +47,8 @@ /* Send the data. */ err = __socket_send (port, aport, flags, buf, n, - NULL, 0, NULL, + NULL, + MACH_MSG_TYPE_COPY_SEND, 0, NULL, 0, &wrote); __mach_port_deallocate (__mach_task_self (), aport); diff -ruN glibc-1.08.1/sysdeps/mach/hurd/setegid.c glibc-1.09/sysdeps/mach/hurd/setegid.c --- glibc-1.08.1/sysdeps/mach/hurd/setegid.c Thu May 12 08:13:29 1994 +++ glibc-1.09/sysdeps/mach/hurd/setegid.c Wed Nov 2 23:01:13 1994 @@ -46,7 +46,7 @@ memcpy (&newgen[1], _hurd_id.gen.gids, (ngen - 1) * sizeof (gid_t)); err = __USEPORT (AUTH, __auth_makeauth - (port, NULL, 0, MACH_MSG_TYPE_COPY_SEND, + (port, NULL, MACH_MSG_TYPE_COPY_SEND, 0, _hurd_id.gen.uids, _hurd_id.gen.nuids, _hurd_id.aux.uids, _hurd_id.aux.nuids, newgen, ngen, diff -ruN glibc-1.08.1/sysdeps/mach/hurd/seteuid.c glibc-1.09/sysdeps/mach/hurd/seteuid.c --- glibc-1.08.1/sysdeps/mach/hurd/seteuid.c Thu May 12 08:13:46 1994 +++ glibc-1.09/sysdeps/mach/hurd/seteuid.c Wed Nov 2 22:39:29 1994 @@ -46,7 +46,7 @@ memcpy (&newgen[1], _hurd_id.gen.uids, (ngen - 1) * sizeof (uid_t)); err = __USEPORT (AUTH, __auth_makeauth - (port, NULL, 0, MACH_MSG_TYPE_COPY_SEND, + (port, NULL, MACH_MSG_TYPE_COPY_SEND, 0, newgen, ngen, _hurd_id.aux.uids, _hurd_id.aux.nuids, _hurd_id.gen.gids, _hurd_id.gen.ngids, diff -ruN glibc-1.08.1/sysdeps/mach/hurd/setgroups.c glibc-1.09/sysdeps/mach/hurd/setgroups.c --- glibc-1.08.1/sysdeps/mach/hurd/setgroups.c Thu May 12 08:14:18 1994 +++ glibc-1.09/sysdeps/mach/hurd/setgroups.c Mon Jul 18 18:11:51 1994 @@ -43,7 +43,7 @@ { /* Get a new auth port using those IDs. */ err = __USEPORT (AUTH, - __auth_makeauth (port, NULL, 0, 0, + __auth_makeauth (port, NULL, MACH_MSG_TYPE_COPY_SEND, 0, _hurd_id.gen.uids, _hurd_id.gen.nuids, _hurd_id.aux.uids, _hurd_id.aux.nuids, new, n, diff -ruN glibc-1.08.1/sysdeps/mach/hurd/setprio.c glibc-1.09/sysdeps/mach/hurd/setprio.c --- glibc-1.08.1/sysdeps/mach/hurd/setprio.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/mach/hurd/setprio.c Wed Oct 26 00:42:14 1994 @@ -0,0 +1,85 @@ +/* Copyright (C) 1994 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include + +/* Set the priority of all processes specified by WHICH and WHO + to PRIO. Returns 0 on success, -1 on errors. */ +int +setpriority (enum __priority_which which, int who, int prio) +{ + error_t err; + error_t pidloser, priloser; + unsigned int npids, ntasks, nwin, nperm, nacces; + + error_t setonepriority (pid_t pid, struct procinfo *pi) + { + task_t task; + error_t piderr = __USEPORT (PROC, __proc_pid2task (port, pid, &task)); + if (piderr == EPERM) + ++nperm; + if (piderr != ESRCH) + { + ++npids; + if (piderr && piderr != EPERM) + pidloser = piderr; + } + if (! piderr) + { + error_t prierr; + ++ntasks; + prierr = __task_priority (task, NICE_TO_MACH_PRIORITY (prio), 1); + __mach_port_deallocate (__mach_task_self (), task); + switch (prierr) + { + case KERN_FAILURE: + ++nacces; + break; + case KERN_SUCCESS: + ++nwin; + break; + case KERN_INVALID_ARGUMENT: /* Task died. */ + --npids; + --ntasks; + break; + default: + priloser = prierr; + } + } + return 0; + } + + npids = ntasks = nwin = nperm = nacces = 0; + pidloser = priloser = 0; + err = _hurd_priority_which_map (which, who, setonepriority); + + if (!err && npids == 0) + /* No error, but no pids found. */ + err = ESRCH; + else if (nperm == npids) + /* Got EPERM from proc_task2pid for every process. */ + err = EPERM; + else if (nacces == ntasks) + /* Got KERN_FAILURE from task_priority for every task. */ + err = EACCES; + else if (nwin == 0) + err = pidloser ?: priloser; + + return err ? __hurd_fail (err) : 0; +} diff -ruN glibc-1.08.1/sysdeps/mach/hurd/sigsuspend.c glibc-1.09/sysdeps/mach/hurd/sigsuspend.c --- glibc-1.08.1/sysdeps/mach/hurd/sigsuspend.c Thu May 5 05:42:27 1994 +++ glibc-1.09/sysdeps/mach/hurd/sigsuspend.c Fri Sep 23 17:13:55 1994 @@ -20,7 +20,7 @@ #include #include #include - +#include /* Change the set of blocked signals to SET, wait until a signal arrives, and restore the set of blocked signals. */ @@ -28,34 +28,49 @@ DEFUN(sigsuspend, (set), CONST sigset_t *set) { struct hurd_sigstate *ss; - sigset_t newmask, oldmask; + sigset_t newmask, oldmask, pending; + mach_port_t wait; + mach_msg_header_t msg; if (set != NULL) /* Crash before locking. */ newmask = *set; + /* Get a fresh port we will wait on. */ + wait = __mach_reply_port (); + ss = _hurd_self_sigstate (); + oldmask = ss->blocked; if (set != NULL) + /* Change to the new blocked signal mask. */ ss->blocked = newmask & ~_SIG_CANT_MASK; - /* Set the `suspended' bit and wait for a condition_signal on - SS->arrived. When a signal arrives and SS->suspended is set, the - signal thread does condition_signal (&SS->arrived) after clearing - SS->suspended. */ - ss->suspended = 1; - do - { -#ifdef noteven - __condition_wait (&ss->arrived, &ss->lock); -#else /* XXX */ - __mutex_unlock (&ss->lock); __swtch (); __mutex_lock (&ss->lock); -#endif - } while (ss->suspended); + /* Notice if any pending signals just became unblocked. */ + pending = ss->pending & ~ss->blocked; + + /* Tell the signal thread to message us when a signal arrives. */ + ss->suspended = wait; + __mutex_unlock (&ss->lock); - ss->blocked = oldmask; + if (pending) + /* Tell the signal thread to check for pending signals. */ + __sig_post (_hurd_msgport, 0, __mach_task_self ()); + + /* Wait for the signal thread's message. */ + __mach_msg (&msg, MACH_RCV_MSG, 0, sizeof (msg), wait, + MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + __mach_port_destroy (__mach_task_self (), wait); + + __mutex_lock (&ss->lock); + ss->blocked = oldmask; /* Restore the old mask. */ + pending = ss->pending & ~ss->blocked; /* Again check for pending signals. */ __mutex_unlock (&ss->lock); + if (pending) + /* Tell the signal thread to check for pending signals. */ + __sig_post (_hurd_msgport, 0, __mach_task_self ()); + /* We've been interrupted! And a good thing, too. Otherwise we'd never return. That's right; this function always returns an error. */ diff -ruN glibc-1.08.1/sysdeps/mach/hurd/socket.c glibc-1.09/sysdeps/mach/hurd/socket.c --- glibc-1.08.1/sysdeps/mach/hurd/socket.c Tue Apr 26 20:18:02 1994 +++ glibc-1.09/sysdeps/mach/hurd/socket.c Thu Oct 6 19:04:48 1994 @@ -32,12 +32,25 @@ int domain AND enum __socket_type type AND int protocol) { error_t err; - socket_t sock, server = _hurd_socket_server (domain); + socket_t sock, server; + /* Find the socket server for DOMAIN. */ + server = _hurd_socket_server (domain, 0); if (server == MACH_PORT_NULL) return -1; - if (err = __socket_create (server, type, protocol, &sock)) + err = __socket_create (server, type, protocol, &sock); + if (err == MACH_SEND_INVALID_DEST || err == MIG_SERVER_DIED) + { + /* On the first use of the socket server during the operation, + allow for the old server port dying. */ + server = _hurd_socket_server (domain, 1); + if (server == MACH_PORT_NULL) + return -1; + err = __socket_create (server, type, protocol, &sock); + } + + if (err) return __hurd_fail (err); return _hurd_intern_fd (sock, O_IGNORE_CTTY, 1); diff -ruN glibc-1.08.1/sysdeps/mach/hurd/stdio_init.c glibc-1.09/sysdeps/mach/hurd/stdio_init.c --- glibc-1.08.1/sysdeps/mach/hurd/stdio_init.c Mon May 23 15:58:50 1994 +++ glibc-1.09/sysdeps/mach/hurd/stdio_init.c Mon Jul 18 18:11:59 1994 @@ -22,6 +22,8 @@ #include #include #include +#include +#include /* Initialize STREAM as necessary. This may change I/O functions, give a buffer, etc. diff -ruN glibc-1.08.1/sysdeps/mach/hurd/sync.c glibc-1.09/sysdeps/mach/hurd/sync.c --- glibc-1.08.1/sysdeps/mach/hurd/sync.c Tue Feb 1 22:55:37 1994 +++ glibc-1.09/sysdeps/mach/hurd/sync.c Tue Sep 13 19:58:49 1994 @@ -25,7 +25,8 @@ int DEFUN_VOID(sync) { - error_t err = __USEPORT (CRDIR, __file_syncfs (port, 1, 1)); + /* This is not actually synchronous; we don't wait. */ + error_t err = __USEPORT (CRDIR, __file_syncfs (port, 0, 1)); if (err) return __hurd_fail (err); return 0; diff -ruN glibc-1.08.1/sysdeps/mach/hurd/sys/param.h glibc-1.09/sysdeps/mach/hurd/sys/param.h --- glibc-1.08.1/sysdeps/mach/hurd/sys/param.h Tue Apr 19 20:49:05 1994 +++ glibc-1.09/sysdeps/mach/hurd/sys/param.h Fri Oct 14 08:01:45 1994 @@ -66,6 +66,7 @@ #include #include +#include #include #include #include @@ -75,9 +76,11 @@ /* What versions of BSD we are compatible with. */ -#define BSD 199103 /* March, 1991 system version (year & month) */ +#define BSD 199306 /* System version (year & month). */ #define BSD4_3 1 -#define BSD4_4 0.5 +#define BSD4_4 1 + +#define GNU 1994100 /* GNU version (year, month, and release). */ /* BSD names for some values. We do not define the BSD names diff -ruN glibc-1.08.1/sysdeps/mach/hurd/sysd-stdio.c glibc-1.09/sysdeps/mach/hurd/sysd-stdio.c --- glibc-1.08.1/sysdeps/mach/hurd/sysd-stdio.c Fri Jun 3 21:49:36 1994 +++ glibc-1.09/sysdeps/mach/hurd/sysd-stdio.c Tue Aug 30 04:57:47 1994 @@ -34,7 +34,7 @@ { int signo = _hurd_fd_error_signal (err); if (signo) - _hurd_raise_signal (NULL, signo, __stdio_fileno (fd)); + _hurd_raise_signal (NULL, signo, __stdio_fileno (fd), err); errno = err; return -1; } @@ -143,7 +143,7 @@ struct hurd_fd *d; flags = modeflags (m); - port = __path_lookup (filename, flags, 0666 & ~_hurd_umask); + port = __file_name_lookup (filename, flags, 0666 & ~_hurd_umask); if (port == MACH_PORT_NULL) return -1; @@ -182,7 +182,7 @@ /* Open a new port on the file. */ flags = modeflags (m); - port = __path_lookup (filename, flags, 0666 & ~_hurd_umask); + port = __file_name_lookup (filename, flags, 0666 & ~_hurd_umask); /* Install the new port in the same file descriptor slot the old cookie points to. If opening the file failed, PORT will be MACH_PORT_NULL diff -ruN glibc-1.08.1/sysdeps/mach/hurd/telldir.c glibc-1.09/sysdeps/mach/hurd/telldir.c --- glibc-1.08.1/sysdeps/mach/hurd/telldir.c Tue Dec 21 01:41:25 1993 +++ glibc-1.09/sysdeps/mach/hurd/telldir.c Mon Jul 18 18:12:01 1994 @@ -1,4 +1,4 @@ -/* Copyright (C) 1993 Free Software Foundation, Inc. +/* Copyright (C) 1993, 1994 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -27,11 +27,5 @@ off_t DEFUN(telldir, (dirp), DIR *dirp) { - if (dirp == NULL) - { - errno = EINVAL; - return (off_t) -1; - } - - return dirp->__filepos + dirp->__offset; + return dirp->__entry_ptr; } diff -ruN glibc-1.08.1/sysdeps/mach/hurd/truncate.c glibc-1.09/sysdeps/mach/hurd/truncate.c --- glibc-1.08.1/sysdeps/mach/hurd/truncate.c Tue Dec 21 01:04:20 1993 +++ glibc-1.09/sysdeps/mach/hurd/truncate.c Tue Aug 30 20:34:26 1994 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -22,13 +22,13 @@ #include #include -/* Truncate PATH to LENGTH bytes. */ +/* Truncate FILE_NAME to LENGTH bytes. */ int -DEFUN(truncate, (path, length), - CONST char *path AND off_t length) +DEFUN(truncate, (file_name, length), + CONST char *file_name AND off_t length) { error_t err; - file_t file = __path_lookup (path, O_WRITE, 0); + file_t file = __file_name_lookup (file_name, O_WRITE, 0); if (file == MACH_PORT_NULL) return -1; diff -ruN glibc-1.08.1/sysdeps/mach/hurd/ttyname.c glibc-1.09/sysdeps/mach/hurd/ttyname.c --- glibc-1.08.1/sysdeps/mach/hurd/ttyname.c Tue Feb 1 23:05:41 1994 +++ glibc-1.09/sysdeps/mach/hurd/ttyname.c Mon Jul 18 18:12:02 1994 @@ -17,92 +17,22 @@ Cambridge, MA 02139, USA. */ #include -#include -#include -#include -#include -#include #include -#include -#include #include #include #include -char *__ttyname = NULL; - /* Return the pathname of the terminal FD is open on, or NULL on errors. The returned storage is good only until the next call to this function. */ char * ttyname (int fd) { - static const char dev[] = "/dev"; - DIR *dirstream; - struct dirent *d; error_t err; - mach_port_t fd_cttyid; - static char nodename[1024] = ""; /* XXX */ - char *name; - - /* Open FILENAME relative to DIR and return nonzero iff its ctty ID port - is the same as FD_CTTYID. */ - int try (file_t dir, const char *filename) - { - mach_port_t file, cttyid; - if (__USEPORT (CRDIR, __hurd_path_lookup (port, dir, filename, 0, 0, - &file))) - return 0; /* Can't open it. */ - err = __term_getctty (file, &cttyid); - __mach_port_deallocate (__mach_task_self (), file); - if (err) - return 0; /* Not a terminal. */ - /* We only need to know if CTTYID is the same port as FD_CTTYID, - so deallocating the reference can never hurt. */ - __mach_port_deallocate (__mach_task_self (), cttyid); - return cttyid == fd_cttyid; - } - - /* Get the ctty ID port of the object we want to find. */ - if (err = HURD_DPORT_USE (fd, - (__term_get_nodename (port, nodename), - __term_getctty (port, &fd_cttyid)))) - return __hurd_fail (err), NULL; - - /* If there was a "nodename" set, and it is correct, return that. */ - if (nodename[0] != '\0' && __USEPORT (CWDIR, try (port, nodename))) - return nodename; - - - /* Search the "/dev" directory for a file that returns the same ctty ID - port that the terminal FD refers to. */ - - dirstream = opendir (dev); - if (dirstream == NULL) - return NULL; - - name = NULL; - while ((d = readdir (dirstream)) != NULL) - if (try (dirstream->__port, d->d_name)) - { - if (__ttyname) - free (__ttyname); - __ttyname = malloc (sizeof (dev) + 1 + d->d_namlen); - if (__ttyname != NULL) - { - memcpy (__ttyname, dev, sizeof (dev) - 1); - __ttyname[sizeof (dev)] = '/'; - memcpy (&__ttyname[sizeof (dev) + 1], d->d_name, d->d_namlen + 1); - } - name = __ttyname; - break; - } + static char nodename[1024]; /* XXX */ - __mach_port_deallocate (__mach_task_self (), fd_cttyid); + nodename[0] = '\0'; + if (err = HURD_DPORT_USE (fd, __term_get_nodename (port, nodename))) + return __hurd_dfail (fd, err), NULL; - { - int save = errno; - (void) closedir (dirstream); - errno = save; - return name; - } + return nodename; } diff -ruN glibc-1.08.1/sysdeps/mach/i386/Implies glibc-1.09/sysdeps/mach/i386/Implies --- glibc-1.08.1/sysdeps/mach/i386/Implies Fri Oct 25 21:11:50 1991 +++ glibc-1.09/sysdeps/mach/i386/Implies Wed Dec 31 19:00:00 1969 @@ -1 +0,0 @@ -i386 diff -ruN glibc-1.08.1/sysdeps/mach/i386/machine-lock.h glibc-1.09/sysdeps/mach/i386/machine-lock.h --- glibc-1.08.1/sysdeps/mach/i386/machine-lock.h Wed Apr 20 16:01:51 1994 +++ glibc-1.09/sysdeps/mach/i386/machine-lock.h Mon Jul 18 18:12:06 1994 @@ -22,7 +22,7 @@ /* The type of a spin lock variable. */ -typedef volatile int __spin_lock_t; +typedef __volatile int __spin_lock_t; /* Value to initialize `__spin_lock_t' variables to. */ @@ -39,8 +39,8 @@ __spin_unlock (__spin_lock_t *__lock) { register int __unlocked; - __asm__ volatile ("xchgl %0, %1" - : "=&r" (__unlocked), "=m" (*__lock) : "0" (0)); + __asm__ __volatile ("xchgl %0, %1" + : "=&r" (__unlocked), "=m" (*__lock) : "0" (0)); } /* Try to lock LOCK; return nonzero if we locked it, zero if another has. */ @@ -49,8 +49,8 @@ __spin_try_lock (__spin_lock_t *__lock) { register int __locked; - __asm__ volatile ("xchgl %0, %1" - : "=&r" (__locked), "=m" (*__lock) : "0" (1)); + __asm__ __volatile ("xchgl %0, %1" + : "=&r" (__locked), "=m" (*__lock) : "0" (1)); return !__locked; } diff -ruN glibc-1.08.1/sysdeps/mach/i386/sysdep.h glibc-1.09/sysdeps/mach/i386/sysdep.h --- glibc-1.08.1/sysdeps/mach/i386/sysdep.h Tue Apr 19 22:53:37 1994 +++ glibc-1.09/sysdeps/mach/i386/sysdep.h Mon Jul 18 18:12:07 1994 @@ -16,20 +16,6 @@ not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#define ENTRY(name) \ - .text; \ - .globl _##name; \ - .align 4; \ - _##name##: - -#define SYSCALL_TRAP(name, number) \ - ENTRY (name) \ - lea number, %eax; \ - /* lcall $7, $0; */ \ - /* Above loses; GAS bug. */ \ - .byte 0x9a, 0, 0, 0, 0, 7, 0; \ - ret - #define MOVE(x,y) movl x , y #define LOSE asm volatile ("hlt") diff -ruN glibc-1.08.1/sysdeps/mach/i386/thread_state.h glibc-1.09/sysdeps/mach/i386/thread_state.h --- glibc-1.08.1/sysdeps/mach/i386/thread_state.h Wed Feb 16 18:18:45 1994 +++ glibc-1.09/sysdeps/mach/i386/thread_state.h Thu Sep 15 16:49:35 1994 @@ -17,9 +17,7 @@ not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* Everything else is called `thread_state', but CMU's header file is - called `thread_status'. Oh boy. */ -#include +#include #define MACHINE_THREAD_STATE_FLAVOR i386_THREAD_STATE #define MACHINE_THREAD_STATE_COUNT i386_THREAD_STATE_COUNT @@ -28,3 +26,13 @@ #define PC eip #define SP uesp +#define SYSRETURN eax + +struct machine_thread_all_state + { + int set; /* Mask of bits (1 << FLAVOR). */ + struct i386_thread_state basic; + struct i386_float_state fpu; + }; + +#include_next diff -ruN glibc-1.08.1/sysdeps/mach/mips/machine-lock.h glibc-1.09/sysdeps/mach/mips/machine-lock.h --- glibc-1.08.1/sysdeps/mach/mips/machine-lock.h Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/mach/mips/machine-lock.h Mon Jul 18 18:12:08 1994 @@ -0,0 +1,73 @@ +/* Machine-specific definition for spin locks. MIPS version. +Copyright (C) 1994 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#ifndef _MACHINE_LOCK_H +#define _MACHINE_LOCK_H + +/* The type of a spin lock variable. */ + +typedef __volatile int __spin_lock_t; + +/* Value to initialize `__spin_lock_t' variables to. */ + +#define __SPIN_LOCK_INITIALIZER 0 + + +#ifndef _EXTERN_INLINE +#define _EXTERN_INLINE extern __inline +#endif + +/* Unlock LOCK. */ + +_EXTERN_INLINE void +__spin_unlock (__spin_lock_t *__lock) +{ + *__lock = 0; +} + +/* Try to lock LOCK; return nonzero if we locked it, zero if another has. */ + +_EXTERN_INLINE int +__spin_try_lock (register __spin_lock_t *__lock) +{ + register int __rtn; + __asm__ __volatile (".set noreorder"); +#if 0 + __asm__ __volatile ("lw %0,0(%1)": "=r" (__rtn) : "r" (__lock)); + __asm__ __volatile ("sw %0,0(%0)": : "r" (__lock)); + __asm__ __volatile ("xor %0,%1,%0": "=r" (__rtn) : "r" (__lock)); +#else + /* Use the Mach microkernel's emulated TAS pseudo-instruction. */ + register int __rtn __asm__ ("a0"); + __asm__ __volatile (".word 0xf ! %0 " : "=r" (__rtn) : "0" (__lock)); +#endif + __asm__ __volatile (".set reorder"); + return __rtn ^ (int) __lock; +} + +/* Return nonzero if LOCK is locked. */ + +_EXTERN_INLINE int +__spin_lock_locked (__spin_lock_t *__lock) +{ + return *__lock != 0; +} + + +#endif /* machine-lock.h */ diff -ruN glibc-1.08.1/sysdeps/mach/mips/machine-sp.h glibc-1.09/sysdeps/mach/mips/machine-sp.h --- glibc-1.08.1/sysdeps/mach/mips/machine-sp.h Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/mach/mips/machine-sp.h Mon Jul 18 18:12:09 1994 @@ -0,0 +1,38 @@ +/* Machine-specific function to return the stack pointer. MIPS version. +Copyright (C) 1994 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#ifndef _MACHINE_SP_H +#define _MACHINE_SP_H + +/* Return the current stack pointer. */ + +#ifndef _EXTERN_INLINE +#define _EXTERN_INLINE extern __inline +#endif + +_EXTERN_INLINE void * +__thread_stack_pointer (void) +{ + void *__sp__; + __asm__ ("move %0,$29" : "=r" (__sp__)); + return __sp__; +} + +#endif /* machine-sp.h */ + diff -ruN glibc-1.08.1/sysdeps/mach/mips/syscall.S glibc-1.09/sysdeps/mach/mips/syscall.S --- glibc-1.08.1/sysdeps/mach/mips/syscall.S Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/mach/mips/syscall.S Tue Aug 30 08:38:11 1994 @@ -0,0 +1,37 @@ +/* Copyright (C) 1994 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include + +ENTRY (syscall) + .frame sp,0,ra + move v0, a0 /* Load system call number from first arg. */ + move a0, a1 /* Move the next three args up a register. */ + move a1, a2 + move a2, a3 + /* Load the remaining possible args (up to 11) from the stack. */ + lw t0,16(sp) + lw t1,20(sp) + lw t2,24(sp) + lw t3,28(sp) + lw t4,32(sp) + lw t5,36(sp) + lw t6,40(sp) + syscall /* Do the system call. */ + j ra /* Return to caller. */ + .end syscall diff -ruN glibc-1.08.1/sysdeps/mach/mips/sysdep.h glibc-1.09/sysdeps/mach/mips/sysdep.h --- glibc-1.08.1/sysdeps/mach/mips/sysdep.h Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/mach/mips/sysdep.h Mon Jul 18 18:12:09 1994 @@ -0,0 +1,69 @@ +/* Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#define MOVE(x,y) move y , x + +#if 0 +#define LOSE asm volatile ("1: b 1b") +#endif + +#define SNARF_ARGS(argc, argv, envp) \ + do \ + { \ + int *entry_sp; \ + register char **p; \ + \ + asm ("addu %0,$30,4" : "=r" (entry_sp)); \ + \ + argc = *entry_sp; \ + argv = (char **) (entry_sp + 1); \ + p = argv; \ + while (*p++ != NULL) \ + ; \ + if (p >= (char **) argv[0]) \ + --p; \ + envp = p; \ + } while (0) + +#define CALL_WITH_SP(fn, sp) \ + ({ register int __fn = fn, __sp = (int) sp; \ + asm volatile ("move $sp,%0; j %1" : : "r" (__sp), "r" (__fn));}) + +#define STACK_GROWTH_DOWN + +#ifdef P40 +#include + +#define SYSCALL(name, args) \ + .globl syscall_error; \ + kernel_trap(name,SYS_##name,args); \ + beq $1,$0,1f; \ + j syscall_error; \ +1: + +#define SYSCALL__(name, args) \ + .globl syscall_error; \ + kernel_trap(__##name,SYS_##name,args); \ + beq $1,$0,1f; \ + j syscall_error; \ +1: + +#define ret j ra; nop +#endif + +#include_next diff -ruN glibc-1.08.1/sysdeps/mach/mips/thread_state.h glibc-1.09/sysdeps/mach/mips/thread_state.h --- glibc-1.08.1/sysdeps/mach/mips/thread_state.h Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/mach/mips/thread_state.h Mon Aug 22 15:00:35 1994 @@ -0,0 +1,37 @@ +/* Mach thread state definitions for machine-independent code. MIPS version. +Copyright (C) 1994 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#define MACHINE_THREAD_STATE_FLAVOR MIPS_THREAD_STATE +#define MACHINE_THREAD_STATE_COUNT MIPS_THREAD_STATE_COUNT + +#define machine_thread_state mips_thread_state + +#define PC pc +#define SP r29 +#define SYSRETURN r2 + +struct machine_thread_all_state + { + int set; /* Mask of bits (1 << FLAVOR). */ + struct mips_thread_state basic; + struct mips_exc_state exc; + struct mips_float_state fpu; + }; + +#include_next diff -ruN glibc-1.08.1/sysdeps/mach/sys/reboot.h glibc-1.09/sysdeps/mach/sys/reboot.h --- glibc-1.08.1/sysdeps/mach/sys/reboot.h Tue Aug 3 18:25:15 1993 +++ glibc-1.09/sysdeps/mach/sys/reboot.h Mon Jul 18 18:12:08 1994 @@ -25,7 +25,10 @@ */ /* * HISTORY - * $Log: reboot.h,v $ + * $Log: reboot.h,v $ + * Revision 1.1 1993/08/03 22:25:15 roland + * entered into RCS + * * Revision 2.8 93/03/11 13:46:40 danner * u_long -> u_int. * [93/03/09 danner] diff -ruN glibc-1.08.1/sysdeps/mach/sysdep.h glibc-1.09/sysdeps/mach/sysdep.h --- glibc-1.08.1/sysdeps/mach/sysdep.h Mon May 16 18:10:04 1994 +++ glibc-1.09/sysdeps/mach/sysdep.h Wed Nov 2 22:59:53 1994 @@ -16,11 +16,17 @@ not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +/* Get the Mach definitions of ENTRY and kernel_trap. */ +#include + /* This is invoked by things run when there is random lossage, before they try to do anything else. Just to be safe, deallocate the reply port so bogons arriving on it don't foul up future RPCs. */ -#define FATAL_PREPARE __mig_dealloc_reply_port () +#ifndef ASSEMBLER +#include +#define FATAL_PREPARE __mig_dealloc_reply_port (MACH_PORT_NULL) +#endif /* sysdeps/mach/MACHINE/sysdep.h should define the following macros. */ @@ -30,12 +36,6 @@ #error ENTRY not defined by sysdeps/mach/MACHINE/sysdep.h #endif -/* Define a C function called NAME which does system call NUMBER. */ -#ifndef SYSCALL_TRAP -#define SYSCALL_TRAP(name, number) -#error SYSCALL_TRAP not defined by sysdeps/mach/MACHINE/sysdep.h -#endif - /* Set variables ARGC, ARGV, and ENVP for the arguments left on the stack by the microkernel. */ #ifndef SNARF_ARGS @@ -55,7 +55,7 @@ similar which will cause the process to die in a characteristic way suggesting a bug. */ #ifndef LOSE -#define LOSE __task_terminate (__mach_task_self ()) +#define LOSE ({ volatile int zero = 0; zero / zero; }) #endif /* One of these should be defined to specify the stack direction. */ diff -ruN glibc-1.08.1/sysdeps/mach/thread_state.h glibc-1.09/sysdeps/mach/thread_state.h --- glibc-1.08.1/sysdeps/mach/thread_state.h Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/mach/thread_state.h Sun Sep 4 15:37:33 1994 @@ -0,0 +1,86 @@ +/* Generic definitions for dealing with Mach thread states. +Copyright (C) 1994 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + + +/* Everything else is called `thread_state', but CMU's header file is + called `thread_status'. Oh boy. */ +#include + +/* The machine-dependent thread_state.h file can either define these + macros, or just define PC and SP to the register names. */ + +#ifndef MACHINE_THREAD_STATE_SET_PC +#define MACHINE_THREAD_STATE_SET_PC(ts, pc) \ + ((ts)->PC = (unsigned long int) (pc)) +#endif +#ifndef MACHINE_THREAD_STATE_SET_SP +#ifdef STACK_GROWTH_UP +#define MACHINE_THREAD_STATE_SET_SP(ts, stack, size) \ + ((ts)->SP = (unsigned long int) (stack)) +#else +#define MACHINE_THREAD_STATE_SET_SP(ts, stack, size) \ + ((ts)->SP = (unsigned long int) (stack) + (size)) +#endif +#endif + +/* These functions are of use in machine-dependent signal trampoline + implementations. */ + +#include /* size_t, memcpy */ +#include /* __thread_get_state */ + +static inline int +machine_get_state (thread_t thread, struct machine_thread_all_state *state, + int flavor, void *stateptr, void *scpptr, size_t size) +{ + if (state->set & (1 << flavor)) + { + /* Copy the saved state. */ + memcpy (scpptr, stateptr, size); + return 1; + } + else + { + /* Noone asked about this flavor of state before; fetch the state + directly from the kernel into the sigcontext. */ + unsigned int got = (size / sizeof (int)); + return (! __thread_get_state (thread, flavor, scpptr, &got) + && got == (size / sizeof (int))); + } +} + +static inline int +machine_get_basic_state (thread_t thread, + struct machine_thread_all_state *state) +{ + unsigned int count; + + if (state->set & (1 << MACHINE_THREAD_STATE_FLAVOR)) + return 1; + + count = MACHINE_THREAD_STATE_COUNT; + if (__thread_get_state (thread, MACHINE_THREAD_STATE_FLAVOR, + (int *) &state->basic, &count) != KERN_SUCCESS || + count != MACHINE_THREAD_STATE_COUNT) + /* What kind of thread?? */ + return 0; /* XXX */ + + state->set |= 1 << MACHINE_THREAD_STATE_FLAVOR; + return 1; +} diff -ruN glibc-1.08.1/sysdeps/mips/dec/bytesex.h glibc-1.09/sysdeps/mips/dec/bytesex.h --- glibc-1.08.1/sysdeps/mips/dec/bytesex.h Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/mips/dec/bytesex.h Mon Jul 18 18:12:17 1994 @@ -0,0 +1,4 @@ +/* The MIPS architecture has selectable endianness. + The DECstation uses little-endian mode. */ + +#define __BYTE_ORDER __LITTLE_ENDIAN diff -ruN glibc-1.08.1/sysdeps/mips/p40/bytesex.h glibc-1.09/sysdeps/mips/p40/bytesex.h --- glibc-1.08.1/sysdeps/mips/p40/bytesex.h Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/mips/p40/bytesex.h Mon Jul 18 18:12:16 1994 @@ -0,0 +1,4 @@ +/* The MIPS has selectable endianness. + The Japanese homebrew P40 architecture uses big-endian mode. */ + +#define __BYTE_ORDER __BIG_ENDIAN diff -ruN glibc-1.08.1/sysdeps/mips/setjmp.S glibc-1.09/sysdeps/mips/setjmp.S --- glibc-1.08.1/sysdeps/mips/setjmp.S Tue May 10 17:29:43 1994 +++ glibc-1.09/sysdeps/mips/setjmp.S Tue Aug 2 21:03:26 1994 @@ -23,6 +23,10 @@ extra arguments. */ ENTRY (__setjmp) move a1, sp +#ifdef __sgi__ move a2, fp +#else + move a2, $fp +#endif j __setjmp_aux diff -ruN glibc-1.08.1/sysdeps/posix/Makefile glibc-1.09/sysdeps/posix/Makefile --- glibc-1.08.1/sysdeps/posix/Makefile Mon Mar 21 21:48:29 1994 +++ glibc-1.09/sysdeps/posix/Makefile Mon Aug 15 20:51:25 1994 @@ -28,11 +28,11 @@ # Turn into a version that works when cd'd into $(objdir). cded-objdir-CPPFLAGS = $(patsubst -I$$cwd//%,-I/%,\ $(patsubst -I%,-I$$cwd/%,$(CPPFLAGS))) -# $(native-CFLAGS) needs to come last because it contains unwanted -Is. +# $(BUILD_CFLAGS) needs to come last because it contains unwanted -Is. $(common-objpfx)mk-stdiolim: $(sysdep_dir)/posix/mk-stdiolim.c \ posix1_lim.h local_lim.h cwd=`pwd`; cd $(common-objdir); \ - $(HOST_CC) $(cded-objdir-CPPFLAGS) $(native-CFLAGS) \ + $(BUILD_CC) $(cded-objdir-CPPFLAGS) $(BUILD_CFLAGS) \ $$cwd/$< -o $(patsubst $(common-objpfx)%,%,$@) diff -ruN glibc-1.08.1/sysdeps/posix/getcwd.c glibc-1.09/sysdeps/posix/getcwd.c --- glibc-1.08.1/sysdeps/posix/getcwd.c Fri May 7 20:00:19 1993 +++ glibc-1.09/sysdeps/posix/getcwd.c Mon Jul 18 18:04:32 1994 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -178,7 +178,6 @@ #ifndef __GNU_LIBRARY__ #define __lstat stat -#define #endif /* Get the pathname of the current working directory, and put it in SIZE diff -ruN glibc-1.08.1/sysdeps/posix/getenv.c glibc-1.09/sysdeps/posix/getenv.c --- glibc-1.08.1/sysdeps/posix/getenv.c Mon Apr 18 19:12:42 1994 +++ glibc-1.09/sysdeps/posix/getenv.c Wed Dec 31 19:00:00 1969 @@ -1,44 +0,0 @@ -/* Copyright (C) 1991, 1992, 1994 Free Software Foundation, Inc. -This file is part of the GNU C Library. - -The GNU C Library is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. - -The GNU C Library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with the GNU C Library; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA. */ - -#include -#include -#include -#include -#include - -#ifndef HAVE_GNU_LD -#define __environ environ -#endif - -/* Return the value of the environment variable NAME. */ -char * -DEFUN(getenv, (name), register CONST char *name) -{ - register CONST size_t len = strlen(name); - register char **ep; - - if (__environ == NULL) - return NULL; - - for (ep = __environ; *ep != NULL; ++ep) - if (!strncmp(*ep, name, len) && (*ep)[len] == '=') - return &(*ep)[len + 1]; - - return NULL; -} diff -ruN glibc-1.08.1/sysdeps/posix/putenv.c glibc-1.09/sysdeps/posix/putenv.c --- glibc-1.08.1/sysdeps/posix/putenv.c Mon Mar 23 17:42:09 1992 +++ glibc-1.09/sysdeps/posix/putenv.c Wed Dec 31 19:00:00 1969 @@ -1,80 +0,0 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. -This file is part of the GNU C Library. - -The GNU C Library is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. - -The GNU C Library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with the GNU C Library; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA. */ - -#include -#include -#include -#include -#include - -#ifndef HAVE_GNU_LD -#define __environ environ -#endif - -/* Put STRING, which is of the form "NAME=VALUE", in the environment. */ -int -DEFUN(putenv, (string), CONST char *string) -{ - CONST char *CONST name_end = strchr(string, '='); - register size_t size; - register char **ep; - - if (name_end == NULL) - { - /* Remove the variable from the environment. */ - size = strlen(string); - for (ep = __environ; *ep != NULL; ++ep) - if (!strncmp(*ep, string, size) && (*ep)[size] == '=') - { - while (ep[1] != NULL) - { - ep[0] = ep[1]; - ++ep; - } - *ep = NULL; - return 0; - } - } - - size = 0; - for (ep = __environ; *ep != NULL; ++ep) - if (!strncmp(*ep, string, name_end - string) && - (*ep)[name_end - string] == '=') - break; - else - ++size; - - if (*ep == NULL) - { - static char **last_environ = NULL; - char **new_environ = (char **) malloc((size + 2) * sizeof(char *)); - if (new_environ == NULL) - return -1; - (void) memcpy((PTR) new_environ, (PTR) __environ, size * sizeof(char *)); - new_environ[size] = (char *) string; - new_environ[size + 1] = NULL; - if (last_environ != NULL) - free((PTR) last_environ); - last_environ = new_environ; - __environ = new_environ; - } - else - *ep = (char *) string; - - return 0; -} diff -ruN glibc-1.08.1/sysdeps/posix/setenv.c glibc-1.09/sysdeps/posix/setenv.c --- glibc-1.08.1/sysdeps/posix/setenv.c Sun May 17 17:10:59 1992 +++ glibc-1.09/sysdeps/posix/setenv.c Wed Dec 31 19:00:00 1969 @@ -1,86 +0,0 @@ -/* Copyright (C) 1992 Free Software Foundation, Inc. -This file is part of the GNU C Library. - -The GNU C Library is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. - -The GNU C Library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with the GNU C Library; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA. */ - -#include -#include -#include -#include - -#ifndef HAVE_GNU_LD -#define __environ environ -#endif - -int -DEFUN(setenv, (name, value, replace), - CONST char *name AND CONST char *value AND int replace) -{ - register char **ep; - register size_t size; - CONST size_t namelen = strlen (name); - CONST size_t vallen = strlen (value); - - size = 0; - for (ep = __environ; *ep != NULL; ++ep) - if (!strncmp (*ep, name, namelen) && (*ep)[namelen] == '=') - break; - else - ++size; - - if (*ep == NULL) - { - static char **last_environ = NULL; - char **new_environ = (char **) malloc((size + 2) * sizeof(char *)); - if (new_environ == NULL) - return -1; - (void) memcpy((PTR) new_environ, (PTR) __environ, size * sizeof(char *)); - - new_environ[size] = malloc (namelen + 1 + vallen + 1); - if (new_environ[size] == NULL) - { - free (new_environ); - errno = ENOMEM; - return -1; - } - memcpy (new_environ[size], name, namelen); - new_environ[size][namelen] = '='; - memcpy (&new_environ[size][namelen + 1], value, vallen + 1); - - new_environ[size + 1] = NULL; - - if (last_environ != NULL) - free ((PTR) last_environ); - last_environ = new_environ; - __environ = new_environ; - } - else if (replace) - { - size_t len = strlen (*ep); - if (len < namelen + 1 + vallen) - { - char *new = malloc (namelen + 1 + vallen); - if (new == NULL) - return -1; - *ep = new; - } - memcpy (*ep, name, namelen); - (*ep)[namelen] = '='; - memcpy (&(*ep)[namelen + 1], value, vallen + 1); - } - - return 0; -} diff -ruN glibc-1.08.1/sysdeps/posix/sysd-stdio.c glibc-1.09/sysdeps/posix/sysd-stdio.c --- glibc-1.08.1/sysdeps/posix/sysd-stdio.c Fri Jun 3 21:50:34 1994 +++ glibc-1.09/sysdeps/posix/sysd-stdio.c Wed Dec 31 19:00:00 1969 @@ -1,189 +0,0 @@ -/* Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc. -This file is part of the GNU C Library. - -The GNU C Library is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. - -The GNU C Library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with the GNU C Library; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA. */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* Read N bytes into BUF from COOKIE. */ -int -DEFUN(__stdio_read, (cookie, buf, n), - PTR cookie AND register char *buf AND register size_t n) -{ - CONST int fd = (int) cookie; -#if defined (EINTR) && defined (EINTR_REPEAT) - int save = errno; - int nread; - - try:; - errno = 0; - nread = __read (fd, buf, (int) n); - if (nread < 0) - { - if (errno == EINTR) - goto try; - return -1; - } - errno = save; - return nread; - -#else /* No EINTR. */ - return __read (fd, buf, n); -#endif -} - - -/* Write N bytes from BUF to COOKIE. */ -int -DEFUN(__stdio_write, (cookie, buf, n), - PTR cookie AND register CONST char *buf AND register size_t n) -{ - CONST int fd = (int) cookie; - register size_t written = 0; - - while (n > 0) - { - int count = __write (fd, buf, (int) n); - if (count > 0) - { - buf += count; - written += count; - n -= count; - } - else if (count < 0 -#if defined (EINTR) && defined (EINTR_REPEAT) - && errno != EINTR -#endif - ) - /* Write error. */ - return -1; - } - - return (int) written; -} - - -/* Move COOKIE's file position *POS bytes, according to WHENCE. - The new file position is stored in *POS. - Returns zero if successful, nonzero if not. */ -int -DEFUN(__stdio_seek, (cookie, pos, whence), - PTR cookie AND fpos_t *pos AND int whence) -{ - off_t new; - new = __lseek ((int) cookie, (off_t) *pos, whence); - if (new < 0) - return 1; - *pos = (fpos_t) new; - return 0; -} - - -/* Close COOKIE. */ -int -DEFUN(__stdio_close, (cookie), PTR cookie) -{ - return __close ((int) cookie); -} - -/* Return the POSIX.1 file descriptor associated with COOKIE, - or -1 for errors. If COOKIE does not relate to any POSIX.1 file - descriptor, this should return -1 with errno set to EOPNOTSUPP. */ -int -DEFUN(__stdio_fileno, (cookie), PTR cookie) -{ - return (int) cookie; -} - - -/* Open the given file with the mode given in the __io_mode argument. */ -int -DEFUN(__stdio_open, (filename, m, cookieptr), - CONST char *filename AND __io_mode m AND PTR *cookieptr) -{ - int fd; - int mode; - - if (m.__read && m.__write) - mode = O_RDWR; - else - mode = m.__read ? O_RDONLY : O_WRONLY; - - if (m.__append) - mode |= O_APPEND; - if (m.__exclusive) - mode |= O_EXCL; - if (m.__truncate) - mode |= O_TRUNC; - - if (m.__create) - fd = __open (filename, mode | O_CREAT, - S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH); - else - fd = __open (filename, mode); - - if (fd < 0) - return -1; - - *cookieptr = (PTR) fd; - return 0; -} - - -/* Open FILENAME with the mode in M. Use the same magic cookie - already in *COOKIEPTR if possible, closing the old cookie with CLOSEFN. */ -int -DEFUN(__stdio_reopen, (filename, m, cookieptr), - CONST char *filename AND __io_mode m AND - PTR *cookieptr AND __io_close_fn closefn) -{ - PTR newcookie; - - /* We leave the old descriptor open while we open the file. - That way ``freopen ("/dev/stdin", "r", stdin)'' works. */ - - if (__stdio_open (filename, m, &newcookie)) - { - if (errno == ENFILE || errno == EMFILE) - { - /* We are out of file descriptors. Try closing the old one and - retrying the open. */ - (void) (*closefn) (*cookieptr); - if (__stdio_open (filename, m, &newcookie)) - return -1; - } - } - - if (newcookie != *cookieptr) - { - if (closefn != __stdio_close || - /* Try to move the descriptor to the desired one. */ - __dup2 ((int) newcookie, (int) *cookieptr) < 0) - /* Didn't work. Give the caller the new cookie. */ - *cookieptr = newcookie; - } - - return 0; -} diff -ruN glibc-1.08.1/sysdeps/sparc/divrem.m4 glibc-1.09/sysdeps/sparc/divrem.m4 --- glibc-1.08.1/sysdeps/sparc/divrem.m4 Wed May 12 21:05:03 1993 +++ glibc-1.09/sysdeps/sparc/divrem.m4 Fri Oct 21 13:13:08 1994 @@ -65,7 +65,7 @@ dnl define(DEVELOP_QUOTIENT_BITS, ` ! depth $1, accumulated bits $2 - bl L.$1.eval(2^N+$2) + bl L.$1.eval(2**N+$2) srl V,1,V ! remainder is positive subcc R,V,R @@ -73,7 +73,7 @@ ` b 9f add Q, ($2*2+1), Q ', ` DEVELOP_QUOTIENT_BITS(incr($1), `eval(2*$2+1)')') -L.$1.eval(2^N+$2): +L.$1.eval(2**N+$2): ! remainder is negative addcc R,V,R ifelse($1, N, @@ -94,7 +94,9 @@ ` ! compute sign of result; if neither is negative, no problem orcc divisor, dividend, %g0 ! either negative? bge 2f ! no, go do the divide - xor divisor, dividend, SIGN ! compute sign in any case +ifelse(OP, `div', +` xor divisor, dividend, SIGN ! compute sign in any case', +` mov dividend, SIGN ! sign of remainder matches dividend') tst divisor bge 1f tst dividend @@ -125,7 +127,7 @@ blu Lnot_really_big clr ITER - ! `Here the dividend is >= 2^(31-N) or so. We must be careful here, + ! `Here the dividend is >= 2**(31-N) or so. We must be careful here, ! as our usual N-at-a-shot divide step will cause overflow and havoc. ! The number of bits in the result here is N*ITER+SC, where SC <= N. ! Compute ITER in an unorthodox manner: know we need to shift V into diff -ruN glibc-1.08.1/sysdeps/sparc/rem.S glibc-1.09/sysdeps/sparc/rem.S --- glibc-1.08.1/sysdeps/sparc/rem.S Wed May 12 21:53:12 1993 +++ glibc-1.09/sysdeps/sparc/rem.S Mon Aug 8 17:46:18 1994 @@ -79,7 +79,7 @@ blu Lnot_really_big clr %o4 - ! Here the dividend is >= 2^(31-N) or so. We must be careful here, + ! Here the dividend is >= 2**(31-N) or so. We must be careful here, ! as our usual N-at-a-shot divide step will cause overflow and havoc. ! The number of bits in the result here is N*ITER+SC, where SC <= N. ! Compute ITER in an unorthodox manner: know we need to shift V into @@ -356,10 +356,6 @@ Lgot_result: - ! check to see if answer should be < 0 - tst %g6 - bl,a 1f - sub %g0, %o3, %o3 -1: + retl mov %o3, %o0 diff -ruN glibc-1.08.1/sysdeps/sparc/sdiv.S glibc-1.09/sysdeps/sparc/sdiv.S --- glibc-1.08.1/sysdeps/sparc/sdiv.S Wed May 12 21:53:18 1993 +++ glibc-1.09/sysdeps/sparc/sdiv.S Mon Aug 8 17:46:09 1994 @@ -79,7 +79,7 @@ blu Lnot_really_big clr %o4 - ! Here the dividend is >= 2^(31-N) or so. We must be careful here, + ! Here the dividend is >= 2**(31-N) or so. We must be careful here, ! as our usual N-at-a-shot divide step will cause overflow and havoc. ! The number of bits in the result here is N*ITER+SC, where SC <= N. ! Compute ITER in an unorthodox manner: know we need to shift V into diff -ruN glibc-1.08.1/sysdeps/sparc/udiv.S glibc-1.09/sysdeps/sparc/udiv.S --- glibc-1.08.1/sysdeps/sparc/udiv.S Wed May 12 21:53:15 1993 +++ glibc-1.09/sysdeps/sparc/udiv.S Mon Aug 8 17:46:12 1994 @@ -66,7 +66,7 @@ blu Lnot_really_big clr %o4 - ! Here the dividend is >= 2^(31-N) or so. We must be careful here, + ! Here the dividend is >= 2**(31-N) or so. We must be careful here, ! as our usual N-at-a-shot divide step will cause overflow and havoc. ! The number of bits in the result here is N*ITER+SC, where SC <= N. ! Compute ITER in an unorthodox manner: know we need to shift V into diff -ruN glibc-1.08.1/sysdeps/sparc/urem.S glibc-1.09/sysdeps/sparc/urem.S --- glibc-1.08.1/sysdeps/sparc/urem.S Wed May 12 21:53:07 1993 +++ glibc-1.09/sysdeps/sparc/urem.S Mon Aug 8 17:46:15 1994 @@ -66,7 +66,7 @@ blu Lnot_really_big clr %o4 - ! Here the dividend is >= 2^(31-N) or so. We must be careful here, + ! Here the dividend is >= 2**(31-N) or so. We must be careful here, ! as our usual N-at-a-shot divide step will cause overflow and havoc. ! The number of bits in the result here is N*ITER+SC, where SC <= N. ! Compute ITER in an unorthodox manner: know we need to shift V into diff -ruN glibc-1.08.1/sysdeps/standalone/Dist glibc-1.09/sysdeps/standalone/Dist --- glibc-1.08.1/sysdeps/standalone/Dist Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/standalone/Dist Fri Aug 26 02:15:51 1994 @@ -0,0 +1,2 @@ +filedesc.h +standalone.h diff -ruN glibc-1.08.1/sysdeps/standalone/Subdirs glibc-1.09/sysdeps/standalone/Subdirs --- glibc-1.08.1/sysdeps/standalone/Subdirs Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/standalone/Subdirs Fri Aug 26 01:45:16 1994 @@ -0,0 +1,4 @@ +# The `bare' subdirectory defines some structure for a target-specific +# library of functions which are actually implemented in +# sysdeps/standalone/CPU/TARGET. +bare diff -ruN glibc-1.08.1/sysdeps/standalone/__brk.c glibc-1.09/sysdeps/standalone/__brk.c --- glibc-1.08.1/sysdeps/standalone/__brk.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/standalone/__brk.c Thu Aug 25 14:12:01 1994 @@ -0,0 +1,68 @@ +/* Copyright (C) 1991, 1994 Free Software Foundation, Inc. + Ported to standalone by Joel Sherrill jsherril@redstone-emh2.army.mil, + On-Line Applications Research Corporation. + +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include + +PTR __curbrk; +PTR __rorig; +PTR __rlimit; + +int +DEFUN(__brk, (inaddr), PTR inaddr) +{ + + if ( ( (void *)inaddr > (void *)__rlimit ) || + ( (void *)inaddr < (void *)__rorig ) ) + return -1; + + __curbrk = inaddr; + return 0; +} + +/* Initialization Code for Memory Allocation */ + +PTR __C_heap_start; +int __C_heap_size; + +#ifdef HAVE_GNU_LD +static +#endif +void +DEFUN(__NONE_set_memvals, (argc, argv, envp), + int argc AND char **argv AND char **envp) +{ + + __rorig = + __curbrk = __C_heap_start; + __rlimit = __curbrk + __C_heap_size; + + (void) &__NONE_set_memvals; /* Avoid "defined but not used" warning. */ +} + +#ifdef HAVE_GNU_LD + +#include + +text_set_element (__libc_subinit, __NONE_set_memvals); + +#endif + diff -ruN glibc-1.08.1/sysdeps/standalone/__close.c glibc-1.09/sysdeps/standalone/__close.c --- glibc-1.08.1/sysdeps/standalone/__close.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/standalone/__close.c Fri Aug 26 01:48:26 1994 @@ -0,0 +1,42 @@ +/* Copyright (C) 1994 Free Software Foundation, Inc. + Ported to standalone by Joel Sherrill jsherril@redstone-emh2.army.mil, + On-Line Applications Research Corporation. + +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include + +#include +#include "filedesc.h" + +/* Close the file descriptor FD. */ +int +DEFUN(__close, (fd), int fd) +{ + if ( !__FD_Is_valid( fd ) || !__FD_Table[ fd ].in_use ) + { + errno = EBADF; + return -1; + } + + __FD_Table[ fd ].in_use = 0; + return 0; +} + diff -ruN glibc-1.08.1/sysdeps/standalone/__open.c glibc-1.09/sysdeps/standalone/__open.c --- glibc-1.08.1/sysdeps/standalone/__open.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/standalone/__open.c Fri Aug 26 01:51:31 1994 @@ -0,0 +1,124 @@ +/* Copyright (C) 1994 Free Software Foundation, Inc. + Ported to standalone by Joel Sherrill jsherril@redstone-emh2.army.mil, + On-Line Applications Research Corporation. + +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include +#include +#include + +#include +#include +#include + +#define __DECLARE_FILE_DESCRIPTORS__ + +#include "filedesc.h" + +/* Open FILE with access OFLAG. If OFLAG includes O_CREAT, + a third argument is the file protection. */ +int +DEFUN(__open, (file, oflag), CONST char *file AND int oflag DOTS) +{ + int mode; + int newfd; + int index; + + if (file == NULL) + { + errno = EINVAL; + return -1; + } + + if (oflag & O_CREAT) + { + va_list arg; + va_start(arg, oflag); + mode = va_arg(arg, int); + va_end(arg); + } + + /* + * Find an open slot. + */ + + newfd = -1; + + for ( index=0 ; index< FOPEN_MAX ; index++ ) + if ( !__FD_Table[ index ].in_use ) { + newfd = index; + break; + } + + if ( newfd == -1 ) { + errno = ENFILE; + return -1; + } + + /* + * Initialize the open slot + */ + + __FD_Table[ newfd ].in_use = 1; + __FD_Table[ newfd ].flags = oflag; + + return newfd; +} + +/* Initialization Code for Console I/O */ + +#ifdef HAVE_GNU_LD +static +#endif +void +DEFUN(__NONE_init_console_io, (argc, argv, envp), + int argc AND char **argv AND char **envp) +{ + int index; + + for ( index=0 ; index< FOPEN_MAX ; index++ ) + __FD_Table[ index ].in_use = 0; + + stdin = fopen( "", "r" ); + + stdout = fopen( "", "w" ); + + stderr = fopen( "", "w" ); + + /* + * Line buffer the standard input and output and use no buffering for + * standard error. + */ + + setvbuf( stdin, NULL, _IOLBF, BUFSIZ ); + setvbuf( stdout, NULL, _IOLBF, BUFSIZ ); + setvbuf( stderr, NULL, _IONBF, BUFSIZ ); + + (void) &__NONE_init_console_io; /* Avoid "defined but not used" warning. */ +} + +#ifdef HAVE_GNU_LD + +#include + +text_set_element (__libc_subinit, __NONE_init_console_io); + +#endif diff -ruN glibc-1.08.1/sysdeps/standalone/__read.c glibc-1.09/sysdeps/standalone/__read.c --- glibc-1.08.1/sysdeps/standalone/__read.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/standalone/__read.c Fri Aug 26 01:52:31 1994 @@ -0,0 +1,85 @@ +/* Copyright (C) 1994 Free Software Foundation, Inc. + Ported to standalone by Joel Sherrill jsherril@redstone-emh2.army.mil, + On-Line Applications Research Corporation. + +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include +#include + +#include "filedesc.h" +#include +#include + +/* Read NBYTES into BUF from FD. Return the number read or -1. */ +ssize_t +DEFUN(__read, (fd, buf, nbytes), + int fd AND PTR buf AND size_t nbytes) +{ + char *buffer = (char *) buf; + int data; + int poll; + + errno = 0; + + if (nbytes == 0) + return 0; + + if ( !__FD_Is_valid( fd ) || !__FD_Table[ fd ].in_use ) + { + errno = EBADF; + return -1; + } + if (buf == NULL) + { + errno = EINVAL; + return -1; + } + + if ( __FD_Table[ fd ].flags & O_WRONLY ) /* is it write only? */ + { + errno = EBADF; + return -1; + } + + /* If this is a non-blocking fd, then we want to poll the console. */ + + poll = ( __FD_Table[ fd ].flags & O_NONBLOCK ) ? 1 : 0; + + /* Read a single character. This is a cheap way to insure that the + upper layers get every character because _Console_Getc can't timeout + or otherwise know when to stop. */ + + + data = _Console_Getc(poll); + + if ( data == -1 ) /* if no data return */ + return -1; + + (void) _Console_Putc(data); /* echo the character */ + + if ( data == '\r' ) { /* translate CR -> CR/LF */ + (void) _Console_Putc('\n'); + data = '\n'; + } + + *buffer = data; + return 1; +} diff -ruN glibc-1.08.1/sysdeps/standalone/__write.c glibc-1.09/sysdeps/standalone/__write.c --- glibc-1.08.1/sysdeps/standalone/__write.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/standalone/__write.c Fri Aug 26 02:04:57 1994 @@ -0,0 +1,72 @@ +/* Copyright (C) 1994 Free Software Foundation, Inc. + Ported to standalone by Joel Sherrill jsherril@redstone-emh2.army.mil, + On-Line Applications Research Corporation. + +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include +#include +#include + +#include "filedesc.h" +#include +#include + +/* Write NBYTES of BUF to FD. Return the number written, or -1. */ +ssize_t +DEFUN(__write, (fd, buf, nbytes), + int fd AND CONST PTR buf AND size_t nbytes) +{ + int count; + CONST char *data = buf; + + if (nbytes == 0) + return 0; + if ( !__FD_Is_valid( fd ) || !__FD_Table[ fd ].in_use ) + { + errno = EBADF; + return -1; + } + if (buf == NULL) + { + errno = EINVAL; + return -1; + } + + if ( !(__FD_Table[ fd ].flags & (O_WRONLY|O_RDWR)) ) /* is it writeable? */ + { + errno = EBADF; + return -1; + } + + /* + * All open file descriptors are mapped to the console. + */ + + for ( count=0 ; count != nbytes ; count++ ) { + if ( _Console_Putc(data[ count ]) == -1 ) + return -1; + if ( data[count] == '\n' && _Console_Putc('\r') == -1 ) + return -1; + } + + return count; +} + diff -ruN glibc-1.08.1/sysdeps/standalone/dirstream.h glibc-1.09/sysdeps/standalone/dirstream.h --- glibc-1.08.1/sysdeps/standalone/dirstream.h Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/standalone/dirstream.h Fri Sep 30 17:51:53 1994 @@ -0,0 +1,43 @@ +/* Copyright (C) 1993 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#ifndef _DIRSTREAM_H + +#define _DIRSTREAM_H 1 + +#define __need_size_t +#include + +/* Directory stream type. + + The miscellaneous Unix `readdir' implementations read directory data + into a buffer and fill in a `struct dirent' copy in the `DIR' object. */ + +typedef struct + { + int __fd; /* File descriptor. */ + + char *__data; /* Directory block. */ + size_t __allocation; /* Space allocated for the block. */ + size_t __offset; /* Current offset into the block. */ + size_t __size; /* Total valid data in the block. */ + + struct dirent __entry; /* Returned by `readdir'. */ + } DIR; + +#endif /* dirstream.h */ diff -ruN glibc-1.08.1/sysdeps/standalone/filedesc.h glibc-1.09/sysdeps/standalone/filedesc.h --- glibc-1.08.1/sysdeps/standalone/filedesc.h Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/standalone/filedesc.h Thu Aug 25 14:14:32 1994 @@ -0,0 +1,48 @@ +/* Copyright (C) 1994 Free Software Foundation, Inc. + Ported to standalone by Joel Sherrill jsherril@redstone-emh2.army.mil, + On-Line Applications Research Corporation. + +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +/* + * This is the file descriptor used by the no OS implementation + * of __open, __read, __write, and __close. + */ + +#ifndef __FILEDESC_h +#define __FILEDESC_h + +#include + +#ifndef __DECLARE_FILE_DESCRIPTORS__ +#define FILEDESC_EXTERN extern +#else +#define FILEDESC_EXTERN +#endif + +typedef struct { + int in_use; /* 1 if in use, 0 otherwise */ + int flags; /* Flags from open */ +} __no_os_file_descriptor; + +#define __FD_Is_valid( _fd ) \ + ( (_fd) >= 0 && (_fd) < FOPEN_MAX ) + +FILEDESC_EXTERN __no_os_file_descriptor __FD_Table[ FOPEN_MAX ]; + +#endif diff -ruN glibc-1.08.1/sysdeps/standalone/i386/force_cpu386/Dist glibc-1.09/sysdeps/standalone/i386/force_cpu386/Dist --- glibc-1.08.1/sysdeps/standalone/i386/force_cpu386/Dist Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/standalone/i386/force_cpu386/Dist Tue Nov 1 03:32:25 1994 @@ -0,0 +1 @@ +target.ld diff -ruN glibc-1.08.1/sysdeps/standalone/i386/force_cpu386/Makefile glibc-1.09/sysdeps/standalone/i386/force_cpu386/Makefile --- glibc-1.08.1/sysdeps/standalone/i386/force_cpu386/Makefile Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/standalone/i386/force_cpu386/Makefile Tue Nov 1 01:28:24 1994 @@ -0,0 +1,24 @@ +# Copyright (C) 1994 Free Software Foundation, Inc. +# Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil), +# On-Line Applications Research Corporation. + +# The GNU C Library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Library General Public License +# as published by the Free Software Foundation; either version 2 of +# the License, or (at your option) any later version. + +# The GNU C Library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Library General Public License for more details. + +# You should have received a copy of the GNU Library General Public +# License along with the GNU C Library; see the file COPYING.LIB. If +# not, write to the Free Software Foundation, Inc., 675 Mass Ave, +# Cambridge, MA 02139, USA. + +ifeq (bare,$(subdir)) +install-others += $(libdir)/force_cpu386.ld +$(libdir)/force_cpu386.ld: $(sysdep_dir)/standalone/i386/target.ld + $(do-install) +endif diff -ruN glibc-1.08.1/sysdeps/standalone/i386/force_cpu386/_exit.c glibc-1.09/sysdeps/standalone/i386/force_cpu386/_exit.c --- glibc-1.08.1/sysdeps/standalone/i386/force_cpu386/_exit.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/standalone/i386/force_cpu386/_exit.c Thu Aug 25 14:07:56 1994 @@ -0,0 +1,47 @@ +/* Copyright (C) 1991 Free Software Foundation, Inc. + Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil), + On-Line Applications Research Corporation. + +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include + +/* This returns control to FORCEbug. */ + +void DEFUN_VOID(Bsp_cleanup); + +/* The function `_exit' should take a status argument and simply + terminate program execution, using the low-order 8 bits of the + given integer as status. */ + +__NORETURN void +DEFUN(_exit, (status), int status) +{ + /* status is ignored */ + Bsp_cleanup(); +} + +#ifdef HAVE_GNU_LD + +#include + +stub_warning(_exit); + +#endif /* GNU stabs. */ diff -ruN glibc-1.08.1/sysdeps/standalone/i386/force_cpu386/brdinit.c glibc-1.09/sysdeps/standalone/i386/force_cpu386/brdinit.c --- glibc-1.08.1/sysdeps/standalone/i386/force_cpu386/brdinit.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/standalone/i386/force_cpu386/brdinit.c Wed Aug 24 19:57:04 1994 @@ -0,0 +1,44 @@ +/* Copyright (C) 1994 Free Software Foundation, Inc. + Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil), + On-Line Applications Research Corporation. + +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include "__i386.h" + +/* _Board_Initialize() + +This routine initializes the FORCE CPU386 board. */ + +void DEFUN_VOID(_Console_Initialize); + +void +DEFUN_VOID(_Board_Initialize) +{ + /* + * FORCE documentation incorrectly states that the bus request + * level is initialized to 3. It is actually initialized by + * FORCEbug to 0. + */ + + outport_byte( 0x00, 0x3f ); /* resets VMEbus request level */ + + _Console_Initialize(); +} diff -ruN glibc-1.08.1/sysdeps/standalone/i386/force_cpu386/console.c glibc-1.09/sysdeps/standalone/i386/force_cpu386/console.c --- glibc-1.08.1/sysdeps/standalone/i386/force_cpu386/console.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/standalone/i386/force_cpu386/console.c Wed Aug 24 20:00:31 1994 @@ -0,0 +1,163 @@ +/* Copyright (C) 1994 Free Software Foundation, Inc. + Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil), + On-Line Applications Research Corporation. + +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include "__i386.h" + +/* Console IO routines for a FORCE CPU386 board. */ + +/* Force CPU/386 specific IO addressing + * + * The following determines whether Port B or the Console should + * be used for console I/O. Setting ONE (and only ONE) of these to 1 + * enables I/O on that port. + * + * PORT A - DUSCC MC68562 Channel A (*** not supported here ***) + * PORT B - DUSCC MC68562 Channel B + * PORT C - MFP MC68901 Channel (*** FORCEbug console ***) + */ + +#define PORTB 1 /* use port b as console */ +#define PORTC 0 /* use console port as console */ + +#if ( PORTB == 1 ) +#define TX_STATUS 0x1b6 /* DUSCC General Status Register */ +#define RX_STATUS 0x1b6 /* DUSCC General Status Register */ +#define TX_BUFFER 0x1e0 /* DUSCC Transmitter Channel B */ +#define RX_BUFFER 0x1e8 /* DUSCC Receiver Channel B */ +#define Is_tx_ready( _status ) ( (_status) & 0x20 ) +#define Is_rx_ready( _status ) ( (_status) & 0x10 ) +#endif + +#if ( PORTC == 1 ) +#define TX_STATUS 0x12c /* MFP Transmit Status Register */ +#define RX_STATUS 0x12a /* MFP Receive Status Register */ +#define TX_BUFFER 0x12e /* MFP Transmitter Channel */ +#define RX_BUFFER 0x12e /* MFP Receiver Channel */ +#define Is_tx_ready( _status ) ( (_status) & 0x80 ) +#define Is_rx_ready( _status ) ( (_status) & 0x80 ) +#endif + +/* _Console_Initialize + +On the Force board the console require some initialization. */ + +void +DEFUN_VOID(_Console_Initialize) +{ + register unsigned8 ignored; + + /* FORCE technical support mentioned that it may be necessary to + read the DUSCC RX_BUFFER port four times to remove all junk. + This code is a little more paranoid. */ + + inport_byte( RX_BUFFER, ignored ); + inport_byte( RX_BUFFER, ignored ); + inport_byte( RX_BUFFER, ignored ); + inport_byte( RX_BUFFER, ignored ); + inport_byte( RX_BUFFER, ignored ); +} + +/* Miscellaneous support for console IO */ + +static inline int _Force386_is_rx_ready() +{ + register unsigned8 status; + + inport_byte( RX_STATUS, status ); + + if ( Is_rx_ready( status ) ) return 1; + else return 0; +} + +static inline int _Force386_is_tx_ready() +{ + register unsigned8 status; + + inport_byte( TX_STATUS, status ); + + if ( Is_tx_ready( status ) ) return 1; + else return 0; +} + + +static inline int _Force386_read_data() +{ + register unsigned8 ch; + +#if ( PORTB == 1 ) + /* Force example code resets the Channel B Receiver here. + * It appears to cause XON's to be lost. + */ + + /* outport_byte( RX_STATUS, 0x10 ); */ +#endif + + inport_byte( RX_BUFFER, ch ); + + return ch; +} + +/* _Console_Putc + +This routine transmits a character. It supports XON/XOFF flow control. */ + +#define XON 0x11 /* control-Q */ +#define XOFF 0x13 /* control-S */ + +int +DEFUN( _Console_Putc, (ch), char ch ) +{ + register unsigned8 inch; + + while ( !_Force386_is_tx_ready() ); + + while ( _Force386_is_rx_ready() == 1 ) { /* must be an XOFF */ + inch = _Force386_read_data(); + if ( inch == XOFF ) + do { + while ( _Force386_is_rx_ready() == 0 ); + inch = _Force386_read_data(); + } while ( inch != XON ); + } + + outport_byte( TX_BUFFER, ch ); + return( 0 ); +} + +/* _Console_Getc + +This routine reads a character from the UART and returns it. */ + +int +DEFUN( _Console_Getc, (poll), int poll ) +{ + if ( poll ) { + if ( !_Force386_is_rx_ready() ) + return -1; + else + return _Force386_read_data(); + } else { + while ( !_Force386_is_rx_ready() ); + return _Force386_read_data(); + } +} diff -ruN glibc-1.08.1/sysdeps/standalone/i386/force_cpu386/strtsupp.S glibc-1.09/sysdeps/standalone/i386/force_cpu386/strtsupp.S --- glibc-1.08.1/sysdeps/standalone/i386/force_cpu386/strtsupp.S Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/standalone/i386/force_cpu386/strtsupp.S Thu Aug 25 13:35:18 1994 @@ -0,0 +1,89 @@ +/* Copyright (C) 1994 Free Software Foundation, Inc. + Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil), + On-Line Applications Research Corporation. + +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +/* This file assists the board independent startup code by + * loading the proper segment register values. The values + * loaded are dependent on the FORCEBUG. + * + * NOTE: No stack has been established when this routine + * is invoked. It returns by jumping back to the start code. + * + */ + +/* + * FORCEBUG loads us into a virtual address space which + * really starts at PHYSICAL_ADDRESS_BASE. + * + */ + +.set PHYSICAL_ADDRESS_BASE, 0x00002000 + +/* + * At reset time, FORCEBUG normally has the segment selectors preloaded. + * If a human resets the instruction pointer, this will not have occurred. + * However, no guarantee can be made of the other registers if cs:ip was + * modified to restart the program. Because of this, the BSP reloads all + * segment registers (except cs) with the values they have following + * a reset. + */ + + +.set RESET_SS, 0x40 # initial value of stack segment register +.set RESET_DS, 0x40 # initial value of data segment register +.set RESET_ES, 0x40 # initial value of extra segment register +.set RESET_FS, 0x40 # initial value of "f" segment register +.set RESET_GS, 0x30 # initial value of "g" segment register + + +#define LOAD_SEGMENTS(_value,_segreg) \ + movw $_value##,%ax ; \ + movw %ax,##_segreg + + + .global _load_segments + + .global _establish_stack + +_load_segments: + + LOAD_SEGMENTS( RESET_SS, %ss ) + LOAD_SEGMENTS( RESET_DS, %ds ) + LOAD_SEGMENTS( RESET_ES, %es ) + LOAD_SEGMENTS( RESET_FS, %fs ) + LOAD_SEGMENTS( RESET_GS, %gs ) + + jmp _establish_stack # return to the bsp entry code + + .global _return_to_monitor +_return_to_monitor: + + movb $0,%al + int $0x20 # restart FORCEbug + jmp start # FORCEbug does not reset PC + + .data + + .global _Do_Load_IDT +_Do_Load_IDT: .byte 1 + + .global _Do_Load_GDT +_Do_Load_GDT: .byte 0 + diff -ruN glibc-1.08.1/sysdeps/standalone/i386/force_cpu386/target.ld glibc-1.09/sysdeps/standalone/i386/force_cpu386/target.ld --- glibc-1.08.1/sysdeps/standalone/i386/force_cpu386/target.ld Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/standalone/i386/force_cpu386/target.ld Tue Sep 13 13:09:48 1994 @@ -0,0 +1,59 @@ +/* Copyright (C) 1994 Free Software Foundation, Inc. + Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil), + On-Line Applications Research Corporation. + +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +/* This file contains directives for the GNU linker which are specific +to the FORCE CPU386 board. */ + +MEMORY + { + ram : org = 0x0, l = 1M + } + +/* This value is also when the space is allocated. If you change +this one, change the other one!!! */ + +heap_size = 0x20000; + +SECTIONS +{ + .text 0x0 : + { + _text_start = ABSOLUTE(.) ; + *(.text) + _etext = ALIGN( 0x10 ) ; + } + .data ADDR( .text ) + SIZEOF( .text ): + { + _data_start = . ; + *(.data) + _edata = ALIGN( 0x10 ) ; + } + .bss ADDR( .data ) + SIZEOF( .data ): + { + _bss_start = . ; + *(.bss) + *(COMMON) + heap_memory = .; + . += 0x20000; + _end = . ; + __end = . ; + } +} diff -ruN glibc-1.08.1/sysdeps/standalone/i386/start.S glibc-1.09/sysdeps/standalone/i386/start.S --- glibc-1.08.1/sysdeps/standalone/i386/start.S Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/standalone/i386/start.S Thu Aug 25 09:55:25 1994 @@ -0,0 +1,323 @@ +/* Copyright (C) 1994 Free Software Foundation, Inc. + Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil), + On-Line Applications Research Corporation. + +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +/* entry.s + * + * This file contains the entry point for the application. + * The name of this entry point is compiler dependent. + * It jumps to the BSP which is responsible for performing + * all initialization. + * + */ + + .data + .global _Do_Load_IDT + .global _Do_Load_GDT + + .text + .global start # GNU default entry point + .global _establish_stack + + .global _bsp_start + .global _load_segments + .global __exit + +start: + nop + cli # DISABLE INTERRUPTS!!! +# +# Load the segment registers +# +# NOTE: Upon return, gs will contain the segment descriptor for +# a segment which maps directly to all of physical memory. +# + jmp _load_segments # load board dependent segments + +# +# Set up the stack +# + +_establish_stack: + + movl $stack_end,%esp # set stack pointer + movl $stack_end,%ebp # set base pointer + +# +# Zero out the BSS segment +# +zero_bss: + cld # make direction flag count up + movl $_end,%ecx # find end of .bss + movl $_bss_start,%edi # edi = beginning of .bss + subl %edi,%ecx # ecx = size of .bss in bytes + shrl $2,%ecx # size of .bss in longs + xorl %eax,%eax # value to clear out memory + repne # while ecx != 0 + stosl # clear a long in the bss + +# +# Set the C heap information for malloc +# + movl $heap_size,___C_heap_size # set ___C_heap_size + movl $heap_memory,___C_heap_start # set ___C_heap_start + +# +# Copy the Global Descriptor Table to our space +# + + sgdt _Original_GDTR # save original GDT + movzwl _Original_GDTR_limit,%ecx # size of GDT in bytes; limit + # is 8192 entries * 8 bytes per + + # make ds:esi point to the original GDT + + movl _Original_GDTR_base,%esi + push %ds # save ds + movw %gs,%ax + movw %ax,%ds + + # make es:edi point to the new (our copy) GDT + movl $_Global_descriptor_table,%edi + + rep + movsb # copy the GDT (ds:esi -> es:edi) + + pop %ds # restore ds + + # Build and load new contents of GDTR + movw _Original_GDTR_limit,%ecx # set new limit + movw %cx,_New_GDTR_limit + + push $_Global_descriptor_table + push %es + call _Logical_to_physical + addl $6,%esp + movl %eax,_New_GDTR_base # set new base + + cmpb $0,_Do_Load_GDT # Should the new GDT be loaded? + je no_gdt_load # NO, then branch + lgdt _New_GDTR # load the new GDT +no_gdt_load: + +# +# Copy the Interrupt Descriptor Table to our space +# + + sidt _Original_IDTR # save original IDT + movzwl _Original_IDTR_limit,%ecx # size of IDT in bytes; limit + # is 256 entries * 8 bytes per + + + # make ds:esi point to the original IDT + movl _Original_IDTR_base,%esi + + push %ds # save ds + movw %gs,%ax + movw %ax,%ds + + # make es:edi point to the new (our copy) IDT + movl $_Interrupt_descriptor_table,%edi + + rep + movsb # copy the IDT (ds:esi -> es:edi) + pop %ds # restore ds + + # Build and load new contents of IDTR + movw _Original_IDTR_limit,%ecx # set new limit + movw %cx,_New_IDTR_limit + + push $_Interrupt_descriptor_table + push %es + call _Logical_to_physical + addl $6,%esp + movl %eax,_New_IDTR_base # set new base + + cmpb $0,_Do_Load_IDT # Should the new IDT be loaded? + je no_idt_load # NO, then branch + lidt _New_IDTR # load the new IDT +no_idt_load: + +# +# Initialize the i387. +# +# Using the NO WAIT form of the instruction insures that if +# it is not present the board will not lock up or get an +# exception. +# + + fninit # MUST USE NO-WAIT FORM + + call __Board_Initialize # initialize the board + + pushl $0 # envp = NULL + pushl $0 # argv = NULL + pushl $0 # argc = NULL + call ___libc_init # initialize the library and + # call main + addl $12,%esp + + pushl $0 # argc = NULL + call __exit # call the Board specific exit + addl $4,%esp + +# +# Clean up +# + + + .global _Bsp_cleanup + + .global _return_to_monitor + +_Bsp_cleanup: + cmpb $0,_Do_Load_IDT # Was the new IDT loaded? + je no_idt_restore # NO, then branch + lidt _Original_IDTR # restore the new IDT +no_idt_restore: + + cmpb $0,_Do_Load_GDT # Was the new GDT loaded? + je no_gdt_restore # NO, then branch + lgdt _Original_GDTR # restore the new GDT +no_gdt_restore: + jmp _return_to_monitor + +# +# void *Logical_to_physical( +# rtems_unsigned16 segment, +# void *address +# ); +# +# Returns thirty-two bit physical address for segment:address. +# + + .global _Logical_to_physical + +.set SEGMENT_ARG, 4 +.set ADDRESS_ARG, 8 + +_Logical_to_physical: + + xorl %eax,%eax # clear eax + movzwl SEGMENT_ARG(%esp),%ecx # ecx = segment value + movl $_Global_descriptor_table,%edx # edx = address of our GDT + addl %ecx,%edx # edx = address of desired entry + movb 7(%edx),%ah # ah = base 31:24 + movb 4(%edx),%al # al = base 23:16 + shll $16,%eax # move ax into correct bits + movw 2(%edx),%ax # ax = base 0:15 + movl ADDRESS_ARG(%esp),%ecx # ecx = address to convert + addl %eax,%ecx # ecx = physical address equivalent + movl %ecx,%eax # eax = ecx + ret + +# +# void *Physical_to_logical( +# rtems_unsigned16 segment, +# void *address +# ); +# +# Returns thirty-two bit physical address for segment:address. +# + + .global _Physical_to_logical + +#.set SEGMENT_ARG, 4 +#.set ADDRESS_ARG, 8 -- use sets from above + +_Physical_to_logical: + + xorl %eax,%eax # clear eax + movzwl SEGMENT_ARG(%esp),%ecx # ecx = segment value + movl $_Global_descriptor_table,%edx # edx = address of our GDT + addl %ecx,%edx # edx = address of desired entry + movb 7(%edx),%ah # ah = base 31:24 + movb 4(%edx),%al # al = base 23:16 + shll $16,%eax # move ax into correct bits + movw 2(%edx),%ax # ax = base 0:15 + movl ADDRESS_ARG(%esp),%ecx # ecx = address to convert + subl %eax,%ecx # ecx = logical address equivalent + movl %ecx,%eax # eax = ecx + ret + + +/* + * Data Declarations. Start with a macro which helps declare space. + */ + + .bss + +#define DECLARE_SPACE(_name,_space,_align) \ + .globl _name ; \ + .align _align ; \ +_name##: .space _space + +#define DECLARE_LABEL(_name) \ + .globl _name ; \ +_name##: + +#define DECLARE_PTR(_name) DECLARE_SPACE(_name,4,2) +#define DECLARE_U32(_name) DECLARE_SPACE(_name,4,2) +#define DECLARE_U16(_name) DECLARE_SPACE(_name,2,1) + +/* + * Require environment stuff + */ + +DECLARE_LABEL(_environ) +DECLARE_PTR(environ) + +DECLARE_LABEL(_errno) +DECLARE_U32(errno) + +/* + * Miscellaneous Variables used to restore the CPU state. + * + * Start with a macro to declare the space for the contents of + * a Descriptor Table register. + */ + +#define DECLARE_DTR_SPACE(_name) \ + .global _name ; \ + .align 4 ; \ +_name##: ; \ +_name##_limit: .space 2 ; \ +_name##_base: .space 4 + +DECLARE_SPACE(_Interrupt_descriptor_table,256*8,4) +DECLARE_SPACE(_Global_descriptor_table,8192*8,4) + +DECLARE_DTR_SPACE(_Original_IDTR) +DECLARE_DTR_SPACE(_New_IDTR) +DECLARE_DTR_SPACE(_Original_GDTR) +DECLARE_DTR_SPACE(_New_GDTR) + +DECLARE_SPACE(_Physical_base_of_ds,4,4) +DECLARE_SPACE(_Physical_base_of_cs,4,4) + +/* + * Stack Size and Space + */ + + .set stack_size, 0x20000 + +DECLARE_SPACE(stack_memory,stack_size,4) +DECLARE_LABEL(stack_end) + diff -ruN glibc-1.08.1/sysdeps/standalone/i960/Dist glibc-1.09/sysdeps/standalone/i960/Dist --- glibc-1.08.1/sysdeps/standalone/i960/Dist Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/standalone/i960/Dist Thu Sep 15 22:14:30 1994 @@ -0,0 +1 @@ +i960ca.h diff -ruN glibc-1.08.1/sysdeps/standalone/i960/i960ca.h glibc-1.09/sysdeps/standalone/i960/i960ca.h --- glibc-1.08.1/sysdeps/standalone/i960/i960ca.h Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/standalone/i960/i960ca.h Tue Sep 13 15:28:54 1994 @@ -0,0 +1,207 @@ +/* Copyright (C) 1994 Free Software Foundation, Inc. + Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil), + On-Line Applications Research Corporation. + +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +/* i960ca.h + * + * This file contains macros which are used to access i80960CA + * registers which are not addressable by C. The functions + * in this file sould be useful to the developer of target + * specific code. + */ + +#ifndef i960ca_h__ +#define i960ca_h__ + +typedef unsigned char unsigned8; +typedef unsigned short unsigned16; +typedef unsigned int unsigned32; + +/* + * Intel i80960CA Processor Control Block + */ + +struct i80960ca_prcb { + unsigned32 *fault_tbl; /* fault table base address */ + struct i80960ca_ctltbl + *control_tbl; /* control table base address */ + unsigned32 initial_ac; /* AC register initial value */ + unsigned32 fault_config; /* fault configuration word */ + void *intr_tbl; /* interrupt table base address */ + void *sys_proc_tbl; /* system procedure table */ + /* base address */ + unsigned32 reserved; /* reserved */ + unsigned32 *intr_stack; /* interrupt stack pointer */ + unsigned32 ins_cache_cfg; /* instruction cache */ + /* configuration word */ + unsigned32 reg_cache_cfg; /* register cache */ + /* configuration word */ +}; + +/* + * Intel i80960CA Control Table + */ + +struct i80960ca_ctltbl { + /* Control Group 0 */ + unsigned32 ipb0; /* IP breakpoint 0 */ + unsigned32 ipb1; /* IP breakpoint 1 */ + unsigned32 dab0; /* data address breakpoint 0 */ + unsigned32 dab1; /* data address breakpoint 1 */ + /* Control Group 1 */ + unsigned32 imap0; /* interrupt map 0 */ + unsigned32 imap1; /* interrupt map 1 */ + unsigned32 imap2; /* interrupt map 2 */ + unsigned32 icon; /* interrupt control */ + /* Control Group 2 */ + unsigned32 mcon0; /* memory region 0 configuration */ + unsigned32 mcon1; /* memory region 1 configuration */ + unsigned32 mcon2; /* memory region 2 configuration */ + unsigned32 mcon3; /* memory region 3 configuration */ + /* Control Group 3 */ + unsigned32 mcon4; /* memory region 4 configuration */ + unsigned32 mcon5; /* memory region 5 configuration */ + unsigned32 mcon6; /* memory region 6 configuration */ + unsigned32 mcon7; /* memory region 7 configuration */ + /* Control Group 4 */ + unsigned32 mcon8; /* memory region 8 configuration */ + unsigned32 mcon9; /* memory region 9 configuration */ + unsigned32 mcon10; /* memory region 10 configuration */ + unsigned32 mcon11; /* memory region 11 configuration */ + /* Control Group 5 */ + unsigned32 mcon12; /* memory region 12 configuration */ + unsigned32 mcon13; /* memory region 13 configuration */ + unsigned32 mcon14; /* memory region 14 configuration */ + unsigned32 mcon15; /* memory region 15 configuration */ + /* Control Group 6 */ + unsigned32 bpcon; /* breakpoint control */ + unsigned32 tc; /* trace control */ + unsigned32 bcon; /* bus configuration control */ + unsigned32 reserved; /* reserved */ +}; + +#define disable_intr( oldlevel ) \ + { (oldlevel) = 0x1f0000; \ + asm volatile ( "modpc 0,%1,%1" \ + : "=d" ((oldlevel)) \ + : "0" ((oldlevel)) ); \ + } + +#define enable_intr( oldlevel ) \ + { unsigned32 _mask = 0x1f0000; \ + asm volatile ( "modpc 0,%0,%1" \ + : "=d" (_mask), "=d" ((oldlevel)) \ + : "0" (_mask), "1" ((oldlevel)) ); \ + } + +#define flash_intr( oldlevel ) \ + { unsigned32 _mask = 0x1f0000; \ + asm volatile ( "modpc 0,%0,%1 ; \ + mov %0,%1 ; \ + modpc 0,%0,%1" \ + : "=d" (_mask), "=d" ((oldlevel)) \ + : "0" (_mask), "1" ((oldlevel)) ); \ + } + +#define atomic_modify( mask, addr, prev ) \ + { register unsigned32 _mask = (mask); \ + register unsigned32 *_addr = (unsigned32 *)(addr); \ + asm volatile( "atmod %0,%1,%1" \ + : "=d" (_addr), "=d" (_mask) \ + : "0" (_addr), "1" (_mask) ); \ + (prev) = _mask; \ + } + +#define delay( microseconds ) \ + { register unsigned32 _delay=(microseconds); \ + register unsigned32 _tmp; \ + asm volatile( "delay0: \ + remo 3,31,%0 ; \ + cmpo 0,%0 ; \ + subo 1,%1,%1 ; \ + cmpobne.t 0,%1,delay0 " \ + : "=d" (_tmp), "=d" (_delay) \ + : "0" (_tmp), "1" (_delay) ); \ + } + +#define enable_tracing() \ + { register unsigned32 _pc = 0x1; \ + asm volatile( "modpc 0,%0,%0" : "=d" (_pc) : "0" (_pc) ); \ + } + +#define unmask_intr( xint ) \ + { register unsigned32 _mask= (1<<(xint)); \ + asm volatile( "or sf1,%0,sf1" : "=d" (_mask) : "0" (_mask) ); \ + } + +#define mask_intr( xint ) \ + { register unsigned32 _mask= (1<<(xint)); \ + asm volatile( "andnot %0,sf1,sf1" : "=d" (_mask) : "0" (_mask) ); \ + } + +#define clear_intr( xint ) \ + { register unsigned32 _xint=(xint); \ + asm volatile( "loop_til_cleared: + clrbit %0,sf0,sf0 ; \ + bbs %0,sf0,loop_til_cleared" \ + : "=d" (_xint) : "0" (_xint) ); \ + } + +#define reload_ctl_group( group ) \ + { register int _cmd = ((group)|0x400) ; \ + asm volatile( "sysctl %0,%0,%0" : "=d" (_cmd) : "0" (_cmd) ); \ + } + +#define cause_intr( intr ) \ + { register int _intr = (intr); \ + asm volatile( "sysctl %0,%0,%0" : "=d" (_intr) : "0" (_intr) ); \ + } + +#define soft_reset( prcb ) \ + { register struct i80960ca_prcb *_prcb = (prcb); \ + register unsigned32 *_next=0; \ + register unsigned32 _cmd = 0x30000; \ + asm volatile( "lda next,%1; \ + sysctl %0,%1,%2; \ + next: mov g0,g0" \ + : "=d" (_cmd), "=d" (_next), "=d" (_prcb) \ + : "0" (_cmd), "1" (_next), "2" (_prcb) ); \ + } + +static inline unsigned32 pend_intrs() +{ register unsigned32 _intr=0; + asm volatile( "mov sf0,%0" : "=d" (_intr) : "0" (_intr) ); + return ( _intr ); +} + +static inline unsigned32 mask_intrs() +{ register unsigned32 _intr=0; + asm volatile( "mov sf1,%0" : "=d" (_intr) : "0" (_intr) ); + return( _intr ); +} + +static inline unsigned32 get_fp() +{ register unsigned32 _fp=0; + asm volatile( "mov fp,%0" : "=d" (_fp) : "0" (_fp) ); + return ( _fp ); +} + +#endif +/* end of include file */ diff -ruN glibc-1.08.1/sysdeps/standalone/i960/nindy960/Makefile glibc-1.09/sysdeps/standalone/i960/nindy960/Makefile --- glibc-1.08.1/sysdeps/standalone/i960/nindy960/Makefile Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/standalone/i960/nindy960/Makefile Thu Aug 25 13:29:20 1994 @@ -0,0 +1,23 @@ +# Copyright (C) 1993 Free Software Foundation, Inc. +# Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil), +# On-Line Applications Research Corporation. + +# The GNU C Library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Library General Public License +# as published by the Free Software Foundation; either version 2 of +# the License, or (at your option) any later version. + +# The GNU C Library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Library General Public License for more details. + +# You should have received a copy of the GNU Library General Public +# License along with the GNU C Library; see the file COPYING.LIB. If +# not, write to the Free Software Foundation, Inc., 675 Mass Ave, +# Cambridge, MA 02139, USA. + + +# The nindy960 support has only been tested on the following boards: +# +# + Cyclone CVME961 VMEbus single board computer. diff -ruN glibc-1.08.1/sysdeps/standalone/i960/nindy960/_exit.c glibc-1.09/sysdeps/standalone/i960/nindy960/_exit.c --- glibc-1.08.1/sysdeps/standalone/i960/nindy960/_exit.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/standalone/i960/nindy960/_exit.c Thu Aug 25 13:36:15 1994 @@ -0,0 +1,55 @@ +/* Copyright (C) 1991 Free Software Foundation, Inc. + Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil), + On-Line Applications Research Corporation. + +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include + +/* The function `_exit' should take a status argument and simply + terminate program execution, using the low-order 8 bits of the + given integer as status. */ + +/* This returns control to Nindy. */ + +__NORETURN void +DEFUN(_exit, (status), int status) +{ + /* status is ignored */ + + asm volatile( "mov 0,g0; \ + fmark ; \ + syncf ; \ + .word 0xfeedface ; \ + bx start" : : ); + /* The constant 0xfeedface is a magic word for break which + * is defined by NINDY. The branch extended restarts the + * application if the user types "go". + */ +} + + +#ifdef HAVE_GNU_LD + +#include + +stub_warning(_exit); + +#endif /* GNU stabs. */ diff -ruN glibc-1.08.1/sysdeps/standalone/i960/nindy960/brdinit.c glibc-1.09/sysdeps/standalone/i960/nindy960/brdinit.c --- glibc-1.08.1/sysdeps/standalone/i960/nindy960/brdinit.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/standalone/i960/nindy960/brdinit.c Wed Aug 24 20:09:09 1994 @@ -0,0 +1,66 @@ +/* Copyright (C) 1994 Free Software Foundation, Inc. + Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil), + On-Line Applications Research Corporation. + +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include "__i960ca.h" + +/* _Board_Initialize() + +This routine initializes the board. + +NOTE: Only tested on a Cyclone CVME961 but should be OK on any i960ca board. */ + +void +DEFUN_VOID(_Board_Initialize) +{ + struct i80960ca_prcb *prcb; /* ptr to processor control block */ + struct i80960ca_ctltbl *ctl_tbl; /* ptr to control table */ + + static inline struct i80960ca_prcb *get_prcb() + { register struct i80960ca_prcb *_prcb = 0; + asm volatile( "calls 5; \ + mov g0,%0" \ + : "=d" (_prcb) \ + : "0" (_prcb) ); + return ( _prcb ); + } + + prcb = get_prcb(); + ctl_tbl = prcb->control_tbl; + + /* The following configures the data breakpoint (which must be set + * before this is executed) to break on writes only. + */ + + ctl_tbl->bpcon &= ~0x00cc0000; + reload_ctl_group( 6 ); + + /* bit 31 of the Register Cache Control can be set to + * enable an alternative caching algorithm. It does + * not appear to help our applications. + */ + + /* Configure Number of Register Caches */ + + prcb->reg_cache_cfg = 8; + soft_reset( prcb ); +} diff -ruN glibc-1.08.1/sysdeps/standalone/i960/nindy960/console.c glibc-1.09/sysdeps/standalone/i960/nindy960/console.c --- glibc-1.08.1/sysdeps/standalone/i960/nindy960/console.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/standalone/i960/nindy960/console.c Thu Aug 25 10:43:19 1994 @@ -0,0 +1,76 @@ +/* Copyright (C) 1994 Free Software Foundation, Inc. + Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil), + On-Line Applications Research Corporation. + +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include "__i960ca.h" + +/* Console IO routines for a NINDY960 board. */ + +/* + * NINDY_IO( ... ) + * + * Interface to NINDY. + */ + +#define NINDY_INPUT 0 +#define NINDY_OUTPUT 1 + +void ___NINDY_IO_WRAPPER( void ) /* never called */ +{ + asm volatile ( " .text" ); + asm volatile ( " .align 4" ); + asm volatile ( " .globl _NINDY_IO" ); + asm volatile ( "_NINDY_IO:" ); + asm volatile ( " calls 0 /* call console routines */" ); + asm volatile ( " ret" ); +} + +/***** !!!! HOW DO I EXFUN NINDY_IO? !!!! *****/ + +/* _Console_Putc + +This routine transmits a character using NINDY. */ + +int +DEFUN( _Console_Putc, (ch), char ch ) +{ + NINDY_IO( NINDY_OUTPUT, ch ); + return( 0 ); +} + +/* _Console_Getc + +This routine reads a character from NINDY and returns it. */ + +int +DEFUN( _Console_Getc, (poll), int poll ) +{ + char ch; + + if ( poll ) { + /* I don't know how to poll with NINDY */ + return -1; + } else { + NINDY_IO( NINDY_INPUT, &ch ); + return ch; + } +} diff -ruN glibc-1.08.1/sysdeps/standalone/i960/start.S glibc-1.09/sysdeps/standalone/i960/start.S --- glibc-1.08.1/sysdeps/standalone/i960/start.S Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/standalone/i960/start.S Sun Aug 28 04:13:00 1994 @@ -0,0 +1,137 @@ +/* Copyright (C) 1994 Free Software Foundation, Inc. + Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil), + On-Line Applications Research Corporation. + +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +/* entry.s + * + * This file contains the entry point for the application. + * The name of this entry point is compiler dependent. + * It jumps to the BSP which is responsible for performing + * all initialization. + * + */ + + .text + .globl start # GNU960 default entry point + +start: + mov 3, r12 + modpc r12, r12, r12 # enable tracing/trace faults + mov g5, g5 # NOP + mov 0, g14 # initialize constant for C + + /* + * zero out uninitialized data area + */ +zerobss: + lda _end, r4 /* find end of .bss */ + lda _bss_start, r5 /* find beginning of .bss */ + ldconst 0, r6 + +loop: st r6, (r5) /* to zero out uninitialized */ + addo 4, r5, r5 /* data area */ + cmpobl r5, r4, loop /* loop until _end reached */ + + + lda heap_memory, r12 /* tell C lib where heap is */ + st r12,___C_heap_start + lda heap_size, r12 /* tell C lib how big heap is */ + st r12,___C_heap_size + lda stack_memory,r12 /* set up stack pointer: */ + mov r12, sp + mov 0, g14 /* initialize constant for C */ + + call init_frames + ret /* return to monitor */ + +init_frames: + ldconst 0x3b001000, g0 + ldconst 0x00009107, g1 + modac g1, g0, g0 /* set AC controls */ + + /* + * Call application mainline. + * Someday, real values of argc and argv will be set up. + * For now, they are set to 0. + */ + + callx __Board_Initialize /* Initialize the board */ + + ldconst 0,g0 + ldconst 0,g1 + ldconst 0,g2 + callx ___libc_init /* initialize the library and */ + /* call main */ + /* + * if we return from main, we have "fallen" off the end + * of the program, therefore status is 0 + * so move 0 to g0 (exit parameter) + */ + + mov 0, g0 + callx __exit + ret + + +/* + * Data Declarations. Start with a macro which helps declare space. + */ + +#define DECLARE_SPACE(_name,_space,_align) \ + .globl _name ; \ + .align _align ; \ +.comm _name##,_space + +#define DECLARE_LABEL(_name) \ + .globl _name ; \ +_name##: + +#define DECLARE_PTR(_name) DECLARE_SPACE(_name,4,2) +#define DECLARE_U32(_name) DECLARE_SPACE(_name,4,2) +#define DECLARE_U16(_name) DECLARE_SPACE(_name,2,1) + +/* + * Require environment stuff + */ + +DECLARE_LABEL(_environ) +DECLARE_PTR(environ) + +DECLARE_LABEL(_errno) +DECLARE_U32(errno) + +/* + * Stack Size and Space + */ + + .set stack_size, 0x20000 + +DECLARE_SPACE(stack_memory,stack_size,4) +DECLARE_LABEL(stack_end) + +/* + * Heap Size and Space + */ + + .set heap_size, 0x20000 + +DECLARE_SPACE(heap_memory,heap_size,4) +DECLARE_LABEL(heap_end) + diff -ruN glibc-1.08.1/sysdeps/standalone/m68k/m68020/Dist glibc-1.09/sysdeps/standalone/m68k/m68020/Dist --- glibc-1.08.1/sysdeps/standalone/m68k/m68020/Dist Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/standalone/m68k/m68020/Dist Thu Sep 15 22:14:07 1994 @@ -0,0 +1 @@ +m68020.h diff -ruN glibc-1.08.1/sysdeps/standalone/m68k/m68020/m68020.h glibc-1.09/sysdeps/standalone/m68k/m68020/m68020.h --- glibc-1.08.1/sysdeps/standalone/m68k/m68020/m68020.h Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/standalone/m68k/m68020/m68020.h Tue Sep 13 12:26:18 1994 @@ -0,0 +1,88 @@ +/* Copyright (C) 1994 Free Software Foundation, Inc. + Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil), + On-Line Applications Research Corporation. + +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +/* m68020.h + * + * This file contains macros which are used to access MC68020 + * registers which are not addressable by C. These are + * useful when developing the board specific support. + */ + +#ifndef m68020_h__ +#define m68020_h__ + +typedef void ( *mc68020_isr )( void ); + +#define disable_intr( level ) \ + { (level) = 0; \ + asm volatile ( "movew %%sr,%0 ; \ + orw #0x0700,%%sr" \ + : "=d" ((level)) : "0" ((level)) ); \ + } + +#define enable_intr( level ) \ + { asm volatile ( "movew %0,%%sr " \ + : "=d" ((level)) : "0" ((level)) ); \ + } + +#define flash_intr( level ) \ + { asm volatile ( "movew %0,%%sr ; \ + orw #0x0700,%%sr" \ + : "=d" ((level)) : "0" ((level)) ); \ + } + +#define get_vbr( vbr ) \ + { (vbr) = 0; \ + asm volatile ( "movec %%vbr,%0 " \ + : "=a" (vbr) : "0" (vbr) ); \ + } + +#define set_vbr( vbr ) \ + { register mc68020_isr *_vbr= (mc68020_isr *)(vbr); \ + asm volatile ( "movec %0,%%vbr " \ + : "=a" (_vbr) : "0" (_vbr) ); \ + } + +#define enable_caching() \ + { register unsigned int _ctl=0x01; \ + asm volatile ( "movec %0,%%cacr" \ + : "=d" (_ctl) : "0" (_ctl) ); \ + } + +#define delay( microseconds ) \ + { register unsigned int _delay=(microseconds); \ + register unsigned int _tmp=123; \ + asm volatile( "0: \ + nbcd %0 ; \ + nbcd %0 ; \ + dbf %1,0 " \ + : "=d" (_tmp), "=d" (_delay) \ + : "0" (_tmp), "1" (_delay) ); \ + } + +#define enable_tracing() +#define cause_intr( X ) +#define clear_intr( X ) + +extern mc68020_isr M68Kvec[]; /* vector table address */ + +#endif +/* end of include file */ diff -ruN glibc-1.08.1/sysdeps/standalone/m68k/m68020/mvme135/Implies glibc-1.09/sysdeps/standalone/m68k/m68020/mvme135/Implies --- glibc-1.08.1/sysdeps/standalone/m68k/m68020/mvme135/Implies Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/standalone/m68k/m68020/mvme135/Implies Wed Aug 24 09:54:00 1994 @@ -0,0 +1,2 @@ +# Motorola MVME135 and MVME136 are compatible. +standalone/m68k/m68020/mvme136 diff -ruN glibc-1.08.1/sysdeps/standalone/m68k/m68020/mvme136/Dist glibc-1.09/sysdeps/standalone/m68k/m68020/mvme136/Dist --- glibc-1.08.1/sysdeps/standalone/m68k/m68020/mvme136/Dist Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/standalone/m68k/m68020/mvme136/Dist Thu Sep 15 22:14:38 1994 @@ -0,0 +1 @@ +mvme136.ld diff -ruN glibc-1.08.1/sysdeps/standalone/m68k/m68020/mvme136/Makefile glibc-1.09/sysdeps/standalone/m68k/m68020/mvme136/Makefile --- glibc-1.08.1/sysdeps/standalone/m68k/m68020/mvme136/Makefile Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/standalone/m68k/m68020/mvme136/Makefile Thu Aug 25 13:30:47 1994 @@ -0,0 +1,22 @@ +# Copyright (C) 1993 Free Software Foundation, Inc. +# Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil), +# On-Line Applications Research Corporation. + +# The GNU C Library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Library General Public License +# as published by the Free Software Foundation; either version 2 of +# the License, or (at your option) any later version. + +# The GNU C Library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Library General Public License for more details. + +# You should have received a copy of the GNU Library General Public +# License along with the GNU C Library; see the file COPYING.LIB. If +# not, write to the Free Software Foundation, Inc., 675 Mass Ave, +# Cambridge, MA 02139, USA. + +ifeq (bare,$(subdir)) +install-lib += mvme136.ld +endif diff -ruN glibc-1.08.1/sysdeps/standalone/m68k/m68020/mvme136/_exit.c glibc-1.09/sysdeps/standalone/m68k/m68020/mvme136/_exit.c --- glibc-1.08.1/sysdeps/standalone/m68k/m68020/mvme136/_exit.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/standalone/m68k/m68020/mvme136/_exit.c Sun Aug 28 04:50:46 1994 @@ -0,0 +1,49 @@ +/* Copyright (C) 1994 Free Software Foundation, Inc. + Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil), + On-Line Applications Research Corporation. + +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include +#include "__m68020.h" + +/* Return control to 135Bug */ + +void +DEFUN_VOID(__exit_trap) +{ + set_vbr( 0 ); /* restore 135Bug vectors */ + asm volatile( "trap #15" ); /* trap to 135Bug */ + asm volatile( ".short 0x63" ); /* return to 135Bug (.RETURN) */ + asm volatile( "jmp main" ); /* restart program */ +} + +/* The function `_exit' should take a status argument and simply + terminate program execution, using the low-order 8 bits of the + given integer as status. */ + +__NORETURN void +DEFUN(_exit, (status), int status) +{ + /* status is ignored */ + + M68Kvec[ 45 ] = __exit_trap; /* install exit_trap handler */ + asm volatile( "trap #13" ); /* insures SUPV mode */ +} diff -ruN glibc-1.08.1/sysdeps/standalone/m68k/m68020/mvme136/brdinit.c glibc-1.09/sysdeps/standalone/m68k/m68020/mvme136/brdinit.c --- glibc-1.08.1/sysdeps/standalone/m68k/m68020/mvme136/brdinit.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/standalone/m68k/m68020/mvme136/brdinit.c Wed Aug 24 18:55:10 1994 @@ -0,0 +1,53 @@ +/* Copyright (C) 1994 Free Software Foundation, Inc. + Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil), + On-Line Applications Research Corporation. + +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include "__m68020.h" + +/* _Board_Initialize() + +This routine initializes the Motorola MVME135/MVME136. */ + +void +DEFUN_VOID(_Board_Initialize) +{ + mc68020_isr *monitors_vector_table; + int index; + + monitors_vector_table = (mc68020_isr *)0; /* 135Bug Vectors are at 0 */ + set_vbr( monitors_vector_table ); + + for ( index=2 ; index<=255 ; index++ ) + M68Kvec[ index ] = monitors_vector_table[ 32 ]; + + M68Kvec[ 2 ] = monitors_vector_table[ 2 ]; /* bus error vector */ + M68Kvec[ 4 ] = monitors_vector_table[ 4 ]; /* breakpoints vector */ + M68Kvec[ 9 ] = monitors_vector_table[ 9 ]; /* trace vector */ + M68Kvec[ 47 ] = monitors_vector_table[ 47 ]; /* system call vector */ + + set_vbr( &M68Kvec ); + + (*(unsigned char *)0xfffb0067) = 0x7f; /* make VME access round-robin */ + + enable_caching(); + +} diff -ruN glibc-1.08.1/sysdeps/standalone/m68k/m68020/mvme136/console.c glibc-1.09/sysdeps/standalone/m68k/m68020/mvme136/console.c --- glibc-1.08.1/sysdeps/standalone/m68k/m68020/mvme136/console.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/standalone/m68k/m68020/mvme136/console.c Wed Aug 24 18:55:05 1994 @@ -0,0 +1,101 @@ +/* Copyright (C) 1994 Free Software Foundation, Inc. + Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil), + On-Line Applications Research Corporation. + +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include "__m68020.h" + +/* Console IO routines for a Motorola MVME135/MVME136 board. + +They currently use the B port. It should be possible to +use the A port by filling in the reset of the chip structure, +adding an ifdef for PORTA/PORTB, and switching the addresses, +and maybe the macroes based on the macro. */ + +/* M68681 DUART chip register structures and constants */ + +typedef struct { + volatile unsigned char fill1[ 5 ]; /* channel A regs ( not used ) */ + volatile unsigned char isr; /* interrupt status reg */ + volatile unsigned char fill2[ 2 ]; /* counter regs (not used) */ + volatile unsigned char mr1mr2b; /* MR1B and MR2B regs */ + volatile unsigned char srb; /* status reg channel B */ + volatile unsigned char fill3; /* do not access */ + volatile unsigned char rbb; /* receive buffer channel B */ + volatile unsigned char ivr; /* interrupt vector register */ +} r_m681_info; + +typedef struct { + volatile unsigned char fill1[ 4 ]; /* channel A regs (not used) */ + volatile unsigned char acr; /* auxillary control reg */ + volatile unsigned char imr; /* interrupt mask reg */ + volatile unsigned char fill2[ 2 ]; /* counter regs (not used) */ + volatile unsigned char mr1mr2b; /* MR1B and MR2B regs */ + volatile unsigned char csrb; /* clock select reg */ + volatile unsigned char crb; /* command reg */ + volatile unsigned char tbb; /* transmit buffer channel B */ + volatile unsigned char ivr; /* interrupt vector register */ +} w_m681_info; + +#define RD_M68681 ((r_m681_info *)0xfffb0040) /* ptr to the M68681 */ +#define WR_M68681 ((w_m681_info *)0xfffb0040) /* ptr to the M68681 */ +#define RXRDYB 0x01 /* status reg recv ready mask */ +#define TXRDYB 0x04 /* status reg trans ready mask */ + +/* _Console_Putc + +This routine transmits a character out the M68681. It supports +XON/XOFF flow control. */ + +#define XON 0x11 /* control-Q */ +#define XOFF 0x13 /* control-S */ + +int +DEFUN( _Console_Putc, (ch), char ch ) +{ + while ( ! (RD_M68681->srb & TXRDYB) ) ; + while ( RD_M68681->srb & RXRDYB ) /* must be an XOFF */ + if ( RD_M68681->rbb == XOFF ) + do { + while ( ! (RD_M68681->srb & RXRDYB) ) ; + } while ( RD_M68681->rbb != XON ); + + WR_M68681->tbb = ch; + return( 0 ); +} + +/* _Console_Getc + +This routine reads a character from the UART and returns it. */ + +int +DEFUN( _Console_Getc, (poll), int poll ) +{ + if ( poll ) { + if ( !(RD_M68681->srb & RXRDYB) ) + return -1; + else + return RD_M68681->rbb; + } else { + while ( !(RD_M68681->srb & RXRDYB) ); + return RD_M68681->rbb; + } +} diff -ruN glibc-1.08.1/sysdeps/standalone/m68k/m68020/mvme136/mvme136.ld glibc-1.09/sysdeps/standalone/m68k/m68020/mvme136/mvme136.ld --- glibc-1.08.1/sysdeps/standalone/m68k/m68020/mvme136/mvme136.ld Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/standalone/m68k/m68020/mvme136/mvme136.ld Tue Sep 13 13:09:48 1994 @@ -0,0 +1,62 @@ +/* Copyright (C) 1994 Free Software Foundation, Inc. + Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil), + On-Line Applications Research Corporation. + +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +/* This file contains directives for the GNU linker which are specific +to the Motorola MVME136/MVME135 boards. */ + +MEMORY + { + ram : org = 0x3000, l = 1M + } + +/* This value is also when the space is allocated. If you change +this one, change the other one!!! */ + +heap_size = 0x20000; + +SECTIONS +{ + .text 0x3000 : + { + text_start = ABSOLUTE(.) ; + *(.text) + etext = ALIGN( 0x10 ) ; + } + + .data ADDR( .text ) + SIZEOF( .text ): + { + data_start = . ; + *(.data) + edata = ALIGN( 0x10 ) ; + } + + .bss ADDR( .data ) + SIZEOF( .data ): + { + bss_start = . ; + _bss_start = . ; + *(.bss) + *(COMMON) + heap_memory = .; + . += 0x20000; + end = . ; + _end = . ; + } +} diff -ruN glibc-1.08.1/sysdeps/standalone/m68k/m68020/start.S glibc-1.09/sysdeps/standalone/m68k/m68020/start.S --- glibc-1.08.1/sysdeps/standalone/m68k/m68020/start.S Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/standalone/m68k/m68020/start.S Wed Aug 24 18:57:24 1994 @@ -0,0 +1,155 @@ +/* Copyright (C) 1994 Free Software Foundation, Inc. + Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil), + On-Line Applications Research Corporation. + +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +/* entry.s + * + * This file contains the entry point for the application. + * The name of this entry point is compiler dependent. + * It jumps to the BSP which is responsible for performing + * all initialization. + */ + + .text + .globl start | Default entry point + .globl _start | Default entry point + .globl M68Kvec | Vector Table + .globl _M68Kvec | Vector Table + +start: +_start: +M68Kvec: | standard location for vectors +_M68Kvec: | standard location for vectors + nop | for linkers with problem + | using location zero as entry + jmp around + .space 4088 | to avoid initial intr stack + | from 135BUG on MVME13? as entry + | and start code at 0x4000 +around: + move.w %sr,initial_sr | save initial values + movec %isp,%a0 + movel %a0,initial_isp + movec %usp,%a0 + movel %a0,initial_usp + movec %msp,%a0 + movel %a0,initial_msp + oriw #0x0700,%sr | INTERRUPTS OFF!!! + + + + | + | zero out uninitialized data area + | +zerobss: + moveal #end,%a0 | find end of .bss + moveal #_bss_start,%a1 | find beginning of .bss + movel #0,%d0 + +loop: movel #0,%a1@+ | to zero out uninitialized + cmpal %a0,%a1 + jlt loop | loop until _end reached + + movel #heap_size,__C_heap_size | set ___C_heap_size + movel #heap_memory,__C_heap_start | set ___C_heap_start + moveal #interrupt_stack_end,%a0 | set interrupt stack pointer + movec %a0,%isp + moveal #stack_end,%a0 | set master stack pointer + movec %a0,%msp + moveal #stack_end,%a6 | set base pointer + movw #0x3000,%sr | SUPV MODE,INTERRUPTS ON!!! + +#ifdef NEED_UNDERSCORES + jsr __Board_Initialize | initialize the board +#else + jsr _Board_Initialize | initialize the board +#endif + + move.l #0,%sp@- | envp = NULL + move.l #0,%sp@- | argv = NULL + move.l #0,%sp@- | argc = NULL +#ifdef NEED_UNDERSCORES + jsr ___libc_init | initialize the library and + | call main +#else + jsr __libc_init | initialize the library and + | call main +#endif + add.l #12,%sp + + move.l #0,%sp@- | argc = NULL + jsr __exit | call the Board specific exit + addq.l #4,%sp + + move.l initial_isp,%a0 | if __exit returns then we can + movec %a0,%isp | restore the initial values + move.l initial_usp,%a0 + movec %a0,%usp + move.l initial_msp,%a0 + movec %a0,%msp + move.w initial_sr,%sr + rts + + + .bss + +/* + * So initial stack registers and status register can be saved. + */ + +#define DECLARE_SPACE(_name,_space,_align) \ + .globl _name ; \ + .align _align ; \ +_name##: .space _space + +#define DECLARE_LABEL(_name) \ + .globl _name ; \ +_name##: + +#define DECLARE_PTR(_name) DECLARE_SPACE(_name,4,2) +#define DECLARE_U32(_name) DECLARE_SPACE(_name,4,2) +#define DECLARE_U16(_name) DECLARE_SPACE(_name,2,1) + +DECLARE_U32(initial_isp) +DECLARE_U32(initial_msp) +DECLARE_U32(initial_usp) +DECLARE_U16(initial_sr) + +/* + * Require environment stuff + */ + +DECLARE_LABEL(_environ) +DECLARE_PTR(environ) + +DECLARE_LABEL(_errno) +DECLARE_U32(errno) + +/* + * Stack Size and Space + */ + + .set stack_size, 0x20000 + +DECLARE_SPACE(stack_memory,stack_size,4) +DECLARE_LABEL(stack_end) + +DECLARE_SPACE(interrupt_stack_memory,0x1000,4) +DECLARE_LABEL(interrupt_stack_end) diff -ruN glibc-1.08.1/sysdeps/standalone/standalone.h glibc-1.09/sysdeps/standalone/standalone.h --- glibc-1.08.1/sysdeps/standalone/standalone.h Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/standalone/standalone.h Thu Oct 27 15:00:26 1994 @@ -0,0 +1,32 @@ +/* Copyright (C) 1994 Free Software Foundation, Inc. + Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil), + On-Line Applications Research Corporation. + +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#ifndef _STANDALONE_H +#define _STANDALONE_H + +#include + +extern void _Board_Initialize __P ((void)); + +extern int _Console_Putc __P ((char c)); +extern int _Console_Getc __P ((int poll)); + +#endif diff -ruN glibc-1.08.1/sysdeps/standalone/stdio_lim.h glibc-1.09/sysdeps/standalone/stdio_lim.h --- glibc-1.08.1/sysdeps/standalone/stdio_lim.h Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/standalone/stdio_lim.h Thu Aug 25 14:15:01 1994 @@ -0,0 +1,27 @@ +/* Copyright (C) 1994 Free Software Foundation, Inc. + Ported to standalone by Joel Sherrill jsherril@redstone-emh2.army.mil, + On-Line Applications Research Corporation. + +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#define L_tmpnam 1 +#define TMPMAX 0 +#define L_ctermid 1 +#define L_cuserid 1 +#define FOPEN_MAX 16 +#define FILENAME_MAX 14 diff -ruN glibc-1.08.1/sysdeps/stub/__ioctl.c glibc-1.09/sysdeps/stub/__ioctl.c --- glibc-1.08.1/sysdeps/stub/__ioctl.c Thu Jul 22 15:20:09 1993 +++ glibc-1.09/sysdeps/stub/__ioctl.c Mon Jul 18 18:05:03 1994 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1993 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1993, 1994 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -24,7 +24,7 @@ The actual type and use of ARG and the return value depend on REQUEST. */ int DEFUN(__ioctl, (fd, request), - int fd AND int request DOTS) + int fd AND unsigned long int request DOTS) { errno = ENOSYS; return -1; diff -ruN glibc-1.08.1/sysdeps/stub/__sigret.c glibc-1.09/sysdeps/stub/__sigret.c --- glibc-1.08.1/sysdeps/stub/__sigret.c Wed Apr 1 02:07:03 1992 +++ glibc-1.09/sysdeps/stub/__sigret.c Thu Aug 25 23:56:56 1994 @@ -1,4 +1,4 @@ -/* Copyright (C) 1992 Free Software Foundation, Inc. +/* Copyright (C) 1992, 1994 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -21,7 +21,7 @@ #include int -DEFUN(__sigreturn, (context), CONST struct sigcontext *context) +DEFUN(__sigreturn, (context), struct sigcontext *context) { errno = ENOSYS; return -1; diff -ruN glibc-1.08.1/sysdeps/stub/_exit.c glibc-1.09/sysdeps/stub/_exit.c --- glibc-1.08.1/sysdeps/stub/_exit.c Sun Mar 8 15:43:46 1992 +++ glibc-1.09/sysdeps/stub/_exit.c Mon Jul 18 18:05:22 1994 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1994 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -23,7 +23,7 @@ /* The function `_exit' should take a status argument and simply terminate program execution, using the low-order 8 bits of the given integer as status. */ -void +__NORETURN void DEFUN(_exit, (status), int status) { status &= 0xff; diff -ruN glibc-1.08.1/sysdeps/stub/asm-syntax.h glibc-1.09/sysdeps/stub/asm-syntax.h --- glibc-1.08.1/sysdeps/stub/asm-syntax.h Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/stub/asm-syntax.h Tue Aug 30 07:59:57 1994 @@ -0,0 +1,3 @@ +/* On some machines the mpn function from GNU MP use a file called + "asm-syntax.h" to define macros for assembly source code to use. */ + diff -ruN glibc-1.08.1/sysdeps/stub/asm.h glibc-1.09/sysdeps/stub/asm.h --- glibc-1.08.1/sysdeps/stub/asm.h Fri Dec 24 23:21:19 1993 +++ glibc-1.09/sysdeps/stub/asm.h Wed Dec 31 19:00:00 1969 @@ -1,3 +0,0 @@ -/* On some machines the mpn function from GNU MP use a file called "asm.h" - to define macros for assembly source code to use. */ - diff -ruN glibc-1.08.1/sysdeps/stub/brdinit.c glibc-1.09/sysdeps/stub/brdinit.c --- glibc-1.08.1/sysdeps/stub/brdinit.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/stub/brdinit.c Fri Aug 26 01:55:47 1994 @@ -0,0 +1,34 @@ +/* Copyright (C) 1994 Free Software Foundation, Inc. + Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil), + On-Line Applications Research Corporation. + +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include + +/* This file is only required when a "bare" board is configured. */ + +/* _Board_Initialize + +This routine normally performs board specific initialization. */ + +void +DEFUN_VOID(_Board_Initialize) +{ +} diff -ruN glibc-1.08.1/sysdeps/stub/console.c glibc-1.09/sysdeps/stub/console.c --- glibc-1.08.1/sysdeps/stub/console.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/stub/console.c Fri Aug 26 01:57:17 1994 @@ -0,0 +1,42 @@ +/* Copyright (C) 1994 Free Software Foundation, Inc. + Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil), + On-Line Applications Research Corporation. + +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include + +/* This file is only required when a "bare" board is configured. */ + +/* These routines provide console IO routines for your embedded target. */ + +int +DEFUN( _Console_Putc, (ch), char ch ) +{ + /* eat the character */ + + return( 0 ); +} + +int +DEFUN( _Console_Getc, (poll), int poll ) +{ + /* boring user, never types anything */ + return -1; +} diff -ruN glibc-1.08.1/sysdeps/stub/errlist.c glibc-1.09/sysdeps/stub/errlist.c --- glibc-1.08.1/sysdeps/stub/errlist.c Tue Jan 11 18:10:15 1994 +++ glibc-1.09/sysdeps/stub/errlist.c Fri Aug 26 01:59:43 1994 @@ -26,11 +26,17 @@ CONST char *CONST _sys_errlist[] = { - "Error 0", - "Operation not implemented", /* ENOSYS */ - "Argument out of function's domain",/* EDOM */ - "Result out of range", /* ERANGE */ - NULL + "Error 0", /* 0 */ + "Argument out of function's domain", /* 1 = EDOM */ + "Result out of range", /* 2 = ERANGE */ + "Operation not implemented", /* 3 = ENOSYS */ + "Invalid argument", /* 4 = EINVAL */ + "Illegal seek", /* 5 = ESPIPE */ + "Bad file descriptor", /* 6 = EBADF */ + "Cannot allocate memory", /* 7 = ENOMEM */ + "Permission denied", /* 8 = EACCES */ + "Too many open files in system", /* 9 = ENFILE */ + "Too many open files", /* 10 = EMFILE */ }; -CONST int _sys_nerr = 4; +CONST int _sys_nerr = sizeof (_sys_errlist) / sizeof (_sys_errlist[0]); diff -ruN glibc-1.08.1/sysdeps/stub/errnos.h glibc-1.09/sysdeps/stub/errnos.h --- glibc-1.08.1/sysdeps/stub/errnos.h Tue Oct 29 22:29:26 1991 +++ glibc-1.09/sysdeps/stub/errnos.h Fri Aug 26 02:00:54 1994 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1994 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -31,5 +31,8 @@ #define EINVAL 4 #define ESPIPE 5 #define EBADF 6 +#define ENOMEM 7 +#define EACCES 8 +#define ENFILE 9 +#define EMFILE 10 #endif - diff -ruN glibc-1.08.1/sysdeps/stub/exc2signal.c glibc-1.09/sysdeps/stub/exc2signal.c --- glibc-1.08.1/sysdeps/stub/exc2signal.c Tue Jan 25 17:07:04 1994 +++ glibc-1.09/sysdeps/stub/exc2signal.c Mon Aug 8 18:53:00 1994 @@ -24,8 +24,10 @@ void _hurd_exception2signal (int exception, int code, int subcode, - int *signo, int *sigcode) + int *signo, int *sigcode, int *error) { + *error = 0; + switch (exception) { default: @@ -39,6 +41,7 @@ else *signo = SIGBUS; *sigcode = subcode; + *error = code; break; case EXC_BAD_INSTRUCTION: diff -ruN glibc-1.08.1/sysdeps/stub/getdomain.c glibc-1.09/sysdeps/stub/getdomain.c --- glibc-1.08.1/sysdeps/stub/getdomain.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/stub/getdomain.c Thu Sep 1 03:23:26 1994 @@ -0,0 +1,41 @@ +/* Copyright (C) 1994 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include + +/* Put the name of the current YP domain in no more than LEN bytes of NAME. + The result is null-terminated if LEN is large enough for the full + name and the terminator. */ +int +DEFUN(getdomainname, (name, len), + char *name AND size_t len) +{ + errno = ENOSYS; + return -1; +} + + +#ifdef HAVE_GNU_LD + +#include + +stub_warning(getdomainname); + +#endif /* GNU stabs. */ diff -ruN glibc-1.08.1/sysdeps/stub/init-fault.c glibc-1.09/sysdeps/stub/init-fault.c --- glibc-1.08.1/sysdeps/stub/init-fault.c Tue Jan 25 18:20:22 1994 +++ glibc-1.09/sysdeps/stub/init-fault.c Wed Dec 31 19:00:00 1969 @@ -1,38 +0,0 @@ -/* Set up a thread_state for proc_handle_exceptions. Stub version. -Copyright (C) 1994 Free Software Foundation, Inc. -This file is part of the GNU C Library. - -The GNU C Library is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. - -The GNU C Library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with the GNU C Library; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA. */ - -#include -#include - -static char fault_stack[32]; -static volatile void -faulted (void) -{ - __longjmp (_hurd_sigthread_fault_env, 1); -} - -void -_hurd_initialize_fault_recovery_state (void *state) -{ - struct hurd_thread_state *ts = state; - memset (ts, 0, sizeof (*ts)); - /* Point the SP in TS at the fault stack, - and set the PC to run `faulted' (above). */ - #error "Need to write sysdeps/mach/hurd/MACHINE/init_fault.c" -} diff -ruN glibc-1.08.1/sysdeps/stub/msging-p.c glibc-1.09/sysdeps/stub/msging-p.c --- glibc-1.08.1/sysdeps/stub/msging-p.c Tue Jan 25 18:20:55 1994 +++ glibc-1.09/sysdeps/stub/msging-p.c Wed Dec 31 19:00:00 1969 @@ -1,38 +0,0 @@ -/* Test a Mach thread_state for being in a mach_msg syscall. Stub version. -Copyright (C) 1994 Free Software Foundation, Inc. -This file is part of the GNU C Library. - -The GNU C Library is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. - -The GNU C Library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with the GNU C Library; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA. */ - -#include -#include - -/* Return nonzero if STATE indicates a thread - that is blocked in a mach_msg system call. */ -int -_hurd_thread_state_msging_p (void *state) -{ - if (setjmp (_hurd_sigthread_fault_env)) - /* The PC pointed at bogus memory. */ - return 0; - else - { - struct hurd_thread_state *ts = state; - /* Examine the code at the PC value in TS and see if - the thread is blocked in a `mach_msg_trap' system call. */ - #error "Need to write sysdeps/mach/hurd/MACHINE/msging_p.c" - } -} diff -ruN glibc-1.08.1/sysdeps/stub/setdomain.c glibc-1.09/sysdeps/stub/setdomain.c --- glibc-1.08.1/sysdeps/stub/setdomain.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/stub/setdomain.c Thu Sep 1 03:30:59 1994 @@ -0,0 +1,40 @@ +/* Copyright (C) 1994 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include + +/* Set the name of the current YP domain to NAME, which is LEN bytes long. + This call is restricted to the super-user. */ +int +DEFUN(setdomainname, (name, len), + char *name AND size_t len) +{ + errno = ENOSYS; + return -1; +} + + +#ifdef HAVE_GNU_LD + +#include + +stub_warning(setdomainname); + +#endif /* GNU stabs. */ diff -ruN glibc-1.08.1/sysdeps/stub/start.c glibc-1.09/sysdeps/stub/start.c --- glibc-1.08.1/sysdeps/stub/start.c Fri Jan 10 23:09:07 1992 +++ glibc-1.09/sysdeps/stub/start.c Fri Aug 19 00:57:19 1994 @@ -5,3 +5,12 @@ This file should be prepared to be the first thing in the text section (on Unix systems), or otherwise appropriately special. */ + +volatile int errno; + +#ifndef HAVE_GNU_LD +#undef environ +#define __environ environ +#endif + +char **__environ; diff -ruN glibc-1.08.1/sysdeps/stub/strtsupp.c glibc-1.09/sysdeps/stub/strtsupp.c --- glibc-1.08.1/sysdeps/stub/strtsupp.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/stub/strtsupp.c Fri Aug 26 02:10:05 1994 @@ -0,0 +1,31 @@ +/* Copyright (C) 1994 Free Software Foundation, Inc. + Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil), + On-Line Applications Research Corporation. + +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include + +/* This file is only required when a "bare" board is configured. */ + +/* Start Support Routines + +The start code for some CPUs (e.g. i386) require target dependent +support. For more info, consult the start file for your CPU. */ + diff -ruN glibc-1.08.1/sysdeps/stub/syscall.c glibc-1.09/sysdeps/stub/syscall.c --- glibc-1.08.1/sysdeps/stub/syscall.c Thu Jan 20 12:45:30 1994 +++ glibc-1.09/sysdeps/stub/syscall.c Mon Jul 18 18:06:23 1994 @@ -16,6 +16,7 @@ not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include #include #include diff -ruN glibc-1.08.1/sysdeps/stub/sysd-stdio.c glibc-1.09/sysdeps/stub/sysd-stdio.c --- glibc-1.08.1/sysdeps/stub/sysd-stdio.c Fri May 27 02:33:20 1994 +++ glibc-1.09/sysdeps/stub/sysd-stdio.c Mon Jul 18 18:06:24 1994 @@ -89,7 +89,7 @@ int DEFUN(__stdio_reopen, (filename, m, cookieptr), CONST char *filename AND __io_mode m AND - PTR *cookieptr AND __io_close closefn) + PTR *cookieptr AND __io_close_fn closefn) { errno = ENOSYS; return -1; diff -ruN glibc-1.08.1/sysdeps/stub/thread_state.h glibc-1.09/sysdeps/stub/thread_state.h --- glibc-1.08.1/sysdeps/stub/thread_state.h Wed Feb 16 18:17:37 1994 +++ glibc-1.09/sysdeps/stub/thread_state.h Mon Aug 8 03:36:46 1994 @@ -32,3 +32,16 @@ for the PC and stack pointer. */ #define PC ? #define SP ? + +/* This structure should contain all of the different flavors of thread + state structures which are meaningful for this machine. Every machine's + definition of this structure should have a member `int set' which is a + bit mask (1 << FLAVOR) of the flavors of thread state in the structure + which are filled in; and a member `struct machine_thread_state basic'. + On some machines those are the only members (e.g. i386); on others, + there are several relevant flavors of thread state (e.g. mips). */ +struct machine_thread_all_state + { + int set; /* Mask of bits (1 << FLAVOR). */ + struct _thread_state basic; + }; diff -ruN glibc-1.08.1/sysdeps/unix/Makefile glibc-1.09/sysdeps/unix/Makefile --- glibc-1.08.1/sysdeps/unix/Makefile Sat May 21 16:03:19 1994 +++ glibc-1.09/sysdeps/unix/Makefile Mon Aug 15 20:53:17 1994 @@ -36,7 +36,7 @@ if $(dir $<)$(notdir $<) > $@-t; then mv $@-t $@; else XXX; fi $(common-objpfx)mk-local_lim: $(sysdep_dir)/unix/mk-local_lim.c cwd=`pwd`; cd $(@D); \ - $(CC) $(native-CFLAGS) $(local_lim-CFLAGS) $$cwd/$< -o $(@F) + $(BUILD_CC) $(BUILD_CFLAGS) $(local_lim-CFLAGS) $$cwd/$< -o $(@F) before-compile := $(before-compile) $(common-objpfx)local_lim.h common-generated := $(common-generated) local_lim.h mk-local_lim @@ -169,7 +169,7 @@ $(ioctl-includes)))) $(common-objpfx)make-ioctls: $(common-objpfx)make-ioctls.c - cd $(@D); $(CC) $(native-CFLAGS) $(make-ioctls-CFLAGS) \ + cd $(@D); $(BUILD_CC) $(BUILD_CFLAGS) $(make-ioctls-CFLAGS) \ $(<:$(common-objpfx)%=%) -o $(@F) $(common-objpfx)make-ioctls.c: $(sysdep_dir)/unix/ioctls-tmpl.c \ diff -ruN glibc-1.08.1/sysdeps/unix/__sbrk.c glibc-1.09/sysdeps/unix/__sbrk.c --- glibc-1.08.1/sysdeps/unix/__sbrk.c Wed Jun 12 15:34:42 1991 +++ glibc-1.09/sysdeps/unix/__sbrk.c Wed Dec 31 19:00:00 1969 @@ -1,40 +0,0 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. -This file is part of the GNU C Library. - -The GNU C Library is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -The GNU C Library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with the GNU C Library; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include - -/* Defined in brk.c. */ -extern PTR __curbrk; -extern int EXFUN(__brk, (PTR addr)); - -/* Extend the process's data space by INCREMENT. - If INCREMENT is negative, shrink data space by - INCREMENT. - Return start of new space allocated, or -1 for errors. */ -PTR -DEFUN(__sbrk, (increment), int increment) -{ - char *oldbrk; - - if (increment == 0) - return __curbrk; - - oldbrk = __curbrk; - if (__brk(oldbrk + increment) < 0) - return (PTR) -1; - - return oldbrk; -} diff -ruN glibc-1.08.1/sysdeps/unix/bsd/Implies glibc-1.09/sysdeps/unix/bsd/Implies --- glibc-1.08.1/sysdeps/unix/bsd/Implies Wed Feb 24 16:34:28 1993 +++ glibc-1.09/sysdeps/unix/bsd/Implies Tue Nov 1 14:38:56 1994 @@ -1,3 +1,5 @@ # The directory unix/common contains things which are common to both BSD # and SVR4. unix/common +# The directory unix/inet implements sockets and networking in the usual way. +unix/inet diff -ruN glibc-1.08.1/sysdeps/unix/bsd/bsd4.4/direct.h glibc-1.09/sysdeps/unix/bsd/bsd4.4/direct.h --- glibc-1.08.1/sysdeps/unix/bsd/bsd4.4/direct.h Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/unix/bsd/bsd4.4/direct.h Thu Sep 29 05:44:13 1994 @@ -0,0 +1,16 @@ +#ifndef MAXNAMLEN +#define MAXNAMLEN 255 +#endif + +struct direct + { + unsigned long int d_fileno; + unsigned short int d_reclen; + unsigned char d_type; /* File type, possibly unknown. */ + unsigned char d_namlen; /* Length of the file name. */ + char d_name[MAXNAMLEN + 1]; + }; + +#define D_NAMLEN(d) ((d)->d_namlen) + +#define HAVE_D_TYPE diff -ruN glibc-1.08.1/sysdeps/unix/bsd/bsd4.4/errnos.h glibc-1.09/sysdeps/unix/bsd/bsd4.4/errnos.h --- glibc-1.08.1/sysdeps/unix/bsd/bsd4.4/errnos.h Tue May 5 21:26:15 1992 +++ glibc-1.09/sysdeps/unix/bsd/bsd4.4/errnos.h Sun Jul 31 15:56:08 1994 @@ -1,6 +1,11 @@ /* - * Copyright (c) 1982, 1986, 1989 Regents of the University of California. - * All rights reserved. + * Copyright (c) 1982, 1986, 1989, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -30,7 +35,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)errno.h 7.13 (Berkeley) 2/19/91 + * @(#)errno.h 8.5 (Berkeley) 1/21/94 */ #ifdef _ERRNO_H @@ -52,8 +57,8 @@ #define EFAULT 14 /* Bad address */ #ifdef __USE_BSD #define ENOTBLK 15 /* Block device required */ -#define EBUSY 16 /* Device busy */ #endif +#define EBUSY 16 /* Device busy */ #define EEXIST 17 /* File exists */ #define EXDEV 18 /* Cross-device link */ #define ENODEV 19 /* Operation not supported by device */ @@ -101,7 +106,7 @@ #define ENOPROTOOPT 42 /* Protocol not available */ #define EPROTONOSUPPORT 43 /* Protocol not supported */ #define ESOCKTNOSUPPORT 44 /* Socket type not supported */ -#define EOPNOTSUPP 45 /* Operation not supported on socket */ +#define EOPNOTSUPP 45 /* Operation not supported */ #define EPFNOSUPPORT 46 /* Protocol family not supported */ #define EAFNOSUPPORT 47 /* Address family not supported by protocol family */ #define EADDRINUSE 48 /* Address already in use */ @@ -118,7 +123,7 @@ #define ENOTCONN 57 /* Socket is not connected */ #define ESHUTDOWN 58 /* Can't send after socket shutdown */ #define ETOOMANYREFS 59 /* Too many references: can't splice */ -#define ETIMEDOUT 60 /* Connection timed out */ +#define ETIMEDOUT 60 /* Operation timed out */ #define ECONNREFUSED 61 /* Connection refused */ #define ELOOP 62 /* Too many levels of symbolic links */ @@ -152,5 +157,12 @@ #define ENOSYS 78 /* Function not implemented */ #define EFTYPE 79 /* Inappropriate file type or format */ + +#ifdef __USE_BSD +#define EAUTH 80 /* Authentication error */ +#define ENEEDAUTH 81 /* Need authenticator */ +#define ELAST 81 /* Must be equal largest errno */ +#endif /* __USE_BSD */ + #endif /* included. */ diff -ruN glibc-1.08.1/sysdeps/unix/bsd/bsd4.4/getdomain.S glibc-1.09/sysdeps/unix/bsd/bsd4.4/getdomain.S --- glibc-1.08.1/sysdeps/unix/bsd/bsd4.4/getdomain.S Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/unix/bsd/bsd4.4/getdomain.S Thu Sep 1 03:36:11 1994 @@ -0,0 +1,22 @@ +/* Copyright (C) 1994 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include + +SYSCALL (getdomainname, 2) + ret diff -ruN glibc-1.08.1/sysdeps/unix/bsd/bsd4.4/setdomain.S glibc-1.09/sysdeps/unix/bsd/bsd4.4/setdomain.S --- glibc-1.08.1/sysdeps/unix/bsd/bsd4.4/setdomain.S Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/unix/bsd/bsd4.4/setdomain.S Thu Sep 1 03:37:30 1994 @@ -0,0 +1,22 @@ +/* Copyright (C) 1994 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include + +SYSCALL (setdomainname, 2) + ret diff -ruN glibc-1.08.1/sysdeps/unix/bsd/direct.h glibc-1.09/sysdeps/unix/bsd/direct.h --- glibc-1.08.1/sysdeps/unix/bsd/direct.h Mon May 3 19:34:11 1993 +++ glibc-1.09/sysdeps/unix/bsd/direct.h Thu Nov 3 18:54:43 1994 @@ -4,9 +4,9 @@ struct direct { - unsigned long int d_fileno; - unsigned short int d_reclen; - unsigned short int d_namlen; + unsigned int d_fileno; /* 32 bits. */ + unsigned short int d_reclen; /* 16 bits. */ + unsigned short int d_namlen; /* 16 bits. */ char d_name[MAXNAMLEN + 1]; }; diff -ruN glibc-1.08.1/sysdeps/unix/bsd/dirstream.h glibc-1.09/sysdeps/unix/bsd/dirstream.h --- glibc-1.08.1/sysdeps/unix/bsd/dirstream.h Tue Dec 21 03:33:28 1993 +++ glibc-1.09/sysdeps/unix/bsd/dirstream.h Tue Nov 1 02:04:43 1994 @@ -1,4 +1,4 @@ -/* Copyright (C) 1993 Free Software Foundation, Inc. +/* Copyright (C) 1993, 1994 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -22,6 +22,7 @@ #define __need_size_t #include +#include /* For __off_t. */ /* Directory stream type. @@ -36,6 +37,7 @@ size_t __allocation; /* Space allocated for the block. */ size_t __offset; /* Current offset into the block. */ size_t __size; /* Total valid data in the block. */ + __off_t __pos; /* Position in directory of this block. */ } DIR; #endif /* dirstream.h */ diff -ruN glibc-1.08.1/sysdeps/unix/bsd/osf1/direct.h glibc-1.09/sysdeps/unix/bsd/osf1/direct.h --- glibc-1.08.1/sysdeps/unix/bsd/osf1/direct.h Thu Dec 23 00:57:43 1993 +++ glibc-1.09/sysdeps/unix/bsd/osf1/direct.h Wed Dec 31 19:00:00 1969 @@ -1,31 +0,0 @@ -/* Copyright (C) 1993 Free Software Foundation, Inc. - Contributed by Brendan Kehoe (brendan@zen.org). - -The GNU C Library is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. - -The GNU C Library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with the GNU C Library; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA. */ - -#ifndef MAXNAMLEN -#define MAXNAMLEN 255 -#endif - -struct direct - { - unsigned int d_fileno; - unsigned short int d_reclen; - unsigned short int d_namlen; - char d_name[MAXNAMLEN + 1]; - }; - -#define D_NAMLEN(d) ((d)->d_namlen) diff -ruN glibc-1.08.1/sysdeps/unix/bsd/osf1/dirstream.h glibc-1.09/sysdeps/unix/bsd/osf1/dirstream.h --- glibc-1.08.1/sysdeps/unix/bsd/osf1/dirstream.h Thu Dec 23 00:57:37 1993 +++ glibc-1.09/sysdeps/unix/bsd/osf1/dirstream.h Thu Nov 3 18:53:24 1994 @@ -33,7 +33,7 @@ size_t __size; /* Total valid data in the block. */ char *__data; /* Directory block. */ - size_t __allocation; /* Space allocated for the block. */ + int __allocation; /* Space allocated for the block. */ int __data_len; /* Size of __data. */ long __dd_seek; /* OSF/1 magic cookie returned by getdents. */ diff -ruN glibc-1.08.1/sysdeps/unix/bsd/readdir.c glibc-1.09/sysdeps/unix/bsd/readdir.c --- glibc-1.08.1/sysdeps/unix/bsd/readdir.c Tue Dec 21 00:10:55 1993 +++ glibc-1.09/sysdeps/unix/bsd/readdir.c Tue Nov 1 01:47:11 1994 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -24,6 +24,7 @@ #include #include #include +#include "direct.h" /* Read a directory entry from DIRP. */ @@ -44,9 +45,8 @@ { /* We've emptied out our buffer. Refill it. */ - off_t base; ssize_t bytes = __getdirentries (dirp->__fd, dirp->__data, - dirp->__allocation, &base); + dirp->__allocation, &dirp->__pos); if (bytes <= 0) return NULL; dirp->__size = (size_t) bytes; @@ -57,6 +57,11 @@ dp = (struct dirent *) &dirp->__data[dirp->__offset]; dirp->__offset += dp->d_reclen; + +#ifndef HAVE_D_TYPE + dp->d_namlen = ((struct direct *) dp)->d_namlen; + dp->d_type = DT_UNKNOWN; +#endif /* Loop to ignore deleted files. */ } while (dp->d_fileno == 0); diff -ruN glibc-1.08.1/sysdeps/unix/bsd/seekdir.c glibc-1.09/sysdeps/unix/bsd/seekdir.c --- glibc-1.08.1/sysdeps/unix/bsd/seekdir.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/unix/bsd/seekdir.c Tue Nov 1 02:08:49 1994 @@ -0,0 +1 @@ +/* Because they share a private data structure, seekdir is in telldir.c. */ diff -ruN glibc-1.08.1/sysdeps/unix/bsd/sun/signum.h glibc-1.09/sysdeps/unix/bsd/sun/signum.h --- glibc-1.08.1/sysdeps/unix/bsd/sun/signum.h Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/unix/bsd/sun/signum.h Mon Jul 18 18:07:02 1994 @@ -0,0 +1,69 @@ +/* Signal number definitions. SunOS version. +Copyright (C) 1994 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#ifdef _SIGNAL_H + +/* This file defines the fake signal functions and signal + number constants for SunOS 3 and 4 Unix systems. */ + +/* Fake signal functions. */ +#define SIG_ERR ((__sighandler_t) -1) /* Error return. */ +#define SIG_DFL ((__sighandler_t) 0) /* Default action. */ +#define SIG_IGN ((__sighandler_t) 1) /* Ignore signal. */ + + +/* Signals. */ +#define SIGHUP 1 /* Hangup (POSIX). */ +#define SIGINT 2 /* Interrupt (ANSI). */ +#define SIGQUIT 3 /* Quit (POSIX). */ +#define SIGILL 4 /* Illegal instruction (ANSI). */ +#define SIGABRT SIGIOT /* Abort (ANSI). */ +#define SIGTRAP 5 /* Trace trap (POSIX). */ +#define SIGIOT 6 /* IOT trap (4.2 BSD). */ +#define SIGEMT 7 /* EMT trap (4.2 BSD). */ +#define SIGFPE 8 /* Floating-point exception (ANSI). */ +#define SIGKILL 9 /* Kill, unblockable (POSIX). */ +#define SIGBUS 10 /* Bus error (4.2 BSD). */ +#define SIGSEGV 11 /* Segmentation violation (ANSI). */ +#define SIGSYS 12 /* Bad argument to system call (4.2 BSD). */ +#define SIGPIPE 13 /* Broken pipe (POSIX). */ +#define SIGALRM 14 /* Alarm clock (POSIX). */ +#define SIGTERM 15 /* Termination (ANSI). */ +#define SIGURG 16 /* Urgent condition on socket (4.2 BSD). */ +#define SIGSTOP 17 /* Stop, unblockable (POSIX). */ +#define SIGTSTP 18 /* Keyboard stop (POSIX). */ +#define SIGCONT 19 /* Continue (POSIX). */ +#define SIGCHLD 20 /* Child status has changed (POSIX). */ +#define SIGCLD SIGCHLD /* Same as SIGCHLD (System V). */ +#define SIGTTIN 21 /* Background read from tty (POSIX). */ +#define SIGTTOU 22 /* Background write to tty (POSIX). */ +#define SIGIO 23 /* I/O now possible (4.2 BSD). */ +#define SIGPOLL SIGIO /* Same as SIGIO? (SVID). */ +#define SIGXCPU 24 /* CPU limit exceeded (4.2 BSD). */ +#define SIGXFSZ 25 /* File size limit exceeded (4.2 BSD). */ +#define SIGVTALRM 26 /* Virtual alarm clock (4.2 BSD). */ +#define SIGPROF 27 /* Profiling alarm clock (4.2 BSD). */ +#define SIGWINCH 28 /* Window size change (4.3 BSD, Sun). */ +#define SIGLOST 29 /* Resource lost (Sun). */ +#define SIGUSR1 30 /* User-defined signal 1 (POSIX). */ +#define SIGUSR2 31 /* User-defined signal 2 (POSIX). */ + +#endif /* included. */ + +#define _NSIG 32 /* Biggest signal number + 1. */ diff -ruN glibc-1.08.1/sysdeps/unix/bsd/sun/sparc/sigtramp.c glibc-1.09/sysdeps/unix/bsd/sun/sparc/sigtramp.c --- glibc-1.08.1/sysdeps/unix/bsd/sun/sparc/sigtramp.c Wed Mar 11 18:09:31 1992 +++ glibc-1.09/sysdeps/unix/bsd/sun/sparc/sigtramp.c Mon Jul 18 18:06:46 1994 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1992 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1992, 1994 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -187,7 +187,7 @@ I don't know what it's for. Ask Sun. */ asm("restore %%g0, 139, %%g1\n" "ta 0\n" - "mov %0, %0" /* Useless insn that will never be executed, */ + "! this should be i0: %0" /* Useless insn that will never be executed, */ /* here to make the compiler happy. */ : /* No outputs. */ : /* CONTEXT is bound to %i0. We reference it as an input here to make diff -ruN glibc-1.08.1/sysdeps/unix/bsd/sun/sunos4/termbits.h glibc-1.09/sysdeps/unix/bsd/sun/sunos4/termbits.h --- glibc-1.08.1/sysdeps/unix/bsd/sun/sunos4/termbits.h Thu May 6 19:29:21 1993 +++ glibc-1.09/sysdeps/unix/bsd/sun/sunos4/termbits.h Mon Oct 31 07:14:07 1994 @@ -1,5 +1,5 @@ /* termios type and macro definitions. SunOS 4 version. -Copyright (C) 1993 Free Software Foundation, Inc. +Copyright (C) 1993, 1994 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -195,9 +195,6 @@ #define TCSANOW 0 /* Change immediately. */ #define TCSADRAIN 1 /* Change when pending output is written. */ #define TCSAFLUSH 2 /* Flush pending input before changing. */ -#ifdef __USE_BSD -#define TCSASOFT 0x10 /* Flag: Don't alter hardware state. */ -#endif /* Values for the QUEUE_SELECTOR argument to `tcflush'. */ #define TCIFLUSH 0 /* Discard data received but not yet read. */ diff -ruN glibc-1.08.1/sysdeps/unix/bsd/sys/reboot.h glibc-1.09/sysdeps/unix/bsd/sys/reboot.h --- glibc-1.08.1/sysdeps/unix/bsd/sys/reboot.h Tue Aug 3 18:23:06 1993 +++ glibc-1.09/sysdeps/unix/bsd/sys/reboot.h Sun Jul 31 15:59:34 1994 @@ -1,6 +1,6 @@ /* - * Copyright (c) 1982, 1986, 1988 Regents of the University of California. - * All rights reserved. + * Copyright (c) 1982, 1986, 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 @@ -30,13 +30,9 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * from: @(#)reboot.h 7.6 (Berkeley) 6/28/90 - * $Id: reboot.h,v 1.3 1993/05/20 16:22:55 cgd Exp $ + * @(#)reboot.h 8.1 (Berkeley) 6/2/93 */ -#ifndef _SYS_REBOOT_H_ -#define _SYS_REBOOT_H_ - /* * Arguments to reboot system call. * These are passed to boot program in r11, @@ -53,6 +49,7 @@ #define RB_KDB 0x40 /* give control to kernel debugger */ #define RB_RDONLY 0x80 /* mount root fs read-only */ #define RB_DUMP 0x100 /* dump kernel memory before reboot */ +#define RB_MINIROOT 0x200 /* mini-root present in memory at boot time */ /* * Constants for converting boot-style device number to type, @@ -89,5 +86,3 @@ (((type) << B_TYPESHIFT) | ((adaptor) << B_ADAPTORSHIFT) | \ ((controller) << B_CONTROLLERSHIFT) | ((unit) << B_UNITSHIFT) | \ ((partition) << B_PARTITIONSHIFT) | B_DEVMAGIC) - -#endif /* !_SYS_REBOOT_H_ */ diff -ruN glibc-1.08.1/sysdeps/unix/bsd/telldir.c glibc-1.09/sysdeps/unix/bsd/telldir.c --- glibc-1.08.1/sysdeps/unix/bsd/telldir.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/unix/bsd/telldir.c Tue Nov 1 02:14:00 1994 @@ -0,0 +1,93 @@ +/* Copyright (C) 1994 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include +#include +#include +#include +#include + +/* Internal data structure for telldir and seekdir. */ +struct record + { + struct record *next; /* Link in chain. */ + off_t cookie; /* Value returned by `telldir'. */ + off_t pos; + size_t offset; + }; +#define NBUCKETS 32 +static struct record *records[32]; +static off_t lastpos; + + +/* Return the current position of DIRP. */ +off_t +DEFUN(telldir, (dirp), DIR *dirp) +{ + struct record *new; + + new = malloc (sizeof *new); + if (new == NULL) + return (off_t) -1; + + new->pos = dirp->__pos; + new->offset = dirp->__offset; + new->cookie = ++lastpos; + new->next = records[new->cookie % NBUCKETS]; + records[new->cookie % NBUCKETS] = new; + + return new->cookie; +} + + + +/* Seek to position POS in DIRP. */ +void +DEFUN(seekdir, (dirp, pos), DIR *dirp AND __off_t pos) +{ + struct record *r, **prevr; + + for (prevr = &records[pos % NBUCKETS], r = *prevr; + r != NULL; + prevr = &r->next, r = r->next) + if (r->cookie == pos) + { + if (dirp->__pos != r->pos || dirp->__offset != r->offset) + { + dirp->__size = 0; /* Must read a fresh buffer. */ + /* Move to the saved position. */ + __lseek (dirp->__fd, r->pos, SEEK_SET); + dirp->__pos = r->pos; + dirp->__offset = 0; + /* Read entries until we reach the saved offset. */ + while (dirp->__offset < r->offset) + if (readdir (dirp) == NULL) + break; + } + + /* To prevent leaking memory, cookies returned from telldir + can only be used once. So free this one's record now. */ + *prevr = r->next; + free (r); + return; + } + + /* We lost, but have no way to indicate it. Oh well. */ +} diff -ruN glibc-1.08.1/sysdeps/unix/bsd/ulimit.c glibc-1.09/sysdeps/unix/bsd/ulimit.c --- glibc-1.08.1/sysdeps/unix/bsd/ulimit.c Thu Feb 3 02:15:26 1994 +++ glibc-1.09/sysdeps/unix/bsd/ulimit.c Mon Jul 18 18:07:35 1994 @@ -26,7 +26,7 @@ #define _etext etext #endif -extern char _etext; +extern int _etext; /* Function depends on CMD: 1 = Return the limit on the size of a file, in units of 512 bytes. diff -ruN glibc-1.08.1/sysdeps/unix/bsd/utime.c glibc-1.09/sysdeps/unix/bsd/utime.c --- glibc-1.08.1/sysdeps/unix/bsd/utime.c Wed Jun 12 17:39:03 1991 +++ glibc-1.09/sysdeps/unix/bsd/utime.c Mon Oct 24 23:33:52 1994 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1994 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -35,14 +35,16 @@ if (times != NULL) { timevals[0].tv_sec = (long int) times->actime; + timevals[0].tv_usec = 0L; timevals[1].tv_sec = (long int) times->modtime; + timevals[1].tv_usec = 0L; } else { - time_t now = time((time_t *) NULL); - timevals[0].tv_sec = (long int) now; - timevals[1].tv_sec = (long int) now; + if (__gettimeofday (&timevals[0], NULL) < 0) + return -1; + timevals[1] = timevals[0]; } - return __utimes(file, timevals); + return __utimes (file, timevals); } diff -ruN glibc-1.08.1/sysdeps/unix/common/Implies glibc-1.09/sysdeps/unix/common/Implies --- glibc-1.08.1/sysdeps/unix/common/Implies Wed Feb 24 17:25:34 1993 +++ glibc-1.09/sysdeps/unix/common/Implies Wed Dec 31 19:00:00 1969 @@ -1,3 +0,0 @@ -# This directory, unix/common, is for things which are common to both BSD -# and SVR4. BSD and SVR4 both have Internet-related things. -unix/inet diff -ruN glibc-1.08.1/sysdeps/unix/common/configure glibc-1.09/sysdeps/unix/common/configure --- glibc-1.08.1/sysdeps/unix/common/configure Thu May 19 11:33:55 1994 +++ glibc-1.09/sysdeps/unix/common/configure Tue Oct 11 00:48:15 1994 @@ -5,98 +5,73 @@ # Find out what this system calls `sys_siglist'. -for ac_func in sys_siglist _sys_siglist -do -ac_tr_func=HAVE_`echo $ac_func | tr '[a-z]' '[A-Z]'` -echo "checking for ${ac_func}" 1>&4 -if eval "test \"`echo '${'ac_cv_func_${ac_func}'+set}'`\" = set"; then - echo " using cached value for ac_cv_func_${ac_func}" 1>&5 -else - cat > conftest.${ac_ext} < conftest.${ac_ext} < + int main() { return 0; } -int t() { -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_${ac_func}) || defined (__stub___${ac_func}) -choke me -#else -/* Override any gcc2 internal prototype to avoid an error. */ -extern char ${ac_func}(); ${ac_func}(); -#endif -; return 0; } +int t() { extern char *sys_siglist[]; puts(*sys_siglist);; return 0; } EOF if eval $ac_compile; then rm -rf conftest* - eval "ac_cv_func_${ac_func}=yes" -else - rm -rf conftest* - eval "ac_cv_func_${ac_func}=no" + +{ +test -n "$verbose" && \ +echo " defining HAVE_SYS_SIGLIST" +echo "#define" HAVE_SYS_SIGLIST "1" >> confdefs.h +DEFS="$DEFS -DHAVE_SYS_SIGLIST=1" +} + + fi rm -f conftest* -fi -if eval "test \"`echo '$ac_cv_func_'${ac_func}`\" = yes"; then +test -n "$silent" || echo "checking for _sys_siglist" +cat > conftest.${ac_ext} <> confdefs.h -DEFS="$DEFS -D${ac_tr_func}=1" +test -n "$verbose" && \ +echo " defining HAVE__SYS_SIGLIST" +echo "#define" HAVE__SYS_SIGLIST "1" >> confdefs.h +DEFS="$DEFS -DHAVE__SYS_SIGLIST=1" } + fi -done +rm -f conftest* # Find out the name of the table the system's uses for character # classification. This is used by sysdeps/unix/common/glue-ctype.c. -for ac_func in _ctype_ __ctype_ __ctype _ctype__ _ctype _locp -do -ac_tr_func=HAVE_`echo $ac_func | tr '[a-z]' '[A-Z]'` -echo "checking for ${ac_func}" 1>&4 -if eval "test \"`echo '${'ac_cv_func_${ac_func}'+set}'`\" = set"; then - echo " using cached value for ac_cv_func_${ac_func}" 1>&5 -else - cat > conftest.${ac_ext} < conftest.${ac_ext} < int main() { return 0; } -int t() { -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_${ac_func}) || defined (__stub___${ac_func}) -choke me -#else -/* Override any gcc2 internal prototype to avoid an error. */ -extern char ${ac_func}(); ${ac_func}(); -#endif -; return 0; } +int t() { $ctype[13];; return 0; } EOF if eval $ac_compile; then rm -rf conftest* - eval "ac_cv_func_${ac_func}=yes" -else - rm -rf conftest* - eval "ac_cv_func_${ac_func}=no" -fi -rm -f conftest* - -fi -if eval "test \"`echo '$ac_cv_func_'${ac_func}`\" = yes"; then { -test "$verbose" = yes && \ -echo " defining ${ac_tr_func}" -echo "#define" ${ac_tr_func} "1" >> confdefs.h -DEFS="$DEFS -D${ac_tr_func}=1" +test -n "$verbose" && \ +echo " defining HAVE_`echo $ctype | tr 'a-z' 'A-Z'`" +echo "#define" HAVE_`echo $ctype | tr 'a-z' 'A-Z'` "1" >> confdefs.h +DEFS="$DEFS -DHAVE_`echo $ctype | tr 'a-z' 'A-Z'`=1" } + fi -done +rm -f conftest* +done fi diff -ruN glibc-1.08.1/sysdeps/unix/common/configure.in glibc-1.09/sysdeps/unix/common/configure.in --- glibc-1.08.1/sysdeps/unix/common/configure.in Mon Mar 28 12:56:13 1994 +++ glibc-1.09/sysdeps/unix/common/configure.in Thu Sep 29 17:04:18 1994 @@ -5,10 +5,19 @@ changequote([,]) # Find out what this system calls `sys_siglist'. -AC_HAVE_FUNCS(sys_siglist _sys_siglist) +AC_COMPILE_CHECK(sys_siglist, , + [extern char *sys_siglist[]; puts(*sys_siglist);], + AC_DEFINE(HAVE_SYS_SIGLIST)) +AC_COMPILE_CHECK(_sys_siglist, , + [extern char *_sys_siglist[]; puts(*_sys_siglist);], + AC_DEFINE(HAVE__SYS_SIGLIST)) # Find out the name of the table the system's uses for character # classification. This is used by sysdeps/unix/common/glue-ctype.c. -AC_HAVE_FUNCS(_ctype_ __ctype_ __ctype _ctype__ _ctype _locp) +for ctype in _ctype_ __ctype_ __ctype _ctype__ _ctype _locp; do +AC_COMPILE_CHECK($ctype, [#include ], + [$ctype[13];], + AC_DEFINE(HAVE_`echo $ctype | tr '[a-z]' '[A-Z]'`)) +done fi diff -ruN glibc-1.08.1/sysdeps/unix/common/glue-ctype.c glibc-1.09/sysdeps/unix/common/glue-ctype.c --- glibc-1.08.1/sysdeps/unix/common/glue-ctype.c Thu May 19 04:15:45 1994 +++ glibc-1.09/sysdeps/unix/common/glue-ctype.c Thu Oct 13 22:15:40 1994 @@ -18,6 +18,19 @@ /* Different systems have different names for the array. This order is important for some systems. */ + +#if !defined(TABLE) && defined(HAVE__LOCP) +/* OSF/1 has the name _ctype defined as a macro, which points down into + the _locp structure. Jesus. We'll hope this works. We need to + check for LOCP first, since there is no symbol actually named _ctype + in their library. */ +#include /* for wchar_t used by localdef.h */ +#include +extern loc_t *_locp; +#define TABLE (_locp->lc_chrtbl)->lc_ctype +#undef _ctype +#define TABLE_NAME _ctype +#endif #ifdef HAVE__CTYPE__ #define TABLE _ctype__ #endif @@ -33,15 +46,6 @@ #if !defined(TABLE) && defined(HAVE___CTYPE) #define TABLE __ctype #endif -#if !defined(TABLE) && defined(HAVE__LOCP) -/* OSF/1 has the name _ctype defined as a macro, which points down into - the _locp structure. Jesus. We'll hope this works. */ -#include -extern loc_t *_locp; -#define TABLE (_locp->lc_chrtbl)->lc_ctype -#undef _ctype -#define TABLE_NAME _ctype -#endif #if defined (__STDC__) && __STDC__ #define STRINGIFY(arg) #arg @@ -57,7 +61,10 @@ int i; +#ifndef HAVE__LOCP + /* This won't work for the define to look into _locp. */ extern unsigned char TABLE[]; +#endif puts ("#include "); #ifdef TABLE_NAME diff -ruN glibc-1.08.1/sysdeps/unix/configure glibc-1.09/sysdeps/unix/configure --- glibc-1.08.1/sysdeps/unix/configure Fri Feb 18 18:26:53 1994 +++ glibc-1.09/sysdeps/unix/configure Fri Sep 2 21:18:40 1994 @@ -64,7 +64,9 @@ for unix_function in \ __dup2 __lstat __mkdir __rmdir __readlink __symlink rename swapon \ __access __select __getgroups/__getgrps setgroups \ - __getitimer/__getitmr __setitimer/__setitmr + __getitimer/__getitmr __setitimer/__setitmr \ + getdomainname/getdomain=bsd/bsd4.4 \ + setdomainname/setdomain=bsd/bsd4.4 do # $unix_function => $unix_syscall $unix_srcname @@ -72,8 +74,10 @@ # __CALL CALL __CALL # __CALL/NAME CALL NAME unix_srcname= + unix_srcdir=common eval "unix_syscall=`echo $unix_function | \ sed -e '/^__/s/^__//' \ + -e 's@=\(.*\)$@ unix_srcdir=\1@' \ -e 's@/\(.*\)$@ unix_srcname=\1@'`" test -z "$unix_srcname" && unix_srcname=$unix_function @@ -102,7 +106,7 @@ if grep -i "[ _]${unix_syscall}[ ]" $unix_syscall_h >/dev/null then # It does seem to be present in . - echo "#include " \ + echo "#include " \ > ${unix_generated_dirpfx}${unix_srcname}.S test -n "$verbose" && echo " wrote ${unix_generated_dirpfx}${unix_srcname}.S" diff -ruN glibc-1.08.1/sysdeps/unix/i386/vfork.S glibc-1.09/sysdeps/unix/i386/vfork.S --- glibc-1.08.1/sysdeps/unix/i386/vfork.S Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/unix/i386/vfork.S Wed Oct 26 20:46:51 1994 @@ -0,0 +1,23 @@ +/* Copyright (C) 1994 Free Software Foundation, Inc. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include + +/* Go directly into __vfork, don't do anything with the stack ptr. */ + +ENTRY(vfork) + jmp __vfork diff -ruN glibc-1.08.1/sysdeps/unix/inet/Subdirs glibc-1.09/sysdeps/unix/inet/Subdirs --- glibc-1.08.1/sysdeps/unix/inet/Subdirs Sun Feb 6 23:28:18 1994 +++ glibc-1.09/sysdeps/unix/inet/Subdirs Mon Aug 8 18:48:59 1994 @@ -1,2 +1,3 @@ inet +resolv sunrpc diff -ruN glibc-1.08.1/sysdeps/unix/ioctls-tmpl.c glibc-1.09/sysdeps/unix/ioctls-tmpl.c --- glibc-1.08.1/sysdeps/unix/ioctls-tmpl.c Sat May 21 22:29:56 1994 +++ glibc-1.09/sysdeps/unix/ioctls-tmpl.c Thu Nov 3 18:33:27 1994 @@ -114,6 +114,11 @@ #undef DKIOCEXCL #undef DKIOCGET #undef DKIOCHDR +/* Introduced by OSF/1 2.0. */ +#undef FIOPIPESTAT +#undef SIOCSRREQR +#undef SIOCSRREQW +#undef SRVC_REQUEST #endif #define DEFINE(name, value) \ diff -ruN glibc-1.08.1/sysdeps/unix/morecore.c glibc-1.09/sysdeps/unix/morecore.c --- glibc-1.08.1/sysdeps/unix/morecore.c Wed Nov 10 20:49:29 1993 +++ glibc-1.09/sysdeps/unix/morecore.c Wed Dec 31 19:00:00 1969 @@ -1,48 +0,0 @@ -/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. -This file is part of the GNU C Library. - -The GNU C Library is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -The GNU C Library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with the GNU C Library; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef _MALLOC_INTERNAL -#define _MALLOC_INTERNAL -#include -#endif - -#ifndef __GNU_LIBRARY__ -#define __sbrk sbrk -#endif - -#ifdef __GNU_LIBRARY__ -/* It is best not to declare this and cast its result on foreign operating - systems with potentially hostile include files. */ -extern __ptr_t __sbrk __P ((int increment)); -#endif - -#ifndef NULL -#define NULL 0 -#endif - -/* Allocate INCREMENT more bytes of data space, - and return the start of data space, or NULL on errors. - If INCREMENT is negative, shrink data space. */ -__ptr_t -__default_morecore (increment) - ptrdiff_t increment; -{ - __ptr_t result = (__ptr_t) __sbrk ((int) increment); - if (result == (__ptr_t) -1) - return NULL; - return result; -} diff -ruN glibc-1.08.1/sysdeps/unix/opendir.c glibc-1.09/sysdeps/unix/opendir.c --- glibc-1.08.1/sysdeps/unix/opendir.c Mon May 17 16:30:58 1993 +++ glibc-1.09/sysdeps/unix/opendir.c Tue Nov 1 01:38:23 1994 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -38,6 +38,14 @@ struct stat statbuf; int fd; + if (name[0] == '\0') + { + /* POSIX.1-1990 says an empty name gets ENOENT; + but `open' might like it fine. */ + errno = ENOENT; + return NULL; + } + fd = __open (name, O_RDONLY); if (fd < 0) return NULL; @@ -45,7 +53,15 @@ if (fcntl (fd, F_SETFD, FD_CLOEXEC) < 0) goto lose; - dirp = (DIR *) malloc (sizeof (DIR) + NAME_MAX); + if (fstat (fd, &statbuf) < 0) + goto lose; + if (! S_ISDIR (statbuf.st_mode)) + { + errno = ENOTDIR; + goto lose; + } + + dirp = (DIR *) calloc (1, sizeof (DIR) + NAME_MAX); /* Zero-fill. */ if (dirp == NULL) lose: { @@ -56,8 +72,7 @@ } #ifdef _STATBUF_ST_BLKSIZE - if (__fstat (fd, &statbuf) < 0 || - statbuf.st_blksize < sizeof (struct direct)) + if (statbuf.st_blksize < sizeof (struct direct)) dirp->__allocation = sizeof (struct direct); else dirp->__allocation = statbuf.st_blksize; @@ -76,7 +91,5 @@ } dirp->__fd = fd; - dirp->__offset = 0; - dirp->__size = 0; return dirp; } diff -ruN glibc-1.08.1/sysdeps/unix/readdir.c glibc-1.09/sysdeps/unix/readdir.c --- glibc-1.08.1/sysdeps/unix/readdir.c Fri Jun 4 14:11:48 1993 +++ glibc-1.09/sysdeps/unix/readdir.c Fri Jul 22 20:01:37 1994 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -69,12 +69,13 @@ { /* Not a deleted file. */ register struct dirent *d = &dirp->__entry; + register const char *p; d->d_fileno = (ino_t) dp->d_ino; - d->d_namlen = (size_t) D_NAMLEN (dp); /* On some systems the name length does not actually mean much. */ - while (dp->d_name[d->d_namlen - 1] == '\0') - --d->d_namlen; - (void) strncpy (d->d_name, dp->d_name, d->d_namlen + 1); + p = memchr ((PTR) dp->d_name, '\0', D_NAMLEN (dp)); + if (p != NULL) + d->d_namlen = p - dp->d_name; + memcpy (d->d_name, dp->d_name, d->d_namlen + 1); return d; } } diff -ruN glibc-1.08.1/sysdeps/unix/sysv/irix4/__getgrps.c glibc-1.09/sysdeps/unix/sysv/irix4/__getgrps.c --- glibc-1.08.1/sysdeps/unix/sysv/irix4/__getgrps.c Thu Feb 24 18:55:30 1994 +++ glibc-1.09/sysdeps/unix/sysv/irix4/__getgrps.c Mon Jul 18 18:09:27 1994 @@ -25,7 +25,7 @@ /* Set the group set for the current user to GROUPS (N of them). */ int -DEFUN(getgroups, (n, groups), size_t n AND gid_t *groups) +DEFUN(__getgroups, (n, groups), size_t n AND gid_t *groups) { return __syssgi (SGI_GETGROUPS, n, groups); } diff -ruN glibc-1.08.1/sysdeps/unix/sysv/isc3/direct.h glibc-1.09/sysdeps/unix/sysv/isc3/direct.h --- glibc-1.08.1/sysdeps/unix/sysv/isc3/direct.h Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/unix/sysv/isc3/direct.h Mon Jul 18 18:09:40 1994 @@ -0,0 +1 @@ +#include diff -ruN glibc-1.08.1/sysdeps/unix/sysv/sco3.2.4/Dist glibc-1.09/sysdeps/unix/sysv/sco3.2.4/Dist --- glibc-1.08.1/sysdeps/unix/sysv/sco3.2.4/Dist Wed Jun 23 15:10:48 1993 +++ glibc-1.09/sysdeps/unix/sysv/sco3.2.4/Dist Mon Jul 18 18:09:13 1994 @@ -1 +1,2 @@ pgrpsys.S +sco_getgrp.S diff -ruN glibc-1.08.1/sysdeps/unix/sysv/sco3.2.4/__getgrps.c glibc-1.09/sysdeps/unix/sysv/sco3.2.4/__getgrps.c --- glibc-1.08.1/sysdeps/unix/sysv/sco3.2.4/__getgrps.c Fri May 20 21:32:10 1994 +++ glibc-1.09/sysdeps/unix/sysv/sco3.2.4/__getgrps.c Mon Jul 18 18:09:14 1994 @@ -20,6 +20,7 @@ #include #include #include +#include extern int __sco_getgroups __P ((int size, unsigned short int *list)); diff -ruN glibc-1.08.1/sysdeps/unix/sysv/sco3.2.4/sco_getgrp.S glibc-1.09/sysdeps/unix/sysv/sco3.2.4/sco_getgrp.S --- glibc-1.08.1/sysdeps/unix/sysv/sco3.2.4/sco_getgrp.S Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/unix/sysv/sco3.2.4/sco_getgrp.S Mon Jul 18 18:09:21 1994 @@ -0,0 +1,22 @@ +/* Copyright (C) 1994 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include + +PSEUDO (__sco_getgroups, getgroups, 2) + ret diff -ruN glibc-1.08.1/sysdeps/unix/sysv/sco3.2.4/uname.S glibc-1.09/sysdeps/unix/sysv/sco3.2.4/uname.S --- glibc-1.08.1/sysdeps/unix/sysv/sco3.2.4/uname.S Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/unix/sysv/sco3.2.4/uname.S Mon Jul 18 18:09:24 1994 @@ -0,0 +1,42 @@ +/* Copyright (C) 1993, 1994 Free Software Foundation, Inc. + Contributed by Scott Bartram. + +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include + +/* + before lcall, stack contents should be: + + 4(%esp) -> name + 8(%esp) -> unspecified + 12(%esp) -> 0 + */ + +ENTRY (uname) + pushl $0x0 /* Push the discriminator flag. */ + pushl $0x0 /* Push dummy placeholder. */ + pushl 12(%esp,1) /* Push NAME (ptr to struct utsname) */ + subl $0x4, %esp /* Adjust stack pointer. */ + DO_CALL (utssys, 3) + jb error /* Test for error. */ + addl $0x10, %esp /* Adjust the stack pointer. */ + xorl %eax, %eax /* Clear return value. */ + ret +error: addl $0x10, %esp /* Adjust the stack pointer. */ + jmp syscall_error diff -ruN glibc-1.08.1/sysdeps/unix/sysv/sysd-stdio.c glibc-1.09/sysdeps/unix/sysv/sysd-stdio.c --- glibc-1.08.1/sysdeps/unix/sysv/sysd-stdio.c Tue Apr 21 01:42:26 1992 +++ glibc-1.09/sysdeps/unix/sysv/sysd-stdio.c Thu Sep 29 17:20:59 1994 @@ -1,2 +1,2 @@ #define EINTR_REPEAT -#include <../sysdeps/posix/sysd-stdio.c> +#include <../sysdeps/generic/sysd-stdio.c> diff -ruN glibc-1.08.1/sysdeps/unix/sysv/sysv4/Dist glibc-1.09/sysdeps/unix/sysv/sysv4/Dist --- glibc-1.08.1/sysdeps/unix/sysv/sysv4/Dist Wed Dec 22 18:00:17 1993 +++ glibc-1.09/sysdeps/unix/sysv/sysv4/Dist Mon Jul 18 18:08:56 1994 @@ -4,3 +4,4 @@ __waitid.S siginfo.h __getpgid.c __setpgid.c +sysinfo.S diff -ruN glibc-1.08.1/sysdeps/unix/sysv/sysv4/Makefile glibc-1.09/sysdeps/unix/sysv/sysv4/Makefile --- glibc-1.08.1/sysdeps/unix/sysv/sysv4/Makefile Sat Dec 18 01:37:59 1993 +++ glibc-1.09/sysdeps/unix/sysv/sysv4/Makefile Thu Jul 14 18:13:17 1994 @@ -22,3 +22,16 @@ __getpgid __setpgid __waitid endif + + +ifeq ($(subdir),signal) + +sysdep_routines := $(sysdep_routines) sys-sig + +endif + +ifeq ($(subdir),misc) + +sysdep_routines := $(sysdep_routines) sysinfo + +endif diff -ruN glibc-1.08.1/sysdeps/unix/sysv/sysv4/__gethstnm.c glibc-1.09/sysdeps/unix/sysv/sysv4/__gethstnm.c --- glibc-1.08.1/sysdeps/unix/sysv/sysv4/__gethstnm.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/unix/sysv/sysv4/__gethstnm.c Mon Jul 18 18:08:58 1994 @@ -0,0 +1,31 @@ +/* Copyright (C) 1994 Free Software Foundation, Inc. + Contributed by Brendan Kehoe (brendan@zen.org). + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include +#include +#include + +extern int __sysinfo __P ((int command, char *buf, long count)); + +int +DEFUN(__gethostname, (name, namelen), char *name AND size_t namelen) +{ + return __sysinfo (SI_HOSTNAME, name, namelen); +} diff -ruN glibc-1.08.1/sysdeps/unix/sysv/sysv4/i386/sysdep.h glibc-1.09/sysdeps/unix/sysv/sysv4/i386/sysdep.h --- glibc-1.08.1/sysdeps/unix/sysv/sysv4/i386/sysdep.h Tue May 24 01:56:11 1994 +++ glibc-1.09/sysdeps/unix/sysv/sysv4/i386/sysdep.h Fri Jul 22 19:54:34 1994 @@ -21,7 +21,9 @@ /* In SVR4 some system calls can fail with the error ERESTART, and this means the call should be retried. */ +#ifndef _ERRNO_H #define _ERRNO_H +#endif #include #undef PSEUDO @@ -33,4 +35,4 @@ cmpb $ERESTART, %al; \ je C_SYMBOL_NAME (name); \ jmp syscall_error; \ - noerror: ret + noerror: diff -ruN glibc-1.08.1/sysdeps/unix/sysv/sysv4/sethostnam.c glibc-1.09/sysdeps/unix/sysv/sysv4/sethostnam.c --- glibc-1.08.1/sysdeps/unix/sysv/sysv4/sethostnam.c Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/unix/sysv/sysv4/sethostnam.c Mon Jul 18 18:09:06 1994 @@ -0,0 +1,31 @@ +/* Copyright (C) 1994 Free Software Foundation, Inc. + Contributed by Brendan Kehoe (brendan@zen.org). + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include +#include +#include + +extern int __sysinfo __P ((int command, const char *buf, long count)); + +int +DEFUN(sethostname, (name, namelen), const char *name AND size_t namelen) +{ + return __sysinfo (SI_SET_HOSTNAME, name, namelen); +} diff -ruN glibc-1.08.1/sysdeps/unix/sysv/sysv4/sigset.h glibc-1.09/sysdeps/unix/sysv/sysv4/sigset.h --- glibc-1.08.1/sysdeps/unix/sysv/sysv4/sigset.h Sat May 21 16:42:51 1994 +++ glibc-1.09/sysdeps/unix/sysv/sysv4/sigset.h Mon Jul 18 18:09:08 1994 @@ -49,7 +49,7 @@ #define __SSMASK(s) (1 << ((s) % __NSSBITS)) #ifndef _EXTERN_INLINE -#define _EXTERN_INLINE +#define _EXTERN_INLINE extern __inline #endif _EXTERN_INLINE int diff -ruN glibc-1.08.1/sysdeps/unix/sysv/sysv4/solaris2/Makefile glibc-1.09/sysdeps/unix/sysv/sysv4/solaris2/Makefile --- glibc-1.08.1/sysdeps/unix/sysv/sysv4/solaris2/Makefile Wed May 12 21:24:22 1993 +++ glibc-1.09/sysdeps/unix/sysv/sysv4/solaris2/Makefile Mon Aug 15 20:52:20 1994 @@ -3,4 +3,4 @@ # along the way (e.g., glue-ctype) will fail because it'll try to link # with the libc.a being *constructed* in $(objdir). As a work-around, # we add this to each native-compile. -native-CFLAGS := $(native-CFLAGS) -L/lib +BUILD_CFLAGS := $(BUILD_CFLAGS) -L/lib diff -ruN glibc-1.08.1/sysdeps/unix/sysv/sysv4/solaris2/fsync.S glibc-1.09/sysdeps/unix/sysv/sysv4/solaris2/fsync.S --- glibc-1.08.1/sysdeps/unix/sysv/sysv4/solaris2/fsync.S Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/unix/sysv/sysv4/solaris2/fsync.S Mon Jul 18 18:08:49 1994 @@ -0,0 +1,29 @@ +/* Copyright (C) 1994 Free Software Foundation, Inc. + Contributed by Brendan Kehoe (brendan@zen.org). + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include + +/* Solaris uses fdsync for the normal fsync. */ +ENTRY(fsync) + mov 16, %i1 + mov SYS_ify(fdsync), %g1 + ta 8 + bcs syscall_error + nop + mov %g0, %o0 + ret diff -ruN glibc-1.08.1/sysdeps/unix/sysv/sysv4/solaris2/sparc/Dist glibc-1.09/sysdeps/unix/sysv/sysv4/solaris2/sparc/Dist --- glibc-1.08.1/sysdeps/unix/sysv/sysv4/solaris2/sparc/Dist Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/unix/sysv/sysv4/solaris2/sparc/Dist Mon Jul 18 18:08:50 1994 @@ -0,0 +1 @@ +sys-sig.S diff -ruN glibc-1.08.1/sysdeps/unix/sysv/sysv4/solaris2/sparc/Makefile glibc-1.09/sysdeps/unix/sysv/sysv4/solaris2/sparc/Makefile --- glibc-1.08.1/sysdeps/unix/sysv/sysv4/solaris2/sparc/Makefile Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/unix/sysv/sysv4/solaris2/sparc/Makefile Mon Jul 18 18:08:51 1994 @@ -0,0 +1,5 @@ +# This flag is necessary because GCC now tries to call _Q_{mul, etc...} +# instead of doing the stuff the hard way. For now, printf_fp.o, __vfscanf.o, +# and difftime.o don't work because of this. The long-term fix is to actually +# implement what they're doing, but for the short-term, we must do this. +sysdep-CFLAGS := $(sysdep-CFLAGS) -mhard-quad-float diff -ruN glibc-1.08.1/sysdeps/unix/sysv/sysv4/solaris2/sparc/sys-sig.S glibc-1.09/sysdeps/unix/sysv/sysv4/solaris2/sparc/sys-sig.S --- glibc-1.08.1/sysdeps/unix/sysv/sysv4/solaris2/sparc/sys-sig.S Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/unix/sysv/sysv4/solaris2/sparc/sys-sig.S Mon Jul 18 18:08:51 1994 @@ -0,0 +1,25 @@ +/* Copyright (C) 1994 Free Software Foundation, Inc. + Contributed by Brendan Kehoe (brendan@zen.org). + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include + +PSEUDO (__sigaction_syscall, sigaction, 3) + ret + +PSEUDO (__context_syscall, context, 2) + ret diff -ruN glibc-1.08.1/sysdeps/unix/sysv/sysv4/solaris2/sparc/sysdep.h glibc-1.09/sysdeps/unix/sysv/sysv4/solaris2/sparc/sysdep.h --- glibc-1.08.1/sysdeps/unix/sysv/sysv4/solaris2/sparc/sysdep.h Mon Dec 6 23:52:10 1993 +++ glibc-1.09/sysdeps/unix/sysv/sysv4/solaris2/sparc/sysdep.h Thu Sep 29 17:20:56 1994 @@ -1,4 +1,4 @@ -/* Copyright (C) 1993 Free Software Foundation, Inc. +/* Copyright (C) 1993, 1994 Free Software Foundation, Inc. Contributed by Brendan Kehoe (brendan@zen.org). The GNU C Library is free software; you can redistribute it and/or @@ -21,11 +21,17 @@ #include +/* As of gcc-2.6.0, it complains about pound signs in front of things + that aren't arguments to the macro. So we use this to pull it off + instead. */ +#define cat(a,b) a##b +#define poundfnc cat(#,function) + #define ENTRY(name) \ .section ".text"; \ .align 4; \ .global C_SYMBOL_NAME(name); \ - .type C_SYMBOL_NAME(name), \#function; \ + .type C_SYMBOL_NAME(name), poundfnc; \ C_LABEL(name) #define PSEUDO(name, syscall_name, args) \ diff -ruN glibc-1.08.1/sysdeps/unix/sysv/sysv4/solaris2/utsnamelen.h glibc-1.09/sysdeps/unix/sysv/sysv4/solaris2/utsnamelen.h --- glibc-1.08.1/sysdeps/unix/sysv/sysv4/solaris2/utsnamelen.h Wed May 12 21:27:59 1993 +++ glibc-1.09/sysdeps/unix/sysv/sysv4/solaris2/utsnamelen.h Wed Dec 31 19:00:00 1969 @@ -1 +0,0 @@ -#define _UTSNAME_LENGTH 257 diff -ruN glibc-1.08.1/sysdeps/unix/sysv/sysv4/sysinfo.S glibc-1.09/sysdeps/unix/sysv/sysv4/sysinfo.S --- glibc-1.08.1/sysdeps/unix/sysv/sysv4/sysinfo.S Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/unix/sysv/sysv4/sysinfo.S Mon Jul 18 18:09:09 1994 @@ -0,0 +1,22 @@ +/* Copyright (C) 1994 Free Software Foundation, Inc. + Contributed by Brendan Kehoe (brendan@zen.org). + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include + +PSEUDO (__sysinfo, systeminfo, 3) + ret diff -ruN glibc-1.08.1/sysdeps/unix/sysv/sysv4/utsnamelen.h glibc-1.09/sysdeps/unix/sysv/sysv4/utsnamelen.h --- glibc-1.08.1/sysdeps/unix/sysv/sysv4/utsnamelen.h Wed Dec 31 19:00:00 1969 +++ glibc-1.09/sysdeps/unix/sysv/sysv4/utsnamelen.h Fri Oct 14 14:00:22 1994 @@ -0,0 +1 @@ +#define _UTSNAME_LENGTH 257 diff -ruN glibc-1.08.1/sysdeps/vax/DEFS.h glibc-1.09/sysdeps/vax/DEFS.h --- glibc-1.08.1/sysdeps/vax/DEFS.h Wed Feb 27 00:24:58 1991 +++ glibc-1.09/sysdeps/vax/DEFS.h Sun Jul 31 16:01:51 1994 @@ -1,22 +1,36 @@ /* - * Copyright (c) 1982 The Regents of the University of California. - * All rights reserved. + * Copyright (c) 1982, 1993 + * The Regents of the University of California. All rights reserved. * - * Redistribution and use in source and binary forms are permitted - * provided that: (1) source distributions retain this entire copyright - * notice and comment, and (2) distributions including binaries display - * the following acknowledgement: ``This product includes software - * developed by the University of California, Berkeley and its contributors'' - * in the documentation or other materials provided with the distribution - * and in all advertising materials mentioning features or use of this - * software. Neither the name of the University nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * @(#)DEFS.h 5.3 (Berkeley) 6/1/90 + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)DEFS.h 8.1 (Berkeley) 6/4/93 */ #define R0 0x001 diff -ruN glibc-1.08.1/sysdeps/vax/Makefile glibc-1.09/sysdeps/vax/Makefile --- glibc-1.08.1/sysdeps/vax/Makefile Fri Aug 2 03:08:34 1991 +++ glibc-1.09/sysdeps/vax/Makefile Mon Aug 15 20:34:56 1994 @@ -1,4 +1,4 @@ -# Copyright (C) 1991 Free Software Foundation, Inc. +# Copyright (C) 1991, 1994 Free Software Foundation, Inc. # This file is part of the GNU C Library. # The GNU C Library is free software; you can redistribute it and/or @@ -19,13 +19,12 @@ ifeq ($(subdir),math) ifndef math-twiddled -routines:= $(filter-out acos asin cos sin ceil rint hypot \ - __copysign __scalb __drem __logb __finite,$(routines))\ - asincos sincos -aux := $(aux) argred support exp__E log__L +elided-routines := $(elided-routines) acos asin cos sin ceil rint hypot \ + __copysign __scalb __drem __logb __finite +sysdep_routines := $(sysdep_routines) asincos sincos argred \ + support exp__E log__L math-twiddled := t - endif bsdmath_dirs := $(bsdmath_dirs) vax diff -ruN glibc-1.08.1/termios/sys/ttydefaults.h glibc-1.09/termios/sys/ttydefaults.h --- glibc-1.08.1/termios/sys/ttydefaults.h Tue May 5 19:16:03 1992 +++ glibc-1.09/termios/sys/ttydefaults.h Sun Jul 31 16:02:58 1994 @@ -1,6 +1,11 @@ /*- - * Copyright (c) 1982, 1986 The Regents of the University of California. - * All rights reserved. + * Copyright (c) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -30,14 +35,14 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)ttydefaults.h 7.9 (Berkeley) 5/9/91 + * @(#)ttydefaults.h 8.4 (Berkeley) 1/21/94 */ /* * System wide defaults for terminal state. */ -#ifndef _TTYDEFAULTS_H_ -#define _TTYDEFAULTS_H_ +#ifndef _SYS_TTYDEFAULTS_H_ +#define _SYS_TTYDEFAULTS_H_ /* * Defaults on "first" open. @@ -53,10 +58,10 @@ */ #define CTRL(x) (x&037) #define CEOF CTRL('d') -#define CEOL ((unsigned)'\377') /* XXX avoid _POSIX_VDISABLE */ +#define CEOL ((unsigned char)'\377') /* XXX avoid _POSIX_VDISABLE */ #define CERASE 0177 #define CINTR CTRL('c') -#define CSTATUS ((unsigned)'\377') /* XXX avoid _POSIX_VDISABLE */ +#define CSTATUS ((unsigned char)'\377') /* XXX avoid _POSIX_VDISABLE */ #define CKILL CTRL('u') #define CMIN 1 #define CQUIT 034 /* FS, ^\ */ @@ -76,7 +81,7 @@ #define CFLUSH CDISCARD /* PROTECTED INCLUSION ENDS HERE */ -#endif /* !_TTYDEFAULTS_H_ */ +#endif /* !_SYS_TTYDEFAULTS_H_ */ /* * #define TTYDEFCHARS to include an array of default control characters. @@ -88,4 +93,4 @@ CDISCARD, CMIN, CTIME, CSTATUS, _POSIX_VDISABLE }; #undef TTYDEFCHARS -#endif /* TTYDEFCHARS */ +#endif diff -ruN glibc-1.08.1/termios/termios.h glibc-1.09/termios/termios.h --- glibc-1.08.1/termios/termios.h Thu May 6 19:29:27 1993 +++ glibc-1.09/termios/termios.h Mon Jul 18 18:12:33 1994 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -30,6 +30,12 @@ /* Get the system-dependent definitions of `struct termios', `tcflag_t', `cc_t', `speed_t', and all the macros specifying the flag bits. */ #include + +#ifdef __USE_BSD +/* Compare a character C to a value VAL from the `c_cc' array in a + `struct termios'. If VAL is _POSIX_VDISABLE, no character can match it. */ +#define CCEQ(val, c) ((c) == (val) && (val) != _POSIX_VDISABLE) +#endif /* Return the output baud rate stored in *TERMIOS_P. */ extern speed_t cfgetospeed __P ((__const struct termios *__termios_p)); diff -ruN glibc-1.08.1/time/Makefile glibc-1.09/time/Makefile --- glibc-1.08.1/time/Makefile Wed May 4 00:18:53 1994 +++ glibc-1.09/time/Makefile Mon Jul 18 18:12:35 1994 @@ -42,7 +42,7 @@ # northamerica. distribute := $(distribute) $(tzfiles) leapseconds pacificnew -install := zic zdump +install-sbin := zic zdump include ../Makeconfig # Get objpfx defined so we can use it below. @@ -54,17 +54,17 @@ include $(objpfx)zonenames # Make these absolute file names. -localtime-file := $(firstword $(filter /%,$(localtime-file)) \ - $(addprefix $(zonedir)/, \ - $(localtime-file))) -posixrules-file := $(firstword $(filter /%,$(posixrules-file)) \ - $(addprefix $(zonedir)/, \ - $(posixrules-file))) +installed-localtime-file := $(firstword $(filter /%,$(localtime-file)) \ + $(addprefix $(zonedir)/, \ + $(localtime-file))) +installed-posixrules-file := $(firstword $(filter /%,$(posixrules-file)) \ + $(addprefix $(zonedir)/, \ + $(posixrules-file))) ifndef cross-compiling # Don't try to install the zoneinfo files since we can't run zic. install-others = $(addprefix $(zonedir)/,$(zonenames)) \ - $(localtime-file) $(posixrules-file) + $(installed-localtime-file) $(installed-posixrules-file) endif include ../Rules @@ -106,11 +106,11 @@ endef ifdef localtime -$(localtime-file): $(zonedir)/$(localtime) $(objpfx)zic +$(installed-localtime-file): $(zonedir)/$(localtime) $(objpfx)zic $(zic-cmd) -l $(localtime) endif ifdef posixrules -$(posixrules-file): $(zonedir)/$(posixrules) $(objpfx)zic +$(installed-posixrules-file): $(zonedir)/$(posixrules) $(objpfx)zic $(zic-cmd) -p $(posixrules) endif diff -ruN glibc-1.08.1/time/asia glibc-1.09/time/asia --- glibc-1.08.1/time/asia Mon Feb 7 14:30:51 1994 +++ glibc-1.09/time/asia Mon Aug 22 15:21:17 1994 @@ -1,10 +1,10 @@ -# @(#)asia 7.9 +# @(#)asia 7.11 # This data is by no means authoritative; if you think you know better, # go ahead and edit the file (and please send any changes to # tz@elsie.nci.nih.gov for general use in the future). -# From Paul Eggert (November 18, 1993): +# From Paul Eggert (August 18, 1994): # # A good source for time zone historical data outside the U.S. is # Thomas G. Shanks, The International Atlas (3rd edition), @@ -15,6 +15,10 @@ # Whitman Publishing Co, 2 Niagara Av, Ealing, London (undated), which # I found in the UCLA library. # +# A reliable and entertaining source about time zones is +# Derek Howse, Greenwich time and the discovery of the longitude, +# Oxford University Press (1980). +# # I invented the abbreviations marked `*' in the following table; # the rest are from earlier versions of this file, or from other sources. # Corrections are welcome! @@ -29,11 +33,12 @@ # 4:00 BSK BSD Baku* # 4:00 GST GDT Gulf* # 4:30 AFT Afghanistan* -# 5:00 TSK TSD Tashkent* +# 5:00 ASK ASD Ashkhabad* # 5:00 PKT Pakistan* # 5:30 IST IST India # 5:45 NPT Nepal* # 6:00 BGT Bengal, Bangladesh* +# 6:00 TSK TSD Tashkent* # 6:30 BMT Burma* # 7:00 ICT Indochina* # 7:00 JVT Java* @@ -60,13 +65,14 @@ ############################################################################### +# From Paul Eggert (May 28, 1994): +# We don't know what happened to the clocks in the Caucausus and the ex-Soviet +# Central Asia after 1990. Until we get more info, stick with the pre-1991 rules. # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Russia 1981 1984 - Apr 1 0:00 1:00 D Rule Russia 1981 1983 - Oct 1 0:00 0 K -Rule Russia 1984 1990 - Sep lastSun 3:00 0 K -Rule Russia 1985 1990 - Mar lastSun 2:00 1:00 D -Rule Russia 1992 max - Sep lastSun 2:00s 0 K -Rule Russia 1992 max - Mar lastSun 2:00s 1:00 D +Rule Russia 1984 max - Sep lastSun 3:00 0 K +Rule Russia 1985 max - Mar lastSun 2:00 1:00 D # Afghanistan # Zone NAME GMTOFF RULES FORMAT [UNTIL] @@ -78,15 +84,13 @@ # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Yerevan 2:58:00 - LMT 1924 May 2 3:00 - MSK 1957 Mar - 4:00 Russia BS%s 1991 Sep 29 3:00 - 3:00 Russia MS%s + 4:00 Russia BS%s # Azerbaijan # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Baku 3:19:24 - LMT 1924 May 2 3:00 - MSK 1957 Mar - 4:00 Russia BS%s 1991 Sep 29 3:00 - 3:00 Russia MS%s + 4:00 Russia BS%s # Bahrain # Zone NAME GMTOFF RULES FORMAT [UNTIL] @@ -277,8 +281,7 @@ Zone Asia/Tbilisi 2:59:16 - LMT 1880 2:59 - LST 1924 May 2 3:00 - MSK 1957 Mar - 4:00 Russia BS%s 1991 Sep 29 3:00 - 3:00 Russia MS%s + 4:00 Russia BS%s # India # Zone NAME GMTOFF RULES FORMAT [UNTIL] @@ -288,7 +291,7 @@ 5:30 - IST 1942 Sep 5:30 1:00 IST 1945 Oct 15 5:30 - IST -# The following are like India/Calcutta: +# The following are like Asia/Calcutta: # Andaman Is # Lakshadweep (Laccadive, Minicoy and Amindivi Is) # Nicobar Is @@ -510,14 +513,11 @@ 2:00 Jordan EET%s # Kazakhstan -# From Paul Eggert (November 18, 1993): -# Before 1993, Almaty was known by its Russian name ``Alma-Ata''. # From Shanks (1991): # Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Almaty 5:07:48 - LMT 1924 May 2 +Zone Asia/Alma-Ata 5:07:48 - LMT 1924 May 2 5:00 - TSK 1957 Mar - 6:00 Russia TS%s 1991 Sep 29 3:00 - 5:00 Russia TS%s + 6:00 Russia TS%s ############################################################################### @@ -565,8 +565,7 @@ # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Frunze 4:58:24 - LMT 1924 May 2 5:00 - TSK 1957 Mar - 6:00 Russia TS%s 1991 Sep 29 3:00 - 5:00 Russia TS%s + 6:00 Russia TS%s # Laos # Zone NAME GMTOFF RULES FORMAT [UNTIL] @@ -676,6 +675,8 @@ # This will undoubtedly change soon. # Philippines +# Howse writes (p 162) that until 1844 the Philippines kept American date. +# The rest of this data is from Shanks. # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Phil 1899 only - May 11 0:00 0 S Rule Phil 1936 only - Nov 1 0:00 1:00 D @@ -685,7 +686,8 @@ Rule Phil 1978 only - Mar 22 0:00 1:00 D Rule Phil 1978 only - Sep 21 0:00 0 S # Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Manila 8:04:00 - LMT 1899 May 11 +Zone Asia/Manila -15:56:00 - LMT 1844 + 8:04:00 - LMT 1899 May 11 8:00 Phil P%sT 1942 May 9:00 - JST 1944 Nov 8:00 Phil P%sT @@ -755,8 +757,7 @@ # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Dushanbe 4:35:12 - LMT 1924 May 2 5:00 - TSK 1957 Mar - 6:00 Russia TS%s 1991 Sep 29 3:00 - 5:00 Russia TS%s + 6:00 Russia TS%s # Thailand # Zone NAME GMTOFF RULES FORMAT [UNTIL] @@ -767,9 +768,8 @@ # Turkmenistan # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Ashkhabad 3:53:32 - LMT 1924 May 2 - 4:00 - BSK 1957 Mar - 5:00 Russia SS%s 1991 Sep 29 3:00 - 4:00 Russia BS%s + 4:00 - ASK 1957 Mar + 5:00 Russia AS%s # United Arab Emirates # Zone NAME GMTOFF RULES FORMAT [UNTIL] @@ -780,8 +780,7 @@ # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Tashkent 4:37:12 - LMT 1924 May 2 5:00 - TSK 1957 Mar - 6:00 Russia TS%s 1991 Sep 29 3:00 - 5:00 Russia TS%s + 6:00 Russia TS%s # Vietnam # From Paul Eggert (November 18, 1993): diff -ruN glibc-1.08.1/time/australasia glibc-1.09/time/australasia --- glibc-1.08.1/time/australasia Mon Feb 7 14:30:51 1994 +++ glibc-1.09/time/australasia Mon Aug 22 15:21:17 1994 @@ -1,4 +1,4 @@ -# @(#)australasia 7.19 +# @(#)australasia 7.20 # This file also includes Pacific islands. # Notes are at the end of this file @@ -52,7 +52,7 @@ Rule AS 1972 only - Feb 27 3:00 0 - Rule AS 1973 1985 - Mar Sun>=1 3:00 0 - Rule AS 1986 1989 - Mar Sun>=15 3:00 0 - -Rule AS 1990 max even Mar Sun>=22 3:00 0 - +Rule AS 1990 max even Mar Sun>=18 3:00 0 - Rule AS 1990 max odd Mar Sun>=1 3:00 0 - # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Australia/Adelaide 9:14:20 - LMT 1895 Feb @@ -181,7 +181,7 @@ # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Pacific/Tarawa 11:32:04 - LMT 1901 # Bairiki 12:00 - NZST -Zone Pacific/Enderbury -12:35:40 - LMT 1901 +Zone Pacific/Enderbury -11:24:20 - LMT 1901 -12:00 - KJT 1979 Oct -11:00 - SST Zone Pacific/Kiritimati -10:29:20 - LMT 1901 @@ -330,7 +330,7 @@ # Wallis and Futuna # Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Pacific/Wallis 11:44:40 - LMT 1901 +Zone Pacific/Wallis 12:15:20 - LMT 1901 12:00 - NZST # Western Samoa @@ -344,11 +344,19 @@ # go ahead and edit the file (and please send any changes to # tz@elsie.nci.nih.gov for general use in the future). -# From Paul Eggert (November 18, 1993): +# From Paul Eggert (August 18, 1994): # A good source for time zone historical data outside the U.S. is # Thomas G. Shanks, The International Atlas (3rd edition), # San Diego: ACS Publications, Inc. (1991). -# Except where noted below, it is the source for the data above. +# Except where noted, it is the source for the data above. +# +# Another source occasionally used is Edward W. Whitman, World Time Differences, +# Whitman Publishing Co, 2 Niagara Av, Ealing, London (undated), which +# I found in the UCLA library. +# +# A reliable and entertaining source about time zones is +# Derek Howse, Greenwich time and the discovery of the longitude, +# Oxford University Press (1980). # # I invented the abbreviations marked `*' in the following table; # the rest are from earlier versions of this file, or from other sources. @@ -547,6 +555,16 @@ # numbered year (from 1990). That's when the Adelaide Festival # is on... +# From Robert Elz (March 16, 1992, 00:57:07 +1000): +# DST didn't end in Adelaide today (yesterday).... +# But whether it's "4th Sunday" or "2nd last Sunday" I have no idea whatever... +# (it's just as likely to be "the Sunday we pick for this year"...). + +# From Bradley White (April 11, 1994): +# If Sun, 15 March, 1992 was at +1030 as kre asserts, but yet Sun, 20 March, +# 1994 was at +0930 as John Connolly's customer seems to assert, then I can +# only conclude that the actual rule is more complicated.... + # Australia/Tasmania # From Bradley White (March 4, 1991): @@ -706,6 +724,12 @@ ############################################################################### +# Fiji + +# Howse writes (p 162) that in 1879 the British governor of Fiji +# enacted an ordinance standardizing the islands on +12:00. +# Perhaps it didn't take. We go with Shanks's more precise date in 1915. + # Kwajalein # In comp.risks 14.87 (26 August 1993), Peter Neumann writes: @@ -713,3 +737,10 @@ # August 20, 1993. Thursday night at midnight Kwajalein switched sides with # respect to the International Date Line, to rejoin its fellow islands, # going from 11:59 p.m. Thursday to 12:00 m. Saturday in a blink. + +# Pacific Islands Trust Territories + +# Howse writes (p 162) ``The Spaniards, on the other hand, reached the +# Philippines and the Ladrones from America,'' and implies that the Ladrones +# (now called the Marianas) kept American date for quite some time. +# Ignore this for now, as we have no hard data. See also Asia/Manila. diff -ruN glibc-1.08.1/time/europe glibc-1.09/time/europe --- glibc-1.08.1/time/europe Mon Feb 7 14:30:52 1994 +++ glibc-1.09/time/europe Mon Aug 22 15:21:18 1994 @@ -1,4 +1,4 @@ -# @(#)europe 7.14 +# @(#)europe 7.16 # This data is by no means authoritative; if you think you know better, # go ahead and edit the file (and please send any changes to @@ -32,15 +32,17 @@ # 2:00 EET+DST Eastern Europe # 3:00 MSK MSD Moscow # 3:00 TUR+DST Turkey (no longer used)* -# 4:00 ESK ESD Yekaterinburg* -# 5:00 OSK OSD Omsk* -# 6:00 NSK NSD Novosibirsk -# 7:00 ISK ISD Irkutsk* -# 8:00 YSK YSD Yakutsk* -# 9:00 VSK VSD Vladivostok* -# 10:00 GSK GSD Magadan* -# 11:00 PSK PSD Petropavlovsk-Kamchatski* -# 12:00 ASK ASD Anadyr* +# 4:00 KSK KSD Kuybyshev* +# 5:00 ESK ESD Yekaterinburg* +# 6:00 OSK OSD Omsk* +# 6:00 NSK NSD Novosibirsk (was 7:00 until 1994) +# 7:00 TSK TSD Tomsk* +# 8:00 ISK ISD Irkutsk* +# 9:00 YSK YSD Yakutsk* +# 10:00 VSK VSD Vladivostok* +# 11:00 GSK GSD Magadan* +# 12:00 PSK PSD Petropavlovsk-Kamchatski* +# 13:00 ASK ASD Anadyr* # # See the `africa' file for Zone naming conventions. # @@ -55,6 +57,27 @@ # United Kingdom +# From Peter Ilieve (July 6, 1994): +# +# On 17 Jan 1994 the Independent, a UK quality newspaper, had a piece about +# historical vistas along the Thames in west London. There was a photo +# and a sketch map showing some of the sightlines involved. One paragraph +# of the text said: +# +# `An old stone obelisk marking a forgotten terrestrial meridian stands +# beside the river at Kew. In the 18th century, before time and longditude +# was standardised by the Royal Observatory in Greenwich, scholars observed +# this stone and the movement of stars from Kew Observatory nearby. They +# made their calculations and set the time for the Horse Guards and Parliament, +# but now the stone is obscured by scrubwood and can only be seen by walking +# along the towpath within a few yards of it.' +# +# I have a one inch to one mile map of London and my estimate of the stone's +# position is 51 deg. 28' 30" N, 0 deg. 18' 45" W. The longditude should +# be within about +-2". The Ordnance Survey grid reference is TQ172761. +# +# [This yields GMTOFF = -0:01:15 for London LMT in the 18th century.] + # From Paul Eggert (November 18, 1993): # # Howse writes that Britain was the first country to use standard time. @@ -421,7 +444,7 @@ # ## is either a single year or a hyphen separated range, with -- # ## also accepted as I use this in TeX a lot. # ## and are a digit followed bu a month name. -# ## It is either an nth Saturday or an explcit date, depending on . +# ## It is either an nth Saturday or an explicit date, depending on . # ## 0 and/or none are used when there is no date, as during 1968--71. # ## can contain `fixed' to indicate explicit dates and `double' # ## to indicate double summer time dates are present. @@ -547,6 +570,28 @@ # 1993 28 Mar 24 Oct fixed # 1994 27 Mar 23 Oct fixed +# From Peter Ilieve (June 8, 1994): +# The European Union bureaucracy has edged a step closer to a 7th Directive +# on summer-time arrangements. I have the text of a Common Position +# (EC No 9/94) and a statement of the Council's reasons dated 4 March 94, +# reported in the Official Journal of the EC, No. C 137/38--41.... +# The dates again: +# Year Start End End (UK & Eire, 1995 only) +# (rule) (last Sun) (last Sun) (4th Sun) +# 1995 26 March 24 September 22 October +# 1996 31 March 27 October +# 1997 30 March 26 October + +# From Peter Ilieve (March 28, 1994): +# The UK/Eire end date of 22 October [1995] conflicts with your current rule of +# Oct Sun>=23, and the historical UK formula of Sun after 4th Sat. +# The last time 4th Sun and Sun after 4th Sat differed was in 1989, +# when 29 October was used. That year was covered by a UK Summer Time Order +# for only a single year and it looks as though there was a matching 4th EC +# directive for just this year. I don't have the text of the 5th EC +# directive (for 1990--92) but my guess would be it said 4th Sun. +# To maintain strict historical accuracy you could start a new UK ending rule +# of Oct Sun>=22 in 1990. # From Paul Eggert (November 18, 1993): # @@ -651,9 +696,13 @@ # Current rules Rule GB-Eire 1981 max - Mar lastSun 1:00s 1:00 BST Rule GB-Eire 1981 max - Oct Sun>=23 1:00s 0 GMT +# Under the 7th EU proposal, replace the above line with the following three: +#Rule GB-Eire 1981 1989 - Oct Sun>=23 1:00s 0 GMT +#Rule GB-Eire 1990 1995 - Oct Sun>=22 1:00s 0 GMT +#Rule GB-Eire 1996 max - Oct lastSun 1:00s 0 GMT # Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Europe/London -0:00:37 - LMT 1847 Sep 22 +Zone Europe/London -0:01:15 - LMT 1847 Sep 22 0:00 GB-Eire %s 1968 Feb 18 2:00 1:00 - BST 1971 Oct 31 2:00 0:00 GB-Eire %s @@ -707,6 +756,9 @@ Rule M-Eur 1977 only - Sep lastSun 2:00s 0 - Rule M-Eur 1978 only - Oct 1 2:00s 0 - Rule M-Eur 1979 max - Sep lastSun 2:00s 0 - +# Under the 7th EU proposal, replace the above line with the following two: +#Rule M-Eur 1979 1995 - Sep lastSun 2:00s 0 - +#Rule M-Eur 1996 max - Oct lastSun 2:00s 0 - Rule M-Eur 1981 max - Mar lastSun 2:00s 1:00 " DST" Rule E-Eur 1981 max - Mar lastSun 3:00s 1:00 " DST" @@ -730,10 +782,8 @@ Rule Russia 1921 only - Oct 1 0:00 0 K Rule Russia 1981 1984 - Apr 1 0:00 1:00 D Rule Russia 1981 1983 - Oct 1 0:00 0 K -Rule Russia 1984 1990 - Sep lastSun 2:00s 0 K -Rule Russia 1985 1990 - Mar lastSun 2:00s 1:00 D -Rule Russia 1992 max - Sep lastSun 2:00s 0 K -Rule Russia 1992 max - Mar lastSun 2:00s 1:00 D +Rule Russia 1984 max - Sep lastSun 2:00s 0 K +Rule Russia 1985 max - Mar lastSun 2:00s 1:00 D # These are for backward compatibility with older versions. @@ -813,8 +863,11 @@ 2:31 Russia LST%s 1919 Jul 1 2:00 3:00 Russia MS%s 1922 Oct 2:00 - EET 1930 Jun 21 - 3:00 Russia MS%s 1991 Sep 29 3:00 - 2:00 Russia MS%s + 3:00 Russia MS%s 1991 Mar 31 2:00s +# From Paul Eggert (May 28, 1994): A guess at recent dates: + 2:00 1:00 "EET DST" 1991 Sep 29 2:00s + 2:00 - EET 1992 Jan 19 2:00s + 3:00 Russia MS%s # Belgium # Whitman and Shanks disagree; go with Shanks, usually. @@ -943,7 +996,7 @@ 1:00 M-Eur MET%s 1945 Apr 2 2:00 1:00 Denmark MET%s 1980 Apr 6 2:00 1:00 M-Eur MET%s -Zone Atlantic/Faeroe 0:27:04 - LMT 1908 Jan 11 # Torshavn +Zone Atlantic/Faeroe -0:27:04 - LMT 1908 Jan 11 # Torshavn 0:00 - WET 1981 Mar 29 1:00 0:00 W-Eur WET%s Zone America/Scoresbysund -1:29:00 - LMT 1916 Jul 28 @@ -966,8 +1019,9 @@ 2:00 - EET 1940 Aug 6 3:00 - MSK 1941 Sep 15 1:00 M-Eur MET%s 1944 Sep 22 - 3:00 Russia MS%s 1989 Mar 26 2:00 - 2:00 M-Eur MET%s + 3:00 Russia MS%s 1989 Mar 26 2:00s + 2:00 1:00 "EET DST" 1989 Sep 24 2:00s + 2:00 M-Eur EET%s # Finland # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S @@ -1162,7 +1216,7 @@ # to the julian/gregorian calendar) over the period in question. # the winter begins on the Saturday next before St. Luke's day # (old style), or on St. Luke's day, if a Saturday. -# St. Luke's day ought to be traceable from ecclesiatical sources. "old style" +# St. Luke's day ought to be traceable from ecclesiastical sources. "old style" # might be a reference to the Julian calendar as opposed to Gregorian, or it # might mean something else (???). The Gregorian calendar was not introduced # in Iceland until 1700. @@ -1260,12 +1314,13 @@ 2:00 - EET 1940 Aug 5 3:00 - MSK 1941 Jul 1:00 M-Eur MET%s 1944 Aug 8 - 3:00 Russia MS%s 1991 Sep 29 3:00 - 2:00 M-Eur MET%s + 3:00 Russia MS%s 1991 Mar 31 2:00s + 2:00 1:00 "EET DST" 1991 Sep 29 2:00s + 2:00 M-Eur EET%s # Liechtenstein # Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Europe/Vaduz 0:30:04 - LMT 1894 Jun +Zone Europe/Vaduz 0:38:04 - LMT 1894 Jun 1:00 - MET 1981 Mar 29 2:00 1:00 M-Eur MET%s @@ -1280,8 +1335,9 @@ 1:00 - MET 1940 Aug 3 3:00 - MSK 1941 Jun 24 1:00 M-Eur MET%s 1944 Aug - 3:00 Russia MS%s 1991 Sep 29 3:00 - 2:00 M-Eur MET%s + 3:00 Russia MS%s 1991 Mar 31 2:00s + 2:00 1:00 "EET DST" 1991 Sep 29 2:00s + 2:00 M-Eur EET%s # Luxembourg # Whitman disagrees with most of these dates in minor ways; go with Shanks. @@ -1319,7 +1375,7 @@ 1:00 Belgium MET%s 1979 Apr 1 2:00 1:00 M-Eur MET%s -# The Former Yugoslav Republic of Macedonia +# Macedonia # They switched from the Julian to the Gregorian calendar on 1918 Mar 18. # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Europe/Skopje 1:25:44 - LMT 1884 @@ -1351,8 +1407,8 @@ # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Europe/Chisinau 1:55:20 - LMT 1924 May 2 2:00 - EET 1930 Jun 21 - 3:00 - MSK 1981 Apr - 3:00 Russia MS%s 1991 Sep 29 2:00s + 3:00 Russia MS%s 1991 Mar 31 2:00s + 2:00 1:00 "EET DST" 1991 Sep 29 2:00s 2:00 M-Eur EET%s # Monaco @@ -1435,7 +1491,7 @@ Rule Poland 1919 only - Apr 15 2:00s 1:00 " DST" # Whitman gives 1944 Nov 30; go with Shanks. Rule Poland 1944 only - Oct 4 2:00 0 - -# For 1944-1948 Whitman gives the previous day; go with SHanks. +# For 1944-1948 Whitman gives the previous day; go with Shanks. Rule Poland 1945 only - Apr 29 0:00 1:00 " DST" Rule Poland 1945 only - Nov 1 0:00 0 - Rule Poland 1946 only - Apr 14 0:00 1:00 " DST" @@ -1574,74 +1630,105 @@ 2:00 M-Eur EET%s # Russia -# From Paul Eggert (November 18, 1993): +# From Paul Eggert (May 28, 1994): # Moscow and Novosibirsk time zone names, and Moscow rules after 1991, # are from Andrew A. Chernov . -# I invented the other time zone names. -# The rest is from Shanks; it's probably wrong after 1991. -# We're not sure whether St Petersburg switched in step with Moscow after 1991; -# it might be a useless name, so we'll comment it out for now. +# I invented the other time zone names, and (unless otherwise specified) +# guessed what happened after 1991; the clocks were chaotic, and we know little. +# The rest is from Shanks. # # From Shanks (1991): # Western Russia switched from the Julian to the Gregorian calendar -# on 1918 Jan 14. Eatern Russia switched on 1920 Mar 18. +# on 1918 Jan 14. Eastern Russia switched on 1920 Mar 18. # In 1929 the Soviet Union instituted a 5 day week; in 1932 it instituted # a 6 day week; on 1940 Jun 27 it returned to the Gregorian week. # Zone NAME GMTOFF RULES FORMAT [UNTIL] -#Zone Europe/St_Petersburg 2:30:20 - LMT 1880 -# 2:01 Russia LST%s 1919 Jul 1 2:00 -# 3:00 Russia MS%s 1922 Oct -# 2:00 - EET 1930 Jun 21 -# 3:00 Russia MS%s 1991 Sep 29 3:00 -# 2:00 Russia SPS%s -Zone Europe/Moscow 2:30:20 - LMT 1880 - 2:31 Russia LST%s 1919 Jul 1 2:00 - 3:00 Russia MS%s 1922 Oct - 2:00 - EET 1930 Jun 21 - 3:00 Russia MS%s 1991 Mar lastSun 2:00s - 2:00 1:00 "EET DST" 1991 Sep lastSun 2:00s - 2:00 - EET 1992 Jan 19 2:00s - 3:00 Russia MS%s -Zone Asia/Yekaterinburg 4:02:34 - LMT 1924 May 2 - 4:00 - ESK 1957 Mar - 5:00 Russia ES%s 1991 Sep 29 3:00 - 4:00 Russia ES%s -Zone Asia/Omsk 4:53:36 - LMT 1924 May 2 - 5:00 - TSK 1957 Mar - 6:00 Russia TS%s 1991 Sep 29 3:00 - 5:00 Russia OS%s -Zone Asia/Novosibirsk 5:31:40 - LMT 1924 May 2 - 6:00 - NSK 1957 Mar - 7:00 Russia NS%s 1991 Sep 29 3:00 - 6:00 Russia NS%s -Zone Asia/Irkutsk 6:57:20 - LMT 1880 - 6:57 - LST 1924 May 2 - 7:00 - ISK 1957 Mar - 8:00 Russia IS%s 1991 Sep 29 3:00 - 7:00 Russia IS%s -Zone Asia/Yakutsk 8:38:40 - LMT 1924 May 2 - 8:00 - YSK 1957 Mar - 9:00 Russia YS%s 1991 Sep 29 3:00 - 8:00 Russia YS%s -Zone Asia/Vladivostok 8:47:44 - LMT 1880 - 8:48 - LST 1924 May 2 - 9:00 - VSK 1957 Mar - 10:00 Russia VS%s 1991 Sep 29 3:00 - 9:00 Russia VS%s +Zone Europe/Moscow 2:30:20 - LMT 1880 + 2:31 Russia LST%s 1919 Jul 1 2:00 + 3:00 Russia MS%s 1922 Oct + 2:00 - EET 1930 Jun 21 + 3:00 Russia MS%s 1991 Mar 31 2:00s + 2:00 1:00 "EET DST" 1991 Sep 29 2:00s + 2:00 - EET 1992 Jan 19 2:00s + 3:00 Russia MS%s +Zone Europe/Kuybyshev 3:20:36 - LMT 1924 May 2 + 3:00 - KSK 1957 Mar + 4:00 Russia KS%s 1991 Mar 31 2:00s + 3:00 1:00 KSD 1991 Sep 29 2:00s + 3:00 - KSK 1992 Jan 19 2:00s + 4:00 Russia KS%s +Zone Asia/Yekaterinburg 4:02:34 - LMT 1924 May 2 + 4:00 - SSK 1957 Mar + 5:00 Russia SS%s 1991 Mar 31 2:00s + 4:00 1:00 SSD 1991 Sep 29 2:00s + 4:00 - SSK 1992 Jan 19 2:00s + 5:00 Russia ES%s # name change from Sverdlovsk +Zone Asia/Omsk 4:53:36 - LMT 1924 May 2 + 5:00 - OSK 1957 Mar + 6:00 Russia OS%s 1991 Mar 31 2:00s + 5:00 1:00 OSD 1991 Sep 29 2:00s + 5:00 - OSK 1992 Jan 19 2:00s + 6:00 Russia OS%s +# From Stanislaw A. Kuzikowski (June 29, 1994): +# But now it is some months since Novosibirsk is 3 hours ahead of Moscow! +# I do not know why they have decided to make this change; +# as far as I remember it was done exactly during winter->summer switching +# so we (Novosibirsk) simply did not switch. +# Tomsk is still 4 hours ahead of Moscow. +Zone Asia/Novosibirsk 5:31:40 - LMT 1924 May 2 + 6:00 - NSK 1957 Mar + 7:00 Russia NS%s 1991 Mar 31 2:00s + 6:00 1:00 NSD 1991 Sep 29 2:00s + 6:00 - NSK 1992 Jan 19 2:00s + 7:00 Russia NS%s 1994 Mar 27 2:00s + 6:00 1:00 NSD 1994 Sep 25 2:00s + 6:00 Russia NS%s +Zone Asia/Tomsk 5:39:52 - LMT 1924 May 2 + 6:00 - TSK 1957 Mar + 7:00 Russia TS%s 1991 Mar 31 2:00s + 6:00 1:00 TSD 1991 Sep 29 2:00s + 6:00 - TSK 1992 Jan 19 2:00s + 7:00 Russia TS%s +Zone Asia/Irkutsk 6:57:20 - LMT 1880 + 6:57 - LST 1924 May 2 + 7:00 - ISK 1957 Mar + 8:00 Russia IS%s 1991 Mar 31 2:00s + 7:00 1:00 ISD 1991 Sep 29 2:00s + 7:00 - ISK 1992 Jan 19 2:00s + 8:00 Russia IS%s +Zone Asia/Yakutsk 8:38:40 - LMT 1924 May 2 + 8:00 - YSK 1957 Mar + 9:00 Russia YS%s 1991 Mar 31 2:00s + 8:00 1:00 YSD 1991 Sep 29 2:00s + 8:00 - YSK 1992 Jan 19 2:00s + 9:00 Russia YS%s +Zone Asia/Vladivostok 8:47:44 - LMT 1880 + 8:48 - LST 1924 May 2 + 9:00 - VSK 1957 Mar + 10:00 Russia VS%s 1991 Mar 31 2:00s + 9:00 1:00 VSD 1991 Sep 29 2:00s + 9:00 - VSK 1992 Jan 19 2:00s + 10:00 Russia VS%s # MSK is taken; settle for GSK. Zone Asia/Magadan 10:03:12 - LMT 1924 May 2 10:00 - GSK 1957 Mar - 11:00 Russia GS%s 1991 Sep 29 3:00 - 10:00 Russia GS%s + 11:00 Russia GS%s 1991 Mar 31 2:00s + 10:00 1:00 GSD 1991 Sep 29 2:00s + 10:00 - GSK 1992 Jan 19 2:00s + 11:00 Russia GS%s # This name should be Asia/Petropavlovsk-Kamchatski, but that's too long. Zone Asia/Kamchatka 10:34:36 - LMT 1924 May 2 11:00 - PSK 1957 Mar - 12:00 Russia PS%s 1991 Sep 29 3:00 - 11:00 Russia PS%s + 12:00 Russia PS%s 1991 Mar 31 2:00s + 11:00 1:00 PSD 1991 Sep 29 2:00s + 11:00 - PSK 1992 Jan 19 2:00s + 12:00 Russia PS%s Zone Asia/Anadyr 11:49:56 - LMT 1924 May 2 12:00 - ASK 1957 Mar - 13:00 Russia AS%s 1991 Sep 29 3:00 - 12:00 Russia AS%s + 13:00 Russia AS%s 1991 Mar 31 2:00s + 12:00 1:00 ASD 1991 Sep 29 2:00s + 12:00 - ASK 1992 Jan 19 2:00s + 13:00 Russia AS%s # Serbia # They switched from the Julian to the Gregorian calendar on 1918 Mar 18. @@ -1703,7 +1790,7 @@ Rule Spain 1977 1978 - Apr 2 23:00 1:00 " DST" Rule Spain 1978 only - Oct 1 1:00 0 - # Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Europe/Madrid 0:14:44 - LMT 1901 +Zone Europe/Madrid -0:14:44 - LMT 1901 0:00 Spain WET%s 1946 Sep 30 1:00 Spain MET%s 1979 Apr 1 2:00 1:00 M-Eur MET%s @@ -1816,12 +1903,24 @@ Rule Ukraine 1921 only - Sep 1 0:00 1:00 " DST" Rule Ukraine 1921 only - Oct 1 0:00 0 - # Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Europe/Kiev 2:02:04 - LMT 1880 +Zone Europe/Kiev 2:02:04 - LMT 1880 2:02 Russia LST%s 1919 Jul 1 2:00 2:02 Ukraine LST%s 1924 May 2 2:00 - EET 1930 Jun 21 3:00 Russia MS%s 1990 Jul 17 2:00 M-Eur EET%s +Zone Europe/Simferopol 2:16:24 - LMT 1880 + 2:08 Russia LST%s 1919 Jul 1 2:00 + 2:08 Ukraine LST%s 1924 May 2 + 2:00 - EET 1930 Jun 21 + 3:00 Russia MS%s 1991 Mar 31 2:00s + 2:00 1:00 "EET DST" 1991 Sep 29 2:00s +# From Paul Eggert (May 28, 1994): +# Today's _Economist_ (p 45) reports that Crimea switched +# from Kiev to Moscow time sometime after the January elections. +# For now, we'll guess that there was a 2-hour leap forward on March 27. + 2:00 M-Eur EET%s 1994 Mar 27 2:00s + 3:00 Russia MS%s ############################################################################### diff -ruN glibc-1.08.1/time/mktime.c glibc-1.09/time/mktime.c --- glibc-1.08.1/time/mktime.c Fri Feb 11 22:41:26 1994 +++ glibc-1.09/time/mktime.c Tue Sep 27 17:15:13 1994 @@ -1,5 +1,7 @@ /* Copyright (C) 1993, 1994 Free Software Foundation, Inc. - Contributed by Noel Cragg (noel@cs.oberlin.edu). + Contributed by Noel Cragg (noel@cs.oberlin.edu), with fixes by + Michael E. Calwas (calwas@ttd.teradyne.com) and + Wade Hampton (tasi029@tmn.com). This file is part of the GNU C Library. @@ -23,14 +25,7 @@ /* #define DEBUG */ #ifdef HAVE_CONFIG_H -#if defined (CONFIG_BROKETS) -/* We use instead of "config.h" so that a compilation - using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h - (which it would do because it found this file in $srcdir). */ #include -#else -#include "config.h" -#endif #endif #include /* Some systems define `time_t' here. */ @@ -66,13 +61,6 @@ hang -- make sure we always return when we're searching for a value */ -/* After testing this, the maximum number of iterations that I had on - any number that I tried was 3! Not bad. - - mktime converts a `struct tm' (broken-down local time) into a `time_t'; - it is the opposite of localtime. It is possible to put the following - values out of range and have mktime compensate: tm_sec, tm_min, tm_hour, - tm_mday, tm_year. The other values in the structure are ignored. */ #ifdef DEBUG @@ -86,10 +74,10 @@ printtm (it) struct tm *it; { - printf ("%d/%d/%d %d:%d:%d (%s) yday:%d f:%d o:%ld", - it->tm_mon, + printf ("%02d/%02d/%04d %02d:%02d:%02d (%s) yday:%03d dst:%d gmtoffset:%ld", + it->tm_mon + 1, it->tm_mday, - it->tm_year, + it->tm_year + 1900, it->tm_hour, it->tm_min, it->tm_sec, @@ -158,80 +146,26 @@ } -/* Modified b-search -- make intelligent guesses as to where the time might - lie along the timeline, assuming that our target time lies a linear - distance (w/o considering time jumps of a particular region). - - Assume that time does not fluctuate at all along the timeline -- e.g., - assume that a day will always take 86400 seconds, etc. -- and come up - with a hypothetical value for the time_t representation of the struct tm - TARGET, in relation to the guess variable -- it should be pretty close! */ - -static time_t -search (target, producer) - struct tm *target; - struct tm *(*producer) __P ((const time_t *)); -{ - struct tm *guess_tm; - time_t guess = 0; - time_t distance = 0; - - times_through_search = 0; - - do - { - guess += distance; - - times_through_search++; - - guess_tm = (*producer) (&guess); - -#ifdef DEBUG - if (debugging_enabled) - { - printf ("guess %d == ", (int) guess); - printtm (guess_tm); - puts (""); - } -#endif - - /* Are we on the money? */ - distance = dist_tm (target, guess_tm); - - } while (distance != 0); - - return guess; -} - -/* Since this function will call localtime many times (and the user might - be passing their `struct tm *' right from localtime, let's make a copy - for ourselves and run the search on the copy. +/* MKTIME converts the values in a struct tm to a time_t. The values + in tm_wday and tm_yday are ignored; other values can be put outside + of legal ranges since they will be normalized. This routine takes + care of that normalization. */ - Also, we have to normalize *TIMEPTR because it's possible to call mktime - with values that are out of range for a specific item (like Feb 30th). */ -time_t -_mktime_internal (timeptr, producer) - struct tm *timeptr; - struct tm *(*producer) __P ((const time_t *)); +void +do_normalization (tmptr) + struct tm *tmptr; { - struct tm private_mktime_struct_tm; /* Yes, users can get a ptr to this. */ - struct tm *me; - time_t result; - - me = &private_mktime_struct_tm; - - *me = *timeptr; #define normalize(foo,x,y,bar); \ - while (me->foo < x) \ + while (tmptr->foo < x) \ { \ - me->bar--; \ - me->foo = (y - (x - me->foo)); \ + tmptr->bar--; \ + tmptr->foo = (y - (x - tmptr->foo) + 1); \ } \ - while (me->foo > y) \ + while (tmptr->foo > y) \ { \ - me->bar++; \ - me->foo = (x + (me->foo - y)); \ + tmptr->foo = (x + (tmptr->foo - y) - 1); \ + tmptr->bar++; \ } normalize (tm_sec, 0, 59, tm_min); @@ -240,8 +174,19 @@ /* Do the month first, so day range can be found. */ normalize (tm_mon, 0, 11, tm_year); + + /* Since the day range modifies the month, we should be careful how + we reference the array of month lengths -- it is possible that + the month will go negative, hence the modulo... + + Also, tm_year is the year - 1900, so we have to 1900 to have it + work correctly. */ + normalize (tm_mday, 1, - __mon_lengths[__isleap (me->tm_year)][me->tm_mon], + __mon_lengths[__isleap (tmptr->tm_year + 1900)] + [((tmptr->tm_mon < 0) + ? (12 + (tmptr->tm_mon % 12)) + : (tmptr->tm_mon % 12)) ], tm_mon); /* Do the month again, because the day may have pushed it out of range. */ @@ -249,19 +194,205 @@ /* Do the day again, because the month may have changed the range. */ normalize (tm_mday, 1, - __mon_lengths[__isleap (me->tm_year)][me->tm_mon], + __mon_lengths[__isleap (tmptr->tm_year + 1900)] + [((tmptr->tm_mon < 0) + ? (12 + (tmptr->tm_mon % 12)) + : (tmptr->tm_mon % 12)) ], tm_mon); #ifdef DEBUG if (debugging_enabled) { - printf ("After normalizing: "); - printtm (me); - puts ("\n"); + printf (" After normalizing:\n "); + printtm (tmptr); + putchar ('\n'); } #endif - result = search (me, producer); +} + + +/* Here's where the work gets done. */ + +#define BAD_STRUCT_TM ((time_t) -1) + +time_t +_mktime_internal (timeptr, producer) + struct tm *timeptr; + struct tm *(*producer) __P ((const time_t *)); +{ + struct tm our_tm; /* our working space */ + struct tm *me = &our_tm; /* a pointer to the above */ + time_t result; /* the value we return */ + + *me = *timeptr; /* copy the struct tm that was passed + in by the caller */ + + + /***************************/ + /* Normalize the structure */ + /***************************/ + + /* This routine assumes that the value of TM_ISDST is -1, 0, or 1. + If the user didn't pass it in that way, fix it. */ + + if (me->tm_isdst > 0) + me->tm_isdst = 1; + else if (me->tm_isdst < 0) + me->tm_isdst = -1; + + do_normalization (me); + + /* Get out of here if it's not possible to represent this struct. + If any of the values in the normalized struct tm are negative, + our algorithms won't work. Luckily, we only need to check the + year at this point; normalization guarantees that all values will + be in correct ranges EXCEPT the year. */ + + if (me->tm_year < 0) + return BAD_STRUCT_TM; + + /*************************************************/ + /* Find the appropriate time_t for the structure */ + /*************************************************/ + + /* Modified b-search -- make intelligent guesses as to where the + time might lie along the timeline, assuming that our target time + lies a linear distance (w/o considering time jumps of a + particular region). + + Assume that time does not fluctuate at all along the timeline -- + e.g., assume that a day will always take 86400 seconds, etc. -- + and come up with a hypothetical value for the time_t + representation of the struct tm TARGET, in relation to the guess + variable -- it should be pretty close! + + After testing this, the maximum number of iterations that I had + on any number that I tried was 3! Not bad. + + The reason this is not a subroutine is that we will modify some + fields in the struct tm (yday and mday). I've never felt good + about side-effects when writing structured code... */ + + { + struct tm *guess_tm; + time_t guess = 0; + time_t distance = 0; + time_t last_distance = 0; + + times_through_search = 0; + + do + { + guess += distance; + + times_through_search++; + + guess_tm = (*producer) (&guess); + +#ifdef DEBUG + if (debugging_enabled) + { + printf (" Guessing time_t == %d\n ", (int) guess); + printtm (guess_tm); + putchar ('\n'); + } +#endif + + /* How far is our guess from the desired struct tm? */ + distance = dist_tm (me, guess_tm); + + /* Handle periods of time where a period of time is skipped. + For example, 2:15 3 April 1994 does not exist, because DST + is in effect. The distance function will alternately + return values of 3600 and -3600, because it doesn't know + that the requested time doesn't exist. In these situations + (even if the skip is not exactly an hour) the distances + returned will be the same, but alternating in sign. We + want the later time, so check to see that the distance is + oscillating and we've chosen the correct of the two + possibilities. + + Useful: 3 Apr 94 765356300, 30 Oct 94 783496000 */ + + if ((distance == -last_distance) && (distance < last_distance)) + { + /* If the caller specified that the DST flag was off, it's + not possible to represent this time. */ + if (me->tm_isdst == 0) + { +#ifdef DEBUG + printf (" Distance is oscillating -- dst flag nixes struct!\n"); +#endif + return BAD_STRUCT_TM; + } + +#ifdef DEBUG + printf (" Distance is oscillating -- chose the later time.\n"); +#endif + distance = 0; + } + + if ((distance == 0) && (me->tm_isdst != -1) + && (me->tm_isdst != guess_tm->tm_isdst)) + { + /* If we're in this code, we've got the right time but the + wrong daylight savings flag. We need to move away from + the time that we have and approach the other time from + the other direction. That is, if I've requested the + non-DST version of a time and I get the DST version + instead, I want to put us forward in time and search + backwards to get the other time. I checked all of the + configuration files for the tz package -- no entry + saves more than two hours, so I think we'll be safe by + moving 24 hours in one direction. IF THE AMOUNT OF + TIME SAVED IN THE CONFIGURATION FILES CHANGES, THIS + VALUE MAY NEED TO BE ADJUSTED. Luckily, we can never + have more than one level of overlaps, or this would + never work. */ + +#define SKIP_VALUE 86400 + + if (guess_tm->tm_isdst == 0) + /* we got the later one, but want the earlier one */ + distance = -SKIP_VALUE; + else + distance = SKIP_VALUE; + +#ifdef DEBUG + printf (" Got the right time, wrong DST value -- adjusting\n"); +#endif + } + + last_distance = distance; + + } while (distance != 0); + + /* Check to see that the dst flag matches */ + + if (me->tm_isdst != -1) + { + if (me->tm_isdst != guess_tm->tm_isdst) + { +#ifdef DEBUG + printf (" DST flag doesn't match! FIXME?\n"); +#endif + return BAD_STRUCT_TM; + } + } + + result = guess; /* Success! */ + + /* On successful completion, the values of tm_wday and tm_yday + have to be set appropriately. */ + + /* me->tm_yday = guess_tm->tm_yday; + me->tm_mday = guess_tm->tm_mday; */ + + *me = *guess_tm; + } + + /* Update the caller's version of the structure */ *timeptr = *me; @@ -269,7 +400,12 @@ } time_t +#ifdef DEBUG /* make it work even if the system's + libc has it's own mktime routine */ +my_mktime (timeptr) +#else mktime (timeptr) +#endif struct tm *timeptr; { return _mktime_internal (timeptr, localtime); @@ -291,11 +427,11 @@ printf ("starting long test...\n"); - for (q = 10000000; q < 1000000000; q++) + for (q = 10000000; q < 1000000000; q += 599) { - struct tm *tm = localtime (&q); + struct tm *tm = localtime ((time_t *) &q); if ((q % 10000) == 0) { printf ("%ld\n", q); fflush (stdout); } - if (q != mktime (tm)) + if (q != my_mktime (tm)) { printf ("failed for %ld\n", q); fflush (stdout); } } @@ -315,14 +451,17 @@ ++argv; time = atoi (*argv); - printf ("Time: %d %s\n", time, ctime ((time_t *) &time)); - tmptr = localtime ((time_t *) &time); - printf ("localtime returns: "); + printf ("Localtime tells us that a time_t of %d represents\n ", time); + printtm (tmptr); + putchar ('\n'); + + printf (" Given localtime's return val, mktime returns %d which is\n ", + (int) my_mktime (tmptr)); printtm (tmptr); - printf ("\n"); - printf ("mktime: %d\n\n", (int) mktime (tmptr)); + putchar ('\n'); +#if 0 tmptr->tm_sec -= 20; tmptr->tm_min -= 20; tmptr->tm_hour -= 20; @@ -332,12 +471,32 @@ tmptr->tm_gmtoff -= 20000; /* This has no effect! */ tmptr->tm_zone = NULL; /* Nor does this! */ tmptr->tm_isdst = -1; +#endif + + tmptr->tm_hour += 1; + tmptr->tm_isdst = -1; + + printf ("\n\nchanged ranges: "); + printtm (tmptr); + putchar ('\n'); - printf ("changed ranges: "); + result_time = my_mktime (tmptr); + printf ("\nmktime: %d\n", result_time); + + tmptr->tm_isdst = 0; + + printf ("\n\nchanged ranges: "); printtm (tmptr); - printf ("\n\n"); + putchar ('\n'); - result_time = mktime (tmptr); + result_time = my_mktime (tmptr); printf ("\nmktime: %d\n", result_time); } #endif /* DEBUG */ + + +/* +Local Variables: +compile-command: "gcc -g mktime.c -o mktime -DDEBUG" +End: +*/ diff -ruN glibc-1.08.1/time/northamerica glibc-1.09/time/northamerica --- glibc-1.08.1/time/northamerica Mon Feb 7 14:30:53 1994 +++ glibc-1.09/time/northamerica Mon Aug 22 15:21:18 1994 @@ -1,10 +1,15 @@ -# @(#)northamerica 7.9 +# @(#)northamerica 7.11 # also includes Central America and the Caribbean # This data is by no means authoritative; if you think you know better, # go ahead and edit the file (and please send any changes to # tz@elsie.nci.nih.gov for general use in the future). +# From Paul Eggert (August 17, 1994): +# A reliable and entertaining source about time zones is +# Derek Howse, Greenwich time and the discovery of the longitude, +# Oxford University Press (1980). + ############################################################################### # United States @@ -106,6 +111,11 @@ # Samoa standard time # The law doesn't give abbreviations. +# From Paul Eggert (August 16, 1994): +# Howse writes that Alaska switched from the Julian to the Gregorian calendar, +# and from east-of-GMT to west-of-GMT days, in 1867 when the US purchased it +# from Russia. We don't have this data pinned down yet, though. + # Easy stuff first--including Alaska, where we ignore history (since we # can't tell if we should give Yukon time or Alaska-Hawaii time for "old" # times). @@ -148,8 +158,14 @@ -5:00 US E%sT # Samoa just changes names. No DST, per Naval Observatory. +# +# Howse writes that in 1879 the King of Samoa decided to change +# ``the date in his kingdom from the Antipodean to the American system, +# ordaining -- by a masterpiece of diplomatic flattery -- that +# the Fourth of July should be celebrated twice in that year.'' -Zone Pacific/Samoa -11:22:48 - LMT 1911 +Zone Pacific/Samoa 12:37:12 - LMT 1879 Jul 5 + -11:22:48 - LMT 1911 -11:30 - SST 1950 -11:00 - NST 1967 Apr # N=Nome -11:00 - BST 1983 Nov 30 # B=Bering @@ -629,7 +645,7 @@ # Bahamas # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Bahamas 1912 max - Mar 2 0:00 0 S +Rule Bahamas 1912 only - Mar 2 0:00 0 S Rule Bahamas 1964 max - Oct lastSun 2:00 0 S Rule Bahamas 1964 1986 - Apr lastSun 2:00 1:00 D Rule Bahamas 1987 max - Apr Sun>=1 2:00 1:00 D diff -ruN glibc-1.08.1/time/strftime.c glibc-1.09/time/strftime.c --- glibc-1.08.1/time/strftime.c Sat May 15 18:46:15 1993 +++ glibc-1.09/time/strftime.c Mon Jul 18 18:12:54 1994 @@ -3,7 +3,7 @@ _ */ -/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -213,7 +213,7 @@ break; case 'j': - fmt(3, (p, "%.3d", tp->tm_yday)); + fmt(3, (p, "%.3d", 1 + tp->tm_yday)); break; case 'M': diff -ruN glibc-1.08.1/time/sys/time.h glibc-1.09/time/sys/time.h --- glibc-1.08.1/time/sys/time.h Tue Feb 22 18:50:29 1994 +++ glibc-1.09/time/sys/time.h Mon Jul 18 18:12:34 1994 @@ -29,16 +29,35 @@ microsecond but also has a range of years. */ struct timeval { - int tv_sec; /* Seconds. */ - int tv_usec; /* Microseconds. */ + int tv_sec; /* Seconds. */ + int tv_usec; /* Microseconds. */ }; +/* POSIX.4 structure for a time value. This is like a `struct timeval' but + has nanoseconds instead of microseconds. */ +struct timespec + { + long int ts_sec; /* Seconds. */ + long int ts_nsec; /* Nanoseconds. */ + }; + +/* Macros for converting between `struct timeval' and `struct timespec'. */ +#define TIMEVAL_TO_TIMESPEC(tv, ts) { \ + (ts)->ts_sec = (tv)->tv_sec; \ + (ts)->ts_nsec = (tv)->tv_usec * 1000; \ +} +#define TIMESPEC_TO_TIMEVAL(tv, ts) { \ + (tv)->tv_sec = (ts)->ts_sec; \ + (tv)->tv_usec = (ts)->ts_nsec / 1000; \ +} + + /* Structure crudely representing a timezone. This is obsolete and should never be used. */ struct timezone { - int tz_minuteswest; /* Minutes west of GMT. */ - int tz_dsttime; /* Nonzero if DST is ever in effect. */ + int tz_minuteswest; /* Minutes west of GMT. */ + int tz_dsttime; /* Nonzero if DST is ever in effect. */ }; /* Get the current time of day and timezone information, diff -ruN glibc-1.08.1/time/test_time.c glibc-1.09/time/test_time.c --- glibc-1.08.1/time/test_time.c Fri May 22 02:17:39 1992 +++ glibc-1.09/time/test_time.c Mon Aug 15 20:16:45 1994 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1992 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1992, 1994 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -55,6 +55,7 @@ tbuf.tm_hour = 6; tbuf.tm_min = 14; tbuf.tm_sec = 50; + tbuf.tm_isdst = -1; doit:; t = mktime(&tbuf); if (t == (time_t) -1) diff -ruN glibc-1.08.1/version.c glibc-1.09/version.c --- glibc-1.08.1/version.c Sun Jun 5 22:04:30 1994 +++ glibc-1.09/version.c Sun Nov 6 19:26:24 1994 @@ -19,8 +19,8 @@ #include #include -CONST char __libc_release[] = "beta"; -CONST char __libc_version[] = "1.08.1"; +CONST char __libc_release[] = "alpha"; +CONST char __libc_version[] = "1.09"; void DEFUN_VOID(__libc_print_version) @@ -36,3 +36,9 @@ There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A\n\ PARTICULAR PURPOSE."); } + +/* + Local Variables: + version-control: never + End: +*/