This file contains unidiffs between from version 1.07 to version 1.08.1 of the GNU C library. 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.07/ChangeLog glibc-1.08.1/ChangeLog --- glibc-1.07/ChangeLog Mon Jan 17 22:55:43 1994 +++ glibc-1.08.1/ChangeLog Sun Jun 5 22:04:40 1994 @@ -1,3 +1,1636 @@ +Sun Jun 5 14:34:12 1994 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * Version 1.08.1. + + * sysdeps/mach/hurd/ioctls.h (_IOR, _IOW): Swap IOC_IN and IOC_OUT. + + * sysdeps/mach/hurd/__ioctl.c: Only pack input for ioctls that + take input. Compute expected reply size for ioctls that take + output and check it properly. + +Sat Jun 4 00:35:42 1994 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * sysdeps/mach/hurd/ioctls.h (union __ioctl): Type removed. + (enum __ioctl_datum): Name this enum. + (_IOC_INOUT, _IOC_GROUP, _IOC_COMMAND, _IOC_TYPE): New macros. + (_IOT_TYPE[012], _IOT_COUNT[012]): New macros. + * sysdeps/mach/hurd/__ioctl.c: Use those macros instead of the union. + + * sysdeps/mach/hurd/__fork.c: Major rewrite. Copy all ports + present in the task, not just library-maintained ones. Handle + sigstate and signal thread setup explicitly here. + * hurd/hurdsig.c (hurdsig_fork, hurdsig_fork_child): Functions removed. + + * hurd/hurdpid.c (init_pids): Don't put this on _hurd_fork_child_hook. + + * sysdeps/mach/hurd/__isatty.c: New file. + + * hurd/hurdsock.c (_hurd_socket_server): Pass NP to __path_lookup, + not NAME (most of which is uninitialized). + + * hurd/hurdsig.c (_hurdsig_init): Don't check for _hurd_msgport + being non-null; always initialize it. + +Fri Jun 3 21:57:14 1994 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * hurd/hurdrlimit.c (init_rlimit): Restore __mutex_init call. + (_hurd_rlimit_lock): Set initializer to random value; run-time + initialization is always required. + + * inet/rcmd.c (rcmd): Compute max fd + 1 for select instead of + hardcoding 32. + +Wed Jun 1 10:52:41 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) + + * hurd/hurdrlimit.c (_hurd_rlimits, _hurd_rlimit_lock): Provide + initializers so that the file is included in the link properly. + (init_rlimit): Omit call to __mutex_init. + +Tue May 31 18:15:33 1994 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * hurd/hurdmalloc.c (more_memory): Do spin_lock_init on H->lock. + (malloc_init): New function; put it on _hurd_preinit_hook. + + * sysdeps/mach/hurd/defs.c (init_stdio): If stream already + allocated, don't allocate a new one. Don't crash if _hurd_alloc_fd + returns null if __newstream does. + + * sysdeps/mach/hurd/__brk.c (init_brk): If _hurd_brk is nonzero, + leave it as it is. Set PAGEND from _hurd_brk instead of &_end. + +Mon May 30 18:37:47 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * hurd/hurdrlimit.c (init_rlimit): Put this on _hurd_preinit_hook + instead of _hurd_subinit. + + * sysdeps/mach/hurd/mig-reply.c (mig_fork_child): Function removed. + * hurd/dtable.c (fork_parent_dtable): Function removed. + + * sysdeps/generic/resourcebits.h: Rename RLIM_NLIMITS to + RLIMIT_NLIMITS, add alias for old name. + + * sysdeps/mach/hurd/Makefile (hurd-objpfx): New variable. + (before-compile): Use that instead of $(common-objpfx). + + * sysdeps/mach/Makefile [! objpfx] (mach-objpfx): Add trailing slash. + +Fri May 27 01:34:56 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * hurd/hurdsig.c (_hurdsig_init): Always initialize _hurd_sigthread. + + * hurd/dtable.c: Use data_set_element instead of text_set_element + for _hurd_fork_locks. + * hurd/hurdsig.c: Likewise. + + * hurd/hurd.h (_hurd_set_data_limit): Declaration removed. + + * hurd/dtable.c (_hurd_dtable_rlimit): Variable removed. + (init_dtable): Don't set it. + + * hurd/Makefile (headers): Add hurd/resource.h. + (routines): Add hurdrlimit. + * hurd/hurd/resource.h: New file. + * hurd/hurdrlimit.c: New file. + * sysdeps/mach/hurd/getrlimit.c: Rewritten to just fetch _hurd_rlimits. + * sysdeps/mach/hurd/setrlimit.c: Rewritten to just set _hurd_rlimits. + * sysdeps/mach/hurd/__brk.c (_hurd_data_limit): Variable removed. + (_hurd_set_brk): Use _hurd_rlimits[RLIMIT_DATA]. + (_hurd_set_data_limit): Function removed. + * hurd/alloc-fd.c (_hurd_dtable_rlimit): Variable removed. + (_hurd_alloc_fd): Use _hurd_rlimits[RLIMIT_OFILE] instead. + + * sysdeps/generic/resourcebits.h: Add RLIMIT_NOFILE as an alias + for RLIMIT_OFILE. + + * sysdeps/mach/hurd/mig-reply.c (__mig_init): Argument is stack + on which to set the per-thread reply port variable. + + * sysdeps/mach/hurd/__brk.c (init_brk): Set _hurd_data_end to + DATA_SIZE bytes past the beginning of data space, rather than to + DATA_SIZE absolutely. If vm_map fails, set it to PAGEND. + + * sysdeps/mach/hurd/start.c (_start): Run _hurd_preinit_hook right + after __mach_init. + + * stdio/freopen.c (freopen): Rewritten using __stdio_reopen to + preserve the old cookie value when possible. + * sysdeps/posix/sysd-stdio.c (__stdio_reopen): New function. + * sysdeps/stub/sysd-stdio.c (__stdio_reopen): New function. + * sysdeps/mach/hurd/sysd-stdio.c (__stdio_reopen): New function. + + * stdio/freopen.c (freopen): Close the stream if MODE is invalid. + + * hurd/hurdsig.c (_hurd_core_limit): Define variable. + + * socket/sys/socket.h (PF_LOCAL): Define in preference to PF_FILE. + +Thu May 26 12:09:51 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) + + * hurd/alloc-fd.c (_hurd_alloc_fd): Don't return EINVAL when + FIRST_FD is greater than _hurd_dtablesize and less than + _hurd_dtable_rlimit. If we want to grow _hurd_dtable, but + _hurd_dtablesize is as big as _hurd_dtable_rlimit, then return + EMFILE. When growing _hurd_dtable, actually do something if + _hurd_dtablesize is zero. + + * hurd/hurdmalloc.c (malloc_fork_prepare, malloc_fork_parent, + malloc_fork_child): Declare as static so they don't conflict with + the user's version of this file. + +Wed May 25 20:55:16 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * sysdeps/mach/hurd/__brk.c: Include instead of . + + * hurd/hurdmalloc.c, hurd/hurdmalloc.h: New files (temporary hack). + * hurd/Makefile (routines): Append hurdmalloc. + (distribute): Append hurdmalloc.h. + * hurd/alloc-fd.c: Include "hurdmalloc.h" (temporary hack). + * hurd/dtable.c: Likewise. + * hurd/hurdinit.c: Likewise. + * hurd/hurdsig.c: Likewise. + * hurd/hurdsock.c: Likewise. + * hurd/new-fd.c: Likewise. + * sysdeps/mach/hurd/start.c: Likewise. + + * sysdeps/mach/hurd/start.c (start1): Use malloc and a for loop + instead of calloc. + * hurd/hurdsig.c (_hurd_thread_sigstate): Use malloc and memset + instead of calloc. + + * sysdeps/mach/hurd/__brk.c (init_brk): Reference self to avoid + compiler warning. Add init_brk to _hurd_preinit_hook instead of + __libc_subinit. + + * sysdeps/mach/hurd/start.c (_hurd_preinit_hook): New variable. + (start1): Run _hurd_preinit_hook before threadvar setup. + +Tue May 24 17:42:34 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * hurd/dtable.c (init_dtable): Initialize _hurd_dtablesize to + _hurd_init_dtablesize. Initialize _hurd_dtable_rlimit as + _hurd_dtablesize used to be set, but don't let it be zero. + (_hurd_dtable_rlimit): New variable. + +Tue May 24 12:57:19 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) + + * sysdeps/mach/sleep.c (sleep): Timeout arg to mach_msg is + in milliseconds, not microseconds; compute it accordingly. + + * sysdeps/mach/hurd/__select.c (__select): Deleted variables + DTABLE and DTABLE_ULINK. Use new vars _hurd_dtablesize and + _hurd_dtable instead of old _hurd_dtable structure. Use new + locking protocol on _hurd_dtable. + +Tue May 24 01:55:24 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * sysdeps/mach/hurd/__setitmr.c: Don't include mutex.h. + + * sysdeps/mach/hurd/defs.c (init_stdio): Reference self. + + * sysdeps/unix/sysv/sysv4/i386/sysdep.h: Include + sysdeps/unix/sysv/i386/sysdep.h, not sysdeps/unix/i386/sysdep.h + +Mon May 23 19:05:44 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * sysdeps/mach/hurd/Makefile (mib_hacks, defines): Variables removed. + + * mach/devstream.c (mach_open_devstream): Set STREAM's seek and + fileno io functions to null. + + * hurd/hurdexec.c (_hurd_exec): Fixed adding of dtable ports to + PLEASE_DEALLOC array. + + * sysdeps/mach/hurd/defs.c (init_stdio): Unlock the descriptors + after fetching them. If a standard descriptor is not allocated, + allocate the structure and store its pointer in the stream anyway. + + * stdio/gets.c: Only return null on P==S if feof (STREAM). + + * stdio/vfprintf.c: Make %Z a type modifier, not a format spec. + + * sysdeps/mach/hurd/fdopen.c: Return NULL rather than -1 for error. + +Mon May 23 14:24:50 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) + + * sysdeps/mach/hurd/__close.c (__close): Use new _hurd_fd_get + protocol. + * sysdeps/mach/hurd/__dup2.c (__dup2): Likewise. Use + _hurd_dtablesize and _hurd_dtable instead of old _hurd_dtable + structure. + + * sysdeps/mach/hurd/sysd-stdio.c (__stdio_seek): Use + HURD_FD_PORT_USE, not HURD_FD_USE. + * sysdeps/mach/hurd/stdio_init.c (__stdio_init_stream): Variable + is D, not FD. + + * hurd/alloc-fd.c (_hurd_alloc_fd): Arg FIRST_FD is not actually + const. + * hurd/hurdsig.c (_hurd_internal_post_signal [case SIGINFO]): If + we are not the process group leader, ignore the signal. + (_S_sig_post [case SIGURG]): Declaration of D was out of place. + + * sysdeps/mach/hurd/fdopen.c: Include for + io_get_openmodes prototype. + +Sat May 21 16:03:23 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * assert/assert.c (__assert_fail): Put program name first in msg. + + * hurd/Makefile (dtable): Removed setdtsz. + + * hurd/hurdexec.c: Use _hurd_dtable and _hurd_dtablesize instead of + old _hurd_dtable structure. + * hurd/hurdsig.c: Likewise. + * hurd/alloc-fd.c: Likewise. + * hurd/hurdioctl.c (rectty_dtable): Likewise. + + * Version 1.08 released. + + * mach/mach_error_string.c: Renamed to errstring.c. + * mach/Makefile (routines): Renamed mach_error_string to errstring. + * mach/err_mach_ipc.sub: Renamed to err_mach.sub. + * mach/err_bootstrap.sub: Renamed to err_boot.sub. + + * sysdeps/generic/sigset.h (__SIGSETFN): Take new arg CONST; use it + for CONST qualifier on SET arg to generated function. + Changed uses to pass it; sigismember passes __const, others empty. + + * sysdeps/mach/hurd/sysd-stdio.c: Rewritten to use `struct hurd_fd *'s + for cookies. + * sysdeps/mach/hurd/fdopen.c: Rewritten accordinly. + * sysdeps/mach/hurd/defs.c (init_stdio): Rewritten accordingly. + Add it to the _hurd_fd_subinit hook instead of the __libc_subinit hook. + * sysdeps/mach/hurd/stdio_init.c: New file. + * hurd/dtable.c (_hurd_fd_subinit): New hook variable. + (init_dtable): Run the _hurd_fd_subinit hook. + + * hurd/hurd/fd.h (struct hurd_dtable): Type removed. + (_hurd_dtable_users, _hurd_dtable_rlimit): Variables removed. + (_hurd_dtable): Make this a struct hurd_fd **. + (_hurd_dtablesize): New variable. + (struct hurd_fd_user): Type removed. + (_hurd_dtable_get, _hurd_dtable_free, _hurd_dtable_fd): Functions + removed. + (_hurd_fd_get): Rewritten. Take just one arg, and look it up in + _hurd_dtable; return a struct hurd_fd *. + (HURD_FD_USE): Rewritten to use new _hurd_fd_get interface. + * hurd/dtable.c (_hurd_dtable_users, _hurd_dtable_rlimit): + Variables removed. + (_hurd_dtable): Make this a struct hurd_fd **. + (_hurd_dtablesize): New variable. + (init_dtable, fork_parent_dtable, fork_child_dtable, + ctty_new_pgrp, reauth_dtable): Use new simpler _hurd_dtable format. + * sysdeps/mach/hurd/__getdtsz.c: Use _hurd_dtablesize. + * sysdeps/mach/hurd/__fcntl.c: Use new _hurd_fd_get protocol. + + * hurd/dtable.c (get_dtable_port): Return the ctty port if set. + + * hurd/hurd/fd.h (_hurd_fd_error_signal): New function, broken out + of _hurd_fd_error. + (_hurd_fd_error): Call it. + + * hurd/Makefile (dtable): Add fd-close. + * hurd/fd-close.c: New file. + * hurd/hurd/fd.h: Declare _hurd_fd_close. + + * sysdeps/mach/hurd/__close.c: Call _hurd_fd_close. + + * signal/Makefile (routines): Add sigsetops. + * signal/sigsetops.c: New file. + + * sysdeps/unix/sysv/sysv4/sigset.h (_EXTERN_INLINE): New macro. + Use it for all the inline functions. + + * signal/signal.h: Move #include inside #ifdef _SIGNAL_H. + + * sysdeps/generic/sigset.h: Protect types with #ifndef + _SIGSET_H_types. Protect rest with #if !defined (_SIGSET_H_fns) + && defined (_SIGNAL_H). + (__SIGSETFN): Add extern declaration of NAME inside function. + + * sysdeps/unix/ioctls-tmpl.c: Add missing #endif. + * sysdeps/unix/Makefile (make-ioctls-CFLAGS): Remember -D. + +Fri May 20 20:42:33 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * sysdeps/unix/Makefile (sys/termios.h): Variable removed. + (ioctl-includes): New variable. + (make-ioctls-CFLAGS): Compute value generally from $(ioctl-includes). + ($(common-objpfx)ioctls): Depend on $(ioctl-includes), instead of + $(sys/termios.h). + + * sysdeps/unix/sysv/sco3.2.4/sco_getgrp.S: New file. + * sysdeps/unix/sysv/sco3.2.4/Makefile (sysdep_routines): Add + sco_getgrp. + * sysdeps/unix/sysv/sco3.2.4/__getgrps.c: New file. + + * sysdeps/generic/sigset.h (__sigismember, __sigaddset, __sigdelset): + Rewritten as extern inline functions; check for bogus signal number. + + * configure.in (names): Put $implied before $* in new $sysnames + list remaining to be processed; this ensures unix/common precedes + unix/sysv4 for sysv4. + +Thu May 19 18:35:02 1994 Michael I Bushnell (mib@geech.gnu.ai.mit.edu) + + * sysdeps/mach/hurd/defs.c (init_stdio): Make stdin and stdout + line buffered and stderr unbuffered. + +Thu May 19 16:14:36 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * sysdeps/mach/hurd/getcwd.c: Remember to call io_stat on cwdir. + + * sysdeps/generic/configure.in: Use changequote around if expr + to avoid [] elision. + +Thu May 19 13:53:59 1994 Michael I Bushnell (mib@geech.gnu.ai.mit.edu) + + * hurd/hurdsock.c (_hurd_socket_server): Return EPFNOSUPPORT + rather than EPROTONOSUPPORT because it's the entire protocol + family that isn't present, not just one protocol. + + * sysdeps/mach/hurd/__access.c (__access): Don't deallocate + CRDIR or CWDIR; that's taken care of by the _hurd_port_get + and _hurd_port_free system. + +Thu May 19 04:14:57 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * sysdeps/posix/libc_fatal.c: Include . + + * sysdeps/unix/sysv/sysv4/__sigact.c: Include for NULL. + + * sysdeps/mach/hurd/__access.c: Fix swapped poly and count args in + __auth_makeauth call. + + * sysdeps/mach/hurd/ioctls.h (_IOC, _IOT): Rewritten using bitwise + operations, so the result is always technically a constant (the + old method of using a union constructor expression was not good + enough for initializers). + + * hurd/hurdsock.c (_hurd_socket_server): If path_lookup returns + ENOENT, we return EPROTONOSUPPORT. + + * hurd/Makefile (dtable): Add hurdioctl. + * hurd/dtable.c (rectty_dtable, tiocsctty, tiocnotty): Functions moved: + * hurd/hurdioctl.c: New file. + (fioctl, fioclex): New functions. + * sysdeps/mach/hurd/__ioctl.c (_hurd_ioctl_handler_lists): Don't + define it, just declare it. + + * sysdeps/mach/hurd/getcwd.c: Use MACH_PORT_RIGHT_SEND, not + MACH_PORT_TYPE_SEND, in mach_port_mod_refs call. + + * sysdeps/mach/hurd/__getpgrp.c: Don't lock _hurd_pid_lock. + + * sysdeps/unix/common/glue-ctype.c: Don't include . + Instead, add explicit extern declaration of TABLE in main. + +Wed May 18 17:54:00 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * sysdeps/m68k/Makefile (asm-CPPFLAGS): Append $(m68k-syntax-flag). + + * Version 1.07.6. + + * sunrpc/Makefile (+gccwarn): Set to -w. + + * sysdeps/unix/Makefile (ifeq testing sys/param.h): Use patsubst + instead of dir to remove directory name from .../sys/param.h but + preserve "sys/". + + * inet/sys/bitypes.h: Replaced with just #include . + + * posix/sys/utsname.h (_UTSNAME_NODENAME_LENGTH): If undefined, + define to _UTSNAME_LENGTH. + (struct utsname): Use _UTSNAME_NODENAME_LENGTH for `nodename' member. + * sysdeps/unix/bsd/sun/sunos4/utsnamelen.h (_UTSNAME_NODENAME_LENGTH): + Define it. + + * resource/sys/resource.h (enum __rlimit_resource): Removed. + Just include instead. + * resource/Makefile (headers): Add resourcebits.h. + * sysdeps/generic/resourcebits.h: New file. + * sysdeps/unix/bsd/sun/sunos4/resourcebits.h: New file. + + * stdio/test-popen.c (main): Use popen to read the file back, too. + + * sysdeps/unix/sysv/sysv4/i386/sysdep.h: New file. + + * sysdeps/unix/sysv/sysv4/i386/sys-sig.S: Fixed typo: movel->movl. + +Tue May 17 12:46:31 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) + + * mach/mach/mach_traps.h (__mach_reply_port, __mach_thread_self, + __mach_task_self, __mach_host_self): New declarations of __ + versions of syscall traps. + (swtch, __swtch, swtch_pri, __swtch_pri, thread_switch, + __thread_switch, evc_wait, __evc_wait): New prototypes. + * mach/Makefile (headers): Added mach/mach_traps.h so that the + GNU version is installed instead of the Mach version. + +Mon May 16 15:34:12 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * sysdeps/stub/sys/param.h: New file. + + * mach/lock-intern.h (__mutex_lock, __mutex_unlock): Real definitions. + (__mutex_lock_solid, __mutex_unlock_solid, __mutex_init): Declare them. + * mach/mutex-solid.c: New file. + * mach/Makefile (lock): Add mutex-solid. + (lock-headers): Remove mutex.h. + * mach/mutex.h: File removed. + * hurd/hurd/id.h: Include instead of . + * hurd/hurd/signal.h: Likewise. + * hurd/hurdsig.c: Likewise. + * hurd/hurdsock.c: Likewise. + * hurd/dtable.c: Likewise. + * hurd/__setauth.c: Likewise. + * sysdeps/mach/hurd/Makefile (includes): Also append + -I$(hurd-srcdir)/libthreads. + + * sysdeps/posix/system.c [WAITPID_CANNOT_BLOCK_SIGCHLD]: Don't + block SIGCHLD. + * sysdeps/unix/sysv/sco3.2.4/system.c + (WAITPID_CANNOT_BLOCK_SIGCHLD): Define this macro. + + * sysdeps/posix/sigintr.c (siginterrupt) [! SA_RESTART]: Always + fail with ENOSYS. + + * sysdeps/posix/__sigvec.c [! SA_ONSTACK]: Fail with ENOSYS if + SV_ONSTACK is set in VEC->sv_flags. + [SA_RESTART]: Protect SV_INTERRUPT check with this. + + * sysdeps/mach/sysdep.h (FATAL_PREPARE): New macro. + * sysdeps/posix/libc_fatal.c: Include . + [FATAL_PREPARE]: Invoke the macro. + * assert/assert.c: Likewise. + + * sysdeps/generic/memmem.c: Start BEGIN at HAYSTACK, not partway + into it. Loop until BEGIN passes the location in HAYSTACK with + NEEDLE_LEN bytes remaining to the end. + Compare first byte manually before calling memcmp. + + * sysdeps/unix/sysv/sco3.2.4/__sigact.S: Fix typo. + + * posix/sys/types.h [__USE_BSD] (int32_t, int16_t, int8_t, + u_int32_t, u_int16_t, u_int8_t): New typedefs. + + * assert/assert.c (__assert_program_name): New variable. + (__assert_fail): Print that in the msg too. + [HAVE_GNU_LD] (set_progname): New function to set it up at startup. + +Thu May 12 01:10:52 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * hurd/__setauth.c: Do critical section locking. + * hurd/hurdexec.c: Likewise. + * hurd/hurdauth.c (_S_del_auth): Likewise. + * hurd/getuids.c: Likewise. + * hurd/dtable.c: Likewise. + * hurd/alloc-fd.c: Likewise. + * hurd/hurd/port.h: Likewise. + * hurd/hurd/fd.h: Likewise. + * hurd/setuids.c: Likewise. + * hurd/intern-fd.c: Likewise. + * hurd/hurdsock.c (_hurd_socket_server): Likewise. + * sysdeps/mach/hurd/setrlimit.c: Likewise. + * sysdeps/mach/hurd/setgroups.c: Likewise. + * sysdeps/mach/hurd/seteuid.c: Likewise. + * sysdeps/mach/hurd/setegid.c: Likewise. + * sysdeps/mach/hurd/getrlimit.c: Likewise. + * sysdeps/mach/hurd/__setuid.c: Likewise. + * sysdeps/mach/hurd/__setreuid.c: Likewise. + * sysdeps/mach/hurd/__setregid.c: Likewise. + * sysdeps/mach/hurd/__setitmr.c: Likewise. + * sysdeps/mach/hurd/__setgid.c: Likewise. + * sysdeps/mach/hurd/__select.c: Likewise. + * sysdeps/mach/hurd/__sbrk.c: Likewise. + * sysdeps/mach/hurd/__getuid.c: Likewise. + * sysdeps/mach/hurd/__getpgrp.c: Likewise. + * sysdeps/mach/hurd/__getitmr.c: Likewise. + * sysdeps/mach/hurd/__getgrps.c: Likewise. + * sysdeps/mach/hurd/__getgid.c: Likewise. + * sysdeps/mach/hurd/__geteuid.c: Likewise. + * sysdeps/mach/hurd/__getegid.c: Likewise. + * sysdeps/mach/hurd/__getdtsz.c: Likewise. + * sysdeps/mach/hurd/__fork.c: Likewise. + * sysdeps/mach/hurd/__fcntl.c: Likewise. + * sysdeps/mach/hurd/__dup2.c: Likewise. + * sysdeps/mach/hurd/__close.c: Likewise. + * sysdeps/mach/hurd/__brk.c: Likewise. + * sysdeps/mach/hurd/__access.c: Likewise. + + * sysdeps/mach/hurd/reboot.c (reboot): Use the host priv port to + prove authority. + + * sysdeps/mach/hurd/__readlink.c: Don't request O_READ access. + + * sysdeps/mach/hurd/__ioctl.c: Don't expect result data unless + return code is zero. Translate MIG_BAD_ID or EOPNOTSUPP to ENOTTY. + + * mach/devstream.c (output): Use device_write instead of + device_write_inband. + +Wed May 11 18:49:31 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * hurd/hurdinit.c (_hurd_init): Finsih loop of _hurd_port_init on + _hurd_ports elts before doing _hurd_proc_init or + __task_set_special_port. + + * hurd/hurd/signal.h (struct hurd_sigstate): Add new + `critical_section' member. Remove #if 0'd out vfork crap. + (_hurd_critical_section_lock, _hurd_critical_section_unlock): New + functions. + (HURD_CRITICAL_BEGIN, HURD_CRITICAL_END): New macros. + + * io/Makefile (headers): Add poll.h and sys/poll.h. + (routines): Add poll. + * sysdeps/unix/bsd/sun/sunos4/poll.S: New file. + * sysdeps/unix/sysv/poll.S: New file. + * sysdeps/unix/bsd/poll.c: New file. + * sysdeps/stub/poll.c: New file. + * io/poll.h, io/sys/poll.h: New files. + + * misc/bsd-compat.c (setjmp): New function. + + * sysdeps/unix/Makefile (sysdep_headers): Remove sys/param.h. + * misc/Makefile (headers): Add it here instead. + + * io/test-utime.c (main): New file. + * io/Makefile (tests): New variable. + +Wed May 11 13:44:33 1994 Michael I Bushnell (mib@geech.gnu.ai.mit.edu) + + * hurd/hurd/threadvar.h (__hurd_errno_location): Remove + __volatile keyword. `volatile int errno' is not the same + as `int errno'; user programs often mention the latter. + * errno.h: Remove __volatile keyword; same reason. + +Tue May 10 17:21:41 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * time/zdump.c: New code from ADO. + + * time/difftime.c (difftime): Use hairy rounding algorithm from + eggert@twinsun.com when sizeof (time_t) >= sizeof (double). + + * Makerules (native-CFLAGS): Remove -I$(sysincludedir). RMS says + people with bogons in /usr/local/include deserve to lose. + + * stdio/printf_fp.c (__printf_fp): If IS_NEG gets set, negate + FPNUM before testing it for %g format choice. + + * sysdeps/unix/sysv/irix4/fcntlbits.h: New file. + * sysdeps/unix/sysv/irix4/Dist: New file. + * sysdeps/unix/sysv/irix4/readv.c: New file. + * sysdeps/unix/sysv/irix4/writev.c: New file. + * sysdeps/unix/sysv/irix4/__dup2.c: New file. + + * sunrpc/xdr_float.c (xdr_float): Change [mc68000 || sparc] to [! vax]. + + * sysdeps/mips/setjmp.S: Remove spurious $. + + * sysdeps/generic/ftime.c: Include . + + * sysdeps/unix/mips/sysdep.S: Add .set noreorder. + +Tue May 10 16:27:13 1994 Michael I Bushnell (mib@geech.gnu.ai.mit.edu) + + * sysdeps/generic/termbits.h (NCCS): Doc fix. + +Mon May 9 18:07:44 1994 Michael I Bushnell (mib@geech.gnu.ai.mit.edu) + + * sysdeps/mach/hurd/uname.c (uname): System uname information + has moved from init to proc. + + * sysdeps/mach/usleep.c (usleep): Return correct value. Destroy + RECV when we're done with it. + +Thu May 5 17:03:56 1994 Michael I Bushnell (mib@geech.gnu.ai.mit.edu) + + * sysdeps/mach/hurd/__lstat.c: Use O_NOLINK instead of O_NOTRANS. + +Thu May 5 04:20:54 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * mach/spin-lock.h (spin_lock_init): Define. + + * sysdeps/mach/hurd/sigsuspend.c: New local variable NEWMASK, set + it to *SET if SET is not null, before taking SS->lock; don't + dereference SET while holding the lock. Restore SS->blocked to + OLDMASK before unlocking and returning. + + * hurd/hurdsig.c (hurdsig_fork_child): Return zero. + + * sysdeps/mach/hurd/__fork.c (_hurd_fork_parent_hook, + _hurd_fork_prepare_hook)): Define variables (symbol sets). + (__fork): Run _hurd_fork_prepare_hook and _hurd_fork_parent_hook. + + * sysdeps/mach/hurd/sigsuspend.c: Don't test SS->pending; instead + wait until SS->suspended is cleared. + * hurd/hurdsig.c (_hurd_internal_post_signal): Clear SS->suspended + before signalling on SS->arrived. + + * mach/Makefile (headers): Added mach/default_pager_helper.defs. + + * sysdeps/sparc/Dist: Added alloca.S. + +Wed May 4 14:02:29 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) + + * hurd/hurdexec.c (_hurd_exec): Unlock _hurd_dtable_lock when + all through. + + * sysdeps/mach/hurd/__setitmr.c: Changed _hurd_itimer_lock + to be a spin_lock; changed mutex_lock and mutex_unlock + accordingly throughout. + * sysdeps/mach/hurd/__getitmr.c: Corresponding changes from + mutex calls to spin lock calls here too. + + * sysdeps/mach/hurd/__setitmr.c (setitimer_locked): Fixed syntax + of declaration of PREEMPT. + (setitimer_locked): Declare variables ERR and ELAPSED. + (setitimer_locked): Fix some references to REMAINING that + were using it as an itimerval instead of a timeval. + (setitimer_locked): Deleted unused label STILLBORN. + +Wed May 4 00:17:32 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * sysdeps/stub/__getitmr.c: Fix arg name __WHICH to WHICH. + + * sysdeps/unix/bsd/alarm.c: Round tv_usec with arithmetic rather + than a test. + + * hurd/Makefile (user-interfaces): Add hurd/msg_request. + + * sysdeps/stub/__setitmr.c: Fix arg name __WHICH to WHICH. + + * Makeconfig (cross-compiling): Define if $(HOST_CC) and $(CC) differ. + * time/Makefile (install-others): Omit defn ifdef cross-compiling. + +Tue May 3 23:12:48 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * mach/Makefile (lock-headers): Add spin-lock.h. + + * misc/Makefile (routines): Add madvise. + + * malloc/Makefile (non-lib.a): Define. + * misc/Makefile (non-lib.a): Define. + * Makerules (install-lib.a): Filter out $(non-lib.a). + (install-lib-non.a): Append $(non-lib.a). + + * mach/Makefile (mach-headers): Rename sys/version.h to mach/version.h. + + * hurd/Makefile (headers): Added hurd/threadvar.h. + + * Version 1.07.5. + + * hurd/port2fd.c (_hurd_port2fd): Use logic copied from + _hurd_port_locked_set to install PORT in D->port, but leave it locked. + + * sunrpc/Makefile (generated): Don't add $(objpfx). + + * sysdeps/stub/machine-lock.h: New file. + * sysdeps/stub/machine-sp.h: New file. + +Tue May 3 22:31:15 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) + + * sysdeps/mach/usleep.c (usleep): Specify MACH_RCV_MSG so that + mach_msg actually waits. + +Tue May 3 19:24:48 1994 Karl Heuer (kwzh@hal.gnu.ai.mit.edu) + + * malloc/malloc.h (enum mcheck_status): Delete trailing + comma in enum list; some compilers don't like it. + +Tue May 3 15:18:15 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) + + * sysdeps/mach/hurd/__symlink.c (__symlink): Pass port type arg to + __file_set_translator. + +Mon May 2 17:56:47 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * hurd/Makefile (generated): Add $(inlines) .c files. + + * sysdeps/mach/hurd/__mknod.c: Pass port type arg to + __file_set_translator. + +Sun May 1 16:03:13 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * mach/mig_syms.c: Add de-__ing aliases for mig_init, + mig_get_reply_port, and mig_dealloc_reply_port. + + * sysdeps/mach/hurd/errnos.awk: Handle copying errors from + mach/mig_errors.h and device/device_types.h. Omit E*_SUCCESS. + Omit MACH_MSG_MASK and other special bit macros. + + * sysdeps/mach/hurd/i386/sigcontext.h (struct sigcontext): Added + sc_reply_port member. + * hurd/hurdsig.c (fetch_reply_port): New function. + (_hurd_internal_post_signal): When setting up to run handler, set + SCP->sc_reply_port to the receiving thread's value for + _HURD_THREADVAR_MIG_REPLY. + * sysdeps/mach/hurd/i386/__sigret.c: Destroy the MiG reply port + used by the signal handler, and restore from SCP->sc_reply_port. + * hurd/hurd/threadvar.h (__hurd_threadvar_location_from_sp): New + function; guts from __hurd_threadvar_location. + (__hurd_threadvar_location): Call that. + + * hurd/hurdsig.c (check_pending): New function, broken out of: + (_hurd_internal_post_signal): Call that for pending signal check. + If SIGNO is zero, call check_pending on each thread's sigstate. + + * sysdeps/mach/hurd/start.c (start1): Use calloc to get + zero-filled space for __hurd_threadvar_stack_offset when + __hurd_threadvar_stack_mask is zero. + +Thu Apr 28 21:29:47 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Merged gmp-1.99.3+ mpn code from tege for printf_fp. + * stdio/printf_fp.c: Include "longlong.h"; gmp-impl.h no longer does. + + * Makerules (+depfiles): Filter $(extra-objs) to get only .o files. + +Wed Apr 27 00:20:41 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Makerules (depend-$(subdir)): Put output in tmp file and use mv -f. + Always use $(+depfiles), since sources is no longer exported. + +Tue Apr 26 20:05:55 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * sysdeps/unix/bsd/bsd4.4/tcdrain.c: Don't include to + avoid conflicts. + * sysdeps/unix/bsd/bsd4.4/tcsetattr.c: Undefine ECHO, MDMBUF, + TOSTOP, FLUSHO, PENDIN, and NOFLSH after including and + before including . + * sysdeps/unix/bsd/bsd4.4/__tcgetatr.c: Likewise. + +Tue Apr 26 14:42:43 1994 Michael I Bushnell (mib@geech.gnu.ai.mit.edu) + + * sysdeps/mach/sleep.c (sleep): Specify MACH_RCV_MSG or else + mach_msg won't do anything but return immediately. + (sleep): Compute return value correctly. + +Tue Apr 26 04:49:56 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * sysdeps/i386/setjmp.c: Put global register decls first thing. + * sysdeps/i386/__longjmp.c: Likewise. + +Fri Apr 22 18:10:36 1994 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * sysdeps/unix/sysv/irix4/__wait3.S: New file. + * sysdeps/unix/sysv/irix4/time.S: New file. + * sysdeps/unix/sysv/irix4/__waitpid.c: New file. + +Thu Apr 21 16:54:11 1994 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * malloc/malloc.c (initialize, morecore): When allocating the + _heapinfo block itself, account for it in the statistics. + +Tue Apr 19 20:17:06 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * sysdeps/unix/sysv/sco3.2.4/pipestream.c: New file. + + * malloc/malloc.c (morecore): Only zero the new part of NEWINFO, + not the part we will copy _heapinfo into. + + * sysdeps/unix/bsd/signum.h (SIGLOST): Define. + (_NSIG): Increase to 33. + +Mon Apr 18 16:56:11 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * configure.in (config.status): Use $configure_args instead of + $ac_configure_args. + (after AC_PREPARE): Call AC_LANG_C. + + * time/Makefile (routines): Add sys/timeb.h. + (routines): Add ftime. + * time/sys/timeb.h: New file. + * sysdeps/unix/bsd/ftime.c: New file. + * sysdeps/generic/ftime.c: New file. + + * sysdeps/posix/getenv.c (getenv): Return NULL if __environ is null. + + * malloc/malloc.h [_MALLOC_INTERNAL] [HAVE_UNISTD_H]: Include unistd.h. + + * malloc/Makefile (gmalloc-routines): Put valloc first. + +Wed Apr 13 14:03:02 1994 Michael I Bushnell (mib@geech.gnu.ai.mit.edu) + + * sysdeps/mach/hurd/__symlink.c (__symlink): Set the target of the + link to FROM, not TO. + + * sysdeps/mach/hurd/__readlink.c (__readlink): Copy just the + target into the user's buffer, not the entire translator spec. + +Tue Apr 12 00:13:19 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) + + * hurd/fd-write.c (_hurd_fd_write): Set noctty for now rather + than depending on what happens to be on the stack. + + * sysdeps/mach/hurd/readdir.c (readdir): Notice when hitting + end-of-file and return NULL. + +Mon Apr 11 17:36:59 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) + + * sysdeps/mach/hurd/start.c (start1): Bother to set __environ. + + * sysdeps/mach/hurd/__ioctl.c (__ioctl): Comment out use of + HURD_EINTR_RPC until signals work. + +Mon Apr 11 14:16:40 1994 Michael I Bushnell (mib@geech.gnu.ai.mit.edu) + + * sysdeps/mach/hurd/__ioctl.c (__ioctl): Call __mig_get_reply_port + rather than __mig_reply_port (which doesn't exist). + + * sysdeps/mach/hurd/__mknod.c: Added temporary declarations + of major and minor. + + * (This change occurred on April 4, 1994) mach/setup-thread.c + (__mach_setup_thread): The March 31 change had an error; the stack + needs to be allocated with ANYWHERE cleared. + + * (This change occurred on April 8, 1994) hurd/hurdexec.c + (_hurd_exec): The arguments to exec_exec had the length and + type parameters transposed. In addition, fetch the correct + procserver port for the new task. + + * (This change occurred on April 8, 1994) + sysdeps/mach/hurd/__wait.c (__wait4): Deal properly with a null + USAGE argument. + + * (This change occurred on April 8, 1994) + sysdeps/mach/hurd/_exit.c (_exit): Changed commented-out call to + __proc_exit into a correct call to __proc_mark_exit. + +Fri Apr 8 14:58:24 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) + + * string/strsignal.c (strsignal): Store of NUL into unknown_signal + was off by one. + +Tue Apr 5 21:26:25 1994 Brendan Kehoe (brendan@zen.org) + + * sysdeps/unix/sysv/sysv4/__sigact.c (__sigaction): Declare member + `oact' in lower case, to match its use in the rest of the function. + +Tue Apr 5 03:07:04 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Makerules (install-lib.a rule): Run ranlib on the target. + + * Makerules (library member rule): Tighten up pattern rule to + match only libc.a, not other libraries. + +Mon Apr 4 21:49:57 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * set-hooks.h: New file. + * Makefile (distribute): Add it. + * set-init.c: Include it and use its macro DEFINE_HOOK_RUNNER. + + * Makerules (sysd-Makefile): Put `sysd-Makefile-done=t' in output. + (sysd-rules): Don't include it unless sysd-Makefile-done is defined. + +Mon Apr 4 18:33:54 1994 Michael I Bushnell (mib@geech.gnu.ai.mit.edu) + + * mach/setup-thread.c (__mach_setup_thread): Oops; the vm_allocate + call should have ANYWHERE cleared so that the change of the 31st + has any effect at all. + +Thu Mar 31 13:46:13 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) + + * mach/setup-thread.c (__mach_setup_thread): Create a red zone + beneath the stack; also, work around a bug in cthreads by + forcing the stack into high memory. FIXME--this routine + depends on the direction of stack growth; that should be fixed. + +Mon Mar 28 12:55:51 1994 Roland McGrath (roland@mole.gnu.ai.mit.edu) + + * Rules (make-dummy-lib): Use `$(AR)' instead of literal `ar'. + + * configure.in (arg parsing): Don't take --os-release or --os-version. + (switches): Variable removed; don't write it into config.status. + (config.status): Write release and version values directly. + + * sysdeps/unix/common/configure.in: Use changequote around if expr + to avoid [] elision. + +Sat Mar 26 18:36:27 1994 Roland McGrath (roland@mole.gnu.ai.mit.edu) + + * malloc/mcheck.c [! _MALLOC_INTERNAL]: #include + +Fri Mar 25 02:17:55 1994 Roland McGrath (roland@mole.gnu.ai.mit.edu) + + * malloc/mcheck.c (mprobe): New function. + (abortfunc): Take enum mcheck_status arg. + (checkhdr): Return an enum mcheck_status, and pass it to abortfunc. + (mabort): New function. + (mcheck): Use mabort as default abortfunc. + * malloc/malloc.h (enum mcheck_status): New type. + (mprobe): Declare new function. + (mcheck): ABORTFUNC takes an `enum mcheck_status' arg. + + * posix/unistd.h [__USE_GNU] (TEMP_FAILURE_RETRY): New macro. + + * stdio/stdio.h [__USE_GNU && !_LIBC] (cookie_io_functions_t): + Define instead of __io_functions (and make that a typedef for + this); omit __ from member names. + +Thu Mar 24 14:59:23 1994 Roland McGrath (roland@mole.gnu.ai.mit.edu) + + * sysdeps/unix/sysv/sco3.2.4/sigaction.h: New file. + + * sysdeps/unix/sysv/sco3.2.4/__sigact.S: Put address of + __sigreturn in %ecx before doing syscall trap. + + * sysdeps/stub/setegid.c: Fix arg type to __gid_t (was int). + +Wed Mar 23 17:33:09 1994 Roland McGrath (roland@mole.gnu.ai.mit.edu) + + * Makefile (headers): Remove $(stdarg.h). + * Makeconfig (stdarg.h): Variable removed. + * configure.in: Remove check for __gnuc_va_list in stdarg.h. + It is not safe to replace the compiler's stdarg.h with our own. + +Tue Mar 22 12:46:08 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Rules (dist): Rule removed. + * Makefile (dist): Likewise. + * Makerules (dist, distinfo): New rules. + (TAGS): Depend on distfile, pass -f distfile to submake. + + * math/Makefile: Remove if-ed out old bsdmath copying rules. + + * Makerules (sources, headers, sysdep_routines): Don't export these. + * Rules (others, tests): Likewise. + + * io/lockf.c: Include fcntl.h and errno.h. + +Mon Mar 21 20:27:32 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * sysdeps/unix/bsd/sony/newsos4/fchdir.S: New file. + * sysdeps/unix/bsd/sony/newsos4/{__wait4.c,__wait3.c,__wait.c, + sys_wait4.S,Makefile,Dist}: New files. + + * sysdeps/unix/Makefile (syscall.h): De-SYS_ify `kerncall_basenum'. + + * sysdeps/unix/bsd/m68k/sysdep.S [! __motorola__]: Rename label 0 + to `store'; a user reports gas 1.38 bombs on numbered labels. + + * sysdeps/posix/Makefile (mk-stdiolim): Use $(HOST_CC). + + * Rules (distribute, dont_distribute, generated): Don't export them. + (dist): Pass those vars down to sub-make on cmd line. + * Makefile (distribute, generated): Don't export them. + (dist): Pass distribute and generated values to sub-make on cmd line. + + * Makerules (install-lib-nosubdir): Insert $(libprefix) appropriately. + +Fri Mar 18 01:02:52 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * sysdeps/unix/bsd/sony/newsos/m68k/sysdep.h (DO_CALL): Use a6 in + place of fp. A user reports gas 1.38 doesn't grok fp. + +Tue Mar 8 18:35:02 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Makerules (common-clean): Prepend $(objpfx) to $(generated). + * Makefile (parent-clean): Prepend $(common-objpfx) to + $(common-generated). + * Makefile (generated): Don't prepend $(objpfx). + * Rules (generated): Likewise. + * sysdeps/unix/common/Makefile (generated): Likewise. + * sysdeps/unix/sysv/Makefile (generated): Likewise. + * sysdeps/unix/Makefile (common-generated): Don't prepend + $(common-objpfx). + * sysdeps/posix/Makefile (common-generated): Likewise. + * sysdeps/generic/Makefile (common-generated): Likewise. + (generated): Don't prepend $(objpfx). + + * sysdeps/generic/Makefile (common-generated): Set this instead of + generated for bytesex.h and det_endian. + + * sysdeps/stub/fexecve.c: New file. + * posix/Makefile (routines): Add fexecve. + * posix/unistd.h [__USE_GNU]: Declare fexecve. + + * sysdeps/unix/common/configure.in: Protect siglist and ctype + checks with if [ ! "$inhibit_glue" ]. + * sysdeps/generic/configure.in: Likewise for psignal check. + * sysdeps/unix/common/Makefile: Protect body with ifndef inhibit-glue. + +Mon Mar 7 17:46:46 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * sysdeps/unix/bsd/osf1/alpha/__sigblock.S: New file from brendan. + +Fri Mar 4 01:56:26 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Makerules (native-compile, common-objdir-compile): Use + $(HOST_CC) in place of $(CC). + + * malloc/cfree.c: Move #undef cfree inside #ifdef _LIBC. + + * misc/sys/ioctl.h (struct ttysize): If TIOCGSIZE != TIOCGWINSZ, + use two int elts instead of four shorts. + +Thu Mar 3 17:35:54 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * malloc/realloc.c (realloc): When shrinking a block by splitting + and then freeing one, bump the _chunks_used counter. + + * sysdeps/unix/sysv/sysv4/i386/__mknod.S: New file. + +Tue Mar 1 11:42:41 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * sysdeps/unix/sysv/sco3.2.4/__waitpid.S: Get first argument from + stack at 8(%esp), not 4(%esp). + + * sysdeps/unix/sysv/isc2.2/rename.S: Get unix/common, not unix/bsd. + +Thu Feb 24 14:40:43 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * io/lockf.c: New file. + * io/Makefile (routines): Add lockf. + * io/fcntl.h [__USE_MISC] (F_ULOCK, F_LOCK, F_TLOCK, F_TEST): New + macros. + [__USE_MISC] (lockf): Declare it. + * posix/unistd.h: Copy those new macros and declaration. + + * time/backward, time/etcetera, time/zic.c: New code and data from ADO. + * Makeconfig (posixrules): Default to America/New_York. + + * sysdeps/unix/mips/sysdep.S: Store -1 in v0 in the delay slot after + the return, rather than before (leaving the delay slot unfilled and + without a nop!). + + * sysdeps/unix/sysv/irix4: New directory; mips-sgi-irix4 port + courtesy Tom Quinn. + + * sysdeps/unix/sysv/sysv4/direct.h: Moved to unix/common; it is right + for irix4 as well as sysv4. + * sysdeps/unix/bsd/ultrix4/__wait.S: Moved to unix/mips. + (noerror): Store register v1 in location pointed to by first arg (if + not NULL). + * sysdeps/unix/bsd/ultrix4/__sigret.S: Moved to unix/mips. + + * sysdeps/unix/bsd/bsd4.4/{mmap,munmap,mprotect,msync,madvise}.S: + Moved to sysdeps/unix/mman (new directory). + * sysdeps/unix/bsd/bsd4.4/Implies: New file; imply unix/mman. + * sysdeps/unix/bsd/sunos4/Implies: Likewise. + * sysdeps/unix/bsd/ultrix4/Implies: Likewise. + * sysdeps/unix/bsd/osf1/Implies: Likewise. + * sysdeps/unix/bsd/sun/sunos4/munmap.S, + sysdeps/unix/bsd/sun/sunos4/mprotect.S, + sysdeps/unix/bsd/sun/sunos4/madvise.S, + sysdeps/unix/bsd/ultrix4/mmap.S, + sysdeps/unix/bsd/ultrix4/munmap.S, + sysdeps/unix/bsd/ultrix4/mprotect.S, + sysdeps/unix/bsd/osf1/mmap.S, + sysdeps/unix/bsd/osf1/munmap.S, + sysdeps/unix/bsd/osf1/mprotect.S: Files removed. + + * sysdeps/unix/sysv/sysv4/fcntlbits.h: Moved to sysdeps/unix/common. + + * stdio/printf_fp.c: Add many assertions to make sure no mpn size + variable is ever zero. + + * Makerules (native-CFLAGS): Add -I$(sysincludedir). + + * Makerules (depend-$(subdir)) [omit-deps]: Use $(+depfiles) value + instead of shell hackery. + +Wed Feb 23 00:09:08 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * sysdeps/sparc/alloca.S [! NO_UNDERSCORES]: Call it ___builtin_alloca. + +Tue Feb 22 18:47:10 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * sysdeps/unix/bsd/sun/sunos4/sys/mman.h: Use __off_t in mmap + prototype. + + * time/setitmr.c: Swap args OLD and NEW. + * time/sys/time.h (setitimer): Likewise. + * sysdeps/stub/__setitmr.c: Likewise. + +Mon Feb 21 20:47:55 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * sysdeps/sparc/Makefile [gnulib] (routines): Add alloca. + * sysdeps/sparc/alloca.S: New file; support for SunOS libc's + `__builtin_alloca' function (never needed with GCC). + + * sysdeps/unix/sysv/sysv4/__sigact.c (trampoline): Cast handler to + three-arg type. + +Sun Feb 20 00:46:15 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * sysdeps/unix/bsd/sun/sunos4/mmap.c: Add missing semicolon. + + * sysdeps/unix/sparc/start.c [! NO_SHLIB]: Include + before . + + * sysdeps/unix/bsd/ultrix4/mips/{sysdep.h,sysdep.S,__pipe.S, + __fork.S,__brk.S}: Moved to sysdeps/unix/mips (new directory). + + * sysdeps/unix/bsd/ultrix4/mips/__sigret.S: Use SYS_sigreturn + instead of literal 103; #define to 103 if not already defined. + +Sat Feb 19 17:39:13 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * sysdeps/unix/sysv/sysv4/i386/Dist: New file; list sys-sig.S. + +Fri Feb 18 18:07:34 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * sysdeps/generic/configure.in: New file; check for psignal. + + * sysdeps/unix/common/glue-ctype.c: Check for table named _ctype, + before checking for _ctype_. + * sysdeps/unix/common/configure.in: Check for _ctype. + + * sysdeps/unix/Makefile (syscall.h): Look for sys.s before syscall.h. + * sysdeps/unix/configure (unix_syscall_h): Likewise. + + * configure.in (os = irix4*): Set base_os=unix/sysv. + + * sunrpc/rpc/auth.h (u_int32): Always define, no #ifdefs. + * sunrpc/xdr_float.c: Change [mc68000 || sparc] to [! vax]. + +Thu Feb 17 18:42:29 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 1.07.4. + + * sysdeps/unix/bsd/sun/sunos4/Dist: Add sys_mmap.S. + + * Makerules (sysdep_dir): Remove defn. + * Makeconfig (sysdep_dir): Define it here instead. + +Wed Feb 16 16:54:00 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * sysdeps/unix/sysv/sysv4/__sigact.c: New file. + * sysdeps/unix/sysv/sysv4/i386/Makefile: New file. + * sysdeps/unix/sysv/sysv4/i386/sys-sig.S: New file. + + * time/sys/time.h (timerisset, timercmp, timerclear): New macros. + + * misc/Makefile (headers): Add sys/mman.h. + (routines): Add mmap, munmap, mprotect, msync. + * sysdeps/unix/bsd/sun/sunos4/sys_mmap.S: New file. + * sysdeps/unix/bsd/sun/sunos4/mmap.c: New file. + * sysdeps/unix/bsd/sun/sunos4/Makefile [$(subdir) == misc] + (sysdep_routines): Add sys_mmap. + * sysdeps/unix/bsd/bsd4.4/mprotect.S: New file. + * sysdeps/unix/bsd/bsd4.4/munmap.S: New file. + * sysdeps/unix/bsd/bsd4.4/msync.S: New file. + * sysdeps/unix/bsd/bsd4.4/mmap.S: New file. + * sysdeps/unix/bsd/bsd4.4/madvise.S: New file. + * sysdeps/unix/bsd/sun/sunos4/mprotect.S: New file. + * sysdeps/unix/bsd/sun/sunos4/munmap.S: New file. + * sysdeps/unix/bsd/sun/sunos4/msync.S: New file. + * sysdeps/unix/bsd/sun/sunos4/madvise.S: New file. + * sysdeps/unix/bsd/ultrix4/sys/mman.h: New file. + * sysdeps/unix/bsd/ultrix4/mmap.S: New file. + * sysdeps/unix/bsd/ultrix4/munmap.S: New file. + * sysdeps/unix/bsd/ultrix4/mprotect.S: New file. + * sysdeps/stub/mprotect.c: New file. + * sysdeps/stub/munmap.c: New file. + * sysdeps/stub/msync.c: New file. + * sysdeps/stub/mmap.c: New file. + * sysdeps/stub/madvise.c: New file. + * sysdeps/generic/sys/mman.h: New file. + * sysdeps/unix/bsd/sun/sunos4/sys/mman.h: New file. + * sysdeps/unix/bsd/osf1/msync.S: New file. + * sysdeps/unix/bsd/osf1/mmap.S: New file. + * sysdeps/unix/bsd/osf1/munmap.S: New file. + * sysdeps/unix/bsd/osf1/mprotect.S: New file. + * sysdeps/unix/bsd/osf1/sys/mman.h: New file. + +Tue Feb 15 16:47:45 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * posix/unistd.h: Declare truncate, ftruncate. + + * misc/Makefile (headers): Add syslog.h. + * misc/syslog.h: New file; just includes . + + * posix/unistd.h: Change duplicate seteuid decl to setegid. + + * io/Makefile (headers): Add sys/fcntl.h. + * io/sys/fcntl.h: New file; just includes . + +Mon Feb 14 10:36:57 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Makerules (library pattern rule): Depend on + $(objpfx)stamp-$(subdir) and have empty commands. + ($(objpfx)stamp-$(subdir)): Move dep on $(objects) and ar cmds here. + (common-mostlyclean): Remove $(objpfx)stamp-$(subdir). + + * Makerules (+depfiles): Filter out deps for modules in $(omit-deps). + + * sunrpc/Makefile (omit-deps): Define new variable. + + * Makerules ($(libc.a)(__.SYMDEF)): Depend on $(+libobjs), not + lib-noranlib. + * Makefile ($(libc.a)(__.SYMDEF)): Depend on subdir_lib. + + * Makerules (+depfiles): Include deps for $(extra-objs). + + * sunrpc/rpcsvc/klm_prot.x: Move program definition to end. + + * sunrpc/Makefile (lib): Depend on $(objpfx)librpcsvc.a. + + * time/zic.c: Set CP to NAME before dereferencing. + + * sunrpc/Makefile ($(objpfx)x%.c): Target fixed from $(objpfx)x%.c. + ($(objpfx)rpcsvc/%.h): Target renamed from $(includedir)rpcsvc/%.h. + Make each x%.o file depend on the corresponding rpcsvc/%.h file. + (headers): Add rpcsvc/%.h. + (install-others): Remove generated rpcsvc headers. + (generated): Define to include generated rpcsvc headers and sources. + + * sysdeps/m68k/fpu/acos.c: Add __CONSTVALUE to defn. + * sysdeps/m68k/fpu/ldexp.c: Likewise. + * sysdeps/m68k/fpu/pow.c: Likewise. + * sysdeps/m68k/fpu/fmod.c: Likewise. + * sysdeps/m68k/fpu/atan2.c: Likewise. + * sysdeps/m68k/fpu/__drem.c: Likewise. + * sysdeps/m68k/fpu/__isinf.c: Likewise. + * sysdeps/generic/hypot.c: Likewise. + * sysdeps/m68k/fpu/__logb.c: Likewise. + + * sysdeps/unix/bsd/m68k/sysdep.S: Swap operands in cmpl. + +Sun Feb 13 19:49:24 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * sysdeps/m68k/Makefile (compile-command.S): Remove definition + that did kludgey # hackery. + * sysdeps/unix/bsd/hp/m68k/sysdep.h (PSEUDO): Add missing close paren. + (POUND): Define (no arg) to just `#' (a single pound sign). + (PSEUDO, DO_CALL): Use `POUND foo' in place of `POUND(foo)'. + * sysdeps/unix/bsd/sony/newsos/m68k/sysdep.h: Likewise. + * sysdeps/unix/bsd/sun/m68k/sysdep.h: Likewise. + * sysdeps/unix/bsd/sun/m68k/__brk.S: Use #0, not POUND(0). + * sysdeps/unix/bsd/hp/m68k/__brk.S: Use #__end instead of POUND(__end). + +Fri Feb 11 00:29:45 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * configure.in (Makefile): Set objdir instead of ARCH in submake cmd. + + * time/mktime.c: Define __P if undefined. + + * assert/assert.h (__ASSERT_FUNCTION): Check __GNUC_MINOR__<6 if + defined(__cplusplus). + +Thu Feb 10 00:52:31 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * sysdeps/unix/sysv/__sigact.c: Use __sigismember and + __sigemptyset on sa_mask instead of assuming it's an int. + + * sysdeps/unix/sysv/sysv4/sigset.h (__sigismember): Declare arg + SET to be a pointer to const. + + * sysdeps/posix/__sigpause.c: Convert MASK to a sigset_t with a loop. + + * sysdeps/posix/__sigblock.c: When sigset_t==mask, take address of + SET or OSET, cast to int *, and dereference. + * sysdeps/posix/__sigstmsk.c: Likewise. + * sysdeps/posix/__sigvec.c: Likewise. + + Add the -lrpcsvc library of XDR routines for standard SunRPC protocols. + * sunrpc/Makefile (install-lib): Define to include librpcsvc.a. + (rpcsvc-objs): New variable. + (extra-objs): Add $(rpcsvc-objs). + ($(objpfxlibrpcsvc.a): New target. + ($(objpfx)x%.o): New rule to rpcgen XDR routines. + +Wed Feb 9 11:59:33 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * time/zic.c (mkdirs): Reapply fix to avoid writing into passed ptr. + + * sunrpc/Makefile (distribute): Add etc.rpc. + ($(includedir)/bootparam_prot.h): Change target to + $(includedir)/rpcsvc/bootparam_prot.h and dep to + $(includedir)/rpcsvc/bootparam.h. + (install-others): Change reference. + + * sunrpc/rpc_util.h: Comment out bogus decl of sprintf. + + * Makerules ($(libc.a)(__.SYMDEF)): Depend on lib-noranlib instead + of $(+libobjs); this way makes the parent do subdir_lib. + + * sysdeps/unix/sysv/sysv4/sigset.h: Protect types with #ifndef + _SIGSET_H_types. Protect rest with #if !defined (_SIGSET_H_fns) + && defined (_SIGNAL_H). + +Tue Feb 8 19:00:42 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 1.07.3. + + * sysdeps/unix/sysv/sysv4/sigset.h: Fix typos (omitted __s). + +Mon Feb 7 14:31:00 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Makerules ($(libc.a)): Depend on $(libc.a)(__.SYMDEF); no commands. + ($(+libobjs)): Remove static pattern rule. + (ar-it): Target removed. + Replace with pattern rule to catch %(*.o) for all $(objects). + ($(libc.a)(__.SYMDEF)): New target. + (lib-noranlib, $(libdir)/lib$(libprefix)c.a): Don't depend on ar-it. + + * sysdeps/unix/sparc/sysdep.h (PSEUDO): Add nop after jmp; the + next insn is most likely a retl, which causes interesting behavior. + + * stdio/vfprintf.c: Pass WORKEND+1 to _itoa, not WORKEND. + Subtract one from result of _itoa when setting W. + + * time/{africa,asia,australasia,backward,europe,leapseconds, + northamerica,southamerica,zic.c}: New code and data from ADO. + +Sun Feb 6 13:55:27 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * sunrpc: New directory; code from Sun's RPCSRC-4.0. + * sysdeps/unix/inet/Subdirs: Add sunrpc. + * inet/netdb.h: #include at end. + + * Make-dist ($(tardir).tar): Use -v when extracting from dist.tar + and pipe output to doschk. + + * Makeconfig (etcdir): New variable. + (localtime-file): Use that in default value. + + * Makerules (depend-$(subdir)): Include dep files for all .o files + listed in $(extra-objs). + + * posix/sys/types.h (NFDBITS): #define to __NFDBITS. + + * inet/netinet/in.h (INADDR_LOOPBACK): Don't define if already + defined; avoids changing source which defines it before including this. + (struct sockaddr_in): Rename `__pad' member to `sin_zero'; some + code wants to bzero the area just for paranoia. + + Make cleaning targets only remove common (not specific to one + subdir) generated files if run from the parent directory. + * Makefile (parent-clean): Remove $(common-generated) also. + * sysdeps/unix/Makefile (local_lim.h, sys/param.h, errnos.h, + ioctls.h, syscall.h): Append to $(common-generated), not $(generated). + * sysdeps/posix/Makefile (stdio_lim.h): Likewise. + + * signal/signal.h: Declare psignal here. + * stdio/stdio.h: Not here. + + * stdio/stdio.h [__OPTIMIZE__] (vprintf, vfscanf, vscanf, + vsscanf): Define as extern inline functions instead of macros. + + * configure.in (names): Check existence of implied dirs and warn + for absentees. + +Sat Feb 5 13:38:26 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 1.07.2. + + * resource/sys/resource.h (RUSAGE_SELF, RUSAGE_CHILDREN): #define + to self for things that test #ifdef. + + * sysdeps/unix/common/Dist: Remove bsd_getgrp.S. + + * sysdeps/unix/Makefile: Don't include param.h.dep ifdef no_deps. + + * Makerules (vpath %.h): Use $(common-objpfx) in place of $(objpfx). + + * sysdeps/unix/bsd/i386/__vfork.S: Decrement R1 and AND it with R0 + to avoid the test and branch. + + * sysdeps/unix/bsd/getprio.S, sysdeps/unix/bsd/setprio.S, + sysdeps/unix/bsd/__setreuid.S, sysdeps/unix/bsd/__setregid.S: Moved to + sysdeps/unix/common. + + * sysdeps/unix/reboot.S: New file. + + * sysdeps/unix/sysv/sysv4/solaris2/signum.h: New file. + * sysdeps/unix/sysv/sysv4/signum.h: New file. + * sysdeps/unix/sysv/sysv4/sigset.h: New file. + * sysdeps/unix/sysv/sysv4/sigaction.h (struct sigaction): Swap + positions of sa_flags and sa_mask members (sa_flags is first now). + (SA_NOCLDWAIT): Renamed from SA_NOSCLDWAIT. + + * sysdeps/unix/bsd/init-posix.c (_posix_start_time): Initialize it. + + * Makerules (open-check-inhibit-asm): Use : for empty commands in case. + + * time/leapseconds: New version from ADO, adds 1994 leap second. + +Thu Feb 3 02:15:30 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * sysdeps/unix/bsd/ulimit.c: Define ulimit instead of __ulimit. + +Wed Feb 2 16:56:29 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * sysdeps/unix/sysv/sco3.2.4/sigsuspend.S: Moved to unix/sysv/sysv4. + Replaced with #include of that file. + + * sysdeps/unix/sysv/sysv4/solaris2/sigaltstack.S: Moved to + sysdeps/unix/sysv/sysv4/sigaltstk.S. + + * sysdeps/unix/sysv/sysv4/i386/__lstat.S: Syscall lxstat, not xlstat. + * sysdeps/unix/sysv/sysv4/i386/__fstat.S: Syscall fxstat, not xfstat. + +Tue Feb 1 18:22:21 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * stdio/_itoa.c, stdio/_itoa.h: New files. + * stdio/Makefile (routines): Add _itoa. + (distribute): Add _itoa.h. + * stdio/vfprintf.c: Use _itoa instead of doing it by hand. + + * sysdeps/unix/sparc/vfork.S: Add nop after jmp. Bad delay slot, + no pipeline. + * sysdeps/unix/bsd/ultrix4/mips/vfork.S: Likewise. + +Mon Jan 31 19:33:04 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * assert/assert.c (__assert_fail): Take 4th arg FUNCTION; if it is + not null, print it in the message. Also declare __NORETURN. + * assert/assert.h (__assert_fail): Update decl; also add __NORETURN. + (__ASSERT_FUNCTION): #define to be __PRETTY_FUNCTION__ for GCC>=2.4. + (assert): Pass __ASSERT_FUNCTION to __assert_fail. + + * sysdeps/unix/bsd/sun/sparc/vfork.S: Moved to sysdeps/unix/sparc. + Use C_SYMBOL_NAME on __vfork instead of prepending an underscore. + + * sysdeps/unix/sysv/sysv4/solaris2/{start.c,sysdep.S,sysdep.h}: Moved + to sysdeps/unix/sysv/sysv4/solaris2/sparc. + + * sysdeps/unix/{i386,sysv/sysv4/solaris2,sysv/i386/linux,bsd/m68k, + bsd/ultrix4/mips,bsd/vax}/sysdep.S: Don't do EWOULDBLOCK_sys->EAGAIN + mapping #if EWOULDBLOCK_sys == EAGAIN. + + * sysdeps/unix/sparc/sysdep.h [NO_UNDERSCORES]: #define syscall_error + to C_SYMBOL_NAME(__syscall_error). + (PSEUDO): On error, jump to syscall_error instead of setting errno. + * sysdeps/unix/sparc/sysdep.S: New file. + + * sysdeps/unix/sysv/sysv4/i386/__vfork.S: New file, just #include + unix/bsd/i386 version. + + * sysdeps/unix/bsd/i386/__vfork.S: Use `scratch' in place of %edx. + +Thu Jan 27 16:46:03 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * configure.in (asm-CPPFLAGS): Add new check to see if assembling + a .S file loses without -P. If so, set asm-CPPFLAGS=-P in config.make. + + * configure.in (stddef.h): Print msg under --verbose. + + * manual/Makefile (subdir): Define outside of `export' directive, + for old make. + + * time/mktime.c (search): Take new arg PRODUCER, fn to call + instead of `localtime'. + (_mktime_internal): New function; all code from old `mktime', but + take 2nd arg PRODUCER and pass along to `search'. + (mktime): Rewrite to call _mktime_internal with localtime. + * time/Makefile (routines): Add dysize, timegm, timelocal. + * time/time.h (_mktime_internal): Declare it. + [__USE_MISC]: Declare timegm, timelocal, dysize. + * time/dysize.c: New file. + * time/timegm.c: New file. + * time/timelocal.c: New file. + +Wed Jan 26 20:06:23 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + Remove the hackery on getgroups for most systems. It is no longer + necessary because gid_t is now the same size as int. + * sysdeps/unix/common/Makefile (sysdep_routines): Don't add bsd_getgrp. + * sysdeps/unix/common/bsd_getgrp.S: File removed. + * sysdeps/unix/common/__getgrps.S: New file. + * sysdeps/unix/bsd/sequent/i386/__getgrps.S: New file. + + Clean up the rules for cleaning up. + * Makerules (common-mostlyclean): New target; remove object files. + (common-clean): New target; depend on common-mostlyclean, and + remove dep files and generated files. + (clean): Depend on common-clean. + (mostlyclean): Depend on common-mostlyclean. + * Rules (mostlyclean): Target removed. + (clean): Target removed. + (distclean): New target; depend on clean. + (realclean): New target; depend on distclean. + (subdir_distclean): New target; depend on distclean. + (subdir_realclean): New target; depend on realclean. + (subdir_mostlyclean): New target; depend on mostlyclean. + * Makefile (+subdir_targets): Add subdir_distclean, + subdir_realclean; change mostlyclean to subdir_mostlyclean. + (parent-mostlyclean): New target; depend on common-mostlyclean and + remove libc.a and $(install-lib). + (parent-clean): New target; depend on parent-mostlyclean and + common-clean, and remove sysdirs sysd-dirs sysd-Makefile. + (clean): Depend on parent-clean and just do submake for subdirs. + (mostlyclean): Depend on parent-clean and just do submake for subdirs. + (distclean, realclean): Depend on parent-clean and do submake + distclean-1 passing it variable assignment distclean-1=$@. + (distclean-1): Depend on subdir_$(distclean-1) and remove + $(config-generated), config.status, config.make, Makefile (if not + in srcdir). + * manual/Makefile (subdir_clean): Target removed. + (subdir_%): New rule to handle all such targets. + (distclean): Depend on clean, not mostlyclean. + (realclean): Depend on distclean, not clean. + + * sysdeps/unix/configure (unix_generated_dirpfx): New variable. + Use it to put created .S files in sysdeps/unix if configured in + srcdir, else in current directory. + (unix_generated): Prepend $unix_generated_dirpfx. + Have generated config.make fragment prepend $(objpfx). + * sysdeps/unix/Makefile (generated): Don't set it. + (config-generated): Set this instead; don't prepend any directory + prefix to $(unix-generated). + + Fixes for SVR4 wait from jmc@ksu.ksu.edu (James Michael Chacon): + * sysdeps/unix/sysv/sysv4/siginfo.h (__siginfo_t): Add `__code' + and `__pid' fields. + (EXITED, KILLED, CORED, TRAPPED, STOPPED, CONTINUED): New macros. + * sysdeps/unix/sysv/sysv4/__waitpid.c: Switch on INFOP.__code and + construct *STAT_LOC from INFOP.__status accordingly. + + * stdlib/testsort.c (main): Use puts to add newlines to printed lines. + +Tue Jan 25 14:32:01 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Version 1.07.1. + + * manual/Makefile (%.z): Change target pattern to %.gz. + (dist): Comment out dep. Don't really need the separate doc dist. + + * stdio/stdio.h [__OPTIMIZE__] (getchar, putchar, getdelim, + getline, __getline): Use extern inlines instead of macros. + + * sysdeps/unix/sysv/sco3.2.4/__waitpid.S: Fix typo ($eax for %eax). + + * sysdeps/unix/siglist.c [! HAVE_GNU_LD] (_sys_siglist): #define + to sys_siglist. + * sysdeps/posix/__gettod.c [! HAVE_GNU_LD] (__daylight, + __timezone, __tzname): #define to non-__ names. + + * math/math.h [__USE_BSD] (M_E, M_LOG2E, M_LOG10E, M_LN2, M-LN10, + M_PI, M_PI_2, M_PI_4, M_1_PI, M_2_PI, M_2_SQRTPI, M_SQRT2, + M_SQRT1_2): New macros. + +Tue Jan 25 14:01:28 1994 Michael I. Bushnell (mib at ernst.gnu.ai.mit.edu) + + * sysdeps/mach/hurd/start.c (start1): Decide separately whether to + split argv and whether to split envp. + + * sysdeps/mach/hurd/i386/sysdep.h: File deleted. + sysdeps/mach/i386/sysdep.h: Delete SET_SP macro. + sysdeps/mach/hurd/start.c (_start): Don't call GET_SP; set globals + instead of locals from exec_startup message. + + * misc/progname.c: Don't try to set + program_invocation_name or program_invocation_short_name if argv + or argv[0] is invalid. + +Mon Jan 24 16:51:43 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * sysdeps/unix/sysv/sysv4/__waitpid.c: Return INFOP.__pid instead of + the PID we were called with. + + * sysdeps/unix/sysv/__mkdir.c (__mkdir): Restore errno before + returning, not after (lot of good that did). + + * sysdeps/unix/bsd/ultrix4/system.c, sysdeps/unix/bsd/bsd4.4/system.c, + sysdeps/unix/bsd/osf1/system.c, sysdeps/unix/sysv/sco3.2.4/system.c, + sysdeps/unix/bsd/sun/sunos4/system.c, sysdeps/unix/sysv/sysv4/system.c: + New files. Avoid sysdeps/unix/system.c, which defines NO_WAITPID. + + * set-init.c (__libc_init): Use `n' count field instead of + checking for null terminator. The latter loses when there are no + set elts at all, and only one word is allocated for __libc_subinit. + + * sysdeps/generic/waitstatus.h (__WCOREFLAG): New macro. + * posix/sys/wait.h [__USE_BSD] (WCOREFLAG): New; define to __WCOREFLAG. + + * stdio/fileno.c (fileno): Call __stdio_check_funcs. + + * stdio/tst-fileno.c: New file. + +Fri Jan 21 16:56:50 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Rules (dep-dummy-lib, make-dummy-lib): New variables. + ($(objpfx)dummy.o): New file rule. + * posix/Makefile ($(objpfx)libposix.a): Depend on + $(dep-dummy-lib), and use $(make-dummy-lib) for commands. + * math/Makefile ($(objpfx)libm.a): Likewise. + + * sysdeps/unix/sysv/sysv4/i386/__stat.S: New file. + * sysdeps/unix/sysv/sysv4/i386/__lstat.S: Likewise. + * sysdeps/unix/sysv/sysv4/i386/__fstat.S: Likewise. + + * sysdeps/sparc/bytesex.h: New file. + +Thu Jan 20 12:45:35 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * sysdeps/stub/syscall.c (syscall): Declare arg type as int. + +Wed Jan 19 18:18:15 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Makerules ($(before-compile) rule): Protect w/`ifdef before-compile'. + + * manual/Makefile: Change all `mv' uses to `mv -f'. + (subdir_install): Depend on stubs. + + * Makerules ($(objpfx)%.dep: %.s): Depend also on $(objpfx)dummy.dep. + +Tue Jan 18 19:12:57 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * stdlib/testsort.c (main): Swap dimensions of BUFS array. + Mon Jan 17 17:31:28 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) * Version 1.07 released. diff -ruN glibc-1.07/INSTALL glibc-1.08.1/INSTALL --- glibc-1.07/INSTALL Wed Dec 29 18:43:09 1993 +++ glibc-1.08.1/INSTALL Mon Feb 7 18:24:45 1994 @@ -86,9 +86,9 @@ to that other directory to run `configure'. In order to run configure, you will have to specify a directory for it, like this: - mkdir ../hp320 - cd ../hp320 - ../src/configure hp320-bsd4.3 + mkdir sun4 + cd sun4 + ../configure sparc-sun-sunos4.1 `configure' looks for the sources in whatever directory you specified for finding `configure' itself. It does not matter where in the file @@ -110,7 +110,11 @@ file `configparms' in the directory where you are building the library, and define in that file the parameters you want to specify. `configparms' should *not* be an edited copy of `Makeconfig'; specify -only the parameters that you want to override. +only the parameters that you want to override. To see how to set these +parameters, find the section of `Makeconfig' that says "These are the +configuration variables." Then for each parameter that you want to +change, copy the definition from `Makeconfig' to your new `configparms' +file, and change the value as appropriate for your system. 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. @@ -763,4 +767,39 @@ was written by Roland McGrath and Torbjorn Granlund. The multi-precision integer functions used in that function are taken from GNU MP, which was contributed by Torbjorn Granlund. + + * The code to support Sun RPC is taken verbatim from Sun's + RPCSRC-4.0 distribution, and is covered by this copyright: + + Copyright (C) 1984, Sun Microsystems, Inc. + + Sun RPC is a product of Sun Microsystems, Inc. and is + provided for unrestricted use provided that this legend is + included on all tape media and as a part of the software + program in whole or part. Users may copy or modify Sun RPC + without charge, but are not authorized to license or + distribute it to anyone else except as part of a product or + program developed by the user. + + SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND + INCLUDING THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND + FITNESS FOR A PARTICULAR PURPOSE, OR ARISING FROM A COURSE OF + DEALING, USAGE OR TRADE PRACTICE. + + Sun RPC is provided with no support and without any + obligation on the part of Sun Microsystems, Inc. to assist in + its use, correction, modification or enhancement. + + SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT + TO THE INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY + PATENTS BY SUN RPC OR ANY PART THEREOF. + + In no event will Sun Microsystems, Inc. be liable for any + lost revenue or profits or other special, indirect and + consequential damages, even if Sun has been advised of the + possibility of such damages. + + Sun Microsystems, Inc. + 2550 Garcia Avenue + Mountain View, California 94043 diff -ruN glibc-1.07/Make-dist glibc-1.08.1/Make-dist --- glibc-1.07/Make-dist Thu Nov 18 05:11:55 1993 +++ glibc-1.08.1/Make-dist Wed May 18 22:44:29 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 @@ -26,14 +26,6 @@ include $(..)Makeconfig -foo:=$(shell echo first generated='$(generated)' >&2) -ifdef objpfx -generated := $(foreach file,$(filter $(objpfx)%,$(generated)),\ - $(file:$(objpfx)%=%) $(file)) \ - $(filter-out $(objpfx)%,$(generated)) -foo:=$(shell echo generated='$(generated)' >&2) -endif - foo:=$(shell echo 'distribute=$(distribute)'>&2) foo:=$(shell echo 'foobar=$(filter %.c %.S %.s %.h,$(distribute))'>&2) @@ -54,6 +46,11 @@ +distinfo := $(shell MAKEFLAGS= MFLAGS= $(MAKE) -s no_deps=t no_ir=t \ echo-distinfo | grep -v '^make') 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)) +subdir-nodist := $(patsubst +nodist+%,%,$(filter +nodist+%,$(+distinfo))) +subdir-headers := $(filter-out $(headers),$(all-headers)) endif @@ -108,7 +105,7 @@ export tardir := glibc-$(version) endif -$(..)$(tardir): +$(..)glibc-$(version): ln -s . $@ +tsrcs := $(+tsrcs) \ @@ -180,7 +177,7 @@ tar chvf $@ $(addprefix $(tardir)/,$(filter-out $(tardir),$^)) $(tardir).tar: dist.tar subdir_dist - tar xf $< -C /tmp + tar xfv $< -C /tmp | doschk tar covf $@ -C /tmp $(tardir) -rm -fr /tmp/$(tardir) & diff -ruN glibc-1.07/Makeconfig glibc-1.08.1/Makeconfig --- glibc-1.07/Makeconfig Tue Jan 11 21:02:41 1994 +++ glibc-1.08.1/Makeconfig Wed May 4 00:17:51 1994 @@ -95,6 +95,9 @@ include $(objpfx)configparms endif endif + +sysdep_dir := $(..)sysdeps +export sysdep_dir := $(sysdep_dir) #### #### These are the configuration variables. You can define values for @@ -137,12 +140,6 @@ stddef.h = stddef.h endif -# Define if the library should install its own . -# Do this unless you are using version 2.3 or later of GCC. -ifndef stdarg.h -stdarg.h := stdarg.h $(wildcard va-*.h) -endif - # Where to install machine-independent data files. # These are the timezone database, and eventually the locale database. ifndef datadir @@ -164,6 +161,12 @@ infodir = $(prefix)/info endif +# Where to install default configuration files. These include the local +# timezone specification and network data base files. +ifndef etcdir +etcdir = $(prefix)/etc +endif + # What timezone should be the installed default (e.g., US/Eastern). # Run `make -C time echo-zonenames' to see a list of available zone names. # The local timezone can be changed with `zic -l TIMEZONE' at any time. @@ -177,7 +180,7 @@ # other than there, so the zoneinfo directory contains only universal data, # localizing the configuration data elsewhere. ifndef localtime-file -localtime-file = $(prefix)/etc/localtime +localtime-file = $(etcdir)/localtime endif # What timezone's DST rules should be used when a POSIX-style TZ @@ -185,8 +188,9 @@ # this timezone must use rules that are as U.S. federal law defines DST. # Run `make -C time echo-zonenames' to see a list of available zone names. # This setting can be changed with `zic -p TIMEZONE' at any time. +# If you want POSIX.1 compatibility, use `America/New_York'. ifndef posixrules -posixrules = US/Eastern +posixrules = America/New_York endif # Where to install the "posixrules" timezone file; this is file @@ -222,12 +226,12 @@ CC := gcc endif -# These are preprocessor macros we want to predefine. Define HAVE_GNU_LD -# if using GNU ld (which you should do if possible). If you do this, you -# may need the GNU assembler as well. If you don't do this, your library -# won't work as well (and won't be strictly compliant with the ANSI C -# and POSIX.1 standards). -+defines = $(config-defines) $(defines) +# 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) +endif # Default flags to pass the C compiler. ifndef default_cflags @@ -295,7 +299,14 @@ else # not -s +cmdecho := echo endif # -s - + +# These are preprocessor macros we want to predefine. configure will +# define HAVE_GNU_LD for you if you use GNU ld (which you should do if +# possible). If you do this, you may need the GNU assembler as well. If +# you don't do this, your library won't work as well (and won't be strictly +# compliant with the ANSI C and POSIX.1 standards). ++defines = $(config-defines) $(defines) + # These are the flags given to the compiler to tell # it what sort of optimization and/or debugging output to do. ifndef +cflags @@ -331,7 +342,7 @@ 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. @@ -360,6 +371,10 @@ ifneq "$(filter -DHAVE_GNU_AS,$(CPPFLAGS))" "" gnu-as := yes +endif + +ifneq ($(HOST_CC),$(CC)) +cross-compiling = yes endif diff -ruN glibc-1.07/Makefile glibc-1.08.1/Makefile --- glibc-1.07/Makefile Thu Jan 6 20:55:16 1994 +++ glibc-1.08.1/Makefile Mon Apr 4 23:10:55 1994 @@ -69,15 +69,15 @@ # These are the targets that are made by making them in each subdirectory. -+subdir_targets := subdir_lib objects objs others mostlyclean \ - subdir_clean tests subdir_lint.out \ ++subdir_targets := subdir_lib objects objs others subdir_mostlyclean \ + subdir_clean subdir_distclean subdir_realclean \ + tests subdir_lint.out \ subdir_echo-headers subdir_echo-distinfo \ subdir_install $(addprefix install-, \ no-libc.a bin lib \ data headers others) -headers := features.h errno.h sys/errno.h errnos.h limits.h \ - $(stddef.h) $(stdarg.h) +headers := features.h errno.h sys/errno.h errnos.h limits.h $(stddef.h) echo-headers: subdir_echo-headers @@ -91,7 +91,7 @@ $(objpfx)munch-init.c: munch.awk munch-tmpl.c $(+subdir_inits) awk -f $< subdirs='$(+init_subdirs)' $(word 2,$^) > $@-t mv $@-t $@ -generated := $(generated) $(objpfx)munch-init.c +generated := $(generated) munch-init.c endif aux := sysdep $(+init) version start @@ -120,7 +120,7 @@ $(COMPILE.c) $(@:.o=.c) $(OUTPUT_OPTION) rm -f $(@:.o=.c) -lib-noranlib: subdir_lib +lib-noranlib $(libc.a)(__.SYMDEF): subdir_lib $(objpfx)sysd-dirs: $(+sysdir_pfx)config.make @@ -177,22 +177,39 @@ .PHONY: $(+subdir_targets) $(all-subdirs-targets) -# This clobbers everything that can be regenerated. -.PHONY: clean realclean distclean -realclean: distclean -clean: - -rm -f $(objects) $(+depfiles) munch-init.c $(objpfx)depend- - -rm -f $(libc.a) $(addprefix $(objpfx),$(install-lib)) core TAGS +# Targets to clean things up to various degrees. + +.PHONY: clean realclean distclean distclean-1 parent-clean parent-mostlyclean + +# Subroutines of all cleaning targets. +parent-mostlyclean: common-mostlyclean # common-mostlyclean is in Makerules. + -rm -f $(libc.a) $(addprefix $(objpfx),$(install-lib)) +parent-clean: parent-mostlyclean common-clean + -rm -f $(addprefix $(common-objpfx),$(common-generated)) -rm -f $(addprefix $(+sysdir_pfx),sysd-Makefile sysd-dirs sysdirs) + +clean: parent-clean # This is done this way rather than having `subdir_clean' be a # dependency of this target so that libc.a will be removed before the # subdirectories are dealt with and so they won't try to remove object # files from it when it's going to be removed anyway. @$(MAKE) subdir_clean no_deps=t +mostlyclean: parent-mostlyclean + @$(MAKE) subdir_mostlyclean no_deps=t + +# The realclean target is just like distclean for the parent, but we want +# the subdirs to know the difference in case they care. +realclean distclean: parent-clean +# This is done this way rather than having `subdir_distclean' be a +# dependency of this target so that libc.a will be removed before the +# subdirectories are dealt with and so they won't try to remove object +# files from it when it's going to be removed anyway. + @$(MAKE) distclean-1 no_deps=t distclean-1=$@ -distclean: clean - -rm -f $(addprefix $(objpfx),config.status config.make \ - sysd-Makefile sysd-dirs) +# Subroutine of distclean and realclean. +distclean-1: subdir_$(distclean-1) + -rm -f $(config-generated) + -rm -f $(addprefix $(objpfx),config.status config.make) ifdef objdir -rm -f $(objpfx)Makefile endif @@ -210,16 +227,12 @@ distribute := README INSTALL NOTES COPYING.LIB COPYING ChangeLog NEWS \ Makefile Makeconfig Makerules Rules Make-dist MakeTAGS \ - ansidecl.h mkinstalldirs move-if-change \ + ansidecl.h mkinstalldirs move-if-change install.sh \ configure configure.in aclocal.m4 config.sub config.guess\ - munch-tmpl.c munch.awk gnu-stabs.h sysdep.h install.sh - -export distribute := $(strip $(distribute)) -export generated := $(generated) $(objpfx)stubs.h + munch-tmpl.c munch.awk gnu-stabs.h sysdep.h set-hooks.h -.PHONY: dist -dist: Make-dist $(distribute) - $(MAKE) -f $< no_deps=t $(Make-dist-args) +distribute := $(strip $(distribute)) +generated := $(generated) stubs.h README: README.template version.c ; # Make-dist should update README. diff -ruN glibc-1.07/Makerules glibc-1.08.1/Makerules --- glibc-1.07/Makerules Mon Jan 17 19:17:25 1994 +++ glibc-1.08.1/Makerules Tue May 10 20:02:28 1994 @@ -38,10 +38,6 @@ headers := $(headers) $(sysdep_headers) -# This is benign and useless in GNU make before version 3.63. -export sources := $(sources) -export headers := $(headers) - oPATH := $(PATH) PATH := this definition should take precedence over $(oPATH) ifeq ($(PATH),$(oPATH)) @@ -59,9 +55,7 @@ +sysdir_pfx = $(common-objpfx) -sysdep_dir := $(..)sysdeps export sysdirs := $(sysdirs) -export sysdep_dir := $(sysdep_dir) +sysdep_dirs := $(addprefix $(sysdep_dir)/,$(sysdirs)) ifdef objdir @@ -77,7 +71,7 @@ # This is here so things in sysdep Makefiles can easily depend on foo.h as # appropriate and not worry about where foo.h comes from, which may be # system dependent and not known by that Makefile. -vpath %.h $(subst $(empty) ,:,$(strip $(objpfx) \ +vpath %.h $(subst $(empty) ,:,$(strip $(common-objpfx) \ $(addprefix $(sysdep_dir)/,$(sysdirs)) \ $(..))) @@ -98,7 +92,8 @@ if [ -f $(..)$$file ]; then \ echo include "\$$(..)$$file"; \ else true; fi; \ - done) > $@T + done; \ + echo 'sysd-Makefile-done=t') > $@T mv $@T $@ @@ -119,7 +114,9 @@ before-compile := $(filter-out $(wildcard $(before-compile)),$(before-compile)) # Don't let any before-compile file be an intermediate and get removed. +ifdef before-compile $(before-compile): +endif # Generate an ordered list of implicit rules which find the source files in # each sysdep directory. The old method was to use vpath to search all the @@ -144,7 +141,7 @@ $(objpfx)%.o: %.S $(before-compile); $(compile-command.S) $(objpfx)%.dep: %.S $(before-compile); $(+make-deps) $(objpfx)%.o: %.s $(before-compile); $(compile-command.s) -$(objpfx)%.dep: %.s; $(make-dummy-dep) +$(objpfx)%.dep: %.s $(objpfx)dummy.dep; $(make-dummy-dep) $(objpfx)%.o: %.c $(before-compile); $(compile-command.c) $(objpfx)%.dep: %.c $(before-compile); $(+make-deps) @@ -166,12 +163,17 @@ # be suppressed. ifdef inhibit-sysdep-asm define open-check-inhibit-asm -case $$sysdir in $(subst $(empty) ,|,$(inhibit-sysdep-asm))) ;; *) +case $$sysdir in $(subst $(empty) ,|,$(inhibit-sysdep-asm))) : ;; *) endef close-check-inhibit-asm = ;; esac endif +# Don't include sysd-rules until sysd-Makefile is already there and has been +# included. It might define inhibit-sysdep-asm, which would affect the +# contents of sysd-rules. +ifdef sysd-Makefile-done include $(+sysdir_pfx)sysd-rules +endif $(+sysdir_pfx)sysd-rules: $(+sysdir_pfx)config.make $(..)Makerules \ $(wildcard $(foreach dir,$(sysdirs),\ $(sysdep_dir)/$(dir)/Makefile)) @@ -237,24 +239,25 @@ override sources := $(addsuffix .c,$(routines) $(aux) \ $(sysdep_routines)) -export sysdep_routines := $(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) $(addsuffix .dep,$(others) $(tests))) -+depfiles := $(addprefix $(objpfx),$(+depfiles)) ++depfiles := $(strip $(sources:.c=.dep) \ + $(patsubst %.o,%.dep,$(filter %.o,$(extra-objs))) \ + $(addsuffix .dep,$(others) $(tests))) ++depfiles := $(addprefix $(objpfx),\ + $(filter-out $(addsuffix .dep,$(omit-deps)),\ + $(+depfiles))) $(objpfx)depend-$(subdir): Makefile ifdef +depfiles -# This used to simply use $(+depfiles) on the command line, but that tended -# to overflow the arg limit on USG systems. Since `sources' is in the -# environment anyway, we do some shell processing on it instead. - for file in $(patsubst %,%.dep,$(others) $(tests)) \ - `echo $${sources} | sed 's/\.c/.dep/g'`; do \ + for file in $(+depfiles:$(objpfx)%=%); do \ echo "include \$$(objpfx)$$file"; \ - done > $@ + done > $@-tmp + mv -f $@-tmp $@ else cp /dev/null $@ endif @@ -294,31 +297,20 @@ # This makes all the object files in the parent library archive. .PHONY: lib libobjs lib-noranlib -$(libc.a): lib-noranlib - $(RANLIB) $@ +$(libc.a): $(libc.a)(__.SYMDEF) lib: $(libc.a) +libobjs := $(patsubst %,$(libc.a)(%),$(notdir $(objects))) -ifdef +libobjs -$(+libobjs): $(libc.a)(%): $(objpfx)%; -endif libobjs: $(+libobjs) -lib-noranlib: libobjs ar-it - -#$(libc.a): %: $(addprefix %,$(patsubst $(objpfx)%,(%),$(objects))) -# $(AR) $(ARFLAGS) $@ $(patsubst $@(%),%,$?) - -define +libc_lock_open -@. $(..)libc-lock-open -endef -define +libc_lock_close -@rm -f $(..)LOCK-libc.a -endef +lib-noranlib: libobjs -# Temporary until I get a better solution. -.PHONY: ar-it -ar-it: $(objects) +# Define a pattern rule that will match many targets libc.%(foo.o), for +# each foo in $(objects) (% will just happen always to match `a'). This is +# the only way to define a rule that updates many targets at once with one +# sequence of commands. ifdef objects +$(patsubst %,$(libc.a:a=)\%(%),$(notdir $(objects))): $(objpfx)stamp-$(subdir); +$(objpfx)stamp-$(subdir): $(objects) # $(+libc_lock_open) ifdef objdir cd $(objdir); $(AR) cru$(verbose) libc.a $(patsubst $(objpfx)%,%,$^) @@ -326,9 +318,18 @@ $(AR) cru$(verbose) $(..)libc.a $^ endif # $(+libc_lock_close) + touch $@ endif +$(libc.a)(__.SYMDEF): $(+libobjs) + $(RANLIB) $@ +define +libc_lock_open +@. $(..)libc-lock-open +endef +define +libc_lock_close +@rm -f $(..)LOCK-libc.a +endef # This makes all the object files. .PHONY: objects objs @@ -336,10 +337,12 @@ # Installation. -# install-lib are installed from the object directory into $(libdir). -# 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. +# $(install-lib) are installed from the object directory into $(libdir); +# 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. define do-install $(make-target-directory) @@ -355,16 +358,6 @@ $(addprefix -mkdir ,$(filter-out $(wildcard $(@D:%/=%)),$(@D:%/=%))) endef -# Don't attempt binaries for the Hurd version (yet). -ifdef mib_hacks -install := -ifeq ($(subdir),time) -install-others := -endif -endif - - - # Any directory (parent or subdir) that has any object files to build # should install libc.a; this way "make install" in a subdir is guaranteed # to install everything it changes. @@ -376,7 +369,7 @@ # __.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 ar-it subdir_install +$(libdir)/lib$(libprefix)c.a: libobjs subdir_install $(make-target-directory) $(INSTALL_DATA) $(libc.a) $@ $(RANLIB) $@ @@ -388,8 +381,8 @@ $(INSTALL_PROGRAM) $< $@ endif ifdef install-lib -install-lib.a := $(filter lib%.a,$(install-lib)) -install-lib-non.a := $(filter-out lib%.a,$(install-lib)) +install-lib.a := $(filter-out $(non-lib.a),$(filter lib%.a,$(install-lib))) +install-lib-non.a := $(filter-out lib%.a,$(install-lib)) $(non-lib.a) ifdef install-lib-non.a $(addprefix $(libdir)/$(libprefix),$(install-lib-non.a)): \ $(libdir)/$(libprefix)%: $(objpfx)% @@ -399,6 +392,7 @@ $(install-lib.a:lib%.a=$(libdir)/lib$(libprefix)%.a): \ $(libdir)/lib$(libprefix)%.a: $(objpfx)lib%.a $(do-install) + $(RANLIB) $@ endif endif ifdef install-data @@ -413,7 +407,9 @@ .PHONY: install-bin-nosubdir install-lib-nosubdir \ install-data-nosubdir install-headers-nosubdir install-bin-nosubdir: $(addprefix $(bindir)/,$(install)) -install-lib-nosubdir: $(addprefix $(libdir)/,$(install-lib)) +install-lib-nosubdir: $(addprefix $(libdir)/,\ + $(patsubst lib%.a,lib$(libprefix)%.a,$(install-lib.a)) \ + $(addprefix $(libprefix),$(install-lib-non.a))) install-data-nosubdir: $(addprefix $(datadir)/,$(install-data)) install-headers-nosubdir: $(addprefix $(includedir)/,$(headers)) install-others-nosubdir: $(install-others) @@ -431,12 +427,14 @@ install: install-no-libc.a-nosubdir # Command to compile $< in $(objdir) using the native libraries. -native-compile = cwd=`pwd`; cd $(@D); $(CC) $(native-CFLAGS) \ - $(addprefix $$cwd/,$^) -o $(@F) +define native-compile +cwd=`pwd`; cd $(@D); $(HOST_CC) $(native-CFLAGS) \ + $(addprefix $$cwd/,$^) -o $(@F) +endef # Command to compile $< in $(common-objdir) using the native libraries. define common-objdir-compile -cd $(@D); $(CC) $(native-CFLAGS) $(<:$(common-objpfx)%=%) -o $(@F) +cd $(@D); $(HOST_CC) $(native-CFLAGS) $(<:$(common-objpfx)%=%) -o $(@F) endef # We always want to use configuration -D switches. @@ -447,8 +445,8 @@ check: tests .PHONY: TAGS -TAGS: $(..)MakeTAGS - $(MAKE) -f $< $@ +TAGS: distfile $(..)MakeTAGS + $(MAKE) $(addprefix -f ,$^) .PHONY: echo-headers echo-headers: @@ -455,6 +453,24 @@ @echo $(headers) +# Common cleaning targets. + +.PHONY: common-mostlyclean common-clean mostlyclean clean +clean: common-clean +mostlyclean: common-mostlyclean + +# Remove the object files. +common-mostlyclean: + -rm -f $(addprefix $(objpfx),$(tests) $(others) \ + $(addsuffix .o,$(tests) $(others))) + -rm -f $(objects) $(addprefix $(objpfx),$(extra-objs) stamp-$(subdir)) + -rm -f core TAGS + +# Also remove the dependencies and generated source files. +common-clean: common-mostlyclean + -rm -f $(objpfx)depend-$(subdir) $(+depfiles) + -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 # looking for references to source files in sysdeps/stub. Then we grovel @@ -469,6 +485,28 @@ $^ /dev/null` \ /dev/null > $@T mv $@T $@ + +# Make the distribution tar file. + +.PHONY: dist +dist: distinfo $(..)Make-dist + $(MAKE) -f $< -f $(word 2,$^) $(Make-dist-args) + +dist: $(distribute) + +# We used to simply export all these variables, but that frequently made the +# environment get too large. Instead, we write all the information into +# a generated makefile fragment `distinfo', and then include it with -f in +# the sub-make that makes the distribution (above). +distinfo: Makefile $(..)Makerules + $(distinfo-vars) + mv -f $@.new $@ + +define distinfo-vars +$(foreach var,subdir sources sysdep_routines headers distribute \ + dont_distribute generated others tests, +echo >> $@.new '$(var) := $($(var))') +endef ifneq (,$(strip $(gpl2lgpl))) ifneq (,$(wildcard $(..)gpl2lgpl.sed)) diff -ruN glibc-1.07/NEWS glibc-1.08.1/NEWS --- glibc-1.07/NEWS Sat Dec 25 02:41:44 1993 +++ glibc-1.08.1/NEWS Mon May 16 15:41:16 1994 @@ -1,15 +1,65 @@ -GNU C Library NEWS -- history of user-visible changes. 23 December 1993 +GNU C Library NEWS -- history of user-visible changes. 16 May 1994 -Copyright (C) 1992, 1993 Free Software Foundation, Inc. +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.08 + +* The C library now includes support for Sun RPC, from Sun's free + RPCSRC-4.0 distribution. The `portmap', `rpcinfo', and `rpcgen' programs + are included. (There is still no support for YP.) + +* Tom Quinn has contributed a port of the C library to SGI machines running + Irix 4 (mips-sgi-irix4). + +* The new `lockf' function is a simplified interface to the locking + facilities of `fcntl', included for compatibility. + +* New time functions `timegm', `timelocal', and `dysize' for compatibility. + +* New header file and new function `ftime' for compatibility. + +* New header files and and new function `poll' for + compatibility. + +* The error message printed by `assert' for a failed assertion now includes + the name of the program (if using GNU ld) and the name of the calling + function (with versions of GCC that support this). + +* The `psignal' function is now declared in , not . + +* The library now includes the header file and memory + management functions `mmap', `munmap', `mprotect', `msync', and + `madvise', on systems that support those facilities. + +* The interface for `mcheck' has changed slightly: the function called to + abort the program when an allocation inconsistency is detected now takes + an argument that indicates the type of failure. The new function + `mprobe' lets you request a consistency check for a particular block at + any time (checks are normally done only when you call `free' or `realloc' + on a block). + +* It is now possible to easily cross-compile the C library, building on one + system a library to run on another machine and/or operating system. All + you need to do is set the variable `HOST_CC' in `configparms' to the + native compiler for programs to run on the machine you are building on (a + few generator programs are used on Unix systems); set `CC' to the + cross-compiler. + +* The new function `fexecve' (only implemented on the GNU system) executes + a program file given a file descriptor already open on the file. + Version 1.07 * Brendan Kehoe has contributed most of a port to the DEC Alpha running OSF/1 (alpha-dec-osf1). He says it is 75% complete. +* You can set the variable `libprefix' in `configparms' to specify a prefix + to be prepended to installed library files; this makes it easy to install + the GNU C library to be linked as `-lgnuc' or whatever. + * The new `stpncpy' is a cross between `stpcpy' and `strncpy': It copies a limited number of characters from a string, and returns the address of the last character written. @@ -181,7 +231,7 @@ ---------------------------------------------------------------------- Copyright information: -Copyright (C) 1992, 1993 Free Software Foundation, Inc. +Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc. Permission is granted to anyone to make or distribute verbatim copies of this document as received, in any medium, provided that the diff -ruN glibc-1.07/README glibc-1.08.1/README --- glibc-1.07/README Mon Jan 17 22:58:34 1994 +++ glibc-1.08.1/README Sun Jun 5 22:19:13 1994 @@ -1,4 +1,4 @@ -This directory contains the version 1.07 test release of the GNU C Library. +This directory contains the version 1.08.1 test release of the GNU C Library. Many bugs have been fixed since the last release. Some bugs surely remain. @@ -14,9 +14,11 @@ i386-sysv i386-sysv4 m68k-hp-bsd4.3 - m68k-sony-newsos + m68k-sony-newsos3 + m68k-sony-newsos4 m68k-sun-sunos4 mips-dec-ultrix4 + mips-sgi-irix4 sparc-sun-solaris2 sparc-sun-sunos4 @@ -29,7 +31,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.07-crypt.tar.gz'. You can just unpack the crypt +called `glibc-1.08.1-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.07/Rules glibc-1.08.1/Rules --- glibc-1.07/Rules Thu Jan 6 20:41:20 1994 +++ glibc-1.08.1/Rules Wed May 4 00:15:50 1994 @@ -56,6 +56,17 @@ .PHONY: subdir_lib subdir_lib: lib-noranlib + +# Some subdirs need to install a dummy library. +# They can use "$(objpfx)libfnord.a: $(dep-dummy-lib); $(make-dummy-lib)". +dep-dummy-lib = $(objpfx)dummy.o +define make-dummy-lib +$(AR) cr$(verbose) $@ $< +endef +$(objpfx)dummy.o: + @rm -f $(@:.o=.c) + cp /dev/null $(@:.o=.c) + $(CC) -c $(@:.o=.c) -o $@ # This makes all the auxilliary and test programs. @@ -80,31 +91,16 @@ $(objpfx)%.out: $(objpfx)% $(dir $<)$(notdir $<) > $@ endif # tests - -# Because the link above depends on libc.a, which I don't want built -# automatically, this is necessary. -mib -ifdef mib_hacks -others := -endif - -export others := $(others) -export tests := $(tests) -# This removes everything that can be regenerated -# except for the object files and the object-file library members. -.PHONY: mostlyclean -mostlyclean: - -rm -f $(addprefix $(objpfx),$(tests) $(others) \ - $(addsuffix .o,$(tests) $(others))) - -rm -f core TAGS $(objpfx)depend-$(subdir) - -# This removes absolutely everything that can be regenerated. -.PHONY: subdir_clean clean realclean -subdir_clean realclean: clean -clean: mostlyclean - -rm -f $(objects) $(addprefix $(objpfx),$(extra-objs)) \ - $(+depfiles) $(generated) - +.PHONY: distclean realclean subdir_distclean subdir_realclean \ + subdir_clean subdir_mostlyclean +subdir_mostlyclean: mostlyclean +subdir_clean: clean +subdir_distclean: distclean +subdir_realclean: realclean +realclean: distclean +distclean: clean + .PHONY: subdir_echo-headers subdir_echo-headers: echo-headers @@ -119,18 +115,10 @@ .PHONY: subdir_install subdir_install: install-no-libc.a lib-noranlib stubs -.PHONY: subdir_TAGS +.PHONY: subdir_TAGS subdir_dist subdir_TAGS: TAGS - -# Make the distribution tarfile for the parent makefile. -export distribute := $(distribute) -export dont_distribute := $(dont_distribute) -export generated := $(generated) -.PHONY: subdir_dist dist subdir_dist: dist -dist: ../Make-dist - $(MAKE) -f $< $(Make-dist-args) # Convenient target to update all the generated source files. .PHONY: generated -generated: $(generated) +generated: $(addprefix $(objpfx),$(generated)) diff -ruN glibc-1.07/assert/assert.c glibc-1.08.1/assert/assert.c --- glibc-1.07/assert/assert.c Wed Jun 12 13:13:24 1991 +++ glibc-1.08.1/assert/assert.c Sat May 21 21:54:16 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 @@ -20,26 +20,65 @@ #include #include #include +#include +CONST char *__assert_program_name; + /* This function, when passed a string containing an asserted expression, a filename, and a line number, prints a message on the standard error stream of the form: - a.c:10: Assertion `a == b' failed. - It then aborts program execution via a call to abort(). */ + a.c:10: foobar: Assertion `a == b' failed. + It then aborts program execution via a call to `abort'. */ -int -DEFUN(__assert_fail, (assertion, file, line), - CONST char *assertion AND CONST char *file AND unsigned int line) +__NORETURN int +DEFUN(__assert_fail, (assertion, file, line, function), + CONST char *assertion AND + CONST char *file AND unsigned int line AND CONST char *function) { +#ifdef FATAL_PREPARE + FATAL_PREPARE; +#endif + /* Print the message. */ - (void) fprintf(stderr, "%s:%u: Assertion `%s' failed.\n", - file, line, assertion); - (void) fflush(stderr); + (void) fprintf (stderr, "%s%s%s:%u: %s%sAssertion `%s' failed.\n", + __assert_program_name ? __assert_program_name : "", + __assert_program_name ? ": " : "", + file, line, + function ? function : "", function ? ": " : "", + assertion); + (void) fflush (stderr); - abort(); + abort (); /* This function never returns, so making it void would make sense, but returning something makes the assert macro easier to write. */ - return(0); + return 0; +} + +#ifdef HAVE_GNU_LD + +#include +#include + +static void +DEFUN(set_progname, (argc, argv, envp), + int argc AND char **argv AND char **envp) +{ + char *p; + + if (argv && argv[0]) + { + p = strrchr (argv[0], '/'); + if (p == NULL) + __assert_program_name = argv[0]; + else + __assert_program_name = p + 1; + } + + (void) &set_progname; /* Avoid "defined but not used" warning. */ } + +text_set_element (__libc_subinit, set_progname); + +#endif diff -ruN glibc-1.07/assert/assert.h glibc-1.08.1/assert/assert.h --- glibc-1.07/assert/assert.h Fri May 22 03:50:36 1992 +++ glibc-1.08.1/assert/assert.h Fri Feb 11 14:11:43 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 @@ -30,8 +30,6 @@ #define _ASSERT_H 1 #include -__BEGIN_DECLS - /* void assert(int expression); If NDEBUG is defined, do nothing. If not, and EXPRESSION is zero, print an error message and abort. */ @@ -42,16 +40,31 @@ #else /* Not NDEBUG. */ +#include + +__BEGIN_DECLS + /* This prints an "Assertion failed" message and aborts. */ -extern int __assert_fail __P ((__const char *__assertion, - __const char *__file, unsigned int __line)); +extern __NORETURN int __assert_fail __P ((__const char *__assertion, + __const char *__file, + unsigned int __line, + __const char *__function)); -#include +__END_DECLS -#define assert(expr) \ - ((void) ((expr) || \ - __assert_fail (__STRING(expr), __FILE__, __LINE__))) +#define assert(expr) \ + ((void) ((expr) || __assert_fail (__STRING(expr), \ + __FILE__, __LINE__, __ASSERT_FUNCTION))) + +/* 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. */ +#if (!defined (__GNUC__) || __GNUC__ < 2 || \ + __GNUC_MINOR__ < (defined (__cplusplus) ? 6 : 4)) +#define __ASSERT_FUNCTION ((__const char *) 0) +#else +#define __ASSERT_FUNCTION __PRETTY_FUNCTION__ +#endif #endif /* NDEBUG. */ -__END_DECLS diff -ruN glibc-1.07/config.guess glibc-1.08.1/config.guess --- glibc-1.07/config.guess Thu Jan 6 17:02:08 1994 +++ glibc-1.08.1/config.guess Tue May 10 16:54:16 1994 @@ -1,6 +1,6 @@ #!/bin/sh # This script attempts to guess a canonical system name. -# Copyright (C) 1992, 1993 Free Software Foundation, Inc. +# Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc. # # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -33,6 +33,8 @@ UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown +trap 'rm -f dummy.c dummy.o dummy; exit 1' 1 2 15 + # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in @@ -97,7 +99,13 @@ echo i386-ibm-aix exit 0 ;; *:AIX:2:3) - echo rs6000-ibm-aix3.2 + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + echo rs6000-ibm-aix3.2.5 + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + echo rs6000-ibm-aix3.2.4 + else + echo rs6000-ibm-aix3.2 + fi exit 0 ;; *:AIX:*:*) echo rs6000-ibm-aix @@ -108,12 +116,6 @@ DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit 0 ;; - 9000/31?:HP-UX:*:*) - echo m68000-hp-hpux - exit 0 ;; - 9000/[34]??:HP-UX:*:*) - echo m68k-hp-hpux - exit 0 ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit 0 ;; @@ -120,11 +122,19 @@ hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit 0 ;; - 9000/7??:HP-UX:*:* | 9000/8?7:HP-UX:*:* ) - echo hppa1.1-hp-hpux - exit 0 ;; - 9000/8??:HP-UX:*:*) - echo hppa1.0-hp-hpux + 9000/[3478]??:HP-UX:*:* | 9000/8?7: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 + echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit 0 ;; 3050*:HI-UX:*:*) sed 's/^ //' << EOF >dummy.c @@ -159,10 +169,10 @@ 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit 0 ;; - C1*:ConvexOS:*:*) + C1*:ConvexOS:*:* | convex:ConvexOS:C1:*) echo c1-convex-bsd exit 0 ;; - C2*:ConvexOS:*:*) + C2*:ConvexOS:*:* | convex:ConvexOS:C2:*) echo c2-convex-bsd exit 0 ;; CRAY*X-MP:UNICOS:*:*) @@ -177,6 +187,9 @@ hp3[0-9][05]:NetBSD:*:*) echo m68k-hp-netbsd${UNAME_RELEASE} exit 0 ;; + i[34]86:FreeBSD:*:*) + echo ${UNAME_MACHINE}-unknown-freebsd + exit 0 ;; i[34]86:NetBSD:*:*) echo ${UNAME_MACHINE}-unknown-netbsd${UNAME_RELEASE} exit 0 ;; @@ -183,7 +196,7 @@ i[34]86:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux exit 0 ;; - i[34]86:UNIX_SV:4.*:*) + i[34]86:UNIX_SV: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 @@ -205,7 +218,7 @@ exit 0 ;; M680[234]0:*:R3V[567]*:*) test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; - 3[34]??:*:4.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 ;; m680[234]0:LynxOS:2.2*:*) @@ -244,7 +257,21 @@ #endif #if defined(NeXT) - printf("m68k-next-bsd\n"); exit(0); +#if !defined(__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + if (version==2) + { + printf("%s-next-ns2\n", __ARCHITECTURE__); + exit(0); + } + else + { + printf("%s-next-ns3\n", __ARCHITECTURE__); + exit(0); + } #endif #if defined (MULTIMAX) || defined (n16) @@ -276,11 +303,19 @@ printf("i386-sequent-ptx\n"); exit(0); #endif +#if defined(vax) +#if !defined(ultrix) + printf("vax-dec-bsd\n"); exit(0); +#else + printf("vax-dec-ultrix\n"); exit(0); +#endif +#endif + exit (1); } EOF -${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0 +${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy && rm dummy.c dummy && exit 0 rm -f dummy.c dummy # Apollos put the system type in the environment. diff -ruN glibc-1.07/config.sub glibc-1.08.1/config.sub --- glibc-1.07/config.sub Sun Jan 16 14:30:35 1994 +++ glibc-1.08.1/config.sub Fri May 20 01:18:20 1994 @@ -129,6 +129,8 @@ | pn-* | np1-* | xps100-* | clipper-* | orion-* | sparclite-* \ | sh-* | powerpc-*) ;; + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; @@ -210,6 +212,10 @@ basic_machine=m88k-motorola os=-sysv3 ;; + dpx20 | dpx20-*) + basic_machine=rs6000-bull + os=-bosx + ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 @@ -257,11 +263,9 @@ ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp - os=-hpux ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp - os=-hpux ;; hp9k7[0-9][0-9] | hp7[0-9][0-9] | hp9k8[0-9]7 | hp8[0-9]7) basic_machine=hppa1.1-hp @@ -336,7 +340,13 @@ ;; next) basic_machine=m68k-next - os=-bsd + case $os in + -ns2*) + ;; + *) + os=-ns3 + ;; + esac ;; nh3000) basic_machine=m68k-harris @@ -437,8 +447,6 @@ basic_machine=a29k-nyu os=-sym1 ;; - # Recognize the various machine names and aliases which stand - # for a CPU type and a company and sometimes even an OS. vaxv) basic_machine=vax-dec os=-sysv @@ -531,12 +539,13 @@ # 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]* | -hpux* \ - | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ + | -vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]* \ + | -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* | -riscix* | -lynxos*) + | -hiux* | -386bsd* | -netbsd* | -freebsd* | -riscix* \ + | -lynxos* | -bosx* | -ns* | -cxux*) ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` @@ -587,7 +596,7 @@ ;; *) # Get rid of the `-' at the beginning of $os. - os=`echo $1 | sed 's/[^-]*-//'` + os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; diff -ruN glibc-1.07/configure glibc-1.08.1/configure --- glibc-1.07/configure Sun Jan 16 00:42:20 1994 +++ glibc-1.08.1/configure Fri May 20 20:48:05 1994 @@ -32,8 +32,6 @@ nfp= gnu_ld= gnu_as= -version= -release= prefix= exec_prefix= verbose= @@ -82,29 +80,6 @@ -x | --x) ;; # ignored - -os-release=* | -os-releas=* | -os-relea=* | -os-rele=* | -os-rel=* \ - | -os-re=* | -os-r=* | --os-release=* | --os-releas=* | --os-relea=* \ - | --os-rele=* | --os-rel=* | --os-re=* | --os-r=*) - release=`echo $arg | sed 's/-*os-r[a-z]*=//'` - ;; - -os-release | -os-releas | -os-relea | -os-rele | -os-rel \ - | -os-re | -os-r | --os-release | --os-releas | --os-relea \ - | --os-rele | --os-rel | --os-re | --os-r) - next=release - ;; - - -os-version=* | -os-versio=* | -os-versi=* | -os-vers=* | -os-ver=* \ - | -os-ver=* | -os-ve=* | -os-v=* | --os-version=* | --os-versio=* \ - | --os-versi=* | --os-vers=* | --os-ver=* | --os-ver=* | --os-ve=* \ - | --os-v=*) - version=`echo $arg | sed 's/-*os-v[a-z]*=//'` - ;; - -os-version | -os-versio | -os-versi | -os-vers | -os-ver \ - | -os-ver | -os-ve | -os-v |--os-version | --os-versio \ - | --os-versi | --os-vers | --os-ver | --os-ver | --os-ve | --os-v) - next=version - ;; - # For backward compatibility, also recognize exact --exec_prefix. -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* | --exec=* | --exe=* | --ex=* | --e=*) exec_prefix=`echo $arg | sed 's/[-a-z_]*=//'` @@ -147,54 +122,67 @@ fi -trap 'rm -fr conftest* confdefs* core $ac_clean_files; exit 1' 1 3 15 -trap 'rm -f confdefs* $ac_clean_files' 0 +trap 'rm -fr conftest* confdefs* core $ac_clean_files; exit 1' 1 2 15 +trap 'rm -fr confdefs* $ac_clean_files' 0 + +# Save the original args if we used an alternate arg parser. +ac_configure_temp="${configure_args-$*}" +# Strip out --no-create and --norecursion so they don't pile up. +configure_args= +for ac_arg in $ac_configure_temp; do + case "$ac_arg" in + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c) ;; + -norecursion | --norecursion | --norecursio | --norecursi \ + | --norecurs | --norecur | --norecu | --norec | --nore | --nor) ;; + *) configure_args="$configure_args $ac_arg" ;; + esac +done # NLS nuisances. # These must not be set unconditionally because not all systems understand # e.g. LANG=C (notably SCO). -if test "${LC_ALL+set}" = 'set' ; then LC_ALL=C; export LC_ALL; fi -if test "${LANG+set}" = 'set' ; then LANG=C; export LANG; fi +if test "${LC_ALL+set}" = 'set'; then LC_ALL=C; export LC_ALL; fi +if test "${LANG+set}" = 'set'; then LANG=C; export LANG; fi +# confdefs.h avoids OS command line length limits that DEFS can exceed. rm -rf conftest* confdefs.h # AIX cpp loses on an empty file, so make sure it contains at least a newline. echo > confdefs.h -compile='${CC-cc} $CFLAGS conftest.c -o conftest $LIBS >/dev/null 2>&1' # A filename unique to this package, relative to the directory that # configure is in, which we can look for to find out if srcdir is correct. -unique_file=features.h +ac_unique_file=features.h # Find the source files, if location was not specified. if test -z "$srcdir"; then - srcdirdefaulted=yes + ac_srcdir_defaulted=yes # Try the directory containing this script, then `..'. - prog=$0 - confdir=`echo $prog|sed 's%/[^/][^/]*$%%'` - test "X$confdir" = "X$prog" && confdir=. - srcdir=$confdir - if test ! -r $srcdir/$unique_file; then + ac_prog=$0 + ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` + test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. + srcdir=$ac_confdir + if test ! -r $srcdir/$ac_unique_file; then srcdir=.. fi fi -if test ! -r $srcdir/$unique_file; then - if test x$srcdirdefaulted = xyes; then - echo "configure: Can not find sources in \`${confdir}' or \`..'." 1>&2 +if test ! -r $srcdir/$ac_unique_file; then + if test x$ac_srcdir_defaulted = xyes; then + echo "configure: can not find sources in ${ac_confdir} or .." >&2; exit 1 else - echo "configure: Can not find sources in \`${srcdir}'." 1>&2 + echo "configure: can not find sources in ${srcdir}" >&2; exit 1 fi - exit 1 fi -# Preserve a srcdir of `.' to avoid automounter screwups with pwd. -# But we can't avoid them for `..', to make subdirectories work. -case $srcdir in - .|/*|~*) ;; - *) srcdir=`cd $srcdir; pwd` ;; # Make relative path absolute. -esac +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='${CPP}' +ac_compile='${CC-cc} $CFLAGS $LDFLAGS conftest.${ac_ext} -o conftest $LIBS >/dev/null 2>&1' -# Save the original args to write them into config.status later. -configure_args="$*" +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='${CPP}' +ac_compile='${CC-cc} $CFLAGS $LDFLAGS conftest.${ac_ext} -o conftest $LIBS >/dev/null 2>&1' @@ -282,7 +270,7 @@ base_os=unix/bsd/bsd4.4 ;; osf1* | sunos* | ultrix* | newsos* | dynix* | *bsd*) base_os=unix/bsd ;; -linux* | sysv* | isc* | esix* | sco* | minix*) +linux* | sysv* | isc* | esix* | sco* | minix* | irix4*) base_os=unix/sysv ;; solaris[2-9]*) base_os=unix/sysv/sysv4 ;; @@ -373,6 +361,9 @@ if [ -f $sysdep_dir/$name/Implies ]; then # Collect more names from the `Implies' file (removing comments). implied="`sed 's/#.*$//' < $sysdep_dir/$name/Implies`" + for x in $implied; do + test -d $sysdep_dir/$x || echo "Warning: $name implies nonexistent $x">&2 + done else implied= fi @@ -383,9 +374,14 @@ # Find the parent of NAME, using the empty string if it has none. parent="`echo $name | sed -n -e '/\//!q' -e 's=/[^/]*$==p'`" - # Append the names implied by NAME, and NAME's parent (if it has one), - # to the list of names to be processed (the argument list). - sysnames="`echo $* $implied $parent`" + # Add the names implied by NAME, and NAME's parent (if it has one), to + # the list of names to be processed (the argument list). We prepend the + # implied names to the list and append the parent. We want implied + # directories to come before further directories inferred from the + # configuration components; this ensures that for sysv4, unix/common + # (implied by unix/sysv/sysv4) comes before unix/sysv (in ostry (here $*) + # after sysv4). + sysnames="`echo $implied $* $parent`" if [ "$sysnames" != "" ]; then set $sysnames fi @@ -416,72 +412,85 @@ echo Using system-dependent files from directories: 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, # or the AFS install, which mishandles nonexistent args, or # /usr/ucb/install on SVR4, which tries to use the nonexistent group -# `staff'. On most BSDish systems install is in /usr/bin, not /usr/ucb -# anyway. Sigh. -if test "z${INSTALL}" = "z" ; then - echo checking for install - IFS="${IFS= }"; saveifs="$IFS"; IFS="${IFS}:" - for dir in $PATH; do - #test -z "$dir" && dir=. - case "$dir" in - ''|.|/etc|/usr/sbin|/usr/etc|/usr/afsws/bin|/usr/ucb) ;; +# `staff', or /sbin/install on IRIX which has incompatible command-line +# syntax. Sigh. +# +# On most BSDish systems install is in /usr/bin, not /usr/ucb +# anyway. +# This turns out not to be true, so the mere pathname isn't an indication +# of whether the program works. What we really need is a set of tests for +# the install program to see if it actually works in all the required ways. +# +# Avoid using ./install, which might have been erroneously created +# by make from ./install.sh. +if test -z "${INSTALL}"; then + test -n "$silent" || echo "checking for a BSD compatible install" + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" + for ac_dir in $PATH; do + case "$ac_dir" in + ''|.|/etc|/sbin|/usr/sbin|/usr/etc|/usr/afsws/bin|/usr/ucb) ;; *) - if test -f $dir/installbsd; then - INSTALL="$dir/installbsd -c" # OSF1 - INSTALL_PROGRAM='$(INSTALL)' - INSTALL_DATA='$(INSTALL) -m 644' - break - fi - if test -f $dir/install; then - if grep dspmsg $dir/install >/dev/null 2>&1; then - : # AIX - else - INSTALL="$dir/install -c" - INSTALL_PROGRAM='$(INSTALL)' - INSTALL_DATA='$(INSTALL) -m 644' - break + # OSF1 and SCO ODT 3.0 have their own names for install. + for ac_prog in installbsd scoinst install; do + if test -f $ac_dir/$ac_prog; then + if test $ac_prog = install && + grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + # OSF/1 installbsd also uses dspmsg, but is usable. + : + else + INSTALL="$ac_dir/$ac_prog -c" + break 2 + fi fi - fi + done ;; esac done - IFS="$saveifs" + IFS="$ac_save_ifs" fi + if test -z "$INSTALL"; then - if test -f ${srcdir}/install.sh; then - # As a last resort, use the slow shell script. - # We want the top-level source directory, not the subdir's srcdir, - # so expand srcdir now rather than in the Makefile. - INSTALL="${srcdir}/install.sh -c" - else - echo "warning: ${srcdir}/install.sh not found; using cp" - INSTALL=cp - fi + # As a last resort, use the slow shell script. + for ac_dir in ${srcdir} ${srcdir}/.. ${srcdir}/../..; do + if test -f $ac_dir/install.sh; then + INSTALL="$ac_dir/install.sh -c"; break + fi + done +fi +if test -z "$INSTALL"; then + echo "configure: can not find install.sh in ${srcdir} or ${srcdir}/.. or ${srcdir}/../.." >&2; exit 1 fi test -n "$verbose" && echo " setting INSTALL to $INSTALL" -INSTALL_PROGRAM=${INSTALL_PROGRAM-'$(INSTALL)'} + +# Use test -z because SunOS4 sh mishandles ${INSTALL_PROGRAM-'${INSTALL}'}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -n "$verbose" && echo " setting INSTALL_PROGRAM to $INSTALL_PROGRAM" -INSTALL_DATA=${INSTALL_DATA-'$(INSTALL)'} + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' test -n "$verbose" && echo " setting INSTALL_DATA to $INSTALL_DATA" if test -z "$RANLIB"; then # Extract the first word of `ranlib', so it can be a program name with args. - set dummy ranlib; word=$2 - echo checking for $word - IFS="${IFS= }"; saveifs="$IFS"; IFS="${IFS}:" - for dir in $PATH; do - test -z "$dir" && dir=. - if test -f $dir/$word; then + set ac_dummy ranlib; ac_word=$2 + test -n "$silent" || echo "checking for $ac_word" + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then RANLIB="ranlib" break fi done - IFS="$saveifs" + IFS="$ac_save_ifs" fi test -z "$RANLIB" && RANLIB=":" test -n "$RANLIB" && test -n "$verbose" && echo " setting RANLIB to $RANLIB" @@ -489,17 +498,17 @@ if test -z "$CC"; then # Extract the first word of `gcc', so it can be a program name with args. - set dummy gcc; word=$2 - echo checking for $word - IFS="${IFS= }"; saveifs="$IFS"; IFS="${IFS}:" - for dir in $PATH; do - test -z "$dir" && dir=. - if test -f $dir/$word; then + set ac_dummy gcc; ac_word=$2 + test -n "$silent" || echo "checking for $ac_word" + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then CC="gcc" break fi done - IFS="$saveifs" + IFS="$ac_save_ifs" fi test -z "$CC" && CC="cc" test -n "$CC" && test -n "$verbose" && echo " setting CC to $CC" @@ -516,30 +525,34 @@ fi rm -f conftest* -echo checking how to run the C preprocessor +test -n "$silent" || echo "checking how to run the C preprocessor" if test -z "$CPP"; then # This must be in double quotes, not single quotes, because CPP may get # substituted into the Makefile and ``${CC-cc}'' will simply confuse # make. It must be expanded now. CPP="${CC-cc} -E" - cat > conftest.c < conftest.${ac_ext} < Syntax Error EOF -err=`eval "($CPP conftest.c >/dev/null) 2>&1"` -if test -z "$err"; then +# Some shells (Coherent) do redirections in the wrong order, so need +# the parens. +ac_err=`eval "($ac_cpp conftest.${ac_ext} >/dev/null) 2>&1"` +if test -z "$ac_err"; then : else rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" - cat > conftest.c < conftest.${ac_ext} < Syntax Error EOF -err=`eval "($CPP conftest.c >/dev/null) 2>&1"` -if test -z "$err"; then +# Some shells (Coherent) do redirections in the wrong order, so need +# the parens. +ac_err=`eval "($ac_cpp conftest.${ac_ext} >/dev/null) 2>&1"` +if test -z "$ac_err"; then : else rm -rf conftest* @@ -549,7 +562,7 @@ fi rm -f conftest* fi -test ".${verbose}" != "." && echo " setting CPP to $CPP" +test -n "$verbose" && echo " setting CPP to $CPP" echo checking for signed size_t type @@ -565,20 +578,8 @@ } rm -f conftest* -echo '#include "confdefs.h" -#include ' > conftest.c -eval "$CPP conftest.c > conftest.out 2>&1" -if egrep "__gnuc_va_list" conftest.out >/dev/null 2>&1; then - rm -rf conftest* - config_vars="$config_vars -stdarg.h = # The installed defines __gnuc_va_list." - -fi -rm -f conftest* - - -echo checking for libc-friendly stddef.h -cat > conftest.c < conftest.${ac_ext} < #define __need_NULL #include -int main() { exit(0); } +int main() { return 0; } int t() { size_t size; wchar_t wchar; #ifdef offsetof #error stddef.h ignored __need_* #endif -if (&size == NULL || &wchar == NULL) abort (); } +if (&size == NULL || &wchar == NULL) abort ();; return 0; } EOF -if eval $compile; then +if eval $ac_compile; then rm -rf conftest* config_vars="$config_vars stddef.h = # The installed seems to be libc-friendly." +test -n "$verbose" && echo ' installed stddef.h looks friendly' fi rm -f conftest* @@ -602,6 +604,18 @@ +echo 'checking for need to use -P to assemble .S files' +cat > conftest.S </dev/null || { + config_vars="$config_vars +asm-CPPFLAGS = -P # The assembler can't grok cpp's # line directives." + test -n "$verbose" && echo ' using -P flag' +} +rm -f conftest* + # Iterate over all the sysdep directories we will use, running their # configure fragments, and looking for a uname implementation. uname= @@ -725,14 +739,6 @@ ) > config.make echo "Wrote config.make in $PWD." -switches= -if [ "$release" ]; then - switches="$switches --os-release='$release'" -fi -if [ "$version" ]; then - switches="$switches --os-version='$version'" -fi - if [ $srcdir != . ]; then if [ $srcdir = .. ]; then cwd=`pwd` @@ -745,7 +751,7 @@ srcdir = $srcdir all .DEFAULT: - \$(MAKE) -C \$(srcdir) ARCH=\`pwd\` \$@ + \$(MAKE) -C \$(srcdir) objdir=\`pwd\` \$@ END echo "Wrote Makefile in $PWD." @@ -756,7 +762,7 @@ # This file was generated automatically by configure. Do not edit. # The GNU C library was configured in $PWD for # $system_name as follows: -$0 $configure_args $switches \$* +release=$release version=$version $0 $configure_args \$* END chmod a+x config.status echo "Wrote config.status in $PWD." diff -ruN glibc-1.07/configure.in glibc-1.08.1/configure.in --- glibc-1.07/configure.in Sat Jan 15 20:27:04 1994 +++ glibc-1.08.1/configure.in Fri May 20 20:42:31 1994 @@ -36,8 +36,6 @@ nfp= gnu_ld= gnu_as= -version= -release= prefix= exec_prefix= verbose= @@ -86,29 +84,6 @@ -x | --x) ;; # ignored - -os-release=* | -os-releas=* | -os-relea=* | -os-rele=* | -os-rel=* \ - | -os-re=* | -os-r=* | --os-release=* | --os-releas=* | --os-relea=* \ - | --os-rele=* | --os-rel=* | --os-re=* | --os-r=*) - release=`echo $arg | sed 's/-*os-r[a-z]*=//'` - ;; - -os-release | -os-releas | -os-relea | -os-rele | -os-rel \ - | -os-re | -os-r | --os-release | --os-releas | --os-relea \ - | --os-rele | --os-rel | --os-re | --os-r) - next=release - ;; - - -os-version=* | -os-versio=* | -os-versi=* | -os-vers=* | -os-ver=* \ - | -os-ver=* | -os-ve=* | -os-v=* | --os-version=* | --os-versio=* \ - | --os-versi=* | --os-vers=* | --os-ver=* | --os-ver=* | --os-ve=* \ - | --os-v=*) - version=`echo $arg | sed 's/-*os-v[a-z]*=//'` - ;; - -os-version | -os-versio | -os-versi | -os-vers | -os-ver \ - | -os-ver | -os-ve | -os-v |--os-version | --os-versio \ - | --os-versi | --os-vers | --os-ver | --os-ver | --os-ve | --os-v) - next=version - ;; - # For backward compatibility, also recognize exact --exec_prefix. -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* | --exec=* | --exe=* | --ex=* | --e=*) exec_prefix=`echo $arg | sed 's/[-a-z_]*=//'` @@ -153,6 +128,7 @@ dnl This deals with setting srcdir if it needs to be set. changequote([,]) AC_PREPARE(features.h) +AC_LANG_C changequote(,) # Decanonicalize srcdir so we can tell when we are configuring in srcdir. @@ -239,7 +215,7 @@ base_os=unix/bsd/bsd4.4 ;; osf1* | sunos* | ultrix* | newsos* | dynix* | *bsd*) base_os=unix/bsd ;; -linux* | sysv* | isc* | esix* | sco* | minix*) +linux* | sysv* | isc* | esix* | sco* | minix* | irix4*) base_os=unix/sysv ;; solaris[2-9]*) base_os=unix/sysv/sysv4 ;; @@ -330,6 +306,9 @@ if [ -f $sysdep_dir/$name/Implies ]; then # Collect more names from the `Implies' file (removing comments). implied="`sed 's/#.*$//' < $sysdep_dir/$name/Implies`" + for x in $implied; do + test -d $sysdep_dir/$x || echo "Warning: $name implies nonexistent $x">&2 + done else implied= fi @@ -340,9 +319,14 @@ # Find the parent of NAME, using the empty string if it has none. parent="`echo $name | sed -n -e '/\//!q' -e 's=/[^/]*$==p'`" - # Append the names implied by NAME, and NAME's parent (if it has one), - # to the list of names to be processed (the argument list). - sysnames="`echo $* $implied $parent`" + # Add the names implied by NAME, and NAME's parent (if it has one), to + # the list of names to be processed (the argument list). We prepend the + # implied names to the list and append the parent. We want implied + # directories to come before further directories inferred from the + # configuration components; this ensures that for sysv4, unix/common + # (implied by unix/sysv/sysv4) comes before unix/sysv (in ostry (here $*) + # after sysv4). + sysnames="`echo $implied $* $parent`" if [ "$sysnames" != "" ]; then set $sysnames fi @@ -375,6 +359,9 @@ 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 AC_PROG_RANLIB @@ -395,9 +382,6 @@ } rm -f conftest* -AC_HEADER_EGREP(__gnuc_va_list, stdarg.h, [config_vars="$config_vars -stdarg.h = # The installed defines __gnuc_va_list."]) - AC_COMPILE_CHECK([libc-friendly stddef.h], [#define __need_size_t #define __need_wchar_t @@ -409,10 +393,23 @@ #endif if (&size == NULL || &wchar == NULL) abort ();], [config_vars="$config_vars -stddef.h = # The installed seems to be libc-friendly."]) +stddef.h = # The installed seems to be libc-friendly." +test -n "$verbose" && echo ' installed stddef.h looks friendly']) changequote(,)dnl The world is again safe for shell scripts. +echo 'checking for need to use -P to assemble .S files' +cat > conftest.S </dev/null || { + config_vars="$config_vars +asm-CPPFLAGS = -P # The assembler can't grok cpp's # line directives." + test -n "$verbose" && echo ' using -P flag' +} +rm -f conftest* + # Iterate over all the sysdep directories we will use, running their # configure fragments, and looking for a uname implementation. uname= @@ -536,14 +533,6 @@ ) > config.make echo "Wrote config.make in $PWD." -switches= -if [ "$release" ]; then - switches="$switches --os-release='$release'" -fi -if [ "$version" ]; then - switches="$switches --os-version='$version'" -fi - if [ $srcdir != . ]; then if [ $srcdir = .. ]; then cwd=`pwd` @@ -556,7 +545,7 @@ srcdir = $srcdir all .DEFAULT: - \$(MAKE) -C \$(srcdir) ARCH=\`pwd\` \$@ + \$(MAKE) -C \$(srcdir) objdir=\`pwd\` \$@ END echo "Wrote Makefile in $PWD." @@ -567,7 +556,7 @@ # This file was generated automatically by configure. Do not edit. # The GNU C library was configured in $PWD for # $system_name as follows: -$0 $configure_args $switches \$* +release=$release version=$version $0 $configure_args \$* END chmod a+x config.status echo "Wrote config.status in $PWD." diff -ruN glibc-1.07/errno.h glibc-1.08.1/errno.h --- glibc-1.07/errno.h Thu Nov 18 03:25:24 1993 +++ glibc-1.08.1/errno.h Wed May 11 13:45:40 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 @@ -31,7 +31,7 @@ #include /* Declare the `errno' variable. */ -extern __volatile int errno; +extern int errno; #ifdef __USE_GNU /* The full and simple forms of the name with which the program was diff -ruN glibc-1.07/hurd/Makefile glibc-1.08.1/hurd/Makefile --- glibc-1.07/hurd/Makefile Thu Dec 30 23:11:46 1993 +++ glibc-1.08.1/hurd/Makefile Fri May 27 08:39:39 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,28 +24,51 @@ include ../Makeconfig -headers = hurd.h $(interface-headers) +headers = hurd.h $(interface-headers) \ + $(addprefix hurd/,fd.h id.h port.h signal.h userlink.h \ + resource.h threadvar.h) + distribute := intr_rpc.awk hurdintr.awk +# The RPC interfaces go in a separate library. +interface-library := libhurduser.a user-interfaces := $(addprefix hurd/,\ - auth process startup msg \ + auth process startup \ + msg msg_reply msg_request \ exec core interrupt \ fs fsys io term socket ) server-interfaces := hurd/msg -routines = $(interface-routines) \ - hurdid hurdpath hurdpid hurdports \ - hurdexec fexecve \ +routines = hurdid hurdpath hurdpid hurdports hurdrlimit \ + hurdexec \ __setauth setauth \ __pid2task __task2pid pid2task task2pid \ getuids setuids getumask fchroot \ - dtable __getdport getdport openport setdtsz \ -# hurdsig hurdmsg hurdsock hurdauth \ + hurdsock hurdauth \ privports \ - msgportdemux startsig \ + msgportdemux \ fopenport __fopenport \ - vpprintf -aux := hurdsyms hurdinit + vpprintf \ + $(sig) $(dtable) $(inlines) +sig = hurdsig siginfo init-fault msging-p hurd-raise preempt-sig \ + trampoline longjmp-ctx longjmp-ts catch-exc exc2signal +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) + +# XXX this is a temporary hack; see hurdmalloc.h +routines += hurdmalloc +distribute += hurdmalloc.h # Get the proper definition of `hurd-srcdir'. include ../sysdeps/mach/hurd/Makefile @@ -59,6 +82,7 @@ hurd-headers := $(patsubst $(hurd-srcdir)/%,%,\ $(wildcard $(addprefix $(hurd-srcdir)/hurd/,\ *.defs *.h))) + # Don't distribute the Hurd headers; they are in the Hurd distribution. dont_distribute = $(hurd-headers) diff -ruN glibc-1.07/hurd/__fopenport.c glibc-1.08.1/hurd/__fopenport.c --- glibc-1.07/hurd/__fopenport.c +++ glibc-1.08.1/hurd/__fopenport.c Wed Apr 20 16:40:26 1994 @@ -0,0 +1,64 @@ +/* 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 + + +/* Defined in fopen.c. */ +extern int EXFUN(__getmode, (CONST char *mode, __io_mode *mptr)); + + +/* Open a stream on PORT. MODE is as for fopen. */ + +FILE * +__fopenport (mach_port_t port, const char *mode) +{ + register FILE *stream; + __io_mode m; + int pflags; + error_t err; + + if (!__getmode (mode, &m)) + return NULL; + + /* Verify the PORT is valid allows the access MODE specifies. */ + + if (err = __io_get_openmodes (port, &pflags)) + return __hurd_fail (err), NULL; + + /* Check the access mode. */ + if ((m.__read && !(pflags & O_READ)) || (m.__write && !(pflags & O_WRITE))) + { + errno = EBADF; + return NULL; + } + + stream = __newstream (); + 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; + + return stream; +} diff -ruN glibc-1.07/hurd/__getdport.c glibc-1.08.1/hurd/__getdport.c --- glibc-1.07/hurd/__getdport.c Sun Mar 22 00:35:03 1992 +++ glibc-1.08.1/hurd/__getdport.c Mon Jan 31 21:49: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 @@ -18,32 +18,35 @@ #include -const struct - { - size_t n; - file_t (*getdport) (int fd); - } _hurd_getdport_fn; +/* This is initialized in dtable.c when that gets linked in. + If dtable.c is not linked in, it will be zero. */ +file_t (*_hurd_getdport_fn) (int fd); file_t __getdport (int fd) { - if (_hurd_init_dtable != NULL) + if (_hurd_getdport_fn) + /* dtable.c has defined the function to fetch a port from the real file + descriptor table. */ + return (*_hurd_getdport_fn) (fd); + + /* getdport is the only use of file descriptors, + so we don't bother allocating a real table. */ + + if (_hurd_init_dtable == NULL) + /* Never had a descriptor table. */ + return EBADF; + + if (fd < 0 || fd > _hurd_init_dtablesize || + _hurd_init_dtable[fd] == MACH_PORT_NULL) + { + errno = EBADF; + return MACH_PORT_NULL; + } + else { - /* getdport is the only use of file descriptors, - so we don't bother allocating a real table. */ - if (fd < 0 || fd > _hurd_init_dtablesize || - _hurd_init_dtable[fd] == MACH_PORT_NULL) - { - errno = EBADF; - return MACH_PORT_NULL; - } - else - { - __mach_port_mod_refs (__mach_task_self (), _hurd_init_dtable[fd], - MACH_PORT_RIGHT_SEND, 1); - return _hurd_init_dtable[fd]; - } + __mach_port_mod_refs (__mach_task_self (), _hurd_init_dtable[fd], + MACH_PORT_RIGHT_SEND, 1); + return _hurd_init_dtable[fd]; } - else - return (*_hurd_getdport_fn.getdport) (fd); } diff -ruN glibc-1.07/hurd/__pid2task.c glibc-1.08.1/hurd/__pid2task.c --- glibc-1.07/hurd/__pid2task.c Wed Jun 23 17:50:25 1993 +++ glibc-1.08.1/hurd/__pid2task.c Mon Jan 31 21:50:20 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,8 +24,7 @@ error_t err; task_t task; - err = _HURD_PORT_USE (&_hurd_ports[INIT_PORT_PROC], - __proc_pid2task (port, pid, &task)); + err = __USEPORT (PROC, __proc_pid2task (port, pid, &task)); return err ? (__hurd_fail (err), MACH_PORT_NULL) : task; } diff -ruN glibc-1.07/hurd/__setauth.c glibc-1.08.1/hurd/__setauth.c --- glibc-1.07/hurd/__setauth.c Mon Nov 29 16:23:41 1993 +++ glibc-1.08.1/hurd/__setauth.c Mon May 16 21:50:22 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 @@ -16,20 +16,17 @@ not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#ifndef MIB_HACKS - #include +#include +#include #include +#include "set-hooks.h" /* Things in the library which want to be run when the auth port changes. */ -const struct - { - size_t n; - void (*fn[0]) (auth_t new_auth); - } _hurd_reauth_hook; - +DEFINE_HOOK (_hurd_reauth_hook, (auth_t new_auth)); -static struct mutex reauth_lock; +#include +static struct mutex reauth_lock = MUTEX_INITIALIZER; /* Set the auth port to NEW, and reauthenticate @@ -39,7 +36,6 @@ { int d; mach_port_t newport; - void (**fn) (auth_t); /* Give the new send right a user reference. This is a good way to check that it is valid. */ @@ -50,6 +46,8 @@ return -1; } + HURD_CRITICAL_BEGIN; + /* We lock against another thread doing setauth. Anyone who sets _hurd_ports[INIT_PORT_AUTH] some other way is asking to lose. */ __mutex_lock (&reauth_lock); @@ -73,11 +71,11 @@ { mach_port_t new; if (! __io_reauthenticate (_hurd_init_dtable[d], _hurd_pid) && - ! _HURD_PORT_USE (&_hurd_ports[INIT_PORT_AUTH], - __auth_user_authenticate (port, - _hurd_init_dtable[d], - _hurd_pid, - &new))) + ! HURD_PORT_USE (&_hurd_ports[INIT_PORT_AUTH], + __auth_user_authenticate (port, + _hurd_init_dtable[d], + _hurd_pid, + &new))) { __mach_port_deallocate (__mach_task_self (), _hurd_init_dtable[d]); @@ -96,20 +94,11 @@ _hurd_port_set (&_hurd_ports[INIT_PORT_CWDIR], newport); /* Run things which want to do reauthorization stuff. */ - for (fn = _hurd_reauth_hook.fn; *fn != NULL; ++fn) - (**fn) (new); + RUN_HOOK (_hurd_reauth_hook, (new)); __mutex_unlock (&reauth_lock); + HURD_CRITICAL_END; + return 0; } - -static void -init_reauth (void) -{ - __mutex_init (&reauth_lock); -} - -text_set_element (__libc_subinit, init_reauth); - -#endif diff -ruN glibc-1.07/hurd/alloc-fd.c glibc-1.08.1/hurd/alloc-fd.c --- glibc-1.07/hurd/alloc-fd.c +++ glibc-1.08.1/hurd/alloc-fd.c Fri May 27 08:37:15 1994 @@ -0,0 +1,127 @@ +/* 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 "hurdmalloc.h" /* XXX */ + +/* Allocate a new file descriptor and return it, locked. The new + descriptor number will be no less than FIRST_FD. If the table is full, + set errno to EMFILE and return NULL. If FIRST_FD is negative or bigger + than the size of the table, set errno to EINVAL and return NULL. */ + +struct hurd_fd * +_hurd_alloc_fd (int *fd, int first_fd) +{ + int i; + void *crit; + long int rlimit; + + if (first_fd < 0) + { + errno = EINVAL; + return NULL; + } + + crit = _hurd_critical_section_lock (); + + __mutex_lock (&_hurd_dtable_lock); + + search: + for (i = first_fd; i < _hurd_dtablesize; ++i) + { + struct hurd_fd *d = _hurd_dtable[i]; + if (d == NULL) + { + /* Allocate a new descriptor structure for this slot, + initializing its port cells to nil. The test below will catch + and return this descriptor cell after locking it. */ + d = _hurd_new_fd (MACH_PORT_NULL, MACH_PORT_NULL); + if (d == NULL) + { + __mutex_unlock (&_hurd_dtable_lock); + _hurd_critical_section_unlock (crit); + return NULL; + } + _hurd_dtable[i] = d; + } + + __spin_lock (&d->port.lock); + if (d->port.port == MACH_PORT_NULL) + { + __mutex_unlock (&_hurd_dtable_lock); + _hurd_critical_section_unlock (crit); + if (fd != NULL) + *fd = i; + return d; + } + else + __spin_unlock (&d->port.lock); + } + + __mutex_lock (&_hurd_rlimit_lock); + rlimit = _hurd_rlimits[RLIMIT_OFILE].rlim_cur; + __mutex_unlock (&_hurd_rlimit_lock); + + if (first_fd < rlimit) + { + /* The descriptor table is full. Check if we have reached the + resource limit, or only the allocated size. */ + if (_hurd_dtablesize < rlimit) + { + /* Enlarge the table. */ + int save = errno; + struct hurd_fd **new; + /* Try to double the table size (but don't exceed the limit). + If there isn't any at all, give it three slots (because + stdio will take that many anyway). */ + int size = _hurd_dtablesize ? _hurd_dtablesize * 2 : 3; + if (size > rlimit) + size = rlimit; + /* If we fail to allocate that, decrement the desired size + until we succeed in allocating it. */ + do + new = realloc (_hurd_dtable, size * sizeof (*_hurd_dtable)); + while (new == NULL && size-- > _hurd_dtablesize); + if (new != NULL) + { + /* We managed to allocate a new table. Now install it. */ + errno = save; + first_fd = _hurd_dtablesize; + /* Initialize the new slots. */ + for (i = first_fd; i < size; ++i) + new[i] = NULL; + _hurd_dtablesize = size; + _hurd_dtable = new; + /* Go back to the loop to initialize the first new slot. */ + goto search; + } + } + else + errno = EMFILE; + } + else + errno = EINVAL; /* Bogus FIRST_FD value. */ + + __mutex_unlock (&_hurd_dtable_lock); + _hurd_critical_section_unlock (crit); + + return NULL; +} diff -ruN glibc-1.07/hurd/catch-exc.c glibc-1.08.1/hurd/catch-exc.c --- glibc-1.07/hurd/catch-exc.c +++ glibc-1.08.1/hurd/catch-exc.c Thu Apr 28 23:08:06 1994 @@ -0,0 +1,43 @@ +/* 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 + +/* Called by the microkernel when a thread gets an exception. */ + +kern_return_t +_S_catch_exception_raise (mach_port_t port, + thread_t thread, + task_t task, + int exception, + int code, + int subcode) +{ + int signo, sigcode; + + /* Call the machine-dependent function to translate the Mach exception + codes into a signal number and subcode. */ + _hurd_exception2signal (exception, code, subcode, &signo, &sigcode); + + /* Post the signal. */ + _hurd_internal_post_signal (_hurd_thread_sigstate (thread), signo, sigcode, + MACH_PORT_NULL, MACH_MSG_TYPE_PORT_SEND); + + return KERN_SUCCESS; +} diff -ruN glibc-1.07/hurd/dtable.c glibc-1.08.1/hurd/dtable.c --- glibc-1.07/hurd/dtable.c Thu Dec 2 17:17:47 1993 +++ glibc-1.08.1/hurd/dtable.c Mon May 30 20:31:56 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 @@ -19,22 +19,23 @@ #include #include #include +#include #include #include #include #include #include +#include /* For `struct mutex'. */ +#include "set-hooks.h" +#include "hurdmalloc.h" /* XXX */ -#ifdef noteven struct mutex _hurd_dtable_lock; -#endif -struct _hurd_dtable _hurd_dtable; -int _hurd_dtable_rlimit; -int *_hurd_dtable_user_dealloc; +struct hurd_fd **_hurd_dtable; +int _hurd_dtablesize; -const struct _hurd_dtable_resizes _hurd_dtable_resizes; +DEFINE_HOOK (_hurd_fd_subinit, (void)); /* Initialize the file descriptor table at startup. */ @@ -43,30 +44,40 @@ { register size_t i; -#ifdef noteven __mutex_init (&_hurd_dtable_lock); -#endif - _hurd_dtable_user_dealloc = NULL; - /* The initial size of the descriptor table is that of the passed-in - table, rounded up to a multiple of FOPEN_MAX descriptors. */ - _hurd_dtable.size - = (_hurd_init_dtablesize + FOPEN_MAX - 1) / FOPEN_MAX * FOPEN_MAX; - _hurd_dtable_rlimit = _hurd_dtable.size; + table. It will be expanded as necessary up to _hurd_dtable_rlimit. */ + _hurd_dtablesize = _hurd_init_dtablesize; - _hurd_dtable.d = malloc (_hurd_dtable.size * sizeof (*_hurd_dtable.d)); - if (_hurd_dtable.d == NULL) + /* Allocate the vector of pointers. */ + _hurd_dtable = malloc (_hurd_dtablesize * sizeof (*_hurd_dtable)); + if (_hurd_dtablesize != 0 && _hurd_dtable == NULL) __libc_fatal ("hurd: Can't allocate file descriptor table\n"); + /* Initialize the descriptor table. */ for (i = 0; i < _hurd_init_dtablesize; ++i) { - struct _hurd_fd *const d = &_hurd_dtable.d[i]; - - _hurd_port_init (&d->port, MACH_PORT_NULL); - _hurd_port_init (&d->ctty, MACH_PORT_NULL); + if (_hurd_init_dtable[i] == MACH_PORT_NULL) + /* An unused descriptor is marked by a null pointer. */ + _hurd_dtable[i] = NULL; + else + { + /* Allocate a new file descriptor structure. */ + struct hurd_fd *new = malloc (sizeof (struct hurd_fd)); + if (new == NULL) + __libc_fatal ("hurd: Can't allocate initial file descriptors\n"); + + /* Initialize the port cells. */ + _hurd_port_init (&new->port, MACH_PORT_NULL); + _hurd_port_init (&new->ctty, MACH_PORT_NULL); + + /* Install the port in the descriptor. + This sets up all the ctty magic. */ + _hurd_port2fd (new, _hurd_init_dtable[i], 0); - _hurd_port2fd (d, _hurd_init_dtable[i], 0); + _hurd_dtable[i] = new; + } } /* Clear out the initial descriptor table. @@ -78,120 +89,18 @@ _hurd_init_dtablesize = 0; /* Initialize the remaining empty slots in the table. */ - for (; i < _hurd_dtable.size; ++i) - { - _hurd_port_init (&_hurd_dtable.d[i].port, MACH_PORT_NULL); - _hurd_port_init (&_hurd_dtable.d[i].ctty, MACH_PORT_NULL); - _hurd_dtable.d[i].flags = 0; - } -} - -text_set_element (__libc_subinit, init_dtable); - -/* Allocate a new file descriptor and install PORT in it. FLAGS are as for - `open'; only O_IGNORE_CTTY is meaningful, but all are saved. - - If the descriptor table is full, set errno, and return -1. - If DEALLOC is nonzero, deallocate PORT first. */ -int -_hurd_intern_fd (io_t port, int flags, int dealloc) -{ - int fd; - struct _hurd_fd *d = _hurd_alloc_fd (&fd, 0); - - if (d == NULL) - { - if (dealloc) - __mach_port_deallocate (__mach_task_self (), port); - return -1; - } - - _hurd_port2fd (d, port, flags); - __spin_unlock (&d->port.lock); - return fd; -} - -/* Allocate a new file descriptor and return it, locked. - If the table is full, set errno and return NULL. */ -struct _hurd_fd * -_hurd_alloc_fd (int *fd, const int first_fd) -{ - int i; - - __mutex_lock (&hurd_dtable_lock); - - for (i = first_fd; i < _hurd_dtable.size; ++i) - { - struct _hurd_fd *d = &_hurd_dtable.d[i]; - __spin_lock (&d->port.lock); - if (d->port.port == MACH_PORT_NULL) - { - __mutex_unlock (&hurd_dtable_lock); - if (fd != NULL) - *fd = i; - return d; - } - else - __spin_unlock (&d->port.lock); - } + for (; i < _hurd_dtablesize; ++i) + _hurd_dtable[i] = NULL; - __mutex_unlock (&hurd_dtable_lock); - - errno = EMFILE; - return NULL; + /* Run things that want to run after the file descriptor table + is initialized. */ + RUN_HOOK (_hurd_fd_subinit, ()); } - -void -_hurd_port2fd (struct _hurd_fd *d, io_t port, int flags) -{ - io_t ctty; - mach_port_t cttyid; - int is_ctty = !(flags & O_IGNORE_CTTY) && ! __term_getctty (port, &cttyid); - - if (is_ctty) - { - /* This port is capable of being a controlling tty. - Is it ours? */ - is_ctty &= __USEPORT (CTTYID, port == cttyid); - __mach_port_deallocate (__mach_task_self (), cttyid); -#if 0 - struct _hurd_port *const id = &_hurd_ports[INIT_PORT_CTTYID]; - __spin_lock (&id->lock); - if (id->port == MACH_PORT_NULL) - /* We have no controlling tty, so make this one it. */ - _hurd_port_locked_set (id, cttyid); - else - { - if (cttyid != id->port) - /* We have a controlling tty and this is not it. */ - is_ctty = 0; - /* Either we don't want CTTYID, or ID->port already is it. - So we don't need to change ID->port, and we - can release the reference to CTTYID. */ - __spin_unlock (&id->lock); - __mach_port_deallocate (__mach_task_self (), cttyid); - } -#endif - } - - 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. */ - d->port.port = ctty; - ctty = port; - } - else - /* 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? */ - /* No ctty magic happening here. */ - ctty = MACH_PORT_NULL; +text_set_element (_hurd_subinit, init_dtable); - _hurd_port_set (&d->ctty, ctty); -} +/* XXX when the linker supports it, the following functions should all be + elsewhere and just have text_set_elements here. */ /* Called by `getdport' to do its work. */ @@ -199,11 +108,10 @@ get_dtable_port (int fd) { file_t dport; - int err = _HURD_DPORT_USE (fd, - __mach_port_mod_refs (__mach_task_self (), - (dport = port), - MACH_PORT_RIGHT_SEND, - 1)); + int err = HURD_DPORT_USE (fd, __mach_port_mod_refs (__mach_task_self (), + (dport = ctty ?: port), + MACH_PORT_RIGHT_SEND, + 1)); if (err) { errno = err; @@ -213,13 +121,15 @@ return dport; } -text_set_element (_hurd_getdport_fn, get_dtable_port); +file_t (*_hurd_getdport_fn) (int fd) = get_dtable_port; -/* Called on fork to install the dtable in NEWTASK. - The dtable lock is held. */ +#include +/* We are in the child fork; the dtable lock is still held. + The parent has inserted send rights for all the normal io ports, + but we must recover ctty-special ports for ourselves. */ static error_t -fork_dtable (task_t newtask) +fork_child_dtable (void) { error_t err; int i; @@ -226,30 +136,72 @@ err = 0; - for (i = 0; !err && i < _hurd_dtable.size; ++i) + for (i = 0; !err && i < _hurd_dtablesize; ++i) { - int dealloc, dealloc_ctty; - io_t port = _hurd_port_get (&_hurd_dtable.d[i].port, &dealloc); - io_t ctty = _hurd_port_get (&_hurd_dtable.d[i].ctty, &dealloc_ctty); - - if (port != MACH_PORT_NULL) - err = __mach_port_insert_right (newtask, port, port, - MACH_MSG_TYPE_COPY_SEND); - if (!err && ctty != MACH_PORT_NULL) - err = __mach_port_insert_right (newtask, ctty, ctty, - MACH_MSG_TYPE_COPY_SEND); + struct hurd_fd *d = _hurd_dtable[i]; + + /* No other thread is using the send rights in the child task. */ + d->port.users = d->ctty.users = NULL; - _hurd_port_free (&_hurd_dtable.d[i].port, &dealloc, port); - _hurd_port_free (&_hurd_dtable.d[i].ctty, &dealloc_ctty, ctty); + 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); /* XXX for each fd with a cntlmap, reauth and re-map_cntl. */ } - __mutex_unlock (&_hurd_dtable_lock); return err; } -text_set_element (_hurd_fork_hook, fork_dtable); -text_set_element (_hurd_fork_locks, _hurd_dtable_lock); +data_set_element (_hurd_fork_locks, _hurd_dtable_lock); +text_set_element (_hurd_fork_child_hook, fork_child_dtable); + +/* Called when our process group has changed. */ + +static void +ctty_new_pgrp (void) +{ + int i; + + HURD_CRITICAL_BEGIN; + __mutex_lock (&_hurd_dtable_lock); + + for (i = 0; i < _hurd_dtablesize; ++i) + { + struct hurd_fd *const d = _hurd_dtable[i]; + struct hurd_userlink ulink, ctty_ulink; + io_t port, ctty; + + if (d == NULL) + /* Nothing to do for an unused descriptor cell. */ + continue; + + port = _hurd_port_get (&d->port, &ulink); + ctty = _hurd_port_get (&d->ctty, &ctty_ulink); + + if (ctty) + { + /* 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); + } + + _hurd_port_free (&d->port, &ulink, port); + _hurd_port_free (&d->ctty, &ctty_ulink, ctty); + } + + __mutex_unlock (&_hurd_dtable_lock); + HURD_CRITICAL_END; +} + +text_set_element (_hurd_pgrp_changed_hook, ctty_new_pgrp); /* Called to reauthenticate the dtable when the auth port changes. */ @@ -258,13 +210,18 @@ { int i; + HURD_CRITICAL_BEGIN; __mutex_lock (&_hurd_dtable_lock); - for (i = 0; i < _hurd_dtable.size; ++i) + for (i = 0; i < _hurd_dtablesize; ++i) { - struct _hurd_fd *const d = &_hurd_dtable.d[i]; + struct hurd_fd *const d = _hurd_dtable[i]; mach_port_t new, newctty; + if (d == NULL) + /* Nothing to do for an unused descriptor cell. */ + continue; + /* Take the descriptor cell's lock. */ __spin_lock (&d->port.lock); @@ -294,109 +251,7 @@ } __mutex_unlock (&_hurd_dtable_lock); + HURD_CRITICAL_END; } text_set_element (_hurd_reauth_hook, reauth_dtable); - -static void -rectty_dtable (mach_port_t cttyid) -{ - int i; - - __mutex_lock (&_hurd_dtable_lock); - - for (i = 0; i < _hurd_dtable.size; ++i) - { - struct _hurd_fd *const d = &_hurd_dtable.d[i]; - mach_port_t newctty; - - if (cttyid == MACH_PORT_NULL) - /* We now have no controlling tty at all. */ - newctty = MACH_PORT_NULL; - else - _HURD_PORT_USE (&d->port, - ({ mach_port_t id; - /* Get the io object's cttyid port. */ - if (! __term_getctty (port, &id)) - { - if (id == cttyid && /* Is it ours? */ - /* Get the ctty io port. */ - __term_become_ctty (port, _hurd_pid, - _hurd_pgrp, - _hurd_msgport, - &newctty)) - /* XXX it is our ctty but the call failed? */ - newctty = MACH_PORT_NULL; - __mach_port_deallocate - (__mach_task_self (), (mach_port_t) id); - } - else - newctty = MACH_PORT_NULL; - 0; - })); - - /* Install the new ctty port. */ - _hurd_port_set (&d->ctty, newctty); - } - - __mutex_unlock (&_hurd_dtable_lock); -} - -#if 0 - -#include - - -/* Make FD be the controlling terminal. - This function is called for `ioctl (fd, TCIOSCTTY)'. */ - -static int -tiocsctty (int fd, - int request, /* Always TCIOSCTTY. */ - void *arg) /* Not used. */ -{ - mach_port_t cttyid; - error_t err; - - /* Get FD's cttyid port, unless it is already ours. */ - err = _HURD_DPORT_USE (fd, - ctty ? EADDRINUSE : __term_getctty (port, &cttyid)); - if (err == EADDRINUSE) - /* FD is already the ctty. Nothing to do. */ - return 0; - else if (err) - return err; - - /* Make it our own. */ - _hurd_port_set (&_hurd_ports[INIT_PORT_CTTYID], cttyid); /* Consumes ref. */ - - /* Reset all the ctty ports in all the descriptors. */ - _HURD_PORT_USE (&_hurd_ports[INIT_PORT_CTTYID], (rectty_dtable (port), 0)); - - return 0; -} -_HURD_HANDLE_IOCTL (tiocsctty, TIOCSCTTY); - -#ifdef TIOCNOCTTY -/* Dissociate from the controlling terminal. */ - -static int -tiocnoctty (int fd, - int request, /* Always TIOCNOCTTY. */ - void *arg) /* Not used. */ -{ - /* XXX should verify that FD is ctty and return EINVAL? */ - - /* Clear our cttyid port cell. */ - _hurd_port_set (&_hurd_ports[INIT_PORT_CTTYID], MACH_PORT_NULL); - - /* Reset all the ctty ports in all the descriptors. */ - _HURD_PORT_USE (&_hurd_ports[INIT_PORT_CTTYID], - (rectty_dtable (MACH_PORT_NULL), 0)); - - return 0; -} -_HURD_HANDLE_IOCTL (tiocnotty, TIOCNOTTY); -#endif - -#endif diff -ruN glibc-1.07/hurd/fchroot.c glibc-1.08.1/hurd/fchroot.c --- glibc-1.07/hurd/fchroot.c Tue Dec 14 16:08:10 1993 +++ glibc-1.08.1/hurd/fchroot.c Thu Feb 3 21:06:29 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 @@ -17,10 +17,9 @@ Cambridge, MA 02139, USA. */ #include -#include -#include #include #include +#include /* Change the current directory root to FD. */ int @@ -29,13 +28,21 @@ error_t err; file_t crdir; - /* XXX check that's it's a directory */ + 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; + })); - if (err = _HURD_DPORT_USE (fd, - __mach_port_mod_refs (__mach_task_self (), - (crdir = port), - MACH_PORT_RIGHT_SEND, 1))) - return err; + if (err) + return __hurd_fail (err); _hurd_port_set (&_hurd_ports[INIT_PORT_CRDIR], crdir); diff -ruN glibc-1.07/hurd/fd-close.c glibc-1.08.1/hurd/fd-close.c --- glibc-1.07/hurd/fd-close.c +++ glibc-1.08.1/hurd/fd-close.c Sat May 21 17:15:14 1994 @@ -0,0 +1,33 @@ +/* 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 + +/* FD is locked. Close and unlock it, so it can be reallocated. */ + +error_t +_hurd_fd_close (struct hurd_fd *fd) +{ + /* Clear the descriptor's port cells. + This deallocates the ports if noone else is still using them. */ + + _hurd_port_set (&fd->ctty, MACH_PORT_NULL); + _hurd_port_locked_set (&fd->port, MACH_PORT_NULL); + + return 0; +} diff -ruN glibc-1.07/hurd/fd-read.c glibc-1.08.1/hurd/fd-read.c --- glibc-1.07/hurd/fd-read.c +++ glibc-1.08.1/hurd/fd-read.c Wed May 11 23:42:53 1994 @@ -0,0 +1,78 @@ +/* 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 +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_fd_read (struct hurd_fd *fd, void *buf, size_t *nbytes) +{ + error_t err; + char *data; + mach_msg_type_size_t nread; + + data = buf; + err = HURD_FD_PORT_USE + (fd, + ({ + call: + err = __io_read (port, &data, &nread, -1, *nbytes); + if (ctty != MACH_PORT_NULL && err == EBACKGROUND) + { +#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) + { + /* 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; + else + err = EINTR; /* XXX Is this right? */ + } +#endif + } + err; + })); + + if (err) + return err; + + if (data != buf) + { + memcpy (buf, data, nread); + __vm_deallocate (__mach_task_self (), (vm_address_t) data, nread); + } + + *nbytes = nread; + return 0; +} diff -ruN glibc-1.07/hurd/fd-write.c glibc-1.08.1/hurd/fd-write.c --- glibc-1.07/hurd/fd-write.c +++ glibc-1.08.1/hurd/fd-write.c Wed May 11 20:21:12 1994 @@ -0,0 +1,71 @@ +/* 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 +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_fd_write (struct hurd_fd *fd, const void *buf, size_t *nbytes) +{ + error_t err; + mach_msg_type_number_t wrote; + int noctty; + +#ifdef notyet + struct _hurd_sigstate *ss = _hurd_self_sigstate (); + + /* Don't use the ctty io port if we are orphaned, or are blocking or + ignoring SIGTTOU. */ + noctty = (_hurd_orphaned || + __sigismember (SIGTTOU, &ss->blocked) || + 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) + { +#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; + })); + + if (! err) + *nbytes = wrote; + + return err; +} diff -ruN glibc-1.07/hurd/fexecve.c glibc-1.08.1/hurd/fexecve.c --- glibc-1.07/hurd/fexecve.c Thu Dec 30 23:10:15 1993 +++ glibc-1.08.1/hurd/fexecve.c @@ -1,29 +0,0 @@ -/* 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. */ - -#include -#include - -/* Execute the file FD refers to, overlaying the running program image. */ - -int -fexecve (int fd, char *const argv[], char *const envp[]) -{ - error_t err = _HURD_DPORT_USE (fd, _hurd_exec (port, argv, envp)); - return __hurd_fail (err); -} diff -ruN glibc-1.07/hurd/fopenport.c glibc-1.08.1/hurd/fopenport.c --- glibc-1.07/hurd/fopenport.c +++ glibc-1.08.1/hurd/fopenport.c Sun Mar 22 00:40:43 1992 @@ -0,0 +1,21 @@ +/* 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 + +symbol_alias (__fopenport, fopenport); diff -ruN glibc-1.07/hurd/getuids.c glibc-1.08.1/hurd/getuids.c --- glibc-1.07/hurd/getuids.c Thu Oct 28 23:08:31 1993 +++ glibc-1.08.1/hurd/getuids.c Wed May 11 23:45:45 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 @@ -17,6 +17,7 @@ Cambridge, MA 02139, USA. */ #include +#include int @@ -24,12 +25,15 @@ { error_t err; int nuids; + void *crit; + crit = _hurd_critical_section_lock (); __mutex_lock (&_hurd_id.lock); if (err = _hurd_check_ids ()) { __mutex_unlock (&_hurd_id.lock); + _hurd_critical_section_unlock (crit); return __hurd_fail (err); } @@ -41,6 +45,7 @@ uid_t uids[nuids]; memcpy (uids, _hurd_id.gen.uids, sizeof (uids)); __mutex_unlock (&_hurd_id.lock); + _hurd_critical_section_unlock (crit); /* Now that the lock is released, we can safely copy the uid set into the user's array, which might fault. */ @@ -49,7 +54,10 @@ memcpy (uidset, uids, nuids * sizeof (uid_t)); } else - __mutex_unlock (&_hurd_idlock); + { + __mutex_unlock (&_hurd_id.lock); + _hurd_critical_section_unlock (crit); + } return nuids; } diff -ruN glibc-1.07/hurd/hurd/fd.h glibc-1.08.1/hurd/hurd/fd.h --- glibc-1.07/hurd/hurd/fd.h +++ glibc-1.08.1/hurd/hurd/fd.h Sat May 21 20:23:30 1994 @@ -0,0 +1,247 @@ +/* File descriptors. +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 +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_FD_H + +#define _HURD_FD_H 1 +#include + +#include +#include + + +/* Structure representing a file descriptor. */ + +struct hurd_fd + { + struct hurd_port port; /* io server port. */ + int flags; /* fcntl flags; locked by port.lock. */ + + /* Normal port to the ctty. When `port' is our ctty, this is a port to + the same io object but which never returns EBACKGROUND; when not, + this is nil. */ + struct hurd_port ctty; + }; + + +/* Current file descriptor table. */ + +extern int _hurd_dtablesize; +extern struct hurd_fd **_hurd_dtable; +extern struct mutex _hurd_dtable_lock; /* Locks those two variables. */ + +#include +#include + +#ifndef _EXTERN_INLINE +#define _EXTERN_INLINE extern __inline +#endif + +/* Returns the descriptor cell for FD, locked. + If FD is invalid or unused, return NULL. */ + +_EXTERN_INLINE struct hurd_fd * +_hurd_fd_get (int fd) +{ + struct hurd_fd *descriptor; + HURD_CRITICAL_BEGIN; + __mutex_lock (&_hurd_dtable_lock); + if (fd < 0 || fd >= _hurd_dtablesize) + descriptor = NULL; + else + { + struct hurd_fd *cell = _hurd_dtable[fd]; + if (cell == NULL) + /* No descriptor allocated at this index. */ + descriptor = NULL; + else + { + __spin_lock (&cell->port.lock); + if (cell->port.port == MACH_PORT_NULL) + { + /* The descriptor at this index has no port in it. + This happens if it existed before but was closed. */ + __spin_unlock (&cell->port.lock); + descriptor = NULL; + } + else + descriptor = cell; + } + } + __mutex_unlock (&_hurd_dtable_lock); + HURD_CRITICAL_END; + return descriptor; +} + + +/* Evaluate EXPR with the variable `descriptor' bound to a pointer to the + locked file descriptor structure for FD. EXPR should unlock the + descriptor when it is finished. */ + +#define HURD_FD_USE(fd, expr) \ + ({ struct hurd_fd *const descriptor = _hurd_fd_get (fd); \ + descriptor == NULL ? EBADF : (expr); }) + +/* Evaluate EXPR with the variable `port' bound to the port to FD, + and `ctty' bound to the ctty port. */ + +#define HURD_DPORT_USE(fd, expr) \ + HURD_FD_USE ((fd), HURD_FD_PORT_USE (descriptor, (expr))) + +/* Likewise, but FD is a pointer to the locked file descriptor structure. + It is unlocked on return. */ + +#define HURD_FD_PORT_USE(fd, expr) \ + ({ error_t __result; \ + struct hurd_fd *const __d = (fd); \ + struct hurd_userlink __ulink, __ctty_ulink; \ + io_t port = _hurd_port_locked_get (&__d->port, &__ulink); \ + io_t ctty = _hurd_port_locked_get (&__d->ctty, &__ctty_ulink); \ + __result = (expr); \ + _hurd_port_free (&__d->port, &__ulink, port); \ + if (ctty != MACH_PORT_NULL) \ + _hurd_port_free (&__d->ctty, &__ctty_ulink, ctty); \ + __result; }) + +#include + +/* Check if ERR should generate a signal. + Returns the signal to take, or zero if none. */ + +_EXTERN_INLINE error_t +_hurd_fd_error_signal (error_t err) +{ + switch (err) + { + case MACH_SEND_INVALID_DEST: /* The server has disappeared! */ + return SIGLOST; + case EPIPE: + return SIGPIPE; + default: + /* Having a default case avoids -Wenum-switch warnings. */ + return 0; + } +} + +/* Handle an error from an RPC on a file descriptor's port. You should + always use this function to handle errors from RPCs made on file + descriptor ports. Some errors are translated into signals. */ + +_EXTERN_INLINE error_t +_hurd_fd_error (int fd, error_t err) +{ + int signo = _hurd_fd_error_signal (err); + if (signo) + _hurd_raise_signal (NULL, signo, fd); + return err; +} + +/* Handle error code ERR from an RPC on file descriptor FD's port. + Set `errno' to the appropriate error code, and always return -1. */ + +_EXTERN_INLINE int +__hurd_dfail (int fd, error_t err) +{ + errno = _hurd_fd_error (fd, err); + return -1; +} + +/* Set up *FD to have PORT its server port, doing appropriate ctty magic. + Does no locking or unlocking. */ + +extern void _hurd_port2fd (struct hurd_fd *fd, io_t port, int flags); + +/* Allocate a new file descriptor and install PORT in it (doing any + appropriate ctty magic); consumes a user reference on PORT. FLAGS are + as for `open'; only O_IGNORE_CTTY is meaningful, but all are saved. + + If the descriptor table is full, set errno, and return -1. + If DEALLOC is nonzero, deallocate PORT first. */ + +extern int _hurd_intern_fd (io_t port, int flags, int dealloc); + +/* Allocate a new file descriptor in the table and return it, locked. The + new descriptor number will be no less than FIRST_FD. If the table is + full, set errno to EMFILE and return NULL. If FIRST_FD is negative or + bigger than the size of the table, set errno to EINVAL and return NULL. */ + +extern struct hurd_fd *_hurd_alloc_fd (int *fd_ptr, int first_fd); + +/* Allocate a new file descriptor structure and initialize its port cells + with PORT and CTTY. (This does not affect the descriptor table.) */ + +extern struct hurd_fd *_hurd_new_fd (io_t port, io_t ctty); + +/* Close a file descriptor, making it available for future reallocation. + FD should be locked, and is unlocked on return. */ + +extern error_t _hurd_fd_close (struct hurd_fd *fd); + +/* Read and write data from a file descriptor; just like `read' and `write'. + If successful, stores the amount actually read or written in *NBYTES. */ + +extern error_t _hurd_fd_read (struct hurd_fd *fd, void *buf, size_t *nbytes); +extern error_t _hurd_fd_write (struct hurd_fd *fd, + const void *buf, size_t *nbytes); + + +/* User-registered handlers for specific `ioctl' requests. */ + +#define __need___va_list +#include + +/* Structure that records an ioctl handler. */ + +struct ioctl_handler + { + int first_request, last_request; /* Range of handled request values. */ + + /* Handler function, called like ioctl to do its entire job. */ + int (*handler) (int fd, int request, void *arg); + + struct ioctl_handler *next; /* Next handler. */ + }; + + +/* Register HANDLER to handle ioctls with REQUEST values between + FIRST_REQUEST and LAST_REQUEST inclusive. Returns zero if successful. + Return nonzero and sets `errno' for an error. */ + +extern int hurd_register_ioctl_handler (int first_request, int last_request, + int (*handler) (int fd, int request, + __gnuc_va_list)); + + +/* Define a library-internal handler for ioctl commands between FIRST and + LAST inclusive. The last element gratuitously references HANDLER to + avoid `defined but not used' warnings. */ + +#define _HURD_HANDLE_IOCTLS(handler, first, last) \ + static const struct ioctl_handler handler##_ioctl_handler = \ + { (first), (last), (int (*) (int, int, __gnuc_va_list)) (handler), \ + (&(handler), &(handler##_ioctl_handler), NULL) }; \ + text_set_element (_hurd_ioctl_handler_lists, ##handler##_ioctl_handler) + +/* Define a library-internal handler for a single ioctl command. */ + +#define _HURD_HANDLE_IOCTL(handler, ioctl) \ + _HURD_HANDLE_IOCTLS (handler, (ioctl), (ioctl)) + + +#endif /* hurd/fd.h */ diff -ruN glibc-1.07/hurd/hurd/id.h glibc-1.08.1/hurd/hurd/id.h --- glibc-1.07/hurd/hurd/id.h +++ glibc-1.08.1/hurd/hurd/id.h Mon May 16 21:50:25 1994 @@ -0,0 +1,55 @@ +/* User and group IDs. +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 +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_ID_H + +#define _HURD_ID_H 1 +#include + +#include /* For `struct mutex'. */ + +/* Structure describing authorization data for the process. */ + +struct hurd_id_data + { + struct mutex lock; + + int valid; /* If following data are up to date. */ + + struct + { + uid_t *uids; + gid_t *gids; + unsigned int nuids, ngids; + } gen, aux; + + auth_t rid_auth; /* Cache used by access. */ + }; + +/* Current data. */ + +extern struct hurd_id_data _hurd_id; + + +/* Update _hurd_id (caller should be holding the lock). */ + +extern error_t _hurd_check_ids (void); + + +#endif /* hurd/id.h */ diff -ruN glibc-1.07/hurd/hurd/port.h glibc-1.08.1/hurd/hurd/port.h --- glibc-1.07/hurd/hurd/port.h +++ glibc-1.08.1/hurd/hurd/port.h Thu May 12 08:33:43 1994 @@ -0,0 +1,152 @@ +/* Lightweight user references for ports. +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 +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_PORT_H + +#define _HURD_PORT_H 1 +#include + +#include +#include +#include +#include + + +/* Structure describing a cell containing a port. With the lock held, a + user extracts PORT, and attaches his own link (in local storage) to the + USERS chain. PORT can then safely be used. When PORT is no longer + needed, with the lock held, the user removes his link from the chain. + If his link is the last, and PORT has changed since he fetched it, the + user deallocates the port he used. See . */ + +struct hurd_port + { + spin_lock_t lock; /* Locks rest. */ + struct hurd_userlink *users; /* Chain of users; see below. */ + mach_port_t port; /* Port. */ + }; + + +/* Evaluate EXPR with the variable `port' bound to the port in PORTCELL. */ + +#define HURD_PORT_USE(portcell, expr) \ + ({ struct hurd_port *const __p = (portcell); \ + struct hurd_userlink __link; \ + const mach_port_t port = _hurd_port_get (__p, &__link); \ + __typeof(expr) __result = (expr); \ + _hurd_port_free (__p, &__link, port); \ + __result; }) + + +#ifndef _EXTERN_INLINE +#define _EXTERN_INLINE extern __inline +#endif + + +/* Initialize *PORT to INIT. */ + +_EXTERN_INLINE void +_hurd_port_init (struct hurd_port *port, mach_port_t init) +{ + __spin_lock_init (&port->lock); + port->users = NULL; + port->port = init; +} + + +/* Get a reference to *PORT, which is locked. + Pass return value and LINK to _hurd_port_free when done. */ + +_EXTERN_INLINE mach_port_t +_hurd_port_locked_get (struct hurd_port *port, + struct hurd_userlink *link) +{ + mach_port_t result; + result = port->port; + if (result != MACH_PORT_NULL) + _hurd_userlink_link (&port->users, link); + __spin_unlock (&port->lock); + return result; +} + +/* Same, but locks PORT first. */ + +_EXTERN_INLINE mach_port_t +_hurd_port_get (struct hurd_port *port, + struct hurd_userlink *link) +{ + mach_port_t result; + HURD_CRITICAL_BEGIN; + __spin_lock (&port->lock); + result = _hurd_port_locked_get (port, link); + HURD_CRITICAL_END; + return result; +} + + +/* Free a reference gotten with `USED_PORT = _hurd_port_get (PORT, LINK);' */ + +_EXTERN_INLINE void +_hurd_port_free (struct hurd_port *port, + struct hurd_userlink *link, + mach_port_t used_port) +{ + int dealloc; + if (used_port == MACH_PORT_NULL) + /* When we fetch an empty port cell with _hurd_port_get, + it does not link us on the users chain, since there is + no shared resource. */ + return; + HURD_CRITICAL_BEGIN; + __spin_lock (&port->lock); + dealloc = _hurd_userlink_unlink (link); + __spin_unlock (&port->lock); + HURD_CRITICAL_END; + if (dealloc) + __mach_port_deallocate (__mach_task_self (), used_port); +} + + +/* Set *PORT's port to NEWPORT. NEWPORT's reference is consumed by PORT->port. + PORT->lock is locked. */ + +_EXTERN_INLINE void +_hurd_port_locked_set (struct hurd_port *port, mach_port_t newport) +{ + mach_port_t old; + old = _hurd_userlink_clear (&port->users) ? port->port : MACH_PORT_NULL; + port->port = newport; + __spin_unlock (&port->lock); + if (old != MACH_PORT_NULL) + __mach_port_deallocate (__mach_task_self (), old); +} + +/* Same, but locks PORT first. */ + +_EXTERN_INLINE void +_hurd_port_set (struct hurd_port *port, mach_port_t newport) +{ + HURD_CRITICAL_BEGIN; + __spin_lock (&port->lock); + _hurd_port_locked_set (port, newport); + HURD_CRITICAL_END; +} + + +#endif /* hurd/port.h */ diff -ruN glibc-1.07/hurd/hurd/resource.h glibc-1.08.1/hurd/hurd/resource.h --- glibc-1.07/hurd/hurd/resource.h +++ glibc-1.08.1/hurd/hurd/resource.h Fri May 27 07:22:53 1994 @@ -0,0 +1,29 @@ +/* Resource limits for 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. */ + +#ifndef _HURD_RESOURCE_H +#define _HURD_RESOURCE_H + +#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. */ + +#endif diff -ruN glibc-1.07/hurd/hurd/signal.h glibc-1.08.1/hurd/hurd/signal.h --- glibc-1.07/hurd/hurd/signal.h +++ glibc-1.08.1/hurd/hurd/signal.h Mon May 16 21:50:19 1994 @@ -0,0 +1,373 @@ +/* Implementing POSIX.1 signals under the Hurd. +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 +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_SIGNAL_H + +#define _HURD_SIGNAL_H 1 +#include +/* Make sure is going to define NSIG. */ +#ifndef __USE_GNU +#error "Must have `_GNU_SOURCE' feature test macro to use this file" +#endif + +#define __need_NULL +#include + +#include +#include +#include +#include +#include +#include + +#include /* For `struct mutex'. */ +#include + + +/* Per-thread signal state. */ + +struct hurd_sigstate + { + /* This mutex locks most of the rest of this structure. It also acts + as a critical section lock for the thread (see below). */ + struct mutex lock; + int critical_section; + + /* XXX This should perhaps instead be something that identifies + cthreads multiplexed on a single kernel thread. */ + thread_t thread; + struct hurd_sigstate *next; /* Linked-list of thread sigstates. */ + + sigset_t blocked; + sigset_t pending; + struct sigaction actions[NSIG]; + struct sigaltstack sigaltstack; + int sigcodes[NSIG]; /* Codes for pending signals. */ + + /* 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 + + /* 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. */ + }; + +/* Linked list of states of all threads whose state has been asked for. */ + +extern struct hurd_sigstate *_hurd_sigstates; + +extern struct mutex _hurd_siglock; /* Locks _hurd_sigstates. */ + +/* Get the sigstate of a given thread, taking its lock. */ + +extern struct hurd_sigstate *_hurd_thread_sigstate (thread_t); + +/* 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 (void) +{ + struct hurd_sigstate **location = + (void *) __hurd_threadvar_location (_HURD_THREADVAR_SIGSTATE); + if (*location) + __mutex_lock (&(*location)->lock); + else + *location = _hurd_thread_sigstate (__mach_thread_self ()); /* cproc_self */ + return *location; +} + +/* Critical sections. + + A critical section is a section of code which cannot safely be interrupted + to run a signal handler; for example, code that holds any lock cannot be + interrupted lest the signal handler try to take the same lock and + deadlock result. Before entering a critical section, a thread must make + sure it holds its own sigstate lock. The thread sets the + `critical_section' flag (which is not itself locked) to indicate the + lock is already held by the same thread. Subroutines which contain + critical sections of their own then test this flag; if it is set, they + don't try to acquire the sigstate lock again, to avoid deadlock. */ + +_EXTERN_INLINE void * +_hurd_critical_section_lock (void) +{ + struct hurd_sigstate **location = + (void *) __hurd_threadvar_location (_HURD_THREADVAR_SIGSTATE); + struct hurd_sigstate *ss = *location; + if (ss == NULL) + /* The thread variable is unset; this must be the first time we've + asked for it. In this case, the critical section flag cannot + possible already be set. Look up our sigstate structure the slow + way; this locks the sigstate lock. */ + ss = *location = _hurd_thread_sigstate (__mach_thread_self ()); + else + { + if (ss->critical_section) + /* Some caller higher up has already acquired the critical section + lock. We need do nothing. The null pointer we return will + make _hurd_critical_section_unlock (below) be a no-op. */ + return NULL; + /* Acquire the sigstate lock to prevent any signal from arriving. */ + __mutex_lock (&ss->lock); + } + /* Set the critical section flag so no later call will try to + take the sigstate lock while we already have it locked. */ + ss->critical_section = 1; + /* Return our sigstate pointer; this will be passed to + _hurd_critical_section_unlock to clear the critical section flag. */ + return ss; +} + +_EXTERN_INLINE void +_hurd_critical_section_unlock (void *our_lock) +{ + if (our_lock == NULL) + /* The critical section lock was held when we began. Do nothing. */ + return; + else + { + /* It was us who acquired the critical section lock. Clear the + critical section flag and unlock the sigstate lock. */ + struct hurd_sigstate *ss = our_lock; + ss->critical_section = 0; + __mutex_unlock (&ss->lock); + } +} + +/* Convenient macros for simple uses of critical sections. + These two must be used as a pair at the same C scoping level. */ + +#define HURD_CRITICAL_BEGIN \ + { void *__hurd_critical__ = _hurd_critical_section_lock () +#define HURD_CRITICAL_END \ + _hurd_critical_section_unlock (__hurd_critical__); } while (0) + +/* Thread listening on our message port; also called the "signal thread". */ + +extern thread_t _hurd_msgport_thread; + +/* Our message port. We hold the receive right and _hurd_msgport_thread + listens for messages on it. We also hold a send right, for convenience. */ + +extern mach_port_t _hurd_msgport; + + +/* Thread to receive process-global signals. */ + +extern thread_t _hurd_sigthread; + + +/* Resource limit on core file size. Enforced by hurdsig.c. */ +extern int _hurd_core_limit; + +/* Initialize the signal code, and start the signal thread. */ + +extern void _hurdsig_init (void); + +/* Initialize proc server-assisted fault recovery for the signal thread. */ + +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. */ + +extern void _hurd_raise_signal (struct hurd_sigstate *ss, + int signo, int sigcode); + +/* Translate a Mach exception into a signal (machine-dependent). */ + +extern void _hurd_exception2signal (int exception, int code, int subcode, + int *signo, int *sigcode); + + +/* Make the thread described by SS take the signal described by SIGNO and + SIGCODE. When the signal can be considered delivered, sends a sig_post + reply message on REPLY_PORT indicating success. SS->lock is held on + entry, and released before return. */ + +extern void _hurd_internal_post_signal (struct hurd_sigstate *ss, + int signo, int sigcode, + 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); + +/* 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. */ + +extern int _hurd_thread_state_msging_p (void *state, mach_port_t *port); + +/* Set up STATE with a thread state that, when resumed, is + like `longjmp (_hurd_sigthread_fault_env, 1)'. */ + +extern void _hurd_initialize_fault_recovery_state (void *state); + + +/* Function run for SIGINFO when its action is SIG_DFL and the current + process is the session leader. */ + +extern void _hurd_siginfo_handler (int); + + +#ifdef notyet + +/* Perform interruptible RPC CALL on PORT. + 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; + }) + +#endif /* notyet */ + +/* Mask of signals that cannot be caught, blocked, or ignored. */ +#define _SIG_CANT_MASK (__sigmask (SIGSTOP) | __sigmask (SIGKILL)) + +/* Do an RPC to a process's message port. + + Each argument is an expression which returns an error code; each + expression may be evaluated several times. FETCH_MSGPORT_EXPR should + fetch the appropriate message port and store it in the local variable + `msgport'. FETCH_REFPORT_EXPR should fetch the appropriate message port + and store it in the local variable `refport' (if no reference port is + needed in the call, then FETCH_REFPORT_EXPR should be simply + KERN_SUCCESS or 0). Both of these are assumed to create user + references, which this macro deallocates. RPC_EXPR should perform the + desired RPC operation using `msgport' and `refport'. + + The reason for the complexity is that a process's message port and + reference port may change between fetching those ports and completing an + RPC using them (usually they change only when a process execs). The RPC + will fail with MACH_SEND_INVALID_DEST if the msgport dies before we can + send the RPC request; or with MIG_SERVER_DIED if the msgport was + destroyed after we sent the RPC request but before it was serviced. In + either of these cases, we retry the entire operation, discarding the old + message and reference ports and fetch them anew. */ + +#define HURD_MSGPORT_RPC(fetch_msgport_expr, fetch_refport_expr, rpc_expr) \ +({ \ + error_t __err; \ + mach_port_t msgport, refport = MACH_PORT_NULL; \ + do \ + { \ + /* Get the message port. */ \ + if (__err = (fetch_msgport_expr)) \ + break; \ + /* Get the reference port. */ \ + if (__err = (fetch_refport_expr)) \ + { \ + /* Couldn't get it; deallocate MSGPORT and fail. */ \ + __mach_port_deallocate (__mach_task_self (), msgport); \ + break; \ + } \ + __err = (rpc_expr); \ + __mach_port_deallocate (__mach_task_self (), msgport); \ + if (refport != MACH_PORT_NULL) \ + __mach_port_deallocate (__mach_task_self (), refport); \ + } while (__err == MACH_SEND_INVALID_DEST || \ + __err == MIG_SERVER_DIED); \ + __err; \ +}) + +/* Some other parts of the library need to preempt signals, to detect + errors that should not result in a POSIX signal. For example, when + some mapped region of memory is used, an extraneous SIGSEGV might be + generated when the mapping server returns an error for a page fault. */ + +struct hurd_signal_preempt + { + /* Function to examine a thread receiving a given signal. The handler + is called even for blocked signals. This function is run in the + signal thread, with THREAD's sigstate locked; it should be as simple + and robust as possible. THREAD is the thread which is about to + receive the signal. SIGNO and SIGCODE would be passed to the normal + handler. + + If the return value is SIG_DFL, normal signal processing continues. + If it is SIG_IGN, the signal is ignored. + Any other value is used in place of the normal handler. */ + sighandler_t (*handler) (thread_t thread, int signo, int sigcode); + int first, last; /* Range of sigcodes this handler wants. */ + struct hurd_signal_preempt *next; /* Next handler on the chain. */ + }; + +extern struct hurd_signal_preempt *_hurd_signal_preempt[NSIG]; +extern struct mutex _hurd_signal_preempt_lock; + + +#endif /* hurd/signal.h */ diff -ruN glibc-1.07/hurd/hurd/threadvar.h glibc-1.08.1/hurd/hurd/threadvar.h --- glibc-1.07/hurd/hurd/threadvar.h +++ glibc-1.08.1/hurd/hurd/threadvar.h Wed May 11 13:44:27 1994 @@ -0,0 +1,107 @@ +/* Internal per-thread variables for 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. */ + +#ifndef _HURD_THREADVAR_H +#define _HURD_THREADVAR_H + +/* The per-thread variables are found by ANDing this mask + with the value of the stack pointer and then adding this offset. + + In the multi-threaded case, cthreads initialization sets + __hurd_threadvar_stack_mask to ~(cthread_stack_size - 1), a mask which + finds the base of the fixed-size cthreads stack; and + __hurd_threadvar_stack_offset to a small offset that skips the data + cthreads itself maintains at the base of each thread's stack. + + In the single-threaded case, __hurd_threadvar_stack_mask is zero, so the + stack pointer is ignored; and __hurd_threadvar_stack_offset gives the + address of a small allocated region which contains the variables for the + single thread. */ + +extern unsigned long int __hurd_threadvar_stack_mask; +extern unsigned long int __hurd_threadvar_stack_offset; + +/* A special case must always be made for the signal thread. Even when there + is only one user thread and an allocated region can be used for the user + thread's variables, the signal thread needs to have its own location for + per-thread variables. The variables __hurd_sigthread_stack_base and + __hurd_sigthread_stack_end define the bounds of the stack used by the + signal thread, so that thread can always be specifically identified. */ + +extern unsigned long int __hurd_sigthread_stack_base; +extern unsigned long int __hurd_sigthread_stack_end; +extern unsigned long int *__hurd_sigthread_variables; + + +/* At the location described by the two variables above, + there are __hurd_threadvar_max `unsigned long int's of per-thread data. */ +extern unsigned int __hurd_threadvar_max; + +/* These values are the indices for the standard per-thread variables. */ +enum __hurd_threadvar_index + { + _HURD_THREADVAR_MIG_REPLY, /* Reply port for MiG user stub functions. */ + _HURD_THREADVAR_ERRNO, /* `errno' value for this thread. */ + _HURD_THREADVAR_SIGSTATE, /* This thread's `struct hurd_sigstate'. */ + _HURD_THREADVAR_DYNAMIC_USER, /* Dynamically-assigned user variables. */ + _HURD_THREADVAR_MAX /* Default value for __hurd_threadvar_max. */ + }; + + +#ifndef _EXTERN_INLINE +#define _EXTERN_INLINE extern __inline +#endif + +/* Return the location of the value for the per-thread variable with index + INDEX used by the thread whose stack pointer is SP. */ + +_EXTERN_INLINE unsigned long int * +__hurd_threadvar_location_from_sp (enum __hurd_threadvar_index __index, + void *__sp) +{ + unsigned long int __stack = (unsigned long int) __sp; + return &((__stack >= __hurd_sigthread_stack_base && + __stack < __hurd_sigthread_stack_end) + ? __hurd_sigthread_variables + : (unsigned long int *) ((__stack & __hurd_threadvar_stack_mask) + + __hurd_threadvar_stack_offset))[__index]; +} + +#include /* Define __thread_stack_pointer. */ + +/* Return the location of the current thread's value for the + per-thread variable with index INDEX. */ + +_EXTERN_INLINE unsigned long int * +__hurd_threadvar_location (enum __hurd_threadvar_index __index) +{ + return __hurd_threadvar_location_from_sp (__index, + __thread_stack_pointer ()); +} + +/* Return the current thread's location for `errno'. + The syntax of this function allows redeclarations like `int errno'. */ +_EXTERN_INLINE int * +__hurd_errno_location (void) +{ + return (int *) __hurd_threadvar_location (_HURD_THREADVAR_ERRNO); +} + + +#endif /* hurd/threadvar.h */ diff -ruN glibc-1.07/hurd/hurd/userlink.h glibc-1.08.1/hurd/hurd/userlink.h --- glibc-1.07/hurd/hurd/userlink.h +++ glibc-1.08.1/hurd/hurd/userlink.h Tue Apr 19 17:24:16 1994 @@ -0,0 +1,105 @@ +/* Support for chains recording users of a resource; `struct hurd_userlink'. +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_USERLINK_H + +#define _HURD_USERLINK_H 1 +#include + +#define __need_NULL +#include + + +/* This structure is simply a doubly-linked list. Users of a given + resource are recorded by their presence in a list associated with that + resource. A user attaches his own link (in local storage) to a shared + chain at the time he begins using some resource. When finished with + that resource, the user removes his link from the chain. If his link is + the last (there are no other users of the resource), and his chain has + been detached from the shared cell (the resource in the cell has been + replaced), then the user deallocates the resource that he used. */ + +struct hurd_userlink + { + struct hurd_userlink *next, **prevp; + }; + + +#ifndef _EXTERN_INLINE +#define _EXTERN_INLINE extern __inline +#endif + + +/* Attach LINK to the chain of users at *CHAINP. */ + +_EXTERN_INLINE void +_hurd_userlink_link (struct hurd_userlink **chainp, + struct hurd_userlink *link) +{ + link->next = *chainp; + if (link->next) + link->next->prevp = &link->next; + link->prevp = chainp; + *chainp = link; +} + + +/* Detach LINK from its chain. If the return value is nonzero, the caller + should deallocate the resource he started using after attaching LINK to + the chain it's on. If the return value is zero, then someone else is + still using the resource. */ + +_EXTERN_INLINE int +_hurd_userlink_unlink (struct hurd_userlink *link) +{ + /* The caller should deallocate the resource he used if his chain has + been detached from the cell (and thus has a nil `prevp'), and there is + no next link representing another user reference to the same resource. */ + int dealloc = ! link->next && ! link->prevp; + + /* Remove our link from the chain of current users. */ + if (link->prevp) + *link->prevp = link->next; + if (link->next) + link->next->prevp = link->prevp; + + return dealloc; +} + + +/* Clear all users from *CHAINP. Call this when the resource *CHAINP + protects is changing. If the return value is nonzero, no users are on + the chain and the caller should deallocate the resource. If the return + value is zero, someone is still using the resource and they will + deallocate it when they are finished. */ + +_EXTERN_INLINE int +_hurd_userlink_clear (struct hurd_userlink **chainp) +{ + if (*chainp == NULL) + return 1; + + /* Detach the chain of current users from the cell. The last user to + remove his link from that chain will deallocate the old resource. */ + (*chainp)->prevp = NULL; + *chainp = NULL; + return 0; +} + +#endif /* hurd/userlink.h */ diff -ruN glibc-1.07/hurd/hurd-raise.c glibc-1.08.1/hurd/hurd-raise.c --- glibc-1.07/hurd/hurd-raise.c +++ glibc-1.08.1/hurd/hurd-raise.c Fri Apr 29 01:01:29 1994 @@ -0,0 +1,43 @@ +/* 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 + +/* Handle signal SIGNO in the calling thread. + If SS is not NULL it is the sigstate for the calling thread; + SS->lock is held on entry and released before return. */ + +void +_hurd_raise_signal (struct hurd_sigstate *ss, int signo, int sigcode) +{ + if (ss == NULL) + ss = _hurd_self_sigstate (); + + /* Mark SIGNO as pending to be delivered. */ + __sigaddset (&ss->pending, signo); + ss->sigcodes[signo] = sigcode; + + __mutex_unlock (&ss->lock); + + /* Send a message to the signal thread so it + will wake up and check for pending signals. */ + __sig_post (_hurd_msgport, 0, __mach_task_self ()); +} diff -ruN glibc-1.07/hurd/hurd.h glibc-1.08.1/hurd/hurd.h --- glibc-1.07/hurd/hurd.h Sun Jan 16 05:38:44 1994 +++ glibc-1.08.1/hurd/hurd.h Wed Apr 27 07:08:55 1994 @@ -19,12 +19,6 @@ #ifndef _HURD_H #define _HURD_H 1 - -/* This is here because this file includes some other headers - and expects some non-ANSI, non-POSIX symbols to be defined. */ -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif #include @@ -41,560 +35,76 @@ #include #include #include -#include + +/* Get `struct hurd_port' and related definitions implementing lightweight + user references for ports. These are used pervasively throughout the C + library; this is here to avoid putting it in nearly every source file. */ +#include #include #define __hurd_fail(err) (errno = (err), -1) - -#define __spin_lock(lockaddr) /* no-op XXX */ -#define __spin_unlock(lockaddr) /* no-op XXX */ - -#define __mutex_lock(lockaddr) /* no-op XXX */ -#define __mutex_unlock(lockaddr) /* no-op XXX */ - - -/* Lightweight user references for ports. */ - -/* Structure describing a cell containing a port. With the lock held, a - user extracts PORT, and attaches his own link (in local storage) to the - USERS chain. PORT can then safely be used. When PORT is no longer - needed, with the lock held, the user removes his link from the chain. - If his link is the last, and PORT has changed since he fetched it, the - user deallocates the port he used. */ -struct _hurd_port - { -#ifdef noteven - spin_lock_t lock; /* Locks rest. */ -#endif - struct _hurd_port_userlink *users; /* Chain of users; see below. */ - mach_port_t port; /* Port. */ - }; - -/* This structure is simply a doubly-linked list. - Users of a port cell are recorded by their presence in the list. */ -struct _hurd_port_userlink - { - struct _hurd_port_userlink *next, **prevp; - }; - -/* Evaluate EXPR with the variable `port' bound to the port in PORTCELL. */ -#define _HURD_PORT_USE(portcell, expr) \ - ({ struct _hurd_port *const __p = (portcell); \ - struct _hurd_port_userlink __link; \ - const mach_port_t port = _hurd_port_get (__p, &__link); \ - __typeof(expr) __result = (expr); \ - _hurd_port_free (__p, &__link, port); \ - __result; }) - -/* Initialize *PORT to INIT. */ -static inline void -_hurd_port_init (struct _hurd_port *port, mach_port_t init) -{ -#ifdef noteven - __spin_lock_init (&port->lock); -#endif - port->users = NULL; - port->port = init; -} - -/* Get a reference to *PORT, which is locked. - Pass return value and LINK to _hurd_port_free when done. */ -static inline mach_port_t -_hurd_port_locked_get (struct _hurd_port *port, - struct _hurd_port_userlink *link) -{ - mach_port_t result; - result = port->port; - if (result != MACH_PORT_NULL) - { - link->next = port->users; - if (link->next) - link->next->prevp = &link->next; - link->prevp = &port->users; - port->users = link; - } - __spin_unlock (&port->lock); - return result; -} - -/* Same, but locks PORT first. */ -static inline mach_port_t -_hurd_port_get (struct _hurd_port *port, int *myflag) -{ - __spin_lock (&port->lock); - return _hurd_port_locked_get (port, myflag); -} - -/* Free a reference gotten with - `USED_PORT = _hurd_port_get (PORT, LINK);' */ -static inline void -_hurd_port_free (struct _hurd_port *port, - struct _hurd_port_userlink *link, - mach_port_t used_port) -{ - int dealloc; - __spin_lock (&port->lock); - /* We should deallocate USED_PORT if our chain has been detached from the - cell (and thus has a nil `prevp'), and there is no next link - representing another user reference to the same port we fetched. */ - dealloc = ! link->next && ! link->prevp; - /* Remove our link from the chain of current users. */ - if (link->prevp) - *link->prevp = link->next; - if (link->next) - link->next->prevp = link->prevp; - __spin_unlock (&port->lock); - if (dealloc) - __mach_port_deallocate (__mach_task_self (), used_port); -} - -/* Set *PORT's port to NEWPORT. NEWPORT's reference is consumed by PORT->port. - PORT->lock is locked. */ -static inline void -_hurd_port_locked_set (struct _hurd_port *port, mach_port_t newport) -{ - mach_port_t old; - if (port->users == NULL) - old = port->port; - else - { - old = MACH_PORT_NULL; - /* Detach the chain of current users from the cell. The last user to - remove his link from that chain will deallocate the old port. */ - port->users->prevp = NULL; - port->users = NULL; - } - port->port = newport; - __spin_unlock (&port->lock); - if (old != MACH_PORT_NULL) - __mach_port_deallocate (__mach_task_self (), old); -} - -/* Same, but locks PORT first. */ -static inline void -_hurd_port_set (struct _hurd_port *port, mach_port_t newport) -{ - __spin_lock (&port->lock); - return _hurd_port_locked_set (port, newport); -} /* Basic ports and info, initialized by startup. */ -extern struct _hurd_port *_hurd_ports; + +extern struct hurd_port *_hurd_ports; extern unsigned int _hurd_nports; extern volatile mode_t _hurd_umask; -/* Shorthand macro for referencing _hurd_ports. */ +/* Shorthand macro for referencing _hurd_ports (see ). */ + #define __USEPORT(which, expr) \ - _HURD_PORT_USE (&_hurd_ports[INIT_PORT_##which], (expr)) + HURD_PORT_USE (&_hurd_ports[INIT_PORT_##which], (expr)) + /* Base address and size of the initial stack set up by the exec server. If using cthreads, this stack is deallocated in startup. Not locked. */ + extern vm_address_t _hurd_stack_base; extern vm_size_t _hurd_stack_size; -extern thread_t _hurd_msgport_thread; -extern mach_port_t _hurd_msgport; /* Locked by _hurd_siglock. */ +/* Initial file descriptor table we were passed at startup. If we are + using a real dtable, these are turned into that and then cleared at + startup. If not, these are never changed after startup. Not locked. */ -/* Not locked. If we are using a real dtable, these are turned into that - and then cleared at startup. If not, these are never changed after - startup. */ extern mach_port_t *_hurd_init_dtable; extern mach_msg_type_number_t _hurd_init_dtablesize; -/* File descriptor table. */ - - -/* File descriptor structure. */ -struct _hurd_fd - { - struct _hurd_port port; /* io server port. */ - int flags; /* fcntl flags; locked by port.lock. */ - - /* Normal port to the ctty. When `port' is our ctty, this is a port to - the same io object but which never returns EBACKGROUND; when not, - this is nil. */ - struct _hurd_port ctty; - }; - -/* Set up *FD to have PORT its server port, doing appropriate ctty magic. - Does no locking or unlocking. */ -extern void _hurd_port2fd (struct _hurd_fd *fd, io_t port, int flags); - -/* Allocate a new file descriptor and install PORT in it (doing any - appropriate ctty magic); consumes a user reference on PORT. FLAGS are - as for `open'; only O_NOCTTY is meaningful, but all are saved. - - If the descriptor table is full, set errno, and return -1. - If DEALLOC is nonzero, deallocate PORT first. */ -extern int _hurd_intern_fd (io_t port, int flags, int dealloc); - -/* Allocate a new file descriptor and return it, locked. - The new descriptor will not be less than FIRST_FD. */ -extern struct _hurd_fd *_hurd_alloc_fd (int *fd_ptr, int first_fd); - - -struct _hurd_dtable - { - int size; /* Number of elts in `d' array. */ - - /* Uses of individual descriptors are not locked. It is up to the user - to synchronize descriptor operations on a single descriptor. */ - - struct _hurd_fd *d; - }; - -#ifdef noteven -extern struct mutex _hurd_dtable_lock; /* Locks next two. */ -#endif -extern struct _hurd_dtable _hurd_dtable; -extern int _hurd_dtable_rlimit; /* RLIM_OFILES: number of file descriptors. */ - -/* If not NULL, pointed-to word is set when _hurd_dtable.d changes. - User who set `user_dealloc' should free the _hurd_dtable.d value - he used if his word is set when he is finished. - If NULL, the old value of _hurd_dtable.d is freed by the setter. */ -int *_hurd_dtable_user_dealloc; - -static inline struct _hurd_dtable -_hurd_dtable_use (int *dealloc) -{ - struct _hurd_dtable dtable; - __mutex_lock (&_hurd_dtable_lock); - _hurd_dtable_user_dealloc = dealloc; - dtable = _hurd_dtable; - __mutex_unlock (&_hurd_dtable_lock); - return dtable; -} - -struct _hurd_dtable_resizes - { - size_t n; - void (*free) (void *); - void *terminator; - }; -extern const struct _hurd_dtable_resizes _hurd_dtable_resizes; - -static inline void -_hurd_dtable_done (struct _hurd_dtable dtable, int *dealloc) -{ - __mutex_lock (&_hurd_dtable_lock); - if (_hurd_dtable_user_dealloc == dealloc) - _hurd_dtable_user_dealloc = NULL; - __mutex_unlock (&_hurd_dtable_lock); - if (*dealloc) - /* _hurd_dtable_resizes is a symbol set. - setrlimit.c gives it one element: free. - If setrlimit is not linked in, *DEALLOC - will never get set, so we will never get here. - This hair avoids linking in free if we don't need it. */ - (*_hurd_dtable_resizes.free) (dtable.d); -} - -/* Return the descriptor cell for FD in DTABLE, locked. */ -static inline struct _hurd_fd * -_hurd_dtable_fd (int fd, struct _hurd_dtable dtable) -{ - if (fd < 0 || fd >= dtable.size) - return NULL; - else - { - struct _hurd_fd *cell = &dtable.d[fd]; - __spin_lock (&cell->port.lock); - if (cell->port.port == MACH_PORT_NULL) - { - __spin_unlock (&cell->port.lock); - return NULL; - } - return cell; - } -} - -struct _hurd_fd_user - { - struct _hurd_dtable dtable; - struct _hurd_fd *d; - }; - -/* Returns the descriptor cell for FD, locked. The passed DEALLOC word and - returned structure hold onto the descriptor table to it doesn't move - while you might be using a pointer into it. */ -static inline struct _hurd_fd_user -_hurd_fd (int fd, int *dealloc) -{ - struct _hurd_fd_user d; - d.dtable = _hurd_dtable_use (dealloc); - d.d = _hurd_dtable_fd (fd, d.dtable); - if (d.d == NULL) - _hurd_dtable_done (d.dtable, dealloc); - return d; -} - -static inline void -_hurd_fd_done (struct _hurd_fd_user d, int *dealloc) -{ - _hurd_dtable_done (d.dtable, dealloc); -} - -/* Evaluate EXPR with the variable `port' bound to the port to FD, - and `ctty' bound to the ctty port. */ - -#define _HURD_DPORT_USE(fd, expr) \ - ({ int __dealloc_dt; \ - error_t __result; \ - struct _hurd_fd_user __d = _hurd_fd (fd, &__dealloc_dt); \ - if (__d.d == NULL) \ - __result = EBADF; \ - else \ - { \ - int __dealloc, __dealloc_ctty; \ - io_t port = _hurd_port_locked_get (&__d.d->port, &__dealloc); \ - io_t ctty = _hurd_port_locked_get (&__d.d->ctty, &__dealloc_ctty); \ - __result = (expr); \ - _hurd_port_free (&__d.d->port, &__dealloc, port); \ - if (ctty != MACH_PORT_NULL) \ - _hurd_port_free (&__d.d->ctty, &__dealloc_ctty, ctty); \ - _hurd_fd_done (__d, &__dealloc_dt); \ - } \ - __result; \ - }) \ - -static inline int -__hurd_dfail (int fd, error_t err) -{ - switch (err) - { - case MACH_SEND_INVALID_DEST: /* The server has disappeared! */ -#ifdef notyet - _hurd_raise_signal (NULL, SIGLOST, fd); -#else - abort (); -#endif - break; - case EPIPE: -#ifdef notyet - _hurd_raise_signal (NULL, SIGPIPE, fd); -#else - abort (); -#endif - break; - default: - return __hurd_fail (err); - } -} - -/* Return the socket server for sockaddr domain DOMAIN. */ -extern socket_t _hurd_socket_server (int domain); +/* Miscellaneous library state. */ /* Current process IDs. */ + extern pid_t _hurd_pid, _hurd_ppid, _hurd_pgrp; extern int _hurd_orphaned; -#ifdef noteven extern struct mutex _hurd_pid_lock; /* Locks above. */ -#endif + +/* Unix `data break', for brk and sbrk. + If brk and sbrk are not used, this info will not be initialized or used. */ -/* User and group IDs. */ -struct _hurd_id_data - { -#ifdef noteven - mutex_t lock; -#endif - - int valid; /* If following data are up to date. */ - - struct - { - uid_t *uids; - gid_t *gids; - unsigned int nuids, ngids; - } gen, aux; - - auth_t rid_auth; /* Cache used by access. */ - }; -extern struct _hurd_id_data _hurd_id; -/* Update _hurd_id (caller should be holding the lock). */ -extern error_t _hurd_check_ids (void); +/* Data break. This is what `sbrk (0)' returns. */ +extern vm_address_t _hurd_brk; -/* Unix `data break', for brk and sbrk. - If brk and sbrk are not used, this info will not be initialized or used. */ -extern vm_address_t _hurd_brk; /* Data break. */ -extern vm_address_t _hurd_data_end; /* End of allocated space. */ -#ifdef noteven -extern struct mutex _hurd_brk_lock; /* Locks brk and data_end. */ -#endif -extern int _hurd_set_data_limit (const struct rlimit *); +/* End of allocated space. This is generally `round_page (_hurd_brk)'. */ + +extern vm_address_t _hurd_data_end; + +/* This mutex locks _hurd_brk and _hurd_data_end. */ -/* Set the data break; the brk lock must +extern struct mutex _hurd_brk_lock; + +/* Set the data break to NEWBRK; _hurd_brk_lock must be held, and is released on return. */ -extern int _hurd_set_brk (vm_address_t newbrk); -/* Resource limit on core file size. Enforced by hurdsig.c. */ -extern int _hurd_core_limit; +extern int _hurd_set_brk (vm_address_t newbrk); -#include +#define __need_FILE +#include -/* Per-thread signal state. */ -struct _hurd_sigstate - { - /* XXX should be in cthread variable (?) */ - thread_t thread; - struct _hurd_sigstate *next; /* Linked-list of thread sigstates. */ - -#ifdef noteven - struct mutex lock; /* Locks the rest of this structure. */ -#endif - sigset_t blocked; - sigset_t pending; - struct sigaction actions[NSIG]; - struct sigaltstack sigaltstack; - int sigcodes[NSIG]; /* Codes for pending signals. */ - - int suspended; /* If nonzero, sig_post signals `arrived'. */ -#ifdef noteven - struct condition arrived; -#endif - -#if 0 - int vforked; /* Nonzero if this thread is a vfork child. */ - struct - { - process_t proc; - file_t ccdir, cwdir, crdir, auth; - mode_t umask; - int ctty_fstype; - fsid_t ctty_fsid; - ino_t ctty_fileid; - struct _hurd_dtable *dtable; - jmp_buf continuation; - } *vfork_saved; -#endif - - /* Not locked. Used only by this thread, - or by 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. */ - }; -/* Linked list of states of all threads - whose state has been inquired about. */ -extern struct _hurd_sigstate *_hurd_sigstates; -extern struct mutex _hurd_siglock; /* Locks _hurd_sigstates. */ -/* Get the sigstate of a given thread, taking its lock. */ -extern struct _hurd_sigstate *_hurd_thread_sigstate (thread_t); - -/* Thread to receive process-global signals. */ -extern thread_t _hurd_sigthread; - -/* Called by the machine-dependent exception handler. */ -extern void _hurd_exc_post_signal (thread_t, int sig, int code); - -/* SS->lock is held on entry, and released before return. */ -extern void _hurd_internal_post_signal (struct _hurd_sigstate *ss, - int signo, int sigcode, - sigset_t *restore_blocked); - -/* Function run by the signal thread to receive from the signal port. */ -extern void _hurd_msgport_receive (void); - - -#ifdef notyet -/* Perform interruptible RPC CALL on PORT. - 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_thread_sigstate (__mach_thread_self ()); - __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; - }) - -#endif /* notyet */ - -/* Mask of signals that cannot be caught, blocked, or ignored. */ -#define _SIG_CANT_MASK (__sigmask (SIGSTOP) | __sigmask (SIGKILL)) - -/* Do an RPC to a process's message port. - - Each argument is an expression which returns an error code; each - expression may be evaluated several times. FETCH_MSGPORT_EXPR should - fetch the appropriate message port and store it in the local variable - `msgport'. FETCH_REFPORT_EXPR should fetch the appropriate message port - and store it in the local variable `refport' (if no reference port is - needed in the call, then FETCH_REFPORT_EXPR should be simply - KERN_SUCCESS or 0). Both of these are assumed to create user - references, which this macro deallocates. RPC_EXPR should perform the - desired RPC operation using `msgport' and `refport'. - - The reason for the complexity is that a process's message port and - reference port may change between fetching those ports and completing an - RPC using them (usually they change only when a process execs). The RPC - will fail with MACH_SEND_INVALID_DEST if the msgport dies before we can - send the RPC request; or with MIG_SERVER_DIED if the msgport was - destroyed after we sent the RPC request but before it was serviced. In - either of these cases, we retry the entire operation, discarding the old - message and reference ports and fetch them anew. */ - -#define _HURD_MSGPORT_RPC(fetch_msgport_expr, fetch_refport_expr, rpc_expr) \ -({ \ - error_t __err; \ - mach_port_t msgport, refport = MACH_PORT_NULL; \ - do \ - { \ - /* Get the message port. */ \ - if (__err = (fetch_msgport_expr)) \ - break; \ - /* Get the reference port. */ \ - if (__err = (fetch_refport_expr)) \ - { \ - /* Couldn't get it; deallocate MSGPORT and fail. */ \ - mach_port_deallocate (__mach_task_self (), msgport); \ - break; \ - } \ - __err = (rpc_expr); \ - mach_port_deallocate (__mach_task_self (), msgport); \ - if (refport != MACH_PORT_NULL) \ - mach_port_deallocate (__mach_task_self (), refport); \ - } while (__err != MACH_SEND_INVALID_DEST && \ - __err != MIG_SERVER_DIED); \ - __err; \ -}) - /* Calls to get and set basic ports. */ + extern process_t getproc (void); extern file_t getccdir (void), getcwdir (void), getcrdir (void); extern auth_t getauth (void); @@ -605,6 +115,12 @@ extern int __setauth (auth_t), setauth (auth_t); +/* Split FILE into a directory and a name within the directory. Look up a + port for the directory and store it in *DIR; store in *NAME a pointer + into FILE where the name within directory begins. The directory lookup + 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); @@ -611,6 +127,12 @@ extern error_t hurd_path_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, @@ -620,71 +142,100 @@ int flags, mode_t mode, file_t *port); -/* Returns a port to the directory, and sets *NAME to the file name. */ +/* Split FILE into a directory and a name within the directory. The + directory lookup uses the current root and working directory. If + successful, stores in *NAME a pointer into FILE where the name + 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); -/* Looks up FILE with the given FLAGS and MODE (as for dir_pathtrans). */ +/* 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); -/* Open a file descriptor on a port. */ + +/* Open a file descriptor on a port. FLAGS are as for `open'. */ + extern int openport (io_t port, int flags); -/* Execute a file, replacing the current program image. */ -extern error_t _hurd_exec (file_t file, +/* Open a stream on a port. MODE is as for `fopen'. + If successful, this consumes a user reference for PORT + (which will be deallocated on fclose). */ + +extern FILE *fopenport (io_t port, const char *mode); +extern FILE *__fopenport (io_t port, const char *mode); + + +/* Execute a file, replacing TASK's current program image. */ + +extern error_t _hurd_exec (task_t task, + file_t file, char *const argv[], char *const envp[]); + /* Inform the proc server we have exitted with STATUS, and kill the task thoroughly. This function never returns, no matter what. */ -extern volatile void _hurd_exit (int status); +extern void _hurd_exit (int status) __attribute__ ((noreturn)); + + /* Initialize the library data structures from the ints and ports passed to us by the exec server. Then vm_deallocate PORTARRAY and INTARRAY. */ + extern void _hurd_init (int flags, char **argv, mach_port_t *portarray, size_t portarraysize, int *intarray, size_t intarraysize); /* Do startup handshaking with the proc server. */ + extern void _hurd_proc_init (char **argv); + +/* Return the socket server for sockaddr domain DOMAIN. */ + +extern socket_t _hurd_socket_server (int domain); + +/* 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. */ + +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 variables - below. A special program that gets them from somewhere other than the - proc server (such as a bootstrap filesystem) can set these variables at - startup to install the ports. */ + server. They are fetched only once and then cached in the + variables below. A special program that gets them from somewhere + other than the proc server (such as a bootstrap filesystem) can set + these variables to install the ports. */ + extern kern_return_t get_privileged_ports (host_priv_t *host_priv_ptr, device_t *device_master_ptr); extern mach_port_t _hurd_host_priv, _hurd_device_master; -/* Convert between PIDs and task ports. */ -extern pid_t __task2pid (task_t), task2pid (task_t); -extern task_t __pid2task (pid_t), pid2task (pid_t); - -/* User-registered handlers for specific `ioctl' requests. */ +/* Return the PID of the task whose control port is TASK. + On error, sets `errno' and returns -1. */ -struct ioctl_handler - { - int first_request, last_request; /* Range of handled request values. */ +extern pid_t __task2pid (task_t task), task2pid (task_t task); - int (*handler) (int fd, int request, void *arg); +/* Return the task control port of process PID. + On error, sets `errno' and returns MACH_PORT_NULL. */ - struct ioctl_handler *next; /* Next handler. */ - }; +extern task_t __pid2task (pid_t pid), pid2task (pid_t pid); -/* Define a library-internal handler for ioctl commands - between FIRST and LAST inclusive. */ -#define _HURD_HANDLE_IOCTLS(handler, first, last) \ - static const struct ioctl_handler handler##_ioctl_handler = \ - { first, last, handler, NULL }; \ - text_set_element (_hurd_ioctl_handler_lists, ##handler##_ioctl_handler) +/* Return the io server port for file descriptor FD. + This adds a Mach user reference to the returned port. + On error, sets `errno' and returns MACH_PORT_NULL. */ -/* Define a library-internal handler for a single ioctl command. */ -#define _HURD_HANDLE_IOCTL(handler, ioctl) \ - _HURD_HANDLE_IOCTLS (handler, (ioctl), (ioctl)) +extern io_t __getdport (int fd), getdport (int fd); #endif /* hurd.h */ diff -ruN glibc-1.07/hurd/hurdauth.c glibc-1.08.1/hurd/hurdauth.c --- glibc-1.07/hurd/hurdauth.c +++ glibc-1.08.1/hurd/hurdauth.c Wed May 11 23:47:25 1994 @@ -0,0 +1,129 @@ +/* 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 + +int +_hurd_refport_secure_p (mach_port_t ref) +{ + if (ref == __mach_task_self ()) + return 1; + if (__USEPORT (AUTH, ref == port)) + return 1; + return 0; +} + +kern_return_t +_S_add_auth (mach_port_t me, + auth_t addauth) +{ + error_t err; + auth_t newauth; + + if (err = __USEPORT (AUTH, + __auth_makeauth (port, + &addauth, 1, MACH_MSG_TYPE_MOVE_SEND, + NULL, 0, + NULL, 0, + NULL, 0, + NULL, 0, + &newauth))) + return err; + + err = __setauth (newauth); + __mach_port_deallocate (__mach_task_self (), newauth); + if (err) + return errno; + + return 0; +} + +kern_return_t +_S_del_auth (mach_port_t me, + task_t task, + intarray_t uids, mach_msg_type_number_t nuids, + intarray_t gids, mach_msg_type_number_t ngids) +{ + error_t err; + auth_t newauth; + + if (!_hurd_refport_secure_p (task)) + return EPERM; + + HURD_CRITICAL_BEGIN; + __mutex_lock (&_hurd_id.lock); + err = _hurd_check_ids (); + + if (!err) + { + size_t i, j; + size_t nu = _hurd_id.gen.nuids, ng = _hurd_id.gen.ngids; + uid_t newu[nu]; + gid_t newg[ng]; + + memcpy (newu, _hurd_id.gen.uids, nu * sizeof (uid_t)); + memcpy (newg, _hurd_id.gen.gids, ng * sizeof (gid_t)); + + for (j = 0; j < nuids; ++j) + { + const uid_t uid = uids[j]; + for (i = 0; i < nu; ++i) + if (newu[i] == uid) + /* Move the last uid into this slot, and decrease the + number of uids so the last slot is no longer used. */ + newu[i] = newu[--nu]; + } + __vm_deallocate (__mach_task_self (), + (vm_address_t) uids, nuids * sizeof (uid_t)); + + for (j = 0; j < ngids; ++j) + { + const gid_t gid = gids[j]; + for (i = 0; i < nu; ++i) + if (newu[i] == gid) + /* Move the last gid into this slot, and decrease the + number of gids so the last slot is no longer used. */ + newu[i] = newu[--nu]; + } + __vm_deallocate (__mach_task_self (), + (vm_address_t) gids, ngids * sizeof (gid_t)); + + err = __USEPORT (AUTH, __auth_makeauth + (port, + NULL, 0, MACH_MSG_TYPE_COPY_SEND, + newu, nu, + _hurd_id.aux.uids, _hurd_id.aux.nuids, + newg, ng, + _hurd_id.aux.uids, _hurd_id.aux.ngids, + &newauth)); + } + __mutex_unlock (&_hurd_id.lock); + HURD_CRITICAL_END; + + if (err) + return err; + + err = __setauth (newauth); /* XXX clobbers errno */ + __mach_port_deallocate (__mach_task_self (), newauth); + if (err) + return errno; + + return 0; +} diff -ruN glibc-1.07/hurd/hurdexec.c glibc-1.08.1/hurd/hurdexec.c --- glibc-1.07/hurd/hurdexec.c Thu Jan 6 01:41:07 1994 +++ glibc-1.08.1/hurd/hurdexec.c Mon May 23 22:30:15 1994 @@ -18,16 +18,20 @@ #include #include -#include #include #include #include #include +#include +#include +#include -/* Replace the current process, executing FILE with arguments ARGV and - environment ENVP. ARGV and ENVP are terminated by NULL pointers. */ +/* Overlay TASK, executing FILE with arguments ARGV and environment ENVP. + If TASK == mach_task_self (), some ports are dealloc'd by the exec server. + ARGV and ENVP are terminated by NULL pointers. */ error_t -_hurd_exec (file_t file, char *const argv[], char *const envp[]) +_hurd_exec (task_t task, file_t file, + char *const argv[], char *const envp[]) { error_t err; char *args, *env, *ap; @@ -34,38 +38,63 @@ size_t argslen, envlen; int ints[INIT_INT_MAX]; mach_port_t ports[_hurd_nports]; - int dealloc_ports[_hurd_nports]; - file_t *dtable; + struct hurd_userlink ulink_ports[_hurd_nports]; + file_t *dtable, *dtable_ctty; int dtablesize; - struct _hurd_port **dtable_cells; - int *dealloc_dtable, *dealloc_cells; + struct hurd_port **dtable_cells, **dtable_ctty_cells; + struct hurd_userlink *ulink_dtable, *ulink_dtable_ctty; int i; char *const *p; - struct _hurd_sigstate *ss; + struct hurd_sigstate *ss; + mach_port_t *please_dealloc, *pdp; + /* Pack the arguments into an array with nulls separating the elements. */ argslen = 0; - p = argv; - while (*p != NULL) - argslen += strlen (*p++) + 1; - args = __alloca (argslen); - ap = args; - for (p = argv; *p != NULL; ++p) - ap = __memccpy (ap, *p, '\0', ULONG_MAX); + if (argv != NULL) + { + p = argv; + while (*p != NULL) + argslen += strlen (*p++) + 1; + args = __alloca (argslen); + ap = args; + for (p = argv; *p != NULL; ++p) + ap = __memccpy (ap, *p, '\0', ULONG_MAX); + } + else + args = NULL; /* Pack the environment into an array with nulls separating elements. */ envlen = 0; - p = envp; - while (*p != NULL) - envlen += strlen (*p++) + 1; - env = __alloca (envlen); - ap = env; - for (p = envp; *p != NULL; ++p) - ap = __memccpy (ap, *p, '\0', ULONG_MAX); + if (envp != NULL) + { + p = envp; + while (*p != NULL) + envlen += strlen (*p++) + 1; + env = __alloca (envlen); + ap = env; + for (p = envp; *p != NULL; ++p) + ap = __memccpy (ap, *p, '\0', ULONG_MAX); + } + else + env = NULL; /* Load up the ports to give to the new program. */ for (i = 0; i < _hurd_nports; ++i) - ports[i] = _hurd_port_get (&_hurd_ports[i], &dealloc_ports[i]); + if (i == INIT_PORT_PROC && task != __mach_task_self ()) + { + /* This is another task, so we need to ask the proc server + for the right proc server port for it. */ + if (err = __USEPORT (PROC, __proc_task2proc (port, task, &ports[i]))) + { + while (--i > 0) + _hurd_port_free (&_hurd_ports[i], &ulink_ports[i], ports[i]); + return err; + } + } + else + ports[i] = _hurd_port_get (&_hurd_ports[i], &ulink_ports[i]); + /* Load up the ints to give the new program. */ for (i = 0; i < INIT_INT_MAX; ++i) @@ -85,7 +114,7 @@ ints[i] = 0; } - ss = _hurd_thread_sigstate (__mach_thread_self ()); + ss = _hurd_self_sigstate (); ints[INIT_SIGMASK] = ss->blocked; ints[INIT_SIGPENDING] = ss->pending; ints[INIT_SIGIGN] = 0; @@ -97,23 +126,59 @@ can arrive between when we pack the blocked and ignored signals, and when the exec actually happens. A signal handler could change what signals are blocked and ignored. Either the change will be reflected - in the exec, or the signal will never be delivered. */ + in the exec, or the signal will never be delivered. Setting the + critical section flag avoids anything we call trying to acquire the + sigstate lock. */ + ss->critical_section = 1; + /* Pack up the descriptor table to give the new program. */ __mutex_lock (&_hurd_dtable_lock); - if (_hurd_dtable.d != NULL) + + dtablesize = _hurd_dtable ? _hurd_dtablesize : _hurd_init_dtablesize; + + if (task == __mach_task_self ()) + /* Request the exec server to deallocate some ports from us if the exec + succeeds. The init ports and descriptor ports will arrive in the + new program's exec_startup message. If we failed to deallocate + them, the new program would have duplicate user references for them. + But we cannot deallocate them ourselves, because we must still have + them after a failed exec call. */ + please_dealloc = __alloca ((_hurd_nports + (2 * dtablesize)) + * sizeof (mach_port_t)); + else + please_dealloc = NULL; + pdp = please_dealloc; + + if (_hurd_dtable != NULL) { - dtablesize = _hurd_dtable.size; dtable = __alloca (dtablesize * sizeof (dtable[0])); - dealloc_dtable = __alloca (dtablesize * sizeof (dealloc_dtable[0])); - dtable_cells = __alloca (dtablesize * sizeof (dealloc_cells[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.d[i]; + struct hurd_fd *const d = _hurd_dtable[i]; + if (d == NULL) + { + dtable[i] = MACH_PORT_NULL; + continue; + } __spin_lock (&d->port.lock); if (d->flags & FD_CLOEXEC) { + /* This descriptor is marked to be closed on exec. + So don't pass it to the new program. */ dtable[i] = MACH_PORT_NULL; + if (pdp && d->port.port != MACH_PORT_NULL) + { + /* We still need to deallocate the ports. */ + *pdp++ = d->port.port; + if (d->ctty.port != MACH_PORT_NULL) + *pdp++ = d->ctty.port; + } __spin_unlock (&d->port.lock); } else @@ -120,15 +185,21 @@ { /* 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, &dealloc_dtable[i]); + dtable[i] = _hurd_port_get (&d->ctty, &ulink_dtable[i]); if (dtable[i] == MACH_PORT_NULL) { dtable[i] = _hurd_port_locked_get (&d->port, - &dealloc_dtable[i]); + &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; } @@ -138,51 +209,57 @@ else { dtable = _hurd_init_dtable; - dtablesize = _hurd_init_dtablesize; - dealloc_dtable = NULL; - dealloc_cells = NULL; + ulink_dtable = NULL; + dtable_cells = NULL; } /* The information is all set up now. Try to exec the file. */ { - mach_port_t please_dealloc[_hurd_nports + dtablesize]; - mach_port_t *p = please_dealloc; - - /* Request the exec server to deallocate some ports from us if the exec - succeeds. The init ports and descriptor ports will arrive in the - new program's exec_startup message. If we failed to deallocate - them, the new program would have duplicate user references for them. - But we cannot deallocate them ourselves, because we must still have - them after a failed exec call. */ - - for (i = 0; i < _hurd_nports; ++i) - *p++ = ports[i]; - for (i = 0; i < dtablesize; ++i) - *p++ = dtable[i]; + if (pdp) + { + /* Request the exec server to deallocate some ports from us if the exec + succeeds. The init ports and descriptor ports will arrive in the + new program's exec_startup message. If we failed to deallocate + them, the new program would have duplicate user references for them. + But we cannot deallocate them ourselves, because we must still have + them after a failed exec call. */ + + for (i = 0; i < _hurd_nports; ++i) + *pdp++ = ports[i]; + for (i = 0; i < dtablesize; ++i) + *pdp++ = dtable[i]; + } - err = __file_exec (file, __mach_task_self (), - 0, + err = __file_exec (file, task, + 0, /* No particular flags. */ args, argslen, env, envlen, - dtable, dtablesize, MACH_MSG_TYPE_COPY_SEND, - ports, _hurd_nports, MACH_MSG_TYPE_COPY_SEND, + dtable, MACH_MSG_TYPE_COPY_SEND, dtablesize, + ports, MACH_MSG_TYPE_COPY_SEND, _hurd_nports, ints, INIT_INT_MAX, - please_dealloc, p - please_dealloc, + please_dealloc, pdp - please_dealloc, NULL, 0); } - /* Safe to let signals happen now. */ - __mutex_unlock (&ss->lock); - /* Release references to the standard ports. */ for (i = 0; i < _hurd_nports; ++i) - _hurd_port_free (&_hurd_ports[i], &dealloc_ports[i], ports[i]); + if (i == INIT_PORT_PROC && task != __mach_task_self ()) + __mach_port_deallocate (__mach_task_self (), ports[i]); + else + _hurd_port_free (&_hurd_ports[i], &ulink_ports[i], ports[i]); - if (dealloc_dtable != NULL) + if (ulink_dtable != NULL) /* Release references to the file descriptor ports. */ for (i = 0; i < dtablesize; ++i) if (dtable[i] != MACH_PORT_NULL) - _hurd_port_free (dtable_cells[i], &dealloc_dtable[i], dtable[i]); + _hurd_port_free (dtable_cells[i], &ulink_dtable[i], dtable[i]); + + /* Release lock on the file descriptor table. */ + __mutex_unlock (&_hurd_dtable_lock); + + /* Safe to let signals happen now. */ + ss->critical_section = 0; + __mutex_unlock (&ss->lock); return err; } diff -ruN glibc-1.07/hurd/hurdid.c glibc-1.08.1/hurd/hurdid.c --- glibc-1.07/hurd/hurdid.c Thu Oct 28 23:08:03 1993 +++ glibc-1.08.1/hurd/hurdid.c Mon Apr 4 23:00:32 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 @@ -17,21 +17,12 @@ Cambridge, MA 02139, USA. */ #include +#include #include -struct _hurd_id_data _hurd_id; +struct hurd_id_data _hurd_id /* = { lock: MUTEX_INITIALIZER } */; -static void -init_id (void) -{ -#ifdef noteven - __mutex_init (&_hurd_id.lock); -#endif - _hurd_id.valid = 0; -} -text_set_element (__libc_subinit, init_id); - /* Check that _hurd_id.{gen,aux} are valid and update them if not. Expects _hurd_id.lock to be held and does not release it. */ diff -ruN glibc-1.07/hurd/hurdinit.c glibc-1.08.1/hurd/hurdinit.c --- glibc-1.07/hurd/hurdinit.c Sun Nov 7 08:31:07 1993 +++ glibc-1.08.1/hurd/hurdinit.c Wed May 25 22:15:10 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 @@ -16,19 +16,24 @@ not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include #include #include #include #include +#include +#include +#include "set-hooks.h" +#include "hurdmalloc.h" /* XXX */ -struct _hurd_port *_hurd_ports; +struct hurd_port *_hurd_ports; unsigned int _hurd_nports; mode_t _hurd_umask; void _hurd_proc_init (char **argv); +DEFINE_HOOK (_hurd_subinit, (void)); + /* Initialize the library data structures from the ints and ports passed to us by the exec server. @@ -48,25 +53,16 @@ /* See what ports we were passed. */ for (i = 0; i < portarraysize; ++i) - { - _hurd_port_init (&_hurd_ports[i], portarray[i]); + _hurd_port_init (&_hurd_ports[i], portarray[i]); - switch (i) - { - case INIT_PORT_PROC: - /* Tell the proc server we exist, if it does. */ - if (portarray[i] != MACH_PORT_NULL) - _hurd_proc_init (argv); - break; - - case INIT_PORT_BOOTSTRAP: - /* When the user asks for the bootstrap port, - he will get the one the exec server passed us. */ - __task_set_special_port (__mach_task_self (), - TASK_BOOTSTRAP_PORT, portarray[i]); - break; - } - } + /* When the user asks for the bootstrap port, + he will get the one the exec server passed us. */ + __task_set_special_port (__mach_task_self (), TASK_BOOTSTRAP_PORT, + portarray[INIT_PORT_BOOTSTRAP]); + + /* Tell the proc server we exist, if it does. */ + if (portarray[INIT_PORT_PROC] != MACH_PORT_NULL) + _hurd_proc_init (argv); if (intarraysize > INIT_UMASK) _hurd_umask = intarray[INIT_UMASK] & 0777; @@ -86,12 +82,23 @@ which the library uses and could be security holes. CORESERVER, COREFILE */ ; + + /* Call other things which want to do some initialization. These are not + on the __libc_subinit hook because things there like to be able to + assume the availability of the POSIX.1 services we provide. */ + RUN_HOOK (_hurd_subinit, ()); } +#include + /* The user can do "int _hide_arguments = 1;" to make sure the arguments are never visible with `ps'. */ int _hide_arguments, _hide_environment; +/* Hook for things which should be initialized as soon as the proc + server is available. */ +DEFINE_HOOK (_hurd_proc_subinit, (void)); + /* Do startup handshaking with the proc server just installed in _hurd_ports. Call _hurdsig_init to set up signal processing. */ @@ -99,28 +106,22 @@ _hurd_proc_init (char **argv) { mach_port_t oldmsg; - int dealloc; + struct hurd_userlink ulink; process_t procserver; -#ifdef notyet - /* Initialize the signal code; Mach exceptions will become signals. - This function will be a no-op on calls after the first. - On the first call, it sets up the message port and the signal thread. */ + /* Initialize the signal code; Mach exceptions will become signals. */ _hurdsig_init (); -#endif /* The signal thread is now prepared to receive messages. It is safe to give the port to the proc server. */ - procserver = _hurd_port_get (&_hurd_ports[INIT_PORT_PROC], &dealloc); + procserver = _hurd_port_get (&_hurd_ports[INIT_PORT_PROC], &ulink); -#ifdef notyet /* Give the proc server our message port. */ __proc_setmsgport (procserver, _hurd_msgport, &oldmsg); if (oldmsg != MACH_PORT_NULL) /* Deallocate the old msg port we replaced. */ __mach_port_deallocate (__mach_task_self (), oldmsg); -#endif /* Tell the proc server where our args and environment are. */ __proc_setprocargs (procserver, @@ -127,10 +128,13 @@ _hide_arguments ? 0 : (vm_address_t) argv, _hide_environment ? 0 : (vm_address_t) __environ); - _hurd_port_free (&_hurd_ports[INIT_PORT_PROC], &dealloc, procserver); + _hurd_port_free (&_hurd_ports[INIT_PORT_PROC], &ulink, procserver); -#ifdef notyet /* Initialize proc server-assisted fault recovery for the signal thread. */ _hurdsig_fault_init (); -#endif + + /* Call other things which want to do some initialization. These are not + on the _hurd_subinit hook because things there assume that things done + here, like _hurd_pid, are already initialized. */ + RUN_HOOK (_hurd_proc_subinit, ()); } diff -ruN glibc-1.07/hurd/hurdioctl.c glibc-1.08.1/hurd/hurdioctl.c --- glibc-1.07/hurd/hurdioctl.c +++ glibc-1.08.1/hurd/hurdioctl.c Sat May 21 20:20:38 1994 @@ -0,0 +1,219 @@ +/* ioctl commands which must be done in the C library. +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 + +/* 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 + { + size_t n; + struct ioctl_handler *v[0]; + } _hurd_ioctl_handler_lists; + +#include + +/* Find out how many bytes may be read from FD without blocking. */ + +static int +fioctl (int fd, + int request, + int *arg) +{ + error_t err; + + *(volatile int *) arg = *arg; + + switch (request) + { + default: + err = EGRATUITOUS; + break; + + case FIONREAD: + err = HURD_DPORT_USE (fd, __io_readable (port, arg)); + break; + + case FIONBIO: + err = HURD_DPORT_USE (fd, (*arg ? + __io_set_some_openmodes : + __io_clear_some_openmodes) + (port, O_NONBLOCK)); + break; + + case FIOASYNC: + err = HURD_DPORT_USE (fd, (*arg ? + __io_set_some_openmodes : + __io_clear_some_openmodes) + (port, O_ASYNC)); + break; + + case FIOSETOWN: + err = HURD_DPORT_USE (fd, __io_mod_owner (port, *arg)); + break; + + case FIOGETOWN: + err = HURD_DPORT_USE (fd, __io_get_owner (port, arg)); + break; + } + + return err ? __hurd_fail (err) : 0; +} + +_HURD_HANDLE_IOCTLS (fioctl, FIOGETOWN, FIONREAD); + + +static int +fioclex (int fd, + int request) +{ + int flag; + + switch (request) + { + default: + return __hurd_fail (EGRATUITOUS); + case FIOCLEX: + flag = FD_CLOEXEC; + break; + case FIONCLEX: + flag = 0; + break; + } + + return __fcntl (fd, F_SETFD, flag); +} +_HURD_HANDLE_IOCTLS (fioclex, FIOCLEX, FIONCLEX); + +#include + +static void +rectty_dtable (mach_port_t cttyid) +{ + int i; + + HURD_CRITICAL_BEGIN; + __mutex_lock (&_hurd_dtable_lock); + + for (i = 0; i < _hurd_dtablesize; ++i) + { + struct hurd_fd *const d = _hurd_dtable[i]; + mach_port_t newctty; + + if (d == NULL) + /* Nothing to do for an unused descriptor cell. */ + continue; + + if (cttyid == MACH_PORT_NULL) + /* We now have no controlling tty at all. */ + newctty = MACH_PORT_NULL; + else + HURD_PORT_USE (&d->port, + ({ mach_port_t id; + /* Get the io object's cttyid port. */ + if (! __term_getctty (port, &id)) + { + if (id == cttyid && /* Is it ours? */ + /* Get the ctty io port. */ + __term_become_ctty (port, _hurd_pid, + _hurd_pgrp, + _hurd_msgport, + &newctty)) + /* XXX it is our ctty but the call failed? */ + newctty = MACH_PORT_NULL; + __mach_port_deallocate + (__mach_task_self (), (mach_port_t) id); + } + else + newctty = MACH_PORT_NULL; + 0; + })); + + /* Install the new ctty port. */ + _hurd_port_set (&d->ctty, newctty); + } + + __mutex_unlock (&_hurd_dtable_lock); + HURD_CRITICAL_END; +} + + +/* Make FD be the controlling terminal. + This function is called for `ioctl (fd, TCIOSCTTY)'. */ + +static int +tiocsctty (int fd, + int request) /* Always TIOCSCTTY. */ +{ + mach_port_t cttyid; + error_t err; + + /* Get FD's cttyid port, unless it is already ours. */ + err = HURD_DPORT_USE (fd, + ctty ? EADDRINUSE : __term_getctty (port, &cttyid)); + if (err == EADDRINUSE) + /* FD is already the ctty. Nothing to do. */ + return 0; + else if (err) + return __hurd_fail (err); + + /* Make it our own. */ + _hurd_port_set (&_hurd_ports[INIT_PORT_CTTYID], cttyid); /* Consumes ref. */ + + /* Reset all the ctty ports in all the descriptors. */ + __USEPORT (CTTYID, (rectty_dtable (port), 0)); + + return 0; +} +_HURD_HANDLE_IOCTL (tiocsctty, TIOCSCTTY); + +/* Dissociate from the controlling terminal. */ + +static int +tiocnotty (int fd, + int request) /* Always TIOCNOTTY. */ +{ + mach_port_t fd_cttyid; + error_t err; + + if (err = HURD_DPORT_USE (fd, __term_getctty (port, &fd_cttyid))) + return __hurd_fail (err); + + if (__USEPORT (CTTYID, port != fd_cttyid)) + err = EINVAL; + + __mach_port_deallocate (__mach_task_self (), fd_cttyid); + + if (err) + return __hurd_fail (err); + + /* Clear our cttyid port cell. */ + _hurd_port_set (&_hurd_ports[INIT_PORT_CTTYID], MACH_PORT_NULL); + + /* Reset all the ctty ports in all the descriptors. */ + + __USEPORT (CTTYID, (rectty_dtable (MACH_PORT_NULL), 0)); + + return 0; +} +_HURD_HANDLE_IOCTL (tiocnotty, TIOCNOTTY); diff -ruN glibc-1.07/hurd/hurdmalloc.c glibc-1.08.1/hurd/hurdmalloc.c --- glibc-1.07/hurd/hurdmalloc.c +++ glibc-1.08.1/hurd/hurdmalloc.c Fri Jun 3 21:48:44 1994 @@ -0,0 +1,383 @@ +#include +#include "hurdmalloc.h" /* XXX see that file */ + +#include +text_set_element (_hurd_fork_prepare_hook, malloc_fork_prepare); +text_set_element (_hurd_fork_parent_hook, malloc_fork_parent); +text_set_element (_hurd_fork_child_hook, malloc_fork_child); +text_set_element (_hurd_preinit_hook, malloc_init); + + +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989 Carnegie Mellon University + * All Rights Reserved. + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie Mellon + * the rights to redistribute these changes. + */ +/* + * HISTORY + * $Log: malloc.c,v $ + * Revision 2.7 91/05/14 17:57:34 mrt + * Correcting copyright + * + * Revision 2.6 91/02/14 14:20:26 mrt + * Added new Mach copyright + * [91/02/13 12:41:21 mrt] + * + * Revision 2.5 90/11/05 14:37:33 rpd + * Added malloc_fork* code. + * [90/11/02 rwd] + * + * Add spin_lock_t. + * [90/10/31 rwd] + * + * Revision 2.4 90/08/07 14:31:28 rpd + * Removed RCS keyword nonsense. + * + * Revision 2.3 90/06/02 15:14:00 rpd + * Converted to new IPC. + * [90/03/20 20:56:57 rpd] + * + * Revision 2.2 89/12/08 19:53:59 rwd + * Removed conditionals. + * [89/10/23 rwd] + * + * Revision 2.1 89/08/03 17:09:46 rwd + * Created. + * + * + * 13-Sep-88 Eric Cooper (ecc) at Carnegie Mellon University + * Changed realloc() to copy min(old size, new size) bytes. + * Bug found by Mike Kupfer at Olivetti. + */ +/* + * File: malloc.c + * Author: Eric Cooper, Carnegie Mellon University + * Date: July, 1988 + * + * Memory allocator for use with multiple threads. + */ + + +#include +#include "cthread_internals.h" + +/* + * C library imports: + */ +extern bcopy(); + +/* + * Structure of memory block header. + * When free, next points to next block on free list. + * When allocated, fl points to free list. + * Size of header is 4 bytes, so minimum usable block size is 8 bytes. + */ +typedef union header { + union header *next; + struct free_list *fl; +} *header_t; + +#define MIN_SIZE 8 /* minimum block size */ + +typedef struct free_list { + spin_lock_t lock; /* spin lock for mutual exclusion */ + header_t head; /* head of free list for this size */ +#ifdef DEBUG + int in_use; /* # mallocs - # frees */ +#endif DEBUG +} *free_list_t; + +/* + * Free list with index i contains blocks of size 2^(i+3) including header. + * Smallest block size is 8, with 4 bytes available to user. + * Size argument to malloc is a signed integer for sanity checking, + * so largest block size is 2^31. + */ +#define NBUCKETS 29 + +static struct free_list malloc_free_list[NBUCKETS]; + +/* Initialization just sets everything to zero, but might be necessary on a + machine where spin_lock_init does otherwise, and is necessary when + running an executable that was written by something like Emacs's unexec. + It preserves the values of data variables like malloc_free_list, but + does not save the vm_allocate'd space allocated by this malloc. */ + +static void +malloc_init (void) +{ + int i; + for (i = 0; i < NBUCKETS; ++i) + { + spin_lock_init (&malloc_free_list[i].lock); + malloc_free_list[i].head = NULL; +#ifdef DEBUG + malloc_free_list[i].in_use = 0; +#endif + } +} + +static void +more_memory(size, fl) + int size; + register free_list_t fl; +{ + register int amount; + register int n; + vm_address_t where; + register header_t h; + kern_return_t r; + + if (size <= vm_page_size) { + amount = vm_page_size; + n = vm_page_size / size; + /* + * We lose vm_page_size - n*size bytes here. */ + } else { + amount = size; + n = 1; + } + MACH_CALL(vm_allocate(mach_task_self(), &where, (vm_size_t) amount, TRUE), r); + h = (header_t) where; + do { + h->next = fl->head; + fl->head = h; + h = (header_t) ((char *) h + size); + } while (--n != 0); +} + +/* Declaration changed to standard one for GNU. */ +void * +malloc(size) + register size_t size; +{ + register int i, n; + register free_list_t fl; + register header_t h; + + if ((int) size < 0) /* sanity check */ + return 0; + size += sizeof(union header); + /* + * Find smallest power-of-two block size + * big enough to hold requested size plus header. + */ + i = 0; + n = MIN_SIZE; + while (n < size) { + i += 1; + n <<= 1; + } + ASSERT(i < NBUCKETS); + fl = &malloc_free_list[i]; + spin_lock(&fl->lock); + h = fl->head; + if (h == 0) { + /* + * Free list is empty; + * allocate more blocks. + */ + more_memory(n, fl); + h = fl->head; + if (h == 0) { + /* + * Allocation failed. + */ + spin_unlock(&fl->lock); + return 0; + } + } + /* + * Pop block from free list. + */ + fl->head = h->next; +#ifdef DEBUG + fl->in_use += 1; +#endif DEBUG + spin_unlock(&fl->lock); + /* + * Store free list pointer in block header + * so we can figure out where it goes + * at free() time. + */ + h->fl = fl; + /* + * Return pointer past the block header. + */ + return ((char *) h) + sizeof(union header); +} + +/* Declaration changed to standard one for GNU. */ +void +free(base) + void *base; +{ + register header_t h; + register free_list_t fl; + register int i; + + if (base == 0) + return; + /* + * Find free list for block. + */ + h = (header_t) (base - sizeof(union header)); + fl = h->fl; + i = fl - malloc_free_list; + /* + * Sanity checks. + */ + if (i < 0 || i >= NBUCKETS) { + ASSERT(0 <= i && i < NBUCKETS); + return; + } + if (fl != &malloc_free_list[i]) { + ASSERT(fl == &malloc_free_list[i]); + return; + } + /* + * Push block on free list. + */ + spin_lock(&fl->lock); + h->next = fl->head; + fl->head = h; +#ifdef DEBUG + fl->in_use -= 1; +#endif DEBUG + spin_unlock(&fl->lock); + return; +} + +/* Declaration changed to standard one for GNU. */ +void * +realloc(old_base, new_size) + void *old_base; + size_t new_size; +{ + register header_t h; + register free_list_t fl; + register int i; + unsigned int old_size; + char *new_base; + + if (old_base == 0) + return malloc (new_size); + + /* + * Find size of old block. + */ + h = (header_t) (old_base - sizeof(union header)); + fl = h->fl; + i = fl - malloc_free_list; + /* + * Sanity checks. + */ + if (i < 0 || i >= NBUCKETS) { + ASSERT(0 <= i && i < NBUCKETS); + return 0; + } + if (fl != &malloc_free_list[i]) { + ASSERT(fl == &malloc_free_list[i]); + return 0; + } + /* + * Free list with index i contains blocks of size 2^(i+3) including header. + */ + old_size = (1 << (i+3)) - sizeof(union header); + /* + * Allocate new block, copy old bytes, and free old block. + */ + new_base = malloc(new_size); + if (new_base != 0) + bcopy(old_base, new_base, (int) (old_size < new_size ? old_size : new_size)); + free(old_base); + return new_base; +} + +#ifdef DEBUG +void +print_malloc_free_list() +{ + register int i, size; + register free_list_t fl; + register int n; + register header_t h; + int total_used = 0; + int total_free = 0; + + fprintf(stderr, " Size In Use Free Total\n"); + for (i = 0, size = MIN_SIZE, fl = malloc_free_list; + i < NBUCKETS; + i += 1, size <<= 1, fl += 1) { + spin_lock(&fl->lock); + if (fl->in_use != 0 || fl->head != 0) { + total_used += fl->in_use * size; + for (n = 0, h = fl->head; h != 0; h = h->next, n += 1) + ; + total_free += n * size; + fprintf(stderr, "%10d %10d %10d %10d\n", + size, fl->in_use, n, fl->in_use + n); + } + spin_unlock(&fl->lock); + } + fprintf(stderr, " all sizes %10d %10d %10d\n", + total_used, total_free, total_used + total_free); +} +#endif DEBUG + +static void malloc_fork_prepare() +/* + * Prepare the malloc module for a fork by insuring that no thread is in a + * malloc critical section. + */ +{ + register int i; + + for (i = 0; i < NBUCKETS; i++) { + spin_lock(&malloc_free_list[i].lock); + } +} + +static void malloc_fork_parent() +/* + * Called in the parent process after a fork() to resume normal operation. + */ +{ + register int i; + + for (i = NBUCKETS-1; i >= 0; i--) { + spin_unlock(&malloc_free_list[i].lock); + } +} + +static void malloc_fork_child() +/* + * Called in the child process after a fork() to resume normal operation. + */ +{ + register int i; + + for (i = NBUCKETS-1; i >= 0; i--) { + spin_unlock(&malloc_free_list[i].lock); + } +} diff -ruN glibc-1.07/hurd/hurdmalloc.h glibc-1.08.1/hurd/hurdmalloc.h --- glibc-1.07/hurd/hurdmalloc.h +++ glibc-1.08.1/hurd/hurdmalloc.h Wed May 25 22:22:49 1994 @@ -0,0 +1,17 @@ +/* XXX this file is a tempoary hack. + + All hurd-internal code which uses malloc et al includes this file so it + will use the internal malloc routines _hurd_{malloc,realloc,free} + instead. The "hurd-internal" functions are the cthreads version, + which uses vm_allocate and is thread-safe. The normal user version + of malloc et al is the unixoid one using sbrk. + + */ + +extern void *_hurd_malloc (size_t); +extern void *_hurd_realloc (void *, size_t); +extern void _hurd_free (void *); + +#define malloc _hurd_malloc +#define realloc _hurd_realloc +#define free _hurd_free diff -ruN glibc-1.07/hurd/hurdpath.c glibc-1.08.1/hurd/hurdpath.c --- glibc-1.07/hurd/hurdpath.c Mon Dec 13 19:23:02 1993 +++ glibc-1.08.1/hurd/hurdpath.c Tue Apr 19 20:52:36 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 @@ -82,8 +82,8 @@ /* Fall through. */ case FS_RETRY_NORMAL: -#ifdef SYMLINK_MAX - if (nloops++ >= SYMLINK_MAX) +#ifdef SYMLOOP_MAX + if (nloops++ >= SYMLOOP_MAX) return ELOOP; #endif @@ -115,6 +115,7 @@ file_t *dir, char **name) { const char *lastslash; + error_t err; /* Skip leading slashes in the pathname. */ if (*path == '/') @@ -132,8 +133,9 @@ { /* "/foobar" => crdir + "foobar". */ *name = (char *) path + 1; - __mach_port_mod_refs (__mach_task_self (), MACH_PORT_RIGHT_SEND, - crdir, +1); + if (err = __mach_port_mod_refs (__mach_task_self (), + crdir, MACH_PORT_RIGHT_SEND, +1)) + return err; *dir = crdir; return 0; } @@ -151,8 +153,9 @@ { /* "foobar" => cwdir + "foobar". */ *name = (char *) path; - __mach_port_mod_refs (__mach_task_self (), MACH_PORT_RIGHT_SEND, - cwdir, 1); + if (err = __mach_port_mod_refs (__mach_task_self (), + cwdir, MACH_PORT_RIGHT_SEND, +1)) + return err; *dir = cwdir; return 0; } @@ -163,15 +166,15 @@ { error_t err; file_t result, crdir, cwdir; - int dealloc_crdir, dealloc_cwdir; + struct hurd_userlink crdir_ulink, cwdir_ulink; - crdir = _hurd_port_get (&_hurd_ports[INIT_PORT_CRDIR], &dealloc_crdir); - cwdir = _hurd_port_get (&_hurd_ports[INIT_PORT_CWDIR], &dealloc_cwdir); + 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], &dealloc_crdir, crdir); - _hurd_port_free (&_hurd_ports[INIT_PORT_CWDIR], &dealloc_cwdir, cwdir); + _hurd_port_free (&_hurd_ports[INIT_PORT_CRDIR], &crdir_ulink, crdir); + _hurd_port_free (&_hurd_ports[INIT_PORT_CWDIR], &cwdir_ulink, cwdir); if (err) { @@ -187,15 +190,15 @@ { error_t err; file_t dir, crdir, cwdir; - int dealloc_crdir, dealloc_cwdir; + struct hurd_userlink crdir_ulink, cwdir_ulink; - crdir = _hurd_port_get (&_hurd_ports[INIT_PORT_CRDIR], &dealloc_crdir); - cwdir = _hurd_port_get (&_hurd_ports[INIT_PORT_CWDIR], &dealloc_cwdir); + 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], &dealloc_crdir, crdir); - _hurd_port_free (&_hurd_ports[INIT_PORT_CWDIR], &dealloc_cwdir, cwdir); + _hurd_port_free (&_hurd_ports[INIT_PORT_CRDIR], &crdir_ulink, crdir); + _hurd_port_free (&_hurd_ports[INIT_PORT_CWDIR], &cwdir_ulink, cwdir); if (err) { diff -ruN glibc-1.07/hurd/hurdpid.c glibc-1.08.1/hurd/hurdpid.c --- glibc-1.07/hurd/hurdpid.c Wed Nov 3 11:13:45 1993 +++ glibc-1.08.1/hurd/hurdpid.c Sat Jun 4 08:54:03 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 @@ -19,9 +19,6 @@ #include #include -#if 0 -struct mutex _hurd_pid_lock; -#endif pid_t _hurd_pid, _hurd_ppid, _hurd_pgrp; int _hurd_orphaned; @@ -28,10 +25,6 @@ static void init_pids (void) { -#if 0 - __mutex_init (&_hurd_pid_lock); -#endif - __USEPORT (PROC, ({ __proc_getpids (port, &_hurd_pid, &_hurd_ppid, &_hurd_orphaned); @@ -39,11 +32,14 @@ })); } -text_set_element (__libc_subinit, init_pids); +text_set_element (_hurd_proc_subinit, init_pids); -#include "hurd/msg_server.h" +#include +#include "set-hooks.h" -error_t +DEFINE_HOOK (_hurd_pgrp_changed_hook, (pid_t)); + +kern_return_t _S_proc_newids (mach_port_t me, task_t task, pid_t ppid, pid_t pgrp, int orphaned) @@ -53,11 +49,12 @@ __mach_port_deallocate (__mach_task_self (), task); - __mutex_lock (&_hurd_pid_lock); _hurd_ppid = ppid; _hurd_pgrp = pgrp; _hurd_orphaned = orphaned; - __mutex_unlock (&_hurd_pid_lock); + + /* Run things that want notification of a pgrp change. */ + RUN_HOOK (_hurd_pgrp_changed_hook, (_hurd_pgrp)); return 0; } diff -ruN glibc-1.07/hurd/hurdports.c glibc-1.08.1/hurd/hurdports.c --- glibc-1.07/hurd/hurdports.c Wed Jun 23 16:22:04 1993 +++ glibc-1.08.1/hurd/hurdports.c Thu Feb 3 21:07:46 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 @@ -17,16 +17,17 @@ Cambridge, MA 02139, USA. */ #include +#include static inline mach_port_t get (const size_t 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_PORT_USE (&_hurd_ports[idx], + __mach_port_mod_refs (__mach_task_self (), + (result = port), + MACH_PORT_RIGHT_SEND, + 1)); if (err) { errno = err; diff -ruN glibc-1.07/hurd/hurdrlimit.c glibc-1.08.1/hurd/hurdrlimit.c --- glibc-1.07/hurd/hurdrlimit.c +++ glibc-1.08.1/hurd/hurdrlimit.c Sat Jun 4 00:44:42 1994 @@ -0,0 +1,51 @@ +/* Resource limits. +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 + +/* 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}; + +/* 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 + mutex_init is still required below just in case of unexec. */ +struct mutex _hurd_rlimit_lock = { SPIN_LOCK_INITIALIZER, }; + +static void +init_rlimit (void) +{ + int i; + + __mutex_init (&_hurd_rlimit_lock); + + for (i = 0; i < RLIM_NLIMITS; ++i) + { + if (_hurd_rlimits[i].rlim_max == 0) + _hurd_rlimits[i].rlim_max = RLIM_INFINITY; + if (_hurd_rlimits[i].rlim_cur == 0) + _hurd_rlimits[i].rlim_cur = _hurd_rlimits[i].rlim_max; + } + + (void) &init_rlimit; +} +text_set_element (_hurd_preinit_hook, init_rlimit); diff -ruN glibc-1.07/hurd/hurdsig.c glibc-1.08.1/hurd/hurdsig.c --- glibc-1.07/hurd/hurdsig.c +++ glibc-1.08.1/hurd/hurdsig.c Sat Jun 4 08:52:54 1994 @@ -0,0 +1,764 @@ +/* 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 /* For `struct mutex'. */ +#include +#include "hurdmalloc.h" /* XXX */ + +struct mutex _hurd_siglock = MUTEX_INITIALIZER; +int _hurd_stopped; + +/* Port that receives signals and other miscellaneous messages. */ +mach_port_t _hurd_msgport; + +/* Thread listening on it. */ +thread_t _hurd_msgport_thread; + +/* Thread which receives task-global signals. */ +thread_t _hurd_sigthread; + +/* Linked-list of per-thread signal state. */ +struct hurd_sigstate *_hurd_sigstates; + +struct hurd_sigstate * +_hurd_thread_sigstate (thread_t thread) +{ + struct hurd_sigstate *ss; + __mutex_lock (&_hurd_siglock); + for (ss = _hurd_sigstates; ss != NULL; ss = ss->next) + if (ss->thread == thread) + break; + if (ss == NULL) + { + 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); + ss->next = _hurd_sigstates; + _hurd_sigstates = ss; + } + __mutex_lock (&ss->lock); + __mutex_unlock (&_hurd_siglock); + return ss; +} + +#include +#include +#include +#include +#include +#include +#include "thread_state.h" +#include +#include /* For __sig_post_reply. */ + +jmp_buf _hurd_sigthread_fault_env; + +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) +{ + error_t err; + volatile mach_port_t coreserver; + volatile file_t file; + char *volatile name; + char *volatile target; + + /* XXX RLIMIT_CORE */ + + coreserver = MACH_PORT_NULL; + if (!setjmp (_hurd_sigthread_fault_env)) + { + name = getenv ("CORESERVER"); + if (name != NULL) + coreserver = __path_lookup (name, 0, 0); + } + + if (coreserver == MACH_PORT_NULL) + coreserver = __path_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) + 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); + } + + err = __core_dump_task (coreserver, + __mach_task_self (), + file, + signo, sigcode, + target); + __mach_port_deallocate (__mach_task_self (), coreserver); + __mach_port_deallocate (__mach_task_self (), file); + if (err) + (void) remove (name); + 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. */ +static inline void +abort_rpcs (struct hurd_sigstate *ss, int signo, void *state) +{ + 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. */ + + 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; + } + + /* 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. */ + } +} + +/* 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) +{ + thread_t me = __mach_thread_self (); + thread_t *threads; + mach_msg_type_number_t nthreads, i; + + __task_threads (__mach_task_self (), &threads, &nthreads); + for (i = 0; i < nthreads; ++i) + { + 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]); + } +} + + +struct hurd_signal_preempt *_hurd_signal_preempt[NSIG]; +struct mutex _hurd_signal_preempt_lock; + + +/* 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. */ + +static mach_port_t +interrupted_reply_port (struct machine_thread_state *thread_state) +{ + mach_port_t port, *portloc; + + if (setjmp (_hurd_sigthread_fault_env)) + /* Faulted trying to read the stack. */ + return MACH_PORT_NULL; + + portloc = (mach_port_t *) __hurd_threadvar_location_from_sp + (_HURD_THREADVAR_MIG_REPLY, (void *) thread_state->SP); + + port = *portloc; + *portloc = MACH_PORT_NULL; + return port; +} + + +/* 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, + mach_port_t reply_port, + mach_msg_type_name_t reply_port_type) +{ + struct machine_thread_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; + + /* 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; + } + + return 0; + } + + /* Check for a preempted signal. */ + __mutex_lock (&_hurd_signal_preempt_lock); + for (pe = _hurd_signal_preempt[signo]; pe != NULL; pe = pe->next) + if (sigcode >= pe->first && sigcode <= pe->last) + { + preempt = pe->handler; + break; + } + __mutex_unlock (&_hurd_signal_preempt_lock); + + handler = SIG_DFL; + if (preempt) + /* Let the preempting handler examine the thread. + 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; + + 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; + + 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 if (handler == SIG_IGN) + act = ignore; + else + act = handle; + + if (_hurd_orphaned && act == stop && + (signo & (__sigmask (SIGTTIN) | __sigmask (SIGTTOU) | + __sigmask (SIGTSTP)))) + { + /* If we would ordinarily stop for a job control signal, but we are + orphaned so noone would ever notice and continue us again, we just + quietly die, alone and in the dark. */ + sigcode = signo; + signo = SIGKILL; + act = term; + } + + /* Handle receipt of a blocked signal. */ + if ((__sigismember (&ss->blocked, signo) && act != ignore) || + (signo != SIGKILL && _hurd_stopped)) + { + __sigaddset (&ss->pending, signo); + /* Save the code to be given to the handler when SIGNO is unblocked. */ + ss->sigcodes[signo] = sigcode; + act = ignore; + } + + /* Perform the chosen action for the signal. */ + 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) + { + /* 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); + + break; + + case ignore: + /* Nobody cares about this signal. */ + break; + + case term: /* Time to die. */ + case core: /* And leave a rotting corpse. */ + /* Have the proc server stop all other threads in our task. */ + __USEPORT (PROC, __proc_dostop (port, __mach_thread_self ())); + /* 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 */ + + case handle: + /* Call a handler for this signal. */ + { + struct sigcontext *scp; + + /* Stop the thread and abort its pending RPC operations. */ + __thread_suspend (ss->thread); + abort_rpcs (ss, signo, &thread_state); + + /* 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, + signo, sigcode, + &thread_state); + + /* 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); + + /* Block SIGNO and requested signals while running the handler. */ + ss->blocked |= __sigmask (signo) | ss->actions[signo].sa_mask; + + /* Start the thread running the handler. */ + __thread_set_state (ss->thread, MACHINE_THREAD_STATE_FLAVOR, + (int *) &thread_state, MACHINE_THREAD_STATE_COUNT); + __thread_resume (ss->thread); + break; + } + } + + /* The signal has either been ignored or is now being handled. We can + consider it delivered and reply to the killer. The exception is + 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; + } + + /* 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)) + { + /* 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); + } + + /* No pending signals left undelivered for this thread. + If we were sent signal 0, we need to check for pending + signals for all threads. */ + if (signo == 0) + { + __mutex_lock (&_hurd_siglock); + for (ss = _hurd_sigstates; ss != NULL; ss = ss->next) + { + __mutex_lock (&ss->lock); + if (! check_pending (ss)) + __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); +} + +/* Implement the sig_post RPC from ; + sent when someone wants us to get a signal. */ +kern_return_t +_S_sig_post (mach_port_t me, + mach_port_t reply_port, mach_msg_type_name_t reply_port_type, + int signo, + mach_port_t refport) +{ + struct hurd_sigstate *ss; + + if (signo < 0 || signo >= NSIG) + return EINVAL; + + if (refport == __mach_task_self ()) + /* Can send any signal. */ + goto win; + + /* Avoid needing to check for this below. */ + if (refport == MACH_PORT_NULL) + return EPERM; + + switch (signo) + { + case SIGINT: + case SIGQUIT: + case SIGTSTP: + case SIGHUP: + case SIGINFO: + /* Job control signals can be sent by the controlling terminal. */ + if (__USEPORT (CTTYID, port == refport)) + goto win; + break; + + case SIGCONT: + { + /* A continue signal can be sent by anyone in the session. */ + mach_port_t sessport; + if (! __USEPORT (PROC, __proc_getsidport (port, &sessport))) + { + int win = refport == sessport; + __mach_port_deallocate (__mach_task_self (), sessport); + if (win) + goto win; + } + } + break; + + case SIGIO: + case SIGURG: + { + /* Any io object a file descriptor refers to might send us + one of these signals using its async ID port for REFPORT. + + This is pretty wide open; it is not unlikely that some random + process can at least open for reading something we have open, + get its async ID port, and send us a spurious SIGIO or SIGURG + signal. But BSD is actually wider open than that!--you can set + the owner of an io object to any process or process group + whatsoever and send them gratuitous signals. + + Someday we could implement some reasonable scheme for + authorizing SIGIO and SIGURG signals properly. */ + + int d; + __mutex_lock (&_hurd_dtable_lock); + for (d = 0; (unsigned int) d < (unsigned int) _hurd_dtablesize; ++d) + { + struct hurd_userlink ulink; + io_t port; + mach_port_t asyncid; + if (_hurd_dtable[d] == NULL) + continue; + port = _hurd_port_get (&_hurd_dtable[d]->port, &ulink); + if (! __io_get_icky_async_id (port, &asyncid)) + { + if (refport == asyncid) + /* Break out of the loop on the next iteration. */ + d = -1; + __mach_port_deallocate (__mach_task_self (), asyncid); + } + _hurd_port_free (&_hurd_dtable[d]->port, &ulink, port); + } + /* If we found a lucky winner, we've set D to -1 in the loop. */ + if (d < 0) + goto win; + } + } + + /* If this signal is legit, we have done `goto win' by now. + When we return the error, mig deallocates REFPORT. */ + return EPERM; + + win: + /* Deallocate the REFPORT send right; we are done with it. */ + __mach_port_deallocate (__mach_task_self (), refport); + + /* Get a hold of the designated signal-receiving thread. */ + ss = _hurd_thread_sigstate (_hurd_sigthread); + + /* 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); + + return MIG_NO_REPLY; /* Already replied. */ +} + +extern void __mig_init (void *); + +#include + +/* Initialize the message port and _hurd_sigthread and start the signal + thread. */ + +void +_hurdsig_init (void) +{ + error_t err; + vm_size_t stacksize; + + if (err = __mach_port_allocate (__mach_task_self (), + MACH_PORT_RIGHT_RECEIVE, + &_hurd_msgport)) + __libc_fatal ("hurd: Can't create message port receive right\n"); + + /* Make a send right to the signal port. */ + if (err = __mach_port_insert_right (__mach_task_self (), + _hurd_msgport, + _hurd_msgport, + MACH_MSG_TYPE_MAKE_SEND)) + __libc_fatal ("hurd: Can't create send right to message port\n"); + + /* Set the default thread to receive task-global signals + to this one, the main (first) user thread. */ + _hurd_sigthread = __mach_thread_self (); + + /* Start the signal thread listening on the message port. */ + + if (err = __thread_create (__mach_task_self (), &_hurd_msgport_thread)) + __libc_fatal ("hurd: Can't create signal thread\n"); + + stacksize = __vm_page_size * 4; /* Small stack for signal thread. */ + if (err = __mach_setup_thread (__mach_task_self (), _hurd_msgport_thread, + _hurd_msgport_receive, + (vm_address_t *) &__hurd_sigthread_stack_base, + &stacksize)) + __libc_fatal ("hurd: Can't setup signal thread\n"); + + __hurd_sigthread_stack_end = __hurd_sigthread_stack_base + stacksize; + __hurd_sigthread_variables = + malloc (__hurd_threadvar_max * sizeof (unsigned long int)); + if (__hurd_sigthread_variables == NULL) + __libc_fatal ("hurd: Can't allocate thread variables for signal thread\n"); + + /* Reinitialize the MiG support routines so they will use a per-thread + variable for the cached reply port. */ + __mig_init ((void *) __hurd_sigthread_stack_base); + + if (err = __thread_resume (_hurd_msgport_thread)) + __libc_fatal ("hurd: Can't resume signal thread\n"); + +#if 0 /* Don't confuse poor gdb. */ + /* Receive exceptions on the signal port. */ + __task_set_special_port (__mach_task_self (), + 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 */ +static void +reauth_proc (mach_port_t new) +{ + mach_port_t ignore; + + /* Reauthenticate with the proc server. */ + if (! HURD_PORT_USE (&_hurd_ports[INIT_PORT_PROC], + __proc_reauthenticate (port, _hurd_pid) || + __auth_user_authenticate (new, port, _hurd_pid, + &ignore)) + && ignore != MACH_PORT_NULL) + __mach_port_deallocate (__mach_task_self (), ignore); +} +text_set_element (__hurd_reauth_hook, reauth_proc); diff -ruN glibc-1.07/hurd/hurdsock.c glibc-1.08.1/hurd/hurdsock.c --- glibc-1.07/hurd/hurdsock.c +++ glibc-1.08.1/hurd/hurdsock.c Sat Jun 4 03:33:57 1994 @@ -0,0 +1,87 @@ +/* _hurd_socket_server - Find the server for a socket domain. + +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 "stdio/_itoa.h" +#include /* For `struct mutex'. */ +#include "hurdmalloc.h" /* XXX */ + +static struct mutex lock = MUTEX_INITIALIZER; + +static file_t *servers; +static int max_domain; + +/* Return a port to the socket server for DOMAIN. + Socket servers translate nodes in the directory _SERVERS_SOCKET + (canonically /servers/socket). These naming point nodes are named + by the simplest decimal representation of the socket domain number, + for example "/servers/socket/3". + + Socket servers are assumed not to change very often. + The library keeps all the server socket ports it has ever looked up, + and does not look them up in /servers/socket more than once. */ + +socket_t +_hurd_socket_server (int domain) +{ + socket_t server; + + HURD_CRITICAL_BEGIN; + __mutex_lock (&lock); + + if (domain > max_domain) + { + file_t *new = realloc (servers, (domain + 1) * sizeof (file_t)); + if (new == NULL) + { + server = MACH_PORT_NULL; + goto out; + } + while (max_domain < domain) + new[max_domain++] = MACH_PORT_NULL; + servers = new; + } + + { + 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 (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; +} diff -ruN glibc-1.07/hurd/intern-fd.c glibc-1.08.1/hurd/intern-fd.c --- glibc-1.07/hurd/intern-fd.c +++ glibc-1.08.1/hurd/intern-fd.c Thu May 12 01:52:12 1994 @@ -0,0 +1,50 @@ +/* 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 + +/* Allocate a new file descriptor and install PORT in it. FLAGS are as for + `open'; only O_IGNORE_CTTY is meaningful. + + If the descriptor table is full, set errno, and return -1. + If DEALLOC is nonzero, deallocate PORT first. */ +int +_hurd_intern_fd (io_t port, int flags, int dealloc) +{ + int fd; + struct hurd_fd *d; + + HURD_CRITICAL_BEGIN; + d = _hurd_alloc_fd (&fd, 0); + if (d != NULL) + { + _hurd_port2fd (d, port, flags); + __spin_unlock (&d->port.lock); + } + HURD_CRITICAL_END; + + if (d == NULL) + { + if (dealloc) + __mach_port_deallocate (__mach_task_self (), port); + return -1; + } + + return fd; +} diff -ruN glibc-1.07/hurd/msgportdemux.c glibc-1.08.1/hurd/msgportdemux.c --- glibc-1.07/hurd/msgportdemux.c +++ glibc-1.08.1/hurd/msgportdemux.c Tue Apr 26 21:53:32 1994 @@ -0,0 +1,61 @@ +/* Demux messages sent on the signal port. + +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 + +struct demux + { + struct demux *next; + boolean_t (*demux) (mach_msg_header_t *inp, + mach_msg_header_t *outp); + }; + +struct demux *_hurd_msgport_demuxers = NULL; + +extern boolean_t __msg_server (mach_msg_header_t *inp, + mach_msg_header_t *outp); + +static boolean_t +msgport_server (mach_msg_header_t *inp, + mach_msg_header_t *outp) +{ + extern boolean_t _S_msg_server (mach_msg_header_t *inp, + mach_msg_header_t *outp); + extern boolean_t _S_exc_server (mach_msg_header_t *inp, + mach_msg_header_t *outp); + struct demux *d; + + for (d = _hurd_msgport_demuxers; d != NULL; d = d->next) + if ((*d->demux) (inp, outp)) + return 1; + + return (_S_exc_server (inp, outp) || + _S_msg_server (inp, outp)); +} + +/* This is the code that the signal thread runs. */ +void +_hurd_msgport_receive (void) +{ + while (1) + (void) __mach_msg_server (msgport_server, __vm_page_size, _hurd_msgport); +} diff -ruN glibc-1.07/hurd/msgstub.c glibc-1.08.1/hurd/msgstub.c --- glibc-1.07/hurd/msgstub.c +++ glibc-1.08.1/hurd/msgstub.c Thu Apr 21 22:31:41 1994 @@ -0,0 +1,24 @@ +#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.07/hurd/new-fd.c glibc-1.08.1/hurd/new-fd.c --- glibc-1.07/hurd/new-fd.c +++ glibc-1.08.1/hurd/new-fd.c Wed May 25 22:14:47 1994 @@ -0,0 +1,39 @@ +/* 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 "hurdmalloc.h" /* XXX */ + +/* Allocate a new file descriptor structure + and initialize it with PORT and CTTY. */ + +struct hurd_fd * +_hurd_new_fd (io_t port, io_t ctty) +{ + struct hurd_fd *d = malloc (sizeof (struct hurd_fd)); + + if (d != NULL) + { + /* Initialize the port cells. */ + _hurd_port_init (&d->port, port); + _hurd_port_init (&d->ctty, ctty); + } + + return d; +} diff -ruN glibc-1.07/hurd/openport.c glibc-1.08.1/hurd/openport.c --- glibc-1.07/hurd/openport.c Thu Oct 28 22:15:37 1993 +++ glibc-1.08.1/hurd/openport.c Sat Feb 5 20:23:11 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 @@ -17,6 +17,7 @@ Cambridge, MA 02139, USA. */ #include +#include #include /* User entry point for interning a port as a new FD. diff -ruN glibc-1.07/hurd/port2fd.c glibc-1.08.1/hurd/port2fd.c --- glibc-1.07/hurd/port2fd.c +++ glibc-1.08.1/hurd/port2fd.c Tue May 3 23:20:56 1994 @@ -0,0 +1,84 @@ +/* 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 + +/* Store PORT in file descriptor D, doing appropriate ctty magic. + FLAGS are as for `open'; only O_IGNORE_CTTY is meaningful. + D should be locked, and will not be unlocked. */ + +void +_hurd_port2fd (struct hurd_fd *d, io_t port, int flags) +{ + io_t ctty; + mach_port_t cttyid; + int is_ctty = !(flags & O_IGNORE_CTTY) && ! __term_getctty (port, &cttyid); + + if (is_ctty) + { + /* This port is capable of being a controlling tty. + Is it ours? */ + struct hurd_port *const id = &_hurd_ports[INIT_PORT_CTTYID]; + __spin_lock (&id->lock); + if (id->port == MACH_PORT_NULL) + /* We have no controlling tty, so make this one it. */ + _hurd_port_locked_set (id, cttyid); + else + { + if (cttyid != id->port) + /* We have a controlling tty and this is not it. */ + is_ctty = 0; + /* Either we don't want CTTYID, or ID->port already is it. + So we don't need to change ID->port, and we can release + the reference to CTTYID. */ + __spin_unlock (&id->lock); + __mach_port_deallocate (__mach_task_self (), cttyid); + } + } + + 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 + /* 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? */ + /* No ctty magic happening here. */ + ctty = MACH_PORT_NULL; + + /* Install PORT in the descriptor cell, leaving it locked. */ + { + mach_port_t old + = _hurd_userlink_clear (&d->port.users) ? d->port.port : MACH_PORT_NULL; + d->port.port = port; + if (old != MACH_PORT_NULL) + __mach_port_deallocate (__mach_task_self (), old); + } + + _hurd_port_set (&d->ctty, ctty); +} diff -ruN glibc-1.07/hurd/preempt-sig.c glibc-1.08.1/hurd/preempt-sig.c --- glibc-1.07/hurd/preempt-sig.c +++ glibc-1.08.1/hurd/preempt-sig.c Wed Apr 27 06:37:04 1994 @@ -0,0 +1,68 @@ +/* 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 + +/* Initialize PREEMPTER with the information given and stick it in the + chain of preempters for SIGNO. */ + +int +hurd_preempt_signals (struct hurd_signal_preempt *preempter, + int signo, int first_code, int last_code, + sighandler_t (*handler) (thread_t, int, int)) +{ + if (signo <= 0 || signo >= NSIG) + { + errno = EINVAL; + return -1; + } + preempter->first = first_code; + preempter->last = last_code; + preempter->handler = handler; + __mutex_lock (&_hurd_signal_preempt_lock); + preempter->next = _hurd_signal_preempt[signo]; + _hurd_signal_preempt[signo] = preempter; + __mutex_unlock (&_hurd_signal_preempt_lock); + return 0; +} + +/* Remove PREEMPTER from the chain for SIGNO. */ + +int +hurd_unpreempt_signals (struct hurd_signal_preempt *preempter, int signo) +{ + struct hurd_signal_preempt *p, *lastp; + if (signo <= 0 || signo >= NSIG) + { + errno = EINVAL; + return -1; + } + __mutex_lock (&_hurd_signal_preempt_lock); + for (p = _hurd_signal_preempt[signo], lastp = NULL; + p != NULL; lastp = p, p = p->next) + if (p == preempter) + { + (lastp == NULL ? _hurd_signal_preempt[signo] : lastp->next) = p->next; + __mutex_unlock (&_hurd_signal_preempt_lock); + return 0; + } + _hurd_signal_preempt[signo] = preempter; + __mutex_unlock (&_hurd_signal_preempt_lock); + errno = ENOENT; + return -1; +} diff -ruN glibc-1.07/hurd/privports.c glibc-1.08.1/hurd/privports.c --- glibc-1.07/hurd/privports.c +++ glibc-1.08.1/hurd/privports.c Thu Jan 20 15:19:03 1994 @@ -0,0 +1,60 @@ +/* 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 +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 + +/* The program might set these if it is the initial task + bootstrapped by the microkernel. */ + +mach_port_t _hurd_host_priv, _hurd_device_master; + + +kern_return_t +get_privileged_ports (host_priv_t *host_priv_ptr, device_t *device_master_ptr) +{ + if (! _hurd_host_priv) + { + error_t err; + + if (_hurd_ports) + /* We have gotten some initial ports, so perhaps + we have a proc server to talk to. */ + err = __USEPORT (PROC, __proc_getprivports (port, + &_hurd_host_priv, + &_hurd_device_master)); + else + return MACH_SEND_INVALID_DEST; + + if (err) + return err; + } + + if (host_priv_ptr) + { + mach_port_mod_refs (mach_task_self (), + _hurd_host_priv, MACH_PORT_RIGHT_SEND, 1); + *host_priv_ptr = _hurd_host_priv; + } + if (device_master_ptr) + { + mach_port_mod_refs (mach_task_self (), + _hurd_device_master, MACH_PORT_RIGHT_SEND, 1); + *device_master_ptr = _hurd_device_master; + } + return KERN_SUCCESS; +} diff -ruN glibc-1.07/hurd/setdtsz.c glibc-1.08.1/hurd/setdtsz.c --- glibc-1.07/hurd/setdtsz.c Thu Oct 28 22:15:36 1993 +++ glibc-1.08.1/hurd/setdtsz.c @@ -1,89 +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 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 - -/* XXX this should be done by setrlimit (RLIM_OFILES, size). */ - -/* Change the size of the descriptor table. - You cannot shrink the table if any of the descriptors - which would be removed are being used. */ - -int -setdtablesize (size_t size) -{ - int i; - struct _hurd_fd *table; - - __mutex_lock (&_hurd_dtable_lock); - - /* Check that no descriptors which are in use are going to disappear. */ - for (i = size; i < _hurd_dtable.size; ++i) - { - struct _hurd_fd *const d = &_hurd_dtable.d[i]; - - __spin_lock (&d->port.lock); - if (d->port.port != MACH_PORT_NULL) - { - __spin_unlock (&d->port.lock); - __mutex_unlock (&_hurd_dtable_lock); - errno = EBUSY; - return -1; - } - } - - /* Resize the table. */ - - if (_hurd_dtable_user_dealloc == NULL) - /* Noone is using the table. We can relocate it. */ - table = realloc (_hurd_dtable.d, size * sizeof (*table)); - else - /* Someone else is using the table. - We must make a new copy, and let them free the old one. */ - table = malloc (size * sizeof (*table)); - - if (table == NULL) - { - __mutex_unlock (&_hurd_dtable_lock); - return -1; - } - - if (_hurd_dtable_user_dealloc != NULL) - { - *_hurd_dtable_user_dealloc = 1; - _hurd_dtable_user_dealloc = NULL; - - memcpy (table, _hurd_dtable.d, _hurd_dtable.size * sizeof (table[0])); - } - - /* If the table grew, initialize the new slots. */ - for (i = _hurd_dtable.size; i < size; ++i) - { - table[i].flags = 0; - _hurd_port_init (&table[i].port, MACH_PORT_NULL); - _hurd_port_init (&table[i].ctty, MACH_PORT_NULL); - } - - _hurd_dtable.size = size; - _hurd_dtable.d = table; - - __mutex_unlock (&_hurd_dtable_lock); - - return 0; -} diff -ruN glibc-1.07/hurd/setuids.c glibc-1.08.1/hurd/setuids.c --- glibc-1.07/hurd/setuids.c Mon Nov 29 16:39:20 1993 +++ glibc-1.08.1/hurd/setuids.c Thu May 12 02:37:26 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 @@ -16,8 +16,8 @@ not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#ifndef MIB_HACKS #include +#include /* Set the uid set for the current user to UIDS (N of them). */ int @@ -32,6 +32,7 @@ for (i = 0; i < n; ++i) new[i] = uids[i]; + HURD_CRITICAL_BEGIN; __mutex_lock (&_hurd_id.lock); err = _hurd_check_ids (); if (! err) @@ -38,7 +39,7 @@ { /* Get a new auth port using those IDs. */ err = __USEPORT (AUTH, - __auth_makeauth (port, + __auth_makeauth (port, NULL, 0, 0, new, n, _hurd_id.aux.uids, _hurd_id.aux.nuids, _hurd_id.gen.gids, _hurd_id.gen.ngids, @@ -46,6 +47,7 @@ &newauth)); } __mutex_unlock (&_hurd_id.lock); + HURD_CRITICAL_END; if (err) return __hurd_fail (err); @@ -55,4 +57,3 @@ __mach_port_deallocate (__mach_task_self (), newauth); return err; } -#endif diff -ruN glibc-1.07/hurd/siginfo.c glibc-1.08.1/hurd/siginfo.c --- glibc-1.07/hurd/siginfo.c +++ glibc-1.08.1/hurd/siginfo.c Thu Feb 3 03:25:37 1994 @@ -0,0 +1,27 @@ +/* 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 + +void +_hurd_siginfo_handler (int signo) +{ + /* XXX */ + puts ("got a SIGINFO"); +} diff -ruN glibc-1.07/hurd/vpprintf.c glibc-1.08.1/hurd/vpprintf.c --- glibc-1.07/hurd/vpprintf.c +++ glibc-1.08.1/hurd/vpprintf.c Sat Feb 5 20:20:35 1994 @@ -0,0 +1,59 @@ +/* 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 +#include +#include + +static ssize_t +DEFUN(pwrite, (cookie, buf, n), + PTR cookie AND CONST char *buf AND size_t n) +{ + error_t error = __io_write ((io_t) cookie, buf, n, -1, &n); + if (error) + return __hurd_fail (error); + return n; +} + + +/* Write formatted output to PORT, a Mach port supporting the i/o protocol, + according to the format string FORMAT, using the argument list in ARG. */ +int +DEFUN(vpprintf, (port, format, arg), + io_t port AND CONST char *format AND va_list arg) +{ + int done; + FILE f; + + /* Create an unbuffered stream talking to PORT on the stack. */ + memset((PTR) &f, 0, sizeof(f)); + f.__magic = _IOMAGIC; + f.__mode.__write = 1; + f.__cookie = (PTR) port; + f.__room_funcs = __default_room_functions; + f.__io_funcs.__write = pwrite; + f.__seen = 1; + f.__userbuf = 1; + + /* vfprintf will use a buffer on the stack for the life of the call. */ + done = vfprintf(&f, format, arg); + + return done; +} diff -ruN glibc-1.07/inet/netdb.h glibc-1.08.1/inet/netdb.h --- glibc-1.07/inet/netdb.h Wed May 19 15:49:49 1993 +++ glibc-1.08.1/inet/netdb.h Sun Feb 6 23:56:15 1994 @@ -150,4 +150,7 @@ void setservent __P((int)); __END_DECLS +/* Get `struct rpcent' and the definition for reading /etc/rpc. */ +#include + #endif /* !_NETDB_H_ */ diff -ruN glibc-1.07/inet/netinet/in.h glibc-1.08.1/inet/netinet/in.h --- glibc-1.07/inet/netinet/in.h Wed Mar 10 18:46:59 1993 +++ glibc-1.08.1/inet/netinet/in.h Sun Feb 6 17:28:20 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 @@ -131,7 +131,9 @@ /* Network number for local host loopback. */ #define IN_LOOPBACKNET 127 /* Address to loopback in software to local host. */ +#ifndef INADDR_LOOPBACK #define INADDR_LOOPBACK 0x7f000001 /* Internet address 127.0.0.1. */ +#endif /* Structure describing an Internet socket address. */ @@ -142,8 +144,10 @@ struct in_addr sin_addr; /* Internet address. */ /* Pad to size of `struct sockaddr'. */ - unsigned char __pad[sizeof(struct sockaddr) - sizeof(short int) - - sizeof(unsigned short int) - sizeof(struct in_addr)]; + unsigned char sin_zero[sizeof(struct sockaddr) - + sizeof(short int) - + sizeof(unsigned short int) - + sizeof(struct in_addr)]; }; diff -ruN glibc-1.07/inet/rcmd.c glibc-1.08.1/inet/rcmd.c --- glibc-1.07/inet/rcmd.c Sat Apr 20 16:50:14 1991 +++ glibc-1.08.1/inet/rcmd.c Fri Jun 3 22:04:49 1994 @@ -138,7 +138,7 @@ FD_SET(s, &reads); FD_SET(s2, &reads); errno = 0; - if (select(32, &reads, 0, 0, 0) < 1 || + if (select(1 + (s > s2 ? s : s2), &reads, 0, 0, 0) < 1 || !FD_ISSET(s2, &reads)) { if (errno != 0) perror("select: setting up stderr"); diff -ruN glibc-1.07/inet/sys/bitypes.h glibc-1.08.1/inet/sys/bitypes.h --- glibc-1.07/inet/sys/bitypes.h Wed May 19 15:32:52 1993 +++ glibc-1.08.1/inet/sys/bitypes.h Wed May 18 22:56:46 1994 @@ -1,70 +1,3 @@ -/* - * $Id: bitypes.h,v 4.9.1.2 1993/05/17 09:59:01 vixie Exp $ - */ +/* The GNU defines all the necessary types. */ -/* - * ++Copyright++ 1993 - * - - * Copyright (c) 1993 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - - * 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 _BITYPES -#define _BITYPES - -typedef int int32_t; /* true for vax, 68k, mips, i386, and alpha */ -typedef short int16_t; -typedef char int8_t; -typedef unsigned int u_int32_t; -typedef unsigned short u_int16_t; -typedef unsigned char u_int8_t; - -#endif +#include diff -ruN glibc-1.07/install.sh glibc-1.08.1/install.sh --- glibc-1.07/install.sh Mon Oct 26 22:42:49 1992 +++ glibc-1.08.1/install.sh Wed Apr 27 15:12:14 1994 @@ -1,8 +1,7 @@ #!/bin/sh - # # install - install a program, script, or datafile -# This comes from X11R5; it is not part of GNU. +# This comes from X11R5. # # $XConsortium: install.sh,v 1.2 89/12/18 14:47:22 jim Exp $ # @@ -26,9 +25,12 @@ chgrpprog="${CHGRPPROG-chgrp}" stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" +mkdirprog="${MKDIRPROG-mkdir}" +tranformbasename="" +transform_arg="" instcmd="$mvprog" -chmodcmd="" +chmodcmd="$chmodprog 0755" chowncmd="" chgrpcmd="" stripcmd="" @@ -36,6 +38,7 @@ mvcmd="$mvprog" src="" dst="" +dir_arg="" while [ x"$1" != x ]; do case $1 in @@ -43,6 +46,10 @@ shift continue;; + -d) dir_arg=true + shift + continue;; + -m) chmodcmd="$chmodprog $2" shift shift @@ -62,10 +69,20 @@ shift continue;; + -t=*) transformarg=`echo $1 | sed 's/-t=//'` + shift + continue;; + + -b=*) transformbasename=`echo $1 | sed 's/-b=//'` + shift + continue;; + *) if [ x"$src" = x ] then src=$1 else + # this colon is to work around a 386BSD /bin/sh bug + : dst=$1 fi shift @@ -75,45 +92,145 @@ if [ x"$src" = x ] then - echo "install: no input file specified" - exit 1 -fi - -if [ x"$dst" = x ] -then - echo "install: no destination specified" + echo "install: no input file specified" exit 1 +else + true fi +if [ x"$dir_arg" != x ]; then + dst=$src + src="" + + if [ -d $dst ]; then + instcmd=: + else + instcmd=mkdir + fi +else + +# Waiting for this to be detected by the "$instcmd $src $dsttmp" command +# might cause directories to be created, which would be especially bad +# if $src (and thus $dsttmp) contains '*'. + + if [ -f $src -o -d $src ] + then + true + else + echo "install: $src does not exist" + exit 1 + fi + + if [ x"$dst" = x ] + then + echo "install: no destination specified" + exit 1 + else + true + fi # If destination is a directory, append the input filename; if your system # does not like double slashes in filenames, you may need to add some logic -if [ -d $dst ] -then - dst="$dst"/`basename $src` + if [ -d $dst ] + then + dst="$dst"/`basename $src` + else + true + fi +fi + +## this sed command emulates the dirname command +dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` + +# Make sure that the destination directory exists. +# this part is taken from Noah Friedman's mkinstalldirs script + +# Skip lots of stat calls in the usual case. +if [ ! -d "$dstdir" ]; then +defaultIFS=' +' +IFS="${IFS-${defaultIFS}}" + +oIFS="${IFS}" +# Some sh's can't handle IFS=/ for some reason. +IFS='%' +set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` +IFS="${oIFS}" + +pathcomp='' + +while [ $# -ne 0 ] ; do + pathcomp="${pathcomp}${1}" + shift + + if [ ! -d "${pathcomp}" ] ; + then + $mkdirprog "${pathcomp}" + else + true + fi + + pathcomp="${pathcomp}/" +done fi +if [ x"$dir_arg" != x ] +then + $doit $instcmd $dst && + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi +else + +# If we're going to rename the final executable, determine the name now. + + if [ x"$transformarg" = x ] + then + dstfile=`basename $dst` + else + dstfile=`basename $dst $transformbasename | + sed $transformarg`$transformbasename + fi + +# don't allow the sed command to completely eliminate the filename + + if [ x"$dstfile" = x ] + then + dstfile=`basename $dst` + else + true + fi + # Make a temp file name in the proper directory. -dstdir=`dirname $dst` -dsttmp=$dstdir/#inst.$$# + dsttmp=$dstdir/#inst.$$# # Move or copy the file name to the temp name -$doit $instcmd $src $dsttmp + $doit $instcmd $src $dsttmp && + + trap "rm -f ${dsttmp}" 0 && # and set any options; do chmod last to preserve setuid bits -if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; fi -if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; fi -if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; fi -if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; fi +# If any of these fail, we abort the whole thing. If we want to +# ignore errors from any of these, just make sure not to ignore +# errors from the above "$doit $instcmd $src $dsttmp" command. + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && # Now rename the file to the real destination. -$doit $rmcmd $dst -$doit $mvcmd $dsttmp $dst + $doit $rmcmd -f $dstdir/$dstfile && + $doit $mvcmd $dsttmp $dstdir/$dstfile + +fi && exit 0 diff -ruN glibc-1.07/io/Makefile glibc-1.08.1/io/Makefile --- glibc-1.07/io/Makefile Wed Dec 1 00:48:35 1993 +++ glibc-1.08.1/io/Makefile Wed May 11 23:11:16 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,7 +21,10 @@ # subdir := io -headers := statbuf.h sys/stat.h fcntlbits.h fcntl.h utime.h ftw.h +headers := sys/stat.h statbuf.h \ + fcntl.h sys/fcntl.h fcntlbits.h \ + poll.h sys/poll.h \ + utime.h ftw.h routines := \ utime \ @@ -28,7 +31,8 @@ mkfifo \ __stat __fstat __lstat \ __umask __chmod __fchmod __mkdir \ - __open __close __read __write __lseek __access __fcntl __flock \ + __open __close __read __write __lseek __access \ + __fcntl __flock lockf \ __dup __dup2 __pipe \ creat \ __chdir fchdir \ @@ -37,9 +41,10 @@ ttyname __isatty \ __link __symlink __readlink \ __unlink __rmdir \ - ftw + ftw poll routines := $(sort $(foreach f,$(routines),$f $(f:__%=%))) others := pwd +tests := test-utime include ../Rules diff -ruN glibc-1.07/io/fcntl.h glibc-1.08.1/io/fcntl.h --- glibc-1.07/io/fcntl.h Thu Nov 12 17:31:48 1992 +++ glibc-1.08.1/io/fcntl.h Thu Feb 24 21:48:41 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 @@ -63,6 +63,23 @@ #ifdef __OPTIMIZE__ #define creat(file, m) __open((file), O_WRONLY|O_CREAT|O_TRUNC, (m)) #endif /* Optimizing. */ + +#if defined (__USE_MISC) && !defined (F_LOCK) +/* NOTE: These declarations also appear in ; be sure to keep both + files consistent. Some systems have them there and some here, and some + software depends on the macros being defined without including both. */ + +/* `lockf' is a simpler interface to the locking facilities of `fcntl'. + LEN is always relative to the current file position. + The CMD argument is one of the following. */ + +#define F_ULOCK 0 /* Unlock a previously locked region. */ +#define F_LOCK 1 /* Lock a region for exclusive use. */ +#define F_TLOCK 2 /* Test and lock a region for exclusive use. */ +#define F_TEST 3 /* Test a region for other processes locks. */ + +extern int lockf __P ((int __fd, int __cmd, __off_t __len)); +#endif __END_DECLS diff -ruN glibc-1.07/io/lockf.c glibc-1.08.1/io/lockf.c --- glibc-1.07/io/lockf.c +++ glibc-1.08.1/io/lockf.c Tue Mar 22 12:46:16 1994 @@ -0,0 +1,68 @@ +/* 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 + +/* lockf is a simplified interface to fcntl's locking facilities. */ + +int +lockf (int fd, int cmd, off_t len) +{ + struct flock fl; + + switch (cmd) + { + case F_TEST: + /* Test the lock: return 0 if FD is unlocked or locked by this process; + return -1, set errno to EACCES, if another process holds the lock. */ + if (fcntl (fd, F_GETLK, &fl) < 0) + return -1; + if (fl.l_type == F_UNLCK || fl.l_pid == getpid ()) + return 0; + errno = EACCES; + return -1; + + case F_ULOCK: + fl.l_type = F_UNLCK; + cmd = F_SETLK; + break; + case F_LOCK: + fl.l_type = F_WRLCK; + cmd = F_SETLKW; + break; + case F_TLOCK: + fl.l_type = F_WRLCK; + cmd = F_SETLK; + break; + + default: + errno = EINVAL; + return -1; + } + + /* lockf is always relative to the current file position. */ + fl.l_whence = SEEK_CUR; + fl.l_start = 0; + + fl.l_len = len; + + return fcntl (fd, cmd, &fl); +} diff -ruN glibc-1.07/io/poll.h glibc-1.08.1/io/poll.h --- glibc-1.07/io/poll.h +++ glibc-1.08.1/io/poll.h Wed May 11 22:42:51 1994 @@ -0,0 +1 @@ +#include diff -ruN glibc-1.07/io/sys/fcntl.h glibc-1.08.1/io/sys/fcntl.h --- glibc-1.07/io/sys/fcntl.h +++ glibc-1.08.1/io/sys/fcntl.h Tue Feb 15 16:47:42 1994 @@ -0,0 +1 @@ +#include diff -ruN glibc-1.07/io/sys/poll.h glibc-1.08.1/io/sys/poll.h --- glibc-1.07/io/sys/poll.h +++ glibc-1.08.1/io/sys/poll.h Wed May 11 22:55:58 1994 @@ -0,0 +1,65 @@ +/* Compatibility definitions for System V `poll' interface. +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 _SYS_POLL_H +#define _SYS_POLL_H + +#include + +/* Data structure describing a polling request. */ +struct pollfd + { + int fd; /* File descriptor to poll. */ + short int events; /* Types of events poller cares about. */ + short int revents; /* Types of events that actually occurred. */ + }; + +/* Event types that can be polled for. These bits may be set in `events' + to indicate the interesting event types; they will appear in `revents' + to indicate the status of the file descriptor. */ +#define POLLIN 01 /* There is data to read. */ +#define POLLPRI 02 /* There is urgent data to read. */ +#define POLLOUT 04 /* Writing now will not block. */ + +/* Event types always implicitly polled for. These bits need not be set in + `events', but they will appear in `revents' to indicate the status of + the file descriptor. */ +#define POLLERR 010 /* Error condition. */ +#define POLLHUP 020 /* Hung up. */ +#define POLLNVAL 040 /* Invalid polling request. */ + +/* Canonical number of polling requests to read in at a time in poll. */ +#define NPOLLFILE 30 + + +__BEGIN_DECLS + +/* Poll the file descriptors described by the NFDS structures starting at + FDS. If TIMEOUT is nonzero and not -1, allow TIMEOUT milliseconds for + an event to occur; if TIMEOUT is -1, block until an event occurs. + Returns the number of file descriptors with events, zero if timed out, + or -1 for errors. */ + +extern int poll __P ((struct pollfd *__fds, unsigned long int __nfds, + int __timeout)); + +__END_DECLS + +#endif /* sys/poll.h */ + diff -ruN glibc-1.07/io/test-utime.c glibc-1.08.1/io/test-utime.c --- glibc-1.07/io/test-utime.c +++ glibc-1.08.1/io/test-utime.c Wed May 11 18:49:25 1994 @@ -0,0 +1,78 @@ +/* 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 + +int +main () +{ + char file[L_tmpnam]; + struct utimbuf ut; + struct stat st; + int fd; + + if (tmpnam (file) == 0) + { + perror ("tmpnam"); + exit (1); + } + + fd = creat (file, 0666); + if (fd < 0) + { + perror ("creat"); + exit (1); + } + close (fd); + + ut.actime = 500000000; + ut.modtime = 500000001; + if (utime (file, &ut)) + { + perror ("utime"); + remove (file); + exit (1); + } + + if (stat (file, &st)) + { + perror ("stat"); + remove (file); + exit (1); + } + + remove (file); + + if (st.st_mtime != ut.modtime) + { + printf ("modtime %ld != %ld\n", st.st_mtime, ut.modtime); + exit (1); + } + + if (st.st_atime != ut.actime) + { + printf ("actime %ld != %ld\n", st.st_atime, ut.actime); + exit (1); + } + + puts ("Test succeeded."); + exit (0); +} diff -ruN glibc-1.07/mach/Machrules glibc-1.08.1/mach/Machrules --- glibc-1.07/mach/Machrules Thu Jan 6 03:03:36 1994 +++ glibc-1.08.1/mach/Machrules Wed Apr 27 06:45:23 1994 @@ -18,9 +18,10 @@ # not, write to the Free Software Foundation, Inc., 675 Mass Ave, # Cambridge, MA 02139, USA. -# Makefiles define these variable before including this file: +# Makefiles may define these variable before including this file: # user-interfaces Names of interfaces to put user stubs in for. # server-interfaces Names of interfaces to put server stubs in for. +# interface-library Name of interface library to build and install. # This file sets: # interface-headers Names of generated interface header files. # interface-routines Names of generated interface routines. @@ -65,7 +66,7 @@ # If any .ir file is missing, we will be unable to make all the deps. no_deps=t endif -generated += $(*.ir) +generated += $(*.ir:$(objpfx)%=%) endif @@ -79,16 +80,18 @@ # other useful pattern) causes the rule for `host_info' to also match # `xxx_host_info', and analogous lossage. # +# While we're at it, we figure out the imports used by %.defs and give them +# as dependencies of the object files for the generated RPC_*.c files. +# # Depend on %.h just so they will be built from %.uh in the # makefile-rebuilding run which builds %.ir; otherwise, %.uh is built as an # 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 - (echo 'define $*-calls' ;\ - awk '/^kern_return_t/ { print $$2 }' $< ;\ - echo 'endef' ;\ - echo '$*-calls := $$(subst $$(nl), ,$$($*-calls))' ;\ + (awk "/^kern_return_t/ { printf \"$*-calls += %s\\n\", \$$2 } \ + /^#include/ { printf \"$*-imports += %s\\n\", \$$2 }" $< ;\ echo '$$($*-calls:%=$$(objpfx)R\%C_%.c): $$(objpfx)$*.ustamp ;';\ + echo '$$($*-calls:%=$$(objpfx)RPC_%.o): $$($*-imports:<%>=%)' ;\ ) > $@-new mv $@-new $@ vpath Machrules ../mach # Find ourselves. @@ -95,7 +98,7 @@ # Not an implicit rule so the stamps are never removed as intermediates! $(patsubst %,$(objpfx)%.ustamp,$(user-interfaces)): $(objpfx)%.ustamp: %.defs - $(MIG) $< $(MIGFLAGS) \ + $(MIG) $< $(MIGFLAGS) $(user-MIGFLAGS) \ -prefix __ -i $(objpfx)tmp_ \ -server /dev/null -user /dev/null -header /dev/null for call in $($*-calls); do \ @@ -108,7 +111,7 @@ # Build the server stubs in $(objdir). $(objpfx)%_server.c $(objpfx)%_server.h: %.defs - $(MIG) $< $(MIGFLAGS) \ + $(MIG) $< $(MIGFLAGS) $(server-MIGFLAGS) \ -prefix _S_ \ -user /dev/null -header /dev/null \ -server $(@:.h=.c) -sheader $(@:.c=.h) @@ -153,7 +156,7 @@ # and don't distribute them. mach-generated = $(interface-routines:%=%.c) \ $(foreach h,$(interface-headers:%.h=%),$h.h $h.uh $h.__h) -generated += $(addprefix $(objpfx),$(mach-generated)) +generated += $(mach-generated) # These are needed to generate the dependencies. before-compile += $(interface-headers:%=$(objpfx)%) @@ -165,3 +168,45 @@ # Convenient target to generate all the headers. .PHONY: interface-headers interface-headers: $(interface-headers) + +# Don't automatically generate dependencies for the sources we generate. +# There are likely to be a whole lot of them, and we know their +# dependencies ahead of time anyway because they're boilerplate. +omit-deps += $(interface-routines) + +# Specify the static dependencies of the generated files. +$(foreach if,$(user-interfaces),$($(if)-calls:%=$(objpfx)RPC_%.o))): \ + mach/boolean.h mach/kern_return.h mach/message.h mach/notify.h \ + mach/mach_types.h mach/mig_errors.h mach/mig_support.h mach/msg_type.h +$(foreach if,$(user-interfaces),$($(if)-calls:%=$(objpfx)%.o)): ../gnu-stabs.h +$(server-interfaces:%=$(objpfx)%.o): \ + mach/boolean.h mach/kern_return.h mach/message.h mach/mig_errors.h \ + mach/mig_support.h mach/std_types.h +# The MiG-generated sources also depend on the imports in their .defs files. +# These dependencies are generated into the .ir files above. + +# If defined, $(interface-library) is `libNAME.a'. It is to be a library +# containing all the MiG-generated functions for the specified interfaces. + +ifdef interface-library + +$(interface-library)-objs := $(interface-routines:%=%.o) + +install-lib += $(interface-library) +extra-objs += $($(interface-library)-objs) + +$(objpfx)$(interface-library): $(addprefix $(objpfx),\ + $($(interface-library)-objs)) +ifdef objdir + cd $(objdir); $(AR) cru$(verbose) $(@:$(objpfx)%=%) $(^:$(objpfx)%=%) +else + $(AR) cru$(verbose) $@ $^ +endif + $(RANLIB) $@ + +lib-noranlib: $(objpfx)$(interface-library) + +mostlyclean: + -rm -f $(objpfx)$(interface-library) + +endif diff -ruN glibc-1.07/mach/Makefile glibc-1.08.1/mach/Makefile --- glibc-1.07/mach/Makefile Thu Jan 6 14:08:09 1994 +++ glibc-1.08.1/mach/Makefile Mon Jun 6 12:41:45 1994 @@ -25,18 +25,23 @@ headers = mach_init.h mach.h mach_error.h mach-shortcuts.h \ - $(interface-headers) mach/mach.h mach/mig_support.h mach/error.h -routines = $(interface-routines) \ - $(filter-out syscall_%,$(mach-syscalls)) \ + $(interface-headers) mach/mach.h mach/mig_support.h mach/error.h \ + $(lock-headers) machine-sp.h +distribute = thread_state.h +lock = spin-solid spin-lock spin-syms mutex-solid +lock-headers = lock-intern.h machine-lock.h spin-lock.h +routines = $(filter-out syscall_%,$(mach-syscalls)) \ $(addprefix __,$(mach-syscalls)) \ $(mach-shortcuts) $(addprefix __,$(mach-shortcuts)) \ mach_init vm_page_size \ mig_strncpy __msg msg \ - mig_support mig_syms \ - msg_destroy msg_server msg_server_t \ - __msg_dest __msg_server \ - mach_error mach_error_string error_compat errsystems \ - devstream bootprivport + mig-alloc mig-dealloc mig-reply mig_syms \ + msg_destroy msgserver msgserver_t \ + __msg_dest __msgserver \ + mach_error errstring error_compat errsystems \ + devstream bootprivport setup-thread thread-sym $(lock) +# The RPC interfaces go in a separate library. +interface-library := libmachuser.a user-interfaces := $(addprefix mach/,mach_interface mach_port mach_host \ memory_object_user \ memory_object_default \ @@ -48,15 +53,17 @@ # It is important that we do not use the wildcard function to expand # `err_*.sub'. Leaving the wildcard allows Make-dist to find all matching # files in all sysdep directories. -distribute := Machrules syscalls.awk shortcut.awk \ +distribute += Machrules syscalls.awk shortcut.awk \ errorlib.h err_*.sub -# XXX currently these files have been copied into mach/. They will -# supposedly disappear in the future. -headers += $(addprefix mach/default_pager_types.,h defs) +# 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 = @@ -80,6 +87,8 @@ # Exclude $(headers) for Mach files we have our own versions of. mach-headers = $(filter-out mach/machine/% $(headers),\ $(mach-src-headers:$(mach-srcdir)/%=%)) +# Rename Mach's sys/version.h to mach/version.h. +mach-headers := $(patsubst sys/version.h,mach/version.h,$(mach-headers)) # Don't distribute the Mach headers; they are in the Mach distribution. dont_distribute = $(mach-headers) @@ -109,7 +118,7 @@ -e 's/^kernel_trap(\(.*\),\([-0-9]*\),[0-9]*)$$/\1 \2/p' \ < $< | awk -f $(word 2,$^) > $@-new mv $@-new $@ -generated += $(objpfx)mach-syscalls.mk +generated += mach-syscalls.mk ifndef mach-syscalls # We cannot make the deps properly until we know how to make the system @@ -124,8 +133,8 @@ (echo '#include '; \ echo 'symbol_alias (__$*, $*);') > $@-new mv $@-new $@ -generated += $(mach-syscalls:%=$(objpfx)__%.S) \ - $(mach-syscalls:%=$(objpfx)%.c) +generated += $(mach-syscalls:%=__%.S) \ + $(mach-syscalls:%=%.c) endif # mach-syscalls mach-shortcuts := $(patsubst syscall_%,%,$(filter syscall_%,$(mach-syscalls))) @@ -157,7 +166,7 @@ (echo '#include '; \ echo 'symbol_alias (__$*, $*);') > $@-new mv $@-new $@ -generated += $(mach-shortcuts:%=$(objpfx)%.c) +generated += $(mach-shortcuts:%=%.c) endif # mach-shortcuts # Generate mach-shortcuts.h, which will contain the prototypes for the @@ -171,7 +180,7 @@ | grep '^/\* Routine [a-z0-9_]*_rpc \*/' \ | sed 's/_rpc//g' | tr @ \\012 > $@-new mv $@-new $@ -generated += $(objpfx)mach-shortcuts.h +generated += mach-shortcuts.h before-compile += $(objpfx)mach-shortcuts.h @@ -199,7 +208,7 @@ # XXX we have an errsystems.c here because a gcc bug makes the generated # version lose. else -generated += $(objpfx)errsystems.c +generated += errsystems.c $(objpfx)errsystems.c: errsystems.awk err_*.sub \ $(wildcard $(addsuffix /err_*.sub,$(+sysdep_dirs))) gawk -v subsys='$(filter-out $<,$^)' -f $^ > $@.n diff -ruN glibc-1.07/mach/__msg_server.c glibc-1.08.1/mach/__msg_server.c --- glibc-1.07/mach/__msg_server.c Mon Dec 6 18:25:25 1993 +++ glibc-1.08.1/mach/__msg_server.c @@ -1,184 +0,0 @@ -/* 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. */ - -/* Based on CMU's mach_msg_server.c revision 2.4 of 91/05/14, and thus - under the following copyright. Rewritten by Roland McGrath (FSF) - 93/12/06 to use stack space instead of malloc, and to handle - large messages with MACH_RCV_LARGE. */ - -/* - * Mach Operating System - * Copyright (c) 1991,1990 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - */ -/* - * HISTORY - * $Log: mach_msg_server.c,v $ - * Revision 2.4 91/05/14 17:53:22 mrt - * Correcting copyright - * - * Revision 2.3 91/02/14 14:17:47 mrt - * Added new Mach copyright - * [91/02/13 12:44:20 mrt] - * - * Revision 2.2 90/08/06 17:23:58 rpd - * Created. - * - */ - - -#include -#include -#include /* For malloc and free. */ - -mach_msg_return_t -__mach_msg_server_timeout (boolean_t (*demux) (mach_msg_header_t *request, - mach_msg_header_t *reply), - mach_msg_size_t max_size, - mach_port_t rcv_name, - mach_msg_option_t option, - mach_msg_timeout_t timeout) -{ - register mig_reply_header_t *request, *reply; - register mach_msg_return_t mr; - - if (max_size == 0) - { - option |= MACH_RCV_LARGE; - max_size = __vm_page_size; /* Generic. Good? XXX */ - } - - request = __alloca (max_size); - reply = __alloca (max_size); - - while (1) - { - get_request: - mr = __mach_msg (&request->Head, MACH_RCV_MSG|option, - 0, max_size, rcv_name, - timeout, MACH_PORT_NULL); - while (mr == MACH_MSG_SUCCESS) - { - /* We have a request message. - Pass it to DEMUX for processing. */ - - (void) (*demux) (&request->Head, &reply->Head); - - switch (reply->RetCode) - { - case KERN_SUCCESS: - /* Hunky dory. */ - break; - - case MIG_NO_REPLY: - /* The server function wanted no reply sent. - Loop for another request. */ - goto get_request; - - default: - /* Some error; destroy the request message to release any - port rights or VM it holds. Don't destroy the reply port - right, so we can send an error message. */ - request->Head.msgh_remote_port = MACH_PORT_NULL; - __mach_msg_destroy (&request->Head); - break; - } - - if (reply->Head.msgh_remote_port == MACH_PORT_NULL) - { - /* No reply port, so destroy the reply. */ - if (reply->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) - __mach_msg_destroy (&reply->Head); - goto get_request; - } - - /* Send the reply and the get next request. */ - - { - /* Swap the request and reply buffers. mach_msg will read the - reply message from the buffer we pass and write the new - request message to the same buffer. */ - void *tmp = request; - request = reply; - reply = tmp; - } - - mr = __mach_msg (&request->Head, - MACH_SEND_MSG|MACH_RCV_MSG|option, - request->Head.msgh_size, max_size, rcv_name, - timeout, MACH_PORT_NULL); - } - - /* A message error occurred. */ - - switch (mr) - { - case MACH_RCV_TOO_LARGE: - /* The request message is larger than MAX_SIZE, and has not - been dequued. The message header has the actual size of - the message. We recurse here in hopes that the compiler - will optimize the tail-call and allocate some more stack - space instead of way too much. */ - return __mach_msg_server_timeout (demux, request->Head.msgh_size, - rcv_name, option, timeout); - - case MACH_SEND_INVALID_DEST: - /* The reply can't be delivered, so destroy it. This error - indicates only that the requestor went away, so we - continue and get the next request. */ - __mach_msg_destroy (&request->Head); - break; - - default: - /* Some other form of lossage; return to caller. */ - return mr; - } - } -} - - -mach_msg_return_t -__mach_msg_server (demux, max_size, rcv_name) - boolean_t (*demux) (); - mach_msg_size_t max_size; - mach_port_t rcv_name; -{ - return __mach_msg_server_timeout (demux, max_size, rcv_name, - MACH_MSG_OPTION_NONE, - MACH_MSG_TIMEOUT_NONE); -} diff -ruN glibc-1.07/mach/__msgserver.c glibc-1.08.1/mach/__msgserver.c --- glibc-1.07/mach/__msgserver.c +++ glibc-1.08.1/mach/__msgserver.c Mon Dec 6 18:25:25 1993 @@ -0,0 +1,184 @@ +/* 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. */ + +/* Based on CMU's mach_msg_server.c revision 2.4 of 91/05/14, and thus + under the following copyright. Rewritten by Roland McGrath (FSF) + 93/12/06 to use stack space instead of malloc, and to handle + large messages with MACH_RCV_LARGE. */ + +/* + * Mach Operating System + * Copyright (c) 1991,1990 Carnegie Mellon University + * All Rights Reserved. + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie Mellon + * the rights to redistribute these changes. + */ +/* + * HISTORY + * $Log: mach_msg_server.c,v $ + * Revision 2.4 91/05/14 17:53:22 mrt + * Correcting copyright + * + * Revision 2.3 91/02/14 14:17:47 mrt + * Added new Mach copyright + * [91/02/13 12:44:20 mrt] + * + * Revision 2.2 90/08/06 17:23:58 rpd + * Created. + * + */ + + +#include +#include +#include /* For malloc and free. */ + +mach_msg_return_t +__mach_msg_server_timeout (boolean_t (*demux) (mach_msg_header_t *request, + mach_msg_header_t *reply), + mach_msg_size_t max_size, + mach_port_t rcv_name, + mach_msg_option_t option, + mach_msg_timeout_t timeout) +{ + register mig_reply_header_t *request, *reply; + register mach_msg_return_t mr; + + if (max_size == 0) + { + option |= MACH_RCV_LARGE; + max_size = __vm_page_size; /* Generic. Good? XXX */ + } + + request = __alloca (max_size); + reply = __alloca (max_size); + + while (1) + { + get_request: + mr = __mach_msg (&request->Head, MACH_RCV_MSG|option, + 0, max_size, rcv_name, + timeout, MACH_PORT_NULL); + while (mr == MACH_MSG_SUCCESS) + { + /* We have a request message. + Pass it to DEMUX for processing. */ + + (void) (*demux) (&request->Head, &reply->Head); + + switch (reply->RetCode) + { + case KERN_SUCCESS: + /* Hunky dory. */ + break; + + case MIG_NO_REPLY: + /* The server function wanted no reply sent. + Loop for another request. */ + goto get_request; + + default: + /* Some error; destroy the request message to release any + port rights or VM it holds. Don't destroy the reply port + right, so we can send an error message. */ + request->Head.msgh_remote_port = MACH_PORT_NULL; + __mach_msg_destroy (&request->Head); + break; + } + + if (reply->Head.msgh_remote_port == MACH_PORT_NULL) + { + /* No reply port, so destroy the reply. */ + if (reply->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) + __mach_msg_destroy (&reply->Head); + goto get_request; + } + + /* Send the reply and the get next request. */ + + { + /* Swap the request and reply buffers. mach_msg will read the + reply message from the buffer we pass and write the new + request message to the same buffer. */ + void *tmp = request; + request = reply; + reply = tmp; + } + + mr = __mach_msg (&request->Head, + MACH_SEND_MSG|MACH_RCV_MSG|option, + request->Head.msgh_size, max_size, rcv_name, + timeout, MACH_PORT_NULL); + } + + /* A message error occurred. */ + + switch (mr) + { + case MACH_RCV_TOO_LARGE: + /* The request message is larger than MAX_SIZE, and has not + been dequued. The message header has the actual size of + the message. We recurse here in hopes that the compiler + will optimize the tail-call and allocate some more stack + space instead of way too much. */ + return __mach_msg_server_timeout (demux, request->Head.msgh_size, + rcv_name, option, timeout); + + case MACH_SEND_INVALID_DEST: + /* The reply can't be delivered, so destroy it. This error + indicates only that the requestor went away, so we + continue and get the next request. */ + __mach_msg_destroy (&request->Head); + break; + + default: + /* Some other form of lossage; return to caller. */ + return mr; + } + } +} + + +mach_msg_return_t +__mach_msg_server (demux, max_size, rcv_name) + boolean_t (*demux) (); + mach_msg_size_t max_size; + mach_port_t rcv_name; +{ + return __mach_msg_server_timeout (demux, max_size, rcv_name, + MACH_MSG_OPTION_NONE, + MACH_MSG_TIMEOUT_NONE); +} diff -ruN glibc-1.07/mach/devstream.c glibc-1.08.1/mach/devstream.c --- glibc-1.07/mach/devstream.c Wed Nov 24 01:01:23 1993 +++ glibc-1.08.1/mach/devstream.c Mon May 23 22:57:40 1994 @@ -1,7 +1,7 @@ /* stdio on a Mach device port. Translates \n to \r\n on output. -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 @@ -47,6 +47,7 @@ f->__eof = 0; + nread = to_read; if (err = device_read_inband ((device_t) f->__cookie, 0, f->__target, to_read, buffer, &nread)) { @@ -75,9 +76,9 @@ int wrote; while (to_write > 0) { - if (err = device_write_inband ((device_t) f->__cookie, 0, - f->__target, (char *)p, - to_write, &wrote)) + if (err = device_write ((device_t) f->__cookie, 0, + f->__target, (char *)p, + to_write, &wrote)) { errno = err; f->__error = 1; @@ -227,6 +228,8 @@ stream->__room_funcs.__input = input; stream->__room_funcs.__output = output; stream->__io_funcs.__close = (__io_close_fn *) device_close; + stream->__io_funcs.__seek = NULL; /* Cannot seek. */ + stream->__io_funcs.__fileno = NULL; /* No corresponding POSIX.1 fd. */ stream->__seen = 1; return stream; diff -ruN glibc-1.07/mach/err_boot.sub glibc-1.08.1/mach/err_boot.sub --- glibc-1.07/mach/err_boot.sub +++ glibc-1.08.1/mach/err_boot.sub Tue Oct 6 14:29:52 1992 @@ -0,0 +1,60 @@ +/* + * Mach Operating System + * Copyright (c) 1992 Carnegie Mellon University + * All Rights Reserved. + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie Mellon + * the rights to redistribute these changes. + */ +/* + * HISTORY + * $Log: err_bootstrap.sub,v $ + * Revision 2.2 92/04/01 19:37:59 rpd + * Created. + * [92/03/09 rpd] + * + */ +/* + * File: err_bootstrap.sub + * Author: Richard Draves, Carnegie Mellon University + * Date: March 9, 1992 + * + * Error string definitions for bootstrap + */ + +static char * err_codes_bootstrap_fs[] = { + /* 0 */ "(bootstrap/fs) not a directory", + /* 1 */ "(bootstrap/fs) name not found", + /* 2 */ "(bootstrap/fs) name too long", + /* 3 */ "(bootstrap/fs) symbolic link loop", + /* 4 */ "(bootstrap/fs) bad file system", + /* 5 */ "(bootstrap/fs) offset not in file", + /* 6 */ "(bootstrap/fs) invalid parameter", +}; + +/* err_bootstrap subsystems */ +static struct error_subsystem err_bootstrap_sub[] = { + /* bootstrap/0; */ + { + "(bootstrap/fs)", + errlib_count(err_codes_bootstrap_fs), + err_codes_bootstrap_fs, + }, +}; diff -ruN glibc-1.07/mach/err_bootstrap.sub glibc-1.08.1/mach/err_bootstrap.sub --- glibc-1.07/mach/err_bootstrap.sub Tue Oct 6 14:29:52 1992 +++ glibc-1.08.1/mach/err_bootstrap.sub @@ -1,60 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1992 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - */ -/* - * HISTORY - * $Log: err_bootstrap.sub,v $ - * Revision 2.2 92/04/01 19:37:59 rpd - * Created. - * [92/03/09 rpd] - * - */ -/* - * File: err_bootstrap.sub - * Author: Richard Draves, Carnegie Mellon University - * Date: March 9, 1992 - * - * Error string definitions for bootstrap - */ - -static char * err_codes_bootstrap_fs[] = { - /* 0 */ "(bootstrap/fs) not a directory", - /* 1 */ "(bootstrap/fs) name not found", - /* 2 */ "(bootstrap/fs) name too long", - /* 3 */ "(bootstrap/fs) symbolic link loop", - /* 4 */ "(bootstrap/fs) bad file system", - /* 5 */ "(bootstrap/fs) offset not in file", - /* 6 */ "(bootstrap/fs) invalid parameter", -}; - -/* err_bootstrap subsystems */ -static struct error_subsystem err_bootstrap_sub[] = { - /* bootstrap/0; */ - { - "(bootstrap/fs)", - errlib_count(err_codes_bootstrap_fs), - err_codes_bootstrap_fs, - }, -}; diff -ruN glibc-1.07/mach/err_mach.sub glibc-1.08.1/mach/err_mach.sub --- glibc-1.07/mach/err_mach.sub +++ glibc-1.08.1/mach/err_mach.sub Tue Oct 6 14:29:52 1992 @@ -0,0 +1,127 @@ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989 Carnegie Mellon University + * All Rights Reserved. + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie the + * rights to redistribute these changes. + */ +/* + * HISTORY + * $Log: err_mach_ipc.sub,v $ + * Revision 2.3 92/04/01 19:38:05 rpd + * Added MIG_DESTROY_REQUEST. + * [92/03/09 rpd] + * + * Revision 2.2 92/01/16 00:09:05 rpd + * Moved from user collection to mk collection. + * + * Revision 2.3 91/08/29 15:51:30 rpd + * Added MIG_SERVER_DIED. + * [91/08/21 rpd] + * + * Revision 2.2 91/03/27 16:05:37 mrt + * First checkin + * + * Revision 2.2 91/03/18 17:39:03 rpd + * Created. + * [91/03/18 rpd] + * + */ +/* + * File: err_mach_ipc.sub + * Author: Richard Draves, Carnegie Mellon University + * Date: Jan, 1990 + * + * Error string definitions for the new Mach IPC + */ + +static char * err_codes_mach_send[] = { + /* 0 */ "(ipc/send) no error", + /* 1 */ "(ipc/send) send in progress", + /* 2 */ "(ipc/send) invalid data", + /* 3 */ "(ipc/send) invalid destination port", + /* 4 */ "(ipc/send) timed out", + /* 5 */ "(ipc/send) will notify", + /* 6 */ "(ipc/send) notify in progress", + /* 7 */ "(ipc/send) interrupted", + /* 8 */ "(ipc/send) msg too small", + /* 9 */ "(ipc/send) invalid reply port", + /* 10 */ "(ipc/send) invalid port right", + /* 11 */ "(ipc/send) invalid notify port", + /* 12 */ "(ipc/send) invalid memory", + /* 13 */ "(ipc/send) no msg buffer", + /* 14 */ "(ipc/send) no notify possible", + /* 15 */ "(ipc/send) invalid msg-type", + /* 16 */ "(ipc/send) invalid msg-header", +}; + +static char * err_codes_mach_rcv[] = { + /* 0 */ "(ipc/rcv) no error", + /* 1 */ "(ipc/rcv) receive in progress", + /* 2 */ "(ipc/rcv) invalid name", + /* 3 */ "(ipc/rcv) timed out", + /* 4 */ "(ipc/rcv) msg too large", + /* 5 */ "(ipc/rcv) interrupted", + /* 6 */ "(ipc/rcv) port changed", + /* 7 */ "(ipc/rcv) invalid notify port", + /* 8 */ "(ipc/rcv) invalid data", + /* 9 */ "(ipc/rcv) port died", + /* 10 */ "(ipc/rcv) port in set", + /* 11 */ "(ipc/rcv) header error", + /* 12 */ "(ipc/rcv) body error", +}; + +static char * err_codes_mach_mig[] = { + /* 0 */ "(ipc/mig) client type check failure", + /* 1 */ "(ipc/mig) wrong reply message ID", + /* 2 */ "(ipc/mig) server detected error", + /* 3 */ "(ipc/mig) bad request message ID", + /* 4 */ "(ipc/mig) server type check failure", + /* 5 */ "(ipc/mig) no reply should be sent", + /* 6 */ "(ipc/mig) server raised exception", + /* 7 */ "(ipc/mig) array not large enough", + /* 8 */ "(ipc/mig) server died", + /* 9 */ "(ipc/mig) destroy request with no reply", +}; + +/* err_mach_ipc subsystems */ +static struct error_subsystem err_mach_ipc_sub[] = { + /* ipc/0; */ + { + "(ipc/send)", + errlib_count(err_codes_mach_send), + err_codes_mach_send, + }, + /* ipc/1; */ + { + "(ipc/rcv)", + errlib_count(err_codes_mach_rcv), + err_codes_mach_rcv, + + }, + /* ipc/2 */ + { + "(ipc/mig)", + errlib_count(err_codes_mach_mig), + err_codes_mach_mig, + }, + +}; diff -ruN glibc-1.07/mach/err_mach_ipc.sub glibc-1.08.1/mach/err_mach_ipc.sub --- glibc-1.07/mach/err_mach_ipc.sub Tue Oct 6 14:29:52 1992 +++ glibc-1.08.1/mach/err_mach_ipc.sub @@ -1,127 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1991,1990,1989 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ -/* - * HISTORY - * $Log: err_mach_ipc.sub,v $ - * Revision 2.3 92/04/01 19:38:05 rpd - * Added MIG_DESTROY_REQUEST. - * [92/03/09 rpd] - * - * Revision 2.2 92/01/16 00:09:05 rpd - * Moved from user collection to mk collection. - * - * Revision 2.3 91/08/29 15:51:30 rpd - * Added MIG_SERVER_DIED. - * [91/08/21 rpd] - * - * Revision 2.2 91/03/27 16:05:37 mrt - * First checkin - * - * Revision 2.2 91/03/18 17:39:03 rpd - * Created. - * [91/03/18 rpd] - * - */ -/* - * File: err_mach_ipc.sub - * Author: Richard Draves, Carnegie Mellon University - * Date: Jan, 1990 - * - * Error string definitions for the new Mach IPC - */ - -static char * err_codes_mach_send[] = { - /* 0 */ "(ipc/send) no error", - /* 1 */ "(ipc/send) send in progress", - /* 2 */ "(ipc/send) invalid data", - /* 3 */ "(ipc/send) invalid destination port", - /* 4 */ "(ipc/send) timed out", - /* 5 */ "(ipc/send) will notify", - /* 6 */ "(ipc/send) notify in progress", - /* 7 */ "(ipc/send) interrupted", - /* 8 */ "(ipc/send) msg too small", - /* 9 */ "(ipc/send) invalid reply port", - /* 10 */ "(ipc/send) invalid port right", - /* 11 */ "(ipc/send) invalid notify port", - /* 12 */ "(ipc/send) invalid memory", - /* 13 */ "(ipc/send) no msg buffer", - /* 14 */ "(ipc/send) no notify possible", - /* 15 */ "(ipc/send) invalid msg-type", - /* 16 */ "(ipc/send) invalid msg-header", -}; - -static char * err_codes_mach_rcv[] = { - /* 0 */ "(ipc/rcv) no error", - /* 1 */ "(ipc/rcv) receive in progress", - /* 2 */ "(ipc/rcv) invalid name", - /* 3 */ "(ipc/rcv) timed out", - /* 4 */ "(ipc/rcv) msg too large", - /* 5 */ "(ipc/rcv) interrupted", - /* 6 */ "(ipc/rcv) port changed", - /* 7 */ "(ipc/rcv) invalid notify port", - /* 8 */ "(ipc/rcv) invalid data", - /* 9 */ "(ipc/rcv) port died", - /* 10 */ "(ipc/rcv) port in set", - /* 11 */ "(ipc/rcv) header error", - /* 12 */ "(ipc/rcv) body error", -}; - -static char * err_codes_mach_mig[] = { - /* 0 */ "(ipc/mig) client type check failure", - /* 1 */ "(ipc/mig) wrong reply message ID", - /* 2 */ "(ipc/mig) server detected error", - /* 3 */ "(ipc/mig) bad request message ID", - /* 4 */ "(ipc/mig) server type check failure", - /* 5 */ "(ipc/mig) no reply should be sent", - /* 6 */ "(ipc/mig) server raised exception", - /* 7 */ "(ipc/mig) array not large enough", - /* 8 */ "(ipc/mig) server died", - /* 9 */ "(ipc/mig) destroy request with no reply", -}; - -/* err_mach_ipc subsystems */ -static struct error_subsystem err_mach_ipc_sub[] = { - /* ipc/0; */ - { - "(ipc/send)", - errlib_count(err_codes_mach_send), - err_codes_mach_send, - }, - /* ipc/1; */ - { - "(ipc/rcv)", - errlib_count(err_codes_mach_rcv), - err_codes_mach_rcv, - - }, - /* ipc/2 */ - { - "(ipc/mig)", - errlib_count(err_codes_mach_mig), - err_codes_mach_mig, - }, - -}; diff -ruN glibc-1.07/mach/errstring.c glibc-1.08.1/mach/errstring.c --- glibc-1.07/mach/errstring.c +++ glibc-1.08.1/mach/errstring.c Tue Nov 30 12:35:58 1993 @@ -0,0 +1,97 @@ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989 Carnegie Mellon University + * All Rights Reserved. + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie Mellon + * the rights to redistribute these changes. + */ +/* + * HISTORY + * $Log: mach_error_string.c,v $ + * Revision 2.3 92/04/01 19:38:18 rpd + * Updated do_compat for kernel device errors, + * bootstrap file-system errors. + * [92/03/09 rpd] + * + * Revision 2.2 92/02/20 15:58:08 elf + * Created from mach_error.c. + * [92/02/11 rpd] + * + */ + +#define EXPORT_BOOLEAN +#include +#include +#include +#include + +extern void __mach_error_map_compat (mach_error_t *); + +const char * +mach_error_type( err ) + mach_error_t err; +{ + int sub, system; + + __mach_error_map_compat( &err ); + + sub = err_get_sub(err); + system = err_get_system(err); + + if (system > err_max_system + || sub >= errors[system].max_sub ) return( "(?/?)" ); + return( errors[system].subsystem[sub].subsys_name ); +} + +boolean_t mach_error_full_diag = FALSE; + +const char * +mach_error_string_int( err, diag ) + mach_error_t err; + boolean_t * diag; +{ + int sub, system, code; + + __mach_error_map_compat( &err ); + + sub = err_get_sub(err); + system = err_get_system(err); + code = err_get_code(err); + + *diag = TRUE; + + if (system > err_max_system) return( "(?/?) unknown error system" ); + if (sub >= errors[system].max_sub) return( errors[system].bad_sub ); + if (code >= errors[system].subsystem[sub].max_code) return ( NO_SUCH_ERROR ); + + *diag = mach_error_full_diag; + return( errors[system].subsystem[sub].codes[code] ); +} + +const char * +mach_error_string( err ) + mach_error_t err; +{ + boolean_t diag; + + return mach_error_string_int( err, &diag ); + +} diff -ruN glibc-1.07/mach/errsystems.c glibc-1.08.1/mach/errsystems.c --- glibc-1.07/mach/errsystems.c Fri Dec 17 17:37:08 1993 +++ glibc-1.08.1/mach/errsystems.c Mon May 23 23:16:09 1994 @@ -6,10 +6,10 @@ #include "../sysdeps/mach/hurd/err_hurd.sub" #include "err_us.sub" #include "err_server.sub" -#include "err_mach_ipc.sub" +#include "err_mach.sub" #include "err_kern.sub" #include "err_ipc.sub" -#include "err_bootstrap.sub" +#include "err_boot.sub" const struct error_system __mach_error_systems[err_max_system + 1] = diff -ruN glibc-1.07/mach/lock-intern.h glibc-1.08.1/mach/lock-intern.h --- glibc-1.07/mach/lock-intern.h +++ glibc-1.08.1/mach/lock-intern.h Mon May 16 21:41:59 1994 @@ -0,0 +1,89 @@ +/* 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 _LOCK_INTERN_H +#define _LOCK_INTERN_H + +#include + +#ifndef _EXTERN_INLINE +#define _EXTERN_INLINE extern __inline +#endif + + +/* Initialize LOCK. */ + +_EXTERN_INLINE void +__spin_lock_init (__spin_lock_t *__lock) +{ + *__lock = __SPIN_LOCK_INITIALIZER; +} + + +/* Lock LOCK, blocking if we can't get it. */ +extern void __spin_lock_solid (__spin_lock_t *__lock); + +/* Lock the spin lock LOCK. */ + +_EXTERN_INLINE void +__spin_lock (__spin_lock_t *__lock) +{ + if (! __spin_try_lock (__lock)) + __spin_lock_solid (__lock); +} + +/* Name space-clean internal interface to mutex locks. + + Code internal to the C library uses these functions to lock and unlock + mutex locks. These locks are of type `struct mutex', defined in + . The functions here are name space-clean. If the program + is linked with the cthreads library, `__mutex_lock_solid' and + `__mutex_unlock_solid' will invoke the corresponding cthreads functions + to implement real mutex locks. If not, simple stub versions just use + spin locks. */ + + +/* Initialize the newly allocated mutex lock LOCK for further use. */ +extern void __mutex_init (void *__lock); + +/* Lock LOCK, blocking if we can't get it. */ +extern void __mutex_lock_solid (void *__lock); + +/* Finish unlocking LOCK, after the spin lock LOCK->held has already been + unlocked. This function will wake up any thread waiting on LOCK. */ +extern void __mutex_unlock_solid (void *__lock); + +/* Lock the mutex lock LOCK. */ + +_EXTERN_INLINE void +__mutex_lock (void *__lock) +{ + if (! __spin_try_lock ((__spin_lock_t *) __lock)) + __mutex_lock_solid (__lock); +} + +/* Unlock the mutex lock LOCK. */ + +_EXTERN_INLINE void +__mutex_unlock (void *__lock) +{ + __spin_unlock ((__spin_lock_t *) __lock); + __mutex_unlock_solid (__lock); +} + +#endif /* lock-intern.h */ diff -ruN glibc-1.07/mach/mach.h glibc-1.08.1/mach/mach.h --- glibc-1.07/mach/mach.h Fri Dec 3 17:32:26 1993 +++ glibc-1.08.1/mach/mach.h Wed Apr 20 16:13:06 1994 @@ -1,5 +1,5 @@ /* Standard header for all Mach programs. -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 @@ -76,6 +76,20 @@ /* Open a stream on a Mach device. */ extern FILE *mach_open_devstream (mach_port_t device_port, const char *mode); + +/* Give THREAD a stack and set it to run at PC when resumed. + If *STACK_SIZE is nonzero, that size of stack is allocated. + If *STACK_BASE is nonzero, that stack location is used. + If STACK_BASE is not null it is filled in with the chosen stack base. + If STACK_SIZE is not null it is filled in with the chosen stack size. + Regardless, an extra page of red zone is allocated off the end; this + is not included in *STACK_SIZE. */ +kern_return_t __mach_setup_thread (task_t task, thread_t thread, void *pc, + vm_address_t *stack_base, + vm_size_t *stack_size); +kern_return_t mach_setup_thread (task_t task, thread_t thread, void *pc, + vm_address_t *stack_base, + vm_size_t *stack_size); #endif /* mach.h */ diff -ruN glibc-1.07/mach/mach_error_string.c glibc-1.08.1/mach/mach_error_string.c --- glibc-1.07/mach/mach_error_string.c Tue Nov 30 12:35:58 1993 +++ glibc-1.08.1/mach/mach_error_string.c @@ -1,97 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1991,1990,1989 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - */ -/* - * HISTORY - * $Log: mach_error_string.c,v $ - * Revision 2.3 92/04/01 19:38:18 rpd - * Updated do_compat for kernel device errors, - * bootstrap file-system errors. - * [92/03/09 rpd] - * - * Revision 2.2 92/02/20 15:58:08 elf - * Created from mach_error.c. - * [92/02/11 rpd] - * - */ - -#define EXPORT_BOOLEAN -#include -#include -#include -#include - -extern void __mach_error_map_compat (mach_error_t *); - -const char * -mach_error_type( err ) - mach_error_t err; -{ - int sub, system; - - __mach_error_map_compat( &err ); - - sub = err_get_sub(err); - system = err_get_system(err); - - if (system > err_max_system - || sub >= errors[system].max_sub ) return( "(?/?)" ); - return( errors[system].subsystem[sub].subsys_name ); -} - -boolean_t mach_error_full_diag = FALSE; - -const char * -mach_error_string_int( err, diag ) - mach_error_t err; - boolean_t * diag; -{ - int sub, system, code; - - __mach_error_map_compat( &err ); - - sub = err_get_sub(err); - system = err_get_system(err); - code = err_get_code(err); - - *diag = TRUE; - - if (system > err_max_system) return( "(?/?) unknown error system" ); - if (sub >= errors[system].max_sub) return( errors[system].bad_sub ); - if (code >= errors[system].subsystem[sub].max_code) return ( NO_SUCH_ERROR ); - - *diag = mach_error_full_diag; - return( errors[system].subsystem[sub].codes[code] ); -} - -const char * -mach_error_string( err ) - mach_error_t err; -{ - boolean_t diag; - - return mach_error_string_int( err, &diag ); - -} diff -ruN glibc-1.07/mach/mig-alloc.c glibc-1.08.1/mach/mig-alloc.c --- glibc-1.07/mach/mig-alloc.c +++ glibc-1.08.1/mach/mig-alloc.c Thu Mar 24 21:28:50 1994 @@ -0,0 +1,28 @@ +/* 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 + +/* Called by MiG to allocate space. */ +void +__mig_allocate (vm_address_t *addr, + vm_size_t size) +{ + if (__vm_allocate (__mach_task_self (), addr, size, 1) != KERN_SUCCESS) + *addr = 0; +} diff -ruN glibc-1.07/mach/mig-dealloc.c glibc-1.08.1/mach/mig-dealloc.c --- glibc-1.07/mach/mig-dealloc.c +++ glibc-1.08.1/mach/mig-dealloc.c Thu Mar 24 21:23:35 1994 @@ -0,0 +1,27 @@ +/* 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 + +/* Called by MiG to deallocate space. */ +void +__mig_deallocate (vm_address_t addr, + vm_size_t size) +{ + (void) __vm_deallocate (__mach_task_self (), addr, size); +} diff -ruN glibc-1.07/mach/mig_support.c glibc-1.08.1/mach/mig_support.c --- glibc-1.07/mach/mig_support.c Thu Nov 5 18:54:03 1992 +++ glibc-1.08.1/mach/mig_support.c @@ -1,68 +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 - -/* These functions are called by MiG-generated code. */ - -static mach_port_t reply_port; - -/* Called at startup with NOP==0. */ -void -__mig_init (int nop) -{ - if (!nop) - reply_port = MACH_PORT_NULL; -} - -/* Called by MiG to get a reply port. */ -mach_port_t -__mig_get_reply_port (void) -{ - if (reply_port == MACH_PORT_NULL) - reply_port = __mach_reply_port (); - - return reply_port; -} - -/* Called by MiG to deallocate the reply port. */ -void -__mig_dealloc_reply_port (void) -{ - mach_port_t port = reply_port; - 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 to allocate space. */ -void -__mig_allocate (vm_address_t *addr, - vm_size_t size) -{ - if (__vm_allocate (__mach_task_self (), addr, size, 1) != KERN_SUCCESS) - *addr = 0; -} - -/* Called by MiG to deallocate space. */ -void -__mig_deallocate (vm_address_t addr, - vm_size_t size) -{ - (void) __vm_deallocate (__mach_task_self (), addr, size); -} diff -ruN glibc-1.07/mach/mig_syms.c glibc-1.08.1/mach/mig_syms.c --- glibc-1.07/mach/mig_syms.c Wed May 19 14:33:13 1993 +++ glibc-1.08.1/mach/mig_syms.c Sun May 1 19:38:57 1994 @@ -3,3 +3,7 @@ symbol_alias (__mig_allocate, mig_allocate); symbol_alias (__mig_deallocate, mig_deallocate); symbol_alias (__mig_strncpy, mig_strncpy); + +symbol_alias (__mig_init, mig_init); +symbol_alias (__mig_get_reply_port, mig_get_reply_port); +symbol_alias (__mig_dealloc_reply_port, mig_dealloc_reply_port); diff -ruN glibc-1.07/mach/msg_server.c glibc-1.08.1/mach/msg_server.c --- glibc-1.07/mach/msg_server.c Wed Oct 23 08:51:55 1991 +++ glibc-1.08.1/mach/msg_server.c @@ -1,4 +0,0 @@ -#include - -#undef mach_msg_server -symbol_alias (__mach_msg_server, mach_msg_server); diff -ruN glibc-1.07/mach/msg_server_t.c glibc-1.08.1/mach/msg_server_t.c --- glibc-1.07/mach/msg_server_t.c Fri Oct 25 19:19:23 1991 +++ glibc-1.08.1/mach/msg_server_t.c @@ -1,4 +0,0 @@ -#include - -#undef mach_msg_server_timeout -symbol_alias (__mach_msg_server_timeout, mach_msg_server_timeout); diff -ruN glibc-1.07/mach/msgserver.c glibc-1.08.1/mach/msgserver.c --- glibc-1.07/mach/msgserver.c +++ glibc-1.08.1/mach/msgserver.c Wed Oct 23 08:51:55 1991 @@ -0,0 +1,4 @@ +#include + +#undef mach_msg_server +symbol_alias (__mach_msg_server, mach_msg_server); diff -ruN glibc-1.07/mach/msgserver_t.c glibc-1.08.1/mach/msgserver_t.c --- glibc-1.07/mach/msgserver_t.c +++ glibc-1.08.1/mach/msgserver_t.c Fri Oct 25 19:19:23 1991 @@ -0,0 +1,4 @@ +#include + +#undef mach_msg_server_timeout +symbol_alias (__mach_msg_server_timeout, mach_msg_server_timeout); diff -ruN glibc-1.07/mach/mutex-solid.c glibc-1.08.1/mach/mutex-solid.c --- glibc-1.07/mach/mutex-solid.c +++ glibc-1.08.1/mach/mutex-solid.c Mon May 16 21:45:23 1994 @@ -0,0 +1,50 @@ +/* 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 + +/* If cthreads is linked in, it will define these variables with values + that point to its mutex functions. */ +void (*_cthread_mutex_lock_routine) (struct mutex *); +void (*_cthread_mutex_unlock_routine) (struct mutex *); + +void +__mutex_lock_solid (void *lock) +{ + if (_cthread_mutex_lock_routine) + (*_cthread_mutex_lock_routine) (lock); + else + __spin_lock_solid (lock); +} + +void +__mutex_unlock_solid (void *lock) +{ + if (_cthread_mutex_unlock_routine) + (*_cthread_mutex_unlock_routine) (lock); +} + +void +__mutex_init (void *lock) +{ + /* This happens to be name space-safe because it is a macro. + It invokes only spin_lock_init, which is a macro for __spin_lock_init; + and cthread_queue_init, which is a macro for some simple code. */ + mutex_init ((struct mutex *) lock); +} diff -ruN glibc-1.07/mach/setup-thread.c glibc-1.08.1/mach/setup-thread.c --- glibc-1.07/mach/setup-thread.c +++ glibc-1.08.1/mach/setup-thread.c Wed Apr 27 02:36:49 1994 @@ -0,0 +1,97 @@ +/* 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 "thread_state.h" +#include +#include +#include "sysdep.h" /* Defines stack direction. */ + +#define STACK_SIZE (16 * 1024 * 1024) /* 16MB, arbitrary. */ + +/* Give THREAD a stack and set it to run at PC when resumed. + If *STACK_SIZE is nonzero, that size of stack is allocated. + If *STACK_BASE is nonzero, that stack location is used. + If STACK_BASE is not null it is filled in with the chosen stack base. + If STACK_SIZE is not null it is filled in with the chosen stack size. + Regardless, an extra page of red zone is allocated off the end; this + is not included in *STACK_SIZE. */ + +kern_return_t +__mach_setup_thread (task_t task, thread_t thread, void *pc, + vm_address_t *stack_base, vm_size_t *stack_size) +{ + kern_return_t error; + struct machine_thread_state ts; + mach_msg_type_number_t tssize = MACHINE_THREAD_STATE_COUNT; + vm_address_t stack; + vm_size_t size; + int anywhere = 0; + + size = stack_size ? *stack_size ? : STACK_SIZE : STACK_SIZE; + + if (stack_base && *stack_base) + stack = *stack_base; + else if (size == STACK_SIZE) + { + /* Cthreads has a bug that makes its stack-probing code fail if + the stack is too low in memory. It's bad to try and fix it there + until cthreads is integrated into libc, so we'll just do it here + by requesting a high address. When the cthreads bug is fixed, + this assignment to STACK should be changed to 0, and the ANYWHERE + argument to vm_allocate should be changed to 0. This comment should + be left, however, in order to confuse people who wonder why its + here. (Though perhaps that last sentence (and this one) should + be deleted to maximize the effect.) */ +#ifdef STACK_GROWTH_DOWN + stack = VM_MAX_ADDRESS - size - __vm_page_size; +#else + stack = VM_MIN_ADDRESS; +#endif + } + else + anywhere = 1; + + if (error = __vm_allocate (task, &stack, size + __vm_page_size, anywhere)) + return error; + + if (stack_size) + *stack_size = size; + + memset (&ts, 0, sizeof (ts)); + ts.PC = (int) pc; +#ifdef STACK_GROWTH_DOWN + if (stack_base) + *stack_base = stack + __vm_page_size; + ts.SP = stack + __vm_page_size + size; +#elif defined (STACK_GROWTH_UP) + if (stack_base) + *stack_base = stack; + ts.SP = stack; + stack += size; +#else + #error stack direction unknown +#endif + + /* Create the red zone. */ + if (error = __vm_protect (task, stack, __vm_page_size, 0, VM_PROT_NONE)) + return error; + + return __thread_set_state (thread, MACHINE_THREAD_STATE_FLAVOR, + (int *) &ts, tssize); +} diff -ruN glibc-1.07/mach/shortcut.awk glibc-1.08.1/mach/shortcut.awk --- glibc-1.07/mach/shortcut.awk Wed Jun 30 21:56:19 1993 +++ glibc-1.08.1/mach/shortcut.awk Mon Feb 7 17:57:52 1994 @@ -5,7 +5,7 @@ inproto=0; proto=""; arglist=""; } -# $1 == "LINTLIBRARY" { print "#include "; next } +$1 == "LINTLIBRARY" { print "#include "; next } # Copy the first line of the definition, but # replace the function name (RPC) with CALL. diff -ruN glibc-1.07/mach/spin-lock.c glibc-1.08.1/mach/spin-lock.c --- glibc-1.07/mach/spin-lock.c +++ glibc-1.08.1/mach/spin-lock.c Tue Apr 19 17:52:55 1994 @@ -0,0 +1,2 @@ +#define _EXTERN_INLINE /* Empty to define the real functions. */ +#include "spin-lock.h" diff -ruN glibc-1.07/mach/spin-lock.h glibc-1.08.1/mach/spin-lock.h --- glibc-1.07/mach/spin-lock.h +++ glibc-1.08.1/mach/spin-lock.h Thu May 5 06:10:08 1994 @@ -0,0 +1,34 @@ +/* Definitions of user-visible names for spin locks. +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 _SPIN_LOCK_H +#define _SPIN_LOCK_H + +#include /* This does all the work. */ + +typedef __spin_lock_t spin_lock_t; +#define SPIN_LOCK_INITIALIZER __SPIN_LOCK_INITIALIZER + +#define spin_lock_init(lock) __spin_lock_init (lock) +#define spin_lock(lock) __spin_lock (lock) +#define spin_try_lock(lock) __spin_try_lock (lock) +#define spin_unlock(lock) __spin_unlock (lock) +#define spin_lock_locked(lock) __spin_lock_locked (lock) + +#endif /* spin-lock.h */ diff -ruN glibc-1.07/mach/spin-solid.c glibc-1.08.1/mach/spin-solid.c --- glibc-1.07/mach/spin-solid.c +++ glibc-1.08.1/mach/spin-solid.c Thu May 5 06:53:15 1994 @@ -0,0 +1,27 @@ +/* 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 + +void +__spin_lock_solid (spin_lock_t *lock) +{ + while (__spin_lock_locked (lock) || ! __spin_try_lock (lock)) + /* Yield to another thread (system call). */ + __swtch (); +} diff -ruN glibc-1.07/mach/spin-syms.c glibc-1.08.1/mach/spin-syms.c --- glibc-1.07/mach/spin-syms.c +++ glibc-1.08.1/mach/spin-syms.c Thu Apr 21 20:35:20 1994 @@ -0,0 +1,8 @@ +#include + +symbol_alias (__spin_lock_init, spin_lock_init); +symbol_alias (__spin_lock_solid, spin_lock_solid); +symbol_alias (__spin_lock_locked, spin_lock_locked); +symbol_alias (__spin_lock, spin_lock); +symbol_alias (__spin_unlock, spin_unlock); +symbol_alias (__spin_try_lock, spin_try_lock); diff -ruN glibc-1.07/mach/thread-sym.c glibc-1.08.1/mach/thread-sym.c --- glibc-1.07/mach/thread-sym.c +++ glibc-1.08.1/mach/thread-sym.c Wed Feb 16 20:01:57 1994 @@ -0,0 +1,6 @@ +#include +#include + +function_alias (mach_setup_thread, __mach_setup_thread, + kern_return_t, (task, thread, pc), + mach_setup_thread (task_t task, thread_t thread, void *pc)) diff -ruN glibc-1.07/malloc/Makefile glibc-1.08.1/malloc/Makefile --- glibc-1.07/malloc/Makefile Mon Jan 17 23:08:56 1994 +++ glibc-1.08.1/malloc/Makefile Tue May 3 23:33:51 1994 @@ -27,8 +27,9 @@ headers := $(dist-headers) obstack.h tests := mallocbug -# Things which get pasted together into gmalloc.c. -gmalloc-routines := malloc free cfree realloc calloc morecore memalign valloc +# Things which get pasted together into gmalloc.c. It is important that +# valloc is first, so that getpagesize.h is included before other things. +gmalloc-routines := valloc malloc free cfree realloc calloc morecore memalign # Things to include in the standalone distribution. dist-routines = $(gmalloc-routines) \ mcheck mtrace mstats vm-limit ralloc @@ -38,6 +39,7 @@ gpl2lgpl := obstack.c obstack.h vm-limit.c mem-limits.h ralloc.c install-lib := libmcheck.a +non-lib.a := libmcheck.a distribute := mcheck-init.c OChangeLog TODO \ malloc/gmalloc-head.c dist-README dist-Makefile \ diff -ruN glibc-1.07/malloc/cfree.c glibc-1.08.1/malloc/cfree.c --- glibc-1.07/malloc/cfree.c Wed May 12 19:43:33 1993 +++ glibc-1.08.1/malloc/cfree.c Fri Mar 4 12:25:50 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 @@ -21,12 +21,12 @@ #include #endif -#undef cfree - #ifdef _LIBC #include #include + +#undef cfree function_alias(cfree, free, void, (ptr), DEFUN(cfree, (ptr), PTR ptr)) diff -ruN glibc-1.07/malloc/malloc.c glibc-1.08.1/malloc/malloc.c --- glibc-1.07/malloc/malloc.c Thu Jul 22 15:04:45 1993 +++ glibc-1.08.1/malloc/malloc.c Thu Apr 21 16:54:45 1994 @@ -1,5 +1,5 @@ /* Memory allocator `malloc'. - Copyright 1990, 1991, 1992, 1993 Free Software Foundation + Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation Written May 1989 by Mike Haertel. This library is free software; you can redistribute it and/or @@ -71,7 +71,7 @@ result = (*__morecore) (size); adj = (unsigned long int) ((unsigned long int) ((char *) result - - (char *) NULL)) % BLOCKSIZE; + (char *) NULL)) % BLOCKSIZE; if (adj != 0) { adj = BLOCKSIZE - adj; @@ -99,6 +99,11 @@ _heapinfo[0].free.next = _heapinfo[0].free.prev = 0; _heapindex = 0; _heapbase = (char *) _heapinfo; + + /* Account for the _heapinfo block itself in the statistics. */ + _bytes_used = heapsize * sizeof (malloc_info); + _chunks_used = 1; + __malloc_initialized = 1; return 1; } @@ -130,13 +135,17 @@ (*__morecore) (-size); return NULL; } - memset (newinfo, 0, newsize * sizeof (malloc_info)); memcpy (newinfo, _heapinfo, heapsize * sizeof (malloc_info)); + memset (&newinfo[heapsize], 0, + (newsize - heapsize) * sizeof (malloc_info)); oldinfo = _heapinfo; newinfo[BLOCK (oldinfo)].busy.type = 0; newinfo[BLOCK (oldinfo)].busy.info.size = BLOCKIFY (heapsize * sizeof (malloc_info)); _heapinfo = newinfo; + /* Account for the _heapinfo block itself in the statistics. */ + _bytes_used += newsize * sizeof (malloc_info); + ++_chunks_used; _free_internal (oldinfo); heapsize = newsize; } diff -ruN glibc-1.07/malloc/malloc.h glibc-1.08.1/malloc/malloc.h --- glibc-1.07/malloc/malloc.h Fri Aug 13 16:53:29 1993 +++ glibc-1.08.1/malloc/malloc.h Tue May 3 19:24:20 1994 @@ -47,6 +47,10 @@ #define CHAR_BIT 8 #endif +#ifdef HAVE_UNISTD_H +#include +#endif + #endif /* _MALLOC_INTERNAL. */ @@ -215,8 +219,27 @@ extern __ptr_t (*__malloc_hook) __P ((size_t __size)); extern __ptr_t (*__realloc_hook) __P ((__ptr_t __ptr, size_t __size)); -/* Activate a standard collection of debugging hooks. */ -extern int mcheck __P ((void (*__func) __P ((void)))); +/* Return values for `mprobe': these are the kinds of inconsistencies that + `mcheck' enables detection of. */ +enum mcheck_status + { + MCHECK_DISABLED = -1, /* Consistency checking is not turned on. */ + MCHECK_OK, /* Block is fine. */ + MCHECK_FREE, /* Block freed twice. */ + MCHECK_HEAD, /* Memory before the block was clobbered. */ + MCHECK_TAIL /* Memory after the block was clobbered. */ + }; + +/* Activate a standard collection of debugging hooks. This must be called + before `malloc' is ever called. ABORTFUNC is called with an error code + (see enum above) when an inconsistency is detected. If ABORTFUNC is + null, the standard function prints on stderr and then calls `abort'. */ +extern int mcheck __P ((void (*__abortfunc) __P ((enum mcheck_status)))); + +/* Check for aberrations in a particular malloc'd block. You must have + called `mcheck' already. These are the same checks that `mcheck' does + when you free or reallocate a block. */ +extern enum mcheck_status mprobe __P ((__ptr_t __ptr)); /* Activate a standard collection of tracing hooks. */ extern void mtrace __P ((void)); diff -ruN glibc-1.07/malloc/mcheck.c glibc-1.08.1/malloc/mcheck.c --- glibc-1.07/malloc/mcheck.c Mon Jul 12 21:59:11 1993 +++ glibc-1.08.1/malloc/mcheck.c Mon Mar 28 15:55:11 1994 @@ -1,5 +1,5 @@ /* Standard debugging hooks for `malloc'. - Copyright 1990, 1991, 1992, 1993 Free Software Foundation + Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation Written May 1989 by Mike Haertel. This library is free software; you can redistribute it and/or @@ -23,6 +23,7 @@ #ifndef _MALLOC_INTERNAL #define _MALLOC_INTERNAL #include +#include #endif /* Old hook values. */ @@ -31,10 +32,11 @@ static __ptr_t (*old_realloc_hook) __P ((__ptr_t ptr, size_t size)); /* Function to call when something awful happens. */ -static void (*abortfunc) __P ((void)); +static void (*abortfunc) __P ((enum mcheck_status)); /* Arbitrary magical numbers. */ #define MAGICWORD 0xfedabeeb +#define MAGICFREE 0xd8675309 #define MAGICBYTE ((char) 0xd7) struct hdr @@ -43,13 +45,30 @@ unsigned long int magic; /* Magic number to check header integrity. */ }; -static void checkhdr __P ((const struct hdr *)); -static void +static enum mcheck_status checkhdr __P ((const struct hdr *)); +static enum mcheck_status checkhdr (hdr) const struct hdr *hdr; { - if (hdr->magic != MAGICWORD || ((char *) &hdr[1])[hdr->size] != MAGICBYTE) - (*abortfunc) (); + enum mcheck_status status; + switch (hdr->magic) + { + default: + status = MCHECK_HEAD; + break; + case MAGICFREE: + status = MCHECK_FREE; + break; + case MAGICWORD: + if (((char *) &hdr[1])[hdr->size] != MAGICBYTE) + status = MCHECK_TAIL; + else + status = MCHECK_OK; + break; + } + if (status != MCHECK_OK) + (*abortfunc) (status); + return status; } static void freehook __P ((__ptr_t)); @@ -59,7 +78,7 @@ { struct hdr *hdr = ((struct hdr *) ptr) - 1; checkhdr (hdr); - hdr->magic = 0; + hdr->magic = MAGICFREE; __free_hook = old_free_hook; free (hdr); __free_hook = freehook; @@ -109,14 +128,41 @@ return (__ptr_t) (hdr + 1); } +static void +mabort (status) + enum mcheck_status status; +{ + const char *msg; + switch (status) + { + case MCHECK_OK: + msg = "memory is consistent, library is buggy"; + break; + case MCHECK_HEAD: + msg = "memory clobbered before allocated block"; + break; + case MCHECK_TAIL: + msg = "memory clobbered past end of allocated block"; + break; + case MCHECK_FREE: + msg = "block freed twice"; + break; + default: + msg = "bogus mcheck_status, library is buggy"; + break; + } + __libc_fatal (msg); +} + +static int mcheck_used = 0; + int mcheck (func) - void (*func) __P ((void)); + void (*func) __P ((enum mcheck_status)); { extern void abort __P ((void)); - static int mcheck_used = 0; - abortfunc = (func != NULL) ? func : abort; + abortfunc = (func != NULL) ? func : &mabort; /* These hooks may not be safely inserted if malloc is already in use. */ if (!__malloc_initialized && !mcheck_used) @@ -131,4 +177,10 @@ } return mcheck_used ? 0 : -1; +} + +enum mcheck_status +mprobe (__ptr_t ptr) +{ + return mcheck_used ? checkhdr (ptr) : MCHECK_DISABLED; } diff -ruN glibc-1.07/malloc/mem-limits.h glibc-1.08.1/malloc/mem-limits.h --- glibc-1.07/malloc/mem-limits.h Thu Jan 6 01:25:51 1994 +++ glibc-1.08.1/malloc/mem-limits.h Tue Apr 19 18:52:43 1994 @@ -1,5 +1,5 @@ /* Includes for memory limit warnings. - Copyright (C) 1990, 1993 Free Software Foundation, Inc. + Copyright (C) 1990, 1993, 1994 Free Software Foundation, Inc. This file is part of the GNU C Library. Its master source is NOT part of @@ -24,6 +24,9 @@ #include #endif +/* Some systems need this before . */ +#include + #ifdef _LIBC #include @@ -98,6 +101,14 @@ /* Number of bytes of writable memory we can expect to be able to get */ static unsigned int lim_data; +#ifdef NO_LIM_DATA +static void +get_lim_data () +{ + lim_data = -1; +} +#else /* not NO_LIM_DATA */ + #ifdef USG static void @@ -157,3 +168,4 @@ } #endif /* BSD4_2 */ #endif /* not USG */ +#endif /* not NO_LIM_DATA */ diff -ruN glibc-1.07/malloc/memalign.c glibc-1.08.1/malloc/memalign.c --- glibc-1.07/malloc/memalign.c Wed Dec 8 15:59:41 1993 +++ glibc-1.08.1/malloc/memalign.c Wed Apr 20 17:55:57 1994 @@ -34,7 +34,7 @@ if (result == NULL) return NULL; adj = (unsigned long int) ((unsigned long int) ((char *) result - - (char *) NULL)) % alignment; + (char *) NULL)) % alignment; if (adj != 0) { struct alignlist *l; diff -ruN glibc-1.07/malloc/obstack.c glibc-1.08.1/malloc/obstack.c --- glibc-1.07/malloc/obstack.c Sat Aug 7 01:52:38 1993 +++ glibc-1.08.1/malloc/obstack.c Wed Feb 9 17:34:35 1994 @@ -1,5 +1,5 @@ /* obstack.c - subroutines used implicitly by object stack macros - Copyright (C) 1988, 1993 Free Software Foundation, Inc. + Copyright (C) 1988, 89, 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. @@ -87,9 +87,13 @@ /* Initialize an obstack H for use. Specify chunk size SIZE (0 means default). Objects start on multiples of ALIGNMENT (0 means use default). CHUNKFUN is the function to use to allocate chunks, - and FREEFUN the function to free them. */ + and FREEFUN the function to free them. -void + Return nonzero if successful, zero if out of memory. + To recover from an out of memory error, + free up some memory, then call this again. */ + +int _obstack_begin (h, size, alignment, chunkfun, freefun) struct obstack *h; int size; @@ -125,6 +129,12 @@ h->use_extra_arg = 0; chunk = h->chunk = CALL_CHUNKFUN (h, h -> chunk_size); + if (!chunk) + { + h->alloc_failed = 1; + return 0; + } + h->alloc_failed = 0; h->next_free = h->object_base = chunk->contents; h->chunk_limit = chunk->limit = (char *) chunk + h->chunk_size; @@ -131,9 +141,10 @@ chunk->prev = 0; /* The initial chunk now contains no empty object. */ h->maybe_empty_object = 0; + return 1; } -void +int _obstack_begin_1 (h, size, alignment, chunkfun, freefun, arg) struct obstack *h; int size; @@ -171,6 +182,12 @@ h->use_extra_arg = 1; chunk = h->chunk = CALL_CHUNKFUN (h, h -> chunk_size); + if (!chunk) + { + h->alloc_failed = 1; + return 0; + } + h->alloc_failed = 0; h->next_free = h->object_base = chunk->contents; h->chunk_limit = chunk->limit = (char *) chunk + h->chunk_size; @@ -177,6 +194,7 @@ chunk->prev = 0; /* The initial chunk now contains no empty object. */ h->maybe_empty_object = 0; + return 1; } /* Allocate a new current chunk for the obstack *H @@ -203,7 +221,14 @@ new_size = h->chunk_size; /* Allocate and initialize the new chunk. */ - new_chunk = h->chunk = CALL_CHUNKFUN (h, new_size); + new_chunk = CALL_CHUNKFUN (h, new_size); + if (!new_chunk) + { + h->alloc_failed = 1; + return; + } + h->alloc_failed = 0; + h->chunk = new_chunk; new_chunk->prev = old_chunk; new_chunk->limit = h->chunk_limit = (char *) new_chunk + new_size; diff -ruN glibc-1.07/malloc/obstack.h glibc-1.08.1/malloc/obstack.h --- glibc-1.07/malloc/obstack.h Sat Aug 7 01:52:42 1993 +++ glibc-1.08.1/malloc/obstack.h Tue Apr 5 04:26:18 1994 @@ -1,5 +1,5 @@ /* obstack.h - object stack macros - Copyright (C) 1988, 1992 Free Software Foundation, Inc. + Copyright (C) 1988, 89, 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. @@ -104,8 +104,8 @@ /* Don't do the contents of this file more than once. */ -#ifndef __OBSTACKS__ -#define __OBSTACKS__ +#ifndef __OBSTACK_H__ +#define __OBSTACK_H__ /* We use subtraction of (char *)0 instead of casting to int because on word-addressable machines a simple cast to int @@ -126,18 +126,15 @@ #if defined (__STDC__) && ! defined (offsetof) #if defined (__GNUC__) && defined (IN_GCC) /* On Next machine, the system's stddef.h screws up if included - after we have defined just ptrdiff_t, so include all of gstddef.h. + after we have defined just ptrdiff_t, so include all of stddef.h. Otherwise, define just ptrdiff_t, which is all we need. */ #ifndef __NeXT__ #define __need_ptrdiff_t #endif +#endif -/* While building GCC, the stddef.h that goes with GCC has this name. */ -#include "gstddef.h" -#else #include #endif -#endif #ifdef __STDC__ #define PTR_INT_TYPE ptrdiff_t @@ -169,6 +166,7 @@ chunk contains a zero-length object. This prevents freeing the chunk if we allocate a bigger chunk to replace it. */ + unsigned alloc_failed:1; /* chunk alloc func returned 0 */ }; /* Declare the external functions we use; they are in obstack.c. */ @@ -176,15 +174,15 @@ #ifdef __STDC__ extern void _obstack_newchunk (struct obstack *, int); extern void _obstack_free (struct obstack *, void *); -extern void _obstack_begin (struct obstack *, int, int, +extern int _obstack_begin (struct obstack *, int, int, void *(*) (), void (*) ()); -extern void _obstack_begin_1 (struct obstack *, int, int, +extern int _obstack_begin_1 (struct obstack *, int, int, void *(*) (), void (*) (), void *); #else extern void _obstack_newchunk (); extern void _obstack_free (); -extern void _obstack_begin (); -extern void _obstack_begin_1 (); +extern int _obstack_begin (); +extern int _obstack_begin_1 (); #endif #ifdef __STDC__ @@ -234,7 +232,7 @@ Note that this might not be the final address of the object because a new chunk might be needed to hold the final size. */ -#define obstack_base(h) ((h)->object_base) +#define obstack_base(h) ((h)->alloc_failed ? 0 : (h)->object_base) /* Size for allocating ordinary chunks. */ @@ -242,7 +240,7 @@ /* Pointer to next byte not yet allocated in current chunk. */ -#define obstack_next_free(h) ((h)->next_free) +#define obstack_next_free(h) ((h)->alloc_failed ? 0 : (h)->next_free) /* Mask specifying low bits that should be clear in address of an object. */ @@ -264,6 +262,12 @@ _obstack_begin_1 ((h), (size), (alignment), \ (void *(*) ()) (chunkfun), (void (*) ()) (freefun), (arg)) +#define obstack_chunkfun(h, newchunkfun) \ + ((h) -> chunkfun = (struct _obstack_chunk *(*)()) (newchunkfun)) + +#define obstack_freefun(h, newfreefun) \ + ((h) -> freefun = (void (*)()) (newfreefun)) + #define obstack_1grow_fast(h,achar) (*((h)->next_free)++ = achar) #define obstack_blank_fast(h,n) ((h)->next_free += (n)) @@ -281,6 +285,7 @@ #define obstack_object_size(OBSTACK) \ __extension__ \ ({ struct obstack *__o = (OBSTACK); \ + __o->alloc_failed ? 0 : \ (unsigned) (__o->next_free - __o->object_base); }) #define obstack_room(OBSTACK) \ @@ -288,19 +293,17 @@ ({ struct obstack *__o = (OBSTACK); \ (unsigned) (__o->chunk_limit - __o->next_free); }) -/* Note that the call to _obstack_newchunk is enclosed in (..., 0) - so that we can avoid having void expressions - in the arms of the conditional expression. - Casting the third operand to void was tried before, - but some compilers won't accept it. */ #define obstack_grow(OBSTACK,where,length) \ __extension__ \ ({ struct obstack *__o = (OBSTACK); \ int __len = (length); \ - ((__o->next_free + __len > __o->chunk_limit) \ - ? (_obstack_newchunk (__o, __len), 0) : 0); \ - bcopy (where, __o->next_free, __len); \ - __o->next_free += __len; \ + if (__o->next_free + __len > __o->chunk_limit) \ + _obstack_newchunk (__o, __len); \ + if (!__o->alloc_failed) \ + { \ + bcopy (where, __o->next_free, __len); \ + __o->next_free += __len; \ + } \ (void) 0; }) #define obstack_grow0(OBSTACK,where,length) \ @@ -307,19 +310,23 @@ __extension__ \ ({ struct obstack *__o = (OBSTACK); \ int __len = (length); \ - ((__o->next_free + __len + 1 > __o->chunk_limit) \ - ? (_obstack_newchunk (__o, __len + 1), 0) : 0), \ - bcopy (where, __o->next_free, __len), \ - __o->next_free += __len, \ - *(__o->next_free)++ = 0; \ + if (__o->next_free + __len + 1 > __o->chunk_limit) \ + _obstack_newchunk (__o, __len + 1); \ + if (!__o->alloc_failed) \ + { \ + bcopy (where, __o->next_free, __len); \ + __o->next_free += __len; \ + *(__o->next_free)++ = 0; \ + } \ (void) 0; }) #define obstack_1grow(OBSTACK,datum) \ __extension__ \ ({ struct obstack *__o = (OBSTACK); \ - ((__o->next_free + 1 > __o->chunk_limit) \ - ? (_obstack_newchunk (__o, 1), 0) : 0), \ - *(__o->next_free)++ = (datum); \ + if (__o->next_free + 1 > __o->chunk_limit) \ + _obstack_newchunk (__o, 1); \ + if (!__o->alloc_failed) \ + *(__o->next_free)++ = (datum); \ (void) 0; }) /* These assume that the obstack alignment is good enough for pointers or ints, @@ -329,17 +336,19 @@ #define obstack_ptr_grow(OBSTACK,datum) \ __extension__ \ ({ struct obstack *__o = (OBSTACK); \ - ((__o->next_free + sizeof (void *) > __o->chunk_limit) \ - ? (_obstack_newchunk (__o, sizeof (void *)), 0) : 0), \ - *((void **)__o->next_free)++ = ((void *)datum); \ + if (__o->next_free + sizeof (void *) > __o->chunk_limit) \ + _obstack_newchunk (__o, sizeof (void *)); \ + if (!__o->alloc_failed) \ + *((void **)__o->next_free)++ = ((void *)datum); \ (void) 0; }) #define obstack_int_grow(OBSTACK,datum) \ __extension__ \ ({ struct obstack *__o = (OBSTACK); \ - ((__o->next_free + sizeof (int) > __o->chunk_limit) \ - ? (_obstack_newchunk (__o, sizeof (int)), 0) : 0), \ - *((int *)__o->next_free)++ = ((int)datum); \ + if (__o->next_free + sizeof (int) > __o->chunk_limit) \ + _obstack_newchunk (__o, sizeof (int)); \ + if (!__o->alloc_failed) \ + *((int *)__o->next_free)++ = ((int)datum); \ (void) 0; }) #define obstack_ptr_grow_fast(h,aptr) (*((void **)(h)->next_free)++ = (void *)aptr) @@ -349,9 +358,10 @@ __extension__ \ ({ struct obstack *__o = (OBSTACK); \ int __len = (length); \ - ((__o->chunk_limit - __o->next_free < __len) \ - ? (_obstack_newchunk (__o, __len), 0) : 0); \ - __o->next_free += __len; \ + if (__o->chunk_limit - __o->next_free < __len) \ + _obstack_newchunk (__o, __len); \ + if (!__o->alloc_failed) \ + __o->next_free += __len; \ (void) 0; }) #define obstack_alloc(OBSTACK,length) \ @@ -377,16 +387,22 @@ #define obstack_finish(OBSTACK) \ __extension__ \ ({ struct obstack *__o1 = (OBSTACK); \ - void *value = (void *) __o1->object_base; \ - if (__o1->next_free == value) \ - __o1->maybe_empty_object = 1; \ - __o1->next_free \ - = __INT_TO_PTR ((__PTR_TO_INT (__o1->next_free)+__o1->alignment_mask)\ - & ~ (__o1->alignment_mask)); \ - ((__o1->next_free - (char *)__o1->chunk \ - > __o1->chunk_limit - (char *)__o1->chunk) \ - ? (__o1->next_free = __o1->chunk_limit) : 0); \ - __o1->object_base = __o1->next_free; \ + void *value; \ + if (__o1->alloc_failed) \ + value = 0; \ + else \ + { \ + value = (void *) __o1->object_base; \ + if (__o1->next_free == value) \ + __o1->maybe_empty_object = 1; \ + __o1->next_free \ + = __INT_TO_PTR ((__PTR_TO_INT (__o1->next_free)+__o1->alignment_mask)\ + & ~ (__o1->alignment_mask)); \ + if (__o1->next_free - (char *)__o1->chunk \ + > __o1->chunk_limit - (char *)__o1->chunk) \ + __o1->next_free = __o1->chunk_limit; \ + __o1->object_base = __o1->next_free; \ + } \ value; }) #define obstack_free(OBSTACK, OBJ) \ @@ -400,40 +416,51 @@ #else /* not __GNUC__ or not __STDC__ */ #define obstack_object_size(h) \ - (unsigned) ((h)->next_free - (h)->object_base) + (unsigned) ((h)->alloc_failed ? 0 : (h)->next_free - (h)->object_base) #define obstack_room(h) \ (unsigned) ((h)->chunk_limit - (h)->next_free) +/* Note that the call to _obstack_newchunk is enclosed in (..., 0) + so that we can avoid having void expressions + in the arms of the conditional expression. + Casting the third operand to void was tried before, + but some compilers won't accept it. */ + #define obstack_grow(h,where,length) \ ( (h)->temp = (length), \ (((h)->next_free + (h)->temp > (h)->chunk_limit) \ ? (_obstack_newchunk ((h), (h)->temp), 0) : 0), \ - bcopy (where, (h)->next_free, (h)->temp), \ - (h)->next_free += (h)->temp) + ((h)->alloc_failed ? 0 : \ + (bcopy (where, (h)->next_free, (h)->temp), \ + (h)->next_free += (h)->temp))) #define obstack_grow0(h,where,length) \ ( (h)->temp = (length), \ (((h)->next_free + (h)->temp + 1 > (h)->chunk_limit) \ ? (_obstack_newchunk ((h), (h)->temp + 1), 0) : 0), \ - bcopy (where, (h)->next_free, (h)->temp), \ + ((h)->alloc_failed ? 0 : \ + (bcopy (where, (h)->next_free, (h)->temp), \ (h)->next_free += (h)->temp, \ - *((h)->next_free)++ = 0) + *((h)->next_free)++ = 0))) #define obstack_1grow(h,datum) \ ( (((h)->next_free + 1 > (h)->chunk_limit) \ ? (_obstack_newchunk ((h), 1), 0) : 0), \ - *((h)->next_free)++ = (datum)) + ((h)->alloc_failed ? 0 : \ + (*((h)->next_free)++ = (datum)))) #define obstack_ptr_grow(h,datum) \ ( (((h)->next_free + sizeof (char *) > (h)->chunk_limit) \ ? (_obstack_newchunk ((h), sizeof (char *)), 0) : 0), \ - *((char **)(((h)->next_free+=sizeof(char *))-sizeof(char *))) = ((char *)datum)) + ((h)->alloc_failed ? 0 : \ + (*((char **)(((h)->next_free+=sizeof(char *))-sizeof(char *))) = ((char *)datum)))) #define obstack_int_grow(h,datum) \ ( (((h)->next_free + sizeof (int) > (h)->chunk_limit) \ ? (_obstack_newchunk ((h), sizeof (int)), 0) : 0), \ - *((int *)(((h)->next_free+=sizeof(int))-sizeof(int))) = ((int)datum)) + ((h)->alloc_failed ? 0 : \ + (*((int *)(((h)->next_free+=sizeof(int))-sizeof(int))) = ((int)datum)))) #define obstack_ptr_grow_fast(h,aptr) (*((char **)(h)->next_free)++ = (char *)aptr) #define obstack_int_grow_fast(h,aint) (*((int *)(h)->next_free)++ = (int)aint) @@ -442,7 +469,8 @@ ( (h)->temp = (length), \ (((h)->chunk_limit - (h)->next_free < (h)->temp) \ ? (_obstack_newchunk ((h), (h)->temp), 0) : 0), \ - (h)->next_free += (h)->temp) + ((h)->alloc_failed ? 0 : \ + ((h)->next_free += (h)->temp))) #define obstack_alloc(h,length) \ (obstack_blank ((h), (length)), obstack_finish ((h))) @@ -454,7 +482,8 @@ (obstack_grow0 ((h), (where), (length)), obstack_finish ((h))) #define obstack_finish(h) \ -( ((h)->next_free == (h)->object_base \ +( (h)->alloc_failed ? 0 : \ + (((h)->next_free == (h)->object_base \ ? (((h)->maybe_empty_object = 1), 0) \ : 0), \ (h)->temp = __PTR_TO_INT ((h)->object_base), \ @@ -465,7 +494,7 @@ > (h)->chunk_limit - (char *)(h)->chunk) \ ? ((h)->next_free = (h)->chunk_limit) : 0), \ (h)->object_base = (h)->next_free, \ - __INT_TO_PTR ((h)->temp)) + __INT_TO_PTR ((h)->temp))) #ifdef __STDC__ #define obstack_free(h,obj) \ @@ -485,4 +514,4 @@ #endif /* not __GNUC__ or not __STDC__ */ -#endif /* not __OBSTACKS__ */ +#endif /* not __OBSTACK_H__ */ diff -ruN glibc-1.07/malloc/realloc.c glibc-1.08.1/malloc/realloc.c --- glibc-1.07/malloc/realloc.c Fri Oct 22 03:58:03 1993 +++ glibc-1.08.1/malloc/realloc.c Thu Mar 3 17:55:29 1994 @@ -1,5 +1,5 @@ /* Change the size of a block allocated by `malloc'. - Copyright 1990, 1991, 1992, 1993 Free Software Foundation, Inc. + 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 @@ -153,6 +153,10 @@ _heapinfo[block + blocks].busy.info.size = _heapinfo[block].busy.info.size - blocks; _heapinfo[block].busy.info.size = blocks; + /* We have just created a new chunk by splitting a chunk in two. + Now we will free this chunk; increment the statistics counter + so it doesn't become wrong when _free_internal decrements it. */ + ++_chunks_used; _free_internal (ADDRESS (block + blocks)); result = ptr; } diff -ruN glibc-1.07/manual/Makefile glibc-1.08.1/manual/Makefile --- glibc-1.07/manual/Makefile Thu Dec 23 01:47:19 1993 +++ glibc-1.08.1/manual/Makefile Thu Jan 27 17:17:23 1994 @@ -1,6 +1,6 @@ # Makefile for the GNU C Library manual. -# 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 @@ -18,7 +18,8 @@ # not, write to the Free Software Foundation, Inc., 675 Mass Ave, # Cambridge, MA 02139, USA. -export subdir := manual +subdir := manual +export subdir := $(subdir) .PHONY: all dvi info all: dvi info @@ -44,7 +45,7 @@ define find-includes (echo '$(@F) :=' \\ ;\ awk '$$1 == "@include" { print $$2 " \\" }' $^) > $@.new -mv $@.new $@ +mv -f $@.new $@ endef libc.dvi libc.info: $(chapters) summary.texi $(chapters-incl) @@ -66,7 +67,7 @@ -e 's,/\* *,/* @r{,g' -e 's, *\*/,} */,' \ -e 's/\(@[a-z][a-z]*\)@{\([^}]*\)@}/\1{\2}/'\ $< | expand > $@.new - mv $@.new $@ + mv -f $@.new $@ minimal-dist = summary.awk move-if-change libc.texinfo $(chapters) \ @@ -96,20 +97,23 @@ %.Z: % compress -c $< > $@.new - mv $@.new $@ -%.z: % + mv -f $@.new $@ +%.gz: % gzip -9 -c $< > $@.new - mv $@.new $@ + mv -f $@.new $@ %.uu: % uuencode $< < $< > $@.new - mv $@.new $@ + mv -f $@.new $@ -.PHONY: mostlyclean distclean realclean clean subdir_clean -subdir_clean: clean -distclean clean: mostlyclean +# The parent makefile sometimes invokes us with targets `subdir_REAL-TARGET'. +subdir_%: % ; + +.PHONY: mostlyclean distclean realclean clean mostlyclean: -rm -f libc.dvi libc.info* -realclean: clean +clean: mostlyclean +distclean: clean +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 @@ -145,7 +149,7 @@ $(dir $<)$(notdir $<) $(infodir) .PHONY: dist -dist: glibc-doc-$(edition).tar.z +dist: # glibc-doc-$(edition).tar.gz ifneq (,$(wildcard ../Make-dist)) dist: ../Make-dist @@ -168,6 +172,9 @@ stubs: $(common-objpfx)stub-manual $(common-objpfx)stub-manual: cp /dev/null $@ + +# The top-level glibc Makefile expects subdir_install to update the stubs file. +subdir_install: stubs # Get rid of these variables if they came from the parent. diff -ruN glibc-1.07/manual/conf.texi glibc-1.08.1/manual/conf.texi --- glibc-1.07/manual/conf.texi Mon Jul 26 19:22:18 1993 +++ glibc-1.08.1/manual/conf.texi Tue Feb 8 20:23:13 1994 @@ -461,7 +461,7 @@ @item _SC_PAGESIZE Inquire about the virtual memory page size of the machine. @code{getpagesize} returns the same value. -@xref{XXX getpagesize}. +@c @xref{XXX getpagesize}. !!! ??? @end table @node Examples of Sysconf diff -ruN glibc-1.07/manual/examples/inetsrv.c glibc-1.08.1/manual/examples/inetsrv.c --- glibc-1.07/manual/examples/inetsrv.c Sun Jun 20 19:15:00 1993 +++ glibc-1.08.1/manual/examples/inetsrv.c Sun Feb 13 22:18:16 1994 @@ -39,7 +39,6 @@ { extern int make_socket (unsigned short int port); int sock; - int status; fd_set active_fd_set, read_fd_set; int i; struct sockaddr_in clientname; @@ -74,9 +73,10 @@ if (i == sock) { /* Connection request on original socket. */ + int new; size = sizeof (clientname); - if (accept (sock, - (struct sockaddr *) &clientname, &size) < 0) + new = accept (sock, (struct sockaddr *) &clientname, &size); + if (new < 0) { perror ("accept"); exit (EXIT_FAILURE); @@ -85,7 +85,7 @@ "Server: connect from host %s, port %hd.\n", inet_ntoa (clientname.sin_addr), ntohs (clientname.sin_port)); - FD_SET (status, &active_fd_set); + FD_SET (new, &active_fd_set); } else { diff -ruN glibc-1.07/manual/inetsrv.c.texi glibc-1.08.1/manual/inetsrv.c.texi --- glibc-1.07/manual/inetsrv.c.texi Sun Jun 20 19:56:32 1993 +++ glibc-1.08.1/manual/inetsrv.c.texi Mon Feb 14 06:49:53 1994 @@ -39,7 +39,6 @@ @{ extern int make_socket (unsigned short int port); int sock; - int status; fd_set active_fd_set, read_fd_set; int i; struct sockaddr_in clientname; @@ -74,9 +73,10 @@ if (i == sock) @{ /* @r{Connection request on original socket.} */ + int new; size = sizeof (clientname); - if (accept (sock, - (struct sockaddr *) &clientname, &size) < 0) + new = accept (sock, (struct sockaddr *) &clientname, &size); + if (new < 0) @{ perror ("accept"); exit (EXIT_FAILURE); @@ -85,7 +85,7 @@ "Server: connect from host %s, port %hd.\n", inet_ntoa (clientname.sin_addr), ntohs (clientname.sin_port)); - FD_SET (status, &active_fd_set); + FD_SET (new, &active_fd_set); @} else @{ diff -ruN glibc-1.07/manual/intro.texi glibc-1.08.1/manual/intro.texi --- glibc-1.07/manual/intro.texi Mon Aug 30 19:40:09 1993 +++ glibc-1.08.1/manual/intro.texi Sun Feb 13 18:10:03 1994 @@ -712,9 +712,9 @@ exponential functions on floating-point numbers. @item -@ref{Low-Level Arithmetic Functions}, describes functions for simple -arithmetic, analysis of floating-point values, and reading numbers from -strings. +@ref{Arithmetic,, Low-Level Arithmetic Functions}, describes functions +for simple arithmetic, analysis of floating-point values, and reading +numbers from strings. @item @ref{Searching and Sorting}, contains information about functions diff -ruN glibc-1.07/manual/lgpl.texinfo glibc-1.08.1/manual/lgpl.texinfo --- glibc-1.07/manual/lgpl.texinfo Sun Jun 20 22:00:04 1993 +++ glibc-1.08.1/manual/lgpl.texinfo Mon May 9 21:20:24 1994 @@ -117,7 +117,7 @@ @center TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION @end ifinfo -@enumerate +@enumerate 0 @item This License Agreement applies to any software library which contains a notice placed by the copyright holder or other authorized diff -ruN glibc-1.07/manual/maint.texi glibc-1.08.1/manual/maint.texi --- glibc-1.07/manual/maint.texi Tue Dec 28 02:23:11 1993 +++ glibc-1.08.1/manual/maint.texi Thu May 19 16:17:11 1994 @@ -54,9 +54,11 @@ i386-@var{anything}-sysv4 i386-sequent-bsd m68k-hp-bsd4.3 -m68k-sony-newsos +m68k-sony-newsos3 +m68k-sony-newsos4 m68k-sun-sunos4.@var{n} mips-dec-ultrix4.@var{n} +mips-sgi-irix4.@var{n} sparc-sun-solaris2.@var{n} sparc-sun-sunos4.@var{n} @end smallexample @@ -83,7 +85,10 @@ @table @samp @item --with-gnu-ld Use this option if you plan to use GNU @code{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 @code{ld}; so if you +configure for GNU @code{ld} you must use GNU @code{ld} @emph{every time} +you link with the GNU C Library, and when building it. @item --with-gnu-as Use this option if you plan to use the GNU assembler, @code{gas}, when @@ -115,9 +120,9 @@ configure, you will have to specify a directory for it, like this: @smallexample -mkdir ../hp320 -cd ../hp320 -../src/configure hp320-bsd4.3 +mkdir sun4 +cd sun4 +../configure sparc-sun-sunos4.1 @end smallexample @noindent @@ -142,7 +147,11 @@ library, and define in that file the parameters you want to specify. @file{configparms} should @strong{not} be an edited copy of @file{Makeconfig}; specify only the parameters that you want to -override. +override. To see how to set these parameters, find the section of +@file{Makeconfig} that says ``These are the configuration variables.'' +Then for each parameter that you want to change, copy the definition +from @file{Makeconfig} to your new @file{configparms} file, and change +the value as appropriate for your system. 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. @@ -887,6 +896,49 @@ was written by Roland McGrath and @value{tege}. The multi-precision integer functions used in that function are taken from GNU MP, which was contributed by @value{tege}. + +@item +The code to support Sun RPC is taken verbatim from Sun's +@w{@sc{rpcsrc-4.0}} distribution, and is covered by this copyright: + +@quotation +@display +Copyright @copyright{} 1984, Sun Microsystems, Inc. +@end display + +Sun RPC is a product of Sun Microsystems, Inc. and is provided for +unrestricted use provided that this legend is included on all tape media +and as a part of the software program in whole or part. Users may copy +or modify Sun RPC without charge, but are not authorized to license or +distribute it to anyone else except as part of a product or program +developed by the user. + +@sc{sun rpc is provided as is with no warranties of any kind including the +warranties of design, merchantibility and fitness for a particular +purpose, or arising from a course of dealing, usage or trade practice.} + +Sun RPC is provided with no support and without any obligation on the +part of Sun Microsystems, Inc. to assist in its use, correction, +modification or enhancement. + +@sc{sun microsystems, inc. shall have no liability with respect to the +infringement of copyrights, trade secrets or any patents by sun rpc +or any part thereof.} + +In no event will Sun Microsystems, Inc. be liable for any lost revenue +or profits or other special, indirect and consequential damages, even if +Sun has been advised of the possibility of such damages. + +@display +Sun Microsystems, Inc. +2550 Garcia Avenue +Mountain View, California 94043 +@end display +@end quotation + +@item +The port to SGI machines running Irix 4 (@code{mips-sgi-irix4}) was +contributed by Tom Quinn. @end itemize @c @bye diff -ruN glibc-1.07/manual/memory.texi glibc-1.08.1/manual/memory.texi --- glibc-1.07/manual/memory.texi Mon Aug 30 20:10:39 1993 +++ glibc-1.08.1/manual/memory.texi Wed Feb 9 08:56:10 1994 @@ -802,8 +802,15 @@ @comment obstack.h @comment GNU -@deftypefun void obstack_init (struct obstack *@var{obstack_ptr}) -Initialize obstack @var{obstack_ptr} for allocation of objects. +@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 +@code{obstack_chunk_alloc} function that calls @code{exit} +(@pxref{Program Termination}) or @code{longjmp} (@pxref{Non-Local +Exits}) when out of memory, you can safely ignore the value that +@code{obstack_init} returns. @end deftypefun Here are two examples of how to allocate the space for an obstack and @@ -840,6 +847,15 @@ 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. + +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 +@code{obstack_chunk_alloc} returns one. In that case, it has not +changed the amount of memory allocated in the obstack. If you supply an +@code{obstack_chunk_alloc} function that calls @code{exit} +(@pxref{Program Termination}) or @code{longjmp} (@pxref{Non-Local +Exits}) when out of memory, then @code{obstack_alloc} will never return +a null pointer. @end deftypefun For example, here is a function that allocates a copy of a string @var{str} @@ -865,7 +881,8 @@ @comment GNU @deftypefun {void *} obstack_copy (struct obstack *@var{obstack_ptr}, void *@var{address}, size_t @var{size}) This allocates a block and initializes it by copying @var{size} -bytes of data starting at @var{address}. +bytes of data starting at @var{address}. It can return a null pointer +under the same conditions as @code{obstack_alloc}. @end deftypefun @comment obstack.h @@ -1044,6 +1061,9 @@ Once you have finished the object, the obstack is available for ordinary allocation or for growing another object. + +This function can return a null pointer under the same conditions as +@code{obstack_alloc} (@pxref{Allocation in an Obstack}). @end deftypefun When you build an object by growing it, you will probably need to know @@ -1271,13 +1291,6 @@ arguments will not work! It is necessary that @code{obstack_chunk_alloc} or @code{obstack_chunk_free}, alone, expand into a function name if it is not itself a function name. - -The function that actually implements @code{obstack_chunk_alloc} cannot -return ``failure'' in any fashion, because the obstack library is not -prepared to handle failure. Therefore, @code{malloc} itself is not -suitable. If the function cannot obtain space, it should either -terminate the process (@pxref{Program Termination}) or do a nonlocal -exit using @code{longjmp} (@pxref{Non-Local Exits}). If you allocate chunks with @code{malloc}, the chunk size should be a power of 2. The default chunk size, 4096, was chosen because it is long diff -ruN glibc-1.07/manual/signal.texi glibc-1.08.1/manual/signal.texi --- glibc-1.07/manual/signal.texi Sun Sep 5 10:06:37 1993 +++ glibc-1.08.1/manual/signal.texi Sun Feb 6 16:05:24 1994 @@ -835,7 +835,7 @@ @file{string.h}. @end deftypefun -@comment stdio.h +@comment signal.h @comment BSD @deftypefun void psignal (int @var{signum}, const char *@var{message}) This function prints a message describing the signal @var{signum} to the @@ -851,7 +851,7 @@ to @var{signum}. @pindex stdio.h -This function is a BSD feature, declared in the header file @file{stdio.h}. +This function is a BSD feature, declared in the header file @file{signal.h}. @end deftypefun @vindex sys_siglist diff -ruN glibc-1.07/manual/socket.texi glibc-1.08.1/manual/socket.texi --- glibc-1.07/manual/socket.texi Thu Jun 24 20:35:35 1993 +++ glibc-1.08.1/manual/socket.texi Thu Feb 10 02:07:29 1994 @@ -1828,8 +1828,8 @@ to control inclusion of routing information on output. @menu -* Sending Data:: Sending data with @code{write}. -* Receiving Data:: Reading data with @code{read}. +* Sending Data:: Sending data with @code{send}. +* Receiving Data:: Reading data with @code{recv}. * Socket Data Options:: Using @code{send} and @code{recv}. @end menu diff -ruN glibc-1.07/manual/stamp-summary glibc-1.08.1/manual/stamp-summary --- glibc-1.07/manual/stamp-summary Thu Jan 6 21:47:39 1994 +++ glibc-1.08.1/manual/stamp-summary Thu May 19 03:47:34 1994 @@ -1 +1 @@ -Thu Jan 6 21:47:36 EST 1994 +Thu May 19 03:47:31 EDT 1994 diff -ruN glibc-1.07/manual/stdio.texi glibc-1.08.1/manual/stdio.texi --- glibc-1.07/manual/stdio.texi Thu Jan 6 17:19:04 1994 +++ glibc-1.08.1/manual/stdio.texi Mon May 23 20:17:12 1994 @@ -214,9 +214,10 @@ @deftypevr Macro int FOPEN_MAX The value of this macro is an integer constant expression that represents the minimum number of streams that the implementation -guarantees can be open simultaneously. The value of this constant is at -least eight, which includes the three standard streams @code{stdin}, -@code{stdout}, and @code{stderr}. +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}. @end deftypevr @comment stdio.h @@ -879,11 +880,6 @@ Print an integer as an unsigned decimal number. @xref{Integer Conversions}, for details. -@item @samp{%Z} -Print an integer as an unsigned decimal number, assuming it was passed -with type @code{size_t}. @xref{Integer Conversions}, for details. -This is a GNU extension. - @item @samp{%x}, @samp{%X} Print an integer as an unsigned hexadecimal number. @samp{%x} uses lower-case letters and @samp{%X} uses upper-case. @xref{Integer @@ -938,7 +934,7 @@ @subsection Integer Conversions This section describes the options for the @samp{%d}, @samp{%i}, -@samp{%o}, @samp{%u}, @samp{%x}, @samp{%X}, and @samp{%Z} conversion +@samp{%o}, @samp{%u}, @samp{%x}, and @samp{%X} conversion specifications. These conversions print integers in various formats. The @samp{%d} and @samp{%i} conversion specifications both print an @@ -946,8 +942,7 @@ @samp{%u}, and @samp{%x} print the argument as an unsigned octal, decimal, or hexadecimal number (respectively). The @samp{%X} conversion specification is just like @samp{%x} except that it uses the characters -@samp{ABCDEF} as digits instead of @samp{abcdef}. @samp{%Z} is like -@samp{%u} but expects an argument of type @code{size_t}. +@samp{ABCDEF} as digits instead of @samp{abcdef}. The following flags are meaningful: @@ -1013,11 +1008,10 @@ 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}.) -@end table -The modifiers for argument type are not applicable to @samp{%Z}, since -the sole purpose of @samp{%Z} is to specify the data type -@code{size_t}. +@item Z +Specifies that the argument is a @code{size_t}. This is a GNU extension. +@end table Here is an example. Using the template string: @@ -2071,7 +2065,7 @@ pattern, you may be better off using a tool such as Flex to generate a lexical scanner, or Bison to generate a parser, rather than using @code{scanf}. For more information about this, see @ref{Top, Flex, -Flex, flex.info, Flex: The Lexical Scanner Generator} and @ref{Top, +Flex, flex.info, Flex: The Lexical Scanner Generator}, and @ref{Top, Bison, Bison, bison.info, The Bison Reference Manual}. @node Input Conversion Syntax @@ -3394,7 +3388,7 @@ When you create a custom stream, you must specify the cookie pointer, and also the four hook functions stored in a structure of type -@code{struct cookie_io_functions}. +@code{cookie_io_functions_t}. These facilities are declared in @file{stdio.h}. @pindex stdio.h @@ -3401,23 +3395,23 @@ @comment stdio.h @comment GNU -@deftp {Data Type} {struct cookie_io_functions} +@deftp {Data Type} {cookie_io_functions_t} This is a structure type that holds the functions that define the communications protocol between the stream and its cookie. It has the following members: @table @code -@item cookie_read_function *read +@item cookie_read_function_t *read This is the function that reads data from the cookie. If the value is a null pointer instead of a function, then read operations on ths stream always return @code{EOF}. -@item cookie_write_function *write +@item cookie_write_function_t *write This is the function that writes data to the cookie. If the value is a null pointer instead of a function, then data written to the stream is discarded. -@item cookie_seek_function *seek +@item cookie_seek_function_t *seek This is the function that performs the equivalent of file positioning on the cookie. If the value is a null pointer instead of a function, calls to @code{fseek} on this stream can only seek to locations within the @@ -3424,7 +3418,7 @@ buffer; any attempt to seek outside the buffer will return an @code{ESPIPE} error. -@item cookie_close_function *close +@item cookie_close_function_t *close This function performs any appropriate cleanup on the cookie when closing the stream. If the value is a null pointer instead of a function, nothing special is done to close the cookie when the stream is @@ -3434,7 +3428,7 @@ @comment stdio.h @comment GNU -@deftypefun {FILE *} fopencookie (void *@var{cookie}, const char *@var{opentype}, struct cookie_functions @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. The @var{opentype} argument is interpreted as for @code{fopen}; diff -ruN glibc-1.07/manual/summary.texi glibc-1.08.1/manual/summary.texi --- glibc-1.07/manual/summary.texi Wed Dec 29 18:34:37 1993 +++ glibc-1.08.1/manual/summary.texi Thu May 19 03:47:31 1994 @@ -438,6 +438,11 @@ @file{stdio.h} (GNU): @ref{Hook Functions}. +@comment cookie_io_functions_t +@item cookie_io_functions_t + +@file{stdio.h} (GNU): @ref{Streams and Cookies}. + @comment cookie_read_function @item cookie_read_function @@ -1430,7 +1435,7 @@ @file{unistd.h} (POSIX.1): @ref{Testing File Access}. @comment fopencookie -@item FILE * fopencookie (void *@var{cookie}, const char *@var{opentype}, struct cookie_functions @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}. @@ -2780,7 +2785,7 @@ @file{obstack.h} (GNU): @ref{Growing Objects}. @comment obstack_init -@item void obstack_init (struct obstack *@var{obstack_ptr}) +@item int obstack_init (struct obstack *@var{obstack_ptr}) @file{obstack.h} (GNU): @ref{Preparing for Obstacks}. @@ -3377,7 +3382,7 @@ @comment psignal @item void psignal (int @var{signum}, const char *@var{message}) -@file{stdio.h} (BSD): @ref{Signal Messages}. +@file{signal.h} (BSD): @ref{Signal Messages}. @comment P_tmpdir @item char * P_tmpdir @@ -3980,7 +3985,7 @@ @file{unistd.h} (BSD): @ref{Host Identification}. @comment setitimer -@item int setitimer (int @var{which}, struct itimerval *@var{old}, struct itimerval *@var{new}) +@item int setitimer (int @var{which}, struct itimerval *@var{new}, struct itimerval *@var{old}) @file{sys/time.h} (BSD): @ref{Setting an Alarm}. @@ -4853,11 +4858,6 @@ @item unsigned long int strtoul (const char *@var{string}, char **@var{tailptr}, int @var{base}) @file{stdlib.h} (ANSI): @ref{Parsing of Integers}. - -@comment struct cookie_io_functions -@item struct cookie_io_functions - -@file{stdio.h} (GNU): @ref{Streams and Cookies}. @comment struct dirent @item struct dirent diff -ruN glibc-1.07/manual/texinfo.tex glibc-1.08.1/manual/texinfo.tex --- glibc-1.07/manual/texinfo.tex Sat Dec 25 22:32:06 1993 +++ glibc-1.08.1/manual/texinfo.tex Tue May 10 02:30:20 1994 @@ -1,6 +1,6 @@ %% TeX macros to handle texinfo files -% Copyright (C) 1985, 86, 88, 90, 91, 92, 1993 Free Software Foundation, Inc. +% Copyright (C) 1985, 86, 88, 90, 91, 92, 93, 1994 Free Software Foundation, Inc. %This texinfo.tex file is free software; you can redistribute it and/or %modify it under the terms of the GNU General Public License as @@ -22,7 +22,9 @@ %You are forbidden to forbid anyone else to use, share and improve %what you give them. Help stamp out software-hoarding! -\def\texinfoversion{2.118} +% This automatically updates the version number based on RCS. +\def\deftexinfoversion$#1: #2 ${\def\texinfoversion{#2}} +\deftexinfoversion$Revision: 2.126 $ \message{Loading texinfo package [Version \texinfoversion]:} % Print the version number if in a .fmt file. @@ -30,6 +32,7 @@ % Save some parts of plain tex whose names we will redefine. +\let\ptextilde=\~ \let\ptexlbrace=\{ \let\ptexrbrace=\} \let\ptexdots=\dots @@ -45,6 +48,7 @@ \let\ptexL=\L \def\tie{\penalty 10000\ } % Save plain tex definition of ~. +\let\~ = \tie % And make it available as @~. \message{Basics,} \chardef\other=12 @@ -53,6 +57,19 @@ % starts a new line in the output. \newlinechar = `^^J +% Set up fixed words for English. +\ifx\putwordChapter\undefined{\gdef\putwordChapter{Chapter}}\fi% +\def\putwordInfo{Info}% +\ifx\putwordSee\undefined{\gdef\putwordSee{See}}\fi% +\ifx\putwordsee\undefined{\gdef\putwordsee{see}}\fi% +\ifx\putwordfile\undefined{\gdef\putwordfile{file}}\fi% +\ifx\putwordpage\undefined{\gdef\putwordpage{page}}\fi% +\ifx\putwordsection\undefined{\gdef\putwordsection{section}}\fi% +\ifx\putwordSection\undefined{\gdef\putwordSection{Section}}\fi% +\ifx\putwordTableofContents\undefined{\gdef\putwordTableofContents{Table of Contents}}\fi% +\ifx\putwordShortContents\undefined{\gdef\putwordShortContents{Short Contents}}\fi% +\ifx\putwordAppendix\undefined{\gdef\putwordAppendix{Appendix}}\fi% + % Ignore a token. % \def\gobble#1{} @@ -297,13 +314,13 @@ % Single-spacing is done by various environments (specifically, in % \nonfillstart and \quotations). -\newskip\singlespaceskip \singlespaceskip = \baselineskip +\newskip\singlespaceskip \singlespaceskip = 12.5pt \def\singlespace{% -% Why was this kern here? It messes up equalizing space above and below -% environments. --karl, 6may93 -%{\advance \baselineskip by -\singlespaceskip -%\kern \baselineskip}% -\baselineskip=\singlespaceskip + % Why was this kern here? It messes up equalizing space above and below + % environments. --karl, 6may93 + %{\advance \baselineskip by -\singlespaceskip + %\kern \baselineskip}% + \setleading \singlespaceskip } %% Simple single-character @ commands @@ -389,8 +406,8 @@ \obeylines \fi % - % We do @comment here in case we are called inside an environment, - % such as @example, where each end-of-line in the input causes an + % Do @comment since we are called inside an environment such as + % @example, where each end-of-line in the input causes an % end-of-line in the output. We don't want the end-of-line after % the `@group' to put extra space in the output. Since @group % should appear on a line by itself (according to the Texinfo @@ -460,7 +477,7 @@ % @dots{} output some dots -\def\dots{.$\,$.$\,$.\:} +\def\dots{$\ldots$} % @page forces the start of a new page @@ -584,6 +601,8 @@ \let\up = \relax \let\set = \relax \let\clear = \relax + \let\item = \relax + \let\message = \relax } % Ignore @ignore ... @end ignore. @@ -819,15 +838,15 @@ \def\donoderef{\ifx\lastnode\relax\else \expandafter\expandafter\expandafter\setref{\lastnode}\fi -\let\lastnode=\relax} +\global\let\lastnode=\relax} \def\unnumbnoderef{\ifx\lastnode\relax\else \expandafter\expandafter\expandafter\unnumbsetref{\lastnode}\fi -\let\lastnode=\relax} +\global\let\lastnode=\relax} \def\appendixnoderef{\ifx\lastnode\relax\else \expandafter\expandafter\expandafter\appendixsetref{\lastnode}\fi -\let\lastnode=\relax} +\global\let\lastnode=\relax} \let\refill=\relax @@ -846,7 +865,7 @@ \outer\def\bye{\pagealignmacro\tracingstats=1\ptexend} \def\inforef #1{\inforefzzz #1,,,,**} -\def\inforefzzz #1,#2,#3,#4**{See Info file \file{\ignorespaces #3{}}, +\def\inforefzzz #1,#2,#3,#4**{\putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}}, node \samp{\ignorespaces#1{}}} \message{fonts,} @@ -1504,7 +1523,7 @@ \def\itemize{\parsearg\itemizezzz} \def\itemizezzz #1{% - \begingroup % ended by the @end itemize + \begingroup % ended by the @end itemsize \itemizey {#1}{\Eitemize} } @@ -1712,6 +1731,32 @@ \def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}} \def\indexdummies{% +% Take care of the plain tex accent commands. +\def\"{\realbackslash "}% +\def\`{\realbackslash `}% +\def\'{\realbackslash '}% +\def\^{\realbackslash ^}% +\def\~{\realbackslash ~}% +\def\={\realbackslash =}% +\def\b{\realbackslash b}% +\def\c{\realbackslash c}% +\def\d{\realbackslash d}% +\def\u{\realbackslash u}% +\def\v{\realbackslash v}% +\def\H{\realbackslash H}% +% Take care of the plain tex special European modified letters. +\def\oe{\realbackslash oe}% +\def\ae{\realbackslash ae}% +\def\aa{\realbackslash aa}% +\def\OE{\realbackslash OE}% +\def\AE{\realbackslash AE}% +\def\AA{\realbackslash AA}% +\def\o{\realbackslash o}% +\def\O{\realbackslash O}% +\def\l{\realbackslash l}% +\def\L{\realbackslash L}% +\def\ss{\realbackslash ss}% +% Take care of texinfo commands likely to appear in an index entry. \def\_{{\realbackslash _}}% \def\w{\realbackslash w }% \def\bf{\realbackslash bf }% @@ -1749,6 +1794,31 @@ \def\indexdummydots{...} \def\indexnofonts{% +% Just ignore accents. +\let\"=\indexdummyfont +\let\`=\indexdummyfont +\let\'=\indexdummyfont +\let\^=\indexdummyfont +\let\~=\indexdummyfont +\let\==\indexdummyfont +\let\b=\indexdummyfont +\let\c=\indexdummyfont +\let\d=\indexdummyfont +\let\u=\indexdummyfont +\let\v=\indexdummyfont +\let\H=\indexdummyfont +% Take care of the plain tex special European modified letters. +\def\oe{oe}% +\def\ae{ae}% +\def\aa{aa}% +\def\OE{OE}% +\def\AE{AE}% +\def\AA{AA}% +\def\o{o}% +\def\O{O}% +\def\l{l}% +\def\L{L}% +\def\ss{ss}% \let\w=\indexdummyfont \let\t=\indexdummyfont \let\r=\indexdummyfont @@ -2223,7 +2293,7 @@ \gdef\thischaptername{#1}% % We don't substitute the actual chapter name into \thischapter % because we don't want its macros evaluated now. -\xdef\thischapter{Chapter \the\chapno: \noexpand\thischaptername}% +\xdef\thischapter{\putwordChapter{} \the\chapno: \noexpand\thischaptername}% {\chapternofonts% \edef\temp{{\realbackslash chapentry {#1}{\the\chapno}{\noexpand\folio}}}% \escapechar=`\\% @@ -2239,13 +2309,13 @@ \def\appendixzzz #1{\seccheck{appendix}% \secno=0 \subsecno=0 \subsubsecno=0 \global\advance \appendixno by 1 \message{Appendix \appendixletter}% -\chapmacro {#1}{Appendix \appendixletter}% +\chapmacro {#1}{\putwordAppendix{} \appendixletter}% \gdef\thissection{#1}% \gdef\thischaptername{#1}% -\xdef\thischapter{Appendix \appendixletter: \noexpand\thischaptername}% +\xdef\thischapter{\putwordAppendix{} \appendixletter: \noexpand\thischaptername}% {\chapternofonts% \edef\temp{{\realbackslash chapentry - {#1}{Appendix \appendixletter}{\noexpand\folio}}}% + {#1}{\putwordAppendix{} \appendixletter}{\noexpand\folio}}}% \escapechar=`\\% \write \contentsfile \temp % \appendixnoderef % @@ -2611,7 +2681,7 @@ % Normal (long) toc. \outer\def\contents{% - \startcontents{Table of Contents}% + \startcontents{\putwordTableofContents}% \input \jobname.toc \endgroup \vfill \eject @@ -2619,7 +2689,7 @@ % And just the chapters. \outer\def\summarycontents{% - \startcontents{Short Contents}% + \startcontents{\putwordShortContents}% % \let\chapentry = \shortchapentry \let\unnumbchapentry = \shortunnumberedentry @@ -2658,7 +2728,7 @@ % We could simplify the code here by writing out an \appendixentry % command in the toc file for appendices, instead of using \chapentry % for both, but it doesn't seem worth it. -\setbox0 = \hbox{\shortcontrm Appendix } +\setbox0 = \hbox{\shortcontrm \putwordAppendix } \newdimen\shortappendixwidth \shortappendixwidth = \wd0 \def\shortchaplabel#1{% @@ -2812,6 +2882,7 @@ \catcode`\>=12 \escapechar=`\\ % +\let\~=\ptextilde \let\{=\ptexlbrace \let\}=\ptexrbrace \let\.=\ptexdot @@ -2986,9 +3057,9 @@ \let\Esmallexample = \nonfillfinish % % Smaller interline space and fonts for small examples. - \baselineskip 10pt + \setleading{10pt}% \indexfonts \tt - \rawbackslash % output the \ character from the current font + \rawbackslash % make \ output the \ character from the current font (tt) \gobble } @@ -3533,13 +3604,13 @@ % file, #5 the name of the printed manual. All but the node name can be % omitted. % -\def\pxref#1{see \xrefX[#1,,,,,,,]} -\def\xref#1{See \xrefX[#1,,,,,,,]} +\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% @@ -3569,10 +3640,10 @@ % the node name again, so it is as if TeX is seeing it for the first % time. \ifdim \wd1>0pt -section ``\printednodename'' in \cite{\printedmanual}% +\putwordsection{} ``\correctnodename'' in \cite{\printedmanual}% \else% \turnoffactive% -\refx{#1-snt}{} [\printednodename], page\tie\refx{#1-pg}{}% +\refx{#1-snt}{} [\correctnodename], \putwordpage\tie\refx{#1-pg}{}% \fi \endgroup} @@ -3599,21 +3670,21 @@ \def\Ynothing{} \def\Ysectionnumberandtype{% -\ifnum\secno=0 Chapter\xreftie\the\chapno % -\else \ifnum \subsecno=0 Section\xreftie\the\chapno.\the\secno % +\ifnum\secno=0 \putwordChapter\xreftie\the\chapno % +\else \ifnum \subsecno=0 \putwordSection\xreftie\the\chapno.\the\secno % \else \ifnum \subsubsecno=0 % -Section\xreftie\the\chapno.\the\secno.\the\subsecno % +\putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno % \else % -Section\xreftie\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno % +\putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno % \fi \fi \fi } \def\Yappendixletterandtype{% -\ifnum\secno=0 Appendix\xreftie'char\the\appendixno{}% -\else \ifnum \subsecno=0 Section\xreftie'char\the\appendixno.\the\secno % +\ifnum\secno=0 \putwordAppendix\xreftie'char\the\appendixno{}% +\else \ifnum \subsecno=0 \putwordSection\xreftie'char\the\appendixno.\the\secno % \else \ifnum \subsubsecno=0 % -Section\xreftie'char\the\appendixno.\the\secno.\the\subsecno % +\putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno % \else % -Section\xreftie'char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno % +\putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno % \fi \fi \fi } \gdef\xreftie{'tie} @@ -3896,6 +3967,8 @@ \global\tolerance=700 \global\hfuzz=1pt \global\contentsrightmargin=0pt +\global\deftypemargin=0pt +\global\defbodyindent=.5cm \global\pagewidth=\hsize \global\pageheight=\vsize @@ -3993,17 +4066,6 @@ %\catcode 27=\active %\def^^[{$\diamondsuit$} -% Used sometimes to turn off (effectively) the active characters -% even after parsing them. -\def\turnoffactive{\let"=\normaldoublequote -\let~=\normaltilde -\let^=\normalcaret -\let_=\normalunderscore -\let|=\normalverticalbar -\let<=\normalless -\let>=\normalgreater -\let+=\normalplus} - % Set up an active definition for =, but don't enable it most of the time. {\catcode`\==\active \global\def={{\tt \char 61}}} @@ -4027,6 +4089,28 @@ % \catcode 17=0 % Define control-q \catcode`\\=\active + +% Used sometimes to turn off (effectively) the active characters +% even after parsing them. +@def@turnoffactive{@let"=@normaldoublequote +@let\=@realbackslash +@let~=@normaltilde +@let^=@normalcaret +@let_=@normalunderscore +@let|=@normalverticalbar +@let<=@normalless +@let>=@normalgreater +@let+=@normalplus} + +@def@normalturnoffactive{@let"=@normaldoublequote +@let\=@normalbackslash +@let~=@normaltilde +@let^=@normalcaret +@let_=@normalunderscore +@let|=@normalverticalbar +@let<=@normalless +@let>=@normalgreater +@let+=@normalplus} % If a .fmt file is being used, we don't want the `\input texinfo' to show up. % That is what \eatinput is for; after that, the `\' should revert to printing diff -ruN glibc-1.07/manual/time.texi glibc-1.08.1/manual/time.texi --- glibc-1.07/manual/time.texi Thu Jun 24 20:35:43 1993 +++ glibc-1.08.1/manual/time.texi Tue Feb 22 18:49:35 1994 @@ -965,7 +965,7 @@ @comment sys/time.h @comment BSD -@deftypefun int setitimer (int @var{which}, struct itimerval *@var{old}, struct itimerval *@var{new}) +@deftypefun int setitimer (int @var{which}, struct itimerval *@var{new}, struct itimerval *@var{old}) The @code{setitimer} function sets the timer specified by @var{which} according to @var{new}. The @var{which} argument can have a value of @code{ITIMER_REAL}, @code{ITIMER_VIRTUAL}, or @code{ITIMER_PROF}. diff -ruN glibc-1.07/math/Makefile glibc-1.08.1/math/Makefile --- glibc-1.07/math/Makefile Mon Jan 17 17:40:23 1994 +++ glibc-1.08.1/math/Makefile Tue Mar 22 15:53:14 1994 @@ -35,77 +35,5 @@ include ../Rules -$(objpfx)libm.a: - $(AR) cr $@ /dev/null - +$(objpfx)libm.a: $(dep-dummy-lib); $(make-dummy-lib) lib: $(objpfx)libm.a - -ifneq (,) # the code is now distributed through ../sysdeps/ - -# Other dirs to look for source files (for dist). -export source_dirs = $(filter-out unused,$(shell find bsd -type d -print)) - -include $(objpfx)BSDmath-files -$(objpfx)BSDmath-files: - (echo define +ansideclificate-bsd; \ - echo "(echo '#include '; \ - echo '#include \"\$$<\"') > \$$@-tmp; \ - mv \$$@-tmp \$$@"; \ - echo endef; \ - for dir in $(source_dirs); do \ - echo "\$$(objpfx)%.c: $${dir}/%.c;\$$(+ansideclificate-bsd)";\ - done) > $@-tmp - mv $@-tmp $@ - - -ifdef bsdmath_dirs - -override CPPFLAGS := $(CPPFLAGS) -Ibsd $(addprefix -Ibsd/,$(bsdmath_dirs)) - -+bsdpath := $(subst $+ ,:,bsd $(addprefix bsd/,$(bsdmath_dirs))) -vpath %.s $(+bsdpath) -vpath %.h $(+bsdpath) - -+bsdfiles := $(wildcard $(patsubst %,bsd/%/*.c,$(bsdmath_dirs))) - -ifdef +bsdfiles - -# Find all the files which have both BSD and sysdep versions. -+sysdeps := $(notdir $(wildcard \ - $(foreach dir, \ - $(filter-out %/generic %/stub, \ - $(+sysdep_dirs)), \ - $(addprefix $(dir)/, \ - $(notdir $(+bsdfiles)))))) - -# Filter these out of the list of BSD files. -+bsdfiles := $(filter-out $(addprefix %/,$(+sysdeps)),$(+bsdfiles)) - -ifdef +bsdfiles -# Assert that all the BSD C sources exist in the object directory, -# so VPATH will find them there first. -$(addprefix $(objpfx),$(notdir $(+bsdfiles))): -endif - -# See how easy this would be in make v4? -ifneq (,) -define bsd-files -$(foreach dir,$(bsdmath_dirs), -$(objpfx)%.c: bsd/$(dir)/%.c - (echo '#include '; echo '#include "$<") > $@-tmp - mv $@-tmp $@ -endef -$(bsd-files) -endif - -ifneq ($(findstring gcc,$(CC)),) -# Disable GCC warnings for grody BSD code. -override CFLAGS := $(filter-out -W%,$(CFLAGS)) -# In make v4, put "$(+bsdfiles): " in front of that. -endif - -endif # +bsdfiles - -endif # bsdmath_dirs - -endif diff -ruN glibc-1.07/math/math.h glibc-1.08.1/math/math.h --- glibc-1.07/math/math.h Fri May 14 16:46:28 1993 +++ glibc-1.08.1/math/math.h Tue Jan 25 14:31:00 1994 @@ -270,4 +270,23 @@ __END_DECLS + +#ifdef __USE_BSD +/* Some useful constants. */ +#define M_E 2.7182818284590452354 /* e */ +#define M_LOG2E 1.4426950408889634074 /* log 2e */ +#define M_LOG10E 0.43429448190325182765 /* log 10e */ +#define M_LN2 0.69314718055994530942 /* log e2 */ +#define M_LN10 2.30258509299404568402 /* log e10 */ +#define M_PI 3.14159265358979323846 /* pi */ +#define M_PI_2 1.57079632679489661923 /* pi/2 */ +#define M_PI_4 0.78539816339744830962 /* pi/4 */ +#define M_1_PI 0.31830988618379067154 /* 1/pi */ +#define M_2_PI 0.63661977236758134308 /* 2/pi */ +#define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */ +#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */ +#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */ +#endif + + #endif /* math.h */ diff -ruN glibc-1.07/misc/Makefile glibc-1.08.1/misc/Makefile --- glibc-1.07/misc/Makefile Mon Jan 17 17:40:27 1994 +++ glibc-1.08.1/misc/Makefile Wed May 11 19:51:57 1994 @@ -24,7 +24,8 @@ 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 sys/syslog.h paths.h sys/reboot.h + ttyent.h syscall.h syslog.h sys/syslog.h paths.h sys/reboot.h \ + sys/mman.h sys/param.h routines := brk sbrk sstk ioctl \ __brk __sbrk __ioctl \ @@ -51,11 +52,13 @@ truncate ftruncate \ chflags fchflags \ insremque getttyent getusersh getpass ttyslot \ - syslog syscall + syslog syscall \ + mmap munmap mprotect msync madvise aux := data_start progname distribute := bsd-compat.c extra-objs := bsd-compat.o install-lib := libbsd-compat.a +non-lib.a := libbsd-compat.a include ../Rules diff -ruN glibc-1.07/misc/bsd-compat.c glibc-1.08.1/misc/bsd-compat.c --- glibc-1.07/misc/bsd-compat.c Sun Jan 9 19:05:40 1994 +++ glibc-1.08.1/misc/bsd-compat.c Wed May 11 22:31:36 1994 @@ -31,6 +31,10 @@ function_alias(getpgrp, __getpgrp, pid_t, (pid), DEFUN(getpgrp, (pid), pid_t pid)) +/* These entry points allow for things compiled for another C library + that want the BSD-compatible definitions. (Of course, their jmp_buf + must be big enough.) */ + #undef longjmp #ifdef __STDC__ #define void __NORETURN void @@ -37,3 +41,10 @@ #endif function_alias_void(longjmp, siglongjmp, (env, val), DEFUN(longjmp, (env, val), CONST jmp_buf env AND int val)) + +#undef setjmp +int +DEFUN(setjmp, (env), jmp_buf env) +{ + return sigsetjmp (env, 1); +} diff -ruN glibc-1.07/misc/progname.c glibc-1.08.1/misc/progname.c --- glibc-1.07/misc/progname.c Wed Mar 17 14:16:15 1993 +++ glibc-1.08.1/misc/progname.c Tue Jan 25 14:01:13 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 @@ -31,12 +31,17 @@ { char *p; - program_invocation_name = argv[0]; - p = strrchr (argv[0], '/'); - if (p == NULL) - program_invocation_short_name = argv[0]; + if (argv && argv[0]) + { + program_invocation_name = argv[0]; + p = strrchr (argv[0], '/'); + if (p == NULL) + program_invocation_short_name = argv[0]; + else + program_invocation_short_name = p + 1; + } else - program_invocation_short_name = p + 1; + program_invocation_name = program_invocation_short_name = 0; (void) &set_progname; /* Avoid "defined but not used" warning. */ } diff -ruN glibc-1.07/misc/sys/cdefs.h glibc-1.08.1/misc/sys/cdefs.h --- glibc-1.07/misc/sys/cdefs.h Sun Nov 14 19:30:54 1993 +++ glibc-1.08.1/misc/sys/cdefs.h Sun Nov 14 18:48:21 1993 @@ -36,7 +36,7 @@ /* In GCC 2.6 and later, these keywords are meaningless when applied to functions, as ANSI requires. Instead, we use GCC's special `__attribute__' syntax. */ -#define __NORETURN __attribute__ ((volatile)) +#define __NORETURN __attribute__ ((noreturn)) #define __CONSTVALUE __attribute__ ((const)) #endif diff -ruN glibc-1.07/misc/sys/ioctl.h glibc-1.08.1/misc/sys/ioctl.h --- glibc-1.07/misc/sys/ioctl.h Fri Dec 17 18:31:19 1993 +++ glibc-1.08.1/misc/sys/ioctl.h Fri Mar 4 01:56: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 @@ -85,6 +85,7 @@ unsigned short int ws_row; /* Rows, in characters. */ unsigned short int ws_col; /* Columns, in characters. */ + /* These are not actually used. */ unsigned short int ws_xpixel; /* Horizontal pixels. */ unsigned short int ws_ypixel; /* Vertical pixels. */ }; @@ -94,6 +95,11 @@ #endif #if defined (TIOCGSIZE) || defined (TIOCSSIZE) +# if defined (TIOCGWINSZ) && TIOCGSIZE == TIOCGWINSZ +/* Many systems that have TIOCGWINSZ define TIOCGSIZE for source + compatibility with Sun; they define `struct ttysize' to have identical + layout as `struct winsize' and #define TIOCGSIZE to be TIOCGWINSZ + (likewise TIOCSSIZE and TIOCSWINSZ). */ struct ttysize { unsigned short int ts_lines; @@ -101,8 +107,16 @@ unsigned short int ts_xxx; unsigned short int ts_yyy; }; - #define _IOT_ttysize _IOT_winsize +# else +/* Suns use a different layout for `struct ttysize', and TIOCGSIZE and + TIOCGWINSZ are separate commands that do the same thing with different + structures (likewise TIOCSSIZE and TIOCSWINSZ). */ +struct ttysize +{ + int ts_lines, ts_cols; /* Lines and columns, in characters. */ +}; +# endif #endif /* Perform the I/O control operation specified by REQUEST on FD. diff -ruN glibc-1.07/misc/syslog.h glibc-1.08.1/misc/syslog.h --- glibc-1.07/misc/syslog.h +++ glibc-1.08.1/misc/syslog.h Tue Feb 15 16:57:38 1994 @@ -0,0 +1 @@ +#include diff -ruN glibc-1.07/mkinstalldirs glibc-1.08.1/mkinstalldirs --- glibc-1.07/mkinstalldirs Fri Aug 13 11:07:14 1993 +++ glibc-1.08.1/mkinstalldirs Fri Mar 25 23:01:14 1994 @@ -1,35 +1,32 @@ #!/bin/sh -# Make directory hierarchy. -# Written by Noah Friedman -# Public domain. - -defaultIFS=' -' -IFS="${IFS-${defaultIFS}}" +# mkinstalldirs --- make directory hierarchy +# Author: Noah Friedman +# Created: 1993-05-16 +# Last modified: 1994-03-25 +# Public domain errstatus=0 for file in ${1+"$@"} ; do - oIFS="${IFS}" - # Some sh's can't handle IFS=/ for some reason. - IFS='%' - set - `echo ${file} | sed -e 's@/@%@g' -e 's@^%@/@'` - IFS="${oIFS}" + set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` + shift - pathcomp='' - + pathcomp= for d in ${1+"$@"} ; do - pathcomp="${pathcomp}${d}" + pathcomp="$pathcomp$d" + case "$pathcomp" in + -* ) pathcomp=./$pathcomp ;; + esac - if test ! -d "${pathcomp}"; then + if test ! -d "$pathcomp"; then echo "mkdir $pathcomp" 1>&2 - mkdir "${pathcomp}" || errstatus=$? + mkdir "$pathcomp" || errstatus=$? fi - pathcomp="${pathcomp}/" + pathcomp="$pathcomp/" done done exit $errstatus -# eof +# mkinstalldirs ends here diff -ruN glibc-1.07/poll.h glibc-1.08.1/poll.h --- glibc-1.07/poll.h +++ glibc-1.08.1/poll.h Mon May 16 23:21:05 1994 @@ -0,0 +1 @@ +#include diff -ruN glibc-1.07/posix/Makefile glibc-1.08.1/posix/Makefile --- glibc-1.07/posix/Makefile Mon Jan 17 18:06:30 1994 +++ glibc-1.08.1/posix/Makefile Tue Mar 8 18:44:50 1994 @@ -34,7 +34,7 @@ __wait __waitpid __wait3 __wait4 \ alarm sleep pause \ __fork __vfork _exit \ - __execve execve execv execle execl execvp execlp \ + __execve execve fexecve execv execle execl execvp execlp \ __getpid __getppid \ __getuid __geteuid __getgid __getegid __getgrps __setuid __setgid \ __getpgrp __setpgrp __setsid setpgid \ @@ -53,9 +53,7 @@ include ../Rules -$(objpfx)libposix.a: - $(AR) cr $@ /dev/null - +$(objpfx)libposix.a: $(dep-dummy-lib); $(make-dummy-lib) lib: $(objpfx)libposix.a # Make the standalone glob/fnmatch package. diff -ruN glibc-1.07/posix/getopt.c glibc-1.08.1/posix/getopt.c --- glibc-1.07/posix/getopt.c Sat Dec 25 02:24:07 1993 +++ glibc-1.08.1/posix/getopt.c Tue May 10 15:53:58 1994 @@ -3,7 +3,7 @@ "Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu before changing it! - Copyright (C) 1987, 88, 89, 90, 91, 92, 1993 + Copyright (C) 1987, 88, 89, 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 @@ -24,10 +24,8 @@ not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* - * This tells Alpha OSF/1 not to define a getopt prototype in . - * Ditto for AIX 3.2 and . - */ +/* This tells Alpha OSF/1 not to define a getopt prototype in . + Ditto for AIX 3.2 and . */ #ifndef _NO_PROTO #define _NO_PROTO #endif @@ -72,11 +70,6 @@ #include #endif /* GNU C library. */ -/* If GETOPT_COMPAT is defined, `+' as well as `--' can introduce a - long-named option. Because this is not POSIX.2 compliant, it is - being phased out. */ -/* #define GETOPT_COMPAT */ - /* This version of `getopt' appears to the caller like standard Unix `getopt' but it behaves differently for the user, since it allows the user to intersperse the options with the other arguments. @@ -99,7 +92,7 @@ Also, when `ordering' is RETURN_IN_ORDER, each non-option ARGV-element is returned here. */ -char *optarg = 0; +char *optarg = NULL; /* Index in ARGV of the next element to be scanned. This is used for communication to and from the caller @@ -199,19 +192,18 @@ } /* If using GCC, we can safely declare strlen this way. - If not using GCC, it is ok not to declare it. - (Supposedly there are some machines where it might get a warning, - but changing this conditional to __STDC__ is too risky.) */ + If not using GCC, it is ok not to declare it. */ #ifdef __GNUC__ -#ifdef IN_GCC -#include "gstddef.h" -#else -#include -#endif -extern size_t strlen (const char *); -#endif +/* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h. + That was relevant to code that was here before. */ +#ifndef __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 *); +#endif /* not __STDC__ */ +#endif /* __GNUC__ */ -#endif /* GNU C library. */ +#endif /* not __GNU_LIBRARY__ */ /* Handle permutation of arguments. */ @@ -286,6 +278,40 @@ first_nonopt += (optind - last_nonopt); last_nonopt = optind; } + +/* Initialize the internal data when the first call is made. */ + +static const char * +_getopt_initialize (optstring) + const char *optstring; +{ + /* Start processing options with ARGV-element 1 (since ARGV-element 0 + is the program name); the sequence of previously skipped + non-option ARGV-elements is empty. */ + + first_nonopt = last_nonopt = optind = 1; + + nextchar = NULL; + + /* Determine how to handle the ordering of options and nonoptions. */ + + if (optstring[0] == '-') + { + ordering = RETURN_IN_ORDER; + ++optstring; + } + else if (optstring[0] == '+') + { + ordering = REQUIRE_ORDER; + ++optstring; + } + else if (getenv ("POSIXLY_CORRECT") != NULL) + ordering = REQUIRE_ORDER; + else + ordering = PERMUTE; + + return optstring; +} /* Scan elements of ARGV (whose length is ARGC) for option characters given in OPTSTRING. @@ -352,41 +378,15 @@ int *longind; int long_only; { - int option_index; - - optarg = 0; - - /* Initialize the internal data when the first call is made. - Start processing options with ARGV-element 1 (since ARGV-element 0 - is the program name); the sequence of previously skipped - non-option ARGV-elements is empty. */ + optarg = NULL; if (optind == 0) - { - first_nonopt = last_nonopt = optind = 1; - - nextchar = NULL; - - /* Determine how to handle the ordering of options and nonoptions. */ - - if (optstring[0] == '-') - { - ordering = RETURN_IN_ORDER; - ++optstring; - } - else if (optstring[0] == '+') - { - ordering = REQUIRE_ORDER; - ++optstring; - } - else if (getenv ("POSIXLY_CORRECT") != NULL) - ordering = REQUIRE_ORDER; - else - ordering = PERMUTE; - } + optstring = _getopt_initialize (optstring); if (nextchar == NULL || *nextchar == '\0') { + /* Advance to the next ARGV-element. */ + if (ordering == PERMUTE) { /* If we have just processed some options following some non-options, @@ -397,21 +397,16 @@ else if (last_nonopt != optind) first_nonopt = optind; - /* Now skip any additional non-options + /* Skip any additional non-options and extend the range of non-options previously skipped. */ while (optind < argc - && (argv[optind][0] != '-' || argv[optind][1] == '\0') -#ifdef GETOPT_COMPAT - && (longopts == NULL - || argv[optind][0] != '+' || argv[optind][1] == '\0') -#endif /* GETOPT_COMPAT */ - ) + && (argv[optind][0] != '-' || argv[optind][1] == '\0')) optind++; last_nonopt = optind; } - /* Special ARGV-element `--' means premature end of options. + /* The special ARGV-element `--' means premature end of options. Skip it like a null option, then exchange with previous non-options as if it were an option, then skip everything else like a non-option. */ @@ -444,12 +439,7 @@ /* If we have come to a non-option and did not permute it, either stop the scan or describe it to the caller and pass it by. */ - if ((argv[optind][0] != '-' || argv[optind][1] == '\0') -#ifdef GETOPT_COMPAT - && (longopts == NULL - || argv[optind][0] != '+' || argv[optind][1] == '\0') -#endif /* GETOPT_COMPAT */ - ) + if ((argv[optind][0] != '-' || argv[optind][1] == '\0')) { if (ordering == REQUIRE_ORDER) return EOF; @@ -458,36 +448,48 @@ } /* We have found another option-ARGV-element. - Start decoding its characters. */ + Skip the initial punctuation. */ nextchar = (argv[optind] + 1 + (longopts != NULL && argv[optind][1] == '-')); } + /* Decode the current option-ARGV-element. */ + + /* Check whether the ARGV-element is a long option. + + If long_only and the ARGV-element has the form "-f", where f is + a valid short option, don't consider it an abbreviated form of + a long option that starts with f. Otherwise there would be no + way to give the -f short option. + + On the other hand, if there's a long option "fubar" and + the ARGV-element is "-fu", do consider that an abbreviation of + the long option, just like "--fu", and not "-f" with arg "u". + + This distinction seems to be the most useful approach. */ + if (longopts != NULL - && ((argv[optind][0] == '-' - && (argv[optind][1] == '-' || long_only)) -#ifdef GETOPT_COMPAT - || argv[optind][0] == '+' -#endif /* GETOPT_COMPAT */ - )) + && (argv[optind][1] == '-' + || (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1]))))) { + char *nameend; const struct option *p; - char *s = nextchar; + const struct option *pfound = NULL; int exact = 0; int ambig = 0; - const struct option *pfound = NULL; int indfound; + int option_index; - while (*s && *s != '=') - s++; + for (nameend = nextchar; *nameend && *nameend != '='; nameend++) + /* Do nothing. */ ; - /* Test all options for either exact match or abbreviated matches. */ - for (p = longopts, option_index = 0; p->name; - p++, option_index++) - if (!strncmp (p->name, nextchar, s - nextchar)) + /* Test all long options for either exact match + or abbreviated matches. */ + for (p = longopts, option_index = 0; p->name; p++, option_index++) + if (!strncmp (p->name, nextchar, nameend - nextchar)) { - if (s - nextchar == strlen (p->name)) + if (nameend - nextchar == strlen (p->name)) { /* Exact match found. */ pfound = p; @@ -502,7 +504,7 @@ indfound = option_index; } else - /* Second nonexact match found. */ + /* Second or later nonexact match found. */ ambig = 1; } @@ -520,12 +522,12 @@ { option_index = indfound; optind++; - if (*s) + if (*nameend) { /* Don't test has_arg with >, because some C compilers don't allow it to be used on enums. */ if (pfound->has_arg) - optarg = s + 1; + optarg = nameend + 1; else { if (opterr) @@ -568,14 +570,12 @@ } return pfound->val; } + /* Can't find it as a long option. If this is not getopt_long_only, or the option starts with '--' or is not a valid short option, then it's an error. Otherwise interpret it as a short option. */ if (!long_only || argv[optind][1] == '-' -#ifdef GETOPT_COMPAT - || argv[optind][0] == '+' -#endif /* GETOPT_COMPAT */ || my_index (optstring, *nextchar) == NULL) { if (opterr) @@ -595,7 +595,7 @@ } } - /* Look at and handle the next option-character. */ + /* Look at and handle the next short option-character. */ { char c = *nextchar++; @@ -609,16 +609,8 @@ { if (opterr) { -#if 0 - if (c < 040 || c >= 0177) - fprintf (stderr, "%s: unrecognized option, character code 0%o\n", - argv[0], c); - else - fprintf (stderr, "%s: unrecognized option `-%c'\n", argv[0], c); -#else /* 1003.2 specifies the format of this message. */ fprintf (stderr, "%s: illegal option -- %c\n", argv[0], c); -#endif } optopt = c; return '?'; @@ -634,7 +626,7 @@ optind++; } else - optarg = 0; + optarg = NULL; nextchar = NULL; } else @@ -651,14 +643,9 @@ { if (opterr) { -#if 0 - fprintf (stderr, "%s: option `-%c' requires an argument\n", - argv[0], c); -#else /* 1003.2 specifies the format of this message. */ fprintf (stderr, "%s: option requires an argument -- %c\n", argv[0], c); -#endif } optopt = c; if (optstring[0] == ':') diff -ruN glibc-1.07/posix/sys/types.h glibc-1.08.1/posix/sys/types.h --- glibc-1.07/posix/sys/types.h Tue Nov 10 18:23:54 1992 +++ glibc-1.08.1/posix/sys/types.h Sun Feb 6 17:35:05 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 @@ -62,10 +62,22 @@ #define __need_size_t #include +#ifdef __USE_BSD +/* These size-specific names are used by some of the inet code. */ +typedef int int32_t; +typedef short int int16_t; +typedef char int8_t; +typedef unsigned int u_int32_t; +typedef unsigned short int u_int16_t; +typedef unsigned char u_int8_t; +#endif + + #ifdef __USE_BSD #define FD_SETSIZE __FD_SETSIZE +#define NFDBITS __NFDBITS #define fd_set __fd_set #define FD_ZERO(set) __FD_ZERO(set) #define FD_SET(d, set) __FD_SET((d), (set)) diff -ruN glibc-1.07/posix/sys/utsname.h glibc-1.08.1/posix/sys/utsname.h --- glibc-1.07/posix/sys/utsname.h Tue Nov 10 17:18:15 1992 +++ glibc-1.08.1/posix/sys/utsname.h Thu Feb 24 20:00:03 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,6 +28,9 @@ __BEGIN_DECLS #include +#ifndef _UTSNAME_NODENAME_LENGTH +#define _UTSNAME_NODENAME_LENGTH _UTSNAME_LENGTH +#endif /* Structure describing the system and machine. */ struct utsname @@ -36,7 +39,7 @@ char sysname[_UTSNAME_LENGTH]; /* Name of this node on the network. */ - char nodename[_UTSNAME_LENGTH]; + char nodename[_UTSNAME_NODENAME_LENGTH]; /* Current release level of this implementation. */ char release[_UTSNAME_LENGTH]; @@ -49,7 +52,7 @@ /* Put information about the system in NAME. */ -extern int uname __P ((struct utsname * __name)); +extern int uname __P ((struct utsname *__name)); __END_DECLS diff -ruN glibc-1.07/posix/sys/wait.h glibc-1.08.1/posix/sys/wait.h --- glibc-1.07/posix/sys/wait.h Tue Jan 11 22:39:28 1994 +++ glibc-1.08.1/posix/sys/wait.h Mon Jan 24 17:26:36 1994 @@ -81,6 +81,7 @@ #define WIFSTOPPED(status) __WIFSTOPPED(__WAIT_INT(status)) #ifdef __USE_BSD +#define WCOREFLAG __WCOREFLAG #define WCOREDUMP(status) __WCOREDUMP(__WAIT_INT(status)) #define W_EXITCODE(ret, sig) __W_EXITCODE(ret, sig) #define W_STOPCODE(sig) __W_STOPCODE(sig) diff -ruN glibc-1.07/posix/unistd.h glibc-1.08.1/posix/unistd.h --- glibc-1.07/posix/unistd.h Wed Nov 10 06:26:47 1993 +++ glibc-1.08.1/posix/unistd.h Fri Mar 25 02:25: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 @@ -234,7 +234,15 @@ extern int execve __P ((__const char *__path, char *__const __argv[], char *__const __envp[])); +#ifdef __USE_GNU +/* Execute the file FD refers to, overlaying the running program image. + ARGV and ENVP are passed to the new program, as for `execve'. */ +extern int fexecve __P ((int __fd, + char *const __argv[], char *const __envp[])); +#endif + + /* Execute PATH with arguments ARGV and environment from `environ'. */ extern int execv __P ((__const char *__path, char *__const __argv[])); @@ -370,8 +378,8 @@ extern int __setregid __P ((__gid_t __rgid, __gid_t __egid)); extern int setregid __P ((__gid_t __rgid, __gid_t __egid)); -/* Set the effective user ID of the calling process to UID. */ -extern int seteuid __P ((__uid_t __uid)); +/* Set the effective group ID of the calling process to GID. */ +extern int setegid __P ((__gid_t __gid)); #endif /* Use BSD. */ @@ -509,6 +517,13 @@ extern int getdtablesize __P ((void)); +/* Truncate FILE to LENGTH bytes. */ +extern int truncate __P ((__const char *__file, __off_t __length)); + +/* Truncate the file FD is open on to LENGTH bytes. */ +extern int ftruncate __P ((int __fd, __off_t __length)); + + /* Make all changes done to FD actually appear on disk. */ extern int fsync __P ((int __fd)); @@ -582,6 +597,37 @@ #endif /* Use misc. */ + +#if defined (__USE_MISC) && !defined (F_LOCK) +/* NOTE: These declarations also appear in ; be sure to keep both + files consistent. Some systems have them there and some here, and some + software depends on the macros being defined without including both. */ + +/* `lockf' is a simpler interface to the locking facilities of `fcntl'. + LEN is always relative to the current file position. + The CMD argument is one of the following. */ + +#define F_ULOCK 0 /* Unlock a previously locked region. */ +#define F_LOCK 1 /* Lock a region for exclusive use. */ +#define F_TLOCK 2 /* Test and lock a region for exclusive use. */ +#define F_TEST 3 /* Test a region for other processes locks. */ + +extern int lockf __P ((int __fd, int __cmd, __off_t __len)); +#endif /* Use misc and F_LOCK not already defined. */ + + +#ifdef __USE_GNU + +/* Evaluate EXPRESSION, and repeat as long as it returns -1 with `errno' + set to EINTR. */ + +#define TEMP_FAILURE_RETRY(expression) \ + ({ long int __result; \ + do __result = (long int) (expression); \ + while (__result == -1L && errno == EINTR); \ + __result; }) + +#endif __END_DECLS diff -ruN glibc-1.07/resource/Makefile glibc-1.08.1/resource/Makefile --- glibc-1.07/resource/Makefile Thu May 14 01:56:22 1992 +++ glibc-1.08.1/resource/Makefile Wed May 18 19:08:10 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 @@ -18,7 +18,7 @@ subdir := resource -headers := sys/resource.h sys/vlimit.h sys/vtimes.h +headers := sys/resource.h resourcebits.h sys/vlimit.h sys/vtimes.h routines := getrlimit setrlimit getrusage ulimit vlimit vtimes \ getprio setprio __getrusag nice diff -ruN glibc-1.07/resource/sys/resource.h glibc-1.08.1/resource/sys/resource.h --- glibc-1.07/resource/sys/resource.h Thu Dec 23 00:57:51 1993 +++ glibc-1.08.1/resource/sys/resource.h Wed May 18 19:09:07 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 @@ -13,7 +13,7 @@ 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, 1992 Free Software Foundation, Inc., 675 Mass Ave, +not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef _SYS_RESOURCE_H @@ -23,35 +23,9 @@ __BEGIN_DECLS +/* Get the system-dependent definitions of RLIM_*. */ +#include -/* Kinds of resource limit. */ -enum __rlimit_resource - { - /* Per-process CPU limit, in seconds. */ - RLIMIT_CPU, - /* Largest file that can be created, in bytes. */ - RLIMIT_FSIZE, - /* Maximum size of data segment, in bytes. */ - RLIMIT_DATA, - /* Maximum size of stack segment, in bytes. */ - RLIMIT_STACK, - /* Largest core file that can be created, in bytes. */ - RLIMIT_CORE, - /* Largest resident set size, in bytes. - This affects swapping; processes that are exceeding their - resident set size will be more likely to have physical memory - taken from them. */ - RLIMIT_RSS, - /* Locked-in-memory address space. */ - RLIMIT_MEMLOCK, - /* Number of processes, */ - RLIMIT_NPROC, - /* Number of open files. */ - RLIMIT_OFILE, - - RLIM_NLIMITS - }; - struct rlimit { /* The current (soft) limit. */ @@ -77,11 +51,16 @@ /* Whose usage statistics do you want? */ enum __rusage_who +/* The macro definitions are necessary because some programs want + to test for operating system features with #ifdef RUSAGE_SELF. + In ANSI C the reflexive definition is a no-op. */ { /* The calling process. */ RUSAGE_SELF = 0, +#define RUSAGE_SELF RUSAGE_SELF /* All of its terminated child processes. */ RUSAGE_CHILDREN = -1, +#define RUSAGE_CHILDREN RUSAGE_CHILDREN }; #include /* For `struct timeval'. */ diff -ruN glibc-1.07/rpc/auth.h glibc-1.08.1/rpc/auth.h --- glibc-1.07/rpc/auth.h +++ glibc-1.08.1/rpc/auth.h Wed May 18 22:46:14 1994 @@ -0,0 +1 @@ +#include diff -ruN glibc-1.07/rpc/auth_unix.h glibc-1.08.1/rpc/auth_unix.h --- glibc-1.07/rpc/auth_unix.h +++ glibc-1.08.1/rpc/auth_unix.h Wed May 18 22:46:14 1994 @@ -0,0 +1 @@ +#include diff -ruN glibc-1.07/rpc/clnt.h glibc-1.08.1/rpc/clnt.h --- glibc-1.07/rpc/clnt.h +++ glibc-1.08.1/rpc/clnt.h Wed May 18 22:46:14 1994 @@ -0,0 +1 @@ +#include diff -ruN glibc-1.07/rpc/netdb.h glibc-1.08.1/rpc/netdb.h --- glibc-1.07/rpc/netdb.h +++ glibc-1.08.1/rpc/netdb.h Wed May 18 22:46:14 1994 @@ -0,0 +1 @@ +#include diff -ruN glibc-1.07/rpc/pmap_clnt.h glibc-1.08.1/rpc/pmap_clnt.h --- glibc-1.07/rpc/pmap_clnt.h +++ glibc-1.08.1/rpc/pmap_clnt.h Wed May 18 22:46:14 1994 @@ -0,0 +1 @@ +#include diff -ruN glibc-1.07/rpc/pmap_prot.h glibc-1.08.1/rpc/pmap_prot.h --- glibc-1.07/rpc/pmap_prot.h +++ glibc-1.08.1/rpc/pmap_prot.h Wed May 18 22:46:14 1994 @@ -0,0 +1 @@ +#include diff -ruN glibc-1.07/rpc/pmap_rmt.h glibc-1.08.1/rpc/pmap_rmt.h --- glibc-1.07/rpc/pmap_rmt.h +++ glibc-1.08.1/rpc/pmap_rmt.h Wed May 18 22:46:14 1994 @@ -0,0 +1 @@ +#include diff -ruN glibc-1.07/rpc/rpc.h glibc-1.08.1/rpc/rpc.h --- glibc-1.07/rpc/rpc.h +++ glibc-1.08.1/rpc/rpc.h Wed May 18 22:46:14 1994 @@ -0,0 +1 @@ +#include diff -ruN glibc-1.07/rpc/rpc_msg.h glibc-1.08.1/rpc/rpc_msg.h --- glibc-1.07/rpc/rpc_msg.h +++ glibc-1.08.1/rpc/rpc_msg.h Wed May 18 22:46:14 1994 @@ -0,0 +1 @@ +#include diff -ruN glibc-1.07/rpc/svc.h glibc-1.08.1/rpc/svc.h --- glibc-1.07/rpc/svc.h +++ glibc-1.08.1/rpc/svc.h Wed May 18 22:46:15 1994 @@ -0,0 +1 @@ +#include diff -ruN glibc-1.07/rpc/svc_auth.h glibc-1.08.1/rpc/svc_auth.h --- glibc-1.07/rpc/svc_auth.h +++ glibc-1.08.1/rpc/svc_auth.h Wed May 18 22:46:15 1994 @@ -0,0 +1 @@ +#include diff -ruN glibc-1.07/rpc/types.h glibc-1.08.1/rpc/types.h --- glibc-1.07/rpc/types.h +++ glibc-1.08.1/rpc/types.h Wed May 18 22:46:15 1994 @@ -0,0 +1 @@ +#include diff -ruN glibc-1.07/rpc/xdr.h glibc-1.08.1/rpc/xdr.h --- glibc-1.07/rpc/xdr.h +++ glibc-1.08.1/rpc/xdr.h Wed May 18 22:46:15 1994 @@ -0,0 +1 @@ +#include diff -ruN glibc-1.07/set-hooks.h glibc-1.08.1/set-hooks.h --- glibc-1.07/set-hooks.h +++ glibc-1.08.1/set-hooks.h Mon Apr 4 23:47:10 1994 @@ -0,0 +1,54 @@ +/* Macros for using symbol sets for running lists of functions. +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 _SET_HOOKS_H + +#define __need_size_t +#include +#include + +/* Define a hook variable called NAME. Functions put on this hook take + arguments described by PROTO. Use `text_set_element (NAME, FUNCTION)' + from gnu-stabs.h to add a function to the hook. */ + +#define DEFINE_HOOK(NAME, PROTO) \ +const struct \ + { \ + size_t n; \ + void (*fn[0]) __P (PROTO); \ + } NAME + +/* Run all the functions hooked on the set called NAME. + Each function is called like this: `function ARGS'. */ + +#define RUN_HOOK(NAME, ARGS) \ +do { \ + size_t i; \ + for (i = 0; i < NAME.n; ++i) \ + (*NAME.fn[i]) ARGS; \ +} while (0) + +/* Define a hook variable with NAME and PROTO, and a function called RUNNER + which calls each function on the hook in turn, with ARGS. */ + +#define DEFINE_HOOK_RUNNER(name, runner, proto, args) \ +DEFINE_HOOK (name, proto); void runner proto { RUN_HOOK (name, args); } + + +#endif diff -ruN glibc-1.07/set-init.c glibc-1.08.1/set-init.c --- glibc-1.07/set-init.c Thu Feb 27 16:13:31 1992 +++ glibc-1.08.1/set-init.c Mon Apr 4 23:17:48 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 @@ -16,22 +16,7 @@ not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include -#include +#include "set-hooks.h" -struct - { - size_t n; - void EXFUN((*fn[0]), (int argc, char **argv, char **envp)); - } __libc_subinit; - -void -DEFUN(__libc_init, (argc, argv, envp), - int argc AND char **argv AND char **envp) -{ - - void EXFUN((**fn), (int argc, char **argv, char **envp)); - - for (fn = __libc_subinit.fn; *fn != NULL; ++fn) - (**fn) (argc, argv, envp); -} +DEFINE_HOOK_RUNNER (__libc_subinit, __libc_init, + (int argc, char **argv, char **envp), (argc, argv, envp)) diff -ruN glibc-1.07/signal/Makefile glibc-1.08.1/signal/Makefile --- glibc-1.07/signal/Makefile Mon Oct 25 15:57:53 1993 +++ glibc-1.08.1/signal/Makefile Sat May 21 16:43:41 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,7 +30,7 @@ sigblock sigsetmask sigpause sigvec \ __sigblock __sigstmsk __sigpause __sigvec \ sigstack sigaltstk sigintr \ - sigempty sigfillset sigaddset sigdelset sigismem \ + sigsetops sigempty sigfillset sigaddset sigdelset sigismem \ sigret __sigret \ gsignal ssignal diff -ruN glibc-1.07/signal/signal.h glibc-1.08.1/signal/signal.h --- glibc-1.07/signal/signal.h Thu Oct 21 15:50:57 1993 +++ glibc-1.08.1/signal/signal.h Sat May 21 16:15:07 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 @@ -34,7 +34,6 @@ #include #include /* __sigset_t, __sig_atomic_t. */ -#include #if !defined(__sig_atomic_t_defined) && \ (defined(_SIGNAL_H) || defined(__need_sig_atomic_t)) @@ -46,6 +45,8 @@ #ifdef _SIGNAL_H +#include + /* Type of a signal handler. */ typedef void (*__sighandler_t) __P ((int)); @@ -76,6 +77,11 @@ extern __sighandler_t ssignal __P ((int __sig, __sighandler_t __handler)); extern int gsignal __P ((int __sig)); #endif /* Use SVID. */ + +#ifdef __USE_MISC +/* Print a message describing the meaning of the given signal number. */ +extern void psignal __P ((int __sig, __const char *__s)); +#endif /* Use misc. */ /* Block signals in MASK, returning the old mask. */ diff -ruN glibc-1.07/signal/sigsetops.c glibc-1.08.1/signal/sigsetops.c --- glibc-1.07/signal/sigsetops.c +++ glibc-1.08.1/signal/sigsetops.c Sat May 21 16:43:26 1994 @@ -0,0 +1,6 @@ +/* Define the real-function versions of all inline functions + defined in signal.h (or sigset.h). */ + +#define _EXTERN_INLINE + +#include "signal.h" diff -ruN glibc-1.07/socket/sys/socket.h glibc-1.08.1/socket/sys/socket.h --- glibc-1.07/socket/sys/socket.h Mon Nov 9 19:34:30 1992 +++ glibc-1.08.1/socket/sys/socket.h Fri May 27 01:35:14 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 @@ -42,8 +42,9 @@ /* Protocol families. */ #define PF_UNSPEC 0 /* Unspecified. */ -#define PF_FILE 1 /* Local to host (pipes and file-domain). */ -#define PF_UNIX PF_FILE /* BSD name for PF_FILE. */ +#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. */ diff -ruN glibc-1.07/stdarg.h glibc-1.08.1/stdarg.h --- glibc-1.07/stdarg.h Fri Nov 12 20:54:16 1993 +++ glibc-1.08.1/stdarg.h @@ -1,160 +0,0 @@ -/* stdarg.h for GNU. - Note that the type used in va_arg is supposed to match the - actual type **after default promotions**. - Thus, va_arg (..., short) is not valid. */ - -#ifndef _STDARG_H -#ifndef _ANSI_STDARG_H_ -#ifndef __need___va_list -#define _STDARG_H -#define _ANSI_STDARG_H_ -#endif /* not __need___va_list */ -#undef __need___va_list - -#ifndef __GNUC__ -/* Use the system's macros with the system's compiler. - This is relevant only when building GCC with some other compiler. */ -#include -#else -#ifdef __clipper__ -#include -#else -#ifdef __m88k__ -#include -#else -#ifdef __i860__ -#include -#else -#ifdef __hppa__ -#include -#else -#ifdef __mips__ -#include -#else -#ifdef __sparc__ -#include -#else -#ifdef __i960__ -#include -#else -#ifdef __alpha__ -#include -#else -#if defined (__H8300__) || defined (__H8300H__) -#include -#else - -/* Define __gnuc_va_list. */ - -#ifndef __GNUC_VA_LIST -#define __GNUC_VA_LIST -#if defined(__svr4__) || defined(_AIX) || defined(_M_UNIX) -typedef char *__gnuc_va_list; -#else -typedef void *__gnuc_va_list; -#endif -#endif - -/* Define the standard macros for the user, - if this invocation was from the user program. */ -#ifdef _STDARG_H - -/* Amount of space required in an argument list for an arg of type TYPE. - TYPE may alternatively be an expression whose type is used. */ - -#define __va_rounded_size(TYPE) \ - (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)) - -#define va_start(AP, LASTARG) \ - (AP = ((__gnuc_va_list) __builtin_next_arg ())) - -#undef va_end -void va_end (__gnuc_va_list); /* Defined in libgcc.a */ -#define va_end(AP) - -/* We cast to void * and then to TYPE * because this avoids - a warning about increasing the alignment requirement. */ - -#if defined (__arm__) || defined (__i386__) || defined (__i860__) || defined (__ns32000__) || defined (__vax__) -/* This is for little-endian machines; small args are padded upward. */ -#define va_arg(AP, TYPE) \ - (AP = (__gnuc_va_list) ((char *) (AP) + __va_rounded_size (TYPE)), \ - *((TYPE *) (void *) ((char *) (AP) - __va_rounded_size (TYPE)))) -#else /* big-endian */ -/* This is for big-endian machines; small args are padded downward. */ -#define va_arg(AP, TYPE) \ - (AP = (__gnuc_va_list) ((char *) (AP) + __va_rounded_size (TYPE)), \ - *((TYPE *) (void *) ((char *) (AP) - ((sizeof (TYPE) < 4 \ - ? sizeof (TYPE) \ - : __va_rounded_size (TYPE)))))) -#endif /* big-endian */ -#endif /* _STDARG_H */ - -#endif /* not h8300 */ -#endif /* not alpha */ -#endif /* not i960 */ -#endif /* not sparc */ -#endif /* not mips */ -#endif /* not hppa */ -#endif /* not i860 */ -#endif /* not m88k */ -#endif /* not clipper */ - -#ifdef _STDARG_H -/* Define va_list, if desired, from __gnuc_va_list. */ -/* We deliberately do not define va_list when called from - stdio.h, because ANSI C says that stdio.h is not supposed to define - va_list. stdio.h needs to have access to that data type, - but must not use that name. It should use the name __gnuc_va_list, - which is safe because it is reserved for the implementation. */ - -#ifdef _HIDDEN_VA_LIST /* On OSF1, this means varargs.h is "half-loaded". */ -#undef _VA_LIST -#endif - -#ifdef _BSD_VA_LIST -#undef _BSD_VA_LIST -#endif - -#ifdef __svr4__ -/* SVR4.2 uses _VA_LIST for an internal alias for va_list, - so we must avoid testing it and setting it here. - SVR4 uses _VA_LIST as a flag in stdarg.h, but we should - have no conflict with that. */ -#ifndef _VA_LIST_ -#define _VA_LIST_ -#ifdef __i860__ -#ifndef _VA_LIST -#define _VA_LIST va_list -#endif -#endif /* __i860__ */ -typedef __gnuc_va_list va_list; -#endif /* _VA_LIST_ */ -#else /* not __svr4__ */ - -/* The macro _VA_LIST_ is the same thing used by this file in Ultrix. - But on BSD NET2 we must not test or define or undef it. - (Note that the comments in NET 2's ansi.h - are incorrect for _VA_LIST_--see stdio.h!) */ -#if !defined (_VA_LIST_) || defined (__BSD_NET2__) || defined (____386BSD____) || defined (__bsdi__) -/* The macro _VA_LIST is used in SCO Unix 3.2. */ -#ifndef _VA_LIST -/* The macro _VA_LIST_T_H is used in the Bull dpx2 */ -#ifndef _VA_LIST_T_H -#define _VA_LIST_T_H -#if !(defined (__BSD_NET2__) || defined (____386BSD____) || defined (__bsdi__)) -#define _VA_LIST_ -#endif -#define _VA_LIST -typedef __gnuc_va_list va_list; -#endif /* not _VA_LIST_T_H */ -#endif /* not _VA_LIST */ -#endif /* not _VA_LIST_ */ - -#endif /* not __svr4__ */ - -#endif /* _STDARG_H */ - -#endif /* __GNUC__ */ -#endif /* not _ANSI_STDARG_H_ */ -#endif /* not _STDARG_H */ diff -ruN glibc-1.07/stddef.h glibc-1.08.1/stddef.h --- glibc-1.07/stddef.h Fri Dec 3 06:47:17 1993 +++ glibc-1.08.1/stddef.h Mon Apr 25 14:13:23 1994 @@ -22,7 +22,7 @@ /* On 4.3bsd-net2, make sure ansi.h is included, so we have one less case to deal with in the following. */ -#if defined (__BSD_NET2__) || defined (____386BSD____) +#if defined (__BSD_NET2__) || defined (____386BSD____) || defined (__FreeBSD__) #include #endif @@ -172,14 +172,7 @@ #ifndef __WCHAR_TYPE__ #define __WCHAR_TYPE__ int #endif -#ifdef __GNUG__ -/* In C++, wchar_t is a distinct basic type, - and we can expect __wchar_t to be defined by cc1plus. */ -typedef __wchar_t wchar_t; -#else -/* In C, cpp tells us which type to make an alias for. */ typedef __WCHAR_TYPE__ wchar_t; -#endif #endif #endif #endif diff -ruN glibc-1.07/stdio/Makefile glibc-1.08.1/stdio/Makefile --- glibc-1.07/stdio/Makefile Sun Jan 16 00:14:45 1994 +++ glibc-1.08.1/stdio/Makefile Mon May 23 19:35:36 1994 @@ -29,7 +29,7 @@ newstream fopen freopen fdopen fopncook fmemopen \ setbuf setvbuf setbuffer setlinebuf \ fseek ftell rewind fgetpos fsetpos \ - vfprintf vprintf printf_fp reg-printf printf-prs \ + vfprintf vprintf printf_fp reg-printf printf-prs _itoa \ vsnprintf vsprintf vasprintf \ fprintf printf snprintf sprintf asprintf \ dprintf vdprintf \ @@ -55,10 +55,10 @@ routines := $(strip $(routines) $(mpn-routines)) dbl2mpn aux := errlist siglist defs syms-stdio glue mp_clz_tab -distribute = $(mpn-headers) mpn-copy.mk +distribute = $(mpn-headers) mpn-copy.mk _itoa.h tests := tst-printf tstscanf test_rdwr test-popen tstgetln test-fseek \ - bug1 bug2 bug3 bug4 bug5 bug6 temptest + bug1 bug2 bug3 bug4 bug5 bug6 temptest tst-fileno xbug include ../Rules @@ -86,7 +86,7 @@ mpn-copy-1 := $(patsubst $(gmp-srcdir)/mpn/%,$(sysdep_dir)/%,$(mpn-found)) mpn-copy-sysdep := $(mpn-copy-sysdep) $(mpn-copy-1) -$(mpn-copy-1): $(sysdep_dir)/%: gmp2glibc.sed $(gmp-srcdir)/mpn/% +$(mpn-copy-1): $(sysdep_dir)/%: $(ignore gmp2glibc.sed) $(gmp-srcdir)/mpn/% $(gmp2glibc) mpn-stuff = $(mpn-copy-sysdep) $(mpn-copy) @@ -93,13 +93,14 @@ # chmod so I don't edit them by mistake. define gmp2glibc -sed -f $^ > $@-tmp +$(ignore sed -f $^ > $@-tmp) +cp $< $@-tmp chmod a-w $@-tmp mv -f $@-tmp $@ endef mpn-copy = $(filter-out $(mpn-sysdep),$(mpn-headers) mp_clz_tab.c) -$(mpn-copy): %: gmp2glibc.sed $(gmp-srcdir)/%; $(gmp2glibc) +$(mpn-copy): %: $(ignore gmp2glibc.sed) $(gmp-srcdir)/%; $(gmp2glibc) .PHONY: copy-mpn clean-mpn copy-mpn: $(mpn-stuff) diff -ruN glibc-1.07/stdio/__vfscanf.c glibc-1.08.1/stdio/__vfscanf.c --- glibc-1.07/stdio/__vfscanf.c Thu Jan 6 01:31:34 1994 +++ glibc-1.08.1/stdio/__vfscanf.c Thu Feb 3 21:11:03 1994 @@ -433,7 +433,6 @@ } break; -#ifndef MIB_HACKS case 'e': /* Floating-point numbers. */ case 'E': case 'f': @@ -481,6 +480,7 @@ if (w[-1] == '-' || w[-1] == '+' || w[-1] == 'e') conv_error(); +#ifndef MIB_HACKS /* Convert the number. */ *w = '\0'; fp_num = strtod(work, &w); diff -ruN glibc-1.07/stdio/_itoa.c glibc-1.08.1/stdio/_itoa.c --- glibc-1.07/stdio/_itoa.c +++ glibc-1.08.1/stdio/_itoa.c Sat Feb 5 15:39:04 1994 @@ -0,0 +1,45 @@ +/* Internal function for converting integers to ASCII. +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 "_itoa.h" + +/* Lower-case digits. */ +CONST char _itoa_lower_digits[] = "0123456789abcdefghijklmnopqrstuvwxyz"; +/* Upper-case digits. */ +CONST char _itoa_upper_digits[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + +char * +DEFUN(_itoa, (value, buflim, base, upper_case), + unsigned long int value AND char *buflim AND + unsigned int base AND int upper_case) +{ + /* Base-36 digits for numbers. */ + CONST char *digits = upper_case ? _itoa_upper_digits : _itoa_lower_digits; + + register char *bp = buflim; + + while (value > 0) + { + *--bp = digits[value % base]; + value /= base; + } + + return bp; +} diff -ruN glibc-1.07/stdio/_itoa.h glibc-1.08.1/stdio/_itoa.h --- glibc-1.07/stdio/_itoa.h +++ glibc-1.08.1/stdio/_itoa.h Thu Feb 3 21:06:45 1994 @@ -0,0 +1,54 @@ +/* Internal function for converting integers to ASCII. +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 _ITOA_H +#define _ITOA_H +#include + +extern const char _itoa_lower_digits[], _itoa_upper_digits[]; + +/* Convert VALUE into ASCII in base BASE (2..36). + Write backwards starting the character just before BUFLIM. + 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, + unsigned int base, int upper_case)); + +#if defined (__GNUC__) && defined (__OPTIMIZE__) +extern __inline char * +_itoa (unsigned long int value, char *buflim, + unsigned int base, int upper_case) +{ + /* Base-36 digits for numbers. */ + const char *digits = upper_case ? _itoa_upper_digits : _itoa_lower_digits; + + register char *bp = buflim; + + while (value > 0) + { + *--bp = digits[value % base]; + value /= base; + } + + return bp; +} +#endif + +#endif /* itoa.h */ diff -ruN glibc-1.07/stdio/fileno.c glibc-1.08.1/stdio/fileno.c --- glibc-1.07/stdio/fileno.c Wed May 26 18:29:32 1993 +++ glibc-1.08.1/stdio/fileno.c Mon Jan 24 16:59:33 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,11 +24,15 @@ int DEFUN(fileno, (stream), FILE *stream) { + extern void __stdio_check_funcs __P ((FILE *)); + if (! __validfp (stream)) { errno = EINVAL; return -1; } + + __stdio_check_funcs (stream); if (stream->__io_funcs.__fileno == NULL) { diff -ruN glibc-1.07/stdio/freopen.c glibc-1.08.1/stdio/freopen.c --- glibc-1.07/stdio/freopen.c Wed Jun 12 14:09:06 1991 +++ glibc-1.08.1/stdio/freopen.c Tue May 31 20:10: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 @@ -21,31 +21,47 @@ #include +/* Defined in fopen.c. */ +extern int __getmode __P ((const char *, __io_mode *)); + + /* Replace STREAM, opening it on FILENAME. */ FILE * DEFUN(freopen, (filename, mode, stream), CONST char *filename AND CONST char *mode AND register FILE *stream) { - FILE *head; + __io_mode m; + PTR cookie; - if (!__validfp(stream)) + if (!__getmode (mode, &m)) { + (void) fclose (stream); errno = EINVAL; return NULL; } - /* Return value explicitly ignored. */ - (void) fclose(stream); - - /* Make sure STREAM will be the first one checked. */ - head = __stdio_head; - __stdio_head = stream; - - /* This will return either STREAM or NULL. */ - stream = fopen(filename, mode); + if (stream->__mode.__write) + /* Flush the stream. */ + (void) fflush (stream); + + /* Open the file, attempting to preserve the old cookie value. */ + cookie = stream->__cookie; + if (__stdio_reopen (filename, m, &cookie, stream->__io_funcs.__close)) + { + int save = errno; + (void) fclose (stream); + errno = save; + return NULL; + } - /* Restore the saved value. */ - __stdio_head = head; + /* Close the stream, first disabling its cookie close function because + __stdio_reopen has already dealt with closing the old cookie. */ + stream->__io_funcs.__close = NULL; + (void) fclose (stream); + + stream->__magic = _IOMAGIC; + stream->__cookie = cookie; + stream->__mode = m; return stream; } diff -ruN glibc-1.07/stdio/gets.c glibc-1.08.1/stdio/gets.c --- glibc-1.07/stdio/gets.c Sun Mar 8 15:40:56 1992 +++ glibc-1.08.1/stdio/gets.c Mon May 23 20:38:51 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 @@ -53,7 +53,12 @@ *p++ = c; *p = '\0'; - if (p == s || ferror(stream)) + + /* Return null if we had an error, or if we got EOF + before writing any characters. */ + + if (ferror (stream) || (feof (stream) && p == s)) return NULL; + return s; } diff -ruN glibc-1.07/stdio/gmp-impl.h glibc-1.08.1/stdio/gmp-impl.h --- glibc-1.07/stdio/gmp-impl.h Sun Jan 16 00:17:22 1994 +++ glibc-1.08.1/stdio/gmp-impl.h Mon May 16 21:58:03 1994 @@ -1,28 +1,24 @@ /* Include file for internal GNU MP types and definitions. -Copyright (C) 1991, 1993 Free Software Foundation, Inc. +Copyright (C) 1991, 1993, 1994 Free Software Foundation, Inc. +This file is part of the GNU MP Library. -! This file is part of the GNU C Library. Its master source is NOT part of -! the C library, however. This file is in fact copied from the GNU MP -! Library and its source lives there. +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 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 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. -! 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 MP Library; see the file COPYING.LIB. If not, write to +the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -! 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 alloca +#if ! defined (alloca) #if defined (__GNUC__) || defined (__sparc__) || defined (sparc) #define alloca __builtin_alloca #endif @@ -44,7 +40,7 @@ #define MAX(h,i) ((h) > (i) ? (h) : (i)) #include "gmp-mparam.h" -#include "longlong.h" +/* #include "longlong.h" */ #ifdef __STDC__ void *malloc (size_t); @@ -163,16 +159,16 @@ #define MPN_MUL_N_RECURSE(prodp, up, vp, size, tspace) \ do { \ if ((size) < KARATSUBA_THRESHOLD) \ - ___mpn_mul_n_basecase (prodp, up, vp, size); \ + ____mpn_mul_n_basecase (prodp, up, vp, size); \ else \ - ___mpn_mul_n (prodp, up, vp, size, tspace); \ + ____mpn_mul_n (prodp, up, vp, size, tspace); \ } while (0); #define MPN_SQR_N_RECURSE(prodp, up, size, tspace) \ do { \ if ((size) < KARATSUBA_THRESHOLD) \ - ___mpn_sqr_n_basecase (prodp, up, size); \ + ____mpn_sqr_n_basecase (prodp, up, size); \ else \ - ___mpn_sqr_n (prodp, up, size, tspace); \ + ____mpn_sqr_n (prodp, up, size, tspace); \ } while (0); /* Structure for conversion between internal binary format and @@ -208,8 +204,8 @@ Put the quotient in Q and the remainder in R. */ #define udiv_qrnnd_preinv(q, r, nh, nl, d, di) \ do { \ - unsigned long int _q, _ql, _r; \ - unsigned long int _xh, _xl; \ + mp_limb _q, _ql, _r; \ + mp_limb _xh, _xl; \ umul_ppmm (_q, _ql, (nh), (di)); \ _q += (nh); /* DI is 2**BITS_PER_MP_LIMB too small */\ umul_ppmm (_xh, _xl, _q, (d)); \ @@ -232,3 +228,58 @@ (r) = _r; \ (q) = _q; \ } while (0) +#define udiv_qrnnd_preinv2gen(q, r, nh, nl, d, di, dnorm, lgup) \ + do { \ + mp_limb n2, n10, n1, nadj, q1; \ + mp_limb _xh, _xl; \ + n2 = ((nh) << (BITS_PER_MP_LIMB - (lgup))) + ((nl) >> 1 >> (l - 1));\ + n10 = (nl) << (BITS_PER_MP_LIMB - (lgup)); \ + n1 = ((mp_limb_signed) n10 >> (BITS_PER_MP_LIMB - 1)); \ + nadj = n10 + (n1 & (dnorm)); \ + umul_ppmm (_xh, _xl, di, n2 - n1); \ + add_ssaaaa (_xh, _xl, _xh, _xl, 0, nadj); \ + q1 = ~(n2 + _xh); \ + umul_ppmm (_xh, _xl, q1, d); \ + add_ssaaaa (_xh, _xl, _xh, _xl, nh, nl); \ + _xh -= (d); \ + (r) = _xl + ((d) & _xh); \ + (q) = _xh - q1; \ + } while (0) +#define udiv_qrnnd_preinv2norm(q, r, nh, nl, d, di) \ + do { \ + mp_limb n2, n10, n1, nadj, q1; \ + mp_limb _xh, _xl; \ + n2 = (nh); \ + n10 = (nl); \ + n1 = ((mp_limb_signed) n10 >> (BITS_PER_MP_LIMB - 1)); \ + nadj = n10 + (n1 & (d)); \ + umul_ppmm (_xh, _xl, di, n2 - n1); \ + add_ssaaaa (_xh, _xl, _xh, _xl, 0, nadj); \ + q1 = ~(n2 + _xh); \ + umul_ppmm (_xh, _xl, q1, d); \ + add_ssaaaa (_xh, _xl, _xh, _xl, nh, nl); \ + _xh -= (d); \ + (r) = _xl + ((d) & _xh); \ + (q) = _xh - q1; \ + } while (0) + +#if defined (__GNUC__) +/* Define stuff for longlong.h asm macros. */ +#if __GNUC_NEW_ATTR_MODE_SYNTAX +typedef unsigned int UQItype __attribute__ ((mode ("QI"))); +typedef int SItype __attribute__ ((mode ("SI"))); +typedef unsigned int USItype __attribute__ ((mode ("SI"))); +typedef int DItype __attribute__ ((mode ("DI"))); +typedef unsigned int UDItype __attribute__ ((mode ("DI"))); +#else +typedef unsigned int UQItype __attribute__ ((mode (QI))); +typedef int SItype __attribute__ ((mode (SI))); +typedef unsigned int USItype __attribute__ ((mode (SI))); +typedef int DItype __attribute__ ((mode (DI))); +typedef unsigned int UDItype __attribute__ ((mode (DI))); +#endif +#endif + +typedef mp_limb UWtype; +typedef unsigned int UHWtype; +#define W_TYPE_SIZE BITS_PER_MP_LIMB diff -ruN glibc-1.07/stdio/gmp.h glibc-1.08.1/stdio/gmp.h --- glibc-1.07/stdio/gmp.h Sun Jan 16 00:17:20 1994 +++ glibc-1.08.1/stdio/gmp.h Sat May 21 18:25:17 1994 @@ -1,26 +1,22 @@ /* gmp.h -- Definitions for GNU multiple precision functions. -Copyright (C) 1991, 1993 Free Software Foundation, Inc. +Copyright (C) 1991, 1993, 1994 Free Software Foundation, Inc. +This file is part of the GNU MP Library. -! This file is part of the GNU C Library. Its master source is NOT part of -! the C library, however. This file is in fact copied from the GNU MP -! Library and its source lives there. - -! 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 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. */ #ifndef __GMP_H__ @@ -131,322 +127,218 @@ typedef __mpz_struct *mpz_ptr; typedef __gmp_const __mpf_struct *mpf_srcptr; typedef __mpf_struct *mpf_ptr; +typedef __gmp_const __mpq_struct *mpq_srcptr; +typedef __mpq_struct *mpq_ptr; - #ifdef __STDC__ -void mp_set_memory_functions (void *(*) (size_t), - void *(*) (void *, size_t, size_t), - void (*) (void *, size_t)); - -/**************** Integer (i.e. Z) routines. ****************/ - -void mpz_init (mpz_ptr); -void mpz_set (mpz_ptr, mpz_srcptr); -void mpz_set_ui (mpz_ptr, unsigned long int); -void mpz_set_si (mpz_ptr, signed long int); -int mpz_set_str (mpz_ptr, const char *, int); -void mpz_init_set (mpz_ptr, mpz_srcptr); -void mpz_init_set_ui (mpz_ptr, unsigned long int); -void mpz_init_set_si (mpz_ptr, signed long int); -int mpz_init_set_str (mpz_ptr, const char *, int); -unsigned long int mpz_get_ui (mpz_srcptr); -signed long int mpz_get_si (mpz_srcptr); -char * mpz_get_str (char *, int, mpz_srcptr); -void mpz_clear (mpz_ptr); -void * _mpz_realloc (mpz_ptr, mp_size_t); -void mpz_add (mpz_ptr, mpz_srcptr, mpz_srcptr); -void mpz_add_ui (mpz_ptr, mpz_srcptr, unsigned long int); -void mpz_sub (mpz_ptr, mpz_srcptr, mpz_srcptr); -void mpz_sub_ui (mpz_ptr, mpz_srcptr, unsigned long int); -void mpz_mul (mpz_ptr, mpz_srcptr, mpz_srcptr); -void mpz_mul_ui (mpz_ptr, mpz_srcptr, unsigned long int); -void mpz_div (mpz_ptr, mpz_srcptr, mpz_srcptr); -void mpz_div_ui (mpz_ptr, mpz_srcptr, unsigned long int); -void mpz_mod (mpz_ptr, mpz_srcptr, mpz_srcptr); -void mpz_mod_ui (mpz_ptr, mpz_srcptr, unsigned long int); -void mpz_divmod (mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr); -void mpz_divmod_ui (mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int); -void mpz_mdiv (mpz_ptr, mpz_srcptr, mpz_srcptr); -void mpz_mdiv_ui (mpz_ptr, mpz_srcptr, unsigned long int); -void mpz_mmod (mpz_ptr, mpz_srcptr, mpz_srcptr); -unsigned long int mpz_mmod_ui (mpz_ptr, mpz_srcptr, unsigned long int); -void mpz_mdivmod (mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr); -unsigned long int mpz_mdivmod_ui (mpz_ptr, mpz_ptr, mpz_srcptr, - unsigned long int); -void mpz_sqrt (mpz_ptr, mpz_srcptr); -void mpz_sqrtrem (mpz_ptr, mpz_ptr, mpz_srcptr); -int mpz_perfect_square_p (mpz_srcptr); -int mpz_probab_prime_p (mpz_srcptr, int); -void mpz_powm (mpz_ptr, mpz_srcptr, mpz_srcptr, mpz_srcptr); -void mpz_powm_ui (mpz_ptr, mpz_srcptr, unsigned long int, mpz_srcptr); -void mpz_pow_ui (mpz_ptr, mpz_srcptr, unsigned long int); -void mpz_fac_ui (mpz_ptr, unsigned long int); -void mpz_gcd (mpz_ptr, mpz_srcptr, mpz_srcptr); -void mpz_gcdext (mpz_ptr, mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr); -int mpz_divides(mpz_srcptr, mpz_srcptr); -void mpz_neg (mpz_ptr, mpz_srcptr); -void mpz_com (mpz_ptr, mpz_srcptr src); -void mpz_abs (mpz_ptr, mpz_srcptr); -int mpz_cmp (mpz_srcptr, mpz_srcptr); -int mpz_cmp_ui (mpz_srcptr, unsigned long int); -int mpz_cmp_si (mpz_srcptr, signed long int); -void mpz_mul_2exp (mpz_ptr, mpz_srcptr, unsigned long int); -void mpz_div_2exp (mpz_ptr, mpz_srcptr, unsigned long int); -void mpz_mod_2exp (mpz_ptr, mpz_srcptr, unsigned long int); -void mpz_and (mpz_ptr, mpz_srcptr, mpz_srcptr); -void mpz_ior (mpz_ptr, mpz_srcptr, mpz_srcptr); -void mpz_xor (mpz_ptr, mpz_srcptr, mpz_srcptr); -void mpz_not (mpz_ptr, mpz_srcptr); - -#ifdef FILE -void mpz_inp_raw (mpz_ptr, FILE *); -void mpz_inp_str (mpz_ptr, FILE *, int); -void mpz_out_raw (FILE *, mpz_srcptr); -void mpz_out_str (FILE *, int, mpz_srcptr); +#define _PROTO(x) x +#else +#define _PROTO(x) () #endif -void mpz_array_init (mpz_ptr [], size_t, mp_size_t); -void mpz_random (mpz_ptr, mp_size_t); -void mpz_random2 (mpz_ptr, mp_size_t); -size_t mpz_size (mpz_srcptr); -size_t mpz_sizeinbase (mpz_srcptr, int); - -/**************** Rational (i.e. Q) routines. ****************/ - -void mpq_init (MP_RAT *); -void mpq_clear (MP_RAT *); -void mpq_set (MP_RAT *, const MP_RAT *); -void mpq_set_ui (MP_RAT *, unsigned long int, unsigned long int); -void mpq_set_si (MP_RAT *, signed long int, unsigned long int); -void mpq_add (MP_RAT *, const MP_RAT *, const MP_RAT *); -void mpq_sub (MP_RAT *, const MP_RAT *, const MP_RAT *); -void mpq_mul (MP_RAT *, const MP_RAT *, const MP_RAT *); -void mpq_div (MP_RAT *, const MP_RAT *, const MP_RAT *); -void mpq_neg (MP_RAT *, const MP_RAT *); -int mpq_cmp (const MP_RAT *, const MP_RAT *); -void mpq_inv (MP_RAT *, const MP_RAT *); -void mpq_set_num (MP_RAT *, mpz_srcptr); -void mpq_set_den (MP_RAT *, mpz_srcptr); -void mpq_get_num (mpz_ptr, const MP_RAT *); -void mpq_get_den (mpz_ptr, const MP_RAT *); +void mp_set_memory_functions _PROTO((void *(*) (size_t), + void *(*) (void *, size_t, size_t), + void (*) (void *, size_t))); -/**************** Float (i.e. F) routines. ****************/ - -char *mpf_get_str (char *, mp_exp_t *, int, size_t, mpf_srcptr); -mp_size_t mpf_set_default_prec (mp_size_t); -void mpf_init (mpf_ptr); -void mpf_init_set (mpf_ptr, mpf_srcptr); -void mpf_init_set_ui (mpf_ptr, unsigned int); -void mpf_init_set_si (mpf_ptr, int); -void mpf_set (mpf_ptr, mpf_srcptr); -void mpf_add (mpf_ptr, mpf_srcptr, mpf_srcptr); -void mpf_add_ui (mpf_ptr, mpf_srcptr, unsigned int); -void mpf_sub (mpf_ptr, mpf_srcptr, mpf_srcptr); -void mpf_sub_ui (mpf_ptr, mpf_srcptr, unsigned int); -void mpf_ui_sub (mpf_ptr, unsigned int, mpf_srcptr); -void mpf_mul (mpf_ptr, mpf_srcptr, mpf_srcptr); -void mpf_mul_ui (mpf_ptr, mpf_srcptr, unsigned int); -void mpf_div (mpf_ptr, mpf_srcptr, mpf_srcptr); -void mpf_div_ui (mpf_ptr, mpf_srcptr, unsigned int); -void mpf_ui_div (mpf_ptr, unsigned int, mpf_srcptr); -void mpf_sqrt (mpf_ptr, mpf_srcptr); -void mpf_sqrt_ui (mpf_ptr, unsigned int); -int mpf_cmp (mpf_srcptr, mpf_srcptr); - - -/************ Low level positive-integer (i.e. N) routines. ************/ - -/* mp_limb __mpn_add (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t); */ -mp_limb __mpn_add_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); -/* mp_limb __mpn_add_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb); */ - -/* mp_limb __mpn_sub (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t); */ -mp_limb __mpn_sub_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); -/* mp_limb __mpn_sub_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb); */ - -mp_limb __mpn_mul (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t); -void __mpn_mul_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); -mp_limb __mpn_mul_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb); -mp_limb __mpn_addmul_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb); -mp_limb __mpn_submul_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb); - -mp_limb __mpn_divmod (mp_ptr, mp_ptr, mp_size_t, mp_srcptr, mp_size_t); -mp_limb __mpn_divmod_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb); -mp_limb __mpn_mod_1 (mp_srcptr, mp_size_t, mp_limb); - -mp_limb __mpn_lshift (mp_ptr, mp_srcptr, mp_size_t, unsigned int); -mp_limb __mpn_rshift (mp_ptr, mp_srcptr, mp_size_t, unsigned int); -mp_limb __mpn_rshiftci (mp_ptr, mp_srcptr, mp_size_t, unsigned int, mp_limb); -mp_size_t __mpn_sqrt (mp_ptr, mp_ptr, mp_srcptr, mp_size_t); -int __mpn_cmp (mp_srcptr, mp_srcptr, mp_size_t); - -void __mpn_random2 (mp_ptr, mp_size_t); -mp_size_t __mpn_set_str (mp_ptr, const unsigned char *, size_t, int); -size_t __mpn_get_str (unsigned char *, int, mp_ptr, mp_size_t); - -mp_size_t __mpn_bingcd (mp_ptr, mp_ptr, mp_size_t, mp_ptr, mp_size_t); -mp_size_t __mpn_accelgcd (mp_ptr, mp_ptr, mp_size_t, mp_ptr, mp_size_t); -mp_size_t __mpn_bmod (mp_ptr, mp_size_t, mp_srcptr, mp_size_t); -mp_size_t __mpn_bmodgcd (mp_ptr, mp_ptr, mp_size_t, mp_ptr, mp_size_t); -void __mpn_compl (mp_ptr, mp_srcptr, mp_size_t); -mp_limb __mpn_compl_rsh (mp_ptr, mp_srcptr, mp_size_t, unsigned int); -mp_limb __mpn_sub_n_rsh (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t, unsigned int); - -#else /* ! __STDC__ */ -void mp_set_memory_functions (); - /**************** Integer (i.e. Z) routines. ****************/ -void mpz_init (); -void mpz_set (); -void mpz_set_ui (); -void mpz_set_si (); -int mpz_set_str (); -void mpz_init_set (); -void mpz_init_set_ui (); -void mpz_init_set_si (); -int mpz_init_set_str (); -unsigned long int mpz_get_ui (); -long int mpz_get_si (); -char * mpz_get_str (); -void mpz_clear (); -void * _mpz_realloc (); -void mpz_add (); -void mpz_add_ui (); -void mpz_sub (); -void mpz_sub_ui (); -void mpz_mul (); -void mpz_mul_ui (); -void mpz_div (); -void mpz_div_ui (); -void mpz_mod (); -void mpz_mod_ui (); -void mpz_divmod (); -void mpz_divmod_ui (); -void mpz_mdiv (); -void mpz_mdiv_ui (); -void mpz_mmod (); -unsigned long int mpz_mmod_ui (); -void mpz_mdivmod (); -unsigned long int mpz_mdivmod_ui (); -void mpz_sqrt (); -void mpz_sqrtrem (); -int mpz_perfect_square_p (); -int mpz_probab_prime_p (); -void mpz_powm (); -void mpz_powm_ui (); -void mpz_pow_ui (); -void mpz_fac_ui (); -void mpz_gcd (); -void mpz_gcdext (); -int mpz_divides(); -void mpz_neg (); -void mpz_com (); -void mpz_abs (); -int mpz_cmp (); -int mpz_cmp_ui (); -int mpz_cmp_si (); -void mpz_mul_2exp (); -void mpz_div_2exp (); -void mpz_mod_2exp (); -void mpz_and (); -void mpz_ior (); -void mpz_xor (); -void mpz_not (); - +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)); +void mpz_and _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr)); +void mpz_clear _PROTO ((mpz_ptr)); +void mpz_clrbit _PROTO ((mpz_ptr, unsigned long int)); +int mpz_cmp _PROTO ((mpz_srcptr, mpz_srcptr)); +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)); +void mpz_gcdext _PROTO ((mpz_ptr, mpz_ptr, mpz_ptr, mpz_srcptr, 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)); +mp_size_t mpz_hamdist _PROTO ((mpz_srcptr, mpz_srcptr)); +void mpz_init _PROTO ((mpz_ptr)); #ifdef FILE -void mpz_inp_raw (); -void mpz_inp_str (); -void mpz_out_raw (); -void mpz_out_str (); +void mpz_inp_raw _PROTO ((mpz_ptr, FILE *)); +int mpz_inp_str _PROTO ((mpz_ptr, FILE *, int)); #endif - -void mpz_array_init (); -void mpz_random (); -void mpz_random2 (); -size_t mpz_size (); -size_t mpz_sizeinbase (); +void mpz_ior _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr)); +void mpz_init_set _PROTO ((mpz_ptr, mpz_srcptr)); +void mpz_init_set_si _PROTO ((mpz_ptr, signed long int)); +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)); +void mpz_neg _PROTO ((mpz_ptr, mpz_srcptr)); +#ifdef FILE +void mpz_out_raw _PROTO ((FILE *, mpz_srcptr)); +void mpz_out_str _PROTO ((FILE *, int, mpz_srcptr)); +#endif +int mpz_perfect_square_p _PROTO ((mpz_srcptr)); +mp_size_t mpz_popcount _PROTO ((mpz_srcptr)); +void mpz_pow_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int)); +void mpz_powm _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr, mpz_srcptr)); +void mpz_powm_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int, mpz_srcptr)); +int mpz_probab_prime_p _PROTO ((mpz_srcptr, int)); +void mpz_random _PROTO ((mpz_ptr, mp_size_t)); +void mpz_random2 _PROTO ((mpz_ptr, mp_size_t)); +void mpz_set _PROTO ((mpz_ptr, mpz_srcptr)); +void mpz_set_si _PROTO ((mpz_ptr, signed long int)); +int mpz_set_str _PROTO ((mpz_ptr, const char *, int)); +void mpz_set_ui _PROTO ((mpz_ptr, unsigned long int)); +size_t mpz_size _PROTO ((mpz_srcptr)); +size_t mpz_sizeinbase _PROTO ((mpz_srcptr, int)); +void mpz_sqrt _PROTO ((mpz_ptr, mpz_srcptr)); +void mpz_sqrtrem _PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr)); +void mpz_sub _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr)); +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)); /**************** Rational (i.e. Q) routines. ****************/ -void mpq_init (); -void mpq_clear (); -void mpq_set (); -void mpq_set_ui (); -void mpq_set_si (); -void mpq_add (); -void mpq_sub (); -void mpq_mul (); -void mpq_div (); -void mpq_neg (); -int mpq_cmp (); -void mpq_inv (); -void mpq_set_num (); -void mpq_set_den (); -void mpq_get_num (); -void mpq_get_den (); +void mpq_init _PROTO ((mpq_ptr)); +void mpq_clear _PROTO ((mpq_ptr)); +void mpq_set _PROTO ((mpq_ptr, mpq_srcptr)); +void mpq_set_ui _PROTO ((mpq_ptr, unsigned long int, unsigned long int)); +void mpq_set_si _PROTO ((mpq_ptr, signed long int, unsigned long int)); +void mpq_add _PROTO ((mpq_ptr, mpq_srcptr, mpq_srcptr)); +void mpq_sub _PROTO ((mpq_ptr, mpq_srcptr, mpq_srcptr)); +void mpq_mul _PROTO ((mpq_ptr, mpq_srcptr, mpq_srcptr)); +void mpq_div _PROTO ((mpq_ptr, mpq_srcptr, mpq_srcptr)); +void mpq_neg _PROTO ((mpq_ptr, mpq_srcptr)); +int mpq_cmp _PROTO ((mpq_srcptr, mpq_srcptr)); +void mpq_inv _PROTO ((mpq_ptr, mpq_srcptr)); +void mpq_set_num _PROTO ((mpq_ptr, mpz_srcptr)); +void mpq_set_den _PROTO ((mpq_ptr, mpz_srcptr)); +void mpq_get_num _PROTO ((mpz_ptr, mpq_srcptr)); +void mpq_get_den _PROTO ((mpz_ptr, mpq_srcptr)); /**************** Float (i.e. F) routines. ****************/ -char *mpf_get_str (); -mp_size_t mpf_set_default_prec (); -void mpf_init (); -void mpf_init_set (); -void mpf_init_set_ui (); -void mpf_init_set_si (); -void mpf_set (); -void mpf_add (); -void mpf_add_ui (); -void mpf_sub (); -void mpf_sub_ui (); -void mpf_ui_sub (); -void mpf_mul (); -void mpf_mul_ui (); -void mpf_div (); -void mpf_div_ui (); -void mpf_ui_div (); -void mpf_sqrt (); -void mpf_sqrt_ui (); -int mpf_cmp (); +void mpf_abs _PROTO ((mpf_ptr, mpf_srcptr)); +void mpf_add _PROTO ((mpf_ptr, mpf_srcptr, mpf_srcptr)); +void mpf_add_ui _PROTO ((mpf_ptr, mpf_srcptr, unsigned long int)); +void mpf_clear _PROTO ((mpf_ptr)); +int mpf_cmp _PROTO ((mpf_srcptr, mpf_srcptr)); +int mpf_cmp_si _PROTO ((mpf_srcptr, long int)); +int mpf_cmp_ui _PROTO ((mpf_srcptr, unsigned long int)); +void mpf_div _PROTO ((mpf_ptr, mpf_srcptr, mpf_srcptr)); +void mpf_div_2exp _PROTO ((mpf_ptr, mpf_srcptr, unsigned long int)); +void mpf_div_ui _PROTO ((mpf_ptr, mpf_srcptr, unsigned long int)); +void mpf_dump _PROTO ((mpf_srcptr)); +char *mpf_get_str _PROTO ((char *, mp_exp_t *, int, size_t, mpf_srcptr)); +void mpf_init _PROTO ((mpf_ptr)); +void mpf_init2 _PROTO ((mpf_ptr, mp_size_t)); +#ifdef FILE +void mpf_inp_str _PROTO ((mpf_ptr, FILE *, int)); +#endif +void mpf_init_set _PROTO ((mpf_ptr, mpf_srcptr)); +void mpf_init_set_d _PROTO ((mpf_ptr, double)); +void mpf_init_set_si _PROTO ((mpf_ptr, long int)); +int mpf_init_set_str _PROTO ((mpf_ptr, char *, int)); +void mpf_init_set_ui _PROTO ((mpf_ptr, unsigned long int)); +void mpf_mul _PROTO ((mpf_ptr, mpf_srcptr, mpf_srcptr)); +void mpf_mul_2exp _PROTO ((mpf_ptr, mpf_srcptr, unsigned long int)); +void mpf_mul_ui _PROTO ((mpf_ptr, mpf_srcptr, unsigned long int)); +void mpf_neg _PROTO ((mpf_ptr, mpf_srcptr)); +#ifdef FILE +void mpf_out_str _PROTO ((mpf_ptr, int, size_t, FILE *)); +#endif +void mpf_set _PROTO ((mpf_ptr, mpf_srcptr)); +void mpf_set_d _PROTO ((mpf_ptr, double)); +mp_size_t mpf_set_default_prec _PROTO ((mp_size_t)); +void mpf_set_si _PROTO ((mpf_ptr, long int)); +int mpf_set_str _PROTO ((mpf_ptr, const char *, int)); +void mpf_set_ui _PROTO ((mpf_ptr, unsigned long int)); +size_t mpf_size _PROTO ((mpf_srcptr)); +void mpf_sqrt _PROTO ((mpf_ptr, mpf_srcptr)); +void mpf_sqrt_ui _PROTO ((mpf_ptr, unsigned long int)); +void mpf_sub _PROTO ((mpf_ptr, mpf_srcptr, mpf_srcptr)); +void mpf_sub_ui _PROTO ((mpf_ptr, mpf_srcptr, unsigned long int)); +void mpf_ui_div _PROTO ((mpf_ptr, unsigned long int, mpf_srcptr)); /************ Low level positive-integer (i.e. N) routines. ************/ -/* mp_limb __mpn_add (); */ -mp_limb __mpn_add_n (); -/* mp_limb __mpn_add_1 (); */ - -/* mp_limb __mpn_sub (); */ -mp_limb __mpn_sub_n (); -/* mp_limb __mpn_sub_1 (); */ - -mp_limb __mpn_mul (); -void __mpn_mul_n (); -mp_limb __mpn_mul_1 (); -mp_limb __mpn_addmul_1 (); -mp_limb __mpn_submul_1 (); - -mp_limb __mpn_divmod (); -mp_limb __mpn_divmod_1 (); -mp_limb __mpn_mod_1 (); - -mp_limb __mpn_lshift (); -mp_limb __mpn_rshift (); -mp_limb __mpn_rshiftci (); -mp_size_t __mpn_sqrt (); -int __mpn_cmp (); - -void __mpn_random2 (); -mp_size_t __mpn_set_str (); -size_t __mpn_get_str (); +/* This is ugly, but we need to make usr calls reach the prefixed function. */ +#define mpn_add_n __mpn_add_n +#define mpn_sub_n __mpn_sub_n +#define mpn_mul_1 __mpn_mul_1 +#define mpn_addmul_1 __mpn_addmul_1 +#define mpn_submul_1 __mpn_submul_1 +#define mpn_lshift __mpn_lshift +#define mpn_rshift __mpn_rshift +#define mpn_sub __mpn_sub +#define mpn_add __mpn_add +#define mpn_normal_size __mpn_normal_size +#define mpn_cmp __mpn_cmp +#define mpn_add_1 __mpn_add_1 +#define mpn_sub_1 __mpn_sub_1 +#define mpn_mul_n __mpn_mul_n +#define mpn_mul __mpn_mul +#define mpn_divmod __mpn_divmod +#define mpn_divmod_1 __mpn_divmod_1 +#define mpn_mod_1 __mpn_mod_1 +#define mpn_sqrt __mpn_sqrt +#define mpn_next_bit_set __mpn_next_bit_set +#define mpn_popcount __mpn_popcount +#define mpn_hamdist __mpn_hamdist +#define mpn_random2 __mpn_random2 +#define mpn_set_str __mpn_set_str +#define mpn_get_str __mpn_get_str +#define mpn_gcd_1 __mpn_gcd_1 + +mp_limb __mpn_add_n _PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t)); +mp_limb __mpn_sub_n _PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t)); +mp_limb __mpn_mul _PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t)); +void __mpn_mul_n _PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t)); +mp_limb __mpn_mul_1 _PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb)); +mp_limb __mpn_addmul_1 _PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb)); +mp_limb __mpn_submul_1 _PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb)); +mp_limb __mpn_divmod _PROTO ((mp_ptr, mp_ptr, mp_size_t, mp_srcptr, mp_size_t)); +mp_limb __mpn_divmod_1 _PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb)); +mp_limb __mpn_mod_1 _PROTO ((mp_srcptr, mp_size_t, mp_limb)); +mp_limb __mpn_lshift _PROTO ((mp_ptr, mp_srcptr, mp_size_t, unsigned int)); +mp_limb __mpn_rshift _PROTO ((mp_ptr, mp_srcptr, mp_size_t, unsigned int)); +mp_size_t __mpn_sqrt _PROTO ((mp_ptr, mp_ptr, mp_srcptr, mp_size_t)); +int __mpn_cmp _PROTO ((mp_srcptr, mp_srcptr, mp_size_t)); +mp_size_t __mpn_next_bit_set _PROTO ((mp_srcptr, mp_size_t)); +mp_size_t __mpn_popcount _PROTO ((mp_srcptr, mp_size_t)); +mp_size_t __mpn_hamdist _PROTO ((mp_srcptr, mp_srcptr, mp_size_t)); +void __mpn_random2 _PROTO ((mp_ptr, mp_size_t)); +mp_size_t __mpn_set_str _PROTO ((mp_ptr, const unsigned char *, size_t, int)); +size_t __mpn_get_str _PROTO ((unsigned char *, int, mp_ptr, mp_size_t)); +mp_limb __mpn_gcd_1 _PROTO ((mp_srcptr, mp_size_t, mp_limb)); -#endif /* __STDC__ */ static __gmp_inline mp_limb #if __STDC__ __mpn_add_1 (register mp_ptr res_ptr, - register mp_srcptr s1_ptr, - register mp_size_t s1_size, - register mp_limb s2_limb) + register mp_srcptr s1_ptr, + register mp_size_t s1_size, + register mp_limb s2_limb) #else __mpn_add_1 (res_ptr, s1_ptr, s1_size, s2_limb) register mp_ptr res_ptr; @@ -475,7 +367,11 @@ fin: if (res_ptr != s1_ptr) - memcpy (res_ptr, s1_ptr, (size_t) (s1_size - 1) * sizeof (mp_limb)); + { + mp_size_t i; + for (i = 0; i < s1_size - 1; i++) + res_ptr[i] = s1_ptr[i]; + } return 0; } @@ -482,10 +378,10 @@ static __gmp_inline mp_limb #if __STDC__ __mpn_add (register mp_ptr res_ptr, - register mp_srcptr s1_ptr, - register mp_size_t s1_size, - register mp_srcptr s2_ptr, - register mp_size_t s2_size) + register mp_srcptr s1_ptr, + register mp_size_t s1_size, + register mp_srcptr s2_ptr, + register mp_size_t s2_size) #else __mpn_add (res_ptr, s1_ptr, s1_size, s2_ptr, s2_size) register mp_ptr res_ptr; @@ -498,16 +394,13 @@ mp_limb cy_limb = 0; if (s2_size != 0) - cy_limb = __mpn_add_n (res_ptr, - s1_ptr, - s2_ptr, - s2_size); + cy_limb = __mpn_add_n (res_ptr, s1_ptr, s2_ptr, s2_size); if (s1_size - s2_size != 0) cy_limb = __mpn_add_1 (res_ptr + s2_size, - s1_ptr + s2_size, - s1_size - s2_size, - cy_limb); + s1_ptr + s2_size, + s1_size - s2_size, + cy_limb); return cy_limb; } @@ -514,9 +407,9 @@ static __gmp_inline mp_limb #if __STDC__ __mpn_sub_1 (register mp_ptr res_ptr, - register mp_srcptr s1_ptr, - register mp_size_t s1_size, - register mp_limb s2_limb) + register mp_srcptr s1_ptr, + register mp_size_t s1_size, + register mp_limb s2_limb) #else __mpn_sub_1 (res_ptr, s1_ptr, s1_size, s2_limb) register mp_ptr res_ptr; @@ -545,7 +438,11 @@ fin: if (res_ptr != s1_ptr) - memcpy (res_ptr, s1_ptr, (size_t) (s1_size - 1) * sizeof (mp_limb)); + { + mp_size_t i; + for (i = 0; i < s1_size - 1; i++) + res_ptr[i] = s1_ptr[i]; + } return 0; } @@ -552,10 +449,10 @@ static __gmp_inline mp_limb #if __STDC__ __mpn_sub (register mp_ptr res_ptr, - register mp_srcptr s1_ptr, - register mp_size_t s1_size, - register mp_srcptr s2_ptr, - register mp_size_t s2_size) + register mp_srcptr s1_ptr, + register mp_size_t s1_size, + register mp_srcptr s2_ptr, + register mp_size_t s2_size) #else __mpn_sub (res_ptr, s1_ptr, s1_size, s2_ptr, s2_size) register mp_ptr res_ptr; @@ -568,16 +465,13 @@ mp_limb cy_limb = 0; if (s2_size != 0) - cy_limb = __mpn_sub_n (res_ptr, - s1_ptr, - s2_ptr, - s2_size); + cy_limb = __mpn_sub_n (res_ptr, s1_ptr, s2_ptr, s2_size); if (s1_size - s2_size != 0) cy_limb = __mpn_sub_1 (res_ptr + s2_size, - s1_ptr + s2_size, - s1_size - s2_size, - cy_limb); + s1_ptr + s2_size, + s1_size - s2_size, + cy_limb); return cy_limb; } @@ -599,6 +493,8 @@ return 0; } -#define __GNU_MP__ +#define __GNU_MP__ 2 +#define __GNU_MP_VERSION 2 +#define __GNU_MP_VERSION_MINOR -100 #define __GMP_H__ #endif /* __GMP_H__ */ diff -ruN glibc-1.07/stdio/longlong.h glibc-1.08.1/stdio/longlong.h --- glibc-1.07/stdio/longlong.h Sun Jan 16 00:17:16 1994 +++ glibc-1.08.1/stdio/longlong.h Tue Apr 26 22:01:54 1994 @@ -1,77 +1,80 @@ /* longlong.h -- definitions for mixed size 32/64 bit arithmetic. - Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. -! This file is part of the GNU C Library. Its master source is NOT part of -! the C library, however. This file is in fact copied from the GNU MP -! Library and its source lives there. - -! 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 LONG_TYPE_SIZE -#ifdef BITS_PER_LONGINT -#define LONG_TYPE_SIZE BITS_PER_LONGINT -#else -#define LONG_TYPE_SIZE 32 -#endif -#endif +Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc. -#define __BITS4 (LONG_TYPE_SIZE / 4) -#define __ll_B (1L << (LONG_TYPE_SIZE / 2)) -#define __ll_lowpart(t) ((unsigned long int) (t) % __ll_B) -#define __ll_highpart(t) ((unsigned long int) (t) / __ll_B) +This file 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. + +This file 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 this file; see the file COPYING.LIB. If not, write to +the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +/* You have to define the following before including this file: + + UWtype -- An unsigned type, default type for operations (typically a "word") + UHWtype -- An unsigned type, at least half the size of UWtype. + UDWtype -- An unsigned type, at least twice as large a UWtype + W_TYPE_SIZE -- size in bits of UWtype + + SItype, USItype -- Signed and unsigned 32 bit types. + DItype, UDItype -- Signed and unsigned 64 bit types. + + On a 32 bit machine UWtype should typically be USItype; + on a 64 bit machine, UWtype should typically be UDItype. +*/ + +#define __BITS4 (W_TYPE_SIZE / 4) +#define __ll_B ((UWtype) 1 << (W_TYPE_SIZE / 2)) +#define __ll_lowpart(t) ((UWtype) (t) & (__ll_B - 1)) +#define __ll_highpart(t) ((UWtype) (t) >> (W_TYPE_SIZE / 2)) /* Define auxiliary asm macros. - 1) umul_ppmm(high_prod, low_prod, multipler, multiplicand) - multiplies two unsigned long integers MULTIPLER and MULTIPLICAND, - and generates a two unsigned word product in HIGH_PROD and - LOW_PROD. + 1) umul_ppmm(high_prod, low_prod, multipler, multiplicand) multiplies two + UWtype integers MULTIPLER and MULTIPLICAND, and generates a two UWtype + word product in HIGH_PROD and LOW_PROD. - 2) __umulsidi3(a,b) multiplies two unsigned long integers A and B, - and returns a long long product. This is just a variant of umul_ppmm. + 2) __umulsidi3(a,b) multiplies two UWtype integers A and B, and returns a + UDWtype product. This is just a variant of umul_ppmm. 3) udiv_qrnnd(quotient, remainder, high_numerator, low_numerator, - denominator) divides a two-word unsigned integer, composed by the - integers HIGH_NUMERATOR and LOW_NUMERATOR, by DENOMINATOR and - places the quotient in QUOTIENT and the remainder in REMAINDER. - HIGH_NUMERATOR must be less than DENOMINATOR for correct operation. - If, in addition, the most significant bit of DENOMINATOR must be 1, - then the pre-processor symbol UDIV_NEEDS_NORMALIZATION is defined to 1. + denominator) divides a UDWtype, composed by the UWtype integers + HIGH_NUMERATOR and LOW_NUMERATOR, by DENOMINATOR and places the quotient + in QUOTIENT and the remainder in REMAINDER. HIGH_NUMERATOR must be less + than DENOMINATOR for correct operation. If, in addition, the most + significant bit of DENOMINATOR must be 1, then the pre-processor symbol + UDIV_NEEDS_NORMALIZATION is defined to 1. 4) sdiv_qrnnd(quotient, remainder, high_numerator, low_numerator, - denominator). Like udiv_qrnnd but the numbers are signed. The - quotient is rounded towards 0. + denominator). Like udiv_qrnnd but the numbers are signed. The quotient + is rounded towards 0. - 5) count_leading_zeros(count, x) counts the number of zero-bits from - the msb to the first non-zero bit. This is the number of steps X - needs to be shifted left to set the msb. Undefined for X == 0. - - 6) add_ssaaaa(high_sum, low_sum, high_addend_1, low_addend_1, - high_addend_2, low_addend_2) adds two two-word unsigned integers, - composed by HIGH_ADDEND_1 and LOW_ADDEND_1, and HIGH_ADDEND_2 and - LOW_ADDEND_2 respectively. The result is placed in HIGH_SUM and - LOW_SUM. Overflow (i.e. carry out) is not stored anywhere, and is - lost. - - 7) sub_ddmmss(high_difference, low_difference, high_minuend, - low_minuend, high_subtrahend, low_subtrahend) subtracts two - two-word unsigned integers, composed by HIGH_MINUEND_1 and - LOW_MINUEND_1, and HIGH_SUBTRAHEND_2 and LOW_SUBTRAHEND_2 - respectively. The result is placed in HIGH_DIFFERENCE and - LOW_DIFFERENCE. Overflow (i.e. carry out) is not stored anywhere, + 5) count_leading_zeros(count, x) counts the number of zero-bits from the + msb to the first non-zero bit in the UWtype X. This is the number of + steps X needs to be shifted left to set the msb. Undefined for X == 0, + unless the symbol COUNT_LEADING_ZEROS_0 is defined to some value. + + 6) count_trailing_zeros(count, x) like count_leading_zeros, but counts + from the least significant end. + + 7) add_ssaaaa(high_sum, low_sum, high_addend_1, low_addend_1, + high_addend_2, low_addend_2) adds two UWtype integers, composed by + HIGH_ADDEND_1 and LOW_ADDEND_1, and HIGH_ADDEND_2 and LOW_ADDEND_2 + respectively. The result is placed in HIGH_SUM and LOW_SUM. Overflow + (i.e. carry out) is not stored anywhere, and is lost. + + 8) sub_ddmmss(high_difference, low_difference, high_minuend, low_minuend, + high_subtrahend, low_subtrahend) subtracts two two-word UWtype integers, + composed by HIGH_MINUEND_1 and LOW_MINUEND_1, and HIGH_SUBTRAHEND_2 and + LOW_SUBTRAHEND_2 respectively. The result is placed in HIGH_DIFFERENCE + and LOW_DIFFERENCE. Overflow (i.e. carry out) is not stored anywhere, and is lost. If any of these macros are left undefined for a particular CPU, @@ -94,89 +97,89 @@ #define __AND_CLOBBER_CC , "cc" #endif /* __GNUC__ < 2 */ -#if defined (__a29k__) || defined (___AM29K__) +#if (defined (__a29k__) || defined (___AM29K__)) && W_TYPE_SIZE == 32 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("add %1,%4,%5 addc %0,%2,%3" \ - : "=r" ((unsigned long int)(sh)), \ - "=&r" ((unsigned long int)(sl)) \ - : "%r" ((unsigned long int)(ah)), \ - "rI" ((unsigned long int)(bh)), \ - "%r" ((unsigned long int)(al)), \ - "rI" ((unsigned long int)(bl))) + : "=r" ((USItype)(sh)), \ + "=&r" ((USItype)(sl)) \ + : "%r" ((USItype)(ah)), \ + "rI" ((USItype)(bh)), \ + "%r" ((USItype)(al)), \ + "rI" ((USItype)(bl))) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("sub %1,%4,%5 subc %0,%2,%3" \ - : "=r" ((unsigned long int)(sh)), \ - "=&r" ((unsigned long int)(sl)) \ - : "r" ((unsigned long int)(ah)), \ - "rI" ((unsigned long int)(bh)), \ - "r" ((unsigned long int)(al)), \ - "rI" ((unsigned long int)(bl))) + : "=r" ((USItype)(sh)), \ + "=&r" ((USItype)(sl)) \ + : "r" ((USItype)(ah)), \ + "rI" ((USItype)(bh)), \ + "r" ((USItype)(al)), \ + "rI" ((USItype)(bl))) #define umul_ppmm(xh, xl, m0, m1) \ do { \ - unsigned long int __m0 = (m0), __m1 = (m1); \ + USItype __m0 = (m0), __m1 = (m1); \ __asm__ ("multiplu %0,%1,%2" \ - : "=r" ((unsigned long int)(xl)) \ + : "=r" ((USItype)(xl)) \ : "r" (__m0), \ "r" (__m1)); \ __asm__ ("multmu %0,%1,%2" \ - : "=r" ((unsigned long int)(xh)) \ + : "=r" ((USItype)(xh)) \ : "r" (__m0), \ "r" (__m1)); \ } while (0) #define udiv_qrnnd(q, r, n1, n0, d) \ __asm__ ("dividu %0,%3,%4" \ - : "=r" ((unsigned long int)(q)), \ - "=q" ((unsigned long int)(r)) \ - : "1" ((unsigned long int)(n1)), \ - "r" ((unsigned long int)(n0)), \ - "r" ((unsigned long int)(d))) + : "=r" ((USItype)(q)), \ + "=q" ((USItype)(r)) \ + : "1" ((USItype)(n1)), \ + "r" ((USItype)(n0)), \ + "r" ((USItype)(d))) #define count_leading_zeros(count, x) \ __asm__ ("clz %0,%1" \ - : "=r" ((unsigned long int)(count)) \ - : "r" ((unsigned long int)(x))) + : "=r" ((USItype)(count)) \ + : "r" ((USItype)(x))) #endif /* __a29k__ */ -#if defined (__alpha__) +#if defined (__alpha__) && W_TYPE_SIZE == 64 #define umul_ppmm(ph, pl, m0, m1) \ do { \ - unsigned long int __m0 = (m0), __m1 = (m1); \ + UDItype __m0 = (m0), __m1 = (m1); \ __asm__ ("umulh %r1,%2,%0" \ - : "=r" ((unsigned long int) ph) \ + : "=r" ((UDItype) ph) \ : "%rJ" (__m0), \ "rI" (__m1)); \ - (pl) = (unsigned long int) (__m0) * (unsigned long int) (__m1); \ + (pl) = __m0 * __m1; \ } while (0) #define UMUL_TIME 46 #define udiv_qrnnd(q, r, n1, n0, d) \ - do { unsigned long int __r; \ - (q) = __udiv_qrnnd(&__r, (n1), (n0), (d)); \ + do { UDItype __r; \ + (q) = __udiv_qrnnd (&__r, (n1), (n0), (d)); \ (r) = __r; \ } while (0) -extern unsigned long __udiv_qrnnd (); +extern UDItype __udiv_qrnnd (); #define UDIV_TIME 220 #endif -#if defined (__arm__) +#if defined (__arm__) && W_TYPE_SIZE == 32 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("adds %1,%4,%5 adc %0,%2,%3" \ - : "=r" ((unsigned long int)(sh)), \ - "=&r" ((unsigned long int)(sl)) \ - : "%r" ((unsigned long int)(ah)), \ - "rI" ((unsigned long int)(bh)), \ - "%r" ((unsigned long int)(al)), \ - "rI" ((unsigned long int)(bl))) + : "=r" ((USItype)(sh)), \ + "=&r" ((USItype)(sl)) \ + : "%r" ((USItype)(ah)), \ + "rI" ((USItype)(bh)), \ + "%r" ((USItype)(al)), \ + "rI" ((USItype)(bl))) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("subs %1,%4,%5 sbc %0,%2,%3" \ - : "=r" ((unsigned long int)(sh)), \ - "=&r" ((unsigned long int)(sl)) \ - : "r" ((unsigned long int)(ah)), \ - "rI" ((unsigned long int)(bh)), \ - "r" ((unsigned long int)(al)), \ - "rI" ((unsigned long int)(bl))) + : "=r" ((USItype)(sh)), \ + "=&r" ((USItype)(sl)) \ + : "r" ((USItype)(ah)), \ + "rI" ((USItype)(bh)), \ + "r" ((USItype)(al)), \ + "rI" ((USItype)(bl))) #define umul_ppmm(xh, xl, a, b) \ __asm__ ("; Inlined umul_ppmm mov r0,%2 lsr 16 @@ -191,111 +194,111 @@ addcs %0,%0,0x10000 adds %1,%1,r1 lsl 16 adc %0,%0,r1 lsr 16" \ - : "=&r" ((unsigned long int)(xh)), \ - "=r" ((unsigned long int)(xl)) \ - : "r" ((unsigned long int)(a)), \ - "r" ((unsigned long int)(b)) \ + : "=&r" ((USItype)(xh)), \ + "=r" ((USItype)(xl)) \ + : "r" ((USItype)(a)), \ + "r" ((USItype)(b)) \ : "r0", "r1", "r2") #define UMUL_TIME 20 #define UDIV_TIME 100 #endif /* __arm__ */ -#if defined (__clipper__) +#if defined (__clipper__) && W_TYPE_SIZE == 32 #define umul_ppmm(w1, w0, u, v) \ - ({union {long long int __ll; \ - struct {unsigned long int __l, __h;} __i; \ + ({union {UDItype __ll; \ + struct {USItype __l, __h;} __i; \ } __xx; \ __asm__ ("mulwux %2,%0" \ : "=r" (__xx.__ll) \ - : "%0" ((unsigned long int)(u)), \ - "r" ((unsigned long int)(v))); \ + : "%0" ((USItype)(u)), \ + "r" ((USItype)(v))); \ (w1) = __xx.__i.__h; (w0) = __xx.__i.__l;}) #define smul_ppmm(w1, w0, u, v) \ - ({union {long long int __ll; \ - struct {unsigned long int __l, __h;} __i; \ + ({union {DItype __ll; \ + struct {SItype __l, __h;} __i; \ } __xx; \ __asm__ ("mulwx %2,%0" \ : "=r" (__xx.__ll) \ - : "%0" ((unsigned long int)(u)), \ - "r" ((unsigned long int)(v))); \ + : "%0" ((SItype)(u)), \ + "r" ((SItype)(v))); \ (w1) = __xx.__i.__h; (w0) = __xx.__i.__l;}) #define __umulsidi3(u, v) \ - ({long long int __w; \ + ({UDItype __w; \ __asm__ ("mulwux %2,%0" \ : "=r" (__w) \ - : "%0" ((unsigned long int)(u)), \ - "r" ((unsigned long int)(v))); \ + : "%0" ((USItype)(u)), \ + "r" ((USItype)(v))); \ __w; }) #endif /* __clipper__ */ -#if defined (__gmicro__) +#if defined (__gmicro__) && W_TYPE_SIZE == 32 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("add.w %5,%1 addx %3,%0" \ - : "=g" ((unsigned long int)(sh)), \ - "=&g" ((unsigned long int)(sl)) \ - : "%0" ((unsigned long int)(ah)), \ - "g" ((unsigned long int)(bh)), \ - "%1" ((unsigned long int)(al)), \ - "g" ((unsigned long int)(bl))) + : "=g" ((USItype)(sh)), \ + "=&g" ((USItype)(sl)) \ + : "%0" ((USItype)(ah)), \ + "g" ((USItype)(bh)), \ + "%1" ((USItype)(al)), \ + "g" ((USItype)(bl))) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("sub.w %5,%1 subx %3,%0" \ - : "=g" ((unsigned long int)(sh)), \ - "=&g" ((unsigned long int)(sl)) \ - : "0" ((unsigned long int)(ah)), \ - "g" ((unsigned long int)(bh)), \ - "1" ((unsigned long int)(al)), \ - "g" ((unsigned long int)(bl))) + : "=g" ((USItype)(sh)), \ + "=&g" ((USItype)(sl)) \ + : "0" ((USItype)(ah)), \ + "g" ((USItype)(bh)), \ + "1" ((USItype)(al)), \ + "g" ((USItype)(bl))) #define umul_ppmm(ph, pl, m0, m1) \ __asm__ ("mulx %3,%0,%1" \ - : "=g" ((unsigned long int)(ph)), \ - "=r" ((unsigned long int)(pl)) \ - : "%0" ((unsigned long int)(m0)), \ - "g" ((unsigned long int)(m1))) + : "=g" ((USItype)(ph)), \ + "=r" ((USItype)(pl)) \ + : "%0" ((USItype)(m0)), \ + "g" ((USItype)(m1))) #define udiv_qrnnd(q, r, nh, nl, d) \ __asm__ ("divx %4,%0,%1" \ - : "=g" ((unsigned long int)(q)), \ - "=r" ((unsigned long int)(r)) \ - : "1" ((unsigned long int)(nh)), \ - "0" ((unsigned long int)(nl)), \ - "g" ((unsigned long int)(d))) + : "=g" ((USItype)(q)), \ + "=r" ((USItype)(r)) \ + : "1" ((USItype)(nh)), \ + "0" ((USItype)(nl)), \ + "g" ((USItype)(d))) #define count_leading_zeros(count, x) \ __asm__ ("bsch/1 %1,%0" \ : "=g" (count) \ - : "g" ((unsigned long int)(x)), \ - "0" (0UL)) + : "g" ((USItype)(x)), \ + "0" ((USItype)0)) #endif -#if defined (__hppa) +#if defined (__hppa) && W_TYPE_SIZE == 32 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("add %4,%5,%1 addc %2,%3,%0" \ - : "=r" ((unsigned long int)(sh)), \ - "=&r" ((unsigned long int)(sl)) \ - : "%rM" ((unsigned long int)(ah)), \ - "rM" ((unsigned long int)(bh)), \ - "%rM" ((unsigned long int)(al)), \ - "rM" ((unsigned long int)(bl))) + : "=r" ((USItype)(sh)), \ + "=&r" ((USItype)(sl)) \ + : "%rM" ((USItype)(ah)), \ + "rM" ((USItype)(bh)), \ + "%rM" ((USItype)(al)), \ + "rM" ((USItype)(bl))) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("sub %4,%5,%1 subb %2,%3,%0" \ - : "=r" ((unsigned long int)(sh)), \ - "=&r" ((unsigned long int)(sl)) \ - : "rM" ((unsigned long int)(ah)), \ - "rM" ((unsigned long int)(bh)), \ - "rM" ((unsigned long int)(al)), \ - "rM" ((unsigned long int)(bl))) + : "=r" ((USItype)(sh)), \ + "=&r" ((USItype)(sl)) \ + : "rM" ((USItype)(ah)), \ + "rM" ((USItype)(bh)), \ + "rM" ((USItype)(al)), \ + "rM" ((USItype)(bl))) #if defined (_PA_RISC1_1) #define umul_ppmm(wh, wl, u, v) \ do { \ - union {long long int __ll; \ - struct {unsigned long int __h, __l;} __i; \ + union {UDItype __ll; \ + struct {USItype __h, __l;} __i; \ } __xx; \ __asm__ ("xmpyu %1,%2,%0" \ : "=x" (__xx.__ll) \ - : "x" ((unsigned long int)(u)), \ - "x" ((unsigned long int)(v))); \ + : "x" ((USItype)(u)), \ + "x" ((USItype)(v))); \ (wh) = __xx.__i.__h; \ (wl) = __xx.__i.__l; \ } while (0) @@ -306,14 +309,14 @@ #define UDIV_TIME 80 #endif #define udiv_qrnnd(q, r, n1, n0, d) \ - do { unsigned long int __r; \ - (q) = __udiv_qrnnd(&__r, (n1), (n0), (d)); \ + do { USItype __r; \ + (q) = __udiv_qrnnd (&__r, (n1), (n0), (d)); \ (r) = __r; \ } while (0) -extern unsigned long __udiv_qrnnd (); +extern USItype __udiv_qrnnd (); #define count_leading_zeros(count, x) \ do { \ - unsigned long int __tmp; \ + USItype __tmp; \ __asm__ ( \ "ldi 1,%0 extru,= %1,15,16,%%r0 ; Bits 31..16 zero? @@ -334,13 +337,13 @@ } while (0) #endif -#if defined (__i370__) || defined (__mvs__) +#if (defined (__i370__) || defined (__mvs__)) && W_TYPE_SIZE == 32 #define umul_ppmm(xh, xl, m0, m1) \ do { \ - union {long long int __ll; \ - struct {unsigned long int __h, __l;} __i; \ + union {UDItype __ll; \ + struct {USItype __h, __l;} __i; \ } __xx; \ - unsigned long int __m0 = (m0), __m1 = (m1); \ + USItype __m0 = (m0), __m1 = (m1); \ __asm__ ("mr %0,%3" \ : "=r" (__xx.__i.__h), \ "=r" (__xx.__i.__l) \ @@ -347,13 +350,13 @@ : "%1" (__m0), \ "r" (__m1)); \ (xh) = __xx.__i.__h; (xl) = __xx.__i.__l; \ - (xh) += ((((signed int) __m0 >> 31) & __m1) \ - + (((signed int) __m1 >> 31) & __m0)); \ + (xh) += ((((SItype) __m0 >> 31) & __m1) \ + + (((SItype) __m1 >> 31) & __m0)); \ } while (0) #define smul_ppmm(xh, xl, m0, m1) \ do { \ - union {long long int __ll; \ - struct {unsigned long int __h, __l;} __i; \ + union {DItype __ll; \ + struct {USItype __h, __l;} __i; \ } __xx; \ __asm__ ("mr %0,%3" \ : "=r" (__xx.__i.__h), \ @@ -364,8 +367,8 @@ } while (0) #define sdiv_qrnnd(q, r, n1, n0, d) \ do { \ - union {long long int __ll; \ - struct {unsigned long int __h, __l;} __i; \ + union {DItype __ll; \ + struct {USItype __h, __l;} __i; \ } __xx; \ __xx.__i.__h = n1; __xx.__i.__l = n0; \ __asm__ ("dr %0,%2" \ @@ -375,185 +378,148 @@ } while (0) #endif -#if defined (__i386__) || defined (__i486__) +#if (defined (__i386__) || defined (__i486__)) && W_TYPE_SIZE == 32 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("addl %5,%1 adcl %3,%0" \ - : "=r" ((unsigned long int)(sh)), \ - "=&r" ((unsigned long int)(sl)) \ - : "%0" ((unsigned long int)(ah)), \ - "g" ((unsigned long int)(bh)), \ - "%1" ((unsigned long int)(al)), \ - "g" ((unsigned long int)(bl))) + : "=r" ((USItype)(sh)), \ + "=&r" ((USItype)(sl)) \ + : "%0" ((USItype)(ah)), \ + "g" ((USItype)(bh)), \ + "%1" ((USItype)(al)), \ + "g" ((USItype)(bl))) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("subl %5,%1 sbbl %3,%0" \ - : "=r" ((unsigned long int)(sh)), \ - "=&r" ((unsigned long int)(sl)) \ - : "0" ((unsigned long int)(ah)), \ - "g" ((unsigned long int)(bh)), \ - "1" ((unsigned long int)(al)), \ - "g" ((unsigned long int)(bl))) + : "=r" ((USItype)(sh)), \ + "=&r" ((USItype)(sl)) \ + : "0" ((USItype)(ah)), \ + "g" ((USItype)(bh)), \ + "1" ((USItype)(al)), \ + "g" ((USItype)(bl))) #define umul_ppmm(w1, w0, u, v) \ __asm__ ("mull %3" \ - : "=a" ((unsigned long int)(w0)), \ - "=d" ((unsigned long int)(w1)) \ - : "%0" ((unsigned long int)(u)), \ - "rm" ((unsigned long int)(v))) + : "=a" ((USItype)(w0)), \ + "=d" ((USItype)(w1)) \ + : "%0" ((USItype)(u)), \ + "rm" ((USItype)(v))) #define udiv_qrnnd(q, r, n1, n0, d) \ __asm__ ("divl %4" \ - : "=a" ((unsigned long int)(q)), \ - "=d" ((unsigned long int)(r)) \ - : "0" ((unsigned long int)(n0)), \ - "1" ((unsigned long int)(n1)), \ - "rm" ((unsigned long int)(d))) + : "=a" ((USItype)(q)), \ + "=d" ((USItype)(r)) \ + : "0" ((USItype)(n0)), \ + "1" ((USItype)(n1)), \ + "rm" ((USItype)(d))) #define count_leading_zeros(count, x) \ do { \ - unsigned long int __cbtmp; \ + USItype __cbtmp; \ __asm__ ("bsrl %1,%0" \ - : "=r" (__cbtmp) : "rm" ((unsigned long int)(x))); \ + : "=r" (__cbtmp) : "rm" ((USItype)(x))); \ (count) = __cbtmp ^ 31; \ } while (0) #define count_trailing_zeros(count, x) \ - __asm__ ("bsfl %1,%0" : "=r" (count) : "rm" ((unsigned long int)(x))) + __asm__ ("bsfl %1,%0" : "=r" (count) : "rm" ((USItype)(x))) #define UMUL_TIME 40 #define UDIV_TIME 40 #endif /* 80x86 */ -#if defined (__i860__) -#if 0 -/* Make sure these patterns really improve the code before - switching them on. */ -#define add_ssaaaa(sh, sl, ah, al, bh, bl) \ - do { \ - union \ - { \ - long long int ll; \ - struct {unsigned long int l, h;} i; \ - } __a, __b, __s; \ - __a.i.l = (al); __a.i.h = (ah); \ - __b.i.l = (bl); __b.i.h = (bh); \ - __asm__ ("fiadd.dd %1,%2,%0" \ - : "=f" (__s.ll) \ - : "%f" (__a.ll), "f" (__b.ll)); \ - (sh) = __s.i.h; (sl) = __s.i.l; \ - } while (0) -#define sub_ddmmss(sh, sl, ah, al, bh, bl) \ - do { \ - union \ - { \ - long long int ll; \ - struct {unsigned long int l, h;} i; \ - } __a, __b, __s; \ - __a.i.l = (al); __a.i.h = (ah); \ - __b.i.l = (bl); __b.i.h = (bh); \ - __asm__ ("fisub.dd %1,%2,%0" \ - : "=f" (__s.ll) \ - : "%f" (__a.ll), "f" (__b.ll)); \ - (sh) = __s.i.h; (sl) = __s.i.l; \ - } while (0) -#endif -#endif /* __i860__ */ - -#if defined (__i960__) +#if defined (__i960__) && W_TYPE_SIZE == 32 #define umul_ppmm(w1, w0, u, v) \ - ({union {long long int __ll; \ - struct {unsigned long int __l, __h;} __i; \ + ({union {UDItype __ll; \ + struct {USItype __l, __h;} __i; \ } __xx; \ __asm__ ("emul %2,%1,%0" \ : "=d" (__xx.__ll) \ - : "%dI" ((unsigned long int)(u)), \ - "dI" ((unsigned long int)(v))); \ + : "%dI" ((USItype)(u)), \ + "dI" ((USItype)(v))); \ (w1) = __xx.__i.__h; (w0) = __xx.__i.__l;}) #define __umulsidi3(u, v) \ - ({long long int __w; \ + ({UDItype __w; \ __asm__ ("emul %2,%1,%0" \ : "=d" (__w) \ - : "%dI" ((unsigned long int)(u)), \ - "dI" ((unsigned long int)(v))); \ + : "%dI" ((USItype)(u)), \ + "dI" ((USItype)(v))); \ __w; }) #endif /* __i960__ */ -#if defined (__mc68000__) +#if defined (__mc68000__) && W_TYPE_SIZE == 32 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("add%.l %5,%1 addx%.l %3,%0" \ - : "=d" ((unsigned long int)(sh)), \ - "=&d" ((unsigned long int)(sl)) \ - : "%0" ((unsigned long int)(ah)), \ - "d" ((unsigned long int)(bh)), \ - "%1" ((unsigned long int)(al)), \ - "g" ((unsigned long int)(bl))) + : "=d" ((USItype)(sh)), \ + "=&d" ((USItype)(sl)) \ + : "%0" ((USItype)(ah)), \ + "d" ((USItype)(bh)), \ + "%1" ((USItype)(al)), \ + "g" ((USItype)(bl))) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("sub%.l %5,%1 subx%.l %3,%0" \ - : "=d" ((unsigned long int)(sh)), \ - "=&d" ((unsigned long int)(sl)) \ - : "0" ((unsigned long int)(ah)), \ - "d" ((unsigned long int)(bh)), \ - "1" ((unsigned long int)(al)), \ - "g" ((unsigned long int)(bl))) -#if defined (__mc68020__) || defined (__NeXT__) || defined(mc68020) + : "=d" ((USItype)(sh)), \ + "=&d" ((USItype)(sl)) \ + : "0" ((USItype)(ah)), \ + "d" ((USItype)(bh)), \ + "1" ((USItype)(al)), \ + "g" ((USItype)(bl))) +#if (defined (__mc68020__) || defined (__NeXT__) || defined(mc68020)) && W_TYPE_SIZE == 32 #define umul_ppmm(w1, w0, u, v) \ __asm__ ("mulu%.l %3,%1:%0" \ - : "=d" ((unsigned long int)(w0)), \ - "=d" ((unsigned long int)(w1)) \ - : "%0" ((unsigned long int)(u)), \ - "dmi" ((unsigned long int)(v))) + : "=d" ((USItype)(w0)), \ + "=d" ((USItype)(w1)) \ + : "%0" ((USItype)(u)), \ + "dmi" ((USItype)(v))) #define UMUL_TIME 45 #define udiv_qrnnd(q, r, n1, n0, d) \ __asm__ ("divu%.l %4,%1:%0" \ - : "=d" ((unsigned long int)(q)), \ - "=d" ((unsigned long int)(r)) \ - : "0" ((unsigned long int)(n0)), \ - "1" ((unsigned long int)(n1)), \ - "dmi" ((unsigned long int)(d))) + : "=d" ((USItype)(q)), \ + "=d" ((USItype)(r)) \ + : "0" ((USItype)(n0)), \ + "1" ((USItype)(n1)), \ + "dmi" ((USItype)(d))) #define UDIV_TIME 90 #define sdiv_qrnnd(q, r, n1, n0, d) \ __asm__ ("divs%.l %4,%1:%0" \ - : "=d" ((unsigned long int)(q)), \ - "=d" ((unsigned long int)(r)) \ - : "0" ((unsigned long int)(n0)), \ - "1" ((unsigned long int)(n1)), \ - "dmi" ((unsigned long int)(d))) + : "=d" ((USItype)(q)), \ + "=d" ((USItype)(r)) \ + : "0" ((USItype)(n0)), \ + "1" ((USItype)(n1)), \ + "dmi" ((USItype)(d))) #define count_leading_zeros(count, x) \ __asm__ ("bfffo %1{%b2:%b2},%0" \ - : "=d" ((unsigned long int)(count)) \ - : "od" ((unsigned long int)(x)), "n" (0)) + : "=d" ((USItype)(count)) \ + : "od" ((USItype)(x)), "n" (0)) #else /* not mc68020 */ -/* This ought to be improved by relying on reload to move inputs and - outputs to their positions. */ #define umul_ppmm(xh, xl, a, b) \ __asm__ ("| Inlined umul_ppmm - movel %2,d0 - movel %3,d1 - movel d0,d2 - swap d0 - movel d1,d3 - swap d1 - movew d2,d4 - mulu d3,d4 - mulu d1,d2 - mulu d0,d3 - mulu d0,d1 - movel d4,d0 - eorw d0,d0 - swap d0 - addl d0,d2 - addl d3,d2 + move%.l %2,%/d0 + move%.l %3,%/d1 + move%.l %/d0,%/d2 + swap %/d0 + move%.l %/d1,%/d3 + swap %/d1 + move%.w %/d2,%/d4 + mulu %/d3,%/d4 + mulu %/d1,%/d2 + mulu %/d0,%/d3 + mulu %/d0,%/d1 + move%.l %/d4,%/d0 + eor%.w %/d0,%/d0 + swap %/d0 + add%.l %/d0,%/d2 + add%.l %/d3,%/d2 jcc 1f - addl #65536,d1 -1: swap d2 - moveq #0,d0 - movew d2,d0 - movew d4,d2 - movel d2,%1 - addl d1,d0 - movel d0,%0" \ - : "=g" ((unsigned long int)(xh)), \ - "=g" ((unsigned long int)(xl)) \ - : "g" ((unsigned long int)(a)), \ - "g" ((unsigned long int)(b)) \ + add%.l #65536,%/d1 +1: swap %/d2 + moveq #0,%/d0 + move%.w %/d2,%/d0 + move%.w %/d4,%/d2 + move%.l %/d2,%1 + add%.l %/d1,%/d0 + move%.l %/d0,%0" \ + : "=g" ((USItype)(xh)), \ + "=g" ((USItype)(xl)) \ + : "g" ((USItype)(a)), \ + "g" ((USItype)(b)) \ : "d0", "d1", "d2", "d3", "d4") #define UMUL_TIME 100 #define UDIV_TIME 400 @@ -560,56 +526,56 @@ #endif /* not mc68020 */ #endif /* mc68000 */ -#if defined (__m88000__) +#if defined (__m88000__) && W_TYPE_SIZE == 32 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("addu.co %1,%r4,%r5 addu.ci %0,%r2,%r3" \ - : "=r" ((unsigned long int)(sh)), \ - "=&r" ((unsigned long int)(sl)) \ - : "%rJ" ((unsigned long int)(ah)), \ - "rJ" ((unsigned long int)(bh)), \ - "%rJ" ((unsigned long int)(al)), \ - "rJ" ((unsigned long int)(bl))) + : "=r" ((USItype)(sh)), \ + "=&r" ((USItype)(sl)) \ + : "%rJ" ((USItype)(ah)), \ + "rJ" ((USItype)(bh)), \ + "%rJ" ((USItype)(al)), \ + "rJ" ((USItype)(bl))) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("subu.co %1,%r4,%r5 subu.ci %0,%r2,%r3" \ - : "=r" ((unsigned long int)(sh)), \ - "=&r" ((unsigned long int)(sl)) \ - : "rJ" ((unsigned long int)(ah)), \ - "rJ" ((unsigned long int)(bh)), \ - "rJ" ((unsigned long int)(al)), \ - "rJ" ((unsigned long int)(bl))) + : "=r" ((USItype)(sh)), \ + "=&r" ((USItype)(sl)) \ + : "rJ" ((USItype)(ah)), \ + "rJ" ((USItype)(bh)), \ + "rJ" ((USItype)(al)), \ + "rJ" ((USItype)(bl))) #define count_leading_zeros(count, x) \ do { \ - unsigned long int __cbtmp; \ + USItype __cbtmp; \ __asm__ ("ff1 %0,%1" \ : "=r" (__cbtmp) \ - : "r" ((unsigned long int)(x))); \ + : "r" ((USItype)(x))); \ (count) = __cbtmp ^ 31; \ } while (0) #if defined (__mc88110__) #define umul_ppmm(wh, wl, u, v) \ do { \ - union {long long int __ll; \ - struct {unsigned long int __h, __l;} __i; \ + union {UDItype __ll; \ + struct {USItype __h, __l;} __i; \ } __xx; \ __asm__ ("mulu.d %0,%1,%2" \ : "=r" (__xx.__ll) \ - : "r" ((unsigned long int)(u)), \ - "r" ((unsigned long int)(v))); \ + : "r" ((USItype)(u)), \ + "r" ((USItype)(v))); \ (wh) = __xx.__i.__h; \ (wl) = __xx.__i.__l; \ } while (0) #define udiv_qrnnd(q, r, n1, n0, d) \ - ({union {long long int __ll; \ - struct {unsigned long int __h, __l;} __i; \ + ({union {UDItype __ll; \ + struct {USItype __h, __l;} __i; \ } __xx; \ - unsigned long int __q; \ + USItype __q; \ __xx.__i.__h = (n1); __xx.__i.__l = (n0); \ __asm__ ("divu.d %0,%1,%2" \ : "=r" (__q) \ : "r" (__xx.__ll), \ - "r" ((unsigned long int)(d))); \ + "r" ((USItype)(d))); \ (r) = (n0) - __q * (d); (q) = __q; }) #define UMUL_TIME 5 #define UDIV_TIME 25 @@ -619,196 +585,210 @@ #endif /* __mc88110__ */ #endif /* __m88000__ */ -#if defined (__mips__) -/* The LO and HI registers are fixed in gcc/mips.h, for some reason. */ -#if 0 && __GNUC__ >= 2 -#define umul_ppmm(w1, w0, u, v) \ - __asm__ ("multu %2,%3" \ - : "=l" ((unsigned long int)(w0)), \ - "=h" ((unsigned long int)(w1)) \ - : "d" ((unsigned long int)(u)), \ - "d" ((unsigned long int)(v))) -#else +#if defined (__mips__) && W_TYPE_SIZE == 32 #define umul_ppmm(w1, w0, u, v) \ __asm__ ("multu %2,%3 mflo %0 mfhi %1" \ - : "=d" ((unsigned long int)(w0)), \ - "=d" ((unsigned long int)(w1)) \ - : "d" ((unsigned long int)(u)), \ - "d" ((unsigned long int)(v))) -#endif + : "=d" ((USItype)(w0)), \ + "=d" ((USItype)(w1)) \ + : "d" ((USItype)(u)), \ + "d" ((USItype)(v))) +#define UMUL_TIME 10 +#define UDIV_TIME 100 +#endif /* __mips__ */ + +#if (defined (__mips__) && defined (__r4000)) && W_TYPE_SIZE == 64 +#define umul_ppmm(w1, w0, u, v) \ + __asm__ ("dmultu %2,%3 + mflo %0 + mfhi %1" \ + : "=d" ((UDItype)(w0)), \ + "=d" ((UDItype)(w1)) \ + : "d" ((UDItype)(u)), \ + "d" ((UDItype)(v))) #define UMUL_TIME 10 #define UDIV_TIME 100 #endif /* __mips__ */ -#if defined (__ns32000__) +#if defined (__ns32000__) && W_TYPE_SIZE == 32 #define umul_ppmm(w1, w0, u, v) \ - ({union {long long int __ll; \ - struct {unsigned long int __l, __h;} __i; \ + ({union {UDItype __ll; \ + struct {USItype __l, __h;} __i; \ } __xx; \ __asm__ ("meid %2,%0" \ : "=g" (__xx.__ll) \ - : "%0" ((unsigned long int)(u)), \ - "g" ((unsigned long int)(v))); \ + : "%0" ((USItype)(u)), \ + "g" ((USItype)(v))); \ (w1) = __xx.__i.__h; (w0) = __xx.__i.__l;}) #define __umulsidi3(u, v) \ - ({long long int __w; \ + ({UDItype __w; \ __asm__ ("meid %2,%0" \ : "=g" (__w) \ - : "%0" ((unsigned long int)(u)), \ - "g" ((unsigned long int)(v))); \ + : "%0" ((USItype)(u)), \ + "g" ((USItype)(v))); \ __w; }) #define udiv_qrnnd(q, r, n1, n0, d) \ - ({union {long long int __ll; \ - struct {unsigned long int __l, __h;} __i; \ + ({union {UDItype __ll; \ + struct {USItype __l, __h;} __i; \ } __xx; \ __xx.__i.__h = (n1); __xx.__i.__l = (n0); \ __asm__ ("deid %2,%0" \ : "=g" (__xx.__ll) \ : "0" (__xx.__ll), \ - "g" ((unsigned long int)(d))); \ + "g" ((USItype)(d))); \ (r) = __xx.__i.__l; (q) = __xx.__i.__h; }) #define count_trailing_zeros(count,x) \ do { __asm__ ("ffsd %2,%0" \ - : "=r" ((unsigned long int) (count)) \ - : "0" ((unsigned long int) 0), \ - "r" ((unsigned long int) (x))); \ + : "=r" ((USItype) (count)) \ + : "0" ((USItype) 0), \ + "r" ((USItype) (x))); \ } while (0) #endif /* __ns32000__ */ -#if defined (__power__) || defined (___IBMR2__) /* IBM RS6000 */ +#if (defined (__powerpc__) || defined (___IBMR2__)) && W_TYPE_SIZE == 32 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ do { \ if (__builtin_constant_p (bh) && (bh) == 0) \ - __asm__ ("a%I4 %1,%3,%4\n\taze %0,%2" \ - : "=r" ((unsigned long int)(sh)), \ - "=&r" ((unsigned long int)(sl)) \ - : "%r" ((unsigned long int)(ah)), \ - "%r" ((unsigned long int)(al)), \ - "rI" ((unsigned long int)(bl))); \ - else if (__builtin_constant_p (bh) && (bh) ==~(unsigned long int) 0)\ - __asm__ ("a%I4 %1,%3,%4\n\tame %0,%2" \ - : "=r" ((unsigned long int)(sh)), \ - "=&r" ((unsigned long int)(sl)) \ - : "%r" ((unsigned long int)(ah)), \ - "%r" ((unsigned long int)(al)), \ - "rI" ((unsigned long int)(bl))); \ + __asm__ ("{a%I4|add%I4c} %1,%3,%4\n\t{aze|addze} %0,%2" \ + : "=r" ((USItype)(sh)), \ + "=&r" ((USItype)(sl)) \ + : "%r" ((USItype)(ah)), \ + "%r" ((USItype)(al)), \ + "rI" ((USItype)(bl))); \ + else if (__builtin_constant_p (bh) && (bh) ==~(USItype) 0) \ + __asm__ ("{a%I4|add%I4c} %1,%3,%4\n\t{ame|addme} %0,%2" \ + : "=r" ((USItype)(sh)), \ + "=&r" ((USItype)(sl)) \ + : "%r" ((USItype)(ah)), \ + "%r" ((USItype)(al)), \ + "rI" ((USItype)(bl))); \ else \ - __asm__ ("a%I5 %1,%4,%5\n\tae %0,%2,%3" \ - : "=r" ((unsigned long int)(sh)), \ - "=&r" ((unsigned long int)(sl)) \ - : "%r" ((unsigned long int)(ah)), \ - "r" ((unsigned long int)(bh)), \ - "%r" ((unsigned long int)(al)), \ - "rI" ((unsigned long int)(bl))); \ + __asm__ ("{a%I5|add%I5c} %1,%4,%5\n\t{ae|adde} %0,%2,%3" \ + : "=r" ((USItype)(sh)), \ + "=&r" ((USItype)(sl)) \ + : "%r" ((USItype)(ah)), \ + "r" ((USItype)(bh)), \ + "%r" ((USItype)(al)), \ + "rI" ((USItype)(bl))); \ } while (0) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ do { \ if (__builtin_constant_p (ah) && (ah) == 0) \ - __asm__ ("sf%I3 %1,%4,%3\n\tsfze %0,%2" \ - : "=r" ((unsigned long int)(sh)), \ - "=&r" ((unsigned long int)(sl)) \ - : "r" ((unsigned long int)(bh)), \ - "rI" ((unsigned long int)(al)), \ - "r" ((unsigned long int)(bl))); \ - else if (__builtin_constant_p (ah) && (ah) ==~(unsigned long int) 0)\ - __asm__ ("sf%I3 %1,%4,%3\n\tsfme %0,%2" \ - : "=r" ((unsigned long int)(sh)), \ - "=&r" ((unsigned long int)(sl)) \ - : "r" ((unsigned long int)(bh)), \ - "rI" ((unsigned long int)(al)), \ - "r" ((unsigned long int)(bl))); \ + __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{sfze|subfze} %0,%2" \ + : "=r" ((USItype)(sh)), \ + "=&r" ((USItype)(sl)) \ + : "r" ((USItype)(bh)), \ + "rI" ((USItype)(al)), \ + "r" ((USItype)(bl))); \ + else if (__builtin_constant_p (ah) && (ah) ==~(USItype) 0) \ + __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{sfme|subfme} %0,%2" \ + : "=r" ((USItype)(sh)), \ + "=&r" ((USItype)(sl)) \ + : "r" ((USItype)(bh)), \ + "rI" ((USItype)(al)), \ + "r" ((USItype)(bl))); \ + else if (__builtin_constant_p (bh) && (bh) == 0) \ + __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{ame|addme} %0,%2" \ + : "=r" ((USItype)(sh)), \ + "=&r" ((USItype)(sl)) \ + : "r" ((USItype)(ah)), \ + "rI" ((USItype)(al)), \ + "r" ((USItype)(bl))); \ + else if (__builtin_constant_p (bh) && (bh) ==~(USItype) 0) \ + __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{aze|addze} %0,%2" \ + : "=r" ((USItype)(sh)), \ + "=&r" ((USItype)(sl)) \ + : "r" ((USItype)(ah)), \ + "rI" ((USItype)(al)), \ + "r" ((USItype)(bl))); \ else \ - __asm__ ("sf%I4 %1,%5,%4\n\tsfe %0,%3,%2" \ - : "=r" ((unsigned long int)(sh)), \ - "=&r" ((unsigned long int)(sl)) \ - : "r" ((unsigned long int)(ah)), \ - "r" ((unsigned long int)(bh)), \ - "rI" ((unsigned long int)(al)), \ - "r" ((unsigned long int)(bl))); \ - } while (0) -#define umul_ppmm(xh, xl, m0, m1) \ - do { \ - unsigned long int __m0 = (m0), __m1 = (m1); \ - __asm__ ("mul %0,%2,%3" \ - : "=r" ((unsigned long int)(xh)), \ - "=q" ((unsigned long int)(xl)) \ - : "r" (__m0), \ - "r" (__m1)); \ - (xh) += ((((signed long int) __m0 >> 31) & __m1) \ - + (((signed long int) __m1 >> 31) & __m0)); \ + __asm__ ("{sf%I4|subf%I4c} %1,%5,%4\n\t{sfe|subfe} %0,%3,%2" \ + : "=r" ((USItype)(sh)), \ + "=&r" ((USItype)(sl)) \ + : "r" ((USItype)(ah)), \ + "r" ((USItype)(bh)), \ + "rI" ((USItype)(al)), \ + "r" ((USItype)(bl))); \ } while (0) -#define smul_ppmm(xh, xl, m0, m1) \ - __asm__ ("mul %0,%2,%3" \ - : "=r" ((unsigned long int)(xh)), \ - "=q" ((unsigned long int)(xl)) \ - : "r" (m0), \ - "r" (m1)) -#define UMUL_TIME 8 -#define sdiv_qrnnd(q, r, nh, nl, d) \ - __asm__ ("div %0,%2,%4" \ - : "=r" (q), "=q" (r) \ - : "r" (nh), "1" (nl), "r" (d)) -#define UDIV_TIME 100 #define count_leading_zeros(count, x) \ - __asm__ ("cntlz %0,%1" \ - : "=r" ((unsigned long int)(count)) \ - : "r" ((unsigned long int)(x))) -#endif /* ___IBMR2__ */ - -#if defined (__powerpc__) && !defined (__powerpc64__) + __asm__ ("{cntlz|cntlzw} %0,%1" \ + : "=r" ((USItype)(count)) \ + : "r" ((USItype)(x))) +#if defined (__powerpc__) #define umul_ppmm(ph, pl, m0, m1) \ do { \ - unsigned long int __m0 = (m0), __m1 = (m1); \ + USItype __m0 = (m0), __m1 = (m1); \ __asm__ ("mulhwu %0,%1,%2" \ - : "=r" ((unsigned long int) ph) \ + : "=r" ((USItype) ph) \ : "%r" (__m0), \ "r" (__m1)); \ - (pl) = (unsigned long int) (__m0) * (unsigned long int) (__m1); \ + (pl) = __m0 * __m1; \ } while (0) #define UMUL_TIME 15 #define smul_ppmm(ph, pl, m0, m1) \ do { \ - unsigned long int __m0 = (m0), __m1 = (m1); \ + SItype __m0 = (m0), __m1 = (m1); \ __asm__ ("mulhw %0,%1,%2" \ - : "=r" ((unsigned long int) ph) \ + : "=r" ((SItype) ph) \ : "%r" (__m0), \ "r" (__m1)); \ - (pl) = (unsigned long int) (__m0) * (unsigned long int) (__m1); \ + (pl) = __m0 * __m1; \ } while (0) #define SMUL_TIME 14 #define UDIV_TIME 120 -#define count_leading_zeros(count, x) \ - __asm__ ("cntlzw %0,%1" \ - : "=r" ((unsigned long int)(count)) \ - : "r" ((unsigned long int)(x))) -#endif /* ___IBMR2__ */ +#else +#define umul_ppmm(xh, xl, m0, m1) \ + do { \ + USItype __m0 = (m0), __m1 = (m1); \ + __asm__ ("mul %0,%2,%3" \ + : "=r" ((USItype)(xh)), \ + "=q" ((USItype)(xl)) \ + : "r" (__m0), \ + "r" (__m1)); \ + (xh) += ((((SItype) __m0 >> 31) & __m1) \ + + (((SItype) __m1 >> 31) & __m0)); \ + } while (0) +#define UMUL_TIME 8 +#define smul_ppmm(xh, xl, m0, m1) \ + __asm__ ("mul %0,%2,%3" \ + : "=r" ((SItype)(xh)), \ + "=q" ((SItype)(xl)) \ + : "r" (m0), \ + "r" (m1)) +#define SMUL_TIME 4 +#define sdiv_qrnnd(q, r, nh, nl, d) \ + __asm__ ("div %0,%2,%4" \ + : "=r" ((SItype)(q)), "=q" ((SItype)(r)) \ + : "r" ((SItype)(nh)), "1" ((SItype)(nl)), "r" ((SItype)(d))) +#define UDIV_TIME 100 +#endif +#endif /* Power architecture variants. */ -#if defined (__pyr__) +#if defined (__pyr__) && W_TYPE_SIZE == 32 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("addw %5,%1 addwc %3,%0" \ - : "=r" ((unsigned long int)(sh)), \ - "=&r" ((unsigned long int)(sl)) \ - : "%0" ((unsigned long int)(ah)), \ - "g" ((unsigned long int)(bh)), \ - "%1" ((unsigned long int)(al)), \ - "g" ((unsigned long int)(bl))) + : "=r" ((USItype)(sh)), \ + "=&r" ((USItype)(sl)) \ + : "%0" ((USItype)(ah)), \ + "g" ((USItype)(bh)), \ + "%1" ((USItype)(al)), \ + "g" ((USItype)(bl))) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("subw %5,%1 subwb %3,%0" \ - : "=r" ((unsigned long int)(sh)), \ - "=&r" ((unsigned long int)(sl)) \ - : "0" ((unsigned long int)(ah)), \ - "g" ((unsigned long int)(bh)), \ - "1" ((unsigned long int)(al)), \ - "g" ((unsigned long int)(bl))) + : "=r" ((USItype)(sh)), \ + "=&r" ((USItype)(sl)) \ + : "0" ((USItype)(ah)), \ + "g" ((USItype)(bh)), \ + "1" ((USItype)(al)), \ + "g" ((USItype)(bl))) /* This insn doesn't work on ancient pyramids. */ #define umul_ppmm(w1, w0, u, v) \ - ({union {long long int __ll; \ - struct {unsigned long int __h, __l;} __i; \ + ({union {UDItype __ll; \ + struct {USItype __h, __l;} __i; \ } __xx; \ __xx.__i.__l = u; \ __asm__ ("uemul %3,%0" \ @@ -815,32 +795,32 @@ : "=r" (__xx.__i.__h), \ "=r" (__xx.__i.__l) \ : "1" (__xx.__i.__l), \ - "g" (v)); \ + "g" ((USItype)(v))); \ (w1) = __xx.__i.__h; (w0) = __xx.__i.__l;}) #endif /* __pyr__ */ -#if defined (__ibm032__) /* RT/ROMP */ +#if defined (__ibm032__) /* RT/ROMP */ && W_TYPE_SIZE == 32 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("a %1,%5 ae %0,%3" \ - : "=r" ((unsigned long int)(sh)), \ - "=&r" ((unsigned long int)(sl)) \ - : "%0" ((unsigned long int)(ah)), \ - "r" ((unsigned long int)(bh)), \ - "%1" ((unsigned long int)(al)), \ - "r" ((unsigned long int)(bl))) + : "=r" ((USItype)(sh)), \ + "=&r" ((USItype)(sl)) \ + : "%0" ((USItype)(ah)), \ + "r" ((USItype)(bh)), \ + "%1" ((USItype)(al)), \ + "r" ((USItype)(bl))) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("s %1,%5 se %0,%3" \ - : "=r" ((unsigned long int)(sh)), \ - "=&r" ((unsigned long int)(sl)) \ - : "0" ((unsigned long int)(ah)), \ - "r" ((unsigned long int)(bh)), \ - "1" ((unsigned long int)(al)), \ - "r" ((unsigned long int)(bl))) + : "=r" ((USItype)(sh)), \ + "=&r" ((USItype)(sl)) \ + : "0" ((USItype)(ah)), \ + "r" ((USItype)(bh)), \ + "1" ((USItype)(al)), \ + "r" ((USItype)(bl))) #define umul_ppmm(ph, pl, m0, m1) \ do { \ - unsigned long int __m0 = (m0), __m1 = (m1); \ + USItype __m0 = (m0), __m1 = (m1); \ __asm__ ( \ "s r2,r2 mts r10,%2 @@ -862,13 +842,13 @@ m r2,%3 cas %0,r2,r0 mfs r10,%1" \ - : "=r" ((unsigned long int)(ph)), \ - "=r" ((unsigned long int)(pl)) \ + : "=r" ((USItype)(ph)), \ + "=r" ((USItype)(pl)) \ : "%r" (__m0), \ "r" (__m1) \ : "r2"); \ - (ph) += ((((signed long int) __m0 >> 31) & __m1) \ - + (((signed long int) __m1 >> 31) & __m0)); \ + (ph) += ((((SItype) __m0 >> 31) & __m1) \ + + (((SItype) __m1 >> 31) & __m0)); \ } while (0) #define UMUL_TIME 20 #define UDIV_TIME 200 @@ -876,38 +856,38 @@ do { \ if ((x) >= 0x10000) \ __asm__ ("clz %0,%1" \ - : "=r" ((unsigned long int)(count)) \ - : "r" ((unsigned long int)(x) >> 16)); \ + : "=r" ((USItype)(count)) \ + : "r" ((USItype)(x) >> 16)); \ else \ { \ __asm__ ("clz %0,%1" \ - : "=r" ((unsigned long int)(count)) \ - : "r" ((unsigned long int)(x))); \ + : "=r" ((USItype)(count)) \ + : "r" ((USItype)(x))); \ (count) += 16; \ } \ } while (0) #endif -#if defined (__sparc__) +#if defined (__sparc__) && W_TYPE_SIZE == 32 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("addcc %r4,%5,%1 addx %r2,%3,%0" \ - : "=r" ((unsigned long int)(sh)), \ - "=&r" ((unsigned long int)(sl)) \ - : "%rJ" ((unsigned long int)(ah)), \ - "rI" ((unsigned long int)(bh)), \ - "%rJ" ((unsigned long int)(al)), \ - "rI" ((unsigned long int)(bl)) \ + : "=r" ((USItype)(sh)), \ + "=&r" ((USItype)(sl)) \ + : "%rJ" ((USItype)(ah)), \ + "rI" ((USItype)(bh)), \ + "%rJ" ((USItype)(al)), \ + "rI" ((USItype)(bl)) \ __CLOBBER_CC) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("subcc %r4,%5,%1 subx %r2,%3,%0" \ - : "=r" ((unsigned long int)(sh)), \ - "=&r" ((unsigned long int)(sl)) \ - : "rJ" ((unsigned long int)(ah)), \ - "rI" ((unsigned long int)(bh)), \ - "rJ" ((unsigned long int)(al)), \ - "rI" ((unsigned long int)(bl)) \ + : "=r" ((USItype)(sh)), \ + "=&r" ((USItype)(sl)) \ + : "rJ" ((USItype)(ah)), \ + "rI" ((USItype)(bh)), \ + "rJ" ((USItype)(al)), \ + "rI" ((USItype)(bl)) \ __CLOBBER_CC) #if defined (__sparc_v8__) /* Don't match immediate range because, 1) it is not often useful, @@ -916,22 +896,84 @@ but INTERPRETED AS UNSIGNED. */ #define umul_ppmm(w1, w0, u, v) \ __asm__ ("umul %2,%3,%1;rd %%y,%0" \ - : "=r" ((unsigned long int)(w1)), \ - "=r" ((unsigned long int)(w0)) \ - : "r" ((unsigned long int)(u)), \ - "r" ((unsigned long int)(v))) + : "=r" ((USItype)(w1)), \ + "=r" ((USItype)(w0)) \ + : "r" ((USItype)(u)), \ + "r" ((USItype)(v))) +#define UMUL_TIME 5 /* We might want to leave this undefined for `SuperSPARC (tm)' since its implementation is crippled and often traps. */ #define udiv_qrnnd(q, r, n1, n0, d) \ __asm__ ("mov %2,%%y;nop;nop;nop;udiv %3,%4,%0;umul %0,%4,%1;sub %3,%1,%1"\ - : "=&r" ((unsigned long int)(q)), \ - "=&r" ((unsigned long int)(r)) \ - : "r" ((unsigned long int)(n1)), \ - "r" ((unsigned long int)(n0)), \ - "r" ((unsigned long int)(d))) -#define UMUL_TIME 5 + : "=&r" ((USItype)(q)), \ + "=&r" ((USItype)(r)) \ + : "r" ((USItype)(n1)), \ + "r" ((USItype)(n0)), \ + "r" ((USItype)(d))) #define UDIV_TIME 25 #else +#if defined (__sparclite__) +/* This has hardware multiply but not divide. It also has two additional + instructions scan (ffs from high bit) and divscc. */ +#define umul_ppmm(w1, w0, u, v) \ + __asm__ ("umul %2,%3,%1;rd %%y,%0" \ + : "=r" ((USItype)(w1)), \ + "=r" ((USItype)(w0)) \ + : "r" ((USItype)(u)), \ + "r" ((USItype)(v))) +#define UMUL_TIME 5 +#define udiv_qrnnd(q, r, n1, n0, d) \ + __asm__ ("! Inlined udiv_qrnnd + wr %%g0,%2,%%y ! Not a delayed write for sparclite + tst %%g0 + divscc %3,%4,%%g1 + divscc %%g1,%4,%%g1 + divscc %%g1,%4,%%g1 + divscc %%g1,%4,%%g1 + divscc %%g1,%4,%%g1 + divscc %%g1,%4,%%g1 + divscc %%g1,%4,%%g1 + divscc %%g1,%4,%%g1 + divscc %%g1,%4,%%g1 + divscc %%g1,%4,%%g1 + divscc %%g1,%4,%%g1 + divscc %%g1,%4,%%g1 + divscc %%g1,%4,%%g1 + divscc %%g1,%4,%%g1 + divscc %%g1,%4,%%g1 + divscc %%g1,%4,%%g1 + divscc %%g1,%4,%%g1 + divscc %%g1,%4,%%g1 + divscc %%g1,%4,%%g1 + divscc %%g1,%4,%%g1 + divscc %%g1,%4,%%g1 + divscc %%g1,%4,%%g1 + divscc %%g1,%4,%%g1 + divscc %%g1,%4,%%g1 + divscc %%g1,%4,%%g1 + divscc %%g1,%4,%%g1 + divscc %%g1,%4,%%g1 + divscc %%g1,%4,%%g1 + divscc %%g1,%4,%%g1 + divscc %%g1,%4,%%g1 + divscc %%g1,%4,%%g1 + divscc %%g1,%4,%0 + rd %%y,%1 + bl,a 1f + add %1,%4,%1 +1: ! End of inline udiv_qrnnd" \ + : "=r" ((USItype)(q)), \ + "=r" ((USItype)(r)) \ + : "r" ((USItype)(n1)), \ + "r" ((USItype)(n0)), \ + "rI" ((USItype)(d)) \ + : "%g1" __AND_CLOBBER_CC) +#define UDIV_TIME 37 +#define count_leading_zeros(count, x) \ + __asm__ ("scan %1,0,%0" \ + : "=r" ((USItype)(x)) \ + : "r" ((USItype)(count))) +#else /* SPARC without integer multiplication and divide instructions. (i.e. at least Sun4/20,40,60,65,75,110,260,280,330,360,380,470,490) */ #define umul_ppmm(w1, w0, u, v) \ @@ -975,61 +1017,60 @@ mulscc %%g1,0,%%g1 add %%g1,%%g2,%0 rd %%y,%1" \ - : "=r" ((unsigned long int)(w1)), \ - "=r" ((unsigned long int)(w0)) \ - : "%rI" ((unsigned long int)(u)), \ - "r" ((unsigned long int)(v)) \ + : "=r" ((USItype)(w1)), \ + "=r" ((USItype)(w0)) \ + : "%rI" ((USItype)(u)), \ + "r" ((USItype)(v)) \ : "%g1", "%g2" __AND_CLOBBER_CC) #define UMUL_TIME 39 /* 39 instructions */ -/* It's quite necessary to add this much assembler for the sparc. - The default udiv_qrnnd (in C) is more than 10 times slower! */ #define udiv_qrnnd(q, r, n1, n0, d) \ - do { unsigned long int __r; \ - (q) = __udiv_qrnnd(&__r, (n1), (n0), (d)); \ + do { USItype __r; \ + (q) = __udiv_qrnnd (&__r, (n1), (n0), (d)); \ (r) = __r; \ } while (0) -extern unsigned long __udiv_qrnnd (); +extern USItype __udiv_qrnnd (); #define UDIV_TIME 140 -#endif /* __sparc8__ */ +#endif /* __sparclite__ */ +#endif /* __sparc_v8__ */ #endif /* __sparc__ */ -#if defined (__vax__) +#if defined (__vax__) && W_TYPE_SIZE == 32 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("addl2 %5,%1 adwc %3,%0" \ - : "=g" ((unsigned long int)(sh)), \ - "=&g" ((unsigned long int)(sl)) \ - : "%0" ((unsigned long int)(ah)), \ - "g" ((unsigned long int)(bh)), \ - "%1" ((unsigned long int)(al)), \ - "g" ((unsigned long int)(bl))) + : "=g" ((USItype)(sh)), \ + "=&g" ((USItype)(sl)) \ + : "%0" ((USItype)(ah)), \ + "g" ((USItype)(bh)), \ + "%1" ((USItype)(al)), \ + "g" ((USItype)(bl))) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("subl2 %5,%1 sbwc %3,%0" \ - : "=g" ((unsigned long int)(sh)), \ - "=&g" ((unsigned long int)(sl)) \ - : "0" ((unsigned long int)(ah)), \ - "g" ((unsigned long int)(bh)), \ - "1" ((unsigned long int)(al)), \ - "g" ((unsigned long int)(bl))) + : "=g" ((USItype)(sh)), \ + "=&g" ((USItype)(sl)) \ + : "0" ((USItype)(ah)), \ + "g" ((USItype)(bh)), \ + "1" ((USItype)(al)), \ + "g" ((USItype)(bl))) #define umul_ppmm(xh, xl, m0, m1) \ do { \ - union {long long int __ll; \ - struct {unsigned long int __l, __h;} __i; \ + union {UDItype __ll; \ + struct {USItype __l, __h;} __i; \ } __xx; \ - unsigned long int __m0 = (m0), __m1 = (m1); \ + USItype __m0 = (m0), __m1 = (m1); \ __asm__ ("emul %1,%2,$0,%0" \ : "=g" (__xx.__ll) \ : "g" (__m0), \ "g" (__m1)); \ (xh) = __xx.__i.__h; (xl) = __xx.__i.__l; \ - (xh) += ((((signed long int) __m0 >> 31) & __m1) \ - + (((signed long int) __m1 >> 31) & __m0)); \ + (xh) += ((((SItype) __m0 >> 31) & __m1) \ + + (((SItype) __m1 >> 31) & __m0)); \ } while (0) #define sdiv_qrnnd(q, r, n1, n0, d) \ do { \ - union {long long int __ll; \ - struct {unsigned long int __l, __h;} __i; \ + union {DItype __ll; \ + struct {SItype __l, __h;} __i; \ } __xx; \ __xx.__i.__h = n1; __xx.__i.__l = n0; \ __asm__ ("ediv %3,%2,%0,%1" \ @@ -1038,7 +1079,7 @@ } while (0) #endif /* __vax__ */ -#if defined (__z8000__) +#if defined (__z8000__) && W_TYPE_SIZE == 16 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("add %H1,%H5\n\tadc %H0,%H3" \ : "=r" ((unsigned int)(sh)), \ @@ -1092,17 +1133,17 @@ #if !defined (umul_ppmm) && defined (__umulsidi3) #define umul_ppmm(ph, pl, m0, m1) \ { \ - unsigned long long int __ll = __umulsidi3 (m0, m1); \ - ph = (unsigned long int) (__ll >> LONG_TYPE_SIZE); \ - pl = (unsigned long int) __ll; \ + UDWtype __ll = __umulsidi3 (m0, m1); \ + ph = (UWtype) (__ll >> W_TYPE_SIZE); \ + pl = (UWtype) __ll; \ } #endif #if !defined (__umulsidi3) #define __umulsidi3(u, v) \ - ({long __hi, __lo; \ + ({UWtype __hi, __lo; \ umul_ppmm (__hi, __lo, u, v); \ - ((unsigned long long) __hi << LONG_TYPE_SIZE) | __lo; }) + ((UDWtype) __hi << W_TYPE_SIZE) | __lo; }) #endif /* If this machine has no inline assembler, use C macros. */ @@ -1110,7 +1151,7 @@ #if !defined (add_ssaaaa) #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ do { \ - unsigned long int __x; \ + UWtype __x; \ __x = (al) + (bl); \ (sh) = (ah) + (bh) + (__x < (al)); \ (sl) = __x; \ @@ -1120,7 +1161,7 @@ #if !defined (sub_ddmmss) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ do { \ - unsigned long int __x; \ + UWtype __x; \ __x = (al) - (bl); \ (sh) = (ah) - (bh) - (__x > (al)); \ (sl) = __x; \ @@ -1130,8 +1171,8 @@ #if !defined (umul_ppmm) #define umul_ppmm(w1, w0, u, v) \ do { \ - unsigned long int __x0, __x1, __x2, __x3; \ - unsigned int __ul, __vl, __uh, __vh; \ + UWtype __x0, __x1, __x2, __x3; \ + UHWtype __ul, __vl, __uh, __vh; \ \ __ul = __ll_lowpart (u); \ __uh = __ll_highpart (u); \ @@ -1138,10 +1179,10 @@ __vl = __ll_lowpart (v); \ __vh = __ll_highpart (v); \ \ - __x0 = (unsigned long int) __ul * __vl; \ - __x1 = (unsigned long int) __ul * __vh; \ - __x2 = (unsigned long int) __uh * __vl; \ - __x3 = (unsigned long int) __uh * __vh; \ + __x0 = (UWtype) __ul * __vl; \ + __x1 = (UWtype) __ul * __vh; \ + __x2 = (UWtype) __uh * __vl; \ + __x3 = (UWtype) __uh * __vh; \ \ __x1 += __ll_highpart (__x0);/* this can't give carry */ \ __x1 += __x2; /* but this indeed can */ \ @@ -1149,7 +1190,7 @@ __x3 += __ll_B; /* yes, add it in the proper pos. */ \ \ (w1) = __x3 + __ll_highpart (__x1); \ - (w0) = __ll_lowpart (__x1) * __ll_B + __ll_lowpart (__x0); \ + (w0) = (__ll_lowpart (__x1) << W_TYPE_SIZE/2) + __ll_lowpart (__x0);\ } while (0) #endif @@ -1156,13 +1197,13 @@ /* Define this unconditionally, so it can be used for debugging. */ #define __udiv_qrnnd_c(q, r, n1, n0, d) \ do { \ - unsigned long int __d1, __d0, __q1, __q0, __r1, __r0, __m; \ + UWtype __d1, __d0, __q1, __q0, __r1, __r0, __m; \ __d1 = __ll_highpart (d); \ __d0 = __ll_lowpart (d); \ \ __r1 = (n1) % __d1; \ __q1 = (n1) / __d1; \ - __m = (unsigned long int) __q1 * __d0; \ + __m = (UWtype) __q1 * __d0; \ __r1 = __r1 * __ll_B | __ll_highpart (n0); \ if (__r1 < __m) \ { \ @@ -1175,7 +1216,7 @@ \ __r0 = __r1 % __d1; \ __q0 = __r1 / __d1; \ - __m = (unsigned long int) __q0 * __d0; \ + __m = (UWtype) __q0 * __d0; \ __r0 = __r0 * __ll_B | __ll_lowpart (n0); \ if (__r0 < __m) \ { \ @@ -1186,7 +1227,7 @@ } \ __r0 -= __m; \ \ - (q) = (unsigned long int) __q1 * __ll_B | __q0; \ + (q) = (UWtype) __q1 * __ll_B | __q0; \ (r) = __r0; \ } while (0) @@ -1195,7 +1236,7 @@ #if !defined (udiv_qrnnd) && defined (sdiv_qrnnd) #define udiv_qrnnd(q, r, nh, nl, d) \ do { \ - unsigned long int __r; \ + UWtype __r; \ (q) = __udiv_w_sdiv (&__r, nh, nl, d); \ (r) = __r; \ } while (0) @@ -1215,26 +1256,26 @@ unsigned char __clz_tab[]; #define count_leading_zeros(count, x) \ do { \ - unsigned long int __xr = (x); \ - unsigned int __a; \ + UWtype __xr = (x); \ + UWtype __a; \ \ - if (LONG_TYPE_SIZE <= 32) \ + if (W_TYPE_SIZE <= 32) \ { \ - __a = __xr < (1<<2*__BITS4) \ - ? (__xr < (1<<__BITS4) ? 0 : __BITS4) \ - : (__xr < (1<<3*__BITS4) ? 2*__BITS4 : 3*__BITS4); \ + __a = __xr < ((UWtype) 1 << 2*__BITS4) \ + ? (__xr < ((UWtype) 1 << __BITS4) ? 0 : __BITS4) \ + : (__xr < ((UWtype) 1 << 3*__BITS4) ? 2*__BITS4 : 3*__BITS4);\ } \ else \ { \ - for (__a = LONG_TYPE_SIZE - 8; __a > 0; __a -= 8) \ + for (__a = W_TYPE_SIZE - 8; __a > 0; __a -= 8) \ if (((__xr >> __a) & 0xff) != 0) \ break; \ } \ \ - (count) = LONG_TYPE_SIZE - (__clz_tab[__xr >> __a] + __a); \ + (count) = W_TYPE_SIZE - (__clz_tab[__xr >> __a] + __a); \ } while (0) /* This version gives a well-defined value for zero. */ -#define COUNT_LEADING_ZEROS_0 LONG_TYPE_SIZE +#define COUNT_LEADING_ZEROS_0 W_TYPE_SIZE #endif #if !defined (count_trailing_zeros) @@ -1242,10 +1283,10 @@ defined in asm, but if it is not, the C version above is good enough. */ #define count_trailing_zeros(count, x) \ do { \ - unsigned long int __ctz_x = (x); \ - unsigned int __ctz_c; \ + UWtype __ctz_x = (x); \ + UWtype __ctz_c; \ count_leading_zeros (__ctz_c, __ctz_x & -__ctz_x); \ - (count) = LONG_TYPE_SIZE - 1 - __ctz_c; \ + (count) = W_TYPE_SIZE - 1 - __ctz_c; \ } while (0) #endif diff -ruN glibc-1.07/stdio/mp_clz_tab.c glibc-1.08.1/stdio/mp_clz_tab.c --- glibc-1.07/stdio/mp_clz_tab.c Sun Jan 16 00:17:24 1994 +++ glibc-1.08.1/stdio/mp_clz_tab.c Tue Apr 26 22:02:11 1994 @@ -1,26 +1,22 @@ /* __clz_tab -- support for longlong.h -Copyright (C) 1991, 1993 Free Software Foundation, Inc. +Copyright (C) 1991, 1993, 1994 Free Software Foundation, Inc. +This file is part of the GNU MP Library. -! This file is part of the GNU C Library. Its master source is NOT part of -! the C library, however. This file is in fact copied from the GNU MP -! Library and its source lives there. - -! 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 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. */ #if 0 #include "gmp.h" @@ -27,7 +23,10 @@ #include "gmp-impl.h" #endif -const unsigned char __clz_tab[] = +#if 0 +const +#endif + unsigned char __clz_tab[] = { 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, diff -ruN glibc-1.07/stdio/mpn-copy.mk glibc-1.08.1/stdio/mpn-copy.mk --- glibc-1.07/stdio/mpn-copy.mk Sat Jan 15 21:33:28 1994 +++ glibc-1.08.1/stdio/mpn-copy.mk Tue Apr 26 21:58:23 1994 @@ -3,7 +3,7 @@ mpn-found := $(filter-out $(mpn-found-1),$(mpn-found)) mpn-copy-sysdep := $(mpn-copy-sysdep) $(mpn-copy-1) $(mpn-copy-1): $(sysdep_dir)/sparc/sparc8/%: \ - gmp2glibc.sed $(gmp-srcdir)/mpn/sparc8/% + $(ignore gmp2glibc.sed) $(gmp-srcdir)/mpn/sparc8/% $(gmp2glibc) mpn-found-1 := $(filter $(gmp-srcdir)/mpn/sparc9/%,$(mpn-found)) mpn-copy-1 := $(patsubst $(gmp-srcdir)/mpn/sparc9/%,$(sysdep_dir)/sparc/sparc9/%,$(mpn-found-1)) @@ -10,7 +10,7 @@ mpn-found := $(filter-out $(mpn-found-1),$(mpn-found)) mpn-copy-sysdep := $(mpn-copy-sysdep) $(mpn-copy-1) $(mpn-copy-1): $(sysdep_dir)/sparc/sparc9/%: \ - gmp2glibc.sed $(gmp-srcdir)/mpn/sparc9/% + $(ignore gmp2glibc.sed) $(gmp-srcdir)/mpn/sparc9/% $(gmp2glibc) mpn-found-1 := $(filter $(gmp-srcdir)/mpn/mc68000/%,$(mpn-found)) mpn-copy-1 := $(patsubst $(gmp-srcdir)/mpn/mc68000/%,$(sysdep_dir)/m68k/m68000/%,$(mpn-found-1)) @@ -17,7 +17,7 @@ mpn-found := $(filter-out $(mpn-found-1),$(mpn-found)) mpn-copy-sysdep := $(mpn-copy-sysdep) $(mpn-copy-1) $(mpn-copy-1): $(sysdep_dir)/m68k/m68000/%: \ - gmp2glibc.sed $(gmp-srcdir)/mpn/mc68000/% + $(ignore gmp2glibc.sed) $(gmp-srcdir)/mpn/mc68000/% $(gmp2glibc) mpn-found-1 := $(filter $(gmp-srcdir)/mpn/mc68020/%,$(mpn-found)) mpn-copy-1 := $(patsubst $(gmp-srcdir)/mpn/mc68020/%,$(sysdep_dir)/m68k/m68020/%,$(mpn-found-1)) @@ -24,7 +24,7 @@ mpn-found := $(filter-out $(mpn-found-1),$(mpn-found)) mpn-copy-sysdep := $(mpn-copy-sysdep) $(mpn-copy-1) $(mpn-copy-1): $(sysdep_dir)/m68k/m68020/%: \ - gmp2glibc.sed $(gmp-srcdir)/mpn/mc68020/% + $(ignore gmp2glibc.sed) $(gmp-srcdir)/mpn/mc68020/% $(gmp2glibc) mpn-found-1 := $(filter $(gmp-srcdir)/mpn/mc88100/%,$(mpn-found)) mpn-copy-1 := $(patsubst $(gmp-srcdir)/mpn/mc88100/%,$(sysdep_dir)/m88k/m88100/%,$(mpn-found-1)) @@ -31,7 +31,7 @@ mpn-found := $(filter-out $(mpn-found-1),$(mpn-found)) mpn-copy-sysdep := $(mpn-copy-sysdep) $(mpn-copy-1) $(mpn-copy-1): $(sysdep_dir)/m88k/m88100/%: \ - gmp2glibc.sed $(gmp-srcdir)/mpn/mc88100/% + $(ignore gmp2glibc.sed) $(gmp-srcdir)/mpn/mc88100/% $(gmp2glibc) mpn-found-1 := $(filter $(gmp-srcdir)/mpn/mc88110/%,$(mpn-found)) mpn-copy-1 := $(patsubst $(gmp-srcdir)/mpn/mc88110/%,$(sysdep_dir)/m88k/m88110/%,$(mpn-found-1)) @@ -38,7 +38,7 @@ mpn-found := $(filter-out $(mpn-found-1),$(mpn-found)) mpn-copy-sysdep := $(mpn-copy-sysdep) $(mpn-copy-1) $(mpn-copy-1): $(sysdep_dir)/m88k/m88110/%: \ - gmp2glibc.sed $(gmp-srcdir)/mpn/mc88110/% + $(ignore gmp2glibc.sed) $(gmp-srcdir)/mpn/mc88110/% $(gmp2glibc) mpn-found-1 := $(filter $(gmp-srcdir)/mpn/r3000/%,$(mpn-found)) mpn-copy-1 := $(patsubst $(gmp-srcdir)/mpn/r3000/%,$(sysdep_dir)/mips/r3000/%,$(mpn-found-1)) @@ -45,7 +45,7 @@ mpn-found := $(filter-out $(mpn-found-1),$(mpn-found)) mpn-copy-sysdep := $(mpn-copy-sysdep) $(mpn-copy-1) $(mpn-copy-1): $(sysdep_dir)/mips/r3000/%: \ - gmp2glibc.sed $(gmp-srcdir)/mpn/r3000/% + $(ignore gmp2glibc.sed) $(gmp-srcdir)/mpn/r3000/% $(gmp2glibc) mpn-found-1 := $(filter $(gmp-srcdir)/mpn/r4000/%,$(mpn-found)) mpn-copy-1 := $(patsubst $(gmp-srcdir)/mpn/r4000/%,$(sysdep_dir)/mips/r4000/%,$(mpn-found-1)) @@ -52,5 +52,5 @@ mpn-found := $(filter-out $(mpn-found-1),$(mpn-found)) mpn-copy-sysdep := $(mpn-copy-sysdep) $(mpn-copy-1) $(mpn-copy-1): $(sysdep_dir)/mips/r4000/%: \ - gmp2glibc.sed $(gmp-srcdir)/mpn/r4000/% + $(ignore gmp2glibc.sed) $(gmp-srcdir)/mpn/r4000/% $(gmp2glibc) diff -ruN glibc-1.07/stdio/printf_fp.c glibc-1.08.1/stdio/printf_fp.c --- glibc-1.07/stdio/printf_fp.c Sat Jan 15 17:28:38 1994 +++ glibc-1.08.1/stdio/printf_fp.c Tue May 10 17:49:30 1994 @@ -34,11 +34,8 @@ #include -#if DEBUG -#define MPN_DUMP(x,y,z) mpn_dump(x,y,z) -#else -#define MPN_DUMP(x,y,z) -#endif +#define NDEBUG +#include #define outchar(x) \ do \ @@ -54,8 +51,17 @@ #error "FLT_RADIX != 2. Write your own __printf_fp." #endif +#undef alloca /* gmp-impl.h defines it again. */ #include "gmp.h" #include "gmp-impl.h" +#include "longlong.h" + +#ifndef NDEBUG +static void mpn_dump (const char *str, mp_limb *p, mp_size_t size); +#define MPN_DUMP(x,y,z) mpn_dump(x,y,z) +#else +#define MPN_DUMP(x,y,z) +#endif extern mp_size_t __mpn_extract_double (mp_ptr res_ptr, mp_size_t size, int *expt, int *is_neg, @@ -165,7 +171,9 @@ { mp_limb norm_scale[scalesize]; mp_limb cy; + assert (scalesize != 0); __mpn_lshift (norm_scale, scale, scalesize, cnt); + assert (r10size != 0); cy = __mpn_lshift (r10, r10, r10size, cnt); if (cy != 0) r10[r10size++] = cy; @@ -189,8 +197,12 @@ digit = '0' + high_qlimb; r10size = __mpn_normal_size (r10, r10size); + if (r10size == 0) + /* We are not prepared for an mpn variable with zero limbs. */ + r10size = 1; MPN_ASSIGN (r, r10); + assert (rsize != 0); cy = __mpn_lshift (r2, r, rsize, 1); r2size = rsize; if (cy != 0) @@ -307,6 +319,9 @@ { if (fpnum != 0) { + if (is_neg) + fpnum = - fpnum; + if (fpnum < 1e-4) type = 'e'; else @@ -370,9 +385,11 @@ { MPN_COPY (r + (e - p) / BITS_PER_MP_LIMB, f, fsize); rsize = fsize + (e - p) / BITS_PER_MP_LIMB; + assert (rsize != 0); } else { + assert (fsize != 0); cy = __mpn_lshift (r + (e - p) / BITS_PER_MP_LIMB, f, fsize, (e - p) % BITS_PER_MP_LIMB); rsize = fsize + (e - p) / BITS_PER_MP_LIMB; @@ -381,10 +398,12 @@ } MPN_POW2 (scale, 0); + assert (scalesize != 0); /* The number is (E - P) factors of two larger than the fraction can represent; this is the potential error. */ MPN_POW2 (loerr, e - p); + assert (loerrsize != 0); } else { @@ -403,14 +422,17 @@ if (MPN_EQ (f, tmp)) { /* Account for unequal gaps. */ + assert (hierrsize != 0); cy = __mpn_lshift (hierr, hierr, hierrsize, 1); if (cy) hierr[hierrsize++] = cy; + assert (rsize != 0); cy = __mpn_lshift (r, r, rsize, 1); if (cy) r[rsize++] = cy; + assert (scalesize != 0); cy = __mpn_lshift (scale, scale, scalesize, 1); if (cy) scale[scalesize++] = cy; @@ -451,6 +473,7 @@ do { mp_limb cy; + assert (rsize != 0); cy = __mpn_lshift (r2, r, rsize, 1); r2size = rsize; if (cy != 0) @@ -471,6 +494,7 @@ tmp[tmpsize++] = cy; /* while (r2 + hierr >= 2 * scale) */ + assert (scalesize != 0); cy = __mpn_lshift (scale2, scale, scalesize, 1); scale2size = scalesize; if (cy) @@ -481,6 +505,7 @@ if (cy) scale[scalesize++] = cy; ++k; + assert (scalesize != 0); cy = __mpn_lshift (scale2, scale, scalesize, 1); scale2size = scalesize; if (cy) @@ -693,19 +718,19 @@ return done; } -#if DEBUG +#ifndef NDEBUG static void mpn_dump (str, p, size) - char *str; + const char *str; mp_limb *p; mp_size_t size; { - printf ("%s = ", str); + fprintf (stderr, "%s = ", str); while (size != 0) { size--; - printf ("%08lX", p[size]); + fprintf (stderr, "%08lX", p[size]); } - printf ("\n"); + fprintf (stderr, "\n"); } #endif diff -ruN glibc-1.07/stdio/stdio.h glibc-1.08.1/stdio/stdio.h --- glibc-1.07/stdio/stdio.h Mon Oct 25 17:37:21 1993 +++ glibc-1.08.1/stdio/stdio.h Fri Mar 25 18:29:31 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 @@ -101,15 +101,39 @@ or -1 on error. There need not be any associated file descriptor. */ typedef int __io_fileno_fn __P ((__ptr_t __cookie)); +#ifdef __USE_GNU +/* User-visible names for the above. */ +typedef __io_read_fn cookie_read_function_t; +typedef __io_write_fn cookie_write_function_t; +typedef __io_seek_fn cookie_seek_function_t; +typedef __io_close_fn cookie_close_function_t; +typedef __io_fileno_fn cookie_fileno_function_t; +#endif + /* Low level interface, independent of FILE representation. */ +#if defined (__USE_GNU) && !defined (_LIBC) +/* Define the user-visible type, with user-friendly member names. */ +typedef struct +{ + __io_read_fn *read; /* Read bytes. */ + __io_write_fn *write; /* Write bytes. */ + __io_seek_fn *seek; /* Seek/tell file position. */ + __io_close_fn *close; /* Close file. */ + __io_fileno_fn *fileno; /* Return file descriptor. */ +} cookie_io_functions_t; +/* This name is still used in the prototypes in this file. */ +typedef cookie_io_functions_t __io_functions; +#else +/* Stick to ANSI-safe names. */ typedef struct { __io_read_fn *__read; /* Read bytes. */ - __io_write_fn *__write; /* Write bytes. */ + __io_write_fn *__write; /* Write bytes. */ __io_seek_fn *__seek; /* Seek/tell file position. */ - __io_close_fn *__close; /* Close file. */ + __io_close_fn *__close; /* Close file. */ __io_fileno_fn *__fileno; /* Return file descriptor. */ } __io_functions; +#endif /* Higher level interface, dependent on FILE representation. */ typedef struct @@ -361,7 +385,11 @@ __gnuc_va_list __arg)); #ifdef __OPTIMIZE__ -#define vprintf(fmt, arg) vfprintf(stdout, (fmt), (arg)) +extern __inline int +vprintf (const char *__fmt, __gnuc_va_list __arg) +{ + return vfprintf (stdout, __fmt, __arg); +} #endif /* Optimizing. */ #ifdef __USE_GNU @@ -410,9 +438,21 @@ #ifdef __OPTIMIZE__ -#define vfscanf(s, format, arg) __vfscanf((s), (format), (arg)) -#define vscanf(format, arg) __vfscanf(stdin, (format), (arg)) -#define vsscanf(s, format, arg) __vsscanf((s), (format), (arg)) +extern __inline int +vfscanf (FILE *__s, const char *__fmt, __gnuc_va_list __arg) +{ + return __vfscanf (__s, __fmt, __arg); +} +extern __inline int +vscanf (const char *__fmt, __gnuc_va_list __arg) +{ + return __vfscanf (stdin, __fmt, __arg); +} +extern __inline int +vsscanf (const char *__s, const char *__fmt, __gnuc_va_list __arg) +{ + return __vsscanf (__s, __fmt, __arg); +} #endif /* Optimizing. */ #endif /* Use GNU. */ @@ -440,7 +480,11 @@ #define getc(stream) __getc(stream) #ifdef __OPTIMIZE__ -#define getchar() __getc(stdin) +extern __inline int +getchar (void) +{ + return __getc (stdin); +} #endif /* Optimizing. */ @@ -464,9 +508,11 @@ #define putc(c, stream) __putc ((c), (stream)) #ifdef __OPTIMIZE__ -/* Note that putchar is NOT allowed to evaluate its arguments more than once. - This macro is valid only because __putc evaluates C exactly once. */ -#define putchar(c) __putc ((c), stdout) +extern __inline int +putchar (int __c) +{ + return __putc (__c, stdout); +} #endif @@ -505,9 +551,22 @@ ssize_t getline __P ((char **__lineptr, size_t *__n, FILE *__stream)); #ifdef __OPTIMIZE__ -#define getdelim(l, n, d, s) __getdelim ((l), (n), (d), (s)) -#define getline(l, n, s) __getline ((l), (n), (s)) -#define __getline(l, n, stream) __getdelim ((l), (n), '\n', (stream)) +extern __inline ssize_t +__getline (char **__lineptr, size_t *__n, FILE *__stream) +{ + return __getdelim (__lineptr, __n, '\n', __stream); +} + +extern __inline ssize_t +getdelim (char **__lineptr, size_t *__n, int __delimiter, FILE *__stream) +{ + return __getdelim (__lineptr, __n, __delimiter, __stream); +} +extern __inline ssize_t +getline (char **__lineptr, size_t *__n, FILE *__stream) +{ + return __getline (__lineptr, __n, __stream); +} #endif /* Optimizing. */ #endif @@ -517,11 +576,7 @@ /* Write a string, followed by a newline, to stdout. */ extern int puts __P ((__const char *__s)); -#ifdef __OPTIMIZE__ -#define puts(s) ((fputs((s), stdout) || __putc('\n', stdout) == EOF) ? EOF : 0) -#endif /* Optimizing. */ - /* Push a character back onto the input buffer of STREAM. */ extern int ungetc __P ((int __c, FILE *__stream)); @@ -571,11 +626,6 @@ extern int _sys_nerr; extern char *_sys_errlist[]; #endif - -#ifdef __USE_MISC -/* Print a message describing the meaning of the given signal number. */ -extern void psignal __P ((int __sig, __const char *__s)); -#endif /* Non strict ANSI and not POSIX only. */ #ifdef __USE_POSIX diff -ruN glibc-1.07/stdio/test-popen.c glibc-1.08.1/stdio/test-popen.c --- glibc-1.07/stdio/test-popen.c Thu Apr 9 22:02:26 1992 +++ glibc-1.08.1/stdio/test-popen.c Wed May 18 18:25:07 1994 @@ -35,7 +35,7 @@ DEFUN_VOID(main) { FILE *output, *input; - int status; + int wstatus, rstatus; output = popen ("/bin/cat >tstpopen.tmp", "w"); if (output == NULL) @@ -45,9 +45,9 @@ exit (1); } write_data (output); - status = pclose (output); - fprintf (stderr, "pclose returned %d\n", status); - input = fopen ("tstpopen.tmp", "r"); + wstatus = pclose (output); + printf ("writing pclose returned %d\n", wstatus); + input = popen ("/bin/cat tstpopen.tmp", "r"); if (input == NULL) { perror ("tstpopen.tmp"); @@ -55,10 +55,11 @@ exit (1); } read_data (input); - (void) fclose (input); + rstatus = pclose (input); + printf ("reading pclose returned %d\n", rstatus); - puts (status ? "Test FAILED!" : "Test succeeded."); - exit (status); + puts (wstatus | rstatus ? "Test FAILED!" : "Test succeeded."); + exit (wstatus | rstatus); } diff -ruN glibc-1.07/stdio/tst-fileno.c glibc-1.08.1/stdio/tst-fileno.c --- glibc-1.07/stdio/tst-fileno.c +++ glibc-1.08.1/stdio/tst-fileno.c Mon Jan 24 17:19:37 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 +#include + +static int +DEFUN(check, (name, stream, fd), CONST char *name AND FILE *stream AND int fd) +{ + int sfd = fileno (stream); + printf ("(fileno (%s) = %d) %c= %d\n", name, sfd, sfd == fd ? '=' : '!', fd); + return sfd != fd; +} + +int +DEFUN_VOID(main) +{ + exit (check ("stdin", stdin, STDIN_FILENO) || + check ("stdout", stdout, STDOUT_FILENO) || + check ("stderr", stderr, STDERR_FILENO)); +} diff -ruN glibc-1.07/stdio/vfprintf.c glibc-1.08.1/stdio/vfprintf.c --- glibc-1.07/stdio/vfprintf.c Wed Nov 3 08:14:14 1993 +++ glibc-1.08.1/stdio/vfprintf.c Mon May 23 20:14: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 @@ -28,6 +28,8 @@ #include #include #include +#include +#include "_itoa.h" /* If it's an unbuffered stream that we provided @@ -71,13 +73,6 @@ DEFUN(vfprintf, (s, format, args), register FILE *s AND CONST char *format AND va_list args) { - /* Lower-case digits. */ - static CONST char lower_digits[] = "0123456789abcdefghijklmnopqrstuvwxyz"; - /* Upper-case digits. */ - static CONST char upper_digits[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - /* Base-36 digits for numbers. */ - CONST char *digits = lower_digits; - /* Pointer into the format string. */ register CONST char *f; @@ -302,6 +297,15 @@ /* double's are long double's, and int's are long long int's. */ is_long_double = 1; break; + + case 'Z': + /* int's are size_t's. */ +#ifdef HAVE_LONGLONG + assert (sizeof(size_t) <= sizeof(unsigned long long int)); + is_longlong = sizeof(size_t) > sizeof(unsigned long int); +#endif + is_long = sizeof(size_t) > sizeof(unsigned int); + break; } /* Format specification. */ @@ -328,18 +332,6 @@ num = is_neg ? (- signed_num) : signed_num; goto number; - case 'Z': - /* `size_t' value. */ -#ifdef HAVE_LONGLONG - if (sizeof(size_t) > sizeof(unsigned long long int)) - __libc_fatal("`size_t' is bigger than any known type!"); - else - is_longlong = sizeof(size_t) > sizeof(unsigned long int); -#endif - is_long = sizeof(size_t) > sizeof(unsigned int); - - /* Fall through, to print a `size_t' as a decimal integer. */ - case 'u': /* Decimal unsigned integer. */ base = 10; @@ -355,8 +347,6 @@ case 'x': /* Hex with lower-case digits. */ - digits = fc == 'X' ? upper_digits : lower_digits; - base = 16; unsigned_number: @@ -387,12 +377,7 @@ prec = 1; /* Put the number in WORK. */ - w = workend; - while (num > 0) - { - *w-- = digits[num % base]; - num /= base; - } + w = _itoa (num, workend + 1, base, fc == 'X') - 1; width -= workend - w; prec -= workend - w; diff -ruN glibc-1.07/stdio/xbug.c glibc-1.08.1/stdio/xbug.c --- glibc-1.07/stdio/xbug.c +++ glibc-1.08.1/stdio/xbug.c Mon Jun 6 12:26:20 1994 @@ -0,0 +1,24 @@ +#include + +int +main() +{ + 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"); + + + while(gets(buf) != NULL) { + fprintf(stdout, "read: %s\n", buf); + } + + return 0; +} diff -ruN glibc-1.07/stdlib/testsort.c glibc-1.08.1/stdlib/testsort.c --- glibc-1.07/stdlib/testsort.c Sat Jan 15 23:48:43 1994 +++ glibc-1.08.1/stdlib/testsort.c Wed Jan 26 20:21:07 1994 @@ -13,7 +13,7 @@ int DEFUN_VOID(main) { - char bufs[20][500]; + char bufs[500][20]; char *lines[500]; size_t lens[500]; size_t i, j; @@ -32,7 +32,7 @@ qsort (lines, 500, sizeof (char *), compare); for (i = 0; i < 500 && lines[i] != NULL; ++i) - fputs (lines[i], stdout); + puts (lines[i]); return 0; } diff -ruN glibc-1.07/string/strsignal.c glibc-1.08.1/string/strsignal.c --- glibc-1.07/string/strsignal.c Wed Apr 1 03:08:50 1992 +++ glibc-1.08.1/string/strsignal.c Fri Apr 8 14:57:45 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 @@ -41,7 +41,7 @@ size_t len = sprintf(unknown_signal, fmt, signum); if (len < sizeof(fmt) - 2) return NULL; - unknown_signal[len - 1] = '\0'; + unknown_signal[len] = '\0'; return unknown_signal; } diff -ruN glibc-1.07/sunrpc/Makefile glibc-1.08.1/sunrpc/Makefile --- glibc-1.07/sunrpc/Makefile +++ glibc-1.08.1/sunrpc/Makefile Wed May 18 23:19:44 1994 @@ -0,0 +1,127 @@ +# 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 sunrpc portion of the library. +# +subdir := sunrpc + +# The code in this subdirectory is taken verbatim from Sun's RPCSRC-4.0 +# distribution. A few files needed trivial modifications to compile in the +# GNU environment; these changes are marked by comments that say +# `roland@gnu'. All the code from Sun's rpc, etc, and rpcgen +# subdirectories is in this directory; the rpc subdirectory contains only +# the header files. Other than that, several files were renamed so as not +# to exceed 14-character file name limits: +# +# authunix_prot.c -> authuxprot.c +# bindresvport.c -> bindrsvprt.c +# clnt_generic.c -> clnt_gen.c +# clnt_perror.c -> clnt_perr.c +# clnt_simple.c -> clnt_simp.c +# get_myaddress.c -> get_myaddr.c +# pmap_getmaps.c -> pm_getmaps.c +# pmap_getport.c -> pm_getport.c +# rpc_callmsg.c -> rpc_cmsg.c +# rpc_commondata.c -> rpc_common.c +# rpc_dtablesize.c -> rpc_dtable.c +# svc_auth_unix.c -> svc_authux.c +# xdr_reference.c -> xdr_ref.c +# rpcsvc/bootparam_prot.x -> rpcsvc/bootparam.x + +headers = $(addprefix rpc/,auth.h auth_unix.h clnt.h netdb.h pmap_clnt.h \ + pmap_prot.h pmap_rmt.h rpc.h rpc_msg.h svc.h \ + svc_auth.h types.h xdr.h) \ + $(rpcsvc:%=rpcsvc/%) $(rpcsvc:%.x=rpcsvc/%.h) +rpcsvc = bootparam.x nlm_prot.x rstat.x \ + yppasswd.x klm_prot.x rex.x sm_inter.x mount.x \ + rnusers.x spray.x nfs_prot.x rquota.x yp.x +install-others = $(includedir)/rpcsvc/bootparam_prot.h \ + $(etcdir)/rpc +generated = $(rpcsvc:%.x=rpcsvc/%.h) $(rpcsvc:%.x=x%.c) + +routines := auth_none auth_unix authuxprot bindrsvprt \ + clnt_gen clnt_perr clnt_raw clnt_simp clnt_tcp \ + clnt_udp rpc_dtable get_myaddr getrpcent getrpcport \ + pmap_clnt pm_getmaps pm_getport pmap_prot \ + pmap_prot2 pmap_rmt rpc_prot rpc_common rpc_cmsg \ + svc svc_auth svc_authux svc_raw svc_run svc_simple \ + svc_tcp svc_udp xdr xdr_array xdr_float xdr_mem \ + xdr_rec xdr_ref xdr_stdio + +install-lib := librpcsvc.a +install := rpcgen rpcinfo portmap +rpcsvc-objs = $(rpcsvc:%.x=x%.o) +rpcgen-objs = rpc_main.o rpc_hout.o rpc_cout.o rpc_parse.o \ + rpc_scan.o rpc_util.o rpc_svcout.o rpc_clntout.o +extra-objs = $(rpcgen-objs) $(rpcsvc-objs) +omit-deps = $(basename $(rpcsvc-objs)) +# These headers are part of rpcgen. +distribute := rpc_util.h rpc_parse.h rpc_scan.h $(rpcgen-objs:.o=.c) etc.rpc + +others := portmap rpcinfo + +# Sun's code is not too clean. +override +gccwarn := -w + +include ../Rules + +$(objpfx)rpcgen: $(addprefix $(objpfx),$(rpcgen-objs)) $(libc.a) + $(+link) + +rpcgen-cmd = $(dir $(word 2,$^))$(notdir $(word 2,$^)) + +# The proper file name is longer than 14 chars, so we install it under +# a shorter name. But if the filesystem can handle it, we want to +# install under the proper name as well. +$(includedir)/rpcsvc/bootparam_prot.h: $(includedir)/rpcsvc/bootparam.h + @echo It is safe to ignore an error here if this file name is too long. + -$(do-install) + +# Install the rpc data base file. +$(etcdir)/rpc: etc.rpc + $(do-install) + +defines := $(defines) -D_PATH_RPC='"$(etcdir)/rpc"' + +# Build the `rpcsvc' library of XDR functions. + +lib: $(objpfx)librpcsvc.a + +$(objpfx)librpcsvc.a: $(addprefix $(objpfx),$(rpcsvc-objs)) +# 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) $@ + +# Generate the rpcsvc headers with rpcgen. +$(objpfx)rpcsvc/%.h: rpcsvc/%.x $(objpfx)rpcgen + $(make-target-directory) + $(rpcgen-cmd) -h $< -o $@ +# Generate the rpcsvc XDR functions with rpcgen. +$(objpfx)x%.c: rpcsvc/%.x $(objpfx)rpcgen + $(rpcgen-cmd) -c $< -o $@ +# The generated source files depend on the corresponding generated headers. +# Gratuitous dependency on generated .c file here just gets it mentioned to +# avoid being an intermediate file and getting removed. +$(rpcsvc:%.x=$(objpfx)x%.o): $(objpfx)x%.o: $(objpfx)x%.c $(objpfx)rpcsvc/%.h diff -ruN glibc-1.07/sunrpc/auth_none.c glibc-1.08.1/sunrpc/auth_none.c --- glibc-1.07/sunrpc/auth_none.c +++ glibc-1.08.1/sunrpc/auth_none.c Sun Feb 6 16:42:41 1994 @@ -0,0 +1,133 @@ +/* @(#)auth_none.c 2.1 88/07/29 4.0 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +#if !defined(lint) && defined(SCCSIDS) +static char sccsid[] = "@(#)auth_none.c 1.19 87/08/11 Copyr 1984 Sun Micro"; +#endif + +/* + * auth_none.c + * Creates a client authentication handle for passing "null" + * credentials and verifiers to remote systems. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#include +#include +#include +#define MAX_MARSHEL_SIZE 20 + +/* + * Authenticator operations routines + */ +static void authnone_verf(); +static void authnone_destroy(); +static bool_t authnone_marshal(); +static bool_t authnone_validate(); +static bool_t authnone_refresh(); + +static struct auth_ops ops = { + authnone_verf, + authnone_marshal, + authnone_validate, + authnone_refresh, + authnone_destroy +}; + +static struct authnone_private { + AUTH no_client; + char marshalled_client[MAX_MARSHEL_SIZE]; + u_int mcnt; +} *authnone_private; + +AUTH * +authnone_create() +{ + register struct authnone_private *ap = authnone_private; + XDR xdr_stream; + register XDR *xdrs; + + if (ap == 0) { + ap = (struct authnone_private *)calloc(1, sizeof (*ap)); + if (ap == 0) + return (0); + authnone_private = ap; + } + if (!ap->mcnt) { + ap->no_client.ah_cred = ap->no_client.ah_verf = _null_auth; + ap->no_client.ah_ops = &ops; + xdrs = &xdr_stream; + xdrmem_create(xdrs, ap->marshalled_client, (u_int)MAX_MARSHEL_SIZE, + XDR_ENCODE); + (void)xdr_opaque_auth(xdrs, &ap->no_client.ah_cred); + (void)xdr_opaque_auth(xdrs, &ap->no_client.ah_verf); + ap->mcnt = XDR_GETPOS(xdrs); + XDR_DESTROY(xdrs); + } + return (&ap->no_client); +} + +/*ARGSUSED*/ +static bool_t +authnone_marshal(client, xdrs) + AUTH *client; + XDR *xdrs; +{ + register struct authnone_private *ap = authnone_private; + + if (ap == 0) + return (0); + return ((*xdrs->x_ops->x_putbytes)(xdrs, + ap->marshalled_client, ap->mcnt)); +} + +static void +authnone_verf() +{ +} + +static bool_t +authnone_validate() +{ + + return (TRUE); +} + +static bool_t +authnone_refresh() +{ + + return (FALSE); +} + +static void +authnone_destroy() +{ +} diff -ruN glibc-1.07/sunrpc/auth_unix.c glibc-1.08.1/sunrpc/auth_unix.c --- glibc-1.07/sunrpc/auth_unix.c +++ glibc-1.08.1/sunrpc/auth_unix.c Sun Feb 6 16:42:41 1994 @@ -0,0 +1,319 @@ +/* @(#)auth_unix.c 2.2 88/08/01 4.0 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +#if !defined(lint) && defined(SCCSIDS) +static char sccsid[] = "@(#)auth_unix.c 1.19 87/08/11 Copyr 1984 Sun Micro"; +#endif + +/* + * auth_unix.c, Implements UNIX style authentication parameters. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + * + * The system is very weak. The client uses no encryption for it's + * credentials and only sends null verifiers. The server sends backs + * null verifiers or optionally a verifier that suggests a new short hand + * for the credentials. + * + */ + +#include + +#include +#include +#include +#include + +/* + * Unix authenticator operations vector + */ +static void authunix_nextverf(); +static bool_t authunix_marshal(); +static bool_t authunix_validate(); +static bool_t authunix_refresh(); +static void authunix_destroy(); + +static struct auth_ops auth_unix_ops = { + authunix_nextverf, + authunix_marshal, + authunix_validate, + authunix_refresh, + authunix_destroy +}; + +/* + * This struct is pointed to by the ah_private field of an auth_handle. + */ +struct audata { + struct opaque_auth au_origcred; /* original credentials */ + struct opaque_auth au_shcred; /* short hand cred */ + u_long au_shfaults; /* short hand cache faults */ + char au_marshed[MAX_AUTH_BYTES]; + u_int au_mpos; /* xdr pos at end of marshed */ +}; +#define AUTH_PRIVATE(auth) ((struct audata *)auth->ah_private) + +static bool_t marshal_new_auth(); + + +/* + * Create a unix style authenticator. + * Returns an auth handle with the given stuff in it. + */ +AUTH * +authunix_create(machname, uid, gid, len, aup_gids) + char *machname; + int uid; + int gid; + register int len; + int *aup_gids; +{ + struct authunix_parms aup; + char mymem[MAX_AUTH_BYTES]; + struct timeval now; + XDR xdrs; + register AUTH *auth; + register struct audata *au; + + /* + * Allocate and set up auth handle + */ + auth = (AUTH *)mem_alloc(sizeof(*auth)); +#ifndef KERNEL + if (auth == NULL) { + (void)fprintf(stderr, "authunix_create: out of memory\n"); + return (NULL); + } +#endif + au = (struct audata *)mem_alloc(sizeof(*au)); +#ifndef KERNEL + if (au == NULL) { + (void)fprintf(stderr, "authunix_create: out of memory\n"); + return (NULL); + } +#endif + auth->ah_ops = &auth_unix_ops; + auth->ah_private = (caddr_t)au; + auth->ah_verf = au->au_shcred = _null_auth; + au->au_shfaults = 0; + + /* + * fill in param struct from the given params + */ + (void)gettimeofday(&now, (struct timezone *)0); + aup.aup_time = now.tv_sec; + aup.aup_machname = machname; + aup.aup_uid = uid; + aup.aup_gid = gid; + aup.aup_len = (u_int)len; + aup.aup_gids = aup_gids; + + /* + * Serialize the parameters into origcred + */ + xdrmem_create(&xdrs, mymem, MAX_AUTH_BYTES, XDR_ENCODE); + if (! xdr_authunix_parms(&xdrs, &aup)) + abort(); + au->au_origcred.oa_length = len = XDR_GETPOS(&xdrs); + au->au_origcred.oa_flavor = AUTH_UNIX; +#ifdef KERNEL + au->au_origcred.oa_base = mem_alloc((u_int) len); +#else + if ((au->au_origcred.oa_base = mem_alloc((u_int) len)) == NULL) { + (void)fprintf(stderr, "authunix_create: out of memory\n"); + return (NULL); + } +#endif + bcopy(mymem, au->au_origcred.oa_base, (u_int)len); + + /* + * set auth handle to reflect new cred. + */ + auth->ah_cred = au->au_origcred; + marshal_new_auth(auth); + return (auth); +} + +/* + * Returns an auth handle with parameters determined by doing lots of + * syscalls. + */ +AUTH * +authunix_create_default() +{ + register int len; + char machname[MAX_MACHINE_NAME + 1]; + register int uid; + register int gid; + int gids[NGRPS]; + + if (gethostname(machname, MAX_MACHINE_NAME) == -1) + abort(); + machname[MAX_MACHINE_NAME] = 0; + uid = geteuid(); + gid = getegid(); + if ((len = getgroups(NGRPS, gids)) < 0) + abort(); + return (authunix_create(machname, uid, gid, len, gids)); +} + +/* + * authunix operations + */ + +static void +authunix_nextverf(auth) + AUTH *auth; +{ + /* no action necessary */ +} + +static bool_t +authunix_marshal(auth, xdrs) + AUTH *auth; + XDR *xdrs; +{ + register struct audata *au = AUTH_PRIVATE(auth); + + return (XDR_PUTBYTES(xdrs, au->au_marshed, au->au_mpos)); +} + +static bool_t +authunix_validate(auth, verf) + register AUTH *auth; + struct opaque_auth verf; +{ + register struct audata *au; + XDR xdrs; + + if (verf.oa_flavor == AUTH_SHORT) { + au = AUTH_PRIVATE(auth); + xdrmem_create(&xdrs, verf.oa_base, verf.oa_length, XDR_DECODE); + + if (au->au_shcred.oa_base != NULL) { + mem_free(au->au_shcred.oa_base, + au->au_shcred.oa_length); + au->au_shcred.oa_base = NULL; + } + if (xdr_opaque_auth(&xdrs, &au->au_shcred)) { + auth->ah_cred = au->au_shcred; + } else { + xdrs.x_op = XDR_FREE; + (void)xdr_opaque_auth(&xdrs, &au->au_shcred); + au->au_shcred.oa_base = NULL; + auth->ah_cred = au->au_origcred; + } + marshal_new_auth(auth); + } + return (TRUE); +} + +static bool_t +authunix_refresh(auth) + register AUTH *auth; +{ + register struct audata *au = AUTH_PRIVATE(auth); + struct authunix_parms aup; + struct timeval now; + XDR xdrs; + register int stat; + + if (auth->ah_cred.oa_base == au->au_origcred.oa_base) { + /* there is no hope. Punt */ + return (FALSE); + } + au->au_shfaults ++; + + /* first deserialize the creds back into a struct authunix_parms */ + aup.aup_machname = NULL; + aup.aup_gids = (int *)NULL; + xdrmem_create(&xdrs, au->au_origcred.oa_base, + au->au_origcred.oa_length, XDR_DECODE); + stat = xdr_authunix_parms(&xdrs, &aup); + if (! stat) + goto done; + + /* update the time and serialize in place */ + (void)gettimeofday(&now, (struct timezone *)0); + aup.aup_time = now.tv_sec; + xdrs.x_op = XDR_ENCODE; + XDR_SETPOS(&xdrs, 0); + stat = xdr_authunix_parms(&xdrs, &aup); + if (! stat) + goto done; + auth->ah_cred = au->au_origcred; + marshal_new_auth(auth); +done: + /* free the struct authunix_parms created by deserializing */ + xdrs.x_op = XDR_FREE; + (void)xdr_authunix_parms(&xdrs, &aup); + XDR_DESTROY(&xdrs); + return (stat); +} + +static void +authunix_destroy(auth) + register AUTH *auth; +{ + register struct audata *au = AUTH_PRIVATE(auth); + + mem_free(au->au_origcred.oa_base, au->au_origcred.oa_length); + + if (au->au_shcred.oa_base != NULL) + mem_free(au->au_shcred.oa_base, au->au_shcred.oa_length); + + mem_free(auth->ah_private, sizeof(struct audata)); + + if (auth->ah_verf.oa_base != NULL) + mem_free(auth->ah_verf.oa_base, auth->ah_verf.oa_length); + + mem_free((caddr_t)auth, sizeof(*auth)); +} + +/* + * Marshals (pre-serializes) an auth struct. + * sets private data, au_marshed and au_mpos + */ +static bool_t +marshal_new_auth(auth) + register AUTH *auth; +{ + XDR xdr_stream; + register XDR *xdrs = &xdr_stream; + register struct audata *au = AUTH_PRIVATE(auth); + + xdrmem_create(xdrs, au->au_marshed, MAX_AUTH_BYTES, XDR_ENCODE); + if ((! xdr_opaque_auth(xdrs, &(auth->ah_cred))) || + (! xdr_opaque_auth(xdrs, &(auth->ah_verf)))) { + perror("auth_none.c - Fatal marshalling problem"); + } else { + au->au_mpos = XDR_GETPOS(xdrs); + } + XDR_DESTROY(xdrs); +} diff -ruN glibc-1.07/sunrpc/authuxprot.c glibc-1.08.1/sunrpc/authuxprot.c --- glibc-1.07/sunrpc/authuxprot.c +++ glibc-1.08.1/sunrpc/authuxprot.c Sun Feb 6 16:42:41 1994 @@ -0,0 +1,66 @@ +/* @(#)authunix_prot.c 2.1 88/07/29 4.0 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +#if !defined(lint) && defined(SCCSIDS) +static char sccsid[] = "@(#)authunix_prot.c 1.15 87/08/11 Copyr 1984 Sun Micro"; +#endif + +/* + * authunix_prot.c + * XDR for UNIX style authentication parameters for RPC + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + + +#include +#include +#include +#include + +/* + * XDR for unix authentication parameters. + */ +bool_t +xdr_authunix_parms(xdrs, p) + register XDR *xdrs; + register struct authunix_parms *p; +{ + + if (xdr_u_long(xdrs, &(p->aup_time)) + && xdr_string(xdrs, &(p->aup_machname), MAX_MACHINE_NAME) + && xdr_int(xdrs, &(p->aup_uid)) + && xdr_int(xdrs, &(p->aup_gid)) + && xdr_array(xdrs, (caddr_t *)&(p->aup_gids), + &(p->aup_len), NGRPS, sizeof(int), xdr_int) ) { + return (TRUE); + } + return (FALSE); +} + diff -ruN glibc-1.07/sunrpc/bindrsvprt.c glibc-1.08.1/sunrpc/bindrsvprt.c --- glibc-1.07/sunrpc/bindrsvprt.c +++ glibc-1.08.1/sunrpc/bindrsvprt.c Sun Feb 6 16:42:41 1994 @@ -0,0 +1,78 @@ +static char sccsid[] = "@(#)bindresvport.c 2.2 88/07/29 4.0 RPCSRC 1.8 88/02/08 SMI"; +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +/* + * Copyright (c) 1987 by Sun Microsystems, Inc. + */ + +#include +#include +#include +#include + +/* + * Bind a socket to a privileged IP port + */ +bindresvport(sd, sin) + int sd; + struct sockaddr_in *sin; +{ + int res; + static short port; + struct sockaddr_in myaddr; + extern int errno; + int i; + +#define STARTPORT 600 +#define ENDPORT (IPPORT_RESERVED - 1) +#define NPORTS (ENDPORT - STARTPORT + 1) + + if (sin == (struct sockaddr_in *)0) { + sin = &myaddr; + bzero(sin, sizeof (*sin)); + sin->sin_family = AF_INET; + } else if (sin->sin_family != AF_INET) { + errno = EPFNOSUPPORT; + return (-1); + } + if (port == 0) { + port = (getpid() % NPORTS) + STARTPORT; + } + res = -1; + errno = EADDRINUSE; + for (i = 0; i < NPORTS && res < 0 && errno == EADDRINUSE; i++) { + sin->sin_port = htons(port++); + if (port > ENDPORT) { + port = STARTPORT; + } + res = bind(sd, sin, sizeof(struct sockaddr_in)); + } + return (res); +} diff -ruN glibc-1.07/sunrpc/clnt_gen.c glibc-1.08.1/sunrpc/clnt_gen.c --- glibc-1.07/sunrpc/clnt_gen.c +++ glibc-1.08.1/sunrpc/clnt_gen.c Sun Feb 6 16:42:41 1994 @@ -0,0 +1,110 @@ +/* @(#)clnt_generic.c 2.2 88/08/01 4.0 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +#if !defined(lint) && defined(SCCSIDS) +static char sccsid[] = "@(#)clnt_generic.c 1.4 87/08/11 (C) 1987 SMI"; +#endif +/* + * Copyright (C) 1987, Sun Microsystems, Inc. + */ +#include +#include +#include +#include + +/* + * Generic client creation: takes (hostname, program-number, protocol) and + * returns client handle. Default options are set, which the user can + * change using the rpc equivalent of ioctl()'s. + */ +CLIENT * +clnt_create(hostname, prog, vers, proto) + char *hostname; + unsigned prog; + unsigned vers; + char *proto; +{ + struct hostent *h; + struct protoent *p; + struct sockaddr_in sin; + int sock; + struct timeval tv; + CLIENT *client; + + h = gethostbyname(hostname); + if (h == NULL) { + rpc_createerr.cf_stat = RPC_UNKNOWNHOST; + return (NULL); + } + if (h->h_addrtype != AF_INET) { + /* + * Only support INET for now + */ + rpc_createerr.cf_stat = RPC_SYSTEMERROR; + rpc_createerr.cf_error.re_errno = EAFNOSUPPORT; + return (NULL); + } + sin.sin_family = h->h_addrtype; + sin.sin_port = 0; + bzero(sin.sin_zero, sizeof(sin.sin_zero)); + bcopy(h->h_addr, (char*)&sin.sin_addr, h->h_length); + p = getprotobyname(proto); + if (p == NULL) { + rpc_createerr.cf_stat = RPC_UNKNOWNPROTO; + rpc_createerr.cf_error.re_errno = EPFNOSUPPORT; + return (NULL); + } + sock = RPC_ANYSOCK; + switch (p->p_proto) { + case IPPROTO_UDP: + tv.tv_sec = 5; + tv.tv_usec = 0; + client = clntudp_create(&sin, prog, vers, tv, &sock); + if (client == NULL) { + return (NULL); + } + tv.tv_sec = 25; + clnt_control(client, CLSET_TIMEOUT, &tv); + break; + case IPPROTO_TCP: + client = clnttcp_create(&sin, prog, vers, &sock, 0, 0); + if (client == NULL) { + return (NULL); + } + tv.tv_sec = 25; + tv.tv_usec = 0; + clnt_control(client, CLSET_TIMEOUT, &tv); + break; + default: + rpc_createerr.cf_stat = RPC_SYSTEMERROR; + rpc_createerr.cf_error.re_errno = EPFNOSUPPORT; + return (NULL); + } + return (client); +} diff -ruN glibc-1.07/sunrpc/clnt_perr.c glibc-1.08.1/sunrpc/clnt_perr.c --- glibc-1.07/sunrpc/clnt_perr.c +++ glibc-1.08.1/sunrpc/clnt_perr.c Sun Feb 6 17:29:40 1994 @@ -0,0 +1,305 @@ +/* @(#)clnt_perror.c 2.1 88/07/29 4.0 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +#if !defined(lint) && defined(SCCSIDS) +static char sccsid[] = "@(#)clnt_perror.c 1.15 87/10/07 Copyr 1984 Sun Micro"; +#endif + +/* + * clnt_perror.c + * + * Copyright (C) 1984, Sun Microsystems, Inc. + * + */ +#include + +#include +#include +#include + +extern char *sys_errlist[]; +/* extern char *sprintf(); --roland@gnu */ +static char *auth_errmsg(); + +extern char *strcpy(); + +static char *buf; + +static char * +_buf() +{ + + if (buf == 0) + buf = (char *)malloc(256); + return (buf); +} + +/* + * Print reply error info + */ +char * +clnt_sperror(rpch, s) + CLIENT *rpch; + char *s; +{ + struct rpc_err e; + void clnt_perrno(); + char *err; + char *str = _buf(); + char *strstart = str; + + if (str == 0) + return (0); + CLNT_GETERR(rpch, &e); + + (void) sprintf(str, "%s: ", s); + str += strlen(str); + + (void) strcpy(str, clnt_sperrno(e.re_status)); + str += strlen(str); + + switch (e.re_status) { + case RPC_SUCCESS: + case RPC_CANTENCODEARGS: + case RPC_CANTDECODERES: + case RPC_TIMEDOUT: + case RPC_PROGUNAVAIL: + case RPC_PROCUNAVAIL: + case RPC_CANTDECODEARGS: + case RPC_SYSTEMERROR: + case RPC_UNKNOWNHOST: + case RPC_UNKNOWNPROTO: + case RPC_PMAPFAILURE: + case RPC_PROGNOTREGISTERED: + case RPC_FAILED: + break; + + case RPC_CANTSEND: + case RPC_CANTRECV: + (void) sprintf(str, "; errno = %s", + sys_errlist[e.re_errno]); + str += strlen(str); + break; + + case RPC_VERSMISMATCH: + (void) sprintf(str, + "; low version = %lu, high version = %lu", + e.re_vers.low, e.re_vers.high); + str += strlen(str); + break; + + case RPC_AUTHERROR: + err = auth_errmsg(e.re_why); + (void) sprintf(str,"; why = "); + str += strlen(str); + if (err != NULL) { + (void) sprintf(str, "%s",err); + } else { + (void) sprintf(str, + "(unknown authentication error - %d)", + (int) e.re_why); + } + str += strlen(str); + break; + + case RPC_PROGVERSMISMATCH: + (void) sprintf(str, + "; low version = %lu, high version = %lu", + e.re_vers.low, e.re_vers.high); + str += strlen(str); + break; + + default: /* unknown */ + (void) sprintf(str, + "; s1 = %lu, s2 = %lu", + e.re_lb.s1, e.re_lb.s2); + str += strlen(str); + break; + } + (void) sprintf(str, "\n"); + return(strstart) ; +} + +void +clnt_perror(rpch, s) + CLIENT *rpch; + char *s; +{ + (void) fprintf(stderr,"%s",clnt_sperror(rpch,s)); +} + + +struct rpc_errtab { + enum clnt_stat status; + char *message; +}; + +static struct rpc_errtab rpc_errlist[] = { + { RPC_SUCCESS, + "RPC: Success" }, + { RPC_CANTENCODEARGS, + "RPC: Can't encode arguments" }, + { RPC_CANTDECODERES, + "RPC: Can't decode result" }, + { RPC_CANTSEND, + "RPC: Unable to send" }, + { RPC_CANTRECV, + "RPC: Unable to receive" }, + { RPC_TIMEDOUT, + "RPC: Timed out" }, + { RPC_VERSMISMATCH, + "RPC: Incompatible versions of RPC" }, + { RPC_AUTHERROR, + "RPC: Authentication error" }, + { RPC_PROGUNAVAIL, + "RPC: Program unavailable" }, + { RPC_PROGVERSMISMATCH, + "RPC: Program/version mismatch" }, + { RPC_PROCUNAVAIL, + "RPC: Procedure unavailable" }, + { RPC_CANTDECODEARGS, + "RPC: Server can't decode arguments" }, + { RPC_SYSTEMERROR, + "RPC: Remote system error" }, + { RPC_UNKNOWNHOST, + "RPC: Unknown host" }, + { RPC_UNKNOWNPROTO, + "RPC: Unknown protocol" }, + { RPC_PMAPFAILURE, + "RPC: Port mapper failure" }, + { RPC_PROGNOTREGISTERED, + "RPC: Program not registered"}, + { RPC_FAILED, + "RPC: Failed (unspecified error)"} +}; + + +/* + * This interface for use by clntrpc + */ +char * +clnt_sperrno(stat) + enum clnt_stat stat; +{ + int i; + + for (i = 0; i < sizeof(rpc_errlist)/sizeof(struct rpc_errtab); i++) { + if (rpc_errlist[i].status == stat) { + return (rpc_errlist[i].message); + } + } + return ("RPC: (unknown error code)"); +} + +void +clnt_perrno(num) + enum clnt_stat num; +{ + (void) fprintf(stderr,"%s",clnt_sperrno(num)); +} + + +char * +clnt_spcreateerror(s) + char *s; +{ + extern int sys_nerr; + extern char *sys_errlist[]; + char *str = _buf(); + + if (str == 0) + return(0); + (void) sprintf(str, "%s: ", s); + (void) strcat(str, clnt_sperrno(rpc_createerr.cf_stat)); + switch (rpc_createerr.cf_stat) { + case RPC_PMAPFAILURE: + (void) strcat(str, " - "); + (void) strcat(str, + clnt_sperrno(rpc_createerr.cf_error.re_status)); + break; + + case RPC_SYSTEMERROR: + (void) strcat(str, " - "); + if (rpc_createerr.cf_error.re_errno > 0 + && rpc_createerr.cf_error.re_errno < sys_nerr) + (void) strcat(str, + sys_errlist[rpc_createerr.cf_error.re_errno]); + else + (void) sprintf(&str[strlen(str)], "Error %d", + rpc_createerr.cf_error.re_errno); + break; + } + (void) strcat(str, "\n"); + return (str); +} + +void +clnt_pcreateerror(s) + char *s; +{ + (void) fprintf(stderr,"%s",clnt_spcreateerror(s)); +} + +struct auth_errtab { + enum auth_stat status; + char *message; +}; + +static struct auth_errtab auth_errlist[] = { + { AUTH_OK, + "Authentication OK" }, + { AUTH_BADCRED, + "Invalid client credential" }, + { AUTH_REJECTEDCRED, + "Server rejected credential" }, + { AUTH_BADVERF, + "Invalid client verifier" }, + { AUTH_REJECTEDVERF, + "Server rejected verifier" }, + { AUTH_TOOWEAK, + "Client credential too weak" }, + { AUTH_INVALIDRESP, + "Invalid server verifier" }, + { AUTH_FAILED, + "Failed (unspecified error)" }, +}; + +static char * +auth_errmsg(stat) + enum auth_stat stat; +{ + int i; + + for (i = 0; i < sizeof(auth_errlist)/sizeof(struct auth_errtab); i++) { + if (auth_errlist[i].status == stat) { + return(auth_errlist[i].message); + } + } + return(NULL); +} diff -ruN glibc-1.07/sunrpc/clnt_raw.c glibc-1.08.1/sunrpc/clnt_raw.c --- glibc-1.07/sunrpc/clnt_raw.c +++ glibc-1.08.1/sunrpc/clnt_raw.c Sun Feb 6 16:42:42 1994 @@ -0,0 +1,238 @@ +/* @(#)clnt_raw.c 2.2 88/08/01 4.0 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +#if !defined(lint) && defined(SCCSIDS) +static char sccsid[] = "@(#)clnt_raw.c 1.22 87/08/11 Copyr 1984 Sun Micro"; +#endif + +/* + * clnt_raw.c + * + * Copyright (C) 1984, Sun Microsystems, Inc. + * + * Memory based rpc for simple testing and timing. + * Interface to create an rpc client and server in the same process. + * This lets us similate rpc and get round trip overhead, without + * any interference from the kernal. + */ + +#include + +#define MCALL_MSG_SIZE 24 + +/* + * This is the "network" we will be moving stuff over. + */ +static struct clntraw_private { + CLIENT client_object; + XDR xdr_stream; + char _raw_buf[UDPMSGSIZE]; + char mashl_callmsg[MCALL_MSG_SIZE]; + u_int mcnt; +} *clntraw_private; + +static enum clnt_stat clntraw_call(); +static void clntraw_abort(); +static void clntraw_geterr(); +static bool_t clntraw_freeres(); +static bool_t clntraw_control(); +static void clntraw_destroy(); + +static struct clnt_ops client_ops = { + clntraw_call, + clntraw_abort, + clntraw_geterr, + clntraw_freeres, + clntraw_destroy, + clntraw_control +}; + +void svc_getreq(); + +/* + * Create a client handle for memory based rpc. + */ +CLIENT * +clntraw_create(prog, vers) + u_long prog; + u_long vers; +{ + register struct clntraw_private *clp = clntraw_private; + struct rpc_msg call_msg; + XDR *xdrs = &clp->xdr_stream; + CLIENT *client = &clp->client_object; + + if (clp == 0) { + clp = (struct clntraw_private *)calloc(1, sizeof (*clp)); + if (clp == 0) + return (0); + clntraw_private = clp; + } + /* + * pre-serialize the staic part of the call msg and stash it away + */ + call_msg.rm_direction = CALL; + call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION; + call_msg.rm_call.cb_prog = prog; + call_msg.rm_call.cb_vers = vers; + xdrmem_create(xdrs, clp->mashl_callmsg, MCALL_MSG_SIZE, XDR_ENCODE); + if (! xdr_callhdr(xdrs, &call_msg)) { + perror("clnt_raw.c - Fatal header serialization error."); + } + clp->mcnt = XDR_GETPOS(xdrs); + XDR_DESTROY(xdrs); + + /* + * Set xdrmem for client/server shared buffer + */ + xdrmem_create(xdrs, clp->_raw_buf, UDPMSGSIZE, XDR_FREE); + + /* + * create client handle + */ + client->cl_ops = &client_ops; + client->cl_auth = authnone_create(); + return (client); +} + +static enum clnt_stat +clntraw_call(h, proc, xargs, argsp, xresults, resultsp, timeout) + CLIENT *h; + u_long proc; + xdrproc_t xargs; + caddr_t argsp; + xdrproc_t xresults; + caddr_t resultsp; + struct timeval timeout; +{ + register struct clntraw_private *clp = clntraw_private; + register XDR *xdrs = &clp->xdr_stream; + struct rpc_msg msg; + enum clnt_stat status; + struct rpc_err error; + + if (clp == 0) + return (RPC_FAILED); +call_again: + /* + * send request + */ + xdrs->x_op = XDR_ENCODE; + XDR_SETPOS(xdrs, 0); + ((struct rpc_msg *)clp->mashl_callmsg)->rm_xid ++ ; + if ((! XDR_PUTBYTES(xdrs, clp->mashl_callmsg, clp->mcnt)) || + (! XDR_PUTLONG(xdrs, (long *)&proc)) || + (! AUTH_MARSHALL(h->cl_auth, xdrs)) || + (! (*xargs)(xdrs, argsp))) { + return (RPC_CANTENCODEARGS); + } + (void)XDR_GETPOS(xdrs); /* called just to cause overhead */ + + /* + * We have to call server input routine here because this is + * all going on in one process. Yuk. + */ + svc_getreq(1); + + /* + * get results + */ + xdrs->x_op = XDR_DECODE; + XDR_SETPOS(xdrs, 0); + msg.acpted_rply.ar_verf = _null_auth; + msg.acpted_rply.ar_results.where = resultsp; + msg.acpted_rply.ar_results.proc = xresults; + if (! xdr_replymsg(xdrs, &msg)) + return (RPC_CANTDECODERES); + _seterr_reply(&msg, &error); + status = error.re_status; + + if (status == RPC_SUCCESS) { + if (! AUTH_VALIDATE(h->cl_auth, &msg.acpted_rply.ar_verf)) { + status = RPC_AUTHERROR; + } + } /* end successful completion */ + else { + if (AUTH_REFRESH(h->cl_auth)) + goto call_again; + } /* end of unsuccessful completion */ + + if (status == RPC_SUCCESS) { + if (! AUTH_VALIDATE(h->cl_auth, &msg.acpted_rply.ar_verf)) { + status = RPC_AUTHERROR; + } + if (msg.acpted_rply.ar_verf.oa_base != NULL) { + xdrs->x_op = XDR_FREE; + (void)xdr_opaque_auth(xdrs, &(msg.acpted_rply.ar_verf)); + } + } + + return (status); +} + +static void +clntraw_geterr() +{ +} + + +static bool_t +clntraw_freeres(cl, xdr_res, res_ptr) + CLIENT *cl; + xdrproc_t xdr_res; + caddr_t res_ptr; +{ + register struct clntraw_private *clp = clntraw_private; + register XDR *xdrs = &clp->xdr_stream; + bool_t rval; + + if (clp == 0) + { + rval = (bool_t) RPC_FAILED; + return (rval); + } + xdrs->x_op = XDR_FREE; + return ((*xdr_res)(xdrs, res_ptr)); +} + +static void +clntraw_abort() +{ +} + +static bool_t +clntraw_control() +{ + return (FALSE); +} + +static void +clntraw_destroy() +{ +} diff -ruN glibc-1.07/sunrpc/clnt_simp.c glibc-1.08.1/sunrpc/clnt_simp.c --- glibc-1.07/sunrpc/clnt_simp.c +++ glibc-1.08.1/sunrpc/clnt_simp.c Sun Feb 6 16:42:42 1994 @@ -0,0 +1,112 @@ +/* @(#)clnt_simple.c 2.2 88/08/01 4.0 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +#if !defined(lint) && defined(SCCSIDS) +static char sccsid[] = "@(#)clnt_simple.c 1.35 87/08/11 Copyr 1984 Sun Micro"; +#endif + +/* + * clnt_simple.c + * Simplified front end to rpc. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#include +#include +#include +#include +#include + +static struct callrpc_private { + CLIENT *client; + int socket; + int oldprognum, oldversnum, valid; + char *oldhost; +} *callrpc_private; + +callrpc(host, prognum, versnum, procnum, inproc, in, outproc, out) + char *host; + xdrproc_t inproc, outproc; + char *in, *out; +{ + register struct callrpc_private *crp = callrpc_private; + struct sockaddr_in server_addr; + enum clnt_stat clnt_stat; + struct hostent *hp; + struct timeval timeout, tottimeout; + + if (crp == 0) { + crp = (struct callrpc_private *)calloc(1, sizeof (*crp)); + if (crp == 0) + return (0); + callrpc_private = crp; + } + if (crp->oldhost == NULL) { + crp->oldhost = malloc(256); + crp->oldhost[0] = 0; + crp->socket = RPC_ANYSOCK; + } + if (crp->valid && crp->oldprognum == prognum && crp->oldversnum == versnum + && strcmp(crp->oldhost, host) == 0) { + /* reuse old client */ + } else { + crp->valid = 0; + (void)close(crp->socket); + crp->socket = RPC_ANYSOCK; + if (crp->client) { + clnt_destroy(crp->client); + crp->client = NULL; + } + if ((hp = gethostbyname(host)) == NULL) + return ((int) RPC_UNKNOWNHOST); + timeout.tv_usec = 0; + timeout.tv_sec = 5; + bcopy(hp->h_addr, (char *)&server_addr.sin_addr, hp->h_length); + server_addr.sin_family = AF_INET; + server_addr.sin_port = 0; + if ((crp->client = clntudp_create(&server_addr, (u_long)prognum, + (u_long)versnum, timeout, &crp->socket)) == NULL) + return ((int) rpc_createerr.cf_stat); + crp->valid = 1; + crp->oldprognum = prognum; + crp->oldversnum = versnum; + (void) strcpy(crp->oldhost, host); + } + tottimeout.tv_sec = 25; + tottimeout.tv_usec = 0; + clnt_stat = clnt_call(crp->client, procnum, inproc, in, + outproc, out, tottimeout); + /* + * if call failed, empty cache + */ + if (clnt_stat != RPC_SUCCESS) + crp->valid = 0; + return ((int) clnt_stat); +} diff -ruN glibc-1.07/sunrpc/clnt_tcp.c glibc-1.08.1/sunrpc/clnt_tcp.c --- glibc-1.07/sunrpc/clnt_tcp.c +++ glibc-1.08.1/sunrpc/clnt_tcp.c Sun Feb 6 16:42:42 1994 @@ -0,0 +1,466 @@ +/* @(#)clnt_tcp.c 2.2 88/08/01 4.0 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +#if !defined(lint) && defined(SCCSIDS) +static char sccsid[] = "@(#)clnt_tcp.c 1.37 87/10/05 Copyr 1984 Sun Micro"; +#endif + +/* + * clnt_tcp.c, Implements a TCP/IP based, client side RPC. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + * + * TCP based RPC supports 'batched calls'. + * A sequence of calls may be batched-up in a send buffer. The rpc call + * return immediately to the client even though the call was not necessarily + * sent. The batching occurs if the results' xdr routine is NULL (0) AND + * the rpc timeout value is zero (see clnt.h, rpc). + * + * Clients should NOT casually batch calls that in fact return results; that is, + * the server side should be aware that a call is batched and not produce any + * return message. Batched calls that produce many result messages can + * deadlock (netlock) the client and the server.... + * + * Now go hang yourself. + */ + +#include +#include +#include +#include +#include +#include + +#define MCALL_MSG_SIZE 24 + +extern int errno; + +static int readtcp(); +static int writetcp(); + +static enum clnt_stat clnttcp_call(); +static void clnttcp_abort(); +static void clnttcp_geterr(); +static bool_t clnttcp_freeres(); +static bool_t clnttcp_control(); +static void clnttcp_destroy(); + +static struct clnt_ops tcp_ops = { + clnttcp_call, + clnttcp_abort, + clnttcp_geterr, + clnttcp_freeres, + clnttcp_destroy, + clnttcp_control +}; + +struct ct_data { + int ct_sock; + bool_t ct_closeit; + struct timeval ct_wait; + bool_t ct_waitset; /* wait set by clnt_control? */ + struct sockaddr_in ct_addr; + struct rpc_err ct_error; + char ct_mcall[MCALL_MSG_SIZE]; /* marshalled callmsg */ + u_int ct_mpos; /* pos after marshal */ + XDR ct_xdrs; +}; + +/* + * Create a client handle for a tcp/ip connection. + * If *sockp<0, *sockp is set to a newly created TCP socket and it is + * connected to raddr. If *sockp non-negative then + * raddr is ignored. The rpc/tcp package does buffering + * similar to stdio, so the client must pick send and receive buffer sizes,]; + * 0 => use the default. + * If raddr->sin_port is 0, then a binder on the remote machine is + * consulted for the right port number. + * NB: *sockp is copied into a private area. + * NB: It is the clients responsibility to close *sockp. + * NB: The rpch->cl_auth is set null authentication. Caller may wish to set this + * something more useful. + */ +CLIENT * +clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz) + struct sockaddr_in *raddr; + u_long prog; + u_long vers; + register int *sockp; + u_int sendsz; + u_int recvsz; +{ + CLIENT *h; + register struct ct_data *ct; + struct timeval now; + struct rpc_msg call_msg; + + h = (CLIENT *)mem_alloc(sizeof(*h)); + if (h == NULL) { + (void)fprintf(stderr, "clnttcp_create: out of memory\n"); + rpc_createerr.cf_stat = RPC_SYSTEMERROR; + rpc_createerr.cf_error.re_errno = errno; + goto fooy; + } + ct = (struct ct_data *)mem_alloc(sizeof(*ct)); + if (ct == NULL) { + (void)fprintf(stderr, "clnttcp_create: out of memory\n"); + rpc_createerr.cf_stat = RPC_SYSTEMERROR; + rpc_createerr.cf_error.re_errno = errno; + goto fooy; + } + + /* + * If no port number given ask the pmap for one + */ + if (raddr->sin_port == 0) { + u_short port; + if ((port = pmap_getport(raddr, prog, vers, IPPROTO_TCP)) == 0) { + mem_free((caddr_t)ct, sizeof(struct ct_data)); + mem_free((caddr_t)h, sizeof(CLIENT)); + return ((CLIENT *)NULL); + } + raddr->sin_port = htons(port); + } + + /* + * If no socket given, open one + */ + if (*sockp < 0) { + *sockp = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + (void)bindresvport(*sockp, (struct sockaddr_in *)0); + if ((*sockp < 0) + || (connect(*sockp, (struct sockaddr *)raddr, + sizeof(*raddr)) < 0)) { + rpc_createerr.cf_stat = RPC_SYSTEMERROR; + rpc_createerr.cf_error.re_errno = errno; + (void)close(*sockp); + goto fooy; + } + ct->ct_closeit = TRUE; + } else { + ct->ct_closeit = FALSE; + } + + /* + * Set up private data struct + */ + ct->ct_sock = *sockp; + ct->ct_wait.tv_usec = 0; + ct->ct_waitset = FALSE; + ct->ct_addr = *raddr; + + /* + * Initialize call message + */ + (void)gettimeofday(&now, (struct timezone *)0); + call_msg.rm_xid = getpid() ^ now.tv_sec ^ now.tv_usec; + call_msg.rm_direction = CALL; + call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION; + call_msg.rm_call.cb_prog = prog; + call_msg.rm_call.cb_vers = vers; + + /* + * pre-serialize the staic part of the call msg and stash it away + */ + xdrmem_create(&(ct->ct_xdrs), ct->ct_mcall, MCALL_MSG_SIZE, + XDR_ENCODE); + if (! xdr_callhdr(&(ct->ct_xdrs), &call_msg)) { + if (ct->ct_closeit) { + (void)close(*sockp); + } + goto fooy; + } + ct->ct_mpos = XDR_GETPOS(&(ct->ct_xdrs)); + XDR_DESTROY(&(ct->ct_xdrs)); + + /* + * Create a client handle which uses xdrrec for serialization + * and authnone for authentication. + */ + xdrrec_create(&(ct->ct_xdrs), sendsz, recvsz, + (caddr_t)ct, readtcp, writetcp); + h->cl_ops = &tcp_ops; + h->cl_private = (caddr_t) ct; + h->cl_auth = authnone_create(); + return (h); + +fooy: + /* + * Something goofed, free stuff and barf + */ + mem_free((caddr_t)ct, sizeof(struct ct_data)); + mem_free((caddr_t)h, sizeof(CLIENT)); + return ((CLIENT *)NULL); +} + +static enum clnt_stat +clnttcp_call(h, proc, xdr_args, args_ptr, xdr_results, results_ptr, timeout) + register CLIENT *h; + u_long proc; + xdrproc_t xdr_args; + caddr_t args_ptr; + xdrproc_t xdr_results; + caddr_t results_ptr; + struct timeval timeout; +{ + register struct ct_data *ct = (struct ct_data *) h->cl_private; + register XDR *xdrs = &(ct->ct_xdrs); + struct rpc_msg reply_msg; + u_long x_id; + u_long *msg_x_id = (u_long *)(ct->ct_mcall); /* yuk */ + register bool_t shipnow; + int refreshes = 2; + + if (!ct->ct_waitset) { + ct->ct_wait = timeout; + } + + shipnow = + (xdr_results == (xdrproc_t)0 && timeout.tv_sec == 0 + && timeout.tv_usec == 0) ? FALSE : TRUE; + +call_again: + xdrs->x_op = XDR_ENCODE; + ct->ct_error.re_status = RPC_SUCCESS; + x_id = ntohl(--(*msg_x_id)); + if ((! XDR_PUTBYTES(xdrs, ct->ct_mcall, ct->ct_mpos)) || + (! XDR_PUTLONG(xdrs, (long *)&proc)) || + (! AUTH_MARSHALL(h->cl_auth, xdrs)) || + (! (*xdr_args)(xdrs, args_ptr))) { + if (ct->ct_error.re_status == RPC_SUCCESS) + ct->ct_error.re_status = RPC_CANTENCODEARGS; + (void)xdrrec_endofrecord(xdrs, TRUE); + return (ct->ct_error.re_status); + } + if (! xdrrec_endofrecord(xdrs, shipnow)) + return (ct->ct_error.re_status = RPC_CANTSEND); + if (! shipnow) + return (RPC_SUCCESS); + /* + * Hack to provide rpc-based message passing + */ + if (timeout.tv_sec == 0 && timeout.tv_usec == 0) { + return(ct->ct_error.re_status = RPC_TIMEDOUT); + } + + + /* + * Keep receiving until we get a valid transaction id + */ + xdrs->x_op = XDR_DECODE; + while (TRUE) { + reply_msg.acpted_rply.ar_verf = _null_auth; + reply_msg.acpted_rply.ar_results.where = NULL; + reply_msg.acpted_rply.ar_results.proc = xdr_void; + if (! xdrrec_skiprecord(xdrs)) + return (ct->ct_error.re_status); + /* now decode and validate the response header */ + if (! xdr_replymsg(xdrs, &reply_msg)) { + if (ct->ct_error.re_status == RPC_SUCCESS) + continue; + return (ct->ct_error.re_status); + } + if (reply_msg.rm_xid == x_id) + break; + } + + /* + * process header + */ + _seterr_reply(&reply_msg, &(ct->ct_error)); + if (ct->ct_error.re_status == RPC_SUCCESS) { + if (! AUTH_VALIDATE(h->cl_auth, &reply_msg.acpted_rply.ar_verf)) { + ct->ct_error.re_status = RPC_AUTHERROR; + ct->ct_error.re_why = AUTH_INVALIDRESP; + } else if (! (*xdr_results)(xdrs, results_ptr)) { + if (ct->ct_error.re_status == RPC_SUCCESS) + ct->ct_error.re_status = RPC_CANTDECODERES; + } + /* free verifier ... */ + if (reply_msg.acpted_rply.ar_verf.oa_base != NULL) { + xdrs->x_op = XDR_FREE; + (void)xdr_opaque_auth(xdrs, &(reply_msg.acpted_rply.ar_verf)); + } + } /* end successful completion */ + else { + /* maybe our credentials need to be refreshed ... */ + if (refreshes-- && AUTH_REFRESH(h->cl_auth)) + goto call_again; + } /* end of unsuccessful completion */ + return (ct->ct_error.re_status); +} + +static void +clnttcp_geterr(h, errp) + CLIENT *h; + struct rpc_err *errp; +{ + register struct ct_data *ct = + (struct ct_data *) h->cl_private; + + *errp = ct->ct_error; +} + +static bool_t +clnttcp_freeres(cl, xdr_res, res_ptr) + CLIENT *cl; + xdrproc_t xdr_res; + caddr_t res_ptr; +{ + register struct ct_data *ct = (struct ct_data *)cl->cl_private; + register XDR *xdrs = &(ct->ct_xdrs); + + xdrs->x_op = XDR_FREE; + return ((*xdr_res)(xdrs, res_ptr)); +} + +static void +clnttcp_abort() +{ +} + +static bool_t +clnttcp_control(cl, request, info) + CLIENT *cl; + int request; + char *info; +{ + register struct ct_data *ct = (struct ct_data *)cl->cl_private; + + switch (request) { + case CLSET_TIMEOUT: + ct->ct_wait = *(struct timeval *)info; + ct->ct_waitset = TRUE; + break; + case CLGET_TIMEOUT: + *(struct timeval *)info = ct->ct_wait; + break; + case CLGET_SERVER_ADDR: + *(struct sockaddr_in *)info = ct->ct_addr; + break; + default: + return (FALSE); + } + return (TRUE); +} + + +static void +clnttcp_destroy(h) + CLIENT *h; +{ + register struct ct_data *ct = + (struct ct_data *) h->cl_private; + + if (ct->ct_closeit) { + (void)close(ct->ct_sock); + } + XDR_DESTROY(&(ct->ct_xdrs)); + mem_free((caddr_t)ct, sizeof(struct ct_data)); + mem_free((caddr_t)h, sizeof(CLIENT)); +} + +/* + * Interface between xdr serializer and tcp connection. + * Behaves like the system calls, read & write, but keeps some error state + * around for the rpc level. + */ +static int +readtcp(ct, buf, len) + register struct ct_data *ct; + caddr_t buf; + register int len; +{ +#ifdef FD_SETSIZE + fd_set mask; + fd_set readfds; + + if (len == 0) + return (0); + FD_ZERO(&mask); + FD_SET(ct->ct_sock, &mask); +#else + register int mask = 1 << (ct->ct_sock); + int readfds; + + if (len == 0) + return (0); + +#endif /* def FD_SETSIZE */ + while (TRUE) { + readfds = mask; + switch (select(_rpc_dtablesize(), &readfds, (int*)NULL, (int*)NULL, + &(ct->ct_wait))) { + case 0: + ct->ct_error.re_status = RPC_TIMEDOUT; + return (-1); + + case -1: + if (errno == EINTR) + continue; + ct->ct_error.re_status = RPC_CANTRECV; + ct->ct_error.re_errno = errno; + return (-1); + } + break; + } + switch (len = read(ct->ct_sock, buf, len)) { + + case 0: + /* premature eof */ + ct->ct_error.re_errno = ECONNRESET; + ct->ct_error.re_status = RPC_CANTRECV; + len = -1; /* it's really an error */ + break; + + case -1: + ct->ct_error.re_errno = errno; + ct->ct_error.re_status = RPC_CANTRECV; + break; + } + return (len); +} + +static int +writetcp(ct, buf, len) + struct ct_data *ct; + caddr_t buf; + int len; +{ + register int i, cnt; + + for (cnt = len; cnt > 0; cnt -= i, buf += i) { + if ((i = write(ct->ct_sock, buf, cnt)) == -1) { + ct->ct_error.re_errno = errno; + ct->ct_error.re_status = RPC_CANTSEND; + return (-1); + } + } + return (len); +} diff -ruN glibc-1.07/sunrpc/clnt_udp.c glibc-1.08.1/sunrpc/clnt_udp.c --- glibc-1.07/sunrpc/clnt_udp.c +++ glibc-1.08.1/sunrpc/clnt_udp.c Sun Feb 6 16:42:42 1994 @@ -0,0 +1,442 @@ +/* @(#)clnt_udp.c 2.2 88/08/01 4.0 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +#if !defined(lint) && defined(SCCSIDS) +static char sccsid[] = "@(#)clnt_udp.c 1.39 87/08/11 Copyr 1984 Sun Micro"; +#endif + +/* + * clnt_udp.c, Implements a UDP/IP based, client side RPC. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#include +#include +#include +#include +#include +#include +#include + +extern int errno; + +/* + * UDP bases client side rpc operations + */ +static enum clnt_stat clntudp_call(); +static void clntudp_abort(); +static void clntudp_geterr(); +static bool_t clntudp_freeres(); +static bool_t clntudp_control(); +static void clntudp_destroy(); + +static struct clnt_ops udp_ops = { + clntudp_call, + clntudp_abort, + clntudp_geterr, + clntudp_freeres, + clntudp_destroy, + clntudp_control +}; + +/* + * Private data kept per client handle + */ +struct cu_data { + int cu_sock; + bool_t cu_closeit; + struct sockaddr_in cu_raddr; + int cu_rlen; + struct timeval cu_wait; + struct timeval cu_total; + struct rpc_err cu_error; + XDR cu_outxdrs; + u_int cu_xdrpos; + u_int cu_sendsz; + char *cu_outbuf; + u_int cu_recvsz; + char cu_inbuf[1]; +}; + +/* + * Create a UDP based client handle. + * If *sockp<0, *sockp is set to a newly created UPD socket. + * If raddr->sin_port is 0 a binder on the remote machine + * is consulted for the correct port number. + * NB: It is the clients responsibility to close *sockp. + * NB: The rpch->cl_auth is initialized to null authentication. + * Caller may wish to set this something more useful. + * + * wait is the amount of time used between retransmitting a call if + * no response has been heard; retransmition occurs until the actual + * rpc call times out. + * + * sendsz and recvsz are the maximum allowable packet sizes that can be + * sent and received. + */ +CLIENT * +clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz) + struct sockaddr_in *raddr; + u_long program; + u_long version; + struct timeval wait; + register int *sockp; + u_int sendsz; + u_int recvsz; +{ + CLIENT *cl; + register struct cu_data *cu; + struct timeval now; + struct rpc_msg call_msg; + + cl = (CLIENT *)mem_alloc(sizeof(CLIENT)); + if (cl == NULL) { + (void) fprintf(stderr, "clntudp_create: out of memory\n"); + rpc_createerr.cf_stat = RPC_SYSTEMERROR; + rpc_createerr.cf_error.re_errno = errno; + goto fooy; + } + sendsz = ((sendsz + 3) / 4) * 4; + recvsz = ((recvsz + 3) / 4) * 4; + cu = (struct cu_data *)mem_alloc(sizeof(*cu) + sendsz + recvsz); + if (cu == NULL) { + (void) fprintf(stderr, "clntudp_create: out of memory\n"); + rpc_createerr.cf_stat = RPC_SYSTEMERROR; + rpc_createerr.cf_error.re_errno = errno; + goto fooy; + } + cu->cu_outbuf = &cu->cu_inbuf[recvsz]; + + (void)gettimeofday(&now, (struct timezone *)0); + if (raddr->sin_port == 0) { + u_short port; + if ((port = + pmap_getport(raddr, program, version, IPPROTO_UDP)) == 0) { + goto fooy; + } + raddr->sin_port = htons(port); + } + cl->cl_ops = &udp_ops; + cl->cl_private = (caddr_t)cu; + cu->cu_raddr = *raddr; + cu->cu_rlen = sizeof (cu->cu_raddr); + cu->cu_wait = wait; + cu->cu_total.tv_sec = -1; + cu->cu_total.tv_usec = -1; + cu->cu_sendsz = sendsz; + cu->cu_recvsz = recvsz; + call_msg.rm_xid = getpid() ^ now.tv_sec ^ now.tv_usec; + call_msg.rm_direction = CALL; + call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION; + call_msg.rm_call.cb_prog = program; + call_msg.rm_call.cb_vers = version; + xdrmem_create(&(cu->cu_outxdrs), cu->cu_outbuf, + sendsz, XDR_ENCODE); + if (! xdr_callhdr(&(cu->cu_outxdrs), &call_msg)) { + goto fooy; + } + cu->cu_xdrpos = XDR_GETPOS(&(cu->cu_outxdrs)); + if (*sockp < 0) { + int dontblock = 1; + + *sockp = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); + if (*sockp < 0) { + rpc_createerr.cf_stat = RPC_SYSTEMERROR; + rpc_createerr.cf_error.re_errno = errno; + goto fooy; + } + /* attempt to bind to prov port */ + (void)bindresvport(*sockp, (struct sockaddr_in *)0); + /* the sockets rpc controls are non-blocking */ + (void)ioctl(*sockp, FIONBIO, (char *) &dontblock); + cu->cu_closeit = TRUE; + } else { + cu->cu_closeit = FALSE; + } + cu->cu_sock = *sockp; + cl->cl_auth = authnone_create(); + return (cl); +fooy: + if (cu) + mem_free((caddr_t)cu, sizeof(*cu) + sendsz + recvsz); + if (cl) + mem_free((caddr_t)cl, sizeof(CLIENT)); + return ((CLIENT *)NULL); +} + +CLIENT * +clntudp_create(raddr, program, version, wait, sockp) + struct sockaddr_in *raddr; + u_long program; + u_long version; + struct timeval wait; + register int *sockp; +{ + + return(clntudp_bufcreate(raddr, program, version, wait, sockp, + UDPMSGSIZE, UDPMSGSIZE)); +} + +static enum clnt_stat +clntudp_call(cl, proc, xargs, argsp, xresults, resultsp, utimeout) + register CLIENT *cl; /* client handle */ + u_long proc; /* procedure number */ + xdrproc_t xargs; /* xdr routine for args */ + caddr_t argsp; /* pointer to args */ + xdrproc_t xresults; /* xdr routine for results */ + caddr_t resultsp; /* pointer to results */ + struct timeval utimeout; /* seconds to wait before giving up */ +{ + register struct cu_data *cu = (struct cu_data *)cl->cl_private; + register XDR *xdrs; + register int outlen; + register int inlen; + int fromlen; +#ifdef FD_SETSIZE + fd_set readfds; + fd_set mask; +#else + int readfds; + register int mask; +#endif /* def FD_SETSIZE */ + struct sockaddr_in from; + struct rpc_msg reply_msg; + XDR reply_xdrs; + struct timeval time_waited; + bool_t ok; + int nrefreshes = 2; /* number of times to refresh cred */ + struct timeval timeout; + + if (cu->cu_total.tv_usec == -1) { + timeout = utimeout; /* use supplied timeout */ + } else { + timeout = cu->cu_total; /* use default timeout */ + } + + time_waited.tv_sec = 0; + time_waited.tv_usec = 0; +call_again: + xdrs = &(cu->cu_outxdrs); + xdrs->x_op = XDR_ENCODE; + XDR_SETPOS(xdrs, cu->cu_xdrpos); + /* + * the transaction is the first thing in the out buffer + */ + (*(u_short *)(cu->cu_outbuf))++; + if ((! XDR_PUTLONG(xdrs, (long *)&proc)) || + (! AUTH_MARSHALL(cl->cl_auth, xdrs)) || + (! (*xargs)(xdrs, argsp))) + return (cu->cu_error.re_status = RPC_CANTENCODEARGS); + outlen = (int)XDR_GETPOS(xdrs); + +send_again: + if (sendto(cu->cu_sock, cu->cu_outbuf, outlen, 0, + (struct sockaddr *)&(cu->cu_raddr), cu->cu_rlen) + != outlen) { + cu->cu_error.re_errno = errno; + return (cu->cu_error.re_status = RPC_CANTSEND); + } + + /* + * Hack to provide rpc-based message passing + */ + if (timeout.tv_sec == 0 && timeout.tv_usec == 0) { + return (cu->cu_error.re_status = RPC_TIMEDOUT); + } + /* + * sub-optimal code appears here because we have + * some clock time to spare while the packets are in flight. + * (We assume that this is actually only executed once.) + */ + reply_msg.acpted_rply.ar_verf = _null_auth; + reply_msg.acpted_rply.ar_results.where = resultsp; + reply_msg.acpted_rply.ar_results.proc = xresults; +#ifdef FD_SETSIZE + FD_ZERO(&mask); + FD_SET(cu->cu_sock, &mask); +#else + mask = 1 << cu->cu_sock; +#endif /* def FD_SETSIZE */ + for (;;) { + readfds = mask; + switch (select(_rpc_dtablesize(), &readfds, (int *)NULL, + (int *)NULL, &(cu->cu_wait))) { + + case 0: + time_waited.tv_sec += cu->cu_wait.tv_sec; + time_waited.tv_usec += cu->cu_wait.tv_usec; + while (time_waited.tv_usec >= 1000000) { + time_waited.tv_sec++; + time_waited.tv_usec -= 1000000; + } + if ((time_waited.tv_sec < timeout.tv_sec) || + ((time_waited.tv_sec == timeout.tv_sec) && + (time_waited.tv_usec < timeout.tv_usec))) + goto send_again; + return (cu->cu_error.re_status = RPC_TIMEDOUT); + + /* + * buggy in other cases because time_waited is not being + * updated. + */ + case -1: + if (errno == EINTR) + continue; + cu->cu_error.re_errno = errno; + return (cu->cu_error.re_status = RPC_CANTRECV); + } + do { + fromlen = sizeof(struct sockaddr); + inlen = recvfrom(cu->cu_sock, cu->cu_inbuf, + (int) cu->cu_recvsz, 0, + (struct sockaddr *)&from, &fromlen); + } while (inlen < 0 && errno == EINTR); + if (inlen < 0) { + if (errno == EWOULDBLOCK) + continue; + cu->cu_error.re_errno = errno; + return (cu->cu_error.re_status = RPC_CANTRECV); + } + if (inlen < sizeof(u_long)) + continue; + /* see if reply transaction id matches sent id */ + if (*((u_long *)(cu->cu_inbuf)) != *((u_long *)(cu->cu_outbuf))) + continue; + /* we now assume we have the proper reply */ + break; + } + + /* + * now decode and validate the response + */ + xdrmem_create(&reply_xdrs, cu->cu_inbuf, (u_int)inlen, XDR_DECODE); + ok = xdr_replymsg(&reply_xdrs, &reply_msg); + /* XDR_DESTROY(&reply_xdrs); save a few cycles on noop destroy */ + if (ok) { + _seterr_reply(&reply_msg, &(cu->cu_error)); + if (cu->cu_error.re_status == RPC_SUCCESS) { + if (! AUTH_VALIDATE(cl->cl_auth, + &reply_msg.acpted_rply.ar_verf)) { + cu->cu_error.re_status = RPC_AUTHERROR; + cu->cu_error.re_why = AUTH_INVALIDRESP; + } + if (reply_msg.acpted_rply.ar_verf.oa_base != NULL) { + xdrs->x_op = XDR_FREE; + (void)xdr_opaque_auth(xdrs, + &(reply_msg.acpted_rply.ar_verf)); + } + } /* end successful completion */ + else { + /* maybe our credentials need to be refreshed ... */ + if (nrefreshes > 0 && AUTH_REFRESH(cl->cl_auth)) { + nrefreshes--; + goto call_again; + } + } /* end of unsuccessful completion */ + } /* end of valid reply message */ + else { + cu->cu_error.re_status = RPC_CANTDECODERES; + } + return (cu->cu_error.re_status); +} + +static void +clntudp_geterr(cl, errp) + CLIENT *cl; + struct rpc_err *errp; +{ + register struct cu_data *cu = (struct cu_data *)cl->cl_private; + + *errp = cu->cu_error; +} + + +static bool_t +clntudp_freeres(cl, xdr_res, res_ptr) + CLIENT *cl; + xdrproc_t xdr_res; + caddr_t res_ptr; +{ + register struct cu_data *cu = (struct cu_data *)cl->cl_private; + register XDR *xdrs = &(cu->cu_outxdrs); + + xdrs->x_op = XDR_FREE; + return ((*xdr_res)(xdrs, res_ptr)); +} + +static void +clntudp_abort(/*h*/) + /*CLIENT *h;*/ +{ +} + +static bool_t +clntudp_control(cl, request, info) + CLIENT *cl; + int request; + char *info; +{ + register struct cu_data *cu = (struct cu_data *)cl->cl_private; + + switch (request) { + case CLSET_TIMEOUT: + cu->cu_total = *(struct timeval *)info; + break; + case CLGET_TIMEOUT: + *(struct timeval *)info = cu->cu_total; + break; + case CLSET_RETRY_TIMEOUT: + cu->cu_wait = *(struct timeval *)info; + break; + case CLGET_RETRY_TIMEOUT: + *(struct timeval *)info = cu->cu_wait; + break; + case CLGET_SERVER_ADDR: + *(struct sockaddr_in *)info = cu->cu_raddr; + break; + default: + return (FALSE); + } + return (TRUE); +} + +static void +clntudp_destroy(cl) + CLIENT *cl; +{ + register struct cu_data *cu = (struct cu_data *)cl->cl_private; + + if (cu->cu_closeit) { + (void)close(cu->cu_sock); + } + XDR_DESTROY(&(cu->cu_outxdrs)); + mem_free((caddr_t)cu, (sizeof(*cu) + cu->cu_sendsz + cu->cu_recvsz)); + mem_free((caddr_t)cl, sizeof(CLIENT)); +} diff -ruN glibc-1.07/sunrpc/etc.rpc glibc-1.08.1/sunrpc/etc.rpc --- glibc-1.07/sunrpc/etc.rpc +++ glibc-1.08.1/sunrpc/etc.rpc Sun Feb 6 22:32:48 1994 @@ -0,0 +1,33 @@ +# +# rpc 88/08/01 4.0 RPCSRC; from 1.12 88/02/07 SMI +# +portmapper 100000 portmap sunrpc +rstatd 100001 rstat rstat_svc rup perfmeter +rusersd 100002 rusers +nfs 100003 nfsprog +ypserv 100004 ypprog +mountd 100005 mount showmount +ypbind 100007 +walld 100008 rwall shutdown +yppasswdd 100009 yppasswd +etherstatd 100010 etherstat +rquotad 100011 rquotaprog quota rquota +sprayd 100012 spray +3270_mapper 100013 +rje_mapper 100014 +selection_svc 100015 selnsvc +database_svc 100016 +rexd 100017 rex +alis 100018 +sched 100019 +llockmgr 100020 +nlockmgr 100021 +x25.inr 100022 +statmon 100023 +status 100024 +bootparam 100026 +ypupdated 100028 ypupdate +keyserv 100029 keyserver +tfsd 100037 +nsed 100038 +nsemntd 100039 diff -ruN glibc-1.07/sunrpc/get_myaddr.c glibc-1.08.1/sunrpc/get_myaddr.c --- glibc-1.07/sunrpc/get_myaddr.c +++ glibc-1.08.1/sunrpc/get_myaddr.c Sun Feb 6 17:31:27 1994 @@ -0,0 +1,89 @@ +/* @(#)get_myaddress.c 2.1 88/07/29 4.0 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +#if !defined(lint) && defined(SCCSIDS) +static char sccsid[] = "@(#)get_myaddress.c 1.4 87/08/11 Copyr 1984 Sun Micro"; +#endif + +/* + * get_myaddress.c + * + * Get client's IP address via ioctl. This avoids using the yellowpages. + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#include +#include +#include +#include +#include +#include +/* Order of following two #includes reversed by roland@gnu */ +#include +#include + +/* + * don't use gethostbyname, which would invoke yellow pages + */ +get_myaddress(addr) + struct sockaddr_in *addr; +{ + int s; + char buf[BUFSIZ]; + struct ifconf ifc; + struct ifreq ifreq, *ifr; + int len; + + if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { + perror("get_myaddress: socket"); + exit(1); + } + ifc.ifc_len = sizeof (buf); + ifc.ifc_buf = buf; + if (ioctl(s, SIOCGIFCONF, (char *)&ifc) < 0) { + perror("get_myaddress: ioctl (get interface configuration)"); + exit(1); + } + ifr = ifc.ifc_req; + for (len = ifc.ifc_len; len; len -= sizeof ifreq) { + ifreq = *ifr; + if (ioctl(s, SIOCGIFFLAGS, (char *)&ifreq) < 0) { + perror("get_myaddress: ioctl"); + exit(1); + } + if ((ifreq.ifr_flags & IFF_UP) && + ifr->ifr_addr.sa_family == AF_INET) { + *addr = *((struct sockaddr_in *)&ifr->ifr_addr); + addr->sin_port = htons(PMAPPORT); + break; + } + ifr++; + } + (void) close(s); +} diff -ruN glibc-1.07/sunrpc/getrpcent.c glibc-1.08.1/sunrpc/getrpcent.c --- glibc-1.07/sunrpc/getrpcent.c +++ glibc-1.08.1/sunrpc/getrpcent.c Tue Feb 8 18:53:04 1994 @@ -0,0 +1,235 @@ +/* @(#)getrpcent.c 2.2 88/07/29 4.0 RPCSRC */ +#if !defined(lint) && defined(SCCSIDS) +static char sccsid[] = "@(#)getrpcent.c 1.9 87/08/11 Copyr 1984 Sun Micro"; +#endif + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +/* + * Copyright (c) 1985 by Sun Microsystems, Inc. + */ + +#include +#include +#include +#include +#include + +/* + * Internet version. + */ +struct rpcdata { + FILE *rpcf; + char *current; + int currentlen; + int stayopen; +#define MAXALIASES 35 + char *rpc_aliases[MAXALIASES]; + struct rpcent rpc; + char line[BUFSIZ+1]; + char *domain; +} *rpcdata, *_rpcdata(); + +static struct rpcent *interpret(); +struct hostent *gethostent(); +char *inet_ntoa(); +extern char *index(); /* Changed from static by roland@gnu */ + +static char RPCDB[] = _PATH_RPC; /* Changed from "/etc/rpc" by roland@gnu */ + +static struct rpcdata * +_rpcdata() +{ + register struct rpcdata *d = rpcdata; + + if (d == 0) { + d = (struct rpcdata *)calloc(1, sizeof (struct rpcdata)); + rpcdata = d; + } + return (d); +} + +struct rpcent * +getrpcbynumber(number) + register int number; +{ + register struct rpcdata *d = _rpcdata(); + register struct rpcent *p; + int reason; + char adrstr[16], *val = NULL; + int vallen; + + if (d == 0) + return (0); + setrpcent(0); + while (p = getrpcent()) { + if (p->r_number == number) + break; + } + endrpcent(); + return (p); +} + +struct rpcent * +getrpcbyname(name) + const char *name; /* const added by roland@gnu */ +{ + struct rpcent *rpc; + char **rp; + + setrpcent(0); + while(rpc = getrpcent()) { + if (strcmp(rpc->r_name, name) == 0) + return (rpc); + for (rp = rpc->r_aliases; *rp != NULL; rp++) { + if (strcmp(*rp, name) == 0) + return (rpc); + } + } + endrpcent(); + return (NULL); +} + +setrpcent(f) + int f; +{ + register struct rpcdata *d = _rpcdata(); + + if (d == 0) + return; + if (d->rpcf == NULL) + d->rpcf = fopen(RPCDB, "r"); + else + rewind(d->rpcf); + if (d->current) + free(d->current); + d->current = NULL; + d->stayopen |= f; +} + +endrpcent() +{ + register struct rpcdata *d = _rpcdata(); + + if (d == 0) + return; + if (d->current && !d->stayopen) { + free(d->current); + d->current = NULL; + } + if (d->rpcf && !d->stayopen) { + fclose(d->rpcf); + d->rpcf = NULL; + } +} + +struct rpcent * +getrpcent() +{ + struct rpcent *hp; + int reason; + char *key = NULL, *val = NULL; + int keylen, vallen; + register struct rpcdata *d = _rpcdata(); + + if (d == 0) + return(NULL); + if (d->rpcf == NULL && (d->rpcf = fopen(RPCDB, "r")) == NULL) + return (NULL); + if (fgets(d->line, BUFSIZ, d->rpcf) == NULL) + return (NULL); + return interpret(d->line, strlen(d->line)); +} + +static struct rpcent * +interpret(val, len) +{ + register struct rpcdata *d = _rpcdata(); + char *p; + register char *cp, **q; + + if (d == 0) + return; + strncpy(d->line, val, len); + p = d->line; + d->line[len] = '\n'; + if (*p == '#') + return (getrpcent()); + cp = index(p, '#'); + if (cp == NULL) + { + cp = index(p, '\n'); + if (cp == NULL) + return (getrpcent()); + } + *cp = '\0'; + cp = index(p, ' '); + if (cp == NULL) + { + cp = index(p, '\t'); + if (cp == NULL) + return (getrpcent()); + } + *cp++ = '\0'; + /* THIS STUFF IS INTERNET SPECIFIC */ + d->rpc.r_name = d->line; + while (*cp == ' ' || *cp == '\t') + cp++; + d->rpc.r_number = atoi(cp); + q = d->rpc.r_aliases = d->rpc_aliases; + cp = index(p, ' '); + if (cp != NULL) + *cp++ = '\0'; + else + { + cp = index(p, '\t'); + if (cp != NULL) + *cp++ = '\0'; + } + while (cp && *cp) { + if (*cp == ' ' || *cp == '\t') { + cp++; + continue; + } + if (q < &(d->rpc_aliases[MAXALIASES - 1])) + *q++ = cp; + cp = index(p, ' '); + if (cp != NULL) + *cp++ = '\0'; + else + { + cp = index(p, '\t'); + if (cp != NULL) + *cp++ = '\0'; + } + } + *q = NULL; + return (&d->rpc); +} diff -ruN glibc-1.07/sunrpc/getrpcport.c glibc-1.08.1/sunrpc/getrpcport.c --- glibc-1.07/sunrpc/getrpcport.c +++ glibc-1.08.1/sunrpc/getrpcport.c Sun Feb 6 16:42:43 1994 @@ -0,0 +1,55 @@ +/* @(#)getrpcport.c 2.1 88/07/29 4.0 RPCSRC */ +#if !defined(lint) && defined(SCCSIDS) +static char sccsid[] = "@(#)getrpcport.c 1.3 87/08/11 SMI"; +#endif +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +/* + * Copyright (c) 1985 by Sun Microsystems, Inc. + */ + +#include +#include +#include +#include + +getrpcport(host, prognum, versnum, proto) + char *host; +{ + struct sockaddr_in addr; + struct hostent *hp; + + if ((hp = gethostbyname(host)) == NULL) + return (0); + bcopy(hp->h_addr, (char *) &addr.sin_addr, hp->h_length); + addr.sin_family = AF_INET; + addr.sin_port = 0; + return (pmap_getport(&addr, prognum, versnum, proto)); +} diff -ruN glibc-1.07/sunrpc/pm_getmaps.c glibc-1.08.1/sunrpc/pm_getmaps.c --- glibc-1.07/sunrpc/pm_getmaps.c +++ glibc-1.08.1/sunrpc/pm_getmaps.c Sun Feb 6 16:42:43 1994 @@ -0,0 +1,84 @@ +/* @(#)pmap_getmaps.c 2.2 88/08/01 4.0 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +#if !defined(lint) && defined(SCCSIDS) +static char sccsid[] = "@(#)pmap_getmaps.c 1.10 87/08/11 Copyr 1984 Sun Micro"; +#endif + +/* + * pmap_getmap.c + * Client interface to pmap rpc service. + * contains pmap_getmaps, which is only tcp service involved + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#define NAMELEN 255 +#define MAX_BROADCAST_SIZE 1400 + +extern int errno; + +/* + * Get a copy of the current port maps. + * Calls the pmap service remotely to do get the maps. + */ +struct pmaplist * +pmap_getmaps(address) + struct sockaddr_in *address; +{ + struct pmaplist *head = (struct pmaplist *)NULL; + int socket = -1; + struct timeval minutetimeout; + register CLIENT *client; + + minutetimeout.tv_sec = 60; + minutetimeout.tv_usec = 0; + address->sin_port = htons(PMAPPORT); + client = clnttcp_create(address, PMAPPROG, + PMAPVERS, &socket, 50, 500); + if (client != (CLIENT *)NULL) { + if (CLNT_CALL(client, PMAPPROC_DUMP, xdr_void, NULL, xdr_pmaplist, + &head, minutetimeout) != RPC_SUCCESS) { + clnt_perror(client, "pmap_getmaps rpc problem"); + } + CLNT_DESTROY(client); + } + (void)close(socket); + address->sin_port = 0; + return (head); +} diff -ruN glibc-1.07/sunrpc/pm_getport.c glibc-1.08.1/sunrpc/pm_getport.c --- glibc-1.07/sunrpc/pm_getport.c +++ glibc-1.08.1/sunrpc/pm_getport.c Sun Feb 6 16:42:43 1994 @@ -0,0 +1,87 @@ +/* @(#)pmap_getport.c 2.2 88/08/01 4.0 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +#if !defined(lint) && defined(SCCSIDS) +static char sccsid[] = "@(#)pmap_getport.c 1.9 87/08/11 Copyr 1984 Sun Micro"; +#endif + +/* + * pmap_getport.c + * Client interface to pmap rpc service. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#include +#include +#include +#include +#include + +static struct timeval timeout = { 5, 0 }; +static struct timeval tottimeout = { 60, 0 }; + +/* + * Find the mapped port for program,version. + * Calls the pmap service remotely to do the lookup. + * Returns 0 if no map exists. + */ +u_short +pmap_getport(address, program, version, protocol) + struct sockaddr_in *address; + u_long program; + u_long version; + u_int protocol; +{ + u_short port = 0; + int socket = -1; + register CLIENT *client; + struct pmap parms; + + address->sin_port = htons(PMAPPORT); + client = clntudp_bufcreate(address, PMAPPROG, + PMAPVERS, timeout, &socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE); + if (client != (CLIENT *)NULL) { + parms.pm_prog = program; + parms.pm_vers = version; + parms.pm_prot = protocol; + parms.pm_port = 0; /* not needed or used */ + if (CLNT_CALL(client, PMAPPROC_GETPORT, xdr_pmap, &parms, + xdr_u_short, &port, tottimeout) != RPC_SUCCESS){ + rpc_createerr.cf_stat = RPC_PMAPFAILURE; + clnt_geterr(client, &rpc_createerr.cf_error); + } else if (port == 0) { + rpc_createerr.cf_stat = RPC_PROGNOTREGISTERED; + } + CLNT_DESTROY(client); + } + (void)close(socket); + address->sin_port = 0; + return (port); +} diff -ruN glibc-1.07/sunrpc/pmap_clnt.c glibc-1.08.1/sunrpc/pmap_clnt.c --- glibc-1.07/sunrpc/pmap_clnt.c +++ glibc-1.08.1/sunrpc/pmap_clnt.c Sun Feb 6 16:42:43 1994 @@ -0,0 +1,115 @@ +/* @(#)pmap_clnt.c 2.2 88/08/01 4.0 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +#if !defined(lint) && defined(SCCSIDS) +static char sccsid[] = "@(#)pmap_clnt.c 1.37 87/08/11 Copyr 1984 Sun Micro"; +#endif + +/* + * pmap_clnt.c + * Client interface to pmap rpc service. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#include +#include +#include + +static struct timeval timeout = { 5, 0 }; +static struct timeval tottimeout = { 60, 0 }; + +void clnt_perror(); + + +/* + * Set a mapping between program,version and port. + * Calls the pmap service remotely to do the mapping. + */ +bool_t +pmap_set(program, version, protocol, port) + u_long program; + u_long version; + int protocol; + u_short port; +{ + struct sockaddr_in myaddress; + int socket = -1; + register CLIENT *client; + struct pmap parms; + bool_t rslt; + + get_myaddress(&myaddress); + client = clntudp_bufcreate(&myaddress, PMAPPROG, PMAPVERS, + timeout, &socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE); + if (client == (CLIENT *)NULL) + return (FALSE); + parms.pm_prog = program; + parms.pm_vers = version; + parms.pm_prot = protocol; + parms.pm_port = port; + if (CLNT_CALL(client, PMAPPROC_SET, xdr_pmap, &parms, xdr_bool, &rslt, + tottimeout) != RPC_SUCCESS) { + clnt_perror(client, "Cannot register service"); + return (FALSE); + } + CLNT_DESTROY(client); + (void)close(socket); + return (rslt); +} + +/* + * Remove the mapping between program,version and port. + * Calls the pmap service remotely to do the un-mapping. + */ +bool_t +pmap_unset(program, version) + u_long program; + u_long version; +{ + struct sockaddr_in myaddress; + int socket = -1; + register CLIENT *client; + struct pmap parms; + bool_t rslt; + + get_myaddress(&myaddress); + client = clntudp_bufcreate(&myaddress, PMAPPROG, PMAPVERS, + timeout, &socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE); + if (client == (CLIENT *)NULL) + return (FALSE); + parms.pm_prog = program; + parms.pm_vers = version; + parms.pm_port = parms.pm_prot = 0; + CLNT_CALL(client, PMAPPROC_UNSET, xdr_pmap, &parms, xdr_bool, &rslt, + tottimeout); + CLNT_DESTROY(client); + (void)close(socket); + return (rslt); +} diff -ruN glibc-1.07/sunrpc/pmap_prot.c glibc-1.08.1/sunrpc/pmap_prot.c --- glibc-1.07/sunrpc/pmap_prot.c +++ glibc-1.08.1/sunrpc/pmap_prot.c Sun Feb 6 16:42:43 1994 @@ -0,0 +1,57 @@ +/* @(#)pmap_prot.c 2.1 88/07/29 4.0 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +#if !defined(lint) && defined(SCCSIDS) +static char sccsid[] = "@(#)pmap_prot.c 1.17 87/08/11 Copyr 1984 Sun Micro"; +#endif + +/* + * pmap_prot.c + * Protocol for the local binder service, or pmap. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#include +#include +#include + + +bool_t +xdr_pmap(xdrs, regs) + XDR *xdrs; + struct pmap *regs; +{ + + if (xdr_u_long(xdrs, ®s->pm_prog) && + xdr_u_long(xdrs, ®s->pm_vers) && + xdr_u_long(xdrs, ®s->pm_prot)) + return (xdr_u_long(xdrs, ®s->pm_port)); + return (FALSE); +} diff -ruN glibc-1.07/sunrpc/pmap_prot2.c glibc-1.08.1/sunrpc/pmap_prot2.c --- glibc-1.07/sunrpc/pmap_prot2.c +++ glibc-1.08.1/sunrpc/pmap_prot2.c Sun Feb 6 16:42:43 1994 @@ -0,0 +1,116 @@ +/* @(#)pmap_prot2.c 2.1 88/07/29 4.0 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +#if !defined(lint) && defined(SCCSIDS) +static char sccsid[] = "@(#)pmap_prot2.c 1.3 87/08/11 Copyr 1984 Sun Micro"; +#endif + +/* + * pmap_prot2.c + * Protocol for the local binder service, or pmap. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#include +#include +#include + + +/* + * What is going on with linked lists? (!) + * First recall the link list declaration from pmap_prot.h: + * + * struct pmaplist { + * struct pmap pml_map; + * struct pmaplist *pml_map; + * }; + * + * Compare that declaration with a corresponding xdr declaration that + * is (a) pointer-less, and (b) recursive: + * + * typedef union switch (bool_t) { + * + * case TRUE: struct { + * struct pmap; + * pmaplist_t foo; + * }; + * + * case FALSE: struct {}; + * } pmaplist_t; + * + * Notice that the xdr declaration has no nxt pointer while + * the C declaration has no bool_t variable. The bool_t can be + * interpreted as ``more data follows me''; if FALSE then nothing + * follows this bool_t; if TRUE then the bool_t is followed by + * an actual struct pmap, and then (recursively) by the + * xdr union, pamplist_t. + * + * This could be implemented via the xdr_union primitive, though this + * would cause a one recursive call per element in the list. Rather than do + * that we can ``unwind'' the recursion + * into a while loop and do the union arms in-place. + * + * The head of the list is what the C programmer wishes to past around + * the net, yet is the data that the pointer points to which is interesting; + * this sounds like a job for xdr_reference! + */ +bool_t +xdr_pmaplist(xdrs, rp) + register XDR *xdrs; + register struct pmaplist **rp; +{ + /* + * more_elements is pre-computed in case the direction is + * XDR_ENCODE or XDR_FREE. more_elements is overwritten by + * xdr_bool when the direction is XDR_DECODE. + */ + bool_t more_elements; + register int freeing = (xdrs->x_op == XDR_FREE); + register struct pmaplist **next; + + while (TRUE) { + more_elements = (bool_t)(*rp != NULL); + if (! xdr_bool(xdrs, &more_elements)) + return (FALSE); + if (! more_elements) + return (TRUE); /* we are done */ + /* + * the unfortunate side effect of non-recursion is that in + * the case of freeing we must remember the next object + * before we free the current object ... + */ + if (freeing) + next = &((*rp)->pml_next); + if (! xdr_reference(xdrs, (caddr_t *)rp, + (u_int)sizeof(struct pmaplist), xdr_pmap)) + return (FALSE); + rp = (freeing) ? next : &((*rp)->pml_next); + } +} diff -ruN glibc-1.07/sunrpc/pmap_rmt.c glibc-1.08.1/sunrpc/pmap_rmt.c --- glibc-1.07/sunrpc/pmap_rmt.c +++ glibc-1.08.1/sunrpc/pmap_rmt.c Sun Feb 6 17:35:33 1994 @@ -0,0 +1,390 @@ +/* @(#)pmap_rmt.c 2.2 88/08/01 4.0 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +#if !defined(lint) && defined(SCCSIDS) +static char sccsid[] = "@(#)pmap_rmt.c 1.21 87/08/27 Copyr 1984 Sun Micro"; +#endif + +/* + * pmap_rmt.c + * Client interface to pmap rpc service. + * remote call and broadcast service + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#define MAX_BROADCAST_SIZE 1400 + +extern int errno; +static struct timeval timeout = { 3, 0 }; + + +/* + * pmapper remote-call-service interface. + * This routine is used to call the pmapper remote call service + * which will look up a service program in the port maps, and then + * remotely call that routine with the given parameters. This allows + * programs to do a lookup and call in one step. +*/ +enum clnt_stat +pmap_rmtcall(addr, prog, vers, proc, xdrargs, argsp, xdrres, resp, tout, port_ptr) + struct sockaddr_in *addr; + u_long prog, vers, proc; + xdrproc_t xdrargs, xdrres; + caddr_t argsp, resp; + struct timeval tout; + u_long *port_ptr; +{ + int socket = -1; + register CLIENT *client; + struct rmtcallargs a; + struct rmtcallres r; + enum clnt_stat stat; + + addr->sin_port = htons(PMAPPORT); + client = clntudp_create(addr, PMAPPROG, PMAPVERS, timeout, &socket); + if (client != (CLIENT *)NULL) { + a.prog = prog; + a.vers = vers; + a.proc = proc; + a.args_ptr = argsp; + a.xdr_args = xdrargs; + r.port_ptr = port_ptr; + r.results_ptr = resp; + r.xdr_results = xdrres; + stat = CLNT_CALL(client, PMAPPROC_CALLIT, xdr_rmtcall_args, &a, + xdr_rmtcallres, &r, tout); + CLNT_DESTROY(client); + } else { + stat = RPC_FAILED; + } + (void)close(socket); + addr->sin_port = 0; + return (stat); +} + + +/* + * XDR remote call arguments + * written for XDR_ENCODE direction only + */ +bool_t +xdr_rmtcall_args(xdrs, cap) + register XDR *xdrs; + register struct rmtcallargs *cap; +{ + u_int lenposition, argposition, position; + + if (xdr_u_long(xdrs, &(cap->prog)) && + xdr_u_long(xdrs, &(cap->vers)) && + xdr_u_long(xdrs, &(cap->proc))) { + lenposition = XDR_GETPOS(xdrs); + if (! xdr_u_long(xdrs, &(cap->arglen))) + return (FALSE); + argposition = XDR_GETPOS(xdrs); + if (! (*(cap->xdr_args))(xdrs, cap->args_ptr)) + return (FALSE); + position = XDR_GETPOS(xdrs); + cap->arglen = (u_long)position - (u_long)argposition; + XDR_SETPOS(xdrs, lenposition); + if (! xdr_u_long(xdrs, &(cap->arglen))) + return (FALSE); + XDR_SETPOS(xdrs, position); + return (TRUE); + } + return (FALSE); +} + +/* + * XDR remote call results + * written for XDR_DECODE direction only + */ +bool_t +xdr_rmtcallres(xdrs, crp) + register XDR *xdrs; + register struct rmtcallres *crp; +{ + caddr_t port_ptr; + + port_ptr = (caddr_t)crp->port_ptr; + if (xdr_reference(xdrs, &port_ptr, sizeof (u_long), + xdr_u_long) && xdr_u_long(xdrs, &crp->resultslen)) { + crp->port_ptr = (u_long *)port_ptr; + return ((*(crp->xdr_results))(xdrs, crp->results_ptr)); + } + return (FALSE); +} + + +/* + * The following is kludged-up support for simple rpc broadcasts. + * Someday a large, complicated system will replace these trivial + * routines which only support udp/ip . + */ + +static int +getbroadcastnets(addrs, sock, buf) + struct in_addr *addrs; + int sock; /* any valid socket will do */ + char *buf; /* why allocxate more when we can use existing... */ +{ + struct ifconf ifc; + struct ifreq ifreq, *ifr; + struct sockaddr_in *sin; + int n, i; + + ifc.ifc_len = UDPMSGSIZE; + ifc.ifc_buf = buf; + if (ioctl(sock, SIOCGIFCONF, (char *)&ifc) < 0) { + perror("broadcast: ioctl (get interface configuration)"); + return (0); + } + ifr = ifc.ifc_req; + for (i = 0, n = ifc.ifc_len/sizeof (struct ifreq); n > 0; n--, ifr++) { + ifreq = *ifr; + if (ioctl(sock, SIOCGIFFLAGS, (char *)&ifreq) < 0) { + perror("broadcast: ioctl (get interface flags)"); + continue; + } + if ((ifreq.ifr_flags & IFF_BROADCAST) && + (ifreq.ifr_flags & IFF_UP) && + ifr->ifr_addr.sa_family == AF_INET) { + sin = (struct sockaddr_in *)&ifr->ifr_addr; +#ifdef SIOCGIFBRDADDR /* 4.3BSD */ + if (ioctl(sock, SIOCGIFBRDADDR, (char *)&ifreq) < 0) { + addrs[i++] = inet_makeaddr(inet_netof + /* Changed to pass struct instead of s_addr member + by roland@gnu. */ + (sin->sin_addr), INADDR_ANY); + } else { + addrs[i++] = ((struct sockaddr_in*) + &ifreq.ifr_addr)->sin_addr; + } +#else /* 4.2 BSD */ + addrs[i++] = inet_makeaddr(inet_netof + (sin->sin_addr.s_addr), INADDR_ANY); +#endif + } + } + return (i); +} + +typedef bool_t (*resultproc_t)(); + +enum clnt_stat +clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult) + u_long prog; /* program number */ + u_long vers; /* version number */ + u_long proc; /* procedure number */ + xdrproc_t xargs; /* xdr routine for args */ + caddr_t argsp; /* pointer to args */ + xdrproc_t xresults; /* xdr routine for results */ + caddr_t resultsp; /* pointer to results */ + resultproc_t eachresult; /* call with each result obtained */ +{ + enum clnt_stat stat; + AUTH *unix_auth = authunix_create_default(); + XDR xdr_stream; + register XDR *xdrs = &xdr_stream; + int outlen, inlen, fromlen, nets; + register int sock; + int on = 1; +#ifdef FD_SETSIZE + fd_set mask; + fd_set readfds; +#else + int readfds; + register int mask; +#endif /* def FD_SETSIZE */ + register int i; + bool_t done = FALSE; + register u_long xid; + u_long port; + struct in_addr addrs[20]; + struct sockaddr_in baddr, raddr; /* broadcast and response addresses */ + struct rmtcallargs a; + struct rmtcallres r; + struct rpc_msg msg; + struct timeval t; + char outbuf[MAX_BROADCAST_SIZE], inbuf[UDPMSGSIZE]; + + /* + * initialization: create a socket, a broadcast address, and + * preserialize the arguments into a send buffer. + */ + if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) { + perror("Cannot create socket for broadcast rpc"); + stat = RPC_CANTSEND; + goto done_broad; + } +#ifdef SO_BROADCAST + if (setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &on, sizeof (on)) < 0) { + perror("Cannot set socket option SO_BROADCAST"); + stat = RPC_CANTSEND; + goto done_broad; + } +#endif /* def SO_BROADCAST */ +#ifdef FD_SETSIZE + FD_ZERO(&mask); + FD_SET(sock, &mask); +#else + mask = (1 << sock); +#endif /* def FD_SETSIZE */ + nets = getbroadcastnets(addrs, sock, inbuf); + bzero((char *)&baddr, sizeof (baddr)); + baddr.sin_family = AF_INET; + baddr.sin_port = htons(PMAPPORT); + baddr.sin_addr.s_addr = htonl(INADDR_ANY); +/* baddr.sin_addr.S_un.S_addr = htonl(INADDR_ANY); */ + (void)gettimeofday(&t, (struct timezone *)0); + msg.rm_xid = xid = getpid() ^ t.tv_sec ^ t.tv_usec; + t.tv_usec = 0; + msg.rm_direction = CALL; + msg.rm_call.cb_rpcvers = RPC_MSG_VERSION; + msg.rm_call.cb_prog = PMAPPROG; + msg.rm_call.cb_vers = PMAPVERS; + msg.rm_call.cb_proc = PMAPPROC_CALLIT; + msg.rm_call.cb_cred = unix_auth->ah_cred; + msg.rm_call.cb_verf = unix_auth->ah_verf; + a.prog = prog; + a.vers = vers; + a.proc = proc; + a.xdr_args = xargs; + a.args_ptr = argsp; + r.port_ptr = &port; + r.xdr_results = xresults; + r.results_ptr = resultsp; + xdrmem_create(xdrs, outbuf, MAX_BROADCAST_SIZE, XDR_ENCODE); + if ((! xdr_callmsg(xdrs, &msg)) || (! xdr_rmtcall_args(xdrs, &a))) { + stat = RPC_CANTENCODEARGS; + goto done_broad; + } + outlen = (int)xdr_getpos(xdrs); + xdr_destroy(xdrs); + /* + * Basic loop: broadcast a packet and wait a while for response(s). + * The response timeout grows larger per iteration. + */ + for (t.tv_sec = 4; t.tv_sec <= 14; t.tv_sec += 2) { + for (i = 0; i < nets; i++) { + baddr.sin_addr = addrs[i]; + if (sendto(sock, outbuf, outlen, 0, + (struct sockaddr *)&baddr, + sizeof (struct sockaddr)) != outlen) { + perror("Cannot send broadcast packet"); + stat = RPC_CANTSEND; + goto done_broad; + } + } + if (eachresult == NULL) { + stat = RPC_SUCCESS; + goto done_broad; + } + recv_again: + msg.acpted_rply.ar_verf = _null_auth; + msg.acpted_rply.ar_results.where = (caddr_t)&r; + msg.acpted_rply.ar_results.proc = xdr_rmtcallres; + readfds = mask; + switch (select(_rpc_dtablesize(), &readfds, (int *)NULL, + (int *)NULL, &t)) { + + case 0: /* timed out */ + stat = RPC_TIMEDOUT; + continue; + + case -1: /* some kind of error */ + if (errno == EINTR) + goto recv_again; + perror("Broadcast select problem"); + stat = RPC_CANTRECV; + goto done_broad; + + } /* end of select results switch */ + try_again: + fromlen = sizeof(struct sockaddr); + inlen = recvfrom(sock, inbuf, UDPMSGSIZE, 0, + (struct sockaddr *)&raddr, &fromlen); + if (inlen < 0) { + if (errno == EINTR) + goto try_again; + perror("Cannot receive reply to broadcast"); + stat = RPC_CANTRECV; + goto done_broad; + } + if (inlen < sizeof(u_long)) + goto recv_again; + /* + * see if reply transaction id matches sent id. + * If so, decode the results. + */ + xdrmem_create(xdrs, inbuf, (u_int)inlen, XDR_DECODE); + if (xdr_replymsg(xdrs, &msg)) { + if ((msg.rm_xid == xid) && + (msg.rm_reply.rp_stat == MSG_ACCEPTED) && + (msg.acpted_rply.ar_stat == SUCCESS)) { + raddr.sin_port = htons((u_short)port); + done = (*eachresult)(resultsp, &raddr); + } + /* otherwise, we just ignore the errors ... */ + } else { +#ifdef notdef + /* some kind of deserialization problem ... */ + if (msg.rm_xid == xid) + fprintf(stderr, "Broadcast deserialization problem"); + /* otherwise, just random garbage */ +#endif + } + xdrs->x_op = XDR_FREE; + msg.acpted_rply.ar_results.proc = xdr_void; + (void)xdr_replymsg(xdrs, &msg); + (void)(*xresults)(xdrs, resultsp); + xdr_destroy(xdrs); + if (done) { + stat = RPC_SUCCESS; + goto done_broad; + } else { + goto recv_again; + } + } +done_broad: + (void)close(sock); + AUTH_DESTROY(unix_auth); + return (stat); +} + diff -ruN glibc-1.07/sunrpc/portmap.c glibc-1.08.1/sunrpc/portmap.c --- glibc-1.07/sunrpc/portmap.c +++ glibc-1.08.1/sunrpc/portmap.c Fri Jan 21 19:14:39 1994 @@ -0,0 +1,481 @@ +/* @(#)portmap.c 2.3 88/08/11 4.0 RPCSRC */ +#ifndef lint +static char sccsid[] = "@(#)portmap.c 1.32 87/08/06 Copyr 1984 Sun Micro"; +#endif + +/* + * Copyright (c) 1984 by Sun Microsystems, Inc. + */ + +/* + * portmap.c, Implements the program,version to port number mapping for + * rpc. + */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +char *malloc(); +int reg_service(); +void reap(); +struct pmaplist *pmaplist; +static int debugging = 0; + +main() +{ + SVCXPRT *xprt; + int sock, pid, t; + struct sockaddr_in addr; + int len = sizeof(struct sockaddr_in); + register struct pmaplist *pml; + +#ifndef DEBUG + pid = fork(); + if (pid < 0) { + perror("portmap: fork"); + exit(1); + } + if (pid != 0) + exit(0); + for (t = 0; t < 20; t++) + close(t); + open("/", 0); + dup2(0, 1); + dup2(0, 2); + t = open("/dev/tty", 2); + if (t >= 0) { + ioctl(t, TIOCNOTTY, (char *)0); + close(t); + } +#endif + if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) { + perror("portmap cannot create socket"); + exit(1); + } + + addr.sin_addr.s_addr = 0; + addr.sin_family = AF_INET; + addr.sin_port = htons(PMAPPORT); + if (bind(sock, (struct sockaddr *)&addr, len) != 0) { + perror("portmap cannot bind"); + exit(1); + } + + if ((xprt = svcudp_create(sock)) == (SVCXPRT *)NULL) { + fprintf(stderr, "couldn't do udp_create\n"); + exit(1); + } + /* make an entry for ourself */ + pml = (struct pmaplist *)malloc((u_int)sizeof(struct pmaplist)); + pml->pml_next = 0; + pml->pml_map.pm_prog = PMAPPROG; + pml->pml_map.pm_vers = PMAPVERS; + pml->pml_map.pm_prot = IPPROTO_UDP; + pml->pml_map.pm_port = PMAPPORT; + pmaplist = pml; + + if ((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) { + perror("portmap cannot create socket"); + exit(1); + } + if (bind(sock, (struct sockaddr *)&addr, len) != 0) { + perror("portmap cannot bind"); + exit(1); + } + if ((xprt = svctcp_create(sock, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE)) + == (SVCXPRT *)NULL) { + fprintf(stderr, "couldn't do tcp_create\n"); + exit(1); + } + /* make an entry for ourself */ + pml = (struct pmaplist *)malloc((u_int)sizeof(struct pmaplist)); + pml->pml_map.pm_prog = PMAPPROG; + pml->pml_map.pm_vers = PMAPVERS; + pml->pml_map.pm_prot = IPPROTO_TCP; + pml->pml_map.pm_port = PMAPPORT; + pml->pml_next = pmaplist; + pmaplist = pml; + + (void)svc_register(xprt, PMAPPROG, PMAPVERS, reg_service, FALSE); + + (void)signal(SIGCHLD, reap); + svc_run(); + fprintf(stderr, "run_svc returned unexpectedly\n"); + abort(); +} + +static struct pmaplist * +find_service(prog, vers, prot) + u_long prog; + u_long vers; +{ + register struct pmaplist *hit = NULL; + register struct pmaplist *pml; + + for (pml = pmaplist; pml != NULL; pml = pml->pml_next) { + if ((pml->pml_map.pm_prog != prog) || + (pml->pml_map.pm_prot != prot)) + continue; + hit = pml; + if (pml->pml_map.pm_vers == vers) + break; + } + return (hit); +} + +/* + * 1 OK, 0 not + */ +reg_service(rqstp, xprt) + struct svc_req *rqstp; + SVCXPRT *xprt; +{ + struct pmap reg; + struct pmaplist *pml, *prevpml, *fnd; + int ans, port; + caddr_t t; + +#ifdef DEBUG + fprintf(stderr, "server: about do a switch\n"); +#endif + switch (rqstp->rq_proc) { + + case PMAPPROC_NULL: + /* + * Null proc call + */ + if ((!svc_sendreply(xprt, xdr_void, NULL)) && debugging) { + abort(); + } + break; + + case PMAPPROC_SET: + /* + * Set a program,version to port mapping + */ + if (!svc_getargs(xprt, xdr_pmap, ®)) + svcerr_decode(xprt); + else { + /* + * check to see if already used + * find_service returns a hit even if + * the versions don't match, so check for it + */ + fnd = find_service(reg.pm_prog, reg.pm_vers, reg.pm_prot); + if (fnd && fnd->pml_map.pm_vers == reg.pm_vers) { + if (fnd->pml_map.pm_port == reg.pm_port) { + ans = 1; + goto done; + } + else { + ans = 0; + goto done; + } + } else { + /* + * add to END of list + */ + pml = (struct pmaplist *) + malloc((u_int)sizeof(struct pmaplist)); + pml->pml_map = reg; + pml->pml_next = 0; + if (pmaplist == 0) { + pmaplist = pml; + } else { + for (fnd= pmaplist; fnd->pml_next != 0; + fnd = fnd->pml_next); + fnd->pml_next = pml; + } + ans = 1; + } + done: + if ((!svc_sendreply(xprt, xdr_long, (caddr_t)&ans)) && + debugging) { + fprintf(stderr, "svc_sendreply\n"); + abort(); + } + } + break; + + case PMAPPROC_UNSET: + /* + * Remove a program,version to port mapping. + */ + if (!svc_getargs(xprt, xdr_pmap, ®)) + svcerr_decode(xprt); + else { + ans = 0; + for (prevpml = NULL, pml = pmaplist; pml != NULL; ) { + if ((pml->pml_map.pm_prog != reg.pm_prog) || + (pml->pml_map.pm_vers != reg.pm_vers)) { + /* both pml & prevpml move forwards */ + prevpml = pml; + pml = pml->pml_next; + continue; + } + /* found it; pml moves forward, prevpml stays */ + ans = 1; + t = (caddr_t)pml; + pml = pml->pml_next; + if (prevpml == NULL) + pmaplist = pml; + else + prevpml->pml_next = pml; + free(t); + } + if ((!svc_sendreply(xprt, xdr_long, (caddr_t)&ans)) && + debugging) { + fprintf(stderr, "svc_sendreply\n"); + abort(); + } + } + break; + + case PMAPPROC_GETPORT: + /* + * Lookup the mapping for a program,version and return its port + */ + if (!svc_getargs(xprt, xdr_pmap, ®)) + svcerr_decode(xprt); + else { + fnd = find_service(reg.pm_prog, reg.pm_vers, reg.pm_prot); + if (fnd) + port = fnd->pml_map.pm_port; + else + port = 0; + if ((!svc_sendreply(xprt, xdr_long, (caddr_t)&port)) && + debugging) { + fprintf(stderr, "svc_sendreply\n"); + abort(); + } + } + break; + + case PMAPPROC_DUMP: + /* + * Return the current set of mapped program,version + */ + if (!svc_getargs(xprt, xdr_void, NULL)) + svcerr_decode(xprt); + else { + if ((!svc_sendreply(xprt, xdr_pmaplist, + (caddr_t)&pmaplist)) && debugging) { + fprintf(stderr, "svc_sendreply\n"); + abort(); + } + } + break; + + case PMAPPROC_CALLIT: + /* + * Calls a procedure on the local machine. If the requested + * procedure is not registered this procedure does not return + * error information!! + * This procedure is only supported on rpc/udp and calls via + * rpc/udp. It passes null authentication parameters. + */ + callit(rqstp, xprt); + break; + + default: + svcerr_noproc(xprt); + break; + } +} + + +/* + * Stuff for the rmtcall service + */ +#define ARGSIZE 9000 + +typedef struct encap_parms { + u_long arglen; + char *args; +}; + +static bool_t +xdr_encap_parms(xdrs, epp) + XDR *xdrs; + struct encap_parms *epp; +{ + + return (xdr_bytes(xdrs, &(epp->args), &(epp->arglen), ARGSIZE)); +} + +typedef struct rmtcallargs { + u_long rmt_prog; + u_long rmt_vers; + u_long rmt_port; + u_long rmt_proc; + struct encap_parms rmt_args; +}; + +static bool_t +xdr_rmtcall_args(xdrs, cap) + register XDR *xdrs; + register struct rmtcallargs *cap; +{ + + /* does not get a port number */ + if (xdr_u_long(xdrs, &(cap->rmt_prog)) && + xdr_u_long(xdrs, &(cap->rmt_vers)) && + xdr_u_long(xdrs, &(cap->rmt_proc))) { + return (xdr_encap_parms(xdrs, &(cap->rmt_args))); + } + return (FALSE); +} + +static bool_t +xdr_rmtcall_result(xdrs, cap) + register XDR *xdrs; + register struct rmtcallargs *cap; +{ + if (xdr_u_long(xdrs, &(cap->rmt_port))) + return (xdr_encap_parms(xdrs, &(cap->rmt_args))); + return (FALSE); +} + +/* + * only worries about the struct encap_parms part of struct rmtcallargs. + * The arglen must already be set!! + */ +static bool_t +xdr_opaque_parms(xdrs, cap) + XDR *xdrs; + struct rmtcallargs *cap; +{ + + return (xdr_opaque(xdrs, cap->rmt_args.args, cap->rmt_args.arglen)); +} + +/* + * This routine finds and sets the length of incoming opaque paraters + * and then calls xdr_opaque_parms. + */ +static bool_t +xdr_len_opaque_parms(xdrs, cap) + register XDR *xdrs; + struct rmtcallargs *cap; +{ + register u_int beginpos, lowpos, highpos, currpos, pos; + + beginpos = lowpos = pos = xdr_getpos(xdrs); + highpos = lowpos + ARGSIZE; + while ((int)(highpos - lowpos) >= 0) { + currpos = (lowpos + highpos) / 2; + if (xdr_setpos(xdrs, currpos)) { + pos = currpos; + lowpos = currpos + 1; + } else { + highpos = currpos - 1; + } + } + xdr_setpos(xdrs, beginpos); + cap->rmt_args.arglen = pos - beginpos; + return (xdr_opaque_parms(xdrs, cap)); +} + +/* + * Call a remote procedure service + * This procedure is very quiet when things go wrong. + * The proc is written to support broadcast rpc. In the broadcast case, + * a machine should shut-up instead of complain, less the requestor be + * overrun with complaints at the expense of not hearing a valid reply ... + * + * This now forks so that the program & process that it calls can call + * back to the portmapper. + */ +static +callit(rqstp, xprt) + struct svc_req *rqstp; + SVCXPRT *xprt; +{ + struct rmtcallargs a; + struct pmaplist *pml; + u_short port; + struct sockaddr_in me; + int pid, socket = -1; + CLIENT *client; + struct authunix_parms *au = (struct authunix_parms *)rqstp->rq_clntcred; + struct timeval timeout; + char buf[ARGSIZE]; + + timeout.tv_sec = 5; + timeout.tv_usec = 0; + a.rmt_args.args = buf; + if (!svc_getargs(xprt, xdr_rmtcall_args, &a)) + return; + if ((pml = find_service(a.rmt_prog, a.rmt_vers, IPPROTO_UDP)) == NULL) + return; + /* + * fork a child to do the work. Parent immediately returns. + * Child exits upon completion. + */ + if ((pid = fork()) != 0) { + if (debugging && (pid < 0)) { + fprintf(stderr, "portmap CALLIT: cannot fork.\n"); + } + return; + } + port = pml->pml_map.pm_port; + get_myaddress(&me); + me.sin_port = htons(port); + client = clntudp_create(&me, a.rmt_prog, a.rmt_vers, timeout, &socket); + if (client != (CLIENT *)NULL) { + if (rqstp->rq_cred.oa_flavor == AUTH_UNIX) { + client->cl_auth = authunix_create(au->aup_machname, + au->aup_uid, au->aup_gid, au->aup_len, au->aup_gids); + } + a.rmt_port = (u_long)port; + if (clnt_call(client, a.rmt_proc, xdr_opaque_parms, &a, + xdr_len_opaque_parms, &a, timeout) == RPC_SUCCESS) { + svc_sendreply(xprt, xdr_rmtcall_result, &a); + } + AUTH_DESTROY(client->cl_auth); + clnt_destroy(client); + } + (void)close(socket); + exit(0); +} + +void +reap() +{ + while (wait3(NULL, WNOHANG, NULL) > 0); +} diff -ruN glibc-1.07/sunrpc/rpc/auth.h glibc-1.08.1/sunrpc/rpc/auth.h --- glibc-1.07/sunrpc/rpc/auth.h +++ glibc-1.08.1/sunrpc/rpc/auth.h Fri Feb 18 18:10:09 1994 @@ -0,0 +1,166 @@ +/* @(#)auth.h 2.3 88/08/07 4.0 RPCSRC; from 1.17 88/02/08 SMI */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +/* + * auth.h, Authentication interface. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + * + * The data structures are completely opaque to the client. The client + * is required to pass a AUTH * to routines that create rpc + * "sessions". + */ + + +#define MAX_AUTH_BYTES 400 +#define MAXNETNAMELEN 255 /* maximum length of network user's name */ + +/* + * Status returned from authentication check + */ +enum auth_stat { + AUTH_OK=0, + /* + * failed at remote end + */ + AUTH_BADCRED=1, /* bogus credentials (seal broken) */ + AUTH_REJECTEDCRED=2, /* client should begin new session */ + AUTH_BADVERF=3, /* bogus verifier (seal broken) */ + AUTH_REJECTEDVERF=4, /* verifier expired or was replayed */ + AUTH_TOOWEAK=5, /* rejected due to security reasons */ + /* + * failed locally + */ + AUTH_INVALIDRESP=6, /* bogus response verifier */ + AUTH_FAILED=7 /* some unknown reason */ +}; + +#if 1 /* (mc68000 || sparc || vax || i386) --roland@gnu */ +typedef u_long u_int32; /* 32-bit unsigned integers */ +#endif + +union des_block { + struct { + u_int32 high; + u_int32 low; + } key; + char c[8]; +}; +typedef union des_block des_block; +extern bool_t xdr_des_block(); + +/* + * Authentication info. Opaque to client. + */ +struct opaque_auth { + enum_t oa_flavor; /* flavor of auth */ + caddr_t oa_base; /* address of more auth stuff */ + u_int oa_length; /* not to exceed MAX_AUTH_BYTES */ +}; + + +/* + * Auth handle, interface to client side authenticators. + */ +typedef struct { + struct opaque_auth ah_cred; + struct opaque_auth ah_verf; + union des_block ah_key; + struct auth_ops { + void (*ah_nextverf)(); + int (*ah_marshal)(); /* nextverf & serialize */ + int (*ah_validate)(); /* validate varifier */ + int (*ah_refresh)(); /* refresh credentials */ + void (*ah_destroy)(); /* destroy this structure */ + } *ah_ops; + caddr_t ah_private; +} AUTH; + + +/* + * Authentication ops. + * The ops and the auth handle provide the interface to the authenticators. + * + * AUTH *auth; + * XDR *xdrs; + * struct opaque_auth verf; + */ +#define AUTH_NEXTVERF(auth) \ + ((*((auth)->ah_ops->ah_nextverf))(auth)) +#define auth_nextverf(auth) \ + ((*((auth)->ah_ops->ah_nextverf))(auth)) + +#define AUTH_MARSHALL(auth, xdrs) \ + ((*((auth)->ah_ops->ah_marshal))(auth, xdrs)) +#define auth_marshall(auth, xdrs) \ + ((*((auth)->ah_ops->ah_marshal))(auth, xdrs)) + +#define AUTH_VALIDATE(auth, verfp) \ + ((*((auth)->ah_ops->ah_validate))((auth), verfp)) +#define auth_validate(auth, verfp) \ + ((*((auth)->ah_ops->ah_validate))((auth), verfp)) + +#define AUTH_REFRESH(auth) \ + ((*((auth)->ah_ops->ah_refresh))(auth)) +#define auth_refresh(auth) \ + ((*((auth)->ah_ops->ah_refresh))(auth)) + +#define AUTH_DESTROY(auth) \ + ((*((auth)->ah_ops->ah_destroy))(auth)) +#define auth_destroy(auth) \ + ((*((auth)->ah_ops->ah_destroy))(auth)) + + +extern struct opaque_auth _null_auth; + + +/* + * These are the various implementations of client side authenticators. + */ + +/* + * Unix style authentication + * AUTH *authunix_create(machname, uid, gid, len, aup_gids) + * char *machname; + * int uid; + * int gid; + * int len; + * int *aup_gids; + */ +extern AUTH *authunix_create(); +extern AUTH *authunix_create_default(); /* takes no parameters */ +extern AUTH *authnone_create(); /* takes no parameters */ +extern AUTH *authdes_create(); + +#define AUTH_NONE 0 /* no authentication */ +#define AUTH_NULL 0 /* backward compatibility */ +#define AUTH_UNIX 1 /* unix style (uid, gids) */ +#define AUTH_SHORT 2 /* short hand unix style */ +#define AUTH_DES 3 /* des style (encrypted timestamps) */ diff -ruN glibc-1.07/sunrpc/rpc/auth_unix.h glibc-1.08.1/sunrpc/rpc/auth_unix.h --- glibc-1.07/sunrpc/rpc/auth_unix.h +++ glibc-1.08.1/sunrpc/rpc/auth_unix.h Sun Feb 6 16:42:41 1994 @@ -0,0 +1,72 @@ +/* @(#)auth_unix.h 2.2 88/07/29 4.0 RPCSRC; from 1.8 88/02/08 SMI */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +/* @(#)auth_unix.h 1.5 86/07/16 SMI */ + +/* + * auth_unix.h, Protocol for UNIX style authentication parameters for RPC + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +/* + * The system is very weak. The client uses no encryption for it + * credentials and only sends null verifiers. The server sends backs + * null verifiers or optionally a verifier that suggests a new short hand + * for the credentials. + */ + +/* The machine name is part of a credential; it may not exceed 255 bytes */ +#define MAX_MACHINE_NAME 255 + +/* gids compose part of a credential; there may not be more than 16 of them */ +#define NGRPS 16 + +/* + * Unix style credentials. + */ +struct authunix_parms { + u_long aup_time; + char *aup_machname; + int aup_uid; + int aup_gid; + u_int aup_len; + int *aup_gids; +}; + +extern bool_t xdr_authunix_parms(); + +/* + * If a response verifier has flavor AUTH_SHORT, + * then the body of the response verifier encapsulates the following structure; + * again it is serialized in the obvious fashion. + */ +struct short_hand_verf { + struct opaque_auth new_cred; +}; diff -ruN glibc-1.07/sunrpc/rpc/clnt.h glibc-1.08.1/sunrpc/rpc/clnt.h --- glibc-1.07/sunrpc/rpc/clnt.h +++ glibc-1.08.1/sunrpc/rpc/clnt.h Sun Feb 6 16:42:41 1994 @@ -0,0 +1,331 @@ +/* @(#)clnt.h 2.1 88/07/29 4.0 RPCSRC; from 1.31 88/02/08 SMI*/ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +/* + * clnt.h - Client side remote procedure call interface. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#ifndef _CLNT_ +#define _CLNT_ + +/* + * Rpc calls return an enum clnt_stat. This should be looked at more, + * since each implementation is required to live with this (implementation + * independent) list of errors. + */ +enum clnt_stat { + RPC_SUCCESS=0, /* call succeeded */ + /* + * local errors + */ + RPC_CANTENCODEARGS=1, /* can't encode arguments */ + RPC_CANTDECODERES=2, /* can't decode results */ + RPC_CANTSEND=3, /* failure in sending call */ + RPC_CANTRECV=4, /* failure in receiving result */ + RPC_TIMEDOUT=5, /* call timed out */ + /* + * remote errors + */ + RPC_VERSMISMATCH=6, /* rpc versions not compatible */ + RPC_AUTHERROR=7, /* authentication error */ + RPC_PROGUNAVAIL=8, /* program not available */ + RPC_PROGVERSMISMATCH=9, /* program version mismatched */ + RPC_PROCUNAVAIL=10, /* procedure unavailable */ + RPC_CANTDECODEARGS=11, /* decode arguments error */ + RPC_SYSTEMERROR=12, /* generic "other problem" */ + + /* + * callrpc & clnt_create errors + */ + RPC_UNKNOWNHOST=13, /* unknown host name */ + RPC_UNKNOWNPROTO=17, /* unkown protocol */ + + /* + * _ create errors + */ + RPC_PMAPFAILURE=14, /* the pmapper failed in its call */ + RPC_PROGNOTREGISTERED=15, /* remote program is not registered */ + /* + * unspecified error + */ + RPC_FAILED=16 +}; + + +/* + * Error info. + */ +struct rpc_err { + enum clnt_stat re_status; + union { + int RE_errno; /* realated system error */ + enum auth_stat RE_why; /* why the auth error occurred */ + struct { + u_long low; /* lowest verion supported */ + u_long high; /* highest verion supported */ + } RE_vers; + struct { /* maybe meaningful if RPC_FAILED */ + long s1; + long s2; + } RE_lb; /* life boot & debugging only */ + } ru; +#define re_errno ru.RE_errno +#define re_why ru.RE_why +#define re_vers ru.RE_vers +#define re_lb ru.RE_lb +}; + + +/* + * Client rpc handle. + * Created by individual implementations, see e.g. rpc_udp.c. + * Client is responsible for initializing auth, see e.g. auth_none.c. + */ +typedef struct { + AUTH *cl_auth; /* authenticator */ + struct clnt_ops { + enum clnt_stat (*cl_call)(); /* call remote procedure */ + void (*cl_abort)(); /* abort a call */ + void (*cl_geterr)(); /* get specific error code */ + bool_t (*cl_freeres)(); /* frees results */ + void (*cl_destroy)();/* destroy this structure */ + bool_t (*cl_control)();/* the ioctl() of rpc */ + } *cl_ops; + caddr_t cl_private; /* private stuff */ +} CLIENT; + + +/* + * client side rpc interface ops + * + * Parameter types are: + * + */ + +/* + * enum clnt_stat + * CLNT_CALL(rh, proc, xargs, argsp, xres, resp, timeout) + * CLIENT *rh; + * u_long proc; + * xdrproc_t xargs; + * caddr_t argsp; + * xdrproc_t xres; + * caddr_t resp; + * struct timeval timeout; + */ +#define CLNT_CALL(rh, proc, xargs, argsp, xres, resp, secs) \ + ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, argsp, xres, resp, secs)) +#define clnt_call(rh, proc, xargs, argsp, xres, resp, secs) \ + ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, argsp, xres, resp, secs)) + +/* + * void + * CLNT_ABORT(rh); + * CLIENT *rh; + */ +#define CLNT_ABORT(rh) ((*(rh)->cl_ops->cl_abort)(rh)) +#define clnt_abort(rh) ((*(rh)->cl_ops->cl_abort)(rh)) + +/* + * struct rpc_err + * CLNT_GETERR(rh); + * CLIENT *rh; + */ +#define CLNT_GETERR(rh,errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp)) +#define clnt_geterr(rh,errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp)) + + +/* + * bool_t + * CLNT_FREERES(rh, xres, resp); + * CLIENT *rh; + * xdrproc_t xres; + * caddr_t resp; + */ +#define CLNT_FREERES(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp)) +#define clnt_freeres(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp)) + +/* + * bool_t + * CLNT_CONTROL(cl, request, info) + * CLIENT *cl; + * u_int request; + * char *info; + */ +#define CLNT_CONTROL(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in)) +#define clnt_control(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in)) + +/* + * control operations that apply to both udp and tcp transports + */ +#define CLSET_TIMEOUT 1 /* set timeout (timeval) */ +#define CLGET_TIMEOUT 2 /* get timeout (timeval) */ +#define CLGET_SERVER_ADDR 3 /* get server's address (sockaddr) */ +/* + * udp only control operations + */ +#define CLSET_RETRY_TIMEOUT 4 /* set retry timeout (timeval) */ +#define CLGET_RETRY_TIMEOUT 5 /* get retry timeout (timeval) */ + +/* + * void + * CLNT_DESTROY(rh); + * CLIENT *rh; + */ +#define CLNT_DESTROY(rh) ((*(rh)->cl_ops->cl_destroy)(rh)) +#define clnt_destroy(rh) ((*(rh)->cl_ops->cl_destroy)(rh)) + + +/* + * RPCTEST is a test program which is accessable on every rpc + * transport/port. It is used for testing, performance evaluation, + * and network administration. + */ + +#define RPCTEST_PROGRAM ((u_long)1) +#define RPCTEST_VERSION ((u_long)1) +#define RPCTEST_NULL_PROC ((u_long)2) +#define RPCTEST_NULL_BATCH_PROC ((u_long)3) + +/* + * By convention, procedure 0 takes null arguments and returns them + */ + +#define NULLPROC ((u_long)0) + +/* + * Below are the client handle creation routines for the various + * implementations of client side rpc. They can return NULL if a + * creation failure occurs. + */ + +/* + * Memory based rpc (for speed check and testing) + * CLIENT * + * clntraw_create(prog, vers) + * u_long prog; + * u_long vers; + */ +extern CLIENT *clntraw_create(); + + +/* + * Generic client creation routine. Supported protocols are "udp" and "tcp" + */ +extern CLIENT * +clnt_create(/*host, prog, vers, prot*/); /* + char *host; -- hostname + u_long prog; -- program number + u_long vers; -- version number + char *prot; -- protocol +*/ + + + + +/* + * TCP based rpc + * CLIENT * + * clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz) + * struct sockaddr_in *raddr; + * u_long prog; + * u_long version; + * register int *sockp; + * u_int sendsz; + * u_int recvsz; + */ +extern CLIENT *clnttcp_create(); + +/* + * UDP based rpc. + * CLIENT * + * clntudp_create(raddr, program, version, wait, sockp) + * struct sockaddr_in *raddr; + * u_long program; + * u_long version; + * struct timeval wait; + * int *sockp; + * + * Same as above, but you specify max packet sizes. + * CLIENT * + * clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz) + * struct sockaddr_in *raddr; + * u_long program; + * u_long version; + * struct timeval wait; + * int *sockp; + * u_int sendsz; + * u_int recvsz; + */ +extern CLIENT *clntudp_create(); +extern CLIENT *clntudp_bufcreate(); + +/* + * Print why creation failed + */ +void clnt_pcreateerror(/* char *msg */); /* stderr */ +char *clnt_spcreateerror(/* char *msg */); /* string */ + +/* + * Like clnt_perror(), but is more verbose in its output + */ +void clnt_perrno(/* enum clnt_stat num */); /* stderr */ + +/* + * Print an English error message, given the client error code + */ +void clnt_perror(/* CLIENT *clnt, char *msg */); /* stderr */ +char *clnt_sperror(/* CLIENT *clnt, char *msg */); /* string */ + +/* + * If a creation fails, the following allows the user to figure out why. + */ +struct rpc_createerr { + enum clnt_stat cf_stat; + struct rpc_err cf_error; /* useful when cf_stat == RPC_PMAPFAILURE */ +}; + +extern struct rpc_createerr rpc_createerr; + + + +/* + * Copy error message to buffer. + */ +char *clnt_sperrno(/* enum clnt_stat num */); /* string */ + + + +#define UDPMSGSIZE 8800 /* rpc imposed limit on udp msg size */ +#define RPCSMALLMSGSIZE 400 /* a more reasonable packet size */ + +#endif /*!_CLNT_*/ diff -ruN glibc-1.07/sunrpc/rpc/netdb.h glibc-1.08.1/sunrpc/rpc/netdb.h --- glibc-1.07/sunrpc/rpc/netdb.h +++ glibc-1.08.1/sunrpc/rpc/netdb.h Sun Feb 6 23:54:52 1994 @@ -0,0 +1,52 @@ +/* @(#)netdb.h 2.1 88/07/29 3.9 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +/* @(#)rpc.h 1.8 87/07/24 SMI */ + +/* Cleaned up for GNU C library roland@gnu.ai.mit.edu: + added multiple inclusion protection and use of . + In GNU this file is #include'd by . */ + +#ifndef _RPC_NETDB_H +#define _RPC_NETDB_H +#include + +struct rpcent { + char *r_name; /* name of server for this rpc program */ + char **r_aliases; /* alias list */ + int r_number; /* rpc program number */ +}; + +__BEGIN_DECLS +struct rpcent *getrpcbyname __P((const char *)); +struct rpcent *getrpcbynumber __P((int)); +struct rpcent *getrpcent __P((void)); +__END_DECLS + +#endif diff -ruN glibc-1.07/sunrpc/rpc/pmap_clnt.h glibc-1.08.1/sunrpc/rpc/pmap_clnt.h --- glibc-1.07/sunrpc/rpc/pmap_clnt.h +++ glibc-1.08.1/sunrpc/rpc/pmap_clnt.h Sun Feb 6 16:42:43 1994 @@ -0,0 +1,65 @@ +/* @(#)pmap_clnt.h 2.1 88/07/29 4.0 RPCSRC; from 1.11 88/02/08 SMI */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +/* + * pmap_clnt.h + * Supplies C routines to get to portmap services. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +/* + * Usage: + * success = pmap_set(program, version, protocol, port); + * success = pmap_unset(program, version); + * port = pmap_getport(address, program, version, protocol); + * head = pmap_getmaps(address); + * clnt_stat = pmap_rmtcall(address, program, version, procedure, + * xdrargs, argsp, xdrres, resp, tout, port_ptr) + * (works for udp only.) + * clnt_stat = clnt_broadcast(program, version, procedure, + * xdrargs, argsp, xdrres, resp, eachresult) + * (like pmap_rmtcall, except the call is broadcasted to all + * locally connected nets. For each valid response received, + * the procedure eachresult is called. Its form is: + * done = eachresult(resp, raddr) + * bool_t done; + * caddr_t resp; + * struct sockaddr_in raddr; + * where resp points to the results of the call and raddr is the + * address if the responder to the broadcast. + */ + +extern bool_t pmap_set(); +extern bool_t pmap_unset(); +extern struct pmaplist *pmap_getmaps(); +enum clnt_stat pmap_rmtcall(); +enum clnt_stat clnt_broadcast(); +extern u_short pmap_getport(); diff -ruN glibc-1.07/sunrpc/rpc/pmap_prot.h glibc-1.08.1/sunrpc/rpc/pmap_prot.h --- glibc-1.07/sunrpc/rpc/pmap_prot.h +++ glibc-1.08.1/sunrpc/rpc/pmap_prot.h Sun Feb 6 16:42:43 1994 @@ -0,0 +1,94 @@ +/* @(#)pmap_prot.h 2.1 88/07/29 4.0 RPCSRC; from 1.14 88/02/08 SMI */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +/* + * pmap_prot.h + * Protocol for the local binder service, or pmap. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + * + * The following procedures are supported by the protocol: + * + * PMAPPROC_NULL() returns () + * takes nothing, returns nothing + * + * PMAPPROC_SET(struct pmap) returns (bool_t) + * TRUE is success, FALSE is failure. Registers the tuple + * [prog, vers, prot, port]. + * + * PMAPPROC_UNSET(struct pmap) returns (bool_t) + * TRUE is success, FALSE is failure. Un-registers pair + * [prog, vers]. prot and port are ignored. + * + * PMAPPROC_GETPORT(struct pmap) returns (long unsigned). + * 0 is failure. Otherwise returns the port number where the pair + * [prog, vers] is registered. It may lie! + * + * PMAPPROC_DUMP() RETURNS (struct pmaplist *) + * + * PMAPPROC_CALLIT(unsigned, unsigned, unsigned, string<>) + * RETURNS (port, string<>); + * usage: encapsulatedresults = PMAPPROC_CALLIT(prog, vers, proc, encapsulatedargs); + * Calls the procedure on the local machine. If it is not registered, + * this procedure is quite; ie it does not return error information!!! + * This procedure only is supported on rpc/udp and calls via + * rpc/udp. This routine only passes null authentication parameters. + * This file has no interface to xdr routines for PMAPPROC_CALLIT. + * + * The service supports remote procedure calls on udp/ip or tcp/ip socket 111. + */ + +#define PMAPPORT ((u_short)111) +#define PMAPPROG ((u_long)100000) +#define PMAPVERS ((u_long)2) +#define PMAPVERS_PROTO ((u_long)2) +#define PMAPVERS_ORIG ((u_long)1) +#define PMAPPROC_NULL ((u_long)0) +#define PMAPPROC_SET ((u_long)1) +#define PMAPPROC_UNSET ((u_long)2) +#define PMAPPROC_GETPORT ((u_long)3) +#define PMAPPROC_DUMP ((u_long)4) +#define PMAPPROC_CALLIT ((u_long)5) + +struct pmap { + long unsigned pm_prog; + long unsigned pm_vers; + long unsigned pm_prot; + long unsigned pm_port; +}; + +extern bool_t xdr_pmap(); + +struct pmaplist { + struct pmap pml_map; + struct pmaplist *pml_next; +}; + +extern bool_t xdr_pmaplist(); diff -ruN glibc-1.07/sunrpc/rpc/pmap_rmt.h glibc-1.08.1/sunrpc/rpc/pmap_rmt.h --- glibc-1.07/sunrpc/rpc/pmap_rmt.h +++ glibc-1.08.1/sunrpc/rpc/pmap_rmt.h Sun Feb 6 16:42:44 1994 @@ -0,0 +1,53 @@ +/* @(#)pmap_rmt.h 2.1 88/07/29 4.0 RPCSRC; from 1.2 88/02/08 SMI */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +/* + * Structures and XDR routines for parameters to and replies from + * the portmapper remote-call-service. + * + * Copyright (C) 1986, Sun Microsystems, Inc. + */ + +struct rmtcallargs { + u_long prog, vers, proc, arglen; + caddr_t args_ptr; + xdrproc_t xdr_args; +}; + +bool_t xdr_rmtcall_args(); + +struct rmtcallres { + u_long *port_ptr; + u_long resultslen; + caddr_t results_ptr; + xdrproc_t xdr_results; +}; + +bool_t xdr_rmtcallres(); diff -ruN glibc-1.07/sunrpc/rpc/rpc.h glibc-1.08.1/sunrpc/rpc/rpc.h --- glibc-1.07/sunrpc/rpc/rpc.h +++ glibc-1.08.1/sunrpc/rpc/rpc.h Sun Feb 6 16:42:44 1994 @@ -0,0 +1,73 @@ +/* @(#)rpc.h 2.3 88/08/10 4.0 RPCSRC; from 1.9 88/02/08 SMI */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +/* + * rpc.h, Just includes the billions of rpc header files necessary to + * do remote procedure calling. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ +#ifndef __RPC_HEADER__ +#define __RPC_HEADER__ + +#include /* some typedefs */ +#include + +/* external data representation interfaces */ +#include /* generic (de)serializer */ + +/* Client side only authentication */ +#include /* generic authenticator (client side) */ + +/* Client side (mostly) remote procedure call */ +#include /* generic rpc stuff */ + +/* semi-private protocol headers */ +#include /* protocol for rpc messages */ +#include /* protocol for unix style cred */ +/* + * Uncomment-out the next line if you are building the rpc library with + * DES Authentication (see the README file in the secure_rpc/ directory). + */ +/*#include /* protocol for des style cred */ + +/* Server side only remote procedure callee */ +#include /* service manager and multiplexer */ +#include /* service side authenticator */ + +/* + * COMMENT OUT THE NEXT INCLUDE IF RUNNING ON SUN OS OR ON A VERSION + * OF UNIX BASED ON NFSSRC. These systems will already have the structures + * defined by included in . + */ +/* routines for parsing /etc/rpc */ +#include /* structures and routines to parse /etc/rpc */ + +#endif /* ndef __RPC_HEADER__ */ diff -ruN glibc-1.07/sunrpc/rpc/rpc_msg.h glibc-1.08.1/sunrpc/rpc/rpc_msg.h --- glibc-1.07/sunrpc/rpc/rpc_msg.h +++ glibc-1.08.1/sunrpc/rpc/rpc_msg.h Sun Feb 6 16:42:46 1994 @@ -0,0 +1,187 @@ +/* @(#)rpc_msg.h 2.1 88/07/29 4.0 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +/* @(#)rpc_msg.h 1.7 86/07/16 SMI */ + +/* + * rpc_msg.h + * rpc message definition + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#define RPC_MSG_VERSION ((u_long) 2) +#define RPC_SERVICE_PORT ((u_short) 2048) + +/* + * Bottom up definition of an rpc message. + * NOTE: call and reply use the same overall stuct but + * different parts of unions within it. + */ + +enum msg_type { + CALL=0, + REPLY=1 +}; + +enum reply_stat { + MSG_ACCEPTED=0, + MSG_DENIED=1 +}; + +enum accept_stat { + SUCCESS=0, + PROG_UNAVAIL=1, + PROG_MISMATCH=2, + PROC_UNAVAIL=3, + GARBAGE_ARGS=4, + SYSTEM_ERR=5 +}; + +enum reject_stat { + RPC_MISMATCH=0, + AUTH_ERROR=1 +}; + +/* + * Reply part of an rpc exchange + */ + +/* + * Reply to an rpc request that was accepted by the server. + * Note: there could be an error even though the request was + * accepted. + */ +struct accepted_reply { + struct opaque_auth ar_verf; + enum accept_stat ar_stat; + union { + struct { + u_long low; + u_long high; + } AR_versions; + struct { + caddr_t where; + xdrproc_t proc; + } AR_results; + /* and many other null cases */ + } ru; +#define ar_results ru.AR_results +#define ar_vers ru.AR_versions +}; + +/* + * Reply to an rpc request that was rejected by the server. + */ +struct rejected_reply { + enum reject_stat rj_stat; + union { + struct { + u_long low; + u_long high; + } RJ_versions; + enum auth_stat RJ_why; /* why authentication did not work */ + } ru; +#define rj_vers ru.RJ_versions +#define rj_why ru.RJ_why +}; + +/* + * Body of a reply to an rpc request. + */ +struct reply_body { + enum reply_stat rp_stat; + union { + struct accepted_reply RP_ar; + struct rejected_reply RP_dr; + } ru; +#define rp_acpt ru.RP_ar +#define rp_rjct ru.RP_dr +}; + +/* + * Body of an rpc request call. + */ +struct call_body { + u_long cb_rpcvers; /* must be equal to two */ + u_long cb_prog; + u_long cb_vers; + u_long cb_proc; + struct opaque_auth cb_cred; + struct opaque_auth cb_verf; /* protocol specific - provided by client */ +}; + +/* + * The rpc message + */ +struct rpc_msg { + u_long rm_xid; + enum msg_type rm_direction; + union { + struct call_body RM_cmb; + struct reply_body RM_rmb; + } ru; +#define rm_call ru.RM_cmb +#define rm_reply ru.RM_rmb +}; +#define acpted_rply ru.RM_rmb.ru.RP_ar +#define rjcted_rply ru.RM_rmb.ru.RP_dr + + +/* + * XDR routine to handle a rpc message. + * xdr_callmsg(xdrs, cmsg) + * XDR *xdrs; + * struct rpc_msg *cmsg; + */ +extern bool_t xdr_callmsg(); + +/* + * XDR routine to pre-serialize the static part of a rpc message. + * xdr_callhdr(xdrs, cmsg) + * XDR *xdrs; + * struct rpc_msg *cmsg; + */ +extern bool_t xdr_callhdr(); + +/* + * XDR routine to handle a rpc reply. + * xdr_replymsg(xdrs, rmsg) + * XDR *xdrs; + * struct rpc_msg *rmsg; + */ +extern bool_t xdr_replymsg(); + +/* + * Fills in the error part of a reply message. + * _seterr_reply(msg, error) + * struct rpc_msg *msg; + * struct rpc_err *error; + */ +extern void _seterr_reply(); diff -ruN glibc-1.07/sunrpc/rpc/svc.h glibc-1.08.1/sunrpc/rpc/svc.h --- glibc-1.07/sunrpc/rpc/svc.h +++ glibc-1.08.1/sunrpc/rpc/svc.h Sun Feb 6 16:42:47 1994 @@ -0,0 +1,280 @@ +/* @(#)svc.h 2.2 88/07/29 4.0 RPCSRC; from 1.20 88/02/08 SMI */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +/* + * svc.h, Server-side remote procedure call interface. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#ifndef __SVC_HEADER__ +#define __SVC_HEADER__ + +/* + * This interface must manage two items concerning remote procedure calling: + * + * 1) An arbitrary number of transport connections upon which rpc requests + * are received. The two most notable transports are TCP and UDP; they are + * created and registered by routines in svc_tcp.c and svc_udp.c, respectively; + * they in turn call xprt_register and xprt_unregister. + * + * 2) An arbitrary number of locally registered services. Services are + * described by the following four data: program number, version number, + * "service dispatch" function, a transport handle, and a boolean that + * indicates whether or not the exported program should be registered with a + * local binder service; if true the program's number and version and the + * port number from the transport handle are registered with the binder. + * These data are registered with the rpc svc system via svc_register. + * + * A service's dispatch function is called whenever an rpc request comes in + * on a transport. The request's program and version numbers must match + * those of the registered service. The dispatch function is passed two + * parameters, struct svc_req * and SVCXPRT *, defined below. + */ + +enum xprt_stat { + XPRT_DIED, + XPRT_MOREREQS, + XPRT_IDLE +}; + +/* + * Server side transport handle + */ +typedef struct { + int xp_sock; + u_short xp_port; /* associated port number */ + struct xp_ops { + bool_t (*xp_recv)(); /* receive incomming requests */ + enum xprt_stat (*xp_stat)(); /* get transport status */ + bool_t (*xp_getargs)(); /* get arguments */ + bool_t (*xp_reply)(); /* send reply */ + bool_t (*xp_freeargs)();/* free mem allocated for args */ + void (*xp_destroy)(); /* destroy this struct */ + } *xp_ops; + int xp_addrlen; /* length of remote address */ + struct sockaddr_in xp_raddr; /* remote address */ + struct opaque_auth xp_verf; /* raw response verifier */ + caddr_t xp_p1; /* private */ + caddr_t xp_p2; /* private */ +} SVCXPRT; + +/* + * Approved way of getting address of caller + */ +#define svc_getcaller(x) (&(x)->xp_raddr) + +/* + * Operations defined on an SVCXPRT handle + * + * SVCXPRT *xprt; + * struct rpc_msg *msg; + * xdrproc_t xargs; + * caddr_t argsp; + */ +#define SVC_RECV(xprt, msg) \ + (*(xprt)->xp_ops->xp_recv)((xprt), (msg)) +#define svc_recv(xprt, msg) \ + (*(xprt)->xp_ops->xp_recv)((xprt), (msg)) + +#define SVC_STAT(xprt) \ + (*(xprt)->xp_ops->xp_stat)(xprt) +#define svc_stat(xprt) \ + (*(xprt)->xp_ops->xp_stat)(xprt) + +#define SVC_GETARGS(xprt, xargs, argsp) \ + (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp)) +#define svc_getargs(xprt, xargs, argsp) \ + (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp)) + +#define SVC_REPLY(xprt, msg) \ + (*(xprt)->xp_ops->xp_reply) ((xprt), (msg)) +#define svc_reply(xprt, msg) \ + (*(xprt)->xp_ops->xp_reply) ((xprt), (msg)) + +#define SVC_FREEARGS(xprt, xargs, argsp) \ + (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp)) +#define svc_freeargs(xprt, xargs, argsp) \ + (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp)) + +#define SVC_DESTROY(xprt) \ + (*(xprt)->xp_ops->xp_destroy)(xprt) +#define svc_destroy(xprt) \ + (*(xprt)->xp_ops->xp_destroy)(xprt) + + +/* + * Service request + */ +struct svc_req { + u_long rq_prog; /* service program number */ + u_long rq_vers; /* service protocol version */ + u_long rq_proc; /* the desired procedure */ + struct opaque_auth rq_cred; /* raw creds from the wire */ + caddr_t rq_clntcred; /* read only cooked cred */ + SVCXPRT *rq_xprt; /* associated transport */ +}; + + +/* + * Service registration + * + * svc_register(xprt, prog, vers, dispatch, protocol) + * SVCXPRT *xprt; + * u_long prog; + * u_long vers; + * void (*dispatch)(); + * int protocol; /* like TCP or UDP, zero means do not register + */ +extern bool_t svc_register(); + +/* + * Service un-registration + * + * svc_unregister(prog, vers) + * u_long prog; + * u_long vers; + */ +extern void svc_unregister(); + +/* + * Transport registration. + * + * xprt_register(xprt) + * SVCXPRT *xprt; + */ +extern void xprt_register(); + +/* + * Transport un-register + * + * xprt_unregister(xprt) + * SVCXPRT *xprt; + */ +extern void xprt_unregister(); + + + + +/* + * When the service routine is called, it must first check to see if it + * knows about the procedure; if not, it should call svcerr_noproc + * and return. If so, it should deserialize its arguments via + * SVC_GETARGS (defined above). If the deserialization does not work, + * svcerr_decode should be called followed by a return. Successful + * decoding of the arguments should be followed the execution of the + * procedure's code and a call to svc_sendreply. + * + * Also, if the service refuses to execute the procedure due to too- + * weak authentication parameters, svcerr_weakauth should be called. + * Note: do not confuse access-control failure with weak authentication! + * + * NB: In pure implementations of rpc, the caller always waits for a reply + * msg. This message is sent when svc_sendreply is called. + * Therefore pure service implementations should always call + * svc_sendreply even if the function logically returns void; use + * xdr.h - xdr_void for the xdr routine. HOWEVER, tcp based rpc allows + * for the abuse of pure rpc via batched calling or pipelining. In the + * case of a batched call, svc_sendreply should NOT be called since + * this would send a return message, which is what batching tries to avoid. + * It is the service/protocol writer's responsibility to know which calls are + * batched and which are not. Warning: responding to batch calls may + * deadlock the caller and server processes! + */ + +extern bool_t svc_sendreply(); +extern void svcerr_decode(); +extern void svcerr_weakauth(); +extern void svcerr_noproc(); +extern void svcerr_progvers(); +extern void svcerr_auth(); +extern void svcerr_noprog(); +extern void svcerr_systemerr(); + +/* + * Lowest level dispatching -OR- who owns this process anyway. + * Somebody has to wait for incoming requests and then call the correct + * service routine. The routine svc_run does infinite waiting; i.e., + * svc_run never returns. + * Since another (co-existant) package may wish to selectively wait for + * incoming calls or other events outside of the rpc architecture, the + * routine svc_getreq is provided. It must be passed readfds, the + * "in-place" results of a select system call (see select, section 2). + */ + +/* + * Global keeper of rpc service descriptors in use + * dynamic; must be inspected before each call to select + */ +#ifdef FD_SETSIZE +extern fd_set svc_fdset; +#define svc_fds svc_fdset.fds_bits[0] /* compatibility */ +#else +extern int svc_fds; +#endif /* def FD_SETSIZE */ + +/* + * a small program implemented by the svc_rpc implementation itself; + * also see clnt.h for protocol numbers. + */ +extern void rpctest_service(); + +extern void svc_getreq(); +extern void svc_getreqset(); /* takes fdset instead of int */ +extern void svc_run(); /* never returns */ + +/* + * Socket to use on svcxxx_create call to get default socket + */ +#define RPC_ANYSOCK -1 + +/* + * These are the existing service side transport implementations + */ + +/* + * Memory based rpc for testing and timing. + */ +extern SVCXPRT *svcraw_create(); + +/* + * Udp based rpc. + */ +extern SVCXPRT *svcudp_create(); +extern SVCXPRT *svcudp_bufcreate(); + +/* + * Tcp based rpc. + */ +extern SVCXPRT *svctcp_create(); + + + +#endif !__SVC_HEADER__ diff -ruN glibc-1.07/sunrpc/rpc/svc_auth.h glibc-1.08.1/sunrpc/rpc/svc_auth.h --- glibc-1.07/sunrpc/rpc/svc_auth.h +++ glibc-1.08.1/sunrpc/rpc/svc_auth.h Sun Feb 6 16:42:47 1994 @@ -0,0 +1,42 @@ +/* @(#)svc_auth.h 2.1 88/07/29 4.0 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +/* @(#)svc_auth.h 1.6 86/07/16 SMI */ + +/* + * svc_auth.h, Service side of rpc authentication. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + + +/* + * Server side authenticator + */ +extern enum auth_stat _authenticate(); diff -ruN glibc-1.07/sunrpc/rpc/types.h glibc-1.08.1/sunrpc/rpc/types.h --- glibc-1.07/sunrpc/rpc/types.h +++ glibc-1.08.1/sunrpc/rpc/types.h Sun Feb 6 16:42:49 1994 @@ -0,0 +1,63 @@ +/* @(#)types.h 2.3 88/08/15 4.0 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +/* @(#)types.h 1.18 87/07/24 SMI */ + +/* + * Rpc additions to + */ +#ifndef __TYPES_RPC_HEADER__ +#define __TYPES_RPC_HEADER__ + +#define bool_t int +#define enum_t int +#define FALSE (0) +#define TRUE (1) +#define __dontcare__ -1 +#ifndef NULL +# define NULL 0 +#endif + +extern char *malloc(); +#define mem_alloc(bsize) malloc(bsize) +#define mem_free(ptr, bsize) free(ptr) + +#ifndef makedev /* ie, we haven't already included it */ +#include +#endif +#include + +#ifndef INADDR_LOOPBACK +#define INADDR_LOOPBACK (u_long)0x7F000001 +#endif +#ifndef MAXHOSTNAMELEN +#define MAXHOSTNAMELEN 64 +#endif + +#endif /* ndef __TYPES_RPC_HEADER__ */ diff -ruN glibc-1.07/sunrpc/rpc/xdr.h glibc-1.08.1/sunrpc/rpc/xdr.h --- glibc-1.07/sunrpc/rpc/xdr.h +++ glibc-1.08.1/sunrpc/rpc/xdr.h Sun Feb 6 16:42:49 1994 @@ -0,0 +1,270 @@ +/* @(#)xdr.h 2.2 88/07/29 4.0 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +/* @(#)xdr.h 1.19 87/04/22 SMI */ + +/* + * xdr.h, External Data Representation Serialization Routines. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#ifndef __XDR_HEADER__ +#define __XDR_HEADER__ + +/* + * XDR provides a conventional way for converting between C data + * types and an external bit-string representation. Library supplied + * routines provide for the conversion on built-in C data types. These + * routines and utility routines defined here are used to help implement + * a type encode/decode routine for each user-defined type. + * + * Each data type provides a single procedure which takes two arguments: + * + * bool_t + * xdrproc(xdrs, argresp) + * XDR *xdrs; + * *argresp; + * + * xdrs is an instance of a XDR handle, to which or from which the data + * type is to be converted. argresp is a pointer to the structure to be + * converted. The XDR handle contains an operation field which indicates + * which of the operations (ENCODE, DECODE * or FREE) is to be performed. + * + * XDR_DECODE may allocate space if the pointer argresp is null. This + * data can be freed with the XDR_FREE operation. + * + * We write only one procedure per data type to make it easy + * to keep the encode and decode procedures for a data type consistent. + * In many cases the same code performs all operations on a user defined type, + * because all the hard work is done in the component type routines. + * decode as a series of calls on the nested data types. + */ + +/* + * Xdr operations. XDR_ENCODE causes the type to be encoded into the + * stream. XDR_DECODE causes the type to be extracted from the stream. + * XDR_FREE can be used to release the space allocated by an XDR_DECODE + * request. + */ +enum xdr_op { + XDR_ENCODE=0, + XDR_DECODE=1, + XDR_FREE=2 +}; + +/* + * This is the number of bytes per unit of external data. + */ +#define BYTES_PER_XDR_UNIT (4) +#define RNDUP(x) ((((x) + BYTES_PER_XDR_UNIT - 1) / BYTES_PER_XDR_UNIT) \ + * BYTES_PER_XDR_UNIT) + +/* + * A xdrproc_t exists for each data type which is to be encoded or decoded. + * + * The second argument to the xdrproc_t is a pointer to an opaque pointer. + * The opaque pointer generally points to a structure of the data type + * to be decoded. If this pointer is 0, then the type routines should + * allocate dynamic storage of the appropriate size and return it. + * bool_t (*xdrproc_t)(XDR *, caddr_t *); + */ +typedef bool_t (*xdrproc_t)(); + +/* + * The XDR handle. + * Contains operation which is being applied to the stream, + * an operations vector for the paticular implementation (e.g. see xdr_mem.c), + * and two private fields for the use of the particular impelementation. + */ +typedef struct { + enum xdr_op x_op; /* operation; fast additional param */ + struct xdr_ops { + bool_t (*x_getlong)(); /* get a long from underlying stream */ + bool_t (*x_putlong)(); /* put a long to " */ + bool_t (*x_getbytes)();/* get some bytes from " */ + bool_t (*x_putbytes)();/* put some bytes to " */ + u_int (*x_getpostn)();/* returns bytes off from beginning */ + bool_t (*x_setpostn)();/* lets you reposition the stream */ + long * (*x_inline)(); /* buf quick ptr to buffered data */ + void (*x_destroy)(); /* free privates of this xdr_stream */ + } *x_ops; + caddr_t x_public; /* users' data */ + caddr_t x_private; /* pointer to private data */ + caddr_t x_base; /* private used for position info */ + int x_handy; /* extra private word */ +} XDR; + +/* + * Operations defined on a XDR handle + * + * XDR *xdrs; + * long *longp; + * caddr_t addr; + * u_int len; + * u_int pos; + */ +#define XDR_GETLONG(xdrs, longp) \ + (*(xdrs)->x_ops->x_getlong)(xdrs, longp) +#define xdr_getlong(xdrs, longp) \ + (*(xdrs)->x_ops->x_getlong)(xdrs, longp) + +#define XDR_PUTLONG(xdrs, longp) \ + (*(xdrs)->x_ops->x_putlong)(xdrs, longp) +#define xdr_putlong(xdrs, longp) \ + (*(xdrs)->x_ops->x_putlong)(xdrs, longp) + +#define XDR_GETBYTES(xdrs, addr, len) \ + (*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len) +#define xdr_getbytes(xdrs, addr, len) \ + (*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len) + +#define XDR_PUTBYTES(xdrs, addr, len) \ + (*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len) +#define xdr_putbytes(xdrs, addr, len) \ + (*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len) + +#define XDR_GETPOS(xdrs) \ + (*(xdrs)->x_ops->x_getpostn)(xdrs) +#define xdr_getpos(xdrs) \ + (*(xdrs)->x_ops->x_getpostn)(xdrs) + +#define XDR_SETPOS(xdrs, pos) \ + (*(xdrs)->x_ops->x_setpostn)(xdrs, pos) +#define xdr_setpos(xdrs, pos) \ + (*(xdrs)->x_ops->x_setpostn)(xdrs, pos) + +#define XDR_INLINE(xdrs, len) \ + (*(xdrs)->x_ops->x_inline)(xdrs, len) +#define xdr_inline(xdrs, len) \ + (*(xdrs)->x_ops->x_inline)(xdrs, len) + +#define XDR_DESTROY(xdrs) \ + if ((xdrs)->x_ops->x_destroy) \ + (*(xdrs)->x_ops->x_destroy)(xdrs) +#define xdr_destroy(xdrs) \ + if ((xdrs)->x_ops->x_destroy) \ + (*(xdrs)->x_ops->x_destroy)(xdrs) + +/* + * Support struct for discriminated unions. + * You create an array of xdrdiscrim structures, terminated with + * a entry with a null procedure pointer. The xdr_union routine gets + * the discriminant value and then searches the array of structures + * for a matching value. If a match is found the associated xdr routine + * is called to handle that part of the union. If there is + * no match, then a default routine may be called. + * If there is no match and no default routine it is an error. + */ +#define NULL_xdrproc_t ((xdrproc_t)0) +struct xdr_discrim { + int value; + xdrproc_t proc; +}; + +/* + * In-line routines for fast encode/decode of primitve data types. + * Caveat emptor: these use single memory cycles to get the + * data from the underlying buffer, and will fail to operate + * properly if the data is not aligned. The standard way to use these + * is to say: + * if ((buf = XDR_INLINE(xdrs, count)) == NULL) + * return (FALSE); + * <<< macro calls >>> + * where ``count'' is the number of bytes of data occupied + * by the primitive data types. + * + * N.B. and frozen for all time: each data type here uses 4 bytes + * of external representation. + */ +#define IXDR_GET_LONG(buf) ((long)ntohl((u_long)*(buf)++)) +#define IXDR_PUT_LONG(buf, v) (*(buf)++ = (long)htonl((u_long)v)) + +#define IXDR_GET_BOOL(buf) ((bool_t)IXDR_GET_LONG(buf)) +#define IXDR_GET_ENUM(buf, t) ((t)IXDR_GET_LONG(buf)) +#define IXDR_GET_U_LONG(buf) ((u_long)IXDR_GET_LONG(buf)) +#define IXDR_GET_SHORT(buf) ((short)IXDR_GET_LONG(buf)) +#define IXDR_GET_U_SHORT(buf) ((u_short)IXDR_GET_LONG(buf)) + +#define IXDR_PUT_BOOL(buf, v) IXDR_PUT_LONG((buf), ((long)(v))) +#define IXDR_PUT_ENUM(buf, v) IXDR_PUT_LONG((buf), ((long)(v))) +#define IXDR_PUT_U_LONG(buf, v) IXDR_PUT_LONG((buf), ((long)(v))) +#define IXDR_PUT_SHORT(buf, v) IXDR_PUT_LONG((buf), ((long)(v))) +#define IXDR_PUT_U_SHORT(buf, v) IXDR_PUT_LONG((buf), ((long)(v))) + +/* + * These are the "generic" xdr routines. + */ +extern bool_t xdr_void(); +extern bool_t xdr_int(); +extern bool_t xdr_u_int(); +extern bool_t xdr_long(); +extern bool_t xdr_u_long(); +extern bool_t xdr_short(); +extern bool_t xdr_u_short(); +extern bool_t xdr_bool(); +extern bool_t xdr_enum(); +extern bool_t xdr_array(); +extern bool_t xdr_bytes(); +extern bool_t xdr_opaque(); +extern bool_t xdr_string(); +extern bool_t xdr_union(); +extern bool_t xdr_char(); +extern bool_t xdr_u_char(); +extern bool_t xdr_vector(); +extern bool_t xdr_float(); +extern bool_t xdr_double(); +extern bool_t xdr_reference(); +extern bool_t xdr_pointer(); +extern bool_t xdr_wrapstring(); + +/* + * Common opaque bytes objects used by many rpc protocols; + * declared here due to commonality. + */ +#define MAX_NETOBJ_SZ 1024 +struct netobj { + u_int n_len; + char *n_bytes; +}; +typedef struct netobj netobj; +extern bool_t xdr_netobj(); + +/* + * These are the public routines for the various implementations of + * xdr streams. + */ +extern void xdrmem_create(); /* XDR using memory buffers */ +extern void xdrstdio_create(); /* XDR using stdio library */ +extern void xdrrec_create(); /* XDR pseudo records for tcp */ +extern bool_t xdrrec_endofrecord(); /* make end of xdr record */ +extern bool_t xdrrec_skiprecord(); /* move to beginning of next record */ +extern bool_t xdrrec_eof(); /* true if no more input */ + +#endif !__XDR_HEADER__ diff -ruN glibc-1.07/sunrpc/rpc_clntout.c glibc-1.08.1/sunrpc/rpc_clntout.c --- glibc-1.07/sunrpc/rpc_clntout.c +++ glibc-1.08.1/sunrpc/rpc_clntout.c Sun Feb 6 22:15:41 1994 @@ -0,0 +1,126 @@ +/* @(#)rpc_clntout.c 2.1 88/08/01 4.0 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +#ifndef lint +static char sccsid[] = "@(#)rpc_clntout.c 1.2 87/06/24 (C) 1987 SMI"; +#endif + +/* + * rpc_clntout.c, Client-stub outputter for the RPC protocol compiler + * Copyright (C) 1987, Sun Microsytsems, Inc. + */ +#include +#include +#include "rpc_parse.h" +#include "rpc_util.h" + +#define DEFAULT_TIMEOUT 25 /* in seconds */ + +void +write_stubs() +{ + list *l; + definition *def; + + f_print(fout, + "\n/* Default timeout can be changed using clnt_control() */\n"); + f_print(fout, "static struct timeval TIMEOUT = { %d, 0 };\n", + DEFAULT_TIMEOUT); + for (l = defined; l != NULL; l = l->next) { + def = (definition *) l->val; + if (def->def_kind == DEF_PROGRAM) { + write_program(def); + } + } +} + + +static +write_program(def) + definition *def; +{ + version_list *vp; + proc_list *proc; + + for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) { + for (proc = vp->procs; proc != NULL; proc = proc->next) { + f_print(fout, "\n"); + ptype(proc->res_prefix, proc->res_type, 1); + f_print(fout, "*\n"); + pvname(proc->proc_name, vp->vers_num); + f_print(fout, "(argp, clnt)\n"); + f_print(fout, "\t"); + ptype(proc->arg_prefix, proc->arg_type, 1); + f_print(fout, "*argp;\n"); + f_print(fout, "\tCLIENT *clnt;\n"); + f_print(fout, "{\n"); + printbody(proc); + f_print(fout, "}\n\n"); + } + } +} + +static char * +ampr(type) + char *type; +{ + if (isvectordef(type, REL_ALIAS)) { + return (""); + } else { + return ("&"); + } +} + +static +printbody(proc) + proc_list *proc; +{ + f_print(fout, "\tstatic "); + if (streq(proc->res_type, "void")) { + f_print(fout, "char "); + } else { + ptype(proc->res_prefix, proc->res_type, 0); + } + f_print(fout, "res;\n"); + f_print(fout, "\n"); + f_print(fout, "\tbzero((char *)%sres, sizeof(res));\n", + ampr(proc->res_type)); + f_print(fout, + "\tif (clnt_call(clnt, %s, xdr_%s, argp, xdr_%s, %sres, TIMEOUT) != RPC_SUCCESS) {\n", + proc->proc_name, stringfix(proc->arg_type), + stringfix(proc->res_type), ampr(proc->res_type)); + f_print(fout, "\t\treturn (NULL);\n"); + f_print(fout, "\t}\n"); + if (streq(proc->res_type, "void")) { + f_print(fout, "\treturn ((void *)%sres);\n", + ampr(proc->res_type)); + } else { + f_print(fout, "\treturn (%sres);\n", ampr(proc->res_type)); + } +} diff -ruN glibc-1.07/sunrpc/rpc_cmsg.c glibc-1.08.1/sunrpc/rpc_cmsg.c --- glibc-1.07/sunrpc/rpc_cmsg.c +++ glibc-1.08.1/sunrpc/rpc_cmsg.c Sun Feb 6 16:42:44 1994 @@ -0,0 +1,190 @@ +/* @(#)rpc_callmsg.c 2.1 88/07/29 4.0 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +#if !defined(lint) && defined(SCCSIDS) +static char sccsid[] = "@(#)rpc_callmsg.c 1.4 87/08/11 Copyr 1984 Sun Micro"; +#endif + +/* + * rpc_callmsg.c + * + * Copyright (C) 1984, Sun Microsystems, Inc. + * + */ + +#include + +#include + +/* + * XDR a call message + */ +bool_t +xdr_callmsg(xdrs, cmsg) + register XDR *xdrs; + register struct rpc_msg *cmsg; +{ + register long *buf; + register struct opaque_auth *oa; + + if (xdrs->x_op == XDR_ENCODE) { + if (cmsg->rm_call.cb_cred.oa_length > MAX_AUTH_BYTES) { + return (FALSE); + } + if (cmsg->rm_call.cb_verf.oa_length > MAX_AUTH_BYTES) { + return (FALSE); + } + buf = XDR_INLINE(xdrs, 8 * BYTES_PER_XDR_UNIT + + RNDUP(cmsg->rm_call.cb_cred.oa_length) + + 2 * BYTES_PER_XDR_UNIT + + RNDUP(cmsg->rm_call.cb_verf.oa_length)); + if (buf != NULL) { + IXDR_PUT_LONG(buf, cmsg->rm_xid); + IXDR_PUT_ENUM(buf, cmsg->rm_direction); + if (cmsg->rm_direction != CALL) { + return (FALSE); + } + IXDR_PUT_LONG(buf, cmsg->rm_call.cb_rpcvers); + if (cmsg->rm_call.cb_rpcvers != RPC_MSG_VERSION) { + return (FALSE); + } + IXDR_PUT_LONG(buf, cmsg->rm_call.cb_prog); + IXDR_PUT_LONG(buf, cmsg->rm_call.cb_vers); + IXDR_PUT_LONG(buf, cmsg->rm_call.cb_proc); + oa = &cmsg->rm_call.cb_cred; + IXDR_PUT_ENUM(buf, oa->oa_flavor); + IXDR_PUT_LONG(buf, oa->oa_length); + if (oa->oa_length) { + bcopy(oa->oa_base, (caddr_t)buf, oa->oa_length); + buf += RNDUP(oa->oa_length) / sizeof (long); + } + oa = &cmsg->rm_call.cb_verf; + IXDR_PUT_ENUM(buf, oa->oa_flavor); + IXDR_PUT_LONG(buf, oa->oa_length); + if (oa->oa_length) { + bcopy(oa->oa_base, (caddr_t)buf, oa->oa_length); + /* no real need.... + buf += RNDUP(oa->oa_length) / sizeof (long); + */ + } + return (TRUE); + } + } + if (xdrs->x_op == XDR_DECODE) { + buf = XDR_INLINE(xdrs, 8 * BYTES_PER_XDR_UNIT); + if (buf != NULL) { + cmsg->rm_xid = IXDR_GET_LONG(buf); + cmsg->rm_direction = IXDR_GET_ENUM(buf, enum msg_type); + if (cmsg->rm_direction != CALL) { + return (FALSE); + } + cmsg->rm_call.cb_rpcvers = IXDR_GET_LONG(buf); + if (cmsg->rm_call.cb_rpcvers != RPC_MSG_VERSION) { + return (FALSE); + } + cmsg->rm_call.cb_prog = IXDR_GET_LONG(buf); + cmsg->rm_call.cb_vers = IXDR_GET_LONG(buf); + cmsg->rm_call.cb_proc = IXDR_GET_LONG(buf); + oa = &cmsg->rm_call.cb_cred; + oa->oa_flavor = IXDR_GET_ENUM(buf, enum_t); + oa->oa_length = IXDR_GET_LONG(buf); + if (oa->oa_length) { + if (oa->oa_length > MAX_AUTH_BYTES) { + return (FALSE); + } + if (oa->oa_base == NULL) { + oa->oa_base = (caddr_t) + mem_alloc(oa->oa_length); + } + buf = XDR_INLINE(xdrs, RNDUP(oa->oa_length)); + if (buf == NULL) { + if (xdr_opaque(xdrs, oa->oa_base, + oa->oa_length) == FALSE) { + return (FALSE); + } + } else { + bcopy((caddr_t)buf, oa->oa_base, + oa->oa_length); + /* no real need.... + buf += RNDUP(oa->oa_length) / + sizeof (long); + */ + } + } + oa = &cmsg->rm_call.cb_verf; + buf = XDR_INLINE(xdrs, 2 * BYTES_PER_XDR_UNIT); + if (buf == NULL) { + if (xdr_enum(xdrs, &oa->oa_flavor) == FALSE || + xdr_u_int(xdrs, &oa->oa_length) == FALSE) { + return (FALSE); + } + } else { + oa->oa_flavor = IXDR_GET_ENUM(buf, enum_t); + oa->oa_length = IXDR_GET_LONG(buf); + } + if (oa->oa_length) { + if (oa->oa_length > MAX_AUTH_BYTES) { + return (FALSE); + } + if (oa->oa_base == NULL) { + oa->oa_base = (caddr_t) + mem_alloc(oa->oa_length); + } + buf = XDR_INLINE(xdrs, RNDUP(oa->oa_length)); + if (buf == NULL) { + if (xdr_opaque(xdrs, oa->oa_base, + oa->oa_length) == FALSE) { + return (FALSE); + } + } else { + bcopy((caddr_t)buf, oa->oa_base, + oa->oa_length); + /* no real need... + buf += RNDUP(oa->oa_length) / + sizeof (long); + */ + } + } + return (TRUE); + } + } + if ( + xdr_u_long(xdrs, &(cmsg->rm_xid)) && + xdr_enum(xdrs, (enum_t *)&(cmsg->rm_direction)) && + (cmsg->rm_direction == CALL) && + xdr_u_long(xdrs, &(cmsg->rm_call.cb_rpcvers)) && + (cmsg->rm_call.cb_rpcvers == RPC_MSG_VERSION) && + xdr_u_long(xdrs, &(cmsg->rm_call.cb_prog)) && + xdr_u_long(xdrs, &(cmsg->rm_call.cb_vers)) && + xdr_u_long(xdrs, &(cmsg->rm_call.cb_proc)) && + xdr_opaque_auth(xdrs, &(cmsg->rm_call.cb_cred)) ) + return (xdr_opaque_auth(xdrs, &(cmsg->rm_call.cb_verf))); + return (FALSE); +} + diff -ruN glibc-1.07/sunrpc/rpc_common.c glibc-1.08.1/sunrpc/rpc_common.c --- glibc-1.07/sunrpc/rpc_common.c +++ glibc-1.08.1/sunrpc/rpc_common.c Sun Feb 6 16:42:46 1994 @@ -0,0 +1,41 @@ +/* @(#)rpc_commondata.c 2.1 88/07/29 4.0 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +#include +/* + * This file should only contain common data (global data) that is exported + * by public interfaces + */ +struct opaque_auth _null_auth; +#ifdef FD_SETSIZE +fd_set svc_fdset; +#else +int svc_fds; +#endif /* def FD_SETSIZE */ +struct rpc_createerr rpc_createerr; diff -ruN glibc-1.07/sunrpc/rpc_cout.c glibc-1.08.1/sunrpc/rpc_cout.c --- glibc-1.07/sunrpc/rpc_cout.c +++ glibc-1.08.1/sunrpc/rpc_cout.c Sun Feb 6 22:15:41 1994 @@ -0,0 +1,350 @@ +/* @(#)rpc_cout.c 2.1 88/08/01 4.0 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +#ifndef lint +static char sccsid[] = "@(#)rpc_cout.c 1.8 87/06/24 (C) 1987 SMI"; +#endif + +/* + * rpc_cout.c, XDR routine outputter for the RPC protocol compiler + * Copyright (C) 1987, Sun Microsystems, Inc. + */ +#include +#include +#include "rpc_util.h" +#include "rpc_parse.h" + +/* + * Emit the C-routine for the given definition + */ +void +emit(def) + definition *def; +{ + if (def->def_kind == DEF_PROGRAM || def->def_kind == DEF_CONST) { + return; + } + print_header(def); + switch (def->def_kind) { + case DEF_UNION: + emit_union(def); + break; + case DEF_ENUM: + emit_enum(def); + break; + case DEF_STRUCT: + emit_struct(def); + break; + case DEF_TYPEDEF: + emit_typedef(def); + break; + } + print_trailer(); +} + +static +findtype(def, type) + definition *def; + char *type; +{ + if (def->def_kind == DEF_PROGRAM || def->def_kind == DEF_CONST) { + return (0); + } else { + return (streq(def->def_name, type)); + } +} + +static +undefined(type) + char *type; +{ + definition *def; + + def = (definition *) FINDVAL(defined, type, findtype); + return (def == NULL); +} + + +static +print_header(def) + definition *def; +{ + space(); + f_print(fout, "bool_t\n"); + f_print(fout, "xdr_%s(xdrs, objp)\n", def->def_name); + f_print(fout, "\tXDR *xdrs;\n"); + f_print(fout, "\t%s ", def->def_name); + if (def->def_kind != DEF_TYPEDEF || + !isvectordef(def->def.ty.old_type, def->def.ty.rel)) { + f_print(fout, "*"); + } + f_print(fout, "objp;\n"); + f_print(fout, "{\n"); +} + +static +print_trailer() +{ + f_print(fout, "\treturn (TRUE);\n"); + f_print(fout, "}\n"); + space(); +} + + +static +print_ifopen(indent, name) + int indent; + char *name; +{ + tabify(fout, indent); + f_print(fout, "if (!xdr_%s(xdrs", name); +} + + +static +print_ifarg(arg) + char *arg; +{ + f_print(fout, ", %s", arg); +} + + +static +print_ifsizeof(prefix, type) + char *prefix; + char *type; +{ + if (streq(type, "bool")) { + f_print(fout, ", sizeof(bool_t), xdr_bool"); + } else { + f_print(fout, ", sizeof("); + if (undefined(type) && prefix) { + f_print(fout, "%s ", prefix); + } + f_print(fout, "%s), xdr_%s", type, type); + } +} + +static +print_ifclose(indent) + int indent; +{ + f_print(fout, ")) {\n"); + tabify(fout, indent); + f_print(fout, "\treturn (FALSE);\n"); + tabify(fout, indent); + f_print(fout, "}\n"); +} + +static +space() +{ + f_print(fout, "\n\n"); +} + +static +print_ifstat(indent, prefix, type, rel, amax, objname, name) + int indent; + char *prefix; + char *type; + relation rel; + char *amax; + char *objname; + char *name; +{ + char *alt = NULL; + + switch (rel) { + case REL_POINTER: + print_ifopen(indent, "pointer"); + print_ifarg("(char **)"); + f_print(fout, "%s", objname); + print_ifsizeof(prefix, type); + break; + case REL_VECTOR: + if (streq(type, "string")) { + alt = "string"; + } else if (streq(type, "opaque")) { + alt = "opaque"; + } + if (alt) { + print_ifopen(indent, alt); + print_ifarg(objname); + } else { + print_ifopen(indent, "vector"); + print_ifarg("(char *)"); + f_print(fout, "%s", objname); + } + print_ifarg(amax); + if (!alt) { + print_ifsizeof(prefix, type); + } + break; + case REL_ARRAY: + if (streq(type, "string")) { + alt = "string"; + } else if (streq(type, "opaque")) { + alt = "bytes"; + } + if (streq(type, "string")) { + print_ifopen(indent, alt); + print_ifarg(objname); + } else { + if (alt) { + print_ifopen(indent, alt); + } else { + print_ifopen(indent, "array"); + } + print_ifarg("(char **)"); + if (*objname == '&') { + f_print(fout, "%s.%s_val, (u_int *)%s.%s_len", + objname, name, objname, name); + } else { + f_print(fout, "&%s->%s_val, (u_int *)&%s->%s_len", + objname, name, objname, name); + } + } + print_ifarg(amax); + if (!alt) { + print_ifsizeof(prefix, type); + } + break; + case REL_ALIAS: + print_ifopen(indent, type); + print_ifarg(objname); + break; + } + print_ifclose(indent); +} + + +/* ARGSUSED */ +static +emit_enum(def) + definition *def; +{ + print_ifopen(1, "enum"); + print_ifarg("(enum_t *)objp"); + print_ifclose(1); +} + + +static +emit_union(def) + definition *def; +{ + declaration *dflt; + case_list *cl; + declaration *cs; + char *object; + char *format = "&objp->%s_u.%s"; + + print_stat(&def->def.un.enum_decl); + f_print(fout, "\tswitch (objp->%s) {\n", def->def.un.enum_decl.name); + for (cl = def->def.un.cases; cl != NULL; cl = cl->next) { + cs = &cl->case_decl; + f_print(fout, "\tcase %s:\n", cl->case_name); + if (!streq(cs->type, "void")) { + object = alloc(strlen(def->def_name) + strlen(format) + + strlen(cs->name) + 1); + s_print(object, format, def->def_name, cs->name); + print_ifstat(2, cs->prefix, cs->type, cs->rel, cs->array_max, + object, cs->name); + free(object); + } + f_print(fout, "\t\tbreak;\n"); + } + dflt = def->def.un.default_decl; + if (dflt != NULL) { + if (!streq(dflt->type, "void")) { + f_print(fout, "\tdefault:\n"); + object = alloc(strlen(def->def_name) + strlen(format) + + strlen(dflt->name) + 1); + s_print(object, format, def->def_name, dflt->name); + print_ifstat(2, dflt->prefix, dflt->type, dflt->rel, + dflt->array_max, object, dflt->name); + free(object); + f_print(fout, "\t\tbreak;\n"); + } + } else { + f_print(fout, "\tdefault:\n"); + f_print(fout, "\t\treturn (FALSE);\n"); + } + f_print(fout, "\t}\n"); +} + + + +static +emit_struct(def) + definition *def; +{ + decl_list *dl; + + for (dl = def->def.st.decls; dl != NULL; dl = dl->next) { + print_stat(&dl->decl); + } +} + + + + +static +emit_typedef(def) + definition *def; +{ + char *prefix = def->def.ty.old_prefix; + char *type = def->def.ty.old_type; + char *amax = def->def.ty.array_max; + relation rel = def->def.ty.rel; + + print_ifstat(1, prefix, type, rel, amax, "objp", def->def_name); +} + + + + + +static +print_stat(dec) + declaration *dec; +{ + char *prefix = dec->prefix; + char *type = dec->type; + char *amax = dec->array_max; + relation rel = dec->rel; + char name[256]; + + if (isvectordef(type, rel)) { + s_print(name, "objp->%s", dec->name); + } else { + s_print(name, "&objp->%s", dec->name); + } + print_ifstat(1, prefix, type, rel, amax, name, dec->name); +} diff -ruN glibc-1.07/sunrpc/rpc_dtable.c glibc-1.08.1/sunrpc/rpc_dtable.c --- glibc-1.07/sunrpc/rpc_dtable.c +++ glibc-1.08.1/sunrpc/rpc_dtable.c Sun Feb 6 16:42:46 1994 @@ -0,0 +1,46 @@ +/* @(#)rpc_dtablesize.c 2.1 88/07/29 4.0 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +#if !defined(lint) && defined(SCCSIDS) +static char sccsid[] = "@(#)rpc_dtablesize.c 1.2 87/08/11 Copyr 1987 Sun Micro"; +#endif + +/* + * Cache the result of getdtablesize(), so we don't have to do an + * expensive system call every time. + */ +_rpc_dtablesize() +{ + static int size; + + if (size == 0) { + size = getdtablesize(); + } + return (size); +} diff -ruN glibc-1.07/sunrpc/rpc_hout.c glibc-1.08.1/sunrpc/rpc_hout.c --- glibc-1.07/sunrpc/rpc_hout.c +++ glibc-1.08.1/sunrpc/rpc_hout.c Sun Feb 6 22:15:41 1994 @@ -0,0 +1,370 @@ +/* @(#)rpc_hout.c 2.1 88/08/01 4.0 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +#ifndef lint +static char sccsid[] = "@(#)rpc_hout.c 1.6 87/07/28 (C) 1987 SMI"; +#endif + +/* + * rpc_hout.c, Header file outputter for the RPC protocol compiler + * Copyright (C) 1987, Sun Microsystems, Inc. + */ +#include +#include +#include "rpc_util.h" +#include "rpc_parse.h" + + +/* + * Print the C-version of an xdr definition + */ +void +print_datadef(def) + definition *def; +{ + if (def->def_kind != DEF_CONST) { + f_print(fout, "\n"); + } + switch (def->def_kind) { + case DEF_STRUCT: + pstructdef(def); + break; + case DEF_UNION: + puniondef(def); + break; + case DEF_ENUM: + penumdef(def); + break; + case DEF_TYPEDEF: + ptypedef(def); + break; + case DEF_PROGRAM: + pprogramdef(def); + break; + case DEF_CONST: + pconstdef(def); + break; + } + if (def->def_kind != DEF_PROGRAM && def->def_kind != DEF_CONST) { + f_print(fout, "bool_t xdr_%s();\n", def->def_name); + } + if (def->def_kind != DEF_CONST) { + f_print(fout, "\n"); + } +} + +static +pconstdef(def) + definition *def; +{ + pdefine(def->def_name, def->def.co); +} + +static +pstructdef(def) + definition *def; +{ + decl_list *l; + char *name = def->def_name; + + f_print(fout, "struct %s {\n", name); + for (l = def->def.st.decls; l != NULL; l = l->next) { + pdeclaration(name, &l->decl, 1); + } + f_print(fout, "};\n"); + f_print(fout, "typedef struct %s %s;\n", name, name); +} + +static +puniondef(def) + definition *def; +{ + case_list *l; + char *name = def->def_name; + declaration *decl; + + f_print(fout, "struct %s {\n", name); + decl = &def->def.un.enum_decl; + if (streq(decl->type, "bool")) { + f_print(fout, "\tbool_t %s;\n", decl->name); + } else { + f_print(fout, "\t%s %s;\n", decl->type, decl->name); + } + f_print(fout, "\tunion {\n"); + for (l = def->def.un.cases; l != NULL; l = l->next) { + pdeclaration(name, &l->case_decl, 2); + } + decl = def->def.un.default_decl; + if (decl && !streq(decl->type, "void")) { + pdeclaration(name, decl, 2); + } + f_print(fout, "\t} %s_u;\n", name); + f_print(fout, "};\n"); + f_print(fout, "typedef struct %s %s;\n", name, name); +} + + + +static +pdefine(name, num) + char *name; + char *num; +{ + f_print(fout, "#define %s %s\n", name, num); +} + +static +puldefine(name, num) + char *name; + char *num; +{ + f_print(fout, "#define %s ((u_long)%s)\n", name, num); +} + +static +define_printed(stop, start) + proc_list *stop; + version_list *start; +{ + version_list *vers; + proc_list *proc; + + for (vers = start; vers != NULL; vers = vers->next) { + for (proc = vers->procs; proc != NULL; proc = proc->next) { + if (proc == stop) { + return (0); + } else if (streq(proc->proc_name, stop->proc_name)) { + return (1); + } + } + } + abort(); + /* NOTREACHED */ +} + + +static +pprogramdef(def) + definition *def; +{ + version_list *vers; + proc_list *proc; + + puldefine(def->def_name, def->def.pr.prog_num); + for (vers = def->def.pr.versions; vers != NULL; vers = vers->next) { + puldefine(vers->vers_name, vers->vers_num); + for (proc = vers->procs; proc != NULL; proc = proc->next) { + if (!define_printed(proc, def->def.pr.versions)) { + puldefine(proc->proc_name, proc->proc_num); + } + pprocdef(proc, vers); + } + } +} + + +pprocdef(proc, vp) + proc_list *proc; + version_list *vp; +{ + f_print(fout, "extern "); + if (proc->res_prefix) { + if (streq(proc->res_prefix, "enum")) { + f_print(fout, "enum "); + } else { + f_print(fout, "struct "); + } + } + if (streq(proc->res_type, "bool")) { + f_print(fout, "bool_t *"); + } else if (streq(proc->res_type, "string")) { + f_print(fout, "char **"); + } else { + f_print(fout, "%s *", fixtype(proc->res_type)); + } + pvname(proc->proc_name, vp->vers_num); + f_print(fout, "();\n"); +} + +static +penumdef(def) + definition *def; +{ + char *name = def->def_name; + enumval_list *l; + char *last = NULL; + int count = 0; + + f_print(fout, "enum %s {\n", name); + for (l = def->def.en.vals; l != NULL; l = l->next) { + f_print(fout, "\t%s", l->name); + if (l->assignment) { + f_print(fout, " = %s", l->assignment); + last = l->assignment; + count = 1; + } else { + if (last == NULL) { + f_print(fout, " = %d", count++); + } else { + f_print(fout, " = %s + %d", last, count++); + } + } + f_print(fout, ",\n"); + } + f_print(fout, "};\n"); + f_print(fout, "typedef enum %s %s;\n", name, name); +} + +static +ptypedef(def) + definition *def; +{ + char *name = def->def_name; + char *old = def->def.ty.old_type; + char prefix[8]; /* enough to contain "struct ", including NUL */ + relation rel = def->def.ty.rel; + + + if (!streq(name, old)) { + if (streq(old, "string")) { + old = "char"; + rel = REL_POINTER; + } else if (streq(old, "opaque")) { + old = "char"; + } else if (streq(old, "bool")) { + old = "bool_t"; + } + if (undefined2(old, name) && def->def.ty.old_prefix) { + s_print(prefix, "%s ", def->def.ty.old_prefix); + } else { + prefix[0] = 0; + } + f_print(fout, "typedef "); + switch (rel) { + case REL_ARRAY: + f_print(fout, "struct {\n"); + f_print(fout, "\tu_int %s_len;\n", name); + f_print(fout, "\t%s%s *%s_val;\n", prefix, old, name); + f_print(fout, "} %s", name); + break; + case REL_POINTER: + f_print(fout, "%s%s *%s", prefix, old, name); + break; + case REL_VECTOR: + f_print(fout, "%s%s %s[%s]", prefix, old, name, + def->def.ty.array_max); + break; + case REL_ALIAS: + f_print(fout, "%s%s %s", prefix, old, name); + break; + } + f_print(fout, ";\n"); + } +} + + +static +pdeclaration(name, dec, tab) + char *name; + declaration *dec; + int tab; +{ + char buf[8]; /* enough to hold "struct ", include NUL */ + char *prefix; + char *type; + + if (streq(dec->type, "void")) { + return; + } + tabify(fout, tab); + if (streq(dec->type, name) && !dec->prefix) { + f_print(fout, "struct "); + } + if (streq(dec->type, "string")) { + f_print(fout, "char *%s", dec->name); + } else { + prefix = ""; + if (streq(dec->type, "bool")) { + type = "bool_t"; + } else if (streq(dec->type, "opaque")) { + type = "char"; + } else { + if (dec->prefix) { + s_print(buf, "%s ", dec->prefix); + prefix = buf; + } + type = dec->type; + } + switch (dec->rel) { + case REL_ALIAS: + f_print(fout, "%s%s %s", prefix, type, dec->name); + break; + case REL_VECTOR: + f_print(fout, "%s%s %s[%s]", prefix, type, dec->name, + dec->array_max); + break; + case REL_POINTER: + f_print(fout, "%s%s *%s", prefix, type, dec->name); + break; + case REL_ARRAY: + f_print(fout, "struct {\n"); + tabify(fout, tab); + f_print(fout, "\tu_int %s_len;\n", dec->name); + tabify(fout, tab); + f_print(fout, "\t%s%s *%s_val;\n", prefix, type, dec->name); + tabify(fout, tab); + f_print(fout, "} %s", dec->name); + break; + } + } + f_print(fout, ";\n"); +} + + + +static +undefined2(type, stop) + char *type; + char *stop; +{ + list *l; + definition *def; + + for (l = defined; l != NULL; l = l->next) { + def = (definition *) l->val; + if (def->def_kind != DEF_PROGRAM) { + if (streq(def->def_name, stop)) { + return (1); + } else if (streq(def->def_name, type)) { + return (0); + } + } + } + return (1); +} diff -ruN glibc-1.07/sunrpc/rpc_main.c glibc-1.08.1/sunrpc/rpc_main.c --- glibc-1.07/sunrpc/rpc_main.c +++ glibc-1.08.1/sunrpc/rpc_main.c Sun Feb 6 22:15:41 1994 @@ -0,0 +1,433 @@ +/* @(#)rpc_main.c 2.2 88/08/01 4.0 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +#ifndef lint +static char sccsid[] = "@(#)rpc_main.c 1.7 87/06/24 (C) 1987 SMI"; +#endif + +/* + * rpc_main.c, Top level of the RPC protocol compiler. + * Copyright (C) 1987, Sun Microsystems, Inc. + */ + +#include +#include +#include +#include "rpc_util.h" +#include "rpc_parse.h" +#include "rpc_scan.h" + +#define EXTEND 1 /* alias for TRUE */ + +struct commandline { + int cflag; + int hflag; + int lflag; + int sflag; + int mflag; + char *infile; + char *outfile; +}; + +static char *cmdname; +static char CPP[] = "/lib/cpp"; +static char CPPFLAGS[] = "-C"; +static char *allv[] = { + "rpcgen", "-s", "udp", "-s", "tcp", +}; +static int allc = sizeof(allv)/sizeof(allv[0]); + +main(argc, argv) + int argc; + char *argv[]; + +{ + struct commandline cmd; + + if (!parseargs(argc, argv, &cmd)) { + f_print(stderr, + "usage: %s infile\n", cmdname); + f_print(stderr, + " %s [-c | -h | -l | -m] [-o outfile] [infile]\n", + cmdname); + f_print(stderr, + " %s [-s udp|tcp]* [-o outfile] [infile]\n", + cmdname); + exit(1); + } + if (cmd.cflag) { + c_output(cmd.infile, "-DRPC_XDR", !EXTEND, cmd.outfile); + } else if (cmd.hflag) { + h_output(cmd.infile, "-DRPC_HDR", !EXTEND, cmd.outfile); + } else if (cmd.lflag) { + l_output(cmd.infile, "-DRPC_CLNT", !EXTEND, cmd.outfile); + } else if (cmd.sflag || cmd.mflag) { + s_output(argc, argv, cmd.infile, "-DRPC_SVC", !EXTEND, + cmd.outfile, cmd.mflag); + } else { + c_output(cmd.infile, "-DRPC_XDR", EXTEND, "_xdr.c"); + reinitialize(); + h_output(cmd.infile, "-DRPC_HDR", EXTEND, ".h"); + reinitialize(); + l_output(cmd.infile, "-DRPC_CLNT", EXTEND, "_clnt.c"); + reinitialize(); + s_output(allc, allv, cmd.infile, "-DRPC_SVC", EXTEND, + "_svc.c", cmd.mflag); + } + exit(0); +} + +/* + * add extension to filename + */ +static char * +extendfile(file, ext) + char *file; + char *ext; +{ + char *res; + char *p; + + res = alloc(strlen(file) + strlen(ext) + 1); + if (res == NULL) { + abort(); + } + p = rindex(file, '.'); + if (p == NULL) { + p = file + strlen(file); + } + (void) strcpy(res, file); + (void) strcpy(res + (p - file), ext); + return (res); +} + +/* + * Open output file with given extension + */ +static +open_output(infile, outfile) + char *infile; + char *outfile; +{ + if (outfile == NULL) { + fout = stdout; + return; + } + if (infile != NULL && streq(outfile, infile)) { + f_print(stderr, "%s: output would overwrite %s\n", cmdname, + infile); + crash(); + } + fout = fopen(outfile, "w"); + if (fout == NULL) { + f_print(stderr, "%s: unable to open ", cmdname); + perror(outfile); + crash(); + } + record_open(outfile); +} + +/* + * Open input file with given define for C-preprocessor + */ +static +open_input(infile, define) + char *infile; + char *define; +{ + int pd[2]; + + infilename = (infile == NULL) ? "" : infile; + (void) pipe(pd); + switch (fork()) { + case 0: + (void) close(1); + (void) dup2(pd[1], 1); + (void) close(pd[0]); + execl(CPP, CPP, CPPFLAGS, define, infile, NULL); + perror("execl"); + exit(1); + case -1: + perror("fork"); + exit(1); + } + (void) close(pd[1]); + fin = fdopen(pd[0], "r"); + if (fin == NULL) { + f_print(stderr, "%s: ", cmdname); + perror(infilename); + crash(); + } +} + +/* + * Compile into an XDR routine output file + */ +static +c_output(infile, define, extend, outfile) + char *infile; + char *define; + int extend; + char *outfile; +{ + definition *def; + char *include; + char *outfilename; + long tell; + + open_input(infile, define); + outfilename = extend ? extendfile(infile, outfile) : outfile; + open_output(infile, outfilename); + f_print(fout, "#include \n"); + if (infile && (include = extendfile(infile, ".h"))) { + f_print(fout, "#include \"%s\"\n", include); + free(include); + } + tell = ftell(fout); + while (def = get_definition()) { + emit(def); + } + if (extend && tell == ftell(fout)) { + (void) unlink(outfilename); + } +} + +/* + * Compile into an XDR header file + */ +static +h_output(infile, define, extend, outfile) + char *infile; + char *define; + int extend; + char *outfile; +{ + definition *def; + char *outfilename; + long tell; + + open_input(infile, define); + outfilename = extend ? extendfile(infile, outfile) : outfile; + open_output(infile, outfilename); + tell = ftell(fout); + while (def = get_definition()) { + print_datadef(def); + } + if (extend && tell == ftell(fout)) { + (void) unlink(outfilename); + } +} + +/* + * Compile into an RPC service + */ +static +s_output(argc, argv, infile, define, extend, outfile, nomain) + int argc; + char *argv[]; + char *infile; + char *define; + int extend; + char *outfile; + int nomain; +{ + char *include; + definition *def; + int foundprogram; + char *outfilename; + + open_input(infile, define); + outfilename = extend ? extendfile(infile, outfile) : outfile; + open_output(infile, outfilename); + f_print(fout, "#include \n"); + f_print(fout, "#include \n"); + if (infile && (include = extendfile(infile, ".h"))) { + f_print(fout, "#include \"%s\"\n", include); + free(include); + } + foundprogram = 0; + while (def = get_definition()) { + foundprogram |= (def->def_kind == DEF_PROGRAM); + } + if (extend && !foundprogram) { + (void) unlink(outfilename); + return; + } + if (nomain) { + write_programs((char *)NULL); + } else { + write_most(); + do_registers(argc, argv); + write_rest(); + write_programs("static"); + } +} + +static +l_output(infile, define, extend, outfile) + char *infile; + char *define; + int extend; + char *outfile; +{ + char *include; + definition *def; + int foundprogram; + char *outfilename; + + open_input(infile, define); + outfilename = extend ? extendfile(infile, outfile) : outfile; + open_output(infile, outfilename); + f_print(fout, "#include \n"); + if (infile && (include = extendfile(infile, ".h"))) { + f_print(fout, "#include \"%s\"\n", include); + free(include); + } + foundprogram = 0; + while (def = get_definition()) { + foundprogram |= (def->def_kind == DEF_PROGRAM); + } + if (extend && !foundprogram) { + (void) unlink(outfilename); + return; + } + write_stubs(); +} + +/* + * Perform registrations for service output + */ +static +do_registers(argc, argv) + int argc; + char *argv[]; + +{ + int i; + + for (i = 1; i < argc; i++) { + if (streq(argv[i], "-s")) { + write_register(argv[i + 1]); + i++; + } + } +} + +/* + * Parse command line arguments + */ +static +parseargs(argc, argv, cmd) + int argc; + char *argv[]; + struct commandline *cmd; + +{ + int i; + int j; + char c; + char flag[(1 << 8 * sizeof(char))]; + int nflags; + + cmdname = argv[0]; + cmd->infile = cmd->outfile = NULL; + if (argc < 2) { + return (0); + } + flag['c'] = 0; + flag['h'] = 0; + flag['s'] = 0; + flag['o'] = 0; + flag['l'] = 0; + flag['m'] = 0; + for (i = 1; i < argc; i++) { + if (argv[i][0] != '-') { + if (cmd->infile) { + return (0); + } + cmd->infile = argv[i]; + } else { + for (j = 1; argv[i][j] != 0; j++) { + c = argv[i][j]; + switch (c) { + case 'c': + case 'h': + case 'l': + case 'm': + if (flag[c]) { + return (0); + } + flag[c] = 1; + break; + case 'o': + case 's': + if (argv[i][j - 1] != '-' || + argv[i][j + 1] != 0) { + return (0); + } + flag[c] = 1; + if (++i == argc) { + return (0); + } + if (c == 's') { + if (!streq(argv[i], "udp") && + !streq(argv[i], "tcp")) { + return (0); + } + } else if (c == 'o') { + if (cmd->outfile) { + return (0); + } + cmd->outfile = argv[i]; + } + goto nextarg; + + default: + return (0); + } + } + nextarg: + ; + } + } + cmd->cflag = flag['c']; + cmd->hflag = flag['h']; + cmd->sflag = flag['s']; + cmd->lflag = flag['l']; + cmd->mflag = flag['m']; + nflags = cmd->cflag + cmd->hflag + cmd->sflag + cmd->lflag + cmd->mflag; + if (nflags == 0) { + if (cmd->outfile != NULL || cmd->infile == NULL) { + return (0); + } + } else if (nflags > 1) { + return (0); + } + return (1); +} diff -ruN glibc-1.07/sunrpc/rpc_parse.c glibc-1.08.1/sunrpc/rpc_parse.c --- glibc-1.07/sunrpc/rpc_parse.c +++ glibc-1.08.1/sunrpc/rpc_parse.c Sun Feb 6 22:15:41 1994 @@ -0,0 +1,419 @@ +/* @(#)rpc_parse.c 2.1 88/08/01 4.0 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +#ifndef lint +static char sccsid[] = "@(#)rpc_parse.c 1.4 87/04/28 (C) 1987 SMI"; +#endif + +/* + * rpc_parse.c, Parser for the RPC protocol compiler + * Copyright (C) 1987 Sun Microsystems, Inc. + */ +#include +#include "rpc_util.h" +#include "rpc_scan.h" +#include "rpc_parse.h" + +/* + * return the next definition you see + */ +definition * +get_definition() +{ + definition *defp; + token tok; + + defp = ALLOC(definition); + get_token(&tok); + switch (tok.kind) { + case TOK_STRUCT: + def_struct(defp); + break; + case TOK_UNION: + def_union(defp); + break; + case TOK_TYPEDEF: + def_typedef(defp); + break; + case TOK_ENUM: + def_enum(defp); + break; + case TOK_PROGRAM: + def_program(defp); + break; + case TOK_CONST: + def_const(defp); + break; + case TOK_EOF: + return (NULL); + break; + default: + error("definition keyword expected"); + } + scan(TOK_SEMICOLON, &tok); + isdefined(defp); + return (defp); +} + +static +isdefined(defp) + definition *defp; +{ + STOREVAL(&defined, defp); +} + + +static +def_struct(defp) + definition *defp; +{ + token tok; + declaration dec; + decl_list *decls; + decl_list **tailp; + + defp->def_kind = DEF_STRUCT; + + scan(TOK_IDENT, &tok); + defp->def_name = tok.str; + scan(TOK_LBRACE, &tok); + tailp = &defp->def.st.decls; + do { + get_declaration(&dec, DEF_STRUCT); + decls = ALLOC(decl_list); + decls->decl = dec; + *tailp = decls; + tailp = &decls->next; + scan(TOK_SEMICOLON, &tok); + peek(&tok); + } while (tok.kind != TOK_RBRACE); + get_token(&tok); + *tailp = NULL; +} + +static +def_program(defp) + definition *defp; +{ + token tok; + version_list *vlist; + version_list **vtailp; + proc_list *plist; + proc_list **ptailp; + + defp->def_kind = DEF_PROGRAM; + scan(TOK_IDENT, &tok); + defp->def_name = tok.str; + scan(TOK_LBRACE, &tok); + vtailp = &defp->def.pr.versions; + scan(TOK_VERSION, &tok); + do { + scan(TOK_IDENT, &tok); + vlist = ALLOC(version_list); + vlist->vers_name = tok.str; + scan(TOK_LBRACE, &tok); + ptailp = &vlist->procs; + do { + plist = ALLOC(proc_list); + get_type(&plist->res_prefix, &plist->res_type, DEF_PROGRAM); + if (streq(plist->res_type, "opaque")) { + error("illegal result type"); + } + scan(TOK_IDENT, &tok); + plist->proc_name = tok.str; + scan(TOK_LPAREN, &tok); + get_type(&plist->arg_prefix, &plist->arg_type, DEF_PROGRAM); + if (streq(plist->arg_type, "opaque")) { + error("illegal argument type"); + } + scan(TOK_RPAREN, &tok); + scan(TOK_EQUAL, &tok); + scan_num(&tok); + scan(TOK_SEMICOLON, &tok); + plist->proc_num = tok.str; + *ptailp = plist; + ptailp = &plist->next; + peek(&tok); + } while (tok.kind != TOK_RBRACE); + *vtailp = vlist; + vtailp = &vlist->next; + scan(TOK_RBRACE, &tok); + scan(TOK_EQUAL, &tok); + scan_num(&tok); + vlist->vers_num = tok.str; + scan(TOK_SEMICOLON, &tok); + scan2(TOK_VERSION, TOK_RBRACE, &tok); + } while (tok.kind == TOK_VERSION); + scan(TOK_EQUAL, &tok); + scan_num(&tok); + defp->def.pr.prog_num = tok.str; + *vtailp = NULL; +} + +static +def_enum(defp) + definition *defp; +{ + token tok; + enumval_list *elist; + enumval_list **tailp; + + defp->def_kind = DEF_ENUM; + scan(TOK_IDENT, &tok); + defp->def_name = tok.str; + scan(TOK_LBRACE, &tok); + tailp = &defp->def.en.vals; + do { + scan(TOK_IDENT, &tok); + elist = ALLOC(enumval_list); + elist->name = tok.str; + elist->assignment = NULL; + scan3(TOK_COMMA, TOK_RBRACE, TOK_EQUAL, &tok); + if (tok.kind == TOK_EQUAL) { + scan_num(&tok); + elist->assignment = tok.str; + scan2(TOK_COMMA, TOK_RBRACE, &tok); + } + *tailp = elist; + tailp = &elist->next; + } while (tok.kind != TOK_RBRACE); + *tailp = NULL; +} + +static +def_const(defp) + definition *defp; +{ + token tok; + + defp->def_kind = DEF_CONST; + scan(TOK_IDENT, &tok); + defp->def_name = tok.str; + scan(TOK_EQUAL, &tok); + scan2(TOK_IDENT, TOK_STRCONST, &tok); + defp->def.co = tok.str; +} + +static +def_union(defp) + definition *defp; +{ + token tok; + declaration dec; + case_list *cases; + case_list **tailp; + + defp->def_kind = DEF_UNION; + scan(TOK_IDENT, &tok); + defp->def_name = tok.str; + scan(TOK_SWITCH, &tok); + scan(TOK_LPAREN, &tok); + get_declaration(&dec, DEF_UNION); + defp->def.un.enum_decl = dec; + tailp = &defp->def.un.cases; + scan(TOK_RPAREN, &tok); + scan(TOK_LBRACE, &tok); + scan(TOK_CASE, &tok); + while (tok.kind == TOK_CASE) { + scan(TOK_IDENT, &tok); + cases = ALLOC(case_list); + cases->case_name = tok.str; + scan(TOK_COLON, &tok); + get_declaration(&dec, DEF_UNION); + cases->case_decl = dec; + *tailp = cases; + tailp = &cases->next; + scan(TOK_SEMICOLON, &tok); + scan3(TOK_CASE, TOK_DEFAULT, TOK_RBRACE, &tok); + } + *tailp = NULL; + if (tok.kind == TOK_DEFAULT) { + scan(TOK_COLON, &tok); + get_declaration(&dec, DEF_UNION); + defp->def.un.default_decl = ALLOC(declaration); + *defp->def.un.default_decl = dec; + scan(TOK_SEMICOLON, &tok); + scan(TOK_RBRACE, &tok); + } else { + defp->def.un.default_decl = NULL; + } +} + + +static +def_typedef(defp) + definition *defp; +{ + declaration dec; + + defp->def_kind = DEF_TYPEDEF; + get_declaration(&dec, DEF_TYPEDEF); + defp->def_name = dec.name; + defp->def.ty.old_prefix = dec.prefix; + defp->def.ty.old_type = dec.type; + defp->def.ty.rel = dec.rel; + defp->def.ty.array_max = dec.array_max; +} + + +static +get_declaration(dec, dkind) + declaration *dec; + defkind dkind; +{ + token tok; + + get_type(&dec->prefix, &dec->type, dkind); + dec->rel = REL_ALIAS; + if (streq(dec->type, "void")) { + return; + } + scan2(TOK_STAR, TOK_IDENT, &tok); + if (tok.kind == TOK_STAR) { + dec->rel = REL_POINTER; + scan(TOK_IDENT, &tok); + } + dec->name = tok.str; + if (peekscan(TOK_LBRACKET, &tok)) { + if (dec->rel == REL_POINTER) { + error("no array-of-pointer declarations -- use typedef"); + } + dec->rel = REL_VECTOR; + scan_num(&tok); + dec->array_max = tok.str; + scan(TOK_RBRACKET, &tok); + } else if (peekscan(TOK_LANGLE, &tok)) { + if (dec->rel == REL_POINTER) { + error("no array-of-pointer declarations -- use typedef"); + } + dec->rel = REL_ARRAY; + if (peekscan(TOK_RANGLE, &tok)) { + dec->array_max = "~0"; /* unspecified size, use max */ + } else { + scan_num(&tok); + dec->array_max = tok.str; + scan(TOK_RANGLE, &tok); + } + } + if (streq(dec->type, "opaque")) { + if (dec->rel != REL_ARRAY && dec->rel != REL_VECTOR) { + error("array declaration expected"); + } + } else if (streq(dec->type, "string")) { + if (dec->rel != REL_ARRAY) { + error("variable-length array declaration expected"); + } + } +} + + +static +get_type(prefixp, typep, dkind) + char **prefixp; + char **typep; + defkind dkind; +{ + token tok; + + *prefixp = NULL; + get_token(&tok); + switch (tok.kind) { + case TOK_IDENT: + *typep = tok.str; + break; + case TOK_STRUCT: + case TOK_ENUM: + case TOK_UNION: + *prefixp = tok.str; + scan(TOK_IDENT, &tok); + *typep = tok.str; + break; + case TOK_UNSIGNED: + unsigned_dec(typep); + break; + case TOK_SHORT: + *typep = "short"; + (void) peekscan(TOK_INT, &tok); + break; + case TOK_LONG: + *typep = "long"; + (void) peekscan(TOK_INT, &tok); + break; + case TOK_VOID: + if (dkind != DEF_UNION && dkind != DEF_PROGRAM) { + error("voids allowed only inside union and program definitions"); + } + *typep = tok.str; + break; + case TOK_STRING: + case TOK_OPAQUE: + case TOK_CHAR: + case TOK_INT: + case TOK_FLOAT: + case TOK_DOUBLE: + case TOK_BOOL: + *typep = tok.str; + break; + default: + error("expected type specifier"); + } +} + + +static +unsigned_dec(typep) + char **typep; +{ + token tok; + + peek(&tok); + switch (tok.kind) { + case TOK_CHAR: + get_token(&tok); + *typep = "u_char"; + break; + case TOK_SHORT: + get_token(&tok); + *typep = "u_short"; + (void) peekscan(TOK_INT, &tok); + break; + case TOK_LONG: + get_token(&tok); + *typep = "u_long"; + (void) peekscan(TOK_INT, &tok); + break; + case TOK_INT: + get_token(&tok); + *typep = "u_int"; + break; + default: + *typep = "u_int"; + break; + } +} diff -ruN glibc-1.07/sunrpc/rpc_parse.h glibc-1.08.1/sunrpc/rpc_parse.h --- glibc-1.07/sunrpc/rpc_parse.h +++ glibc-1.08.1/sunrpc/rpc_parse.h Sun Feb 6 22:15:42 1994 @@ -0,0 +1,157 @@ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +/* @(#)rpc_parse.h 1.3 87/03/09 (C) 1987 SMI */ + +/* + * rpc_parse.h, Definitions for the RPCL parser + * Copyright (C) 1987, Sun Microsystems, Inc. + */ + +enum defkind { + DEF_CONST, + DEF_STRUCT, + DEF_UNION, + DEF_ENUM, + DEF_TYPEDEF, + DEF_PROGRAM +}; +typedef enum defkind defkind; + +typedef char *const_def; + +enum relation { + REL_VECTOR, /* fixed length array */ + REL_ARRAY, /* variable length array */ + REL_POINTER, /* pointer */ + REL_ALIAS, /* simple */ +}; +typedef enum relation relation; + +struct typedef_def { + char *old_prefix; + char *old_type; + relation rel; + char *array_max; +}; +typedef struct typedef_def typedef_def; + + +struct enumval_list { + char *name; + char *assignment; + struct enumval_list *next; +}; +typedef struct enumval_list enumval_list; + +struct enum_def { + enumval_list *vals; +}; +typedef struct enum_def enum_def; + + +struct declaration { + char *prefix; + char *type; + char *name; + relation rel; + char *array_max; +}; +typedef struct declaration declaration; + + +struct decl_list { + declaration decl; + struct decl_list *next; +}; +typedef struct decl_list decl_list; + +struct struct_def { + decl_list *decls; +}; +typedef struct struct_def struct_def; + + +struct case_list { + char *case_name; + declaration case_decl; + struct case_list *next; +}; +typedef struct case_list case_list; + +struct union_def { + declaration enum_decl; + case_list *cases; + declaration *default_decl; +}; +typedef struct union_def union_def; + + + +struct proc_list { + char *proc_name; + char *proc_num; + char *arg_type; + char *arg_prefix; + char *res_type; + char *res_prefix; + struct proc_list *next; +}; +typedef struct proc_list proc_list; + + +struct version_list { + char *vers_name; + char *vers_num; + proc_list *procs; + struct version_list *next; +}; +typedef struct version_list version_list; + +struct program_def { + char *prog_num; + version_list *versions; +}; +typedef struct program_def program_def; + +struct definition { + char *def_name; + defkind def_kind; + union { + const_def co; + struct_def st; + union_def un; + enum_def en; + typedef_def ty; + program_def pr; + } def; +}; +typedef struct definition definition; + +/* @(#)rpc_parse.h 2.1 88/08/01 4.0 RPCSRC */ +definition *get_definition(); diff -ruN glibc-1.07/sunrpc/rpc_prot.c glibc-1.08.1/sunrpc/rpc_prot.c --- glibc-1.07/sunrpc/rpc_prot.c +++ glibc-1.08.1/sunrpc/rpc_prot.c Sun Feb 6 16:42:47 1994 @@ -0,0 +1,289 @@ +/* @(#)rpc_prot.c 2.3 88/08/07 4.0 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +#if !defined(lint) && defined(SCCSIDS) +static char sccsid[] = "@(#)rpc_prot.c 1.36 87/08/11 Copyr 1984 Sun Micro"; +#endif + +/* + * rpc_prot.c + * + * Copyright (C) 1984, Sun Microsystems, Inc. + * + * This set of routines implements the rpc message definition, + * its serializer and some common rpc utility routines. + * The routines are meant for various implementations of rpc - + * they are NOT for the rpc client or rpc service implementations! + * Because authentication stuff is easy and is part of rpc, the opaque + * routines are also in this program. + */ + +#include + +#include + +/* * * * * * * * * * * * * * XDR Authentication * * * * * * * * * * * */ + +struct opaque_auth _null_auth; + +/* + * XDR an opaque authentication struct + * (see auth.h) + */ +bool_t +xdr_opaque_auth(xdrs, ap) + register XDR *xdrs; + register struct opaque_auth *ap; +{ + + if (xdr_enum(xdrs, &(ap->oa_flavor))) + return (xdr_bytes(xdrs, &ap->oa_base, + &ap->oa_length, MAX_AUTH_BYTES)); + return (FALSE); +} + +/* + * XDR a DES block + */ +bool_t +xdr_des_block(xdrs, blkp) + register XDR *xdrs; + register des_block *blkp; +{ + return (xdr_opaque(xdrs, (caddr_t)blkp, sizeof(des_block))); +} + +/* * * * * * * * * * * * * * XDR RPC MESSAGE * * * * * * * * * * * * * * * */ + +/* + * XDR the MSG_ACCEPTED part of a reply message union + */ +bool_t +xdr_accepted_reply(xdrs, ar) + register XDR *xdrs; + register struct accepted_reply *ar; +{ + + /* personalized union, rather than calling xdr_union */ + if (! xdr_opaque_auth(xdrs, &(ar->ar_verf))) + return (FALSE); + if (! xdr_enum(xdrs, (enum_t *)&(ar->ar_stat))) + return (FALSE); + switch (ar->ar_stat) { + + case SUCCESS: + return ((*(ar->ar_results.proc))(xdrs, ar->ar_results.where)); + + case PROG_MISMATCH: + if (! xdr_u_long(xdrs, &(ar->ar_vers.low))) + return (FALSE); + return (xdr_u_long(xdrs, &(ar->ar_vers.high))); + } + return (TRUE); /* TRUE => open ended set of problems */ +} + +/* + * XDR the MSG_DENIED part of a reply message union + */ +bool_t +xdr_rejected_reply(xdrs, rr) + register XDR *xdrs; + register struct rejected_reply *rr; +{ + + /* personalized union, rather than calling xdr_union */ + if (! xdr_enum(xdrs, (enum_t *)&(rr->rj_stat))) + return (FALSE); + switch (rr->rj_stat) { + + case RPC_MISMATCH: + if (! xdr_u_long(xdrs, &(rr->rj_vers.low))) + return (FALSE); + return (xdr_u_long(xdrs, &(rr->rj_vers.high))); + + case AUTH_ERROR: + return (xdr_enum(xdrs, (enum_t *)&(rr->rj_why))); + } + return (FALSE); +} + +static struct xdr_discrim reply_dscrm[3] = { + { (int)MSG_ACCEPTED, xdr_accepted_reply }, + { (int)MSG_DENIED, xdr_rejected_reply }, + { __dontcare__, NULL_xdrproc_t } }; + +/* + * XDR a reply message + */ +bool_t +xdr_replymsg(xdrs, rmsg) + register XDR *xdrs; + register struct rpc_msg *rmsg; +{ + if ( + xdr_u_long(xdrs, &(rmsg->rm_xid)) && + xdr_enum(xdrs, (enum_t *)&(rmsg->rm_direction)) && + (rmsg->rm_direction == REPLY) ) + return (xdr_union(xdrs, (enum_t *)&(rmsg->rm_reply.rp_stat), + (caddr_t)&(rmsg->rm_reply.ru), reply_dscrm, NULL_xdrproc_t)); + return (FALSE); +} + + +/* + * Serializes the "static part" of a call message header. + * The fields include: rm_xid, rm_direction, rpcvers, prog, and vers. + * The rm_xid is not really static, but the user can easily munge on the fly. + */ +bool_t +xdr_callhdr(xdrs, cmsg) + register XDR *xdrs; + register struct rpc_msg *cmsg; +{ + + cmsg->rm_direction = CALL; + cmsg->rm_call.cb_rpcvers = RPC_MSG_VERSION; + if ( + (xdrs->x_op == XDR_ENCODE) && + xdr_u_long(xdrs, &(cmsg->rm_xid)) && + xdr_enum(xdrs, (enum_t *)&(cmsg->rm_direction)) && + xdr_u_long(xdrs, &(cmsg->rm_call.cb_rpcvers)) && + xdr_u_long(xdrs, &(cmsg->rm_call.cb_prog)) ) + return (xdr_u_long(xdrs, &(cmsg->rm_call.cb_vers))); + return (FALSE); +} + +/* ************************** Client utility routine ************* */ + +static void +accepted(acpt_stat, error) + register enum accept_stat acpt_stat; + register struct rpc_err *error; +{ + + switch (acpt_stat) { + + case PROG_UNAVAIL: + error->re_status = RPC_PROGUNAVAIL; + return; + + case PROG_MISMATCH: + error->re_status = RPC_PROGVERSMISMATCH; + return; + + case PROC_UNAVAIL: + error->re_status = RPC_PROCUNAVAIL; + return; + + case GARBAGE_ARGS: + error->re_status = RPC_CANTDECODEARGS; + return; + + case SYSTEM_ERR: + error->re_status = RPC_SYSTEMERROR; + return; + + case SUCCESS: + error->re_status = RPC_SUCCESS; + return; + } + /* something's wrong, but we don't know what ... */ + error->re_status = RPC_FAILED; + error->re_lb.s1 = (long)MSG_ACCEPTED; + error->re_lb.s2 = (long)acpt_stat; +} + +static void +rejected(rjct_stat, error) + register enum reject_stat rjct_stat; + register struct rpc_err *error; +{ + + switch (rjct_stat) { + + case RPC_VERSMISMATCH: + error->re_status = RPC_VERSMISMATCH; + return; + + case AUTH_ERROR: + error->re_status = RPC_AUTHERROR; + return; + } + /* something's wrong, but we don't know what ... */ + error->re_status = RPC_FAILED; + error->re_lb.s1 = (long)MSG_DENIED; + error->re_lb.s2 = (long)rjct_stat; +} + +/* + * given a reply message, fills in the error + */ +void +_seterr_reply(msg, error) + register struct rpc_msg *msg; + register struct rpc_err *error; +{ + + /* optimized for normal, SUCCESSful case */ + switch (msg->rm_reply.rp_stat) { + + case MSG_ACCEPTED: + if (msg->acpted_rply.ar_stat == SUCCESS) { + error->re_status = RPC_SUCCESS; + return; + }; + accepted(msg->acpted_rply.ar_stat, error); + break; + + case MSG_DENIED: + rejected(msg->rjcted_rply.rj_stat, error); + break; + + default: + error->re_status = RPC_FAILED; + error->re_lb.s1 = (long)(msg->rm_reply.rp_stat); + break; + } + switch (error->re_status) { + + case RPC_VERSMISMATCH: + error->re_vers.low = msg->rjcted_rply.rj_vers.low; + error->re_vers.high = msg->rjcted_rply.rj_vers.high; + break; + + case RPC_AUTHERROR: + error->re_why = msg->rjcted_rply.rj_why; + break; + + case RPC_PROGVERSMISMATCH: + error->re_vers.low = msg->acpted_rply.ar_vers.low; + error->re_vers.high = msg->acpted_rply.ar_vers.high; + break; + } +} diff -ruN glibc-1.07/sunrpc/rpc_scan.c glibc-1.08.1/sunrpc/rpc_scan.c --- glibc-1.07/sunrpc/rpc_scan.c +++ glibc-1.08.1/sunrpc/rpc_scan.c Sun Feb 6 22:15:42 1994 @@ -0,0 +1,473 @@ +/* @(#)rpc_scan.c 2.1 88/08/01 4.0 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +#ifndef lint +static char sccsid[] = "@(#)rpc_scan.c 1.6 87/06/24 (C) 1987 SMI"; +#endif + +/* + * rpc_scan.c, Scanner for the RPC protocol compiler + * Copyright (C) 1987, Sun Microsystems, Inc. + */ +#include +#include +#include +#include "rpc_scan.h" +#include "rpc_util.h" + +#define startcomment(where) (where[0] == '/' && where[1] == '*') +#define endcomment(where) (where[-1] == '*' && where[0] == '/') + +static int pushed = 0; /* is a token pushed */ +static token lasttok; /* last token, if pushed */ + +/* + * scan expecting 1 given token + */ +void +scan(expect, tokp) + tok_kind expect; + token *tokp; +{ + get_token(tokp); + if (tokp->kind != expect) { + expected1(expect); + } +} + +/* + * scan expecting 2 given tokens + */ +void +scan2(expect1, expect2, tokp) + tok_kind expect1; + tok_kind expect2; + token *tokp; +{ + get_token(tokp); + if (tokp->kind != expect1 && tokp->kind != expect2) { + expected2(expect1, expect2); + } +} + +/* + * scan expecting 3 given token + */ +void +scan3(expect1, expect2, expect3, tokp) + tok_kind expect1; + tok_kind expect2; + tok_kind expect3; + token *tokp; +{ + get_token(tokp); + if (tokp->kind != expect1 && tokp->kind != expect2 + && tokp->kind != expect3) { + expected3(expect1, expect2, expect3); + } +} + + +/* + * scan expecting a constant, possibly symbolic + */ +void +scan_num(tokp) + token *tokp; +{ + get_token(tokp); + switch (tokp->kind) { + case TOK_IDENT: + break; + default: + error("constant or identifier expected"); + } +} + + +/* + * Peek at the next token + */ +void +peek(tokp) + token *tokp; +{ + get_token(tokp); + unget_token(tokp); +} + + +/* + * Peek at the next token and scan it if it matches what you expect + */ +int +peekscan(expect, tokp) + tok_kind expect; + token *tokp; +{ + peek(tokp); + if (tokp->kind == expect) { + get_token(tokp); + return (1); + } + return (0); +} + + + +/* + * Get the next token, printing out any directive that are encountered. + */ +void +get_token(tokp) + token *tokp; +{ + int commenting; + + if (pushed) { + pushed = 0; + *tokp = lasttok; + return; + } + commenting = 0; + for (;;) { + if (*where == 0) { + for (;;) { + if (!fgets(curline, MAXLINESIZE, fin)) { + tokp->kind = TOK_EOF; + *where = 0; + return; + } + linenum++; + if (commenting) { + break; + } else if (cppline(curline)) { + docppline(curline, &linenum, + &infilename); + } else if (directive(curline)) { + printdirective(curline); + } else { + break; + } + } + where = curline; + } else if (isspace(*where)) { + while (isspace(*where)) { + where++; /* eat */ + } + } else if (commenting) { + where++; + if (endcomment(where)) { + where++; + commenting--; + } + } else if (startcomment(where)) { + where += 2; + commenting++; + } else { + break; + } + } + + /* + * 'where' is not whitespace, comment or directive Must be a token! + */ + switch (*where) { + case ':': + tokp->kind = TOK_COLON; + where++; + break; + case ';': + tokp->kind = TOK_SEMICOLON; + where++; + break; + case ',': + tokp->kind = TOK_COMMA; + where++; + break; + case '=': + tokp->kind = TOK_EQUAL; + where++; + break; + case '*': + tokp->kind = TOK_STAR; + where++; + break; + case '[': + tokp->kind = TOK_LBRACKET; + where++; + break; + case ']': + tokp->kind = TOK_RBRACKET; + where++; + break; + case '{': + tokp->kind = TOK_LBRACE; + where++; + break; + case '}': + tokp->kind = TOK_RBRACE; + where++; + break; + case '(': + tokp->kind = TOK_LPAREN; + where++; + break; + case ')': + tokp->kind = TOK_RPAREN; + where++; + break; + case '<': + tokp->kind = TOK_LANGLE; + where++; + break; + case '>': + tokp->kind = TOK_RANGLE; + where++; + break; + + case '"': + tokp->kind = TOK_STRCONST; + findstrconst(&where, &tokp->str); + break; + + case '-': + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + tokp->kind = TOK_IDENT; + findconst(&where, &tokp->str); + break; + + + default: + if (!(isalpha(*where) || *where == '_')) { + char buf[100]; + char *p; + + s_print(buf, "illegal character in file: "); + p = buf + strlen(buf); + if (isprint(*where)) { + s_print(p, "%c", *where); + } else { + s_print(p, "%d", *where); + } + error(buf); + } + findkind(&where, tokp); + break; + } +} + + + +static +unget_token(tokp) + token *tokp; +{ + lasttok = *tokp; + pushed = 1; +} + + +static +findstrconst(str, val) + char **str; + char **val; +{ + char *p; + int size; + + p = *str; + do { + *p++; + } while (*p && *p != '"'); + if (*p == 0) { + error("unterminated string constant"); + } + p++; + size = p - *str; + *val = alloc(size + 1); + (void) strncpy(*val, *str, size); + (*val)[size] = 0; + *str = p; +} + +static +findconst(str, val) + char **str; + char **val; +{ + char *p; + int size; + + p = *str; + if (*p == '0' && *(p + 1) == 'x') { + p++; + do { + p++; + } while (isxdigit(*p)); + } else { + do { + p++; + } while (isdigit(*p)); + } + size = p - *str; + *val = alloc(size + 1); + (void) strncpy(*val, *str, size); + (*val)[size] = 0; + *str = p; +} + + + +static token symbols[] = { + {TOK_CONST, "const"}, + {TOK_UNION, "union"}, + {TOK_SWITCH, "switch"}, + {TOK_CASE, "case"}, + {TOK_DEFAULT, "default"}, + {TOK_STRUCT, "struct"}, + {TOK_TYPEDEF, "typedef"}, + {TOK_ENUM, "enum"}, + {TOK_OPAQUE, "opaque"}, + {TOK_BOOL, "bool"}, + {TOK_VOID, "void"}, + {TOK_CHAR, "char"}, + {TOK_INT, "int"}, + {TOK_UNSIGNED, "unsigned"}, + {TOK_SHORT, "short"}, + {TOK_LONG, "long"}, + {TOK_FLOAT, "float"}, + {TOK_DOUBLE, "double"}, + {TOK_STRING, "string"}, + {TOK_PROGRAM, "program"}, + {TOK_VERSION, "version"}, + {TOK_EOF, "??????"}, +}; + + +static +findkind(mark, tokp) + char **mark; + token *tokp; +{ + + int len; + token *s; + char *str; + + str = *mark; + for (s = symbols; s->kind != TOK_EOF; s++) { + len = strlen(s->str); + if (strncmp(str, s->str, len) == 0) { + if (!isalnum(str[len]) && str[len] != '_') { + tokp->kind = s->kind; + tokp->str = s->str; + *mark = str + len; + return; + } + } + } + tokp->kind = TOK_IDENT; + for (len = 0; isalnum(str[len]) || str[len] == '_'; len++); + tokp->str = alloc(len + 1); + (void) strncpy(tokp->str, str, len); + tokp->str[len] = 0; + *mark = str + len; +} + +static +cppline(line) + char *line; +{ + return (line == curline && *line == '#'); +} + +static +directive(line) + char *line; +{ + return (line == curline && *line == '%'); +} + +static +printdirective(line) + char *line; +{ + f_print(fout, "%s", line + 1); +} + +static +docppline(line, lineno, fname) + char *line; + int *lineno; + char **fname; +{ + char *file; + int num; + char *p; + + line++; + while (isspace(*line)) { + line++; + } + num = atoi(line); + while (isdigit(*line)) { + line++; + } + while (isspace(*line)) { + line++; + } + if (*line != '"') { + error("preprocessor error"); + } + line++; + p = file = alloc(strlen(line) + 1); + while (*line && *line != '"') { + *p++ = *line++; + } + if (*line == 0) { + error("preprocessor error"); + } + *p = 0; + if (*file == 0) { + *fname = NULL; + } else { + *fname = file; + } + *lineno = num - 1; +} diff -ruN glibc-1.07/sunrpc/rpc_scan.h glibc-1.08.1/sunrpc/rpc_scan.h --- glibc-1.07/sunrpc/rpc_scan.h +++ glibc-1.08.1/sunrpc/rpc_scan.h Sun Feb 6 22:15:42 1994 @@ -0,0 +1,101 @@ +/* @(#)rpc_scan.h 2.1 88/08/01 4.0 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +/* @(#)rpc_scan.h 1.3 87/03/09 (C) 1987 SMI */ + +/* + * rpc_scan.h, Definitions for the RPCL scanner + * Copyright (C) 1987, Sun Microsystems, Inc. + */ + +/* + * kinds of tokens + */ +enum tok_kind { + TOK_IDENT, + TOK_STRCONST, + TOK_LPAREN, + TOK_RPAREN, + TOK_LBRACE, + TOK_RBRACE, + TOK_LBRACKET, + TOK_RBRACKET, + TOK_LANGLE, + TOK_RANGLE, + TOK_STAR, + TOK_COMMA, + TOK_EQUAL, + TOK_COLON, + TOK_SEMICOLON, + TOK_CONST, + TOK_STRUCT, + TOK_UNION, + TOK_SWITCH, + TOK_CASE, + TOK_DEFAULT, + TOK_ENUM, + TOK_TYPEDEF, + TOK_INT, + TOK_SHORT, + TOK_LONG, + TOK_UNSIGNED, + TOK_FLOAT, + TOK_DOUBLE, + TOK_OPAQUE, + TOK_CHAR, + TOK_STRING, + TOK_BOOL, + TOK_VOID, + TOK_PROGRAM, + TOK_VERSION, + TOK_EOF +}; +typedef enum tok_kind tok_kind; + +/* + * a token + */ +struct token { + tok_kind kind; + char *str; +}; +typedef struct token token; + + +/* + * routine interface + */ +void scanprint(); +void scan(); +void scan2(); +void scan3(); +void scan_num(); +void peek(); +int peekscan(); +void get_token(); diff -ruN glibc-1.07/sunrpc/rpc_svcout.c glibc-1.08.1/sunrpc/rpc_svcout.c --- glibc-1.07/sunrpc/rpc_svcout.c +++ glibc-1.08.1/sunrpc/rpc_svcout.c Sun Feb 6 22:15:43 1994 @@ -0,0 +1,275 @@ +/* @(#)rpc_svcout.c 2.1 88/08/01 4.0 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +#ifndef lint +static char sccsid[] = "@(#)rpc_svcout.c 1.6 87/06/24 (C) 1987 SMI"; +#endif + +/* + * rpc_svcout.c, Server-skeleton outputter for the RPC protocol compiler + * Copyright (C) 1987, Sun Microsytsems, Inc. + */ +#include +#include +#include "rpc_parse.h" +#include "rpc_util.h" + +static char RQSTP[] = "rqstp"; +static char TRANSP[] = "transp"; +static char ARG[] = "argument"; +static char RESULT[] = "result"; +static char ROUTINE[] = "local"; + + +/* + * write most of the service, that is, everything but the registrations. + */ +void +write_most() +{ + list *l; + definition *def; + version_list *vp; + + for (l = defined; l != NULL; l = l->next) { + def = (definition *) l->val; + if (def->def_kind == DEF_PROGRAM) { + for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) { + f_print(fout, "\nstatic void "); + pvname(def->def_name, vp->vers_num); + f_print(fout, "();"); + } + } + } + f_print(fout, "\n\n"); + f_print(fout, "main()\n"); + f_print(fout, "{\n"); + f_print(fout, "\tSVCXPRT *%s;\n", TRANSP); + f_print(fout, "\n"); + for (l = defined; l != NULL; l = l->next) { + def = (definition *) l->val; + if (def->def_kind != DEF_PROGRAM) { + continue; + } + for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) { + f_print(fout, "\t(void)pmap_unset(%s, %s);\n", def->def_name, vp->vers_name); + } + } +} + + +/* + * write a registration for the given transport + */ +void +write_register(transp) + char *transp; +{ + list *l; + definition *def; + version_list *vp; + + f_print(fout, "\n"); + f_print(fout, "\t%s = svc%s_create(RPC_ANYSOCK", TRANSP, transp); + if (streq(transp, "tcp")) { + f_print(fout, ", 0, 0"); + } + f_print(fout, ");\n"); + f_print(fout, "\tif (%s == NULL) {\n", TRANSP); + f_print(fout, "\t\t(void)fprintf(stderr, \"cannot create %s service.\\n\");\n", transp); + f_print(fout, "\t\texit(1);\n"); + f_print(fout, "\t}\n"); + + for (l = defined; l != NULL; l = l->next) { + def = (definition *) l->val; + if (def->def_kind != DEF_PROGRAM) { + continue; + } + for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) { + f_print(fout, + "\tif (!svc_register(%s, %s, %s, ", + TRANSP, def->def_name, vp->vers_name); + pvname(def->def_name, vp->vers_num); + f_print(fout, ", IPPROTO_%s)) {\n", + streq(transp, "udp") ? "UDP" : "TCP"); + f_print(fout, + "\t\t(void)fprintf(stderr, \"unable to register (%s, %s, %s).\\n\");\n", + def->def_name, vp->vers_name, transp); + f_print(fout, "\t\texit(1);\n"); + f_print(fout, "\t}\n"); + } + } +} + + +/* + * write the rest of the service + */ +void +write_rest() +{ + f_print(fout, "\tsvc_run();\n"); + f_print(fout, "\t(void)fprintf(stderr, \"svc_run returned\\n\");\n"); + f_print(fout, "\texit(1);\n"); + f_print(fout, "}\n"); +} + +void +write_programs(storage) + char *storage; +{ + list *l; + definition *def; + + for (l = defined; l != NULL; l = l->next) { + def = (definition *) l->val; + if (def->def_kind == DEF_PROGRAM) { + write_program(def, storage); + } + } +} + + +static +write_program(def, storage) + definition *def; + char *storage; +{ + version_list *vp; + proc_list *proc; + int filled; + + for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) { + f_print(fout, "\n"); + if (storage != NULL) { + f_print(fout, "%s ", storage); + } + f_print(fout, "void\n"); + pvname(def->def_name, vp->vers_num); + f_print(fout, "(%s, %s)\n", RQSTP, TRANSP); + f_print(fout, " struct svc_req *%s;\n", RQSTP); + f_print(fout, " SVCXPRT *%s;\n", TRANSP); + f_print(fout, "{\n"); + + filled = 0; + f_print(fout, "\tunion {\n"); + for (proc = vp->procs; proc != NULL; proc = proc->next) { + if (streq(proc->arg_type, "void")) { + continue; + } + filled = 1; + f_print(fout, "\t\t"); + ptype(proc->arg_prefix, proc->arg_type, 0); + pvname(proc->proc_name, vp->vers_num); + f_print(fout, "_arg;\n"); + } + if (!filled) { + f_print(fout, "\t\tint fill;\n"); + } + f_print(fout, "\t} %s;\n", ARG); + f_print(fout, "\tchar *%s;\n", RESULT); + f_print(fout, "\tbool_t (*xdr_%s)(), (*xdr_%s)();\n", ARG, RESULT); + f_print(fout, "\tchar *(*%s)();\n", ROUTINE); + f_print(fout, "\n"); + f_print(fout, "\tswitch (%s->rq_proc) {\n", RQSTP); + + if (!nullproc(vp->procs)) { + f_print(fout, "\tcase NULLPROC:\n"); + f_print(fout, "\t\t(void)svc_sendreply(%s, xdr_void, (char *)NULL);\n", TRANSP); + f_print(fout, "\t\treturn;\n\n"); + } + for (proc = vp->procs; proc != NULL; proc = proc->next) { + f_print(fout, "\tcase %s:\n", proc->proc_name); + f_print(fout, "\t\txdr_%s = xdr_%s;\n", ARG, + stringfix(proc->arg_type)); + f_print(fout, "\t\txdr_%s = xdr_%s;\n", RESULT, + stringfix(proc->res_type)); + f_print(fout, "\t\t%s = (char *(*)()) ", ROUTINE); + pvname(proc->proc_name, vp->vers_num); + f_print(fout, ";\n"); + f_print(fout, "\t\tbreak;\n\n"); + } + f_print(fout, "\tdefault:\n"); + printerr("noproc", TRANSP); + f_print(fout, "\t\treturn;\n"); + f_print(fout, "\t}\n"); + + f_print(fout, "\tbzero((char *)&%s, sizeof(%s));\n", ARG, ARG); + printif("getargs", TRANSP, "&", ARG); + printerr("decode", TRANSP); + f_print(fout, "\t\treturn;\n"); + f_print(fout, "\t}\n"); + + f_print(fout, "\t%s = (*%s)(&%s, %s);\n", RESULT, ROUTINE, ARG, + RQSTP); + f_print(fout, + "\tif (%s != NULL && !svc_sendreply(%s, xdr_%s, %s)) {\n", + RESULT, TRANSP, RESULT, RESULT); + printerr("systemerr", TRANSP); + f_print(fout, "\t}\n"); + + printif("freeargs", TRANSP, "&", ARG); + f_print(fout, "\t\t(void)fprintf(stderr, \"unable to free arguments\\n\");\n"); + f_print(fout, "\t\texit(1);\n"); + f_print(fout, "\t}\n"); + + f_print(fout, "}\n\n"); + } +} + +static +printerr(err, transp) + char *err; + char *transp; +{ + f_print(fout, "\t\tsvcerr_%s(%s);\n", err, transp); +} + +static +printif(proc, transp, prefix, arg) + char *proc; + char *transp; + char *prefix; + char *arg; +{ + f_print(fout, "\tif (!svc_%s(%s, xdr_%s, %s%s)) {\n", + proc, transp, arg, prefix, arg); +} + + +nullproc(proc) + proc_list *proc; +{ + for (; proc != NULL; proc = proc->next) { + if (streq(proc->proc_num, "0")) { + return (1); + } + } + return (0); +} diff -ruN glibc-1.07/sunrpc/rpc_util.c glibc-1.08.1/sunrpc/rpc_util.c --- glibc-1.07/sunrpc/rpc_util.c +++ glibc-1.08.1/sunrpc/rpc_util.c Sun Feb 6 22:15:43 1994 @@ -0,0 +1,436 @@ +/* @(#)rpc_util.c 2.1 88/08/01 4.0 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +#ifndef lint +static char sccsid[] = "@(#)rpc_util.c 1.5 87/06/24 (C) 1987 SMI"; +#endif + +/* + * rpc_util.c, Utility routines for the RPC protocol compiler + * Copyright (C) 1987, Sun Microsystems, Inc. + */ +#include +#include "rpc_scan.h" +#include "rpc_parse.h" +#include "rpc_util.h" + +char curline[MAXLINESIZE]; /* current read line */ +char *where = curline; /* current point in line */ +int linenum = 0; /* current line number */ + +char *infilename; /* input filename */ + +#define NFILES 4 +char *outfiles[NFILES]; /* output file names */ +int nfiles; + +FILE *fout; /* file pointer of current output */ +FILE *fin; /* file pointer of current input */ + +list *defined; /* list of defined things */ + +/* + * Reinitialize the world + */ +reinitialize() +{ + bzero(curline, MAXLINESIZE); + where = curline; + linenum = 0; + defined = NULL; +} + +/* + * string equality + */ +streq(a, b) + char *a; + char *b; +{ + return (strcmp(a, b) == 0); +} + +/* + * find a value in a list + */ +char * +findval(lst, val, cmp) + list *lst; + char *val; + int (*cmp) (); + +{ + for (; lst != NULL; lst = lst->next) { + if ((*cmp) (lst->val, val)) { + return (lst->val); + } + } + return (NULL); +} + +/* + * store a value in a list + */ +void +storeval(lstp, val) + list **lstp; + char *val; +{ + list **l; + list *lst; + + for (l = lstp; *l != NULL; l = (list **) & (*l)->next); + lst = ALLOC(list); + lst->val = val; + lst->next = NULL; + *l = lst; +} + + +static +findit(def, type) + definition *def; + char *type; +{ + return (streq(def->def_name, type)); +} + + +static char * +fixit(type, orig) + char *type; + char *orig; +{ + definition *def; + + def = (definition *) FINDVAL(defined, type, findit); + if (def == NULL || def->def_kind != DEF_TYPEDEF) { + return (orig); + } + switch (def->def.ty.rel) { + case REL_VECTOR: + return (def->def.ty.old_type); + case REL_ALIAS: + return (fixit(def->def.ty.old_type, orig)); + default: + return (orig); + } +} + +char * +fixtype(type) + char *type; +{ + return (fixit(type, type)); +} + +char * +stringfix(type) + char *type; +{ + if (streq(type, "string")) { + return ("wrapstring"); + } else { + return (type); + } +} + +void +ptype(prefix, type, follow) + char *prefix; + char *type; + int follow; +{ + if (prefix != NULL) { + if (streq(prefix, "enum")) { + f_print(fout, "enum "); + } else { + f_print(fout, "struct "); + } + } + if (streq(type, "bool")) { + f_print(fout, "bool_t "); + } else if (streq(type, "string")) { + f_print(fout, "char *"); + } else { + f_print(fout, "%s ", follow ? fixtype(type) : type); + } +} + + +static +typedefed(def, type) + definition *def; + char *type; +{ + if (def->def_kind != DEF_TYPEDEF || def->def.ty.old_prefix != NULL) { + return (0); + } else { + return (streq(def->def_name, type)); + } +} + +isvectordef(type, rel) + char *type; + relation rel; +{ + definition *def; + + for (;;) { + switch (rel) { + case REL_VECTOR: + return (!streq(type, "string")); + case REL_ARRAY: + return (0); + case REL_POINTER: + return (0); + case REL_ALIAS: + def = (definition *) FINDVAL(defined, type, typedefed); + if (def == NULL) { + return (0); + } + type = def->def.ty.old_type; + rel = def->def.ty.rel; + } + } +} + + +static char * +locase(str) + char *str; +{ + char c; + static char buf[100]; + char *p = buf; + + while (c = *str++) { + *p++ = (c >= 'A' && c <= 'Z') ? (c - 'A' + 'a') : c; + } + *p = 0; + return (buf); +} + + +void +pvname(pname, vnum) + char *pname; + char *vnum; +{ + f_print(fout, "%s_%s", locase(pname), vnum); +} + + +/* + * print a useful (?) error message, and then die + */ +void +error(msg) + char *msg; +{ + printwhere(); + f_print(stderr, "%s, line %d: ", infilename, linenum); + f_print(stderr, "%s\n", msg); + crash(); +} + +/* + * Something went wrong, unlink any files that we may have created and then + * die. + */ +crash() +{ + int i; + + for (i = 0; i < nfiles; i++) { + (void) unlink(outfiles[i]); + } + exit(1); +} + + +void +record_open(file) + char *file; +{ + if (nfiles < NFILES) { + outfiles[nfiles++] = file; + } else { + f_print(stderr, "too many files!\n"); + crash(); + } +} + +static char expectbuf[100]; +static char *toktostr(); + +/* + * error, token encountered was not the expected one + */ +void +expected1(exp1) + tok_kind exp1; +{ + s_print(expectbuf, "expected '%s'", + toktostr(exp1)); + error(expectbuf); +} + +/* + * error, token encountered was not one of two expected ones + */ +void +expected2(exp1, exp2) + tok_kind exp1, exp2; +{ + s_print(expectbuf, "expected '%s' or '%s'", + toktostr(exp1), + toktostr(exp2)); + error(expectbuf); +} + +/* + * error, token encountered was not one of 3 expected ones + */ +void +expected3(exp1, exp2, exp3) + tok_kind exp1, exp2, exp3; +{ + s_print(expectbuf, "expected '%s', '%s' or '%s'", + toktostr(exp1), + toktostr(exp2), + toktostr(exp3)); + error(expectbuf); +} + +void +tabify(f, tab) + FILE *f; + int tab; +{ + while (tab--) { + (void) fputc('\t', f); + } +} + + + +static token tokstrings[] = { + {TOK_IDENT, "identifier"}, + {TOK_CONST, "const"}, + {TOK_RPAREN, ")"}, + {TOK_LPAREN, "("}, + {TOK_RBRACE, "}"}, + {TOK_LBRACE, "{"}, + {TOK_LBRACKET, "["}, + {TOK_RBRACKET, "]"}, + {TOK_STAR, "*"}, + {TOK_COMMA, ","}, + {TOK_EQUAL, "="}, + {TOK_COLON, ":"}, + {TOK_SEMICOLON, ";"}, + {TOK_UNION, "union"}, + {TOK_STRUCT, "struct"}, + {TOK_SWITCH, "switch"}, + {TOK_CASE, "case"}, + {TOK_DEFAULT, "default"}, + {TOK_ENUM, "enum"}, + {TOK_TYPEDEF, "typedef"}, + {TOK_INT, "int"}, + {TOK_SHORT, "short"}, + {TOK_LONG, "long"}, + {TOK_UNSIGNED, "unsigned"}, + {TOK_DOUBLE, "double"}, + {TOK_FLOAT, "float"}, + {TOK_CHAR, "char"}, + {TOK_STRING, "string"}, + {TOK_OPAQUE, "opaque"}, + {TOK_BOOL, "bool"}, + {TOK_VOID, "void"}, + {TOK_PROGRAM, "program"}, + {TOK_VERSION, "version"}, + {TOK_EOF, "??????"} +}; + +static char * +toktostr(kind) + tok_kind kind; +{ + token *sp; + + for (sp = tokstrings; sp->kind != TOK_EOF && sp->kind != kind; sp++); + return (sp->str); +} + + + +static +printbuf() +{ + char c; + int i; + int cnt; + +# define TABSIZE 4 + + for (i = 0; c = curline[i]; i++) { + if (c == '\t') { + cnt = 8 - (i % TABSIZE); + c = ' '; + } else { + cnt = 1; + } + while (cnt--) { + (void) fputc(c, stderr); + } + } +} + + +static +printwhere() +{ + int i; + char c; + int cnt; + + printbuf(); + for (i = 0; i < where - curline; i++) { + c = curline[i]; + if (c == '\t') { + cnt = 8 - (i % TABSIZE); + } else { + cnt = 1; + } + while (cnt--) { + (void) fputc('^', stderr); + } + } + (void) fputc('\n', stderr); +} diff -ruN glibc-1.07/sunrpc/rpc_util.h glibc-1.08.1/sunrpc/rpc_util.h --- glibc-1.07/sunrpc/rpc_util.h +++ glibc-1.08.1/sunrpc/rpc_util.h Wed Feb 9 13:08:15 1994 @@ -0,0 +1,114 @@ +/* @(#)rpc_util.h 2.1 88/08/01 4.0 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +/* @(#)rpc_util.h 1.6 87/06/24 (C) 1987 SMI */ + +/* + * rpc_util.h, Useful definitions for the RPC protocol compiler + * Copyright (C) 1987, Sun Microsystems, Inc. + */ +extern char *malloc(); + +#define alloc(size) malloc((unsigned)(size)) +#define ALLOC(object) (object *) malloc(sizeof(object)) + +/* extern char *sprintf(); --roland@gnu */ + +#define s_print (void) sprintf +#define f_print (void) fprintf + +struct list { + char *val; + struct list *next; +}; +typedef struct list list; + +/* + * Global variables + */ +#define MAXLINESIZE 1024 +extern char curline[MAXLINESIZE]; +extern char *where; +extern int linenum; + +extern char *infilename; +extern FILE *fout; +extern FILE *fin; + +extern list *defined; + +/* + * rpc_util routines + */ +void storeval(); + +#define STOREVAL(list,item) \ + storeval(list,(char *)item) + +char *findval(); + +#define FINDVAL(list,item,finder) \ + findval(list, (char *) item, finder) + +char *fixtype(); +char *stringfix(); +void pvname(); +void ptype(); +int isvectordef(); +int streq(); +void error(); +void expected1(); +void expected2(); +void expected3(); +void tabify(); +void record_open(); + +/* + * rpc_cout routines + */ +void cprint(); +void emit(); + +/* + * rpc_hout routines + */ +void print_datadef(); + +/* + * rpc_svcout routines + */ +void write_most(); +void write_register(); +void write_rest(); +void write_programs(); + +/* + * rpc_clntout routines + */ +void write_stubs(); diff -ruN glibc-1.07/sunrpc/rpcinfo.c glibc-1.08.1/sunrpc/rpcinfo.c --- glibc-1.07/sunrpc/rpcinfo.c +++ glibc-1.08.1/sunrpc/rpcinfo.c Fri Jan 21 19:14:52 1994 @@ -0,0 +1,665 @@ +/* @(#)rpcinfo.c 2.2 88/08/11 4.0 RPCSRC */ +#ifndef lint +static char sccsid[] = "@(#)rpcinfo.c 1.22 87/08/12 SMI"; +#endif + +/* + * Copyright (C) 1986, Sun Microsystems, Inc. + */ + +/* + * rpcinfo: ping a particular rpc program + * or dump the portmapper + */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define MAXHOSTLEN 256 + +#define MIN_VERS ((u_long) 0) +#define MAX_VERS ((u_long) 4294967295L) + +static void udpping(/*u_short portflag, int argc, char **argv*/); +static void tcpping(/*u_short portflag, int argc, char **argv*/); +static int pstatus(/*CLIENT *client, u_long prognum, u_long vers*/); +static void pmapdump(/*int argc, char **argv*/); +static bool_t reply_proc(/*void *res, struct sockaddr_in *who*/); +static void brdcst(/*int argc, char **argv*/); +static void deletereg(/* int argc, char **argv */) ; +static void usage(/*void*/); +static u_long getprognum(/*char *arg*/); +static u_long getvers(/*char *arg*/); +static void get_inet_address(/*struct sockaddr_in *addr, char *host*/); +extern u_long inet_addr(); /* in 4.2BSD, arpa/inet.h called that a in_addr */ +extern char *inet_ntoa(); + +/* + * Functions to be performed. + */ +#define NONE 0 /* no function */ +#define PMAPDUMP 1 /* dump portmapper registrations */ +#define TCPPING 2 /* ping TCP service */ +#define UDPPING 3 /* ping UDP service */ +#define BRDCST 4 /* ping broadcast UDP service */ +#define DELETES 5 /* delete registration for the service */ + +int +main(argc, argv) + int argc; + char **argv; +{ + register int c; + extern char *optarg; + extern int optind; + int errflg; + int function; + u_short portnum; + + function = NONE; + portnum = 0; + errflg = 0; + while ((c = getopt(argc, argv, "ptubdn:")) != EOF) { + switch (c) { + + case 'p': + if (function != NONE) + errflg = 1; + else + function = PMAPDUMP; + break; + + case 't': + if (function != NONE) + errflg = 1; + else + function = TCPPING; + break; + + case 'u': + if (function != NONE) + errflg = 1; + else + function = UDPPING; + break; + + case 'b': + if (function != NONE) + errflg = 1; + else + function = BRDCST; + break; + + case 'n': + portnum = (u_short) atoi(optarg); /* hope we don't get bogus # */ + break; + + case 'd': + if (function != NONE) + errflg = 1; + else + function = DELETES; + break; + + case '?': + errflg = 1; + } + } + + if (errflg || function == NONE) { + usage(); + return (1); + } + + switch (function) { + + case PMAPDUMP: + if (portnum != 0) { + usage(); + return (1); + } + pmapdump(argc - optind, argv + optind); + break; + + case UDPPING: + udpping(portnum, argc - optind, argv + optind); + break; + + case TCPPING: + tcpping(portnum, argc - optind, argv + optind); + break; + + case BRDCST: + if (portnum != 0) { + usage(); + return (1); + } + brdcst(argc - optind, argv + optind); + break; + + case DELETES: + deletereg(argc - optind, argv + optind); + break; + } + + return (0); +} + +static void +udpping(portnum, argc, argv) + u_short portnum; + int argc; + char **argv; +{ + struct timeval to; + struct sockaddr_in addr; + enum clnt_stat rpc_stat; + CLIENT *client; + u_long prognum, vers, minvers, maxvers; + int sock = RPC_ANYSOCK; + struct rpc_err rpcerr; + int failure; + + if (argc < 2 || argc > 3) { + usage(); + exit(1); + } + prognum = getprognum(argv[1]); + get_inet_address(&addr, argv[0]); + /* Open the socket here so it will survive calls to clnt_destroy */ + sock = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP); + if (sock < 0) { + perror("rpcinfo: socket"); + exit(1); + } + failure = 0; + if (argc == 2) { + /* + * A call to version 0 should fail with a program/version + * mismatch, and give us the range of versions supported. + */ + addr.sin_port = htons(portnum); + to.tv_sec = 5; + to.tv_usec = 0; + if ((client = clntudp_create(&addr, prognum, (u_long)0, + to, &sock)) == NULL) { + clnt_pcreateerror("rpcinfo"); + printf("program %lu is not available\n", + prognum); + exit(1); + } + to.tv_sec = 10; + to.tv_usec = 0; + rpc_stat = clnt_call(client, NULLPROC, xdr_void, (char *)NULL, + xdr_void, (char *)NULL, to); + if (rpc_stat == RPC_PROGVERSMISMATCH) { + clnt_geterr(client, &rpcerr); + minvers = rpcerr.re_vers.low; + maxvers = rpcerr.re_vers.high; + } else if (rpc_stat == RPC_SUCCESS) { + /* + * Oh dear, it DOES support version 0. + * Let's try version MAX_VERS. + */ + addr.sin_port = htons(portnum); + to.tv_sec = 5; + to.tv_usec = 0; + if ((client = clntudp_create(&addr, prognum, MAX_VERS, + to, &sock)) == NULL) { + clnt_pcreateerror("rpcinfo"); + printf("program %lu version %lu is not available\n", + prognum, MAX_VERS); + exit(1); + } + to.tv_sec = 10; + to.tv_usec = 0; + rpc_stat = clnt_call(client, NULLPROC, xdr_void, + (char *)NULL, xdr_void, (char *)NULL, to); + if (rpc_stat == RPC_PROGVERSMISMATCH) { + clnt_geterr(client, &rpcerr); + minvers = rpcerr.re_vers.low; + maxvers = rpcerr.re_vers.high; + } else if (rpc_stat == RPC_SUCCESS) { + /* + * It also supports version MAX_VERS. + * Looks like we have a wise guy. + * OK, we give them information on all + * 4 billion versions they support... + */ + minvers = 0; + maxvers = MAX_VERS; + } else { + (void) pstatus(client, prognum, MAX_VERS); + exit(1); + } + } else { + (void) pstatus(client, prognum, (u_long)0); + exit(1); + } + clnt_destroy(client); + for (vers = minvers; vers <= maxvers; vers++) { + addr.sin_port = htons(portnum); + to.tv_sec = 5; + to.tv_usec = 0; + if ((client = clntudp_create(&addr, prognum, vers, + to, &sock)) == NULL) { + clnt_pcreateerror("rpcinfo"); + printf("program %lu version %lu is not available\n", + prognum, vers); + exit(1); + } + to.tv_sec = 10; + to.tv_usec = 0; + rpc_stat = clnt_call(client, NULLPROC, xdr_void, + (char *)NULL, xdr_void, (char *)NULL, to); + if (pstatus(client, prognum, vers) < 0) + failure = 1; + clnt_destroy(client); + } + } + else { + vers = getvers(argv[2]); + addr.sin_port = htons(portnum); + to.tv_sec = 5; + to.tv_usec = 0; + if ((client = clntudp_create(&addr, prognum, vers, + to, &sock)) == NULL) { + clnt_pcreateerror("rpcinfo"); + printf("program %lu version %lu is not available\n", + prognum, vers); + exit(1); + } + to.tv_sec = 10; + to.tv_usec = 0; + rpc_stat = clnt_call(client, 0, xdr_void, (char *)NULL, + xdr_void, (char *)NULL, to); + if (pstatus(client, prognum, vers) < 0) + failure = 1; + } + (void) close(sock); /* Close it up again */ + if (failure) + exit(1); +} + +static void +tcpping(portnum, argc, argv) + u_short portnum; + int argc; + char **argv; +{ + struct timeval to; + struct sockaddr_in addr; + enum clnt_stat rpc_stat; + CLIENT *client; + u_long prognum, vers, minvers, maxvers; + int sock = RPC_ANYSOCK; + struct rpc_err rpcerr; + int failure; + + if (argc < 2 || argc > 3) { + usage(); + exit(1); + } + prognum = getprognum(argv[1]); + get_inet_address(&addr, argv[0]); + failure = 0; + if (argc == 2) { + /* + * A call to version 0 should fail with a program/version + * mismatch, and give us the range of versions supported. + */ + addr.sin_port = htons(portnum); + if ((client = clnttcp_create(&addr, prognum, MIN_VERS, + &sock, 0, 0)) == NULL) { + clnt_pcreateerror("rpcinfo"); + printf("program %lu is not available\n", + prognum); + exit(1); + } + to.tv_sec = 10; + to.tv_usec = 0; + rpc_stat = clnt_call(client, NULLPROC, xdr_void, (char *)NULL, + xdr_void, (char *)NULL, to); + if (rpc_stat == RPC_PROGVERSMISMATCH) { + clnt_geterr(client, &rpcerr); + minvers = rpcerr.re_vers.low; + maxvers = rpcerr.re_vers.high; + } else if (rpc_stat == RPC_SUCCESS) { + /* + * Oh dear, it DOES support version 0. + * Let's try version MAX_VERS. + */ + addr.sin_port = htons(portnum); + if ((client = clnttcp_create(&addr, prognum, MAX_VERS, + &sock, 0, 0)) == NULL) { + clnt_pcreateerror("rpcinfo"); + printf("program %lu version %lu is not available\n", + prognum, MAX_VERS); + exit(1); + } + to.tv_sec = 10; + to.tv_usec = 0; + rpc_stat = clnt_call(client, NULLPROC, xdr_void, + (char *)NULL, xdr_void, (char *)NULL, to); + if (rpc_stat == RPC_PROGVERSMISMATCH) { + clnt_geterr(client, &rpcerr); + minvers = rpcerr.re_vers.low; + maxvers = rpcerr.re_vers.high; + } else if (rpc_stat == RPC_SUCCESS) { + /* + * It also supports version MAX_VERS. + * Looks like we have a wise guy. + * OK, we give them information on all + * 4 billion versions they support... + */ + minvers = 0; + maxvers = MAX_VERS; + } else { + (void) pstatus(client, prognum, MAX_VERS); + exit(1); + } + } else { + (void) pstatus(client, prognum, MIN_VERS); + exit(1); + } + clnt_destroy(client); + (void) close(sock); + sock = RPC_ANYSOCK; /* Re-initialize it for later */ + for (vers = minvers; vers <= maxvers; vers++) { + addr.sin_port = htons(portnum); + if ((client = clnttcp_create(&addr, prognum, vers, + &sock, 0, 0)) == NULL) { + clnt_pcreateerror("rpcinfo"); + printf("program %lu version %lu is not available\n", + prognum, vers); + exit(1); + } + to.tv_usec = 0; + to.tv_sec = 10; + rpc_stat = clnt_call(client, 0, xdr_void, (char *)NULL, + xdr_void, (char *)NULL, to); + if (pstatus(client, prognum, vers) < 0) + failure = 1; + clnt_destroy(client); + (void) close(sock); + sock = RPC_ANYSOCK; + } + } + else { + vers = getvers(argv[2]); + addr.sin_port = htons(portnum); + if ((client = clnttcp_create(&addr, prognum, vers, &sock, + 0, 0)) == NULL) { + clnt_pcreateerror("rpcinfo"); + printf("program %lu version %lu is not available\n", + prognum, vers); + exit(1); + } + to.tv_usec = 0; + to.tv_sec = 10; + rpc_stat = clnt_call(client, 0, xdr_void, (char *)NULL, + xdr_void, (char *)NULL, to); + if (pstatus(client, prognum, vers) < 0) + failure = 1; + } + if (failure) + exit(1); +} + +/* + * This routine should take a pointer to an "rpc_err" structure, rather than + * a pointer to a CLIENT structure, but "clnt_perror" takes a pointer to + * a CLIENT structure rather than a pointer to an "rpc_err" structure. + * As such, we have to keep the CLIENT structure around in order to print + * a good error message. + */ +static int +pstatus(client, prognum, vers) + register CLIENT *client; + u_long prognum; + u_long vers; +{ + struct rpc_err rpcerr; + + clnt_geterr(client, &rpcerr); + if (rpcerr.re_status != RPC_SUCCESS) { + clnt_perror(client, "rpcinfo"); + printf("program %lu version %lu is not available\n", + prognum, vers); + return (-1); + } else { + printf("program %lu version %lu ready and waiting\n", + prognum, vers); + return (0); + } +} + +static void +pmapdump(argc, argv) + int argc; + char **argv; +{ + struct sockaddr_in server_addr; + register struct hostent *hp; + struct pmaplist *head = NULL; + int socket = RPC_ANYSOCK; + struct timeval minutetimeout; + register CLIENT *client; + struct rpcent *rpc; + + if (argc > 1) { + usage(); + exit(1); + } + if (argc == 1) + get_inet_address(&server_addr, argv[0]); + else { + bzero((char *)&server_addr, sizeof server_addr); + server_addr.sin_family = AF_INET; + if ((hp = gethostbyname("localhost")) != NULL) + bcopy(hp->h_addr, (caddr_t)&server_addr.sin_addr, + hp->h_length); + else + server_addr.sin_addr.s_addr = inet_addr("0.0.0.0"); + } + minutetimeout.tv_sec = 60; + minutetimeout.tv_usec = 0; + server_addr.sin_port = htons(PMAPPORT); + if ((client = clnttcp_create(&server_addr, PMAPPROG, + PMAPVERS, &socket, 50, 500)) == NULL) { + clnt_pcreateerror("rpcinfo: can't contact portmapper"); + exit(1); + } + if (clnt_call(client, PMAPPROC_DUMP, xdr_void, NULL, + xdr_pmaplist, &head, minutetimeout) != RPC_SUCCESS) { + fprintf(stderr, "rpcinfo: can't contact portmapper: "); + clnt_perror(client, "rpcinfo"); + exit(1); + } + if (head == NULL) { + printf("No remote programs registered.\n"); + } else { + printf(" program vers proto port\n"); + for (; head != NULL; head = head->pml_next) { + printf("%10ld%5ld", + head->pml_map.pm_prog, + head->pml_map.pm_vers); + if (head->pml_map.pm_prot == IPPROTO_UDP) + printf("%6s", "udp"); + else if (head->pml_map.pm_prot == IPPROTO_TCP) + printf("%6s", "tcp"); + else + printf("%6ld", head->pml_map.pm_prot); + printf("%7ld", head->pml_map.pm_port); + rpc = getrpcbynumber(head->pml_map.pm_prog); + if (rpc) + printf(" %s\n", rpc->r_name); + else + printf("\n"); + } + } +} + +/* + * reply_proc collects replies from the broadcast. + * to get a unique list of responses the output of rpcinfo should + * be piped through sort(1) and then uniq(1). + */ + +/*ARGSUSED*/ +static bool_t +reply_proc(res, who) + void *res; /* Nothing comes back */ + struct sockaddr_in *who; /* Who sent us the reply */ +{ + register struct hostent *hp; + + hp = gethostbyaddr((char *) &who->sin_addr, sizeof who->sin_addr, + AF_INET); + printf("%s %s\n", inet_ntoa(who->sin_addr), + (hp == NULL) ? "(unknown)" : hp->h_name); + return(FALSE); +} + +static void +brdcst(argc, argv) + int argc; + char **argv; +{ + enum clnt_stat rpc_stat; + u_long prognum, vers; + + if (argc != 2) { + usage(); + exit(1); + } + prognum = getprognum(argv[0]); + vers = getvers(argv[1]); + rpc_stat = clnt_broadcast(prognum, vers, NULLPROC, xdr_void, + (char *)NULL, xdr_void, (char *)NULL, reply_proc); + if ((rpc_stat != RPC_SUCCESS) && (rpc_stat != RPC_TIMEDOUT)) { + fprintf(stderr, "rpcinfo: broadcast failed: %s\n", + clnt_sperrno(rpc_stat)); + exit(1); + } + exit(0); +} + +static void +deletereg(argc, argv) + int argc; + char **argv; +{ u_long prog_num, version_num ; + + if (argc != 2) { + usage() ; + exit(1) ; + } + if (getuid()) { /* This command allowed only to root */ + fprintf(stderr, "Sorry. You are not root\n") ; + exit(1) ; + } + prog_num = getprognum(argv[0]); + version_num = getvers(argv[1]); + if ((pmap_unset(prog_num, version_num)) == 0) { + fprintf(stderr, "rpcinfo: Could not delete registration for prog %s version %s\n", + argv[0], argv[1]) ; + exit(1) ; + } +} + +static void +usage() +{ + fprintf(stderr, "Usage: rpcinfo [ -n portnum ] -u host prognum [ versnum ]\n"); + fprintf(stderr, " rpcinfo [ -n portnum ] -t host prognum [ versnum ]\n"); + fprintf(stderr, " rpcinfo -p [ host ]\n"); + fprintf(stderr, " rpcinfo -b prognum versnum\n"); + fprintf(stderr, " rpcinfo -d prognum versnum\n") ; +} + +static u_long +getprognum(arg) + char *arg; +{ + register struct rpcent *rpc; + register u_long prognum; + + if (isalpha(*arg)) { + rpc = getrpcbyname(arg); + if (rpc == NULL) { + fprintf(stderr, "rpcinfo: %s is unknown service\n", + arg); + exit(1); + } + prognum = rpc->r_number; + } else { + prognum = (u_long) atoi(arg); + } + + return (prognum); +} + +static u_long +getvers(arg) + char *arg; +{ + register u_long vers; + + vers = (int) atoi(arg); + return (vers); +} + +static void +get_inet_address(addr, host) + struct sockaddr_in *addr; + char *host; +{ + register struct hostent *hp; + + bzero((char *)addr, sizeof *addr); + addr->sin_addr.s_addr = (u_long) inet_addr(host); + if (addr->sin_addr.s_addr == -1 || addr->sin_addr.s_addr == 0) { + if ((hp = gethostbyname(host)) == NULL) { + fprintf(stderr, "rpcinfo: %s is unknown host\n", host); + exit(1); + } + bcopy(hp->h_addr, (char *)&addr->sin_addr, hp->h_length); + } + addr->sin_family = AF_INET; +} diff -ruN glibc-1.07/sunrpc/rpcsvc/bootparam.x glibc-1.08.1/sunrpc/rpcsvc/bootparam.x --- glibc-1.07/sunrpc/rpcsvc/bootparam.x +++ glibc-1.08.1/sunrpc/rpcsvc/bootparam.x Sun Feb 6 21:47:37 1994 @@ -0,0 +1,97 @@ +/* @(#)bootparam_prot.x 2.1 88/08/01 4.0 RPCSRC */ +/* @(#)bootparam_prot.x 1.2 87/06/24 Copyr 1987 Sun Micro */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +/* + * RPC for bootparms service. + * There are two procedures: + * WHOAMI takes a net address and returns a client name and also a + * likely net address for routing + * GETFILE takes a client name and file identifier and returns the + * server name, server net address and pathname for the file. + * file identifiers typically include root, swap, pub and dump + */ + +#ifdef RPC_HDR +%#include +%#include +%#include +%#include +#endif + +const MAX_MACHINE_NAME = 255; +const MAX_PATH_LEN = 1024; +const MAX_FILEID = 32; +const IP_ADDR_TYPE = 1; + +typedef string bp_machine_name_t; +typedef string bp_path_t; +typedef string bp_fileid_t; + +struct ip_addr_t { + char net; + char host; + char lh; + char impno; +}; + +union bp_address switch (int address_type) { + case IP_ADDR_TYPE: + ip_addr_t ip_addr; +}; + +struct bp_whoami_arg { + bp_address client_address; +}; + +struct bp_whoami_res { + bp_machine_name_t client_name; + bp_machine_name_t domain_name; + bp_address router_address; +}; + +struct bp_getfile_arg { + bp_machine_name_t client_name; + bp_fileid_t file_id; +}; + +struct bp_getfile_res { + bp_machine_name_t server_name; + bp_address server_address; + bp_path_t server_path; +}; + +program BOOTPARAMPROG { + version BOOTPARAMVERS { + bp_whoami_res BOOTPARAMPROC_WHOAMI(bp_whoami_arg) = 1; + bp_getfile_res BOOTPARAMPROC_GETFILE(bp_getfile_arg) = 2; + } = 1; +} = 100026; diff -ruN glibc-1.07/sunrpc/rpcsvc/klm_prot.x glibc-1.08.1/sunrpc/rpcsvc/klm_prot.x --- glibc-1.07/sunrpc/rpcsvc/klm_prot.x +++ glibc-1.08.1/sunrpc/rpcsvc/klm_prot.x Mon Feb 14 21:48:59 1994 @@ -0,0 +1,134 @@ +/* @(#)klm_prot.x 2.1 88/08/01 4.0 RPCSRC */ +/* @(#)klm_prot.x 1.7 87/07/08 Copyr 1987 Sun Micro */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +/* + * Kernel/lock manager protocol definition + * Copyright (C) 1986 Sun Microsystems, Inc. + * + * protocol used between the UNIX kernel (the "client") and the + * local lock manager. The local lock manager is a deamon running + * above the kernel. + */ + +const LM_MAXSTRLEN = 1024; + +/* + * lock manager status returns + */ +enum klm_stats { + klm_granted = 0, /* lock is granted */ + klm_denied = 1, /* lock is denied */ + klm_denied_nolocks = 2, /* no lock entry available */ + klm_working = 3 /* lock is being processed */ +}; + +/* + * lock manager lock identifier + */ +struct klm_lock { + string server_name; + netobj fh; /* a counted file handle */ + int pid; /* holder of the lock */ + unsigned l_offset; /* beginning offset of the lock */ + unsigned l_len; /* byte length of the lock; + * zero means through end of file */ +}; + +/* + * lock holder identifier + */ +struct klm_holder { + bool exclusive; /* FALSE if shared lock */ + int svid; /* holder of the lock (pid) */ + unsigned l_offset; /* beginning offset of the lock */ + unsigned l_len; /* byte length of the lock; + * zero means through end of file */ +}; + +/* + * reply to KLM_LOCK / KLM_UNLOCK / KLM_CANCEL + */ +struct klm_stat { + klm_stats stat; +}; + +/* + * reply to a KLM_TEST call + */ +union klm_testrply switch (klm_stats stat) { + case klm_denied: + struct klm_holder holder; + default: /* All other cases return no arguments */ + void; +}; + + +/* + * arguments to KLM_LOCK + */ +struct klm_lockargs { + bool block; + bool exclusive; + struct klm_lock alock; +}; + +/* + * arguments to KLM_TEST + */ +struct klm_testargs { + bool exclusive; + struct klm_lock alock; +}; + +/* + * arguments to KLM_UNLOCK + */ +struct klm_unlockargs { + struct klm_lock alock; +}; + +program KLM_PROG { + version KLM_VERS { + + klm_testrply KLM_TEST (struct klm_testargs) = 1; + + klm_stat KLM_LOCK (struct klm_lockargs) = 2; + + klm_stat KLM_CANCEL (struct klm_lockargs) = 3; + /* klm_granted=> the cancel request fails due to lock is already granted */ + /* klm_denied=> the cancel request successfully aborts +lock request */ + + klm_stat KLM_UNLOCK (struct klm_unlockargs) = 4; + } = 1; +} = 100020; + diff -ruN glibc-1.07/sunrpc/rpcsvc/mount.x glibc-1.08.1/sunrpc/rpcsvc/mount.x --- glibc-1.07/sunrpc/rpcsvc/mount.x +++ glibc-1.08.1/sunrpc/rpcsvc/mount.x Sun Feb 6 21:47:38 1994 @@ -0,0 +1,161 @@ +/* @(#)mount.x 2.1 88/08/01 4.0 RPCSRC */ +/* @(#)mount.x 1.2 87/09/18 Copyr 1987 Sun Micro */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +/* + * Protocol description for the mount program + */ + + +const MNTPATHLEN = 1024; /* maximum bytes in a pathname argument */ +const MNTNAMLEN = 255; /* maximum bytes in a name argument */ +const FHSIZE = 32; /* size in bytes of a file handle */ + +/* + * The fhandle is the file handle that the server passes to the client. + * All file operations are done using the file handles to refer to a file + * or a directory. The file handle can contain whatever information the + * server needs to distinguish an individual file. + */ +typedef opaque fhandle[FHSIZE]; + +/* + * If a status of zero is returned, the call completed successfully, and + * a file handle for the directory follows. A non-zero status indicates + * some sort of error. The status corresponds with UNIX error numbers. + */ +union fhstatus switch (unsigned fhs_status) { +case 0: + fhandle fhs_fhandle; +default: + void; +}; + +/* + * The type dirpath is the pathname of a directory + */ +typedef string dirpath; + +/* + * The type name is used for arbitrary names (hostnames, groupnames) + */ +typedef string name; + +/* + * A list of who has what mounted + */ +typedef struct mountbody *mountlist; +struct mountbody { + name ml_hostname; + dirpath ml_directory; + mountlist ml_next; +}; + +/* + * A list of netgroups + */ +typedef struct groupnode *groups; +struct groupnode { + name gr_name; + groups gr_next; +}; + +/* + * A list of what is exported and to whom + */ +typedef struct exportnode *exports; +struct exportnode { + dirpath ex_dir; + groups ex_groups; + exports ex_next; +}; + +program MOUNTPROG { + /* + * Version one of the mount protocol communicates with version two + * of the NFS protocol. The only connecting point is the fhandle + * structure, which is the same for both protocols. + */ + version MOUNTVERS { + /* + * Does no work. It is made available in all RPC services + * to allow server reponse testing and timing + */ + void + MOUNTPROC_NULL(void) = 0; + + /* + * If fhs_status is 0, then fhs_fhandle contains the + * file handle for the directory. This file handle may + * be used in the NFS protocol. This procedure also adds + * a new entry to the mount list for this client mounting + * the directory. + * Unix authentication required. + */ + fhstatus + MOUNTPROC_MNT(dirpath) = 1; + + /* + * Returns the list of remotely mounted filesystems. The + * mountlist contains one entry for each hostname and + * directory pair. + */ + mountlist + MOUNTPROC_DUMP(void) = 2; + + /* + * Removes the mount list entry for the directory + * Unix authentication required. + */ + void + MOUNTPROC_UMNT(dirpath) = 3; + + /* + * Removes all of the mount list entries for this client + * Unix authentication required. + */ + void + MOUNTPROC_UMNTALL(void) = 4; + + /* + * Returns a list of all the exported filesystems, and which + * machines are allowed to import it. + */ + exports + MOUNTPROC_EXPORT(void) = 5; + + /* + * Identical to MOUNTPROC_EXPORT above + */ + exports + MOUNTPROC_EXPORTALL(void) = 6; + } = 1; +} = 100005; diff -ruN glibc-1.07/sunrpc/rpcsvc/nfs_prot.x glibc-1.08.1/sunrpc/rpcsvc/nfs_prot.x --- glibc-1.07/sunrpc/rpcsvc/nfs_prot.x +++ glibc-1.08.1/sunrpc/rpcsvc/nfs_prot.x Sun Feb 6 21:47:38 1994 @@ -0,0 +1,355 @@ +/* @(#)nfs_prot.x 2.1 88/08/01 4.0 RPCSRC */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +/* + * nfs_prot.x 1.2 87/10/12 + * Copyright 1987 Sun Microsystems, Inc. + */ +const NFS_PORT = 2049; +const NFS_MAXDATA = 8192; +const NFS_MAXPATHLEN = 1024; +const NFS_MAXNAMLEN = 255; +const NFS_FHSIZE = 32; +const NFS_COOKIESIZE = 4; +const NFS_FIFO_DEV = -1; /* size kludge for named pipes */ + +/* + * File types + */ +const NFSMODE_FMT = 0170000; /* type of file */ +const NFSMODE_DIR = 0040000; /* directory */ +const NFSMODE_CHR = 0020000; /* character special */ +const NFSMODE_BLK = 0060000; /* block special */ +const NFSMODE_REG = 0100000; /* regular */ +const NFSMODE_LNK = 0120000; /* symbolic link */ +const NFSMODE_SOCK = 0140000; /* socket */ +const NFSMODE_FIFO = 0010000; /* fifo */ + +/* + * Error status + */ +enum nfsstat { + NFS_OK= 0, /* no error */ + NFSERR_PERM=1, /* Not owner */ + NFSERR_NOENT=2, /* No such file or directory */ + NFSERR_IO=5, /* I/O error */ + NFSERR_NXIO=6, /* No such device or address */ + NFSERR_ACCES=13, /* Permission denied */ + NFSERR_EXIST=17, /* File exists */ + NFSERR_NODEV=19, /* No such device */ + NFSERR_NOTDIR=20, /* Not a directory*/ + NFSERR_ISDIR=21, /* Is a directory */ + NFSERR_FBIG=27, /* File too large */ + NFSERR_NOSPC=28, /* No space left on device */ + NFSERR_ROFS=30, /* Read-only file system */ + NFSERR_NAMETOOLONG=63, /* File name too long */ + NFSERR_NOTEMPTY=66, /* Directory not empty */ + NFSERR_DQUOT=69, /* Disc quota exceeded */ + NFSERR_STALE=70, /* Stale NFS file handle */ + NFSERR_WFLUSH=99 /* write cache flushed */ +}; + +/* + * File types + */ +enum ftype { + NFNON = 0, /* non-file */ + NFREG = 1, /* regular file */ + NFDIR = 2, /* directory */ + NFBLK = 3, /* block special */ + NFCHR = 4, /* character special */ + NFLNK = 5, /* symbolic link */ + NFSOCK = 6, /* unix domain sockets */ + NFBAD = 7, /* unused */ + NFFIFO = 8 /* named pipe */ +}; + +/* + * File access handle + */ +struct nfs_fh { + opaque data[NFS_FHSIZE]; +}; + +/* + * Timeval + */ +struct nfstime { + unsigned seconds; + unsigned useconds; +}; + + +/* + * File attributes + */ +struct fattr { + ftype type; /* file type */ + unsigned mode; /* protection mode bits */ + unsigned nlink; /* # hard links */ + unsigned uid; /* owner user id */ + unsigned gid; /* owner group id */ + unsigned size; /* file size in bytes */ + unsigned blocksize; /* prefered block size */ + unsigned rdev; /* special device # */ + unsigned blocks; /* Kb of disk used by file */ + unsigned fsid; /* device # */ + unsigned fileid; /* inode # */ + nfstime atime; /* time of last access */ + nfstime mtime; /* time of last modification */ + nfstime ctime; /* time of last change */ +}; + +/* + * File attributes which can be set + */ +struct sattr { + unsigned mode; /* protection mode bits */ + unsigned uid; /* owner user id */ + unsigned gid; /* owner group id */ + unsigned size; /* file size in bytes */ + nfstime atime; /* time of last access */ + nfstime mtime; /* time of last modification */ +}; + + +typedef string filename; +typedef string nfspath; + +/* + * Reply status with file attributes + */ +union attrstat switch (nfsstat status) { +case NFS_OK: + fattr attributes; +default: + void; +}; + +struct sattrargs { + nfs_fh file; + sattr attributes; +}; + +/* + * Arguments for directory operations + */ +struct diropargs { + nfs_fh dir; /* directory file handle */ + filename name; /* name (up to NFS_MAXNAMLEN bytes) */ +}; + +struct diropokres { + nfs_fh file; + fattr attributes; +}; + +/* + * Results from directory operation + */ +union diropres switch (nfsstat status) { +case NFS_OK: + diropokres diropres; +default: + void; +}; + +union readlinkres switch (nfsstat status) { +case NFS_OK: + nfspath data; +default: + void; +}; + +/* + * Arguments to remote read + */ +struct readargs { + nfs_fh file; /* handle for file */ + unsigned offset; /* byte offset in file */ + unsigned count; /* immediate read count */ + unsigned totalcount; /* total read count (from this offset)*/ +}; + +/* + * Status OK portion of remote read reply + */ +struct readokres { + fattr attributes; /* attributes, need for pagin*/ + opaque data; +}; + +union readres switch (nfsstat status) { +case NFS_OK: + readokres reply; +default: + void; +}; + +/* + * Arguments to remote write + */ +struct writeargs { + nfs_fh file; /* handle for file */ + unsigned beginoffset; /* beginning byte offset in file */ + unsigned offset; /* current byte offset in file */ + unsigned totalcount; /* total write count (to this offset)*/ + opaque data; +}; + +struct createargs { + diropargs where; + sattr attributes; +}; + +struct renameargs { + diropargs from; + diropargs to; +}; + +struct linkargs { + nfs_fh from; + diropargs to; +}; + +struct symlinkargs { + diropargs from; + nfspath to; + sattr attributes; +}; + + +typedef opaque nfscookie[NFS_COOKIESIZE]; + +/* + * Arguments to readdir + */ +struct readdirargs { + nfs_fh dir; /* directory handle */ + nfscookie cookie; + unsigned count; /* number of directory bytes to read */ +}; + +struct entry { + unsigned fileid; + filename name; + nfscookie cookie; + entry *nextentry; +}; + +struct dirlist { + entry *entries; + bool eof; +}; + +union readdirres switch (nfsstat status) { +case NFS_OK: + dirlist reply; +default: + void; +}; + +struct statfsokres { + unsigned tsize; /* preferred transfer size in bytes */ + unsigned bsize; /* fundamental file system block size */ + unsigned blocks; /* total blocks in file system */ + unsigned bfree; /* free blocks in fs */ + unsigned bavail; /* free blocks avail to non-superuser */ +}; + +union statfsres switch (nfsstat status) { +case NFS_OK: + statfsokres reply; +default: + void; +}; + +/* + * Remote file service routines + */ +program NFS_PROGRAM { + version NFS_VERSION { + void + NFSPROC_NULL(void) = 0; + + attrstat + NFSPROC_GETATTR(nfs_fh) = 1; + + attrstat + NFSPROC_SETATTR(sattrargs) = 2; + + void + NFSPROC_ROOT(void) = 3; + + diropres + NFSPROC_LOOKUP(diropargs) = 4; + + readlinkres + NFSPROC_READLINK(nfs_fh) = 5; + + readres + NFSPROC_READ(readargs) = 6; + + void + NFSPROC_WRITECACHE(void) = 7; + + attrstat + NFSPROC_WRITE(writeargs) = 8; + + diropres + NFSPROC_CREATE(createargs) = 9; + + nfsstat + NFSPROC_REMOVE(diropargs) = 10; + + nfsstat + NFSPROC_RENAME(renameargs) = 11; + + nfsstat + NFSPROC_LINK(linkargs) = 12; + + nfsstat + NFSPROC_SYMLINK(symlinkargs) = 13; + + diropres + NFSPROC_MKDIR(createargs) = 14; + + nfsstat + NFSPROC_RMDIR(diropargs) = 15; + + readdirres + NFSPROC_READDIR(readdirargs) = 16; + + statfsres + NFSPROC_STATFS(nfs_fh) = 17; + } = 2; +} = 100003; + diff -ruN glibc-1.07/sunrpc/rpcsvc/nlm_prot.x glibc-1.08.1/sunrpc/rpcsvc/nlm_prot.x --- glibc-1.07/sunrpc/rpcsvc/nlm_prot.x +++ glibc-1.08.1/sunrpc/rpcsvc/nlm_prot.x Sun Feb 6 21:47:38 1994 @@ -0,0 +1,179 @@ +/* @(#)nlm_prot.x 2.1 88/08/01 4.0 RPCSRC */ +/* @(#)nlm_prot.x 1.8 87/09/21 Copyr 1987 Sun Micro */ + +/* + * Network lock manager protocol definition + * Copyright (C) 1986 Sun Microsystems, Inc. + * + * protocol used between local lock manager and remote lock manager + */ + +#ifdef RPC_HDR +%#define LM_MAXSTRLEN 1024 +%#define MAXNAMELEN LM_MAXSTRLEN+1 +#endif + +/* + * status of a call to the lock manager + */ +enum nlm_stats { + nlm_granted = 0, + nlm_denied = 1, + nlm_denied_nolocks = 2, + nlm_blocked = 3, + nlm_denied_grace_period = 4 +}; + +struct nlm_holder { + bool exclusive; + int svid; + netobj oh; + unsigned l_offset; + unsigned l_len; +}; + +union nlm_testrply switch (nlm_stats stat) { + case nlm_denied: + struct nlm_holder holder; + default: + void; +}; + +struct nlm_stat { + nlm_stats stat; +}; + +struct nlm_res { + netobj cookie; + nlm_stat stat; +}; + +struct nlm_testres { + netobj cookie; + nlm_testrply stat; +}; + +struct nlm_lock { + string caller_name; + netobj fh; /* identify a file */ + netobj oh; /* identify owner of a lock */ + int svid; /* generated from pid for svid */ + unsigned l_offset; + unsigned l_len; +}; + +struct nlm_lockargs { + netobj cookie; + bool block; + bool exclusive; + struct nlm_lock alock; + bool reclaim; /* used for recovering locks */ + int state; /* specify local status monitor state */ +}; + +struct nlm_cancargs { + netobj cookie; + bool block; + bool exclusive; + struct nlm_lock alock; +}; + +struct nlm_testargs { + netobj cookie; + bool exclusive; + struct nlm_lock alock; +}; + +struct nlm_unlockargs { + netobj cookie; + struct nlm_lock alock; +}; + + +#ifdef RPC_HDR +%/* +% * The following enums are actually bit encoded for efficient +% * boolean algebra.... DON'T change them..... +% */ +#endif +enum fsh_mode { + fsm_DN = 0, /* deny none */ + fsm_DR = 1, /* deny read */ + fsm_DW = 2, /* deny write */ + fsm_DRW = 3 /* deny read/write */ +}; + +enum fsh_access { + fsa_NONE = 0, /* for completeness */ + fsa_R = 1, /* read only */ + fsa_W = 2, /* write only */ + fsa_RW = 3 /* read/write */ +}; + +struct nlm_share { + string caller_name; + netobj fh; + netobj oh; + fsh_mode mode; + fsh_access access; +}; + +struct nlm_shareargs { + netobj cookie; + nlm_share share; + bool reclaim; +}; + +struct nlm_shareres { + netobj cookie; + nlm_stats stat; + int sequence; +}; + +struct nlm_notify { + string name; + long state; +}; + +/* + * Over-the-wire protocol used between the network lock managers + */ + +program NLM_PROG { + version NLM_VERS { + + nlm_testres NLM_TEST(struct nlm_testargs) = 1; + + nlm_res NLM_LOCK(struct nlm_lockargs) = 2; + + nlm_res NLM_CANCEL(struct nlm_cancargs) = 3; + nlm_res NLM_UNLOCK(struct nlm_unlockargs) = 4; + + /* + * remote lock manager call-back to grant lock + */ + nlm_res NLM_GRANTED(struct nlm_testargs)= 5; + /* + * message passing style of requesting lock + */ + void NLM_TEST_MSG(struct nlm_testargs) = 6; + void NLM_LOCK_MSG(struct nlm_lockargs) = 7; + void NLM_CANCEL_MSG(struct nlm_cancargs) =8; + void NLM_UNLOCK_MSG(struct nlm_unlockargs) = 9; + void NLM_GRANTED_MSG(struct nlm_testargs) = 10; + void NLM_TEST_RES(nlm_testres) = 11; + void NLM_LOCK_RES(nlm_res) = 12; + void NLM_CANCEL_RES(nlm_res) = 13; + void NLM_UNLOCK_RES(nlm_res) = 14; + void NLM_GRANTED_RES(nlm_res) = 15; + } = 1; + + version NLM_VERSX { + nlm_shareres NLM_SHARE(nlm_shareargs) = 20; + nlm_shareres NLM_UNSHARE(nlm_shareargs) = 21; + nlm_res NLM_NM_LOCK(nlm_lockargs) = 22; + void NLM_FREE_ALL(nlm_notify) = 23; + } = 3; + +} = 100021; + diff -ruN glibc-1.07/sunrpc/rpcsvc/rex.x glibc-1.08.1/sunrpc/rpcsvc/rex.x --- glibc-1.07/sunrpc/rpcsvc/rex.x +++ glibc-1.08.1/sunrpc/rpcsvc/rex.x Sun Feb 6 21:47:38 1994 @@ -0,0 +1,229 @@ +/* @(#)rex.x 2.1 88/08/01 4.0 RPCSRC */ +/* @(#)rex.x 1.3 87/09/18 Copyr 1987 Sun Micro */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +/* + * Remote execution (rex) protocol specification + */ + +const STRINGSIZE = 1024; +typedef string rexstring<1024>; + +/* + * values to pass to REXPROC_SIGNAL + */ +const SIGINT = 2; /* interrupt */ + +/* + * Values for rst_flags, below + */ +const REX_INTERACTIVE = 1; /* interactive mode */ + +struct rex_start { + rexstring rst_cmd<>; /* list of command and args */ + rexstring rst_host; /* working directory host name */ + rexstring rst_fsname; /* working directory file system name */ + rexstring rst_dirwithin;/* working directory within file system */ + rexstring rst_env<>; /* list of environment */ + unsigned int rst_port0; /* port for stdin */ + unsigned int rst_port1; /* port for stdout */ + unsigned int rst_port2; /* port for stderr */ + unsigned int rst_flags; /* options - see const above */ +}; + +struct rex_result { + int rlt_stat; /* integer status code */ + rexstring rlt_message; /* string message for human consumption */ +}; + + +struct sgttyb { + unsigned four; /* always equals 4 */ + opaque chars[4]; + /* chars[0] == input speed */ + /* chars[1] == output speed */ + /* chars[2] == kill character */ + /* chars[3] == erase character */ + unsigned flags; +}; +/* values for speeds above (baud rates) */ +const B0 = 0; +const B50 = 1; +const B75 = 2; +const B110 = 3; +const B134 = 4; +const B150 = 5; +const B200 = 6; +const B300 = 7; +const B600 = 8; +const B1200 = 9; +const B1800 = 10; +const B2400 = 11; +const B4800 = 12; +const B9600 = 13; +const B19200 = 14; +const B38400 = 15; + +/* values for flags above */ +const TANDEM = 0x00000001; /* send stopc on out q full */ +const CBREAK = 0x00000002; /* half-cooked mode */ +const LCASE = 0x00000004; /* simulate lower case */ +const ECHO = 0x00000008; /* echo input */ +const CRMOD = 0x00000010; /* map \r to \r\n on output */ +const RAW = 0x00000020; /* no i/o processing */ +const ODDP = 0x00000040; /* get/send odd parity */ +const EVENP = 0x00000080; /* get/send even parity */ +const ANYP = 0x000000c0; /* get any parity/send none */ +const NLDELAY = 0x00000300; /* \n delay */ +const NL0 = 0x00000000; +const NL1 = 0x00000100; /* tty 37 */ +const NL2 = 0x00000200; /* vt05 */ +const NL3 = 0x00000300; +const TBDELAY = 0x00000c00; /* horizontal tab delay */ +const TAB0 = 0x00000000; +const TAB1 = 0x00000400; /* tty 37 */ +const TAB2 = 0x00000800; +const XTABS = 0x00000c00; /* expand tabs on output */ +const CRDELAY = 0x00003000; /* \r delay */ +const CR0 = 0x00000000; +const CR1 = 0x00001000; /* tn 300 */ +const CR2 = 0x00002000; /* tty 37 */ +const CR3 = 0x00003000; /* concept 100 */ +const VTDELAY = 0x00004000; /* vertical tab delay */ +const FF0 = 0x00000000; +const FF1 = 0x00004000; /* tty 37 */ +const BSDELAY = 0x00008000; /* \b delay */ +const BS0 = 0x00000000; +const BS1 = 0x00008000; +const CRTBS = 0x00010000; /* do backspacing for crt */ +const PRTERA = 0x00020000; /* \ ... / erase */ +const CRTERA = 0x00040000; /* " \b " to wipe out char */ +const TILDE = 0x00080000; /* hazeltine tilde kludge */ +const MDMBUF = 0x00100000; /* start/stop output on carrier intr */ +const LITOUT = 0x00200000; /* literal output */ +const TOSTOP = 0x00400000; /* SIGTTOU on background output */ +const FLUSHO = 0x00800000; /* flush output to terminal */ +const NOHANG = 0x01000000; /* no SIGHUP on carrier drop */ +const L001000 = 0x02000000; +const CRTKIL = 0x04000000; /* kill line with " \b " */ +const PASS8 = 0x08000000; +const CTLECH = 0x10000000; /* echo control chars as ^X */ +const PENDIN = 0x20000000; /* tp->t_rawq needs reread */ +const DECCTQ = 0x40000000; /* only ^Q starts after ^S */ +const NOFLSH = 0x80000000; /* no output flush on signal */ + +struct tchars { + unsigned six; /* always equals 6 */ + opaque chars[6]; + /* chars[0] == interrupt char */ + /* chars[1] == quit char */ + /* chars[2] == start output char */ + /* chars[3] == stop output char */ + /* chars[4] == end-of-file char */ + /* chars[5] == input delimeter (like nl) */ +}; + +struct ltchars { + unsigned six; /* always equals 6 */ + opaque chars[6]; + /* chars[0] == stop process signal */ + /* chars[1] == delayed stop process signal */ + /* chars[2] == reprint line */ + /* chars[3] == flush output */ + /* chars[4] == word erase */ + /* chars[5] == literal next character */ + unsigned mode; +}; + +struct rex_ttysize { + int ts_lines; + int ts_cols; +}; + +struct rex_ttymode { + sgttyb basic; /* standard unix tty flags */ + tchars more; /* interrupt, kill characters, etc. */ + ltchars yetmore; /* special Berkeley characters */ + unsigned andmore; /* and Berkeley modes */ +}; + +/* values for andmore above */ +const LCRTBS = 0x0001; /* do backspacing for crt */ +const LPRTERA = 0x0002; /* \ ... / erase */ +const LCRTERA = 0x0004; /* " \b " to wipe out char */ +const LTILDE = 0x0008; /* hazeltine tilde kludge */ +const LMDMBUF = 0x0010; /* start/stop output on carrier intr */ +const LLITOUT = 0x0020; /* literal output */ +const LTOSTOP = 0x0040; /* SIGTTOU on background output */ +const LFLUSHO = 0x0080; /* flush output to terminal */ +const LNOHANG = 0x0100; /* no SIGHUP on carrier drop */ +const LL001000 = 0x0200; +const LCRTKIL = 0x0400; /* kill line with " \b " */ +const LPASS8 = 0x0800; +const LCTLECH = 0x1000; /* echo control chars as ^X */ +const LPENDIN = 0x2000; /* needs reread */ +const LDECCTQ = 0x4000; /* only ^Q starts after ^S */ +const LNOFLSH = 0x8000; /* no output flush on signal */ + +program REXPROG { + version REXVERS { + + /* + * Start remote execution + */ + rex_result + REXPROC_START(rex_start) = 1; + + /* + * Wait for remote execution to terminate + */ + rex_result + REXPROC_WAIT(void) = 2; + + /* + * Send tty modes + */ + void + REXPROC_MODES(rex_ttymode) = 3; + + /* + * Send window size change + */ + void + REXPROC_WINCH(rex_ttysize) = 4; + + /* + * Send other signal + */ + void + REXPROC_SIGNAL(int) = 5; + } = 1; +} = 100017; diff -ruN glibc-1.07/sunrpc/rpcsvc/rnusers.x glibc-1.08.1/sunrpc/rpcsvc/rnusers.x --- glibc-1.07/sunrpc/rpcsvc/rnusers.x +++ glibc-1.08.1/sunrpc/rpcsvc/rnusers.x Sun Feb 6 21:47:38 1994 @@ -0,0 +1,86 @@ +/* @(#)rnusers.x 2.1 88/08/01 4.0 RPCSRC */ +/* @(#)rnusers.x 1.2 87/09/20 Copyr 1987 Sun Micro */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +/* + * Find out about remote users + */ + +const MAXUSERS = 100; +const MAXUTLEN = 256; + +struct utmp { + string ut_line; + string ut_name; + string ut_host; + int ut_time; +}; + + +struct utmpidle { + utmp ui_utmp; + unsigned int ui_idle; +}; + +typedef utmp utmparr; + +typedef utmpidle utmpidlearr; + +program RUSERSPROG { + /* + * Includes idle information + */ + version RUSERSVERS_IDLE { + int + RUSERSPROC_NUM(void) = 1; + + utmpidlearr + RUSERSPROC_NAMES(void) = 2; + + utmpidlearr + RUSERSPROC_ALLNAMES(void) = 3; + } = 1; + + /* + * Old version does not include idle information + */ + version RUSERSVERS_ORIG { + int + RUSERSPROC_NUM(void) = 1; + + utmparr + RUSERSPROC_NAMES(void) = 2; + + utmparr + RUSERSPROC_ALLNAMES(void) = 3; + } = 2; +} = 100002; + diff -ruN glibc-1.07/sunrpc/rpcsvc/rquota.x glibc-1.08.1/sunrpc/rpcsvc/rquota.x --- glibc-1.07/sunrpc/rpcsvc/rquota.x +++ glibc-1.08.1/sunrpc/rpcsvc/rquota.x Sun Feb 6 21:47:38 1994 @@ -0,0 +1,61 @@ +/* @(#)rquota.x 2.1 88/08/01 4.0 RPCSRC */ +/* @(#)rquota.x 1.2 87/09/20 Copyr 1987 Sun Micro */ + +/* + * Remote quota protocol + * Requires unix authentication + */ + +const RQ_PATHLEN = 1024; + +struct getquota_args { + string gqa_pathp; /* path to filesystem of interest */ + int gqa_uid; /* inquire about quota for uid */ +}; + +/* + * remote quota structure + */ +struct rquota { + int rq_bsize; /* block size for block counts */ + bool rq_active; /* indicates whether quota is active */ + unsigned int rq_bhardlimit; /* absolute limit on disk blks alloc */ + unsigned int rq_bsoftlimit; /* preferred limit on disk blks */ + unsigned int rq_curblocks; /* current block count */ + unsigned int rq_fhardlimit; /* absolute limit on allocated files */ + unsigned int rq_fsoftlimit; /* preferred file limit */ + unsigned int rq_curfiles; /* current # allocated files */ + unsigned int rq_btimeleft; /* time left for excessive disk use */ + unsigned int rq_ftimeleft; /* time left for excessive files */ +}; + +enum gqr_status { + Q_OK = 1, /* quota returned */ + Q_NOQUOTA = 2, /* noquota for uid */ + Q_EPERM = 3 /* no permission to access quota */ +}; + +union getquota_rslt switch (gqr_status status) { +case Q_OK: + rquota gqr_rquota; /* valid if status == Q_OK */ +case Q_NOQUOTA: + void; +case Q_EPERM: + void; +}; + +program RQUOTAPROG { + version RQUOTAVERS { + /* + * Get all quotas + */ + getquota_rslt + RQUOTAPROC_GETQUOTA(getquota_args) = 1; + + /* + * Get active quotas only + */ + getquota_rslt + RQUOTAPROC_GETACTIVEQUOTA(getquota_args) = 2; + } = 1; +} = 100011; diff -ruN glibc-1.07/sunrpc/rpcsvc/rstat.x glibc-1.08.1/sunrpc/rpcsvc/rstat.x --- glibc-1.07/sunrpc/rpcsvc/rstat.x +++ glibc-1.08.1/sunrpc/rpcsvc/rstat.x Sun Feb 6 21:47:39 1994 @@ -0,0 +1,145 @@ +/* @(#)rstat.x 2.2 88/08/01 4.0 RPCSRC */ +/* @(#)rstat.x 1.2 87/09/18 Copyr 1987 Sun Micro */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +/* + * Gather statistics on remote machines + */ + +#ifdef RPC_HDR + +%#ifndef FSCALE +%/* +% * Scale factor for scaled integers used to count load averages. +% */ +%#define FSHIFT 8 /* bits to right of fixed binary point */ +%#define FSCALE (1<; +}; + +struct my_id { + string my_name; /* name of the site iniates the monitoring request*/ + int my_prog; /* rpc program # of the requesting process */ + int my_vers; /* rpc version # of the requesting process */ + int my_proc; /* rpc procedure # of the requesting process */ +}; + +struct mon_id { + string mon_name; /* name of the site to be monitored */ + struct my_id my_id; +}; + + +struct mon{ + struct mon_id mon_id; + opaque priv[16]; /* private information to store at monitor for requesting process */ +}; + + +/* + * state # of status monitor monitonically increases each time + * status of the site changes: + * an even number (>= 0) indicates the site is down and + * an odd number (> 0) indicates the site is up; + */ +struct sm_stat { + int state; /* state # of status monitor */ +}; + +enum res { + stat_succ = 0, /* status monitor agrees to monitor */ + stat_fail = 1 /* status monitor cannot monitor */ +}; + +struct sm_stat_res { + res res_stat; + int state; +}; + +/* + * structure of the status message sent back by the status monitor + * when monitor site status changes + */ +struct status { + string mon_name; + int state; + opaque priv[16]; /* stored private information */ +}; diff -ruN glibc-1.07/sunrpc/rpcsvc/spray.x glibc-1.08.1/sunrpc/rpcsvc/spray.x --- glibc-1.07/sunrpc/rpcsvc/spray.x +++ glibc-1.08.1/sunrpc/rpcsvc/spray.x Sun Feb 6 21:47:39 1994 @@ -0,0 +1,84 @@ +/* @(#)spray.x 2.1 88/08/01 4.0 RPCSRC */ +/* @(#)spray.x 1.2 87/09/18 Copyr 1987 Sun Micro */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +/* + * Spray a server with packets + * Useful for testing flakiness of network interfaces + */ + +const SPRAYMAX = 8845; /* max amount can spray */ + +/* + * GMT since 0:00, 1 January 1970 + */ +struct spraytimeval { + unsigned int sec; + unsigned int usec; +}; + +/* + * spray statistics + */ +struct spraycumul { + unsigned int counter; + spraytimeval clock; +}; + +/* + * spray data + */ +typedef opaque sprayarr; + +program SPRAYPROG { + version SPRAYVERS { + /* + * Just throw away the data and increment the counter + * This call never returns, so the client should always + * time it out. + */ + void + SPRAYPROC_SPRAY(sprayarr) = 1; + + /* + * Get the value of the counter and elapsed time since + * last CLEAR. + */ + spraycumul + SPRAYPROC_GET(void) = 2; + + /* + * Clear the counter and reset the elapsed time + */ + void + SPRAYPROC_CLEAR(void) = 3; + } = 1; +} = 100012; diff -ruN glibc-1.07/sunrpc/rpcsvc/yp.x glibc-1.08.1/sunrpc/rpcsvc/yp.x --- glibc-1.07/sunrpc/rpcsvc/yp.x +++ glibc-1.08.1/sunrpc/rpcsvc/yp.x Sun Feb 6 21:47:39 1994 @@ -0,0 +1,291 @@ +/* @(#)yp.x 2.1 88/08/01 4.0 RPCSRC */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +/* + * Protocol description file for the Yellow Pages Service + */ + +const YPMAXRECORD = 1024; +const YPMAXDOMAIN = 64; +const YPMAXMAP = 64; +const YPMAXPEER = 64; + + +enum ypstat { + YP_TRUE = 1, + YP_NOMORE = 2, + YP_FALSE = 0, + YP_NOMAP = -1, + YP_NODOM = -2, + YP_NOKEY = -3, + YP_BADOP = -4, + YP_BADDB = -5, + YP_YPERR = -6, + YP_BADARGS = -7, + YP_VERS = -8 +}; + + +enum ypxfrstat { + YPXFR_SUCC = 1, + YPXFR_AGE = 2, + YPXFR_NOMAP = -1, + YPXFR_NODOM = -2, + YPXFR_RSRC = -3, + YPXFR_RPC = -4, + YPXFR_MADDR = -5, + YPXFR_YPERR = -6, + YPXFR_BADARGS = -7, + YPXFR_DBM = -8, + YPXFR_FILE = -9, + YPXFR_SKEW = -10, + YPXFR_CLEAR = -11, + YPXFR_FORCE = -12, + YPXFR_XFRERR = -13, + YPXFR_REFUSED = -14 +}; + + +typedef string domainname; +typedef string mapname; +typedef string peername; +typedef opaque keydat; +typedef opaque valdat; + + +struct ypmap_parms { + domainname domain; + mapname map; + unsigned int ordernum; + peername peer; +}; + +struct ypreq_key { + domainname domain; + mapname map; + keydat key; +}; + +struct ypreq_nokey { + domainname domain; + mapname map; +}; + +struct ypreq_xfr { + ypmap_parms map_parms; + unsigned int transid; + unsigned int prog; + unsigned int port; +}; + + +struct ypresp_val { + ypstat stat; + valdat val; +}; + +struct ypresp_key_val { + ypstat stat; + keydat key; + valdat val; +}; + + +struct ypresp_master { + ypstat stat; + peername peer; +}; + +struct ypresp_order { + ypstat stat; + unsigned int ordernum; +}; + +union ypresp_all switch (bool more) { +case TRUE: + ypresp_key_val val; +case FALSE: + void; +}; + +struct ypresp_xfr { + unsigned int transid; + ypxfrstat xfrstat; +}; + +struct ypmaplist { + mapname map; + ypmaplist *next; +}; + +struct ypresp_maplist { + ypstat stat; + ypmaplist *maps; +}; + +enum yppush_status { + YPPUSH_SUCC = 1, /* Success */ + YPPUSH_AGE = 2, /* Master's version not newer */ + YPPUSH_NOMAP = -1, /* Can't find server for map */ + YPPUSH_NODOM = -2, /* Domain not supported */ + YPPUSH_RSRC = -3, /* Local resource alloc failure */ + YPPUSH_RPC = -4, /* RPC failure talking to server */ + YPPUSH_MADDR = -5, /* Can't get master address */ + YPPUSH_YPERR = -6, /* YP server/map db error */ + YPPUSH_BADARGS = -7, /* Request arguments bad */ + YPPUSH_DBM = -8, /* Local dbm operation failed */ + YPPUSH_FILE = -9, /* Local file I/O operation failed */ + YPPUSH_SKEW = -10, /* Map version skew during transfer */ + YPPUSH_CLEAR = -11, /* Can't send "Clear" req to local ypserv */ + YPPUSH_FORCE = -12, /* No local order number in map use -f flag. */ + YPPUSH_XFRERR = -13, /* ypxfr error */ + YPPUSH_REFUSED = -14 /* Transfer request refused by ypserv */ +}; + +struct yppushresp_xfr { + unsigned transid; + yppush_status status; +}; + +/* + * Response structure and overall result status codes. Success and failure + * represent two separate response message types. + */ + +enum ypbind_resptype { + YPBIND_SUCC_VAL = 1, + YPBIND_FAIL_VAL = 2 +}; + +struct ypbind_binding { + opaque ypbind_binding_addr[4]; /* In network order */ + opaque ypbind_binding_port[2]; /* In network order */ +}; + +union ypbind_resp switch (ypbind_resptype ypbind_status) { +case YPBIND_FAIL_VAL: + unsigned ypbind_error; +case YPBIND_SUCC_VAL: + ypbind_binding ypbind_bindinfo; +}; + +/* Detailed failure reason codes for response field ypbind_error*/ + +const YPBIND_ERR_ERR = 1; /* Internal error */ +const YPBIND_ERR_NOSERV = 2; /* No bound server for passed domain */ +const YPBIND_ERR_RESC = 3; /* System resource allocation failure */ + + +/* + * Request data structure for ypbind "Set domain" procedure. + */ +struct ypbind_setdom { + domainname ypsetdom_domain; + ypbind_binding ypsetdom_binding; + unsigned ypsetdom_vers; +}; + + +/* + * YP access protocol + */ +program YPPROG { + version YPVERS { + void + YPPROC_NULL(void) = 0; + + bool + YPPROC_DOMAIN(domainname) = 1; + + bool + YPPROC_DOMAIN_NONACK(domainname) = 2; + + ypresp_val + YPPROC_MATCH(ypreq_key) = 3; + + ypresp_key_val + YPPROC_FIRST(ypreq_key) = 4; + + ypresp_key_val + YPPROC_NEXT(ypreq_key) = 5; + + ypresp_xfr + YPPROC_XFR(ypreq_xfr) = 6; + + void + YPPROC_CLEAR(void) = 7; + + ypresp_all + YPPROC_ALL(ypreq_nokey) = 8; + + ypresp_master + YPPROC_MASTER(ypreq_nokey) = 9; + + ypresp_order + YPPROC_ORDER(ypreq_nokey) = 10; + + ypresp_maplist + YPPROC_MAPLIST(domainname) = 11; + } = 2; +} = 100004; + + +/* + * YPPUSHPROC_XFRRESP is the callback routine for result of YPPROC_XFR + */ +program YPPUSH_XFRRESPPROG { + version YPPUSH_XFRRESPVERS { + void + YPPUSHPROC_NULL(void) = 0; + + yppushresp_xfr + YPPUSHPROC_XFRRESP(void) = 1; + } = 1; +} = 0x40000000; /* transient: could be anything up to 0x5fffffff */ + + +/* + * YP binding protocol + */ +program YPBINDPROG { + version YPBINDVERS { + void + YPBINDPROC_NULL(void) = 0; + + ypbind_resp + YPBINDPROC_DOMAIN(domainname) = 1; + + void + YPBINDPROC_SETDOM(ypbind_setdom) = 2; + } = 2; +} = 100007; + + diff -ruN glibc-1.07/sunrpc/rpcsvc/yppasswd.x glibc-1.08.1/sunrpc/rpcsvc/yppasswd.x --- glibc-1.07/sunrpc/rpcsvc/yppasswd.x +++ glibc-1.08.1/sunrpc/rpcsvc/yppasswd.x Sun Feb 6 21:47:39 1994 @@ -0,0 +1,63 @@ +/* @(#)yppasswd.x 2.1 88/08/01 4.0 RPCSRC */ +/* @(#)yppasswd.x 1.1 87/04/13 Copyr 1987 Sun Micro */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +/* + * YP password update protocol + * Requires unix authentication + */ +program YPPASSWDPROG { + version YPPASSWDVERS { + /* + * Update my passwd entry + */ + int + YPPASSWDPROC_UPDATE(yppasswd) = 1; + } = 1; +} = 100009; + + +struct passwd { + string pw_name<>; /* username */ + string pw_passwd<>; /* encrypted password */ + int pw_uid; /* user id */ + int pw_gid; /* group id */ + string pw_gecos<>; /* in real life name */ + string pw_dir<>; /* home directory */ + string pw_shell<>; /* default shell */ +}; + +struct yppasswd { + string oldpass<>; /* unencrypted old password */ + passwd newpw; /* new passwd entry */ +}; + + diff -ruN glibc-1.07/sunrpc/svc.c glibc-1.08.1/sunrpc/svc.c --- glibc-1.07/sunrpc/svc.c +++ glibc-1.08.1/sunrpc/svc.c Sun Feb 6 16:42:47 1994 @@ -0,0 +1,479 @@ +/* @(#)svc.c 2.4 88/08/11 4.0 RPCSRC; from 1.44 88/02/08 SMI */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +#if !defined(lint) && defined(SCCSIDS) +static char sccsid[] = "@(#)svc.c 1.41 87/10/13 Copyr 1984 Sun Micro"; +#endif + +/* + * svc.c, Server-side remote procedure call interface. + * + * There are two sets of procedures here. The xprt routines are + * for handling transport handles. The svc routines handle the + * list of service routines. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#include +#include +#include + +extern int errno; + +#ifdef FD_SETSIZE +static SVCXPRT **xports; +#else +#define NOFILE 32 + +static SVCXPRT *xports[NOFILE]; +#endif /* def FD_SETSIZE */ + +#define NULL_SVC ((struct svc_callout *)0) +#define RQCRED_SIZE 400 /* this size is excessive */ + +/* + * The services list + * Each entry represents a set of procedures (an rpc program). + * The dispatch routine takes request structs and runs the + * apropriate procedure. + */ +static struct svc_callout { + struct svc_callout *sc_next; + u_long sc_prog; + u_long sc_vers; + void (*sc_dispatch)(); +} *svc_head; + +static struct svc_callout *svc_find(); + +/* *************** SVCXPRT related stuff **************** */ + +/* + * Activate a transport handle. + */ +void +xprt_register(xprt) + SVCXPRT *xprt; +{ + register int sock = xprt->xp_sock; + +#ifdef FD_SETSIZE + if (xports == NULL) { + xports = (SVCXPRT **) + mem_alloc(FD_SETSIZE * sizeof(SVCXPRT *)); + } + if (sock < _rpc_dtablesize()) { + xports[sock] = xprt; + FD_SET(sock, &svc_fdset); + } +#else + if (sock < NOFILE) { + xports[sock] = xprt; + svc_fds |= (1 << sock); + } +#endif /* def FD_SETSIZE */ + +} + +/* + * De-activate a transport handle. + */ +void +xprt_unregister(xprt) + SVCXPRT *xprt; +{ + register int sock = xprt->xp_sock; + +#ifdef FD_SETSIZE + if ((sock < _rpc_dtablesize()) && (xports[sock] == xprt)) { + xports[sock] = (SVCXPRT *)0; + FD_CLR(sock, &svc_fdset); + } +#else + if ((sock < NOFILE) && (xports[sock] == xprt)) { + xports[sock] = (SVCXPRT *)0; + svc_fds &= ~(1 << sock); + } +#endif /* def FD_SETSIZE */ +} + + +/* ********************** CALLOUT list related stuff ************* */ + +/* + * Add a service program to the callout list. + * The dispatch routine will be called when a rpc request for this + * program number comes in. + */ +bool_t +svc_register(xprt, prog, vers, dispatch, protocol) + SVCXPRT *xprt; + u_long prog; + u_long vers; + void (*dispatch)(); + int protocol; +{ + struct svc_callout *prev; + register struct svc_callout *s; + + if ((s = svc_find(prog, vers, &prev)) != NULL_SVC) { + if (s->sc_dispatch == dispatch) + goto pmap_it; /* he is registering another xptr */ + return (FALSE); + } + s = (struct svc_callout *)mem_alloc(sizeof(struct svc_callout)); + if (s == (struct svc_callout *)0) { + return (FALSE); + } + s->sc_prog = prog; + s->sc_vers = vers; + s->sc_dispatch = dispatch; + s->sc_next = svc_head; + svc_head = s; +pmap_it: + /* now register the information with the local binder service */ + if (protocol) { + return (pmap_set(prog, vers, protocol, xprt->xp_port)); + } + return (TRUE); +} + +/* + * Remove a service program from the callout list. + */ +void +svc_unregister(prog, vers) + u_long prog; + u_long vers; +{ + struct svc_callout *prev; + register struct svc_callout *s; + + if ((s = svc_find(prog, vers, &prev)) == NULL_SVC) + return; + if (prev == NULL_SVC) { + svc_head = s->sc_next; + } else { + prev->sc_next = s->sc_next; + } + s->sc_next = NULL_SVC; + mem_free((char *) s, (u_int) sizeof(struct svc_callout)); + /* now unregister the information with the local binder service */ + (void)pmap_unset(prog, vers); +} + +/* + * Search the callout list for a program number, return the callout + * struct. + */ +static struct svc_callout * +svc_find(prog, vers, prev) + u_long prog; + u_long vers; + struct svc_callout **prev; +{ + register struct svc_callout *s, *p; + + p = NULL_SVC; + for (s = svc_head; s != NULL_SVC; s = s->sc_next) { + if ((s->sc_prog == prog) && (s->sc_vers == vers)) + goto done; + p = s; + } +done: + *prev = p; + return (s); +} + +/* ******************* REPLY GENERATION ROUTINES ************ */ + +/* + * Send a reply to an rpc request + */ +bool_t +svc_sendreply(xprt, xdr_results, xdr_location) + register SVCXPRT *xprt; + xdrproc_t xdr_results; + caddr_t xdr_location; +{ + struct rpc_msg rply; + + rply.rm_direction = REPLY; + rply.rm_reply.rp_stat = MSG_ACCEPTED; + rply.acpted_rply.ar_verf = xprt->xp_verf; + rply.acpted_rply.ar_stat = SUCCESS; + rply.acpted_rply.ar_results.where = xdr_location; + rply.acpted_rply.ar_results.proc = xdr_results; + return (SVC_REPLY(xprt, &rply)); +} + +/* + * No procedure error reply + */ +void +svcerr_noproc(xprt) + register SVCXPRT *xprt; +{ + struct rpc_msg rply; + + rply.rm_direction = REPLY; + rply.rm_reply.rp_stat = MSG_ACCEPTED; + rply.acpted_rply.ar_verf = xprt->xp_verf; + rply.acpted_rply.ar_stat = PROC_UNAVAIL; + SVC_REPLY(xprt, &rply); +} + +/* + * Can't decode args error reply + */ +void +svcerr_decode(xprt) + register SVCXPRT *xprt; +{ + struct rpc_msg rply; + + rply.rm_direction = REPLY; + rply.rm_reply.rp_stat = MSG_ACCEPTED; + rply.acpted_rply.ar_verf = xprt->xp_verf; + rply.acpted_rply.ar_stat = GARBAGE_ARGS; + SVC_REPLY(xprt, &rply); +} + +/* + * Some system error + */ +void +svcerr_systemerr(xprt) + register SVCXPRT *xprt; +{ + struct rpc_msg rply; + + rply.rm_direction = REPLY; + rply.rm_reply.rp_stat = MSG_ACCEPTED; + rply.acpted_rply.ar_verf = xprt->xp_verf; + rply.acpted_rply.ar_stat = SYSTEM_ERR; + SVC_REPLY(xprt, &rply); +} + +/* + * Authentication error reply + */ +void +svcerr_auth(xprt, why) + SVCXPRT *xprt; + enum auth_stat why; +{ + struct rpc_msg rply; + + rply.rm_direction = REPLY; + rply.rm_reply.rp_stat = MSG_DENIED; + rply.rjcted_rply.rj_stat = AUTH_ERROR; + rply.rjcted_rply.rj_why = why; + SVC_REPLY(xprt, &rply); +} + +/* + * Auth too weak error reply + */ +void +svcerr_weakauth(xprt) + SVCXPRT *xprt; +{ + + svcerr_auth(xprt, AUTH_TOOWEAK); +} + +/* + * Program unavailable error reply + */ +void +svcerr_noprog(xprt) + register SVCXPRT *xprt; +{ + struct rpc_msg rply; + + rply.rm_direction = REPLY; + rply.rm_reply.rp_stat = MSG_ACCEPTED; + rply.acpted_rply.ar_verf = xprt->xp_verf; + rply.acpted_rply.ar_stat = PROG_UNAVAIL; + SVC_REPLY(xprt, &rply); +} + +/* + * Program version mismatch error reply + */ +void +svcerr_progvers(xprt, low_vers, high_vers) + register SVCXPRT *xprt; + u_long low_vers; + u_long high_vers; +{ + struct rpc_msg rply; + + rply.rm_direction = REPLY; + rply.rm_reply.rp_stat = MSG_ACCEPTED; + rply.acpted_rply.ar_verf = xprt->xp_verf; + rply.acpted_rply.ar_stat = PROG_MISMATCH; + rply.acpted_rply.ar_vers.low = low_vers; + rply.acpted_rply.ar_vers.high = high_vers; + SVC_REPLY(xprt, &rply); +} + +/* ******************* SERVER INPUT STUFF ******************* */ + +/* + * Get server side input from some transport. + * + * Statement of authentication parameters management: + * This function owns and manages all authentication parameters, specifically + * the "raw" parameters (msg.rm_call.cb_cred and msg.rm_call.cb_verf) and + * the "cooked" credentials (rqst->rq_clntcred). + * However, this function does not know the structure of the cooked + * credentials, so it make the following assumptions: + * a) the structure is contiguous (no pointers), and + * b) the cred structure size does not exceed RQCRED_SIZE bytes. + * In all events, all three parameters are freed upon exit from this routine. + * The storage is trivially management on the call stack in user land, but + * is mallocated in kernel land. + */ + +void +svc_getreq(rdfds) + int rdfds; +{ +#ifdef FD_SETSIZE + fd_set readfds; + + FD_ZERO(&readfds); + readfds.fds_bits[0] = rdfds; + svc_getreqset(&readfds); +#else + int readfds = rdfds & svc_fds; + + svc_getreqset(&readfds); +#endif /* def FD_SETSIZE */ +} + +void +svc_getreqset(readfds) +#ifdef FD_SETSIZE + fd_set *readfds; +{ +#else + int *readfds; +{ + int readfds_local = *readfds; +#endif /* def FD_SETSIZE */ + enum xprt_stat stat; + struct rpc_msg msg; + int prog_found; + u_long low_vers; + u_long high_vers; + struct svc_req r; + register SVCXPRT *xprt; + register u_long mask; + register int bit; + register u_long *maskp; + register int setsize; + register int sock; + char cred_area[2*MAX_AUTH_BYTES + RQCRED_SIZE]; + msg.rm_call.cb_cred.oa_base = cred_area; + msg.rm_call.cb_verf.oa_base = &(cred_area[MAX_AUTH_BYTES]); + r.rq_clntcred = &(cred_area[2*MAX_AUTH_BYTES]); + + +#ifdef FD_SETSIZE + setsize = _rpc_dtablesize(); + maskp = (u_long *)readfds->fds_bits; + for (sock = 0; sock < setsize; sock += NFDBITS) { + for (mask = *maskp++; bit = ffs(mask); mask ^= (1 << (bit - 1))) { + /* sock has input waiting */ + xprt = xports[sock + bit - 1]; +#else + for (sock = 0; readfds_local != 0; sock++, readfds_local >>= 1) { + if ((readfds_local & 1) != 0) { + /* sock has input waiting */ + xprt = xports[sock]; +#endif /* def FD_SETSIZE */ + /* now receive msgs from xprtprt (support batch calls) */ + do { + if (SVC_RECV(xprt, &msg)) { + + /* now find the exported program and call it */ + register struct svc_callout *s; + enum auth_stat why; + + r.rq_xprt = xprt; + r.rq_prog = msg.rm_call.cb_prog; + r.rq_vers = msg.rm_call.cb_vers; + r.rq_proc = msg.rm_call.cb_proc; + r.rq_cred = msg.rm_call.cb_cred; + /* first authenticate the message */ + if ((why= _authenticate(&r, &msg)) != AUTH_OK) { + svcerr_auth(xprt, why); + goto call_done; + } + /* now match message with a registered service*/ + prog_found = FALSE; + low_vers = 0 - 1; + high_vers = 0; + for (s = svc_head; s != NULL_SVC; s = s->sc_next) { + if (s->sc_prog == r.rq_prog) { + if (s->sc_vers == r.rq_vers) { + (*s->sc_dispatch)(&r, xprt); + goto call_done; + } /* found correct version */ + prog_found = TRUE; + if (s->sc_vers < low_vers) + low_vers = s->sc_vers; + if (s->sc_vers > high_vers) + high_vers = s->sc_vers; + } /* found correct program */ + } + /* + * if we got here, the program or version + * is not served ... + */ + if (prog_found) + svcerr_progvers(xprt, + low_vers, high_vers); + else + svcerr_noprog(xprt); + /* Fall through to ... */ + } + call_done: + if ((stat = SVC_STAT(xprt)) == XPRT_DIED){ + SVC_DESTROY(xprt); + break; + } + } while (stat == XPRT_MOREREQS); + } + } +} diff -ruN glibc-1.07/sunrpc/svc_auth.c glibc-1.08.1/sunrpc/svc_auth.c --- glibc-1.07/sunrpc/svc_auth.c +++ glibc-1.08.1/sunrpc/svc_auth.c Sun Feb 6 16:42:47 1994 @@ -0,0 +1,114 @@ +#if !defined(lint) && defined(SCCSIDS) +static char sccsid[] = "@(#)svc_auth.c 2.1 88/08/07 4.0 RPCSRC; from 1.19 87/08/11 Copyr 1984 Sun Micro"; +#endif +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +/* + * svc_auth_nodes.c, Server-side rpc authenticator interface, + * *WITHOUT* DES authentication. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#include + +/* + * svcauthsw is the bdevsw of server side authentication. + * + * Server side authenticators are called from authenticate by + * using the client auth struct flavor field to index into svcauthsw. + * The server auth flavors must implement a routine that looks + * like: + * + * enum auth_stat + * flavorx_auth(rqst, msg) + * register struct svc_req *rqst; + * register struct rpc_msg *msg; + * + */ + +enum auth_stat _svcauth_null(); /* no authentication */ +enum auth_stat _svcauth_unix(); /* unix style (uid, gids) */ +enum auth_stat _svcauth_short(); /* short hand unix style */ + +static struct { + enum auth_stat (*authenticator)(); +} svcauthsw[] = { + _svcauth_null, /* AUTH_NULL */ + _svcauth_unix, /* AUTH_UNIX */ + _svcauth_short, /* AUTH_SHORT */ +}; +#define AUTH_MAX 2 /* HIGHEST AUTH NUMBER */ + + +/* + * The call rpc message, msg has been obtained from the wire. The msg contains + * the raw form of credentials and verifiers. authenticate returns AUTH_OK + * if the msg is successfully authenticated. If AUTH_OK then the routine also + * does the following things: + * set rqst->rq_xprt->verf to the appropriate response verifier; + * sets rqst->rq_client_cred to the "cooked" form of the credentials. + * + * NB: rqst->rq_cxprt->verf must be pre-alloctaed; + * its length is set appropriately. + * + * The caller still owns and is responsible for msg->u.cmb.cred and + * msg->u.cmb.verf. The authentication system retains ownership of + * rqst->rq_client_cred, the cooked credentials. + * + * There is an assumption that any flavour less than AUTH_NULL is + * invalid. + */ +enum auth_stat +_authenticate(rqst, msg) + register struct svc_req *rqst; + struct rpc_msg *msg; +{ + register int cred_flavor; + + rqst->rq_cred = msg->rm_call.cb_cred; + rqst->rq_xprt->xp_verf.oa_flavor = _null_auth.oa_flavor; + rqst->rq_xprt->xp_verf.oa_length = 0; + cred_flavor = rqst->rq_cred.oa_flavor; + if ((cred_flavor <= AUTH_MAX) && (cred_flavor >= AUTH_NULL)) { + return ((*(svcauthsw[cred_flavor].authenticator))(rqst, msg)); + } + + return (AUTH_REJECTEDCRED); +} + +enum auth_stat +_svcauth_null(/*rqst, msg*/) + /*struct svc_req *rqst; + struct rpc_msg *msg;*/ +{ + + return (AUTH_OK); +} diff -ruN glibc-1.07/sunrpc/svc_authux.c glibc-1.08.1/sunrpc/svc_authux.c --- glibc-1.07/sunrpc/svc_authux.c +++ glibc-1.08.1/sunrpc/svc_authux.c Sun Feb 6 16:42:47 1994 @@ -0,0 +1,134 @@ +/* @(#)svc_auth_unix.c 2.3 88/08/01 4.0 RPCSRC; from 1.28 88/02/08 SMI */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +#if !defined(lint) && defined(SCCSIDS) +static char sccsid[] = "@(#)svc_auth_unix.c 1.28 88/02/08 Copyr 1984 Sun Micro"; +#endif + +/* + * svc_auth_unix.c + * Handles UNIX flavor authentication parameters on the service side of rpc. + * There are two svc auth implementations here: AUTH_UNIX and AUTH_SHORT. + * _svcauth_unix does full blown unix style uid,gid+gids auth, + * _svcauth_short uses a shorthand auth to index into a cache of longhand auths. + * Note: the shorthand has been gutted for efficiency. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#include +#include + +/* + * Unix longhand authenticator + */ +enum auth_stat +_svcauth_unix(rqst, msg) + register struct svc_req *rqst; + register struct rpc_msg *msg; +{ + register enum auth_stat stat; + XDR xdrs; + register struct authunix_parms *aup; + register long *buf; + struct area { + struct authunix_parms area_aup; + char area_machname[MAX_MACHINE_NAME+1]; + int area_gids[NGRPS]; + } *area; + u_int auth_len; + int str_len, gid_len; + register int i; + + area = (struct area *) rqst->rq_clntcred; + aup = &area->area_aup; + aup->aup_machname = area->area_machname; + aup->aup_gids = area->area_gids; + auth_len = (u_int)msg->rm_call.cb_cred.oa_length; + xdrmem_create(&xdrs, msg->rm_call.cb_cred.oa_base, auth_len,XDR_DECODE); + buf = XDR_INLINE(&xdrs, auth_len); + if (buf != NULL) { + aup->aup_time = IXDR_GET_LONG(buf); + str_len = IXDR_GET_U_LONG(buf); + if (str_len > MAX_MACHINE_NAME) { + stat = AUTH_BADCRED; + goto done; + } + bcopy((caddr_t)buf, aup->aup_machname, (u_int)str_len); + aup->aup_machname[str_len] = 0; + str_len = RNDUP(str_len); + buf += str_len / sizeof (long); + aup->aup_uid = IXDR_GET_LONG(buf); + aup->aup_gid = IXDR_GET_LONG(buf); + gid_len = IXDR_GET_U_LONG(buf); + if (gid_len > NGRPS) { + stat = AUTH_BADCRED; + goto done; + } + aup->aup_len = gid_len; + for (i = 0; i < gid_len; i++) { + aup->aup_gids[i] = IXDR_GET_LONG(buf); + } + /* + * five is the smallest unix credentials structure - + * timestamp, hostname len (0), uid, gid, and gids len (0). + */ + if ((5 + gid_len) * BYTES_PER_XDR_UNIT + str_len > auth_len) { + (void) printf("bad auth_len gid %d str %d auth %d\n", + gid_len, str_len, auth_len); + stat = AUTH_BADCRED; + goto done; + } + } else if (! xdr_authunix_parms(&xdrs, aup)) { + xdrs.x_op = XDR_FREE; + (void)xdr_authunix_parms(&xdrs, aup); + stat = AUTH_BADCRED; + goto done; + } + rqst->rq_xprt->xp_verf.oa_flavor = AUTH_NULL; + rqst->rq_xprt->xp_verf.oa_length = 0; + stat = AUTH_OK; +done: + XDR_DESTROY(&xdrs); + return (stat); +} + + +/* + * Shorthand unix authenticator + * Looks up longhand in a cache. + */ +/*ARGSUSED*/ +enum auth_stat +_svcauth_short(rqst, msg) + struct svc_req *rqst; + struct rpc_msg *msg; +{ + return (AUTH_REJECTEDCRED); +} diff -ruN glibc-1.07/sunrpc/svc_raw.c glibc-1.08.1/sunrpc/svc_raw.c --- glibc-1.07/sunrpc/svc_raw.c +++ glibc-1.08.1/sunrpc/svc_raw.c Sun Feb 6 16:42:48 1994 @@ -0,0 +1,166 @@ +/* @(#)svc_raw.c 2.1 88/07/29 4.0 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +#if !defined(lint) && defined(SCCSIDS) +static char sccsid[] = "@(#)svc_raw.c 1.15 87/08/11 Copyr 1984 Sun Micro"; +#endif + +/* + * svc_raw.c, This a toy for simple testing and timing. + * Interface to create an rpc client and server in the same UNIX process. + * This lets us similate rpc and get rpc (round trip) overhead, without + * any interference from the kernal. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#include + + +/* + * This is the "network" that we will be moving data over + */ +static struct svcraw_private { + char _raw_buf[UDPMSGSIZE]; + SVCXPRT server; + XDR xdr_stream; + char verf_body[MAX_AUTH_BYTES]; +} *svcraw_private; + +static bool_t svcraw_recv(); +static enum xprt_stat svcraw_stat(); +static bool_t svcraw_getargs(); +static bool_t svcraw_reply(); +static bool_t svcraw_freeargs(); +static void svcraw_destroy(); + +static struct xp_ops server_ops = { + svcraw_recv, + svcraw_stat, + svcraw_getargs, + svcraw_reply, + svcraw_freeargs, + svcraw_destroy +}; + +SVCXPRT * +svcraw_create() +{ + register struct svcraw_private *srp = svcraw_private; + + if (srp == 0) { + srp = (struct svcraw_private *)calloc(1, sizeof (*srp)); + if (srp == 0) + return (0); + } + srp->server.xp_sock = 0; + srp->server.xp_port = 0; + srp->server.xp_ops = &server_ops; + srp->server.xp_verf.oa_base = srp->verf_body; + xdrmem_create(&srp->xdr_stream, srp->_raw_buf, UDPMSGSIZE, XDR_FREE); + return (&srp->server); +} + +static enum xprt_stat +svcraw_stat() +{ + + return (XPRT_IDLE); +} + +static bool_t +svcraw_recv(xprt, msg) + SVCXPRT *xprt; + struct rpc_msg *msg; +{ + register struct svcraw_private *srp = svcraw_private; + register XDR *xdrs; + + if (srp == 0) + return (0); + xdrs = &srp->xdr_stream; + xdrs->x_op = XDR_DECODE; + XDR_SETPOS(xdrs, 0); + if (! xdr_callmsg(xdrs, msg)) + return (FALSE); + return (TRUE); +} + +static bool_t +svcraw_reply(xprt, msg) + SVCXPRT *xprt; + struct rpc_msg *msg; +{ + register struct svcraw_private *srp = svcraw_private; + register XDR *xdrs; + + if (srp == 0) + return (FALSE); + xdrs = &srp->xdr_stream; + xdrs->x_op = XDR_ENCODE; + XDR_SETPOS(xdrs, 0); + if (! xdr_replymsg(xdrs, msg)) + return (FALSE); + (void)XDR_GETPOS(xdrs); /* called just for overhead */ + return (TRUE); +} + +static bool_t +svcraw_getargs(xprt, xdr_args, args_ptr) + SVCXPRT *xprt; + xdrproc_t xdr_args; + caddr_t args_ptr; +{ + register struct svcraw_private *srp = svcraw_private; + + if (srp == 0) + return (FALSE); + return ((*xdr_args)(&srp->xdr_stream, args_ptr)); +} + +static bool_t +svcraw_freeargs(xprt, xdr_args, args_ptr) + SVCXPRT *xprt; + xdrproc_t xdr_args; + caddr_t args_ptr; +{ + register struct svcraw_private *srp = svcraw_private; + register XDR *xdrs; + + if (srp == 0) + return (FALSE); + xdrs = &srp->xdr_stream; + xdrs->x_op = XDR_FREE; + return ((*xdr_args)(xdrs, args_ptr)); +} + +static void +svcraw_destroy() +{ +} diff -ruN glibc-1.07/sunrpc/svc_run.c glibc-1.08.1/sunrpc/svc_run.c --- glibc-1.07/sunrpc/svc_run.c +++ glibc-1.08.1/sunrpc/svc_run.c Sun Feb 6 16:42:48 1994 @@ -0,0 +1,72 @@ +/* @(#)svc_run.c 2.1 88/07/29 4.0 RPCSRC */ +#if !defined(lint) && defined(SCCSIDS) +static char sccsid[] = "@(#)svc_run.c 1.1 87/10/13 Copyr 1984 Sun Micro"; +#endif + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +/* + * This is the rpc server side idle loop + * Wait for input, call server program. + */ +#include +#include + +void +svc_run() +{ +#ifdef FD_SETSIZE + fd_set readfds; +#else + int readfds; +#endif /* def FD_SETSIZE */ + extern int errno; + + for (;;) { +#ifdef FD_SETSIZE + readfds = svc_fdset; +#else + readfds = svc_fds; +#endif /* def FD_SETSIZE */ + switch (select(_rpc_dtablesize(), &readfds, (int *)0, (int *)0, + (struct timeval *)0)) { + case -1: + if (errno == EINTR) { + continue; + } + perror("svc_run: - select failed"); + return; + case 0: + continue; + default: + svc_getreqset(&readfds); + } + } +} diff -ruN glibc-1.07/sunrpc/svc_simple.c glibc-1.08.1/sunrpc/svc_simple.c --- glibc-1.07/sunrpc/svc_simple.c +++ glibc-1.08.1/sunrpc/svc_simple.c Sun Feb 6 16:42:48 1994 @@ -0,0 +1,143 @@ +/* @(#)svc_simple.c 2.2 88/08/01 4.0 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +#if !defined(lint) && defined(SCCSIDS) +static char sccsid[] = "@(#)svc_simple.c 1.18 87/08/11 Copyr 1984 Sun Micro"; +#endif + +/* + * svc_simple.c + * Simplified front end to rpc. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#include +#include +#include +#include + +static struct proglst { + char *(*p_progname)(); + int p_prognum; + int p_procnum; + xdrproc_t p_inproc, p_outproc; + struct proglst *p_nxt; +} *proglst; +static void universal(); +static SVCXPRT *transp; +struct proglst *pl; + +registerrpc(prognum, versnum, procnum, progname, inproc, outproc) + char *(*progname)(); + xdrproc_t inproc, outproc; +{ + + if (procnum == NULLPROC) { + (void) fprintf(stderr, + "can't reassign procedure number %d\n", NULLPROC); + return (-1); + } + if (transp == 0) { + transp = svcudp_create(RPC_ANYSOCK); + if (transp == NULL) { + (void) fprintf(stderr, "couldn't create an rpc server\n"); + return (-1); + } + } + (void) pmap_unset((u_long)prognum, (u_long)versnum); + if (!svc_register(transp, (u_long)prognum, (u_long)versnum, + universal, IPPROTO_UDP)) { + (void) fprintf(stderr, "couldn't register prog %d vers %d\n", + prognum, versnum); + return (-1); + } + pl = (struct proglst *)malloc(sizeof(struct proglst)); + if (pl == NULL) { + (void) fprintf(stderr, "registerrpc: out of memory\n"); + return (-1); + } + pl->p_progname = progname; + pl->p_prognum = prognum; + pl->p_procnum = procnum; + pl->p_inproc = inproc; + pl->p_outproc = outproc; + pl->p_nxt = proglst; + proglst = pl; + return (0); +} + +static void +universal(rqstp, transp) + struct svc_req *rqstp; + SVCXPRT *transp; +{ + int prog, proc; + char *outdata; + char xdrbuf[UDPMSGSIZE]; + struct proglst *pl; + + /* + * enforce "procnum 0 is echo" convention + */ + if (rqstp->rq_proc == NULLPROC) { + if (svc_sendreply(transp, xdr_void, (char *)NULL) == FALSE) { + (void) fprintf(stderr, "xxx\n"); + exit(1); + } + return; + } + prog = rqstp->rq_prog; + proc = rqstp->rq_proc; + for (pl = proglst; pl != NULL; pl = pl->p_nxt) + if (pl->p_prognum == prog && pl->p_procnum == proc) { + /* decode arguments into a CLEAN buffer */ + bzero(xdrbuf, sizeof(xdrbuf)); /* required ! */ + if (!svc_getargs(transp, pl->p_inproc, xdrbuf)) { + svcerr_decode(transp); + return; + } + outdata = (*(pl->p_progname))(xdrbuf); + if (outdata == NULL && pl->p_outproc != xdr_void) + /* there was an error */ + return; + if (!svc_sendreply(transp, pl->p_outproc, outdata)) { + (void) fprintf(stderr, + "trouble replying to prog %d\n", + pl->p_prognum); + exit(1); + } + /* free the decoded arguments */ + (void)svc_freeargs(transp, pl->p_inproc, xdrbuf); + return; + } + (void) fprintf(stderr, "never registered prog %d\n", prog); + exit(1); +} + diff -ruN glibc-1.07/sunrpc/svc_tcp.c glibc-1.08.1/sunrpc/svc_tcp.c --- glibc-1.07/sunrpc/svc_tcp.c +++ glibc-1.08.1/sunrpc/svc_tcp.c Sun Feb 6 16:42:48 1994 @@ -0,0 +1,419 @@ +/* @(#)svc_tcp.c 2.2 88/08/01 4.0 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +#if !defined(lint) && defined(SCCSIDS) +static char sccsid[] = "@(#)svc_tcp.c 1.21 87/08/11 Copyr 1984 Sun Micro"; +#endif + +/* + * svc_tcp.c, Server side for TCP/IP based RPC. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + * + * Actually implements two flavors of transporter - + * a tcp rendezvouser (a listner and connection establisher) + * and a record/tcp stream. + */ + +#include +#include +#include +#include +extern bool_t abort(); +extern errno; + +/* + * Ops vector for TCP/IP based rpc service handle + */ +static bool_t svctcp_recv(); +static enum xprt_stat svctcp_stat(); +static bool_t svctcp_getargs(); +static bool_t svctcp_reply(); +static bool_t svctcp_freeargs(); +static void svctcp_destroy(); + +static struct xp_ops svctcp_op = { + svctcp_recv, + svctcp_stat, + svctcp_getargs, + svctcp_reply, + svctcp_freeargs, + svctcp_destroy +}; + +/* + * Ops vector for TCP/IP rendezvous handler + */ +static bool_t rendezvous_request(); +static enum xprt_stat rendezvous_stat(); + +static struct xp_ops svctcp_rendezvous_op = { + rendezvous_request, + rendezvous_stat, + abort, + abort, + abort, + svctcp_destroy +}; + +static int readtcp(), writetcp(); +static SVCXPRT *makefd_xprt(); + +struct tcp_rendezvous { /* kept in xprt->xp_p1 */ + u_int sendsize; + u_int recvsize; +}; + +struct tcp_conn { /* kept in xprt->xp_p1 */ + enum xprt_stat strm_stat; + u_long x_id; + XDR xdrs; + char verf_body[MAX_AUTH_BYTES]; +}; + +/* + * Usage: + * xprt = svctcp_create(sock, send_buf_size, recv_buf_size); + * + * Creates, registers, and returns a (rpc) tcp based transporter. + * Once *xprt is initialized, it is registered as a transporter + * see (svc.h, xprt_register). This routine returns + * a NULL if a problem occurred. + * + * If sock<0 then a socket is created, else sock is used. + * If the socket, sock is not bound to a port then svctcp_create + * binds it to an arbitrary port. The routine then starts a tcp + * listener on the socket's associated port. In any (successful) case, + * xprt->xp_sock is the registered socket number and xprt->xp_port is the + * associated port number. + * + * Since tcp streams do buffered io similar to stdio, the caller can specify + * how big the send and receive buffers are via the second and third parms; + * 0 => use the system default. + */ +SVCXPRT * +svctcp_create(sock, sendsize, recvsize) + register int sock; + u_int sendsize; + u_int recvsize; +{ + bool_t madesock = FALSE; + register SVCXPRT *xprt; + register struct tcp_rendezvous *r; + struct sockaddr_in addr; + int len = sizeof(struct sockaddr_in); + + if (sock == RPC_ANYSOCK) { + if ((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) { + perror("svctcp_.c - udp socket creation problem"); + return ((SVCXPRT *)NULL); + } + madesock = TRUE; + } + bzero((char *)&addr, sizeof (addr)); + addr.sin_family = AF_INET; + if (bindresvport(sock, &addr)) { + addr.sin_port = 0; + (void)bind(sock, (struct sockaddr *)&addr, len); + } + if ((getsockname(sock, (struct sockaddr *)&addr, &len) != 0) || + (listen(sock, 2) != 0)) { + perror("svctcp_.c - cannot getsockname or listen"); + if (madesock) + (void)close(sock); + return ((SVCXPRT *)NULL); + } + r = (struct tcp_rendezvous *)mem_alloc(sizeof(*r)); + if (r == NULL) { + (void) fprintf(stderr, "svctcp_create: out of memory\n"); + return (NULL); + } + r->sendsize = sendsize; + r->recvsize = recvsize; + xprt = (SVCXPRT *)mem_alloc(sizeof(SVCXPRT)); + if (xprt == NULL) { + (void) fprintf(stderr, "svctcp_create: out of memory\n"); + return (NULL); + } + xprt->xp_p2 = NULL; + xprt->xp_p1 = (caddr_t)r; + xprt->xp_verf = _null_auth; + xprt->xp_ops = &svctcp_rendezvous_op; + xprt->xp_port = ntohs(addr.sin_port); + xprt->xp_sock = sock; + xprt_register(xprt); + return (xprt); +} + +/* + * Like svtcp_create(), except the routine takes any *open* UNIX file + * descriptor as its first input. + */ +SVCXPRT * +svcfd_create(fd, sendsize, recvsize) + int fd; + u_int sendsize; + u_int recvsize; +{ + + return (makefd_xprt(fd, sendsize, recvsize)); +} + +static SVCXPRT * +makefd_xprt(fd, sendsize, recvsize) + int fd; + u_int sendsize; + u_int recvsize; +{ + register SVCXPRT *xprt; + register struct tcp_conn *cd; + + xprt = (SVCXPRT *)mem_alloc(sizeof(SVCXPRT)); + if (xprt == (SVCXPRT *)NULL) { + (void) fprintf(stderr, "svc_tcp: makefd_xprt: out of memory\n"); + goto done; + } + cd = (struct tcp_conn *)mem_alloc(sizeof(struct tcp_conn)); + if (cd == (struct tcp_conn *)NULL) { + (void) fprintf(stderr, "svc_tcp: makefd_xprt: out of memory\n"); + mem_free((char *) xprt, sizeof(SVCXPRT)); + xprt = (SVCXPRT *)NULL; + goto done; + } + cd->strm_stat = XPRT_IDLE; + xdrrec_create(&(cd->xdrs), sendsize, recvsize, + (caddr_t)xprt, readtcp, writetcp); + xprt->xp_p2 = NULL; + xprt->xp_p1 = (caddr_t)cd; + xprt->xp_verf.oa_base = cd->verf_body; + xprt->xp_addrlen = 0; + xprt->xp_ops = &svctcp_op; /* truely deals with calls */ + xprt->xp_port = 0; /* this is a connection, not a rendezvouser */ + xprt->xp_sock = fd; + xprt_register(xprt); + done: + return (xprt); +} + +static bool_t +rendezvous_request(xprt) + register SVCXPRT *xprt; +{ + int sock; + struct tcp_rendezvous *r; + struct sockaddr_in addr; + int len; + + r = (struct tcp_rendezvous *)xprt->xp_p1; + again: + len = sizeof(struct sockaddr_in); + if ((sock = accept(xprt->xp_sock, (struct sockaddr *)&addr, + &len)) < 0) { + if (errno == EINTR) + goto again; + return (FALSE); + } + /* + * make a new transporter (re-uses xprt) + */ + xprt = makefd_xprt(sock, r->sendsize, r->recvsize); + xprt->xp_raddr = addr; + xprt->xp_addrlen = len; + return (FALSE); /* there is never an rpc msg to be processed */ +} + +static enum xprt_stat +rendezvous_stat() +{ + + return (XPRT_IDLE); +} + +static void +svctcp_destroy(xprt) + register SVCXPRT *xprt; +{ + register struct tcp_conn *cd = (struct tcp_conn *)xprt->xp_p1; + + xprt_unregister(xprt); + (void)close(xprt->xp_sock); + if (xprt->xp_port != 0) { + /* a rendezvouser socket */ + xprt->xp_port = 0; + } else { + /* an actual connection socket */ + XDR_DESTROY(&(cd->xdrs)); + } + mem_free((caddr_t)cd, sizeof(struct tcp_conn)); + mem_free((caddr_t)xprt, sizeof(SVCXPRT)); +} + +/* + * All read operations timeout after 35 seconds. + * A timeout is fatal for the connection. + */ +static struct timeval wait_per_try = { 35, 0 }; + +/* + * reads data from the tcp conection. + * any error is fatal and the connection is closed. + * (And a read of zero bytes is a half closed stream => error.) + */ +static int +readtcp(xprt, buf, len) + register SVCXPRT *xprt; + caddr_t buf; + register int len; +{ + register int sock = xprt->xp_sock; +#ifdef FD_SETSIZE + fd_set mask; + fd_set readfds; + + FD_ZERO(&mask); + FD_SET(sock, &mask); +#else + register int mask = 1 << sock; + int readfds; +#endif /* def FD_SETSIZE */ + do { + readfds = mask; + if (select(_rpc_dtablesize(), &readfds, (int*)NULL, (int*)NULL, + &wait_per_try) <= 0) { + if (errno == EINTR) { + continue; + } + goto fatal_err; + } +#ifdef FD_SETSIZE + } while (!FD_ISSET(sock, &readfds)); +#else + } while (readfds != mask); +#endif /* def FD_SETSIZE */ + if ((len = read(sock, buf, len)) > 0) { + return (len); + } +fatal_err: + ((struct tcp_conn *)(xprt->xp_p1))->strm_stat = XPRT_DIED; + return (-1); +} + +/* + * writes data to the tcp connection. + * Any error is fatal and the connection is closed. + */ +static int +writetcp(xprt, buf, len) + register SVCXPRT *xprt; + caddr_t buf; + int len; +{ + register int i, cnt; + + for (cnt = len; cnt > 0; cnt -= i, buf += i) { + if ((i = write(xprt->xp_sock, buf, cnt)) < 0) { + ((struct tcp_conn *)(xprt->xp_p1))->strm_stat = + XPRT_DIED; + return (-1); + } + } + return (len); +} + +static enum xprt_stat +svctcp_stat(xprt) + SVCXPRT *xprt; +{ + register struct tcp_conn *cd = + (struct tcp_conn *)(xprt->xp_p1); + + if (cd->strm_stat == XPRT_DIED) + return (XPRT_DIED); + if (! xdrrec_eof(&(cd->xdrs))) + return (XPRT_MOREREQS); + return (XPRT_IDLE); +} + +static bool_t +svctcp_recv(xprt, msg) + SVCXPRT *xprt; + register struct rpc_msg *msg; +{ + register struct tcp_conn *cd = + (struct tcp_conn *)(xprt->xp_p1); + register XDR *xdrs = &(cd->xdrs); + + xdrs->x_op = XDR_DECODE; + (void)xdrrec_skiprecord(xdrs); + if (xdr_callmsg(xdrs, msg)) { + cd->x_id = msg->rm_xid; + return (TRUE); + } + return (FALSE); +} + +static bool_t +svctcp_getargs(xprt, xdr_args, args_ptr) + SVCXPRT *xprt; + xdrproc_t xdr_args; + caddr_t args_ptr; +{ + + return ((*xdr_args)(&(((struct tcp_conn *)(xprt->xp_p1))->xdrs), args_ptr)); +} + +static bool_t +svctcp_freeargs(xprt, xdr_args, args_ptr) + SVCXPRT *xprt; + xdrproc_t xdr_args; + caddr_t args_ptr; +{ + register XDR *xdrs = + &(((struct tcp_conn *)(xprt->xp_p1))->xdrs); + + xdrs->x_op = XDR_FREE; + return ((*xdr_args)(xdrs, args_ptr)); +} + +static bool_t +svctcp_reply(xprt, msg) + SVCXPRT *xprt; + register struct rpc_msg *msg; +{ + register struct tcp_conn *cd = + (struct tcp_conn *)(xprt->xp_p1); + register XDR *xdrs = &(cd->xdrs); + register bool_t stat; + + xdrs->x_op = XDR_ENCODE; + msg->rm_xid = cd->x_id; + stat = xdr_replymsg(xdrs, msg); + (void)xdrrec_endofrecord(xdrs, TRUE); + return (stat); +} diff -ruN glibc-1.07/sunrpc/svc_udp.c glibc-1.08.1/sunrpc/svc_udp.c --- glibc-1.07/sunrpc/svc_udp.c +++ glibc-1.08.1/sunrpc/svc_udp.c Sun Feb 6 16:42:48 1994 @@ -0,0 +1,475 @@ +/* @(#)svc_udp.c 2.2 88/07/29 4.0 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +#if !defined(lint) && defined(SCCSIDS) +static char sccsid[] = "@(#)svc_udp.c 1.24 87/08/11 Copyr 1984 Sun Micro"; +#endif + +/* + * svc_udp.c, + * Server side for UDP/IP based RPC. (Does some caching in the hopes of + * achieving execute-at-most-once semantics.) + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#include +#include +#include +#include + + +#define rpc_buffer(xprt) ((xprt)->xp_p1) +#define MAX(a, b) ((a > b) ? a : b) + +static bool_t svcudp_recv(); +static bool_t svcudp_reply(); +static enum xprt_stat svcudp_stat(); +static bool_t svcudp_getargs(); +static bool_t svcudp_freeargs(); +static void svcudp_destroy(); + +static struct xp_ops svcudp_op = { + svcudp_recv, + svcudp_stat, + svcudp_getargs, + svcudp_reply, + svcudp_freeargs, + svcudp_destroy +}; + +extern int errno; + +/* + * kept in xprt->xp_p2 + */ +struct svcudp_data { + u_int su_iosz; /* byte size of send.recv buffer */ + u_long su_xid; /* transaction id */ + XDR su_xdrs; /* XDR handle */ + char su_verfbody[MAX_AUTH_BYTES]; /* verifier body */ + char * su_cache; /* cached data, NULL if no cache */ +}; +#define su_data(xprt) ((struct svcudp_data *)(xprt->xp_p2)) + +/* + * Usage: + * xprt = svcudp_create(sock); + * + * If sock<0 then a socket is created, else sock is used. + * If the socket, sock is not bound to a port then svcudp_create + * binds it to an arbitrary port. In any (successful) case, + * xprt->xp_sock is the registered socket number and xprt->xp_port is the + * associated port number. + * Once *xprt is initialized, it is registered as a transporter; + * see (svc.h, xprt_register). + * The routines returns NULL if a problem occurred. + */ +SVCXPRT * +svcudp_bufcreate(sock, sendsz, recvsz) + register int sock; + u_int sendsz, recvsz; +{ + bool_t madesock = FALSE; + register SVCXPRT *xprt; + register struct svcudp_data *su; + struct sockaddr_in addr; + int len = sizeof(struct sockaddr_in); + + if (sock == RPC_ANYSOCK) { + if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) { + perror("svcudp_create: socket creation problem"); + return ((SVCXPRT *)NULL); + } + madesock = TRUE; + } + bzero((char *)&addr, sizeof (addr)); + addr.sin_family = AF_INET; + if (bindresvport(sock, &addr)) { + addr.sin_port = 0; + (void)bind(sock, (struct sockaddr *)&addr, len); + } + if (getsockname(sock, (struct sockaddr *)&addr, &len) != 0) { + perror("svcudp_create - cannot getsockname"); + if (madesock) + (void)close(sock); + return ((SVCXPRT *)NULL); + } + xprt = (SVCXPRT *)mem_alloc(sizeof(SVCXPRT)); + if (xprt == NULL) { + (void)fprintf(stderr, "svcudp_create: out of memory\n"); + return (NULL); + } + su = (struct svcudp_data *)mem_alloc(sizeof(*su)); + if (su == NULL) { + (void)fprintf(stderr, "svcudp_create: out of memory\n"); + return (NULL); + } + su->su_iosz = ((MAX(sendsz, recvsz) + 3) / 4) * 4; + if ((rpc_buffer(xprt) = mem_alloc(su->su_iosz)) == NULL) { + (void)fprintf(stderr, "svcudp_create: out of memory\n"); + return (NULL); + } + xdrmem_create( + &(su->su_xdrs), rpc_buffer(xprt), su->su_iosz, XDR_DECODE); + su->su_cache = NULL; + xprt->xp_p2 = (caddr_t)su; + xprt->xp_verf.oa_base = su->su_verfbody; + xprt->xp_ops = &svcudp_op; + xprt->xp_port = ntohs(addr.sin_port); + xprt->xp_sock = sock; + xprt_register(xprt); + return (xprt); +} + +SVCXPRT * +svcudp_create(sock) + int sock; +{ + + return(svcudp_bufcreate(sock, UDPMSGSIZE, UDPMSGSIZE)); +} + +static enum xprt_stat +svcudp_stat(xprt) + SVCXPRT *xprt; +{ + + return (XPRT_IDLE); +} + +static bool_t +svcudp_recv(xprt, msg) + register SVCXPRT *xprt; + struct rpc_msg *msg; +{ + register struct svcudp_data *su = su_data(xprt); + register XDR *xdrs = &(su->su_xdrs); + register int rlen; + char *reply; + u_long replylen; + + again: + xprt->xp_addrlen = sizeof(struct sockaddr_in); + rlen = recvfrom(xprt->xp_sock, rpc_buffer(xprt), (int) su->su_iosz, + 0, (struct sockaddr *)&(xprt->xp_raddr), &(xprt->xp_addrlen)); + if (rlen == -1 && errno == EINTR) + goto again; + if (rlen < 4*sizeof(u_long)) + return (FALSE); + xdrs->x_op = XDR_DECODE; + XDR_SETPOS(xdrs, 0); + if (! xdr_callmsg(xdrs, msg)) + return (FALSE); + su->su_xid = msg->rm_xid; + if (su->su_cache != NULL) { + if (cache_get(xprt, msg, &reply, &replylen)) { + (void) sendto(xprt->xp_sock, reply, (int) replylen, 0, + (struct sockaddr *) &xprt->xp_raddr, xprt->xp_addrlen); + return (TRUE); + } + } + return (TRUE); +} + +static bool_t +svcudp_reply(xprt, msg) + register SVCXPRT *xprt; + struct rpc_msg *msg; +{ + register struct svcudp_data *su = su_data(xprt); + register XDR *xdrs = &(su->su_xdrs); + register int slen; + register bool_t stat = FALSE; + + xdrs->x_op = XDR_ENCODE; + XDR_SETPOS(xdrs, 0); + msg->rm_xid = su->su_xid; + if (xdr_replymsg(xdrs, msg)) { + slen = (int)XDR_GETPOS(xdrs); + if (sendto(xprt->xp_sock, rpc_buffer(xprt), slen, 0, + (struct sockaddr *)&(xprt->xp_raddr), xprt->xp_addrlen) + == slen) { + stat = TRUE; + if (su->su_cache && slen >= 0) { + cache_set(xprt, (u_long) slen); + } + } + } + return (stat); +} + +static bool_t +svcudp_getargs(xprt, xdr_args, args_ptr) + SVCXPRT *xprt; + xdrproc_t xdr_args; + caddr_t args_ptr; +{ + + return ((*xdr_args)(&(su_data(xprt)->su_xdrs), args_ptr)); +} + +static bool_t +svcudp_freeargs(xprt, xdr_args, args_ptr) + SVCXPRT *xprt; + xdrproc_t xdr_args; + caddr_t args_ptr; +{ + register XDR *xdrs = &(su_data(xprt)->su_xdrs); + + xdrs->x_op = XDR_FREE; + return ((*xdr_args)(xdrs, args_ptr)); +} + +static void +svcudp_destroy(xprt) + register SVCXPRT *xprt; +{ + register struct svcudp_data *su = su_data(xprt); + + xprt_unregister(xprt); + (void)close(xprt->xp_sock); + XDR_DESTROY(&(su->su_xdrs)); + mem_free(rpc_buffer(xprt), su->su_iosz); + mem_free((caddr_t)su, sizeof(struct svcudp_data)); + mem_free((caddr_t)xprt, sizeof(SVCXPRT)); +} + + +/***********this could be a separate file*********************/ + +/* + * Fifo cache for udp server + * Copies pointers to reply buffers into fifo cache + * Buffers are sent again if retransmissions are detected. + */ + +#define SPARSENESS 4 /* 75% sparse */ + +#define CACHE_PERROR(msg) \ + (void) fprintf(stderr,"%s\n", msg) + +#define ALLOC(type, size) \ + (type *) mem_alloc((unsigned) (sizeof(type) * (size))) + +#define BZERO(addr, type, size) \ + bzero((char *) addr, sizeof(type) * (int) (size)) + +/* + * An entry in the cache + */ +typedef struct cache_node *cache_ptr; +struct cache_node { + /* + * Index into cache is xid, proc, vers, prog and address + */ + u_long cache_xid; + u_long cache_proc; + u_long cache_vers; + u_long cache_prog; + struct sockaddr_in cache_addr; + /* + * The cached reply and length + */ + char * cache_reply; + u_long cache_replylen; + /* + * Next node on the list, if there is a collision + */ + cache_ptr cache_next; +}; + + + +/* + * The entire cache + */ +struct udp_cache { + u_long uc_size; /* size of cache */ + cache_ptr *uc_entries; /* hash table of entries in cache */ + cache_ptr *uc_fifo; /* fifo list of entries in cache */ + u_long uc_nextvictim; /* points to next victim in fifo list */ + u_long uc_prog; /* saved program number */ + u_long uc_vers; /* saved version number */ + u_long uc_proc; /* saved procedure number */ + struct sockaddr_in uc_addr; /* saved caller's address */ +}; + + +/* + * the hashing function + */ +#define CACHE_LOC(transp, xid) \ + (xid % (SPARSENESS*((struct udp_cache *) su_data(transp)->su_cache)->uc_size)) + + +/* + * Enable use of the cache. + * Note: there is no disable. + */ +svcudp_enablecache(transp, size) + SVCXPRT *transp; + u_long size; +{ + struct svcudp_data *su = su_data(transp); + struct udp_cache *uc; + + if (su->su_cache != NULL) { + CACHE_PERROR("enablecache: cache already enabled"); + return(0); + } + uc = ALLOC(struct udp_cache, 1); + if (uc == NULL) { + CACHE_PERROR("enablecache: could not allocate cache"); + return(0); + } + uc->uc_size = size; + uc->uc_nextvictim = 0; + uc->uc_entries = ALLOC(cache_ptr, size * SPARSENESS); + if (uc->uc_entries == NULL) { + CACHE_PERROR("enablecache: could not allocate cache data"); + return(0); + } + BZERO(uc->uc_entries, cache_ptr, size * SPARSENESS); + uc->uc_fifo = ALLOC(cache_ptr, size); + if (uc->uc_fifo == NULL) { + CACHE_PERROR("enablecache: could not allocate cache fifo"); + return(0); + } + BZERO(uc->uc_fifo, cache_ptr, size); + su->su_cache = (char *) uc; + return(1); +} + + +/* + * Set an entry in the cache + */ +static +cache_set(xprt, replylen) + SVCXPRT *xprt; + u_long replylen; +{ + register cache_ptr victim; + register cache_ptr *vicp; + register struct svcudp_data *su = su_data(xprt); + struct udp_cache *uc = (struct udp_cache *) su->su_cache; + u_int loc; + char *newbuf; + + /* + * Find space for the new entry, either by + * reusing an old entry, or by mallocing a new one + */ + victim = uc->uc_fifo[uc->uc_nextvictim]; + if (victim != NULL) { + loc = CACHE_LOC(xprt, victim->cache_xid); + for (vicp = &uc->uc_entries[loc]; + *vicp != NULL && *vicp != victim; + vicp = &(*vicp)->cache_next) + ; + if (*vicp == NULL) { + CACHE_PERROR("cache_set: victim not found"); + return; + } + *vicp = victim->cache_next; /* remote from cache */ + newbuf = victim->cache_reply; + } else { + victim = ALLOC(struct cache_node, 1); + if (victim == NULL) { + CACHE_PERROR("cache_set: victim alloc failed"); + return; + } + newbuf = mem_alloc(su->su_iosz); + if (newbuf == NULL) { + CACHE_PERROR("cache_set: could not allocate new rpc_buffer"); + return; + } + } + + /* + * Store it away + */ + victim->cache_replylen = replylen; + victim->cache_reply = rpc_buffer(xprt); + rpc_buffer(xprt) = newbuf; + xdrmem_create(&(su->su_xdrs), rpc_buffer(xprt), su->su_iosz, XDR_ENCODE); + victim->cache_xid = su->su_xid; + victim->cache_proc = uc->uc_proc; + victim->cache_vers = uc->uc_vers; + victim->cache_prog = uc->uc_prog; + victim->cache_addr = uc->uc_addr; + loc = CACHE_LOC(xprt, victim->cache_xid); + victim->cache_next = uc->uc_entries[loc]; + uc->uc_entries[loc] = victim; + uc->uc_fifo[uc->uc_nextvictim++] = victim; + uc->uc_nextvictim %= uc->uc_size; +} + +/* + * Try to get an entry from the cache + * return 1 if found, 0 if not found + */ +static +cache_get(xprt, msg, replyp, replylenp) + SVCXPRT *xprt; + struct rpc_msg *msg; + char **replyp; + u_long *replylenp; +{ + u_int loc; + register cache_ptr ent; + register struct svcudp_data *su = su_data(xprt); + register struct udp_cache *uc = (struct udp_cache *) su->su_cache; + +# define EQADDR(a1, a2) (bcmp((char*)&a1, (char*)&a2, sizeof(a1)) == 0) + + loc = CACHE_LOC(xprt, su->su_xid); + for (ent = uc->uc_entries[loc]; ent != NULL; ent = ent->cache_next) { + if (ent->cache_xid == su->su_xid && + ent->cache_proc == uc->uc_proc && + ent->cache_vers == uc->uc_vers && + ent->cache_prog == uc->uc_prog && + EQADDR(ent->cache_addr, uc->uc_addr)) { + *replyp = ent->cache_reply; + *replylenp = ent->cache_replylen; + return(1); + } + } + /* + * Failed to find entry + * Remember a few things so we can do a set later + */ + uc->uc_proc = msg->rm_call.cb_proc; + uc->uc_vers = msg->rm_call.cb_vers; + uc->uc_prog = msg->rm_call.cb_prog; + uc->uc_addr = xprt->xp_raddr; + return(0); +} + diff -ruN glibc-1.07/sunrpc/xdr.c glibc-1.08.1/sunrpc/xdr.c --- glibc-1.07/sunrpc/xdr.c +++ glibc-1.08.1/sunrpc/xdr.c Sun Feb 6 16:42:49 1994 @@ -0,0 +1,577 @@ +/* @(#)xdr.c 2.1 88/07/29 4.0 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +#if !defined(lint) && defined(SCCSIDS) +static char sccsid[] = "@(#)xdr.c 1.35 87/08/12"; +#endif + +/* + * xdr.c, Generic XDR routines implementation. + * + * Copyright (C) 1986, Sun Microsystems, Inc. + * + * These are the "generic" xdr routines used to serialize and de-serialize + * most common data items. See xdr.h for more info on the interface to + * xdr. + */ + +#include +char *malloc(); + +#include +#include + +/* + * constants specific to the xdr "protocol" + */ +#define XDR_FALSE ((long) 0) +#define XDR_TRUE ((long) 1) +#define LASTUNSIGNED ((u_int) 0-1) + +/* + * for unit alignment + */ +static char xdr_zero[BYTES_PER_XDR_UNIT] = { 0, 0, 0, 0 }; + +/* + * Free a data structure using XDR + * Not a filter, but a convenient utility nonetheless + */ +void +xdr_free(proc, objp) + xdrproc_t proc; + char *objp; +{ + XDR x; + + x.x_op = XDR_FREE; + (*proc)(&x, objp); +} + +/* + * XDR nothing + */ +bool_t +xdr_void(/* xdrs, addr */) + /* XDR *xdrs; */ + /* caddr_t addr; */ +{ + + return (TRUE); +} + +/* + * XDR integers + */ +bool_t +xdr_int(xdrs, ip) + XDR *xdrs; + int *ip; +{ + +#ifdef lint + (void) (xdr_short(xdrs, (short *)ip)); + return (xdr_long(xdrs, (long *)ip)); +#else + if (sizeof (int) == sizeof (long)) { + return (xdr_long(xdrs, (long *)ip)); + } else { + return (xdr_short(xdrs, (short *)ip)); + } +#endif +} + +/* + * XDR unsigned integers + */ +bool_t +xdr_u_int(xdrs, up) + XDR *xdrs; + u_int *up; +{ + +#ifdef lint + (void) (xdr_short(xdrs, (short *)up)); + return (xdr_u_long(xdrs, (u_long *)up)); +#else + if (sizeof (u_int) == sizeof (u_long)) { + return (xdr_u_long(xdrs, (u_long *)up)); + } else { + return (xdr_short(xdrs, (short *)up)); + } +#endif +} + +/* + * XDR long integers + * same as xdr_u_long - open coded to save a proc call! + */ +bool_t +xdr_long(xdrs, lp) + register XDR *xdrs; + long *lp; +{ + + if (xdrs->x_op == XDR_ENCODE) + return (XDR_PUTLONG(xdrs, lp)); + + if (xdrs->x_op == XDR_DECODE) + return (XDR_GETLONG(xdrs, lp)); + + if (xdrs->x_op == XDR_FREE) + return (TRUE); + + return (FALSE); +} + +/* + * XDR unsigned long integers + * same as xdr_long - open coded to save a proc call! + */ +bool_t +xdr_u_long(xdrs, ulp) + register XDR *xdrs; + u_long *ulp; +{ + + if (xdrs->x_op == XDR_DECODE) + return (XDR_GETLONG(xdrs, (long *)ulp)); + if (xdrs->x_op == XDR_ENCODE) + return (XDR_PUTLONG(xdrs, (long *)ulp)); + if (xdrs->x_op == XDR_FREE) + return (TRUE); + return (FALSE); +} + +/* + * XDR short integers + */ +bool_t +xdr_short(xdrs, sp) + register XDR *xdrs; + short *sp; +{ + long l; + + switch (xdrs->x_op) { + + case XDR_ENCODE: + l = (long) *sp; + return (XDR_PUTLONG(xdrs, &l)); + + case XDR_DECODE: + if (!XDR_GETLONG(xdrs, &l)) { + return (FALSE); + } + *sp = (short) l; + return (TRUE); + + case XDR_FREE: + return (TRUE); + } + return (FALSE); +} + +/* + * XDR unsigned short integers + */ +bool_t +xdr_u_short(xdrs, usp) + register XDR *xdrs; + u_short *usp; +{ + u_long l; + + switch (xdrs->x_op) { + + case XDR_ENCODE: + l = (u_long) *usp; + return (XDR_PUTLONG(xdrs, &l)); + + case XDR_DECODE: + if (!XDR_GETLONG(xdrs, &l)) { + return (FALSE); + } + *usp = (u_short) l; + return (TRUE); + + case XDR_FREE: + return (TRUE); + } + return (FALSE); +} + + +/* + * XDR a char + */ +bool_t +xdr_char(xdrs, cp) + XDR *xdrs; + char *cp; +{ + int i; + + i = (*cp); + if (!xdr_int(xdrs, &i)) { + return (FALSE); + } + *cp = i; + return (TRUE); +} + +/* + * XDR an unsigned char + */ +bool_t +xdr_u_char(xdrs, cp) + XDR *xdrs; + char *cp; +{ + u_int u; + + u = (*cp); + if (!xdr_u_int(xdrs, &u)) { + return (FALSE); + } + *cp = u; + return (TRUE); +} + +/* + * XDR booleans + */ +bool_t +xdr_bool(xdrs, bp) + register XDR *xdrs; + bool_t *bp; +{ + long lb; + + switch (xdrs->x_op) { + + case XDR_ENCODE: + lb = *bp ? XDR_TRUE : XDR_FALSE; + return (XDR_PUTLONG(xdrs, &lb)); + + case XDR_DECODE: + if (!XDR_GETLONG(xdrs, &lb)) { + return (FALSE); + } + *bp = (lb == XDR_FALSE) ? FALSE : TRUE; + return (TRUE); + + case XDR_FREE: + return (TRUE); + } + return (FALSE); +} + +/* + * XDR enumerations + */ +bool_t +xdr_enum(xdrs, ep) + XDR *xdrs; + enum_t *ep; +{ +#ifndef lint + enum sizecheck { SIZEVAL }; /* used to find the size of an enum */ + + /* + * enums are treated as ints + */ + if (sizeof (enum sizecheck) == sizeof (long)) { + return (xdr_long(xdrs, (long *)ep)); + } else if (sizeof (enum sizecheck) == sizeof (short)) { + return (xdr_short(xdrs, (short *)ep)); + } else { + return (FALSE); + } +#else + (void) (xdr_short(xdrs, (short *)ep)); + return (xdr_long(xdrs, (long *)ep)); +#endif +} + +/* + * XDR opaque data + * Allows the specification of a fixed size sequence of opaque bytes. + * cp points to the opaque object and cnt gives the byte length. + */ +bool_t +xdr_opaque(xdrs, cp, cnt) + register XDR *xdrs; + caddr_t cp; + register u_int cnt; +{ + register u_int rndup; + static crud[BYTES_PER_XDR_UNIT]; + + /* + * if no data we are done + */ + if (cnt == 0) + return (TRUE); + + /* + * round byte count to full xdr units + */ + rndup = cnt % BYTES_PER_XDR_UNIT; + if (rndup > 0) + rndup = BYTES_PER_XDR_UNIT - rndup; + + if (xdrs->x_op == XDR_DECODE) { + if (!XDR_GETBYTES(xdrs, cp, cnt)) { + return (FALSE); + } + if (rndup == 0) + return (TRUE); + return (XDR_GETBYTES(xdrs, crud, rndup)); + } + + if (xdrs->x_op == XDR_ENCODE) { + if (!XDR_PUTBYTES(xdrs, cp, cnt)) { + return (FALSE); + } + if (rndup == 0) + return (TRUE); + return (XDR_PUTBYTES(xdrs, xdr_zero, rndup)); + } + + if (xdrs->x_op == XDR_FREE) { + return (TRUE); + } + + return (FALSE); +} + +/* + * XDR counted bytes + * *cpp is a pointer to the bytes, *sizep is the count. + * If *cpp is NULL maxsize bytes are allocated + */ +bool_t +xdr_bytes(xdrs, cpp, sizep, maxsize) + register XDR *xdrs; + char **cpp; + register u_int *sizep; + u_int maxsize; +{ + register char *sp = *cpp; /* sp is the actual string pointer */ + register u_int nodesize; + + /* + * first deal with the length since xdr bytes are counted + */ + if (! xdr_u_int(xdrs, sizep)) { + return (FALSE); + } + nodesize = *sizep; + if ((nodesize > maxsize) && (xdrs->x_op != XDR_FREE)) { + return (FALSE); + } + + /* + * now deal with the actual bytes + */ + switch (xdrs->x_op) { + + case XDR_DECODE: + if (nodesize == 0) { + return (TRUE); + } + if (sp == NULL) { + *cpp = sp = (char *)mem_alloc(nodesize); + } + if (sp == NULL) { + (void) fprintf(stderr, "xdr_bytes: out of memory\n"); + return (FALSE); + } + /* fall into ... */ + + case XDR_ENCODE: + return (xdr_opaque(xdrs, sp, nodesize)); + + case XDR_FREE: + if (sp != NULL) { + mem_free(sp, nodesize); + *cpp = NULL; + } + return (TRUE); + } + return (FALSE); +} + +/* + * Implemented here due to commonality of the object. + */ +bool_t +xdr_netobj(xdrs, np) + XDR *xdrs; + struct netobj *np; +{ + + return (xdr_bytes(xdrs, &np->n_bytes, &np->n_len, MAX_NETOBJ_SZ)); +} + +/* + * XDR a descriminated union + * Support routine for discriminated unions. + * You create an array of xdrdiscrim structures, terminated with + * an entry with a null procedure pointer. The routine gets + * the discriminant value and then searches the array of xdrdiscrims + * looking for that value. It calls the procedure given in the xdrdiscrim + * to handle the discriminant. If there is no specific routine a default + * routine may be called. + * If there is no specific or default routine an error is returned. + */ +bool_t +xdr_union(xdrs, dscmp, unp, choices, dfault) + register XDR *xdrs; + enum_t *dscmp; /* enum to decide which arm to work on */ + char *unp; /* the union itself */ + struct xdr_discrim *choices; /* [value, xdr proc] for each arm */ + xdrproc_t dfault; /* default xdr routine */ +{ + register enum_t dscm; + + /* + * we deal with the discriminator; it's an enum + */ + if (! xdr_enum(xdrs, dscmp)) { + return (FALSE); + } + dscm = *dscmp; + + /* + * search choices for a value that matches the discriminator. + * if we find one, execute the xdr routine for that value. + */ + for (; choices->proc != NULL_xdrproc_t; choices++) { + if (choices->value == dscm) + return ((*(choices->proc))(xdrs, unp, LASTUNSIGNED)); + } + + /* + * no match - execute the default xdr routine if there is one + */ + return ((dfault == NULL_xdrproc_t) ? FALSE : + (*dfault)(xdrs, unp, LASTUNSIGNED)); +} + + +/* + * Non-portable xdr primitives. + * Care should be taken when moving these routines to new architectures. + */ + + +/* + * XDR null terminated ASCII strings + * xdr_string deals with "C strings" - arrays of bytes that are + * terminated by a NULL character. The parameter cpp references a + * pointer to storage; If the pointer is null, then the necessary + * storage is allocated. The last parameter is the max allowed length + * of the string as specified by a protocol. + */ +bool_t +xdr_string(xdrs, cpp, maxsize) + register XDR *xdrs; + char **cpp; + u_int maxsize; +{ + register char *sp = *cpp; /* sp is the actual string pointer */ + u_int size; + u_int nodesize; + + /* + * first deal with the length since xdr strings are counted-strings + */ + switch (xdrs->x_op) { + case XDR_FREE: + if (sp == NULL) { + return(TRUE); /* already free */ + } + /* fall through... */ + case XDR_ENCODE: + size = strlen(sp); + break; + } + if (! xdr_u_int(xdrs, &size)) { + return (FALSE); + } + if (size > maxsize) { + return (FALSE); + } + nodesize = size + 1; + + /* + * now deal with the actual bytes + */ + switch (xdrs->x_op) { + + case XDR_DECODE: + if (nodesize == 0) { + return (TRUE); + } + if (sp == NULL) + *cpp = sp = (char *)mem_alloc(nodesize); + if (sp == NULL) { + (void) fprintf(stderr, "xdr_string: out of memory\n"); + return (FALSE); + } + sp[size] = 0; + /* fall into ... */ + + case XDR_ENCODE: + return (xdr_opaque(xdrs, sp, size)); + + case XDR_FREE: + mem_free(sp, nodesize); + *cpp = NULL; + return (TRUE); + } + return (FALSE); +} + +/* + * Wrapper for xdr_string that can be called directly from + * routines like clnt_call + */ +bool_t +xdr_wrapstring(xdrs, cpp) + XDR *xdrs; + char **cpp; +{ + if (xdr_string(xdrs, cpp, LASTUNSIGNED)) { + return (TRUE); + } + return (FALSE); +} diff -ruN glibc-1.07/sunrpc/xdr_array.c glibc-1.08.1/sunrpc/xdr_array.c --- glibc-1.07/sunrpc/xdr_array.c +++ glibc-1.08.1/sunrpc/xdr_array.c Sun Feb 6 16:42:50 1994 @@ -0,0 +1,153 @@ +/* @(#)xdr_array.c 2.1 88/07/29 4.0 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +#if !defined(lint) && defined(SCCSIDS) +static char sccsid[] = "@(#)xdr_array.c 1.10 87/08/11 Copyr 1984 Sun Micro"; +#endif + +/* + * xdr_array.c, Generic XDR routines impelmentation. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + * + * These are the "non-trivial" xdr primitives used to serialize and de-serialize + * arrays. See xdr.h for more info on the interface to xdr. + */ + +#include + +#include +#include + +#define LASTUNSIGNED ((u_int)0-1) + + +/* + * XDR an array of arbitrary elements + * *addrp is a pointer to the array, *sizep is the number of elements. + * If addrp is NULL (*sizep * elsize) bytes are allocated. + * elsize is the size (in bytes) of each element, and elproc is the + * xdr procedure to call to handle each element of the array. + */ +bool_t +xdr_array(xdrs, addrp, sizep, maxsize, elsize, elproc) + register XDR *xdrs; + caddr_t *addrp; /* array pointer */ + u_int *sizep; /* number of elements */ + u_int maxsize; /* max numberof elements */ + u_int elsize; /* size in bytes of each element */ + xdrproc_t elproc; /* xdr routine to handle each element */ +{ + register u_int i; + register caddr_t target = *addrp; + register u_int c; /* the actual element count */ + register bool_t stat = TRUE; + register u_int nodesize; + + /* like strings, arrays are really counted arrays */ + if (! xdr_u_int(xdrs, sizep)) { + return (FALSE); + } + c = *sizep; + if ((c > maxsize) && (xdrs->x_op != XDR_FREE)) { + return (FALSE); + } + nodesize = c * elsize; + + /* + * if we are deserializing, we may need to allocate an array. + * We also save time by checking for a null array if we are freeing. + */ + if (target == NULL) + switch (xdrs->x_op) { + case XDR_DECODE: + if (c == 0) + return (TRUE); + *addrp = target = mem_alloc(nodesize); + if (target == NULL) { + (void) fprintf(stderr, + "xdr_array: out of memory\n"); + return (FALSE); + } + bzero(target, nodesize); + break; + + case XDR_FREE: + return (TRUE); + } + + /* + * now we xdr each element of array + */ + for (i = 0; (i < c) && stat; i++) { + stat = (*elproc)(xdrs, target, LASTUNSIGNED); + target += elsize; + } + + /* + * the array may need freeing + */ + if (xdrs->x_op == XDR_FREE) { + mem_free(*addrp, nodesize); + *addrp = NULL; + } + return (stat); +} + +/* + * xdr_vector(): + * + * XDR a fixed length array. Unlike variable-length arrays, + * the storage of fixed length arrays is static and unfreeable. + * > basep: base of the array + * > size: size of the array + * > elemsize: size of each element + * > xdr_elem: routine to XDR each element + */ +bool_t +xdr_vector(xdrs, basep, nelem, elemsize, xdr_elem) + register XDR *xdrs; + register char *basep; + register u_int nelem; + register u_int elemsize; + register xdrproc_t xdr_elem; +{ + register u_int i; + register char *elptr; + + elptr = basep; + for (i = 0; i < nelem; i++) { + if (! (*xdr_elem)(xdrs, elptr, LASTUNSIGNED)) { + return(FALSE); + } + elptr += elemsize; + } + return(TRUE); +} + diff -ruN glibc-1.07/sunrpc/xdr_float.c glibc-1.08.1/sunrpc/xdr_float.c --- glibc-1.07/sunrpc/xdr_float.c +++ glibc-1.08.1/sunrpc/xdr_float.c Tue May 10 17:29:38 1994 @@ -0,0 +1,267 @@ +/* @(#)xdr_float.c 2.1 88/07/29 4.0 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +#if !defined(lint) && defined(SCCSIDS) +static char sccsid[] = "@(#)xdr_float.c 1.12 87/08/11 Copyr 1984 Sun Micro"; +#endif + +/* + * xdr_float.c, Generic XDR routines impelmentation. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + * + * These are the "floating point" xdr routines used to (de)serialize + * most common data items. See xdr.h for more info on the interface to + * xdr. + */ + +#include + +#include +#include + +/* + * NB: Not portable. + * This routine works on Suns (Sky / 68000's) and Vaxen. + */ + +#ifdef vax + +/* What IEEE single precision floating point looks like on a Vax */ +struct ieee_single { + unsigned int mantissa: 23; + unsigned int exp : 8; + unsigned int sign : 1; +}; + +/* Vax single precision floating point */ +struct vax_single { + unsigned int mantissa1 : 7; + unsigned int exp : 8; + unsigned int sign : 1; + unsigned int mantissa2 : 16; +}; + +#define VAX_SNG_BIAS 0x81 +#define IEEE_SNG_BIAS 0x7f + +static struct sgl_limits { + struct vax_single s; + struct ieee_single ieee; +} sgl_limits[2] = { + {{ 0x7f, 0xff, 0x0, 0xffff }, /* Max Vax */ + { 0x0, 0xff, 0x0 }}, /* Max IEEE */ + {{ 0x0, 0x0, 0x0, 0x0 }, /* Min Vax */ + { 0x0, 0x0, 0x0 }} /* Min IEEE */ +}; +#endif /* vax */ + +bool_t +xdr_float(xdrs, fp) + register XDR *xdrs; + register float *fp; +{ +#ifdef vax + struct ieee_single is; + struct vax_single vs, *vsp; + struct sgl_limits *lim; + int i; +#endif + switch (xdrs->x_op) { + + case XDR_ENCODE: +#ifndef vax + return (XDR_PUTLONG(xdrs, (long *)fp)); +#else + vs = *((struct vax_single *)fp); + for (i = 0, lim = sgl_limits; + i < sizeof(sgl_limits)/sizeof(struct sgl_limits); + i++, lim++) { + if ((vs.mantissa2 == lim->s.mantissa2) && + (vs.exp == lim->s.exp) && + (vs.mantissa1 == lim->s.mantissa1)) { + is = lim->ieee; + goto shipit; + } + } + is.exp = vs.exp - VAX_SNG_BIAS + IEEE_SNG_BIAS; + is.mantissa = (vs.mantissa1 << 16) | vs.mantissa2; + shipit: + is.sign = vs.sign; + return (XDR_PUTLONG(xdrs, (long *)&is)); +#endif + + case XDR_DECODE: +#ifndef vax + return (XDR_GETLONG(xdrs, (long *)fp)); +#else + vsp = (struct vax_single *)fp; + if (!XDR_GETLONG(xdrs, (long *)&is)) + return (FALSE); + for (i = 0, lim = sgl_limits; + i < sizeof(sgl_limits)/sizeof(struct sgl_limits); + i++, lim++) { + if ((is.exp == lim->ieee.exp) && + (is.mantissa == lim->ieee.mantissa)) { + *vsp = lim->s; + goto doneit; + } + } + vsp->exp = is.exp - IEEE_SNG_BIAS + VAX_SNG_BIAS; + vsp->mantissa2 = is.mantissa; + vsp->mantissa1 = (is.mantissa >> 16); + doneit: + vsp->sign = is.sign; + return (TRUE); +#endif + + case XDR_FREE: + return (TRUE); + } + return (FALSE); +} + +/* + * This routine works on Suns (Sky / 68000's) and Vaxen. + */ + +#ifdef vax +/* What IEEE double precision floating point looks like on a Vax */ +struct ieee_double { + unsigned int mantissa1 : 20; + unsigned int exp : 11; + unsigned int sign : 1; + unsigned int mantissa2 : 32; +}; + +/* Vax double precision floating point */ +struct vax_double { + unsigned int mantissa1 : 7; + unsigned int exp : 8; + unsigned int sign : 1; + unsigned int mantissa2 : 16; + unsigned int mantissa3 : 16; + unsigned int mantissa4 : 16; +}; + +#define VAX_DBL_BIAS 0x81 +#define IEEE_DBL_BIAS 0x3ff +#define MASK(nbits) ((1 << nbits) - 1) + +static struct dbl_limits { + struct vax_double d; + struct ieee_double ieee; +} dbl_limits[2] = { + {{ 0x7f, 0xff, 0x0, 0xffff, 0xffff, 0xffff }, /* Max Vax */ + { 0x0, 0x7ff, 0x0, 0x0 }}, /* Max IEEE */ + {{ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, /* Min Vax */ + { 0x0, 0x0, 0x0, 0x0 }} /* Min IEEE */ +}; + +#endif /* vax */ + + +bool_t +xdr_double(xdrs, dp) + register XDR *xdrs; + double *dp; +{ + register long *lp; +#ifdef vax + struct ieee_double id; + struct vax_double vd; + register struct dbl_limits *lim; + int i; +#endif + + switch (xdrs->x_op) { + + case XDR_ENCODE: +#ifndef vax + lp = (long *)dp; +#else + vd = *((struct vax_double *)dp); + for (i = 0, lim = dbl_limits; + i < sizeof(dbl_limits)/sizeof(struct dbl_limits); + i++, lim++) { + if ((vd.mantissa4 == lim->d.mantissa4) && + (vd.mantissa3 == lim->d.mantissa3) && + (vd.mantissa2 == lim->d.mantissa2) && + (vd.mantissa1 == lim->d.mantissa1) && + (vd.exp == lim->d.exp)) { + id = lim->ieee; + goto shipit; + } + } + id.exp = vd.exp - VAX_DBL_BIAS + IEEE_DBL_BIAS; + id.mantissa1 = (vd.mantissa1 << 13) | (vd.mantissa2 >> 3); + id.mantissa2 = ((vd.mantissa2 & MASK(3)) << 29) | + (vd.mantissa3 << 13) | + ((vd.mantissa4 >> 3) & MASK(13)); + shipit: + id.sign = vd.sign; + lp = (long *)&id; +#endif + return (XDR_PUTLONG(xdrs, lp++) && XDR_PUTLONG(xdrs, lp)); + + case XDR_DECODE: +#ifndef vax + lp = (long *)dp; + return (XDR_GETLONG(xdrs, lp++) && XDR_GETLONG(xdrs, lp)); +#else + lp = (long *)&id; + if (!XDR_GETLONG(xdrs, lp++) || !XDR_GETLONG(xdrs, lp)) + return (FALSE); + for (i = 0, lim = dbl_limits; + i < sizeof(dbl_limits)/sizeof(struct dbl_limits); + i++, lim++) { + if ((id.mantissa2 == lim->ieee.mantissa2) && + (id.mantissa1 == lim->ieee.mantissa1) && + (id.exp == lim->ieee.exp)) { + vd = lim->d; + goto doneit; + } + } + vd.exp = id.exp - IEEE_DBL_BIAS + VAX_DBL_BIAS; + vd.mantissa1 = (id.mantissa1 >> 13); + vd.mantissa2 = ((id.mantissa1 & MASK(13)) << 3) | + (id.mantissa2 >> 29); + vd.mantissa3 = (id.mantissa2 >> 13); + vd.mantissa4 = (id.mantissa2 << 3); + doneit: + vd.sign = id.sign; + *dp = *((double *)&vd); + return (TRUE); +#endif + + case XDR_FREE: + return (TRUE); + } + return (FALSE); +} diff -ruN glibc-1.07/sunrpc/xdr_mem.c glibc-1.08.1/sunrpc/xdr_mem.c --- glibc-1.07/sunrpc/xdr_mem.c +++ glibc-1.08.1/sunrpc/xdr_mem.c Sun Feb 6 16:42:50 1994 @@ -0,0 +1,184 @@ +/* @(#)xdr_mem.c 2.1 88/07/29 4.0 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +#if !defined(lint) && defined(SCCSIDS) +static char sccsid[] = "@(#)xdr_mem.c 1.19 87/08/11 Copyr 1984 Sun Micro"; +#endif + +/* + * xdr_mem.h, XDR implementation using memory buffers. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + * + * If you have some data to be interpreted as external data representation + * or to be converted to external data representation in a memory buffer, + * then this is the package for you. + * + */ + + +#include +#include +#include + +static bool_t xdrmem_getlong(); +static bool_t xdrmem_putlong(); +static bool_t xdrmem_getbytes(); +static bool_t xdrmem_putbytes(); +static u_int xdrmem_getpos(); +static bool_t xdrmem_setpos(); +static long * xdrmem_inline(); +static void xdrmem_destroy(); + +static struct xdr_ops xdrmem_ops = { + xdrmem_getlong, + xdrmem_putlong, + xdrmem_getbytes, + xdrmem_putbytes, + xdrmem_getpos, + xdrmem_setpos, + xdrmem_inline, + xdrmem_destroy +}; + +/* + * The procedure xdrmem_create initializes a stream descriptor for a + * memory buffer. + */ +void +xdrmem_create(xdrs, addr, size, op) + register XDR *xdrs; + caddr_t addr; + u_int size; + enum xdr_op op; +{ + + xdrs->x_op = op; + xdrs->x_ops = &xdrmem_ops; + xdrs->x_private = xdrs->x_base = addr; + xdrs->x_handy = size; +} + +static void +xdrmem_destroy(/*xdrs*/) + /*XDR *xdrs;*/ +{ +} + +static bool_t +xdrmem_getlong(xdrs, lp) + register XDR *xdrs; + long *lp; +{ + + if ((xdrs->x_handy -= sizeof(long)) < 0) + return (FALSE); + *lp = (long)ntohl((u_long)(*((long *)(xdrs->x_private)))); + xdrs->x_private += sizeof(long); + return (TRUE); +} + +static bool_t +xdrmem_putlong(xdrs, lp) + register XDR *xdrs; + long *lp; +{ + + if ((xdrs->x_handy -= sizeof(long)) < 0) + return (FALSE); + *(long *)xdrs->x_private = (long)htonl((u_long)(*lp)); + xdrs->x_private += sizeof(long); + return (TRUE); +} + +static bool_t +xdrmem_getbytes(xdrs, addr, len) + register XDR *xdrs; + caddr_t addr; + register u_int len; +{ + + if ((xdrs->x_handy -= len) < 0) + return (FALSE); + bcopy(xdrs->x_private, addr, len); + xdrs->x_private += len; + return (TRUE); +} + +static bool_t +xdrmem_putbytes(xdrs, addr, len) + register XDR *xdrs; + caddr_t addr; + register u_int len; +{ + + if ((xdrs->x_handy -= len) < 0) + return (FALSE); + bcopy(addr, xdrs->x_private, len); + xdrs->x_private += len; + return (TRUE); +} + +static u_int +xdrmem_getpos(xdrs) + register XDR *xdrs; +{ + + return ((u_int)xdrs->x_private - (u_int)xdrs->x_base); +} + +static bool_t +xdrmem_setpos(xdrs, pos) + register XDR *xdrs; + u_int pos; +{ + register caddr_t newaddr = xdrs->x_base + pos; + register caddr_t lastaddr = xdrs->x_private + xdrs->x_handy; + + if ((long)newaddr > (long)lastaddr) + return (FALSE); + xdrs->x_private = newaddr; + xdrs->x_handy = (int)lastaddr - (int)newaddr; + return (TRUE); +} + +static long * +xdrmem_inline(xdrs, len) + register XDR *xdrs; + int len; +{ + long *buf = 0; + + if (xdrs->x_handy >= len) { + xdrs->x_handy -= len; + buf = (long *) xdrs->x_private; + xdrs->x_private += len; + } + return (buf); +} diff -ruN glibc-1.07/sunrpc/xdr_rec.c glibc-1.08.1/sunrpc/xdr_rec.c --- glibc-1.07/sunrpc/xdr_rec.c +++ glibc-1.08.1/sunrpc/xdr_rec.c Sun Feb 6 16:42:50 1994 @@ -0,0 +1,580 @@ +/* @(#)xdr_rec.c 2.2 88/08/01 4.0 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +#if !defined(lint) && defined(SCCSIDS) +static char sccsid[] = "@(#)xdr_rec.c 1.21 87/08/11 Copyr 1984 Sun Micro"; +#endif + +/* + * xdr_rec.c, Implements TCP/IP based XDR streams with a "record marking" + * layer above tcp (for rpc's use). + * + * Copyright (C) 1984, Sun Microsystems, Inc. + * + * These routines interface XDRSTREAMS to a tcp/ip connection. + * There is a record marking layer between the xdr stream + * and the tcp transport level. A record is composed on one or more + * record fragments. A record fragment is a thirty-two bit header followed + * by n bytes of data, where n is contained in the header. The header + * is represented as a htonl(u_long). Thegh order bit encodes + * whether or not the fragment is the last fragment of the record + * (1 => fragment is last, 0 => more fragments to follow. + * The other 31 bits encode the byte length of the fragment. + */ + +#include +#include +#include +#include + +extern long lseek(); + +static u_int fix_buf_size(); + +static bool_t xdrrec_getlong(); +static bool_t xdrrec_putlong(); +static bool_t xdrrec_getbytes(); +static bool_t xdrrec_putbytes(); +static u_int xdrrec_getpos(); +static bool_t xdrrec_setpos(); +static long * xdrrec_inline(); +static void xdrrec_destroy(); + +static struct xdr_ops xdrrec_ops = { + xdrrec_getlong, + xdrrec_putlong, + xdrrec_getbytes, + xdrrec_putbytes, + xdrrec_getpos, + xdrrec_setpos, + xdrrec_inline, + xdrrec_destroy +}; + +/* + * A record is composed of one or more record fragments. + * A record fragment is a two-byte header followed by zero to + * 2**32-1 bytes. The header is treated as a long unsigned and is + * encode/decoded to the network via htonl/ntohl. The low order 31 bits + * are a byte count of the fragment. The highest order bit is a boolean: + * 1 => this fragment is the last fragment of the record, + * 0 => this fragment is followed by more fragment(s). + * + * The fragment/record machinery is not general; it is constructed to + * meet the needs of xdr and rpc based on tcp. + */ + +#define LAST_FRAG ((u_long)(1 << 31)) + +typedef struct rec_strm { + caddr_t tcp_handle; + caddr_t the_buffer; + /* + * out-goung bits + */ + int (*writeit)(); + caddr_t out_base; /* output buffer (points to frag header) */ + caddr_t out_finger; /* next output position */ + caddr_t out_boundry; /* data cannot up to this address */ + u_long *frag_header; /* beginning of curren fragment */ + bool_t frag_sent; /* true if buffer sent in middle of record */ + /* + * in-coming bits + */ + int (*readit)(); + u_long in_size; /* fixed size of the input buffer */ + caddr_t in_base; + caddr_t in_finger; /* location of next byte to be had */ + caddr_t in_boundry; /* can read up to this location */ + long fbtbc; /* fragment bytes to be consumed */ + bool_t last_frag; + u_int sendsize; + u_int recvsize; +} RECSTREAM; + + +/* + * Create an xdr handle for xdrrec + * xdrrec_create fills in xdrs. Sendsize and recvsize are + * send and recv buffer sizes (0 => use default). + * tcp_handle is an opaque handle that is passed as the first parameter to + * the procedures readit and writeit. Readit and writeit are read and + * write respectively. They are like the system + * calls expect that they take an opaque handle rather than an fd. + */ +void +xdrrec_create(xdrs, sendsize, recvsize, tcp_handle, readit, writeit) + register XDR *xdrs; + register u_int sendsize; + register u_int recvsize; + caddr_t tcp_handle; + int (*readit)(); /* like read, but pass it a tcp_handle, not sock */ + int (*writeit)(); /* like write, but pass it a tcp_handle, not sock */ +{ + register RECSTREAM *rstrm = + (RECSTREAM *)mem_alloc(sizeof(RECSTREAM)); + + if (rstrm == NULL) { + (void)fprintf(stderr, "xdrrec_create: out of memory\n"); + /* + * This is bad. Should rework xdrrec_create to + * return a handle, and in this case return NULL + */ + return; + } + /* + * adjust sizes and allocate buffer quad byte aligned + */ + rstrm->sendsize = sendsize = fix_buf_size(sendsize); + rstrm->recvsize = recvsize = fix_buf_size(recvsize); + rstrm->the_buffer = mem_alloc(sendsize + recvsize + BYTES_PER_XDR_UNIT); + if (rstrm->the_buffer == NULL) { + (void)fprintf(stderr, "xdrrec_create: out of memory\n"); + return; + } + for (rstrm->out_base = rstrm->the_buffer; + (u_int)rstrm->out_base % BYTES_PER_XDR_UNIT != 0; + rstrm->out_base++); + rstrm->in_base = rstrm->out_base + sendsize; + /* + * now the rest ... + */ + xdrs->x_ops = &xdrrec_ops; + xdrs->x_private = (caddr_t)rstrm; + rstrm->tcp_handle = tcp_handle; + rstrm->readit = readit; + rstrm->writeit = writeit; + rstrm->out_finger = rstrm->out_boundry = rstrm->out_base; + rstrm->frag_header = (u_long *)rstrm->out_base; + rstrm->out_finger += sizeof(u_long); + rstrm->out_boundry += sendsize; + rstrm->frag_sent = FALSE; + rstrm->in_size = recvsize; + rstrm->in_boundry = rstrm->in_base; + rstrm->in_finger = (rstrm->in_boundry += recvsize); + rstrm->fbtbc = 0; + rstrm->last_frag = TRUE; +} + + +/* + * The reoutines defined below are the xdr ops which will go into the + * xdr handle filled in by xdrrec_create. + */ + +static bool_t +xdrrec_getlong(xdrs, lp) + XDR *xdrs; + long *lp; +{ + register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); + register long *buflp = (long *)(rstrm->in_finger); + long mylong; + + /* first try the inline, fast case */ + if ((rstrm->fbtbc >= sizeof(long)) && + (((int)rstrm->in_boundry - (int)buflp) >= sizeof(long))) { + *lp = (long)ntohl((u_long)(*buflp)); + rstrm->fbtbc -= sizeof(long); + rstrm->in_finger += sizeof(long); + } else { + if (! xdrrec_getbytes(xdrs, (caddr_t)&mylong, sizeof(long))) + return (FALSE); + *lp = (long)ntohl((u_long)mylong); + } + return (TRUE); +} + +static bool_t +xdrrec_putlong(xdrs, lp) + XDR *xdrs; + long *lp; +{ + register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); + register long *dest_lp = ((long *)(rstrm->out_finger)); + + if ((rstrm->out_finger += sizeof(long)) > rstrm->out_boundry) { + /* + * this case should almost never happen so the code is + * inefficient + */ + rstrm->out_finger -= sizeof(long); + rstrm->frag_sent = TRUE; + if (! flush_out(rstrm, FALSE)) + return (FALSE); + dest_lp = ((long *)(rstrm->out_finger)); + rstrm->out_finger += sizeof(long); + } + *dest_lp = (long)htonl((u_long)(*lp)); + return (TRUE); +} + +static bool_t /* must manage buffers, fragments, and records */ +xdrrec_getbytes(xdrs, addr, len) + XDR *xdrs; + register caddr_t addr; + register u_int len; +{ + register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); + register int current; + + while (len > 0) { + current = rstrm->fbtbc; + if (current == 0) { + if (rstrm->last_frag) + return (FALSE); + if (! set_input_fragment(rstrm)) + return (FALSE); + continue; + } + current = (len < current) ? len : current; + if (! get_input_bytes(rstrm, addr, current)) + return (FALSE); + addr += current; + rstrm->fbtbc -= current; + len -= current; + } + return (TRUE); +} + +static bool_t +xdrrec_putbytes(xdrs, addr, len) + XDR *xdrs; + register caddr_t addr; + register u_int len; +{ + register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); + register int current; + + while (len > 0) { + current = (u_int)rstrm->out_boundry - (u_int)rstrm->out_finger; + current = (len < current) ? len : current; + bcopy(addr, rstrm->out_finger, current); + rstrm->out_finger += current; + addr += current; + len -= current; + if (rstrm->out_finger == rstrm->out_boundry) { + rstrm->frag_sent = TRUE; + if (! flush_out(rstrm, FALSE)) + return (FALSE); + } + } + return (TRUE); +} + +static u_int +xdrrec_getpos(xdrs) + register XDR *xdrs; +{ + register RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private; + register long pos; + + pos = lseek((int)rstrm->tcp_handle, (long) 0, 1); + if (pos != -1) + switch (xdrs->x_op) { + + case XDR_ENCODE: + pos += rstrm->out_finger - rstrm->out_base; + break; + + case XDR_DECODE: + pos -= rstrm->in_boundry - rstrm->in_finger; + break; + + default: + pos = (u_int) -1; + break; + } + return ((u_int) pos); +} + +static bool_t +xdrrec_setpos(xdrs, pos) + register XDR *xdrs; + u_int pos; +{ + register RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private; + u_int currpos = xdrrec_getpos(xdrs); + int delta = currpos - pos; + caddr_t newpos; + + if ((int)currpos != -1) + switch (xdrs->x_op) { + + case XDR_ENCODE: + newpos = rstrm->out_finger - delta; + if ((newpos > (caddr_t)(rstrm->frag_header)) && + (newpos < rstrm->out_boundry)) { + rstrm->out_finger = newpos; + return (TRUE); + } + break; + + case XDR_DECODE: + newpos = rstrm->in_finger - delta; + if ((delta < (int)(rstrm->fbtbc)) && + (newpos <= rstrm->in_boundry) && + (newpos >= rstrm->in_base)) { + rstrm->in_finger = newpos; + rstrm->fbtbc -= delta; + return (TRUE); + } + break; + } + return (FALSE); +} + +static long * +xdrrec_inline(xdrs, len) + register XDR *xdrs; + int len; +{ + register RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private; + long * buf = NULL; + + switch (xdrs->x_op) { + + case XDR_ENCODE: + if ((rstrm->out_finger + len) <= rstrm->out_boundry) { + buf = (long *) rstrm->out_finger; + rstrm->out_finger += len; + } + break; + + case XDR_DECODE: + if ((len <= rstrm->fbtbc) && + ((rstrm->in_finger + len) <= rstrm->in_boundry)) { + buf = (long *) rstrm->in_finger; + rstrm->fbtbc -= len; + rstrm->in_finger += len; + } + break; + } + return (buf); +} + +static void +xdrrec_destroy(xdrs) + register XDR *xdrs; +{ + register RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private; + + mem_free(rstrm->the_buffer, + rstrm->sendsize + rstrm->recvsize + BYTES_PER_XDR_UNIT); + mem_free((caddr_t)rstrm, sizeof(RECSTREAM)); +} + + +/* + * Exported routines to manage xdr records + */ + +/* + * Before reading (deserializing from the stream, one should always call + * this procedure to guarantee proper record alignment. + */ +bool_t +xdrrec_skiprecord(xdrs) + XDR *xdrs; +{ + register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); + + while (rstrm->fbtbc > 0 || (! rstrm->last_frag)) { + if (! skip_input_bytes(rstrm, rstrm->fbtbc)) + return (FALSE); + rstrm->fbtbc = 0; + if ((! rstrm->last_frag) && (! set_input_fragment(rstrm))) + return (FALSE); + } + rstrm->last_frag = FALSE; + return (TRUE); +} + +/* + * Look ahead fuction. + * Returns TRUE iff there is no more input in the buffer + * after consuming the rest of the current record. + */ +bool_t +xdrrec_eof(xdrs) + XDR *xdrs; +{ + register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); + + while (rstrm->fbtbc > 0 || (! rstrm->last_frag)) { + if (! skip_input_bytes(rstrm, rstrm->fbtbc)) + return (TRUE); + rstrm->fbtbc = 0; + if ((! rstrm->last_frag) && (! set_input_fragment(rstrm))) + return (TRUE); + } + if (rstrm->in_finger == rstrm->in_boundry) + return (TRUE); + return (FALSE); +} + +/* + * The client must tell the package when an end-of-record has occurred. + * The second paraemters tells whether the record should be flushed to the + * (output) tcp stream. (This let's the package support batched or + * pipelined procedure calls.) TRUE => immmediate flush to tcp connection. + */ +bool_t +xdrrec_endofrecord(xdrs, sendnow) + XDR *xdrs; + bool_t sendnow; +{ + register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); + register u_long len; /* fragment length */ + + if (sendnow || rstrm->frag_sent || + ((u_long)rstrm->out_finger + sizeof(u_long) >= + (u_long)rstrm->out_boundry)) { + rstrm->frag_sent = FALSE; + return (flush_out(rstrm, TRUE)); + } + len = (u_long)(rstrm->out_finger) - (u_long)(rstrm->frag_header) - + sizeof(u_long); + *(rstrm->frag_header) = htonl((u_long)len | LAST_FRAG); + rstrm->frag_header = (u_long *)rstrm->out_finger; + rstrm->out_finger += sizeof(u_long); + return (TRUE); +} + + +/* + * Internal useful routines + */ +static bool_t +flush_out(rstrm, eor) + register RECSTREAM *rstrm; + bool_t eor; +{ + register u_long eormask = (eor == TRUE) ? LAST_FRAG : 0; + register u_long len = (u_long)(rstrm->out_finger) - + (u_long)(rstrm->frag_header) - sizeof(u_long); + + *(rstrm->frag_header) = htonl(len | eormask); + len = (u_long)(rstrm->out_finger) - (u_long)(rstrm->out_base); + if ((*(rstrm->writeit))(rstrm->tcp_handle, rstrm->out_base, (int)len) + != (int)len) + return (FALSE); + rstrm->frag_header = (u_long *)rstrm->out_base; + rstrm->out_finger = (caddr_t)rstrm->out_base + sizeof(u_long); + return (TRUE); +} + +static bool_t /* knows nothing about records! Only about input buffers */ +fill_input_buf(rstrm) + register RECSTREAM *rstrm; +{ + register caddr_t where; + u_int i; + register int len; + + where = rstrm->in_base; + i = (u_int)rstrm->in_boundry % BYTES_PER_XDR_UNIT; + where += i; + len = rstrm->in_size - i; + if ((len = (*(rstrm->readit))(rstrm->tcp_handle, where, len)) == -1) + return (FALSE); + rstrm->in_finger = where; + where += len; + rstrm->in_boundry = where; + return (TRUE); +} + +static bool_t /* knows nothing about records! Only about input buffers */ +get_input_bytes(rstrm, addr, len) + register RECSTREAM *rstrm; + register caddr_t addr; + register int len; +{ + register int current; + + while (len > 0) { + current = (int)rstrm->in_boundry - (int)rstrm->in_finger; + if (current == 0) { + if (! fill_input_buf(rstrm)) + return (FALSE); + continue; + } + current = (len < current) ? len : current; + bcopy(rstrm->in_finger, addr, current); + rstrm->in_finger += current; + addr += current; + len -= current; + } + return (TRUE); +} + +static bool_t /* next two bytes of the input stream are treated as a header */ +set_input_fragment(rstrm) + register RECSTREAM *rstrm; +{ + u_long header; + + if (! get_input_bytes(rstrm, (caddr_t)&header, sizeof(header))) + return (FALSE); + header = (long)ntohl(header); + rstrm->last_frag = ((header & LAST_FRAG) == 0) ? FALSE : TRUE; + rstrm->fbtbc = header & (~LAST_FRAG); + return (TRUE); +} + +static bool_t /* consumes input bytes; knows nothing about records! */ +skip_input_bytes(rstrm, cnt) + register RECSTREAM *rstrm; + long cnt; +{ + register int current; + + while (cnt > 0) { + current = (int)rstrm->in_boundry - (int)rstrm->in_finger; + if (current == 0) { + if (! fill_input_buf(rstrm)) + return (FALSE); + continue; + } + current = (cnt < current) ? cnt : current; + rstrm->in_finger += current; + cnt -= current; + } + return (TRUE); +} + +static u_int +fix_buf_size(s) + register u_int s; +{ + + if (s < 100) + s = 4000; + return (RNDUP(s)); +} diff -ruN glibc-1.07/sunrpc/xdr_ref.c glibc-1.08.1/sunrpc/xdr_ref.c --- glibc-1.07/sunrpc/xdr_ref.c +++ glibc-1.08.1/sunrpc/xdr_ref.c Sun Feb 6 16:42:50 1994 @@ -0,0 +1,132 @@ +/* @(#)xdr_reference.c 2.1 88/07/29 4.0 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +#if !defined(lint) && defined(SCCSIDS) +static char sccsid[] = "@(#)xdr_reference.c 1.11 87/08/11 SMI"; +#endif + +/* + * xdr_reference.c, Generic XDR routines impelmentation. + * + * Copyright (C) 1987, Sun Microsystems, Inc. + * + * These are the "non-trivial" xdr primitives used to serialize and de-serialize + * "pointers". See xdr.h for more info on the interface to xdr. + */ + +#include +#include +#include + +#define LASTUNSIGNED ((u_int)0-1) + +/* + * XDR an indirect pointer + * xdr_reference is for recursively translating a structure that is + * referenced by a pointer inside the structure that is currently being + * translated. pp references a pointer to storage. If *pp is null + * the necessary storage is allocated. + * size is the sizeof the referneced structure. + * proc is the routine to handle the referenced structure. + */ +bool_t +xdr_reference(xdrs, pp, size, proc) + register XDR *xdrs; + caddr_t *pp; /* the pointer to work on */ + u_int size; /* size of the object pointed to */ + xdrproc_t proc; /* xdr routine to handle the object */ +{ + register caddr_t loc = *pp; + register bool_t stat; + + if (loc == NULL) + switch (xdrs->x_op) { + case XDR_FREE: + return (TRUE); + + case XDR_DECODE: + *pp = loc = (caddr_t) mem_alloc(size); + if (loc == NULL) { + (void) fprintf(stderr, + "xdr_reference: out of memory\n"); + return (FALSE); + } + bzero(loc, (int)size); + break; + } + + stat = (*proc)(xdrs, loc, LASTUNSIGNED); + + if (xdrs->x_op == XDR_FREE) { + mem_free(loc, size); + *pp = NULL; + } + return (stat); +} + + +/* + * xdr_pointer(): + * + * XDR a pointer to a possibly recursive data structure. This + * differs with xdr_reference in that it can serialize/deserialiaze + * trees correctly. + * + * What's sent is actually a union: + * + * union object_pointer switch (boolean b) { + * case TRUE: object_data data; + * case FALSE: void nothing; + * } + * + * > objpp: Pointer to the pointer to the object. + * > obj_size: size of the object. + * > xdr_obj: routine to XDR an object. + * + */ +bool_t +xdr_pointer(xdrs,objpp,obj_size,xdr_obj) + register XDR *xdrs; + char **objpp; + u_int obj_size; + xdrproc_t xdr_obj; +{ + + bool_t more_data; + + more_data = (*objpp != NULL); + if (! xdr_bool(xdrs,&more_data)) { + return (FALSE); + } + if (! more_data) { + *objpp = NULL; + return (TRUE); + } + return (xdr_reference(xdrs,objpp,obj_size,xdr_obj)); +} diff -ruN glibc-1.07/sunrpc/xdr_stdio.c glibc-1.08.1/sunrpc/xdr_stdio.c --- glibc-1.07/sunrpc/xdr_stdio.c +++ glibc-1.08.1/sunrpc/xdr_stdio.c Sun Feb 6 16:42:50 1994 @@ -0,0 +1,189 @@ +/* @(#)xdr_stdio.c 2.1 88/07/29 4.0 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +#if !defined(lint) && defined(SCCSIDS) +static char sccsid[] = "@(#)xdr_stdio.c 1.16 87/08/11 Copyr 1984 Sun Micro"; +#endif + +/* + * xdr_stdio.c, XDR implementation on standard i/o file. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + * + * This set of routines implements a XDR on a stdio stream. + * XDR_ENCODE serializes onto the stream, XDR_DECODE de-serializes + * from the stream. + */ + +#include +#include +#include + +static bool_t xdrstdio_getlong(); +static bool_t xdrstdio_putlong(); +static bool_t xdrstdio_getbytes(); +static bool_t xdrstdio_putbytes(); +static u_int xdrstdio_getpos(); +static bool_t xdrstdio_setpos(); +static long * xdrstdio_inline(); +static void xdrstdio_destroy(); + +/* + * Ops vector for stdio type XDR + */ +static struct xdr_ops xdrstdio_ops = { + xdrstdio_getlong, /* deseraialize a long int */ + xdrstdio_putlong, /* seraialize a long int */ + xdrstdio_getbytes, /* deserialize counted bytes */ + xdrstdio_putbytes, /* serialize counted bytes */ + xdrstdio_getpos, /* get offset in the stream */ + xdrstdio_setpos, /* set offset in the stream */ + xdrstdio_inline, /* prime stream for inline macros */ + xdrstdio_destroy /* destroy stream */ +}; + +/* + * Initialize a stdio xdr stream. + * Sets the xdr stream handle xdrs for use on the stream file. + * Operation flag is set to op. + */ +void +xdrstdio_create(xdrs, file, op) + register XDR *xdrs; + FILE *file; + enum xdr_op op; +{ + + xdrs->x_op = op; + xdrs->x_ops = &xdrstdio_ops; + xdrs->x_private = (caddr_t)file; + xdrs->x_handy = 0; + xdrs->x_base = 0; +} + +/* + * Destroy a stdio xdr stream. + * Cleans up the xdr stream handle xdrs previously set up by xdrstdio_create. + */ +static void +xdrstdio_destroy(xdrs) + register XDR *xdrs; +{ + (void)fflush((FILE *)xdrs->x_private); + /* xx should we close the file ?? */ +}; + +static bool_t +xdrstdio_getlong(xdrs, lp) + XDR *xdrs; + register long *lp; +{ + + if (fread((caddr_t)lp, sizeof(long), 1, (FILE *)xdrs->x_private) != 1) + return (FALSE); +#ifndef mc68000 + *lp = ntohl(*lp); +#endif + return (TRUE); +} + +static bool_t +xdrstdio_putlong(xdrs, lp) + XDR *xdrs; + long *lp; +{ + +#ifndef mc68000 + long mycopy = htonl(*lp); + lp = &mycopy; +#endif + if (fwrite((caddr_t)lp, sizeof(long), 1, (FILE *)xdrs->x_private) != 1) + return (FALSE); + return (TRUE); +} + +static bool_t +xdrstdio_getbytes(xdrs, addr, len) + XDR *xdrs; + caddr_t addr; + u_int len; +{ + + if ((len != 0) && (fread(addr, (int)len, 1, (FILE *)xdrs->x_private) != 1)) + return (FALSE); + return (TRUE); +} + +static bool_t +xdrstdio_putbytes(xdrs, addr, len) + XDR *xdrs; + caddr_t addr; + u_int len; +{ + + if ((len != 0) && (fwrite(addr, (int)len, 1, (FILE *)xdrs->x_private) != 1)) + return (FALSE); + return (TRUE); +} + +static u_int +xdrstdio_getpos(xdrs) + XDR *xdrs; +{ + + return ((u_int) ftell((FILE *)xdrs->x_private)); +} + +static bool_t +xdrstdio_setpos(xdrs, pos) + XDR *xdrs; + u_int pos; +{ + + return ((fseek((FILE *)xdrs->x_private, (long)pos, 0) < 0) ? + FALSE : TRUE); +} + +static long * +xdrstdio_inline(xdrs, len) + XDR *xdrs; + u_int len; +{ + + /* + * Must do some work to implement this: must insure + * enough data in the underlying stdio buffer, + * that the buffer is aligned so that we can indirect through a + * long *, and stuff this pointer in xdrs->x_buf. Doing + * a fread or fwrite to a scratch buffer would defeat + * most of the gains to be had here and require storage + * management on this buffer, so we don't do this. + */ + return (NULL); +} diff -ruN glibc-1.07/sys/fcntl.h glibc-1.08.1/sys/fcntl.h --- glibc-1.07/sys/fcntl.h +++ glibc-1.08.1/sys/fcntl.h Thu Feb 17 18:07:12 1994 @@ -0,0 +1 @@ +#include diff -ruN glibc-1.07/sys/poll.h glibc-1.08.1/sys/poll.h --- glibc-1.07/sys/poll.h +++ glibc-1.08.1/sys/poll.h Mon May 16 23:21:12 1994 @@ -0,0 +1 @@ +#include diff -ruN glibc-1.07/sys/timeb.h glibc-1.08.1/sys/timeb.h --- glibc-1.07/sys/timeb.h +++ glibc-1.08.1/sys/timeb.h Mon May 2 19:49:41 1994 @@ -0,0 +1 @@ +#include