These are unidiffs between versions 1.02 and 1.03 of the GNU C library. You will need the GNU version of patch to apply these diffs. Some files are moved or deleted between version 1.02 and version 1.03. In the diffs, a moved or deleted file is represented by a patch to make that file empty. The empty files that result from applying the patches normally may cause problems, so they should be removed. You can do this with the -E option to GNU patch if you have version 2.0.12u6 or later; or by running a `find' command in the library source directory, like this: find . -size 0 -exec rm {} \; diff -Nru glibc-1.02/ChangeLog glibc-1.03/ChangeLog --- glibc-1.02/ChangeLog Fri Mar 20 21:47:17 1992 +++ glibc-1.03/ChangeLog Thu Apr 9 23:46:34 1992 @@ -1,3 +1,318 @@ +Thu Apr 9 01:49:39 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * Version 1.03. + + * grp/testgrp.c: Print members correctly. + + * stdio/test-popen.c: Pipe to cat rather than more, and then check + output file. Better error checking. + + * setjmp/tst-setjmp.c: Notice if we didn't jump the right number of + times. + + * signal/tst-signal.c, string/testcopy.c, stdio/bug[12345].c: Print + msgs that more clearly say whether we won or lost. Better error + checking. + + * sysdeps/generic/printf_fp.c: Completely rewritten from scratch. + Now uses Steele & White's "Dragon4" algorithm to do things right. + +Wed Apr 8 01:08:41 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * sysdeps/i386/__longjmp.c: Test for VAL==0 before clobbering regs. + Wire V to AX, rather than DX. Use "a" constraint on unused operand + in jmp asm, rather than global reg var, to force value into AX. + +Tue Apr 7 17:51:25 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * posix/Makefile (headers): Added tar.h. + * posix/tar.h: New file, from djm. + +Mon Apr 6 01:39:07 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * time/tzfile.c (struct ttinfo): Made `isstd' member be unsigned + char instead of 1-bit bitfield. + + * time/tzfile.c (__tzfile_default): New function. + * time/__tzset.c: Call it when no rule is given. + * time/Makefile: Install posixrules just like localtime. + * time/Makeconfig (posixrules, posixrules-file): New config vars. + + * time/time.h (struct tm): Add `tz_gmtoff', `tz_zone'. + * time/localtime.c: Set those members. + + * sysdeps/ieee754/__drem.c: XOR the signs of X and the result, + rather than setting the sign of the result to that of X. + + * sysdeps/unix/bsd/make-local_lim.c: Don't do MAXUPRC or MAXLINK if + didn't define them. + + * sysdeps/posix/__sigvec.c: Fixed braino: SA_ONSTACK should be + SA_RESTART. + + * pwd/getpw.c, pwd/putpwent.c: Use %u fmt for uid and gid (which are + unsigned). + + * time/time.h (tzname, daylight, timezone): Don't #define to __. + * time/tzfile.c, time/__tzset.c, time/localtime.c, time/strftime.c + [! HAVE_GNU_LD]: #define __ to plain for above three vars. + +Thu Apr 2 03:39:04 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * locale/Makefile (routines): Add localeconv. + + * sysdeps/i386/jmp_buf.h: Removed `__dx' elt; replaced with `__pc'. + __bp and __sp are PTRs. + * sysdeps/i386/setjmp.c: Rewritten. Use global reg vars to save regs. + Use arithmetic on address of arg to get caller's PC, BP, and SP. + * sysdeps/i386/__longjmp.c: Rewritten. Use global reg vars to + restore regs. + +Wed Apr 1 23:13:57 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * Moved sysdeps/unix/i386/{bsd,sysv} to + sysdeps/unix/{bsd,sysv}/i386, and updated Implies files. + Implied dirs come before parents, and we want unix/i386 before + unix/{sysv,bsd}. + + * io/chown.c: Fixed types in fn alias. + +Wed Apr 1 14:18:58 1992 Torbjorn Granlund (tege@mole.gnu.ai.mit.edu) + + * sysdeps/generic/memcmp.c + (memcmp_common_alignment, memcmp_not_common_alignment): + Move back do0 label to its original position, after the loop. + Add comment before do0 labels. + * sysdeps/generic/wordcopy.c (_wordcopy_fwd_aligned): Indentation. + Add comment before do0 labels. + +Wed Apr 1 02:16:19 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * sysdeps/unix/sysv/Makefile [subdir==misc]: Generate sysdep header + termio.h from sysv_termio.h. + + * sysdeps/generic/make_siglist.c: New file. + * sysdeps/generic/signame.[ch]: Symlink'd from /gd/gnu/lib. + * sysdeps/generic/Makefile: Generate siglist.c with above. + * sysdeps/generic/Dist: Add make_siglist.c, signame.[ch]. + + * sysdeps/unix/bsd/Makefile (before-compile): Define properly as a + variable. + + * sysdeps/unix/bsd/make_siglist.c: Generate #define _sys_siglist + sys_siglist #ifndef HAVE_GNU_LD. + * stdio/psignal.h, string/strsignal.h [! HAVE_GNU_LD]: + #define _sys_siglist sys_siglist. + + * sysdeps/unix/sysv/signum.h (SIGCHLD): Changed #. + (SIGUSR1, SIGUSR2, SIGPWR): Added. + (_NSIG): Updated. + + * sysdeps/unix/sysv/utmp.h: New. + + * sysdeps/unix/bsd/getlogin.c: Moved to sysdeps/unix/getlogin.c. + + * sysdeps/unix/sysv/r4/bsddir.h, sysdeps/unix/sysv/r4/readdir.c, + sysdeps/unix/sysv/r4/closedir.c, sysdeps/unix/sysv/r4/rewinddir.c, + sysdeps/unix/sysv/r4/opendir.c, sysdeps/unix/sysv/r4/sys_getdents.S, + sysdeps/unix/sysv/r4/Makefile: New. + + * sysdeps/unix/sysv/tcflow.c: New. + + * sysdeps/unix/sysv/sysv_termio.h: Add lots of bits; VMIN and VTIME + elts of c_cc. + * sysdeps/unix/sysv/__tcgetatr.c, sysdeps/unix/sysv/tcsetattr.c: Use + VMIN and VTIME elts from sysv termio struct. + + * sysdeps/unix/sysv/__gethstnm.c: New. + + * sysdeps/unix/sysv/local_lim.h (NGROUPS_MAX): Define as 0. + + * sysdeps/unix/sysv/fcntlbits.h (struct __flock): Changed l_pid to + short; added l_sysid. + + * sysdeps/unix/sysv/__sigact.c: New. + + * sysdeps/unix/sysv/r4/__access.S: New; just #include bsd/__access.S. + + * sysdeps/unix/sysv/Makefile: Fixed typo: sysdep-routines => + sysdep_routines. + + * sysdeps/unix/i386/sysv/__sigret.S, + sysdeps/unix/i386/sysv/signal.S: New. + + * signal/Makefile (routines): Added sigret, __sigret. + * signal/sigret.c: New; fn alias to __sigreturn. + * sysdeps/stub/__sigret.c: New. + + * sysdeps/unix/i386/sysdep.h (PSEUDO): Use hard-coded numbers for + lcalls insn--GAS bug. + + * sysdeps/unix/bsd/readdir.c (D_NAMLEN): New macro; define if not + already defined, to return length of a direct elt. + + * sysdeps/stub/__getgrps.c: #include ; if NGROUPS_MAX is + defined as 0, always return 0, and no stub warning. + + * sysdeps/posix/system.c: Don't fail if sigprocmask fails with ENOSYS. + + * sysdeps/posix/sysd-stdio.c, sysdeps/stub/sysd-stdio.c: Doc fix. + + * sysdeps/posix/__gettod.c: Use CONST where appropriate and not + where not. + + * sysdeps/i386/memchr.c, sysdeps/i386/strlen.c: Changed `repnz' to + `repne'. + + * stdio/fgets.c: Notice returned char from __fillbf in length calc. + + * misc/sys/ioctl.h: Always define `struct sgttyb'. + + * stdlib/alloca.h: #undef __alloca, too. + Always #define alloca == __alloca. + + * signal/signal.h (__kill): Fixed type in decl. + * posix/unistd.h (setgid): Fixed type in decl. + * posix/setpgid.c, posix/setgid.c, signal/kill.c, posix/fork.c, + posix/vfork.c, posix/getpid.c, posix/getppid.c, posix/setsid.c: + Fixed DEFUNs in fn aliases. + * pwd/getpw.c: Fixed type in defn. + +Mon Mar 30 17:06:54 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * sysdeps/generic/printf_fp.c: In %f, decrement PREC for each + leading zero in the fractional part. + + * sysdeps/ieee754/ieee754.h: Made all elts unsigned. + * sysdeps/ieee754/__drem.c: Return NAN if Y is zero. + * sysdeps/ieee754/ldexp.c: Rewritten. + * sysdeps/ieee754/__logb.c: Handle denormalized numbers. + + * posix/sys/wait.h: #include + + * sysdeps/ieee754/fl.h: Fixed NAN and HUGE_VAL bit patterns; added + code for little endian. + + * sysdeps/generic/frexp.c: Add one to exponent to give the result a + digit before the point. Use negative exponent rather than division. + + * math/__finite.c: Return zero for NaN. + * math/math.h: Doc fix for same. + + * stdio/__getdelim.c: Correctly notice when the buffer is full. + + * sysdeps/unix/bsd/opendir.c: Pass arg to fcntl F_SETFD by value, + not by reference. + + * time/__tzset.c: Correct default rule: M4.1.0,M10.5.0. + + * time/__tzset.c: Move ptr past Mfoobar syntax after parsing it. + + * time/__tzset.c: Properly parse the DST offset (or its absence). + + * sysdeps/unix/make_errlist.c: Write an #ifdef HAVE_GNU_LD, rather + than testing it when compiling make_errlist. + + * time/tzfile.c (__tzfile_read): Convert transitions to host byte + order. + + * Makeconfig (localtime-file): New config var. + * time/Makefile (tzfile.o, zic.o): Use it for TZDEFAULT. + + * stdio/Makefile (tests): Added tstgetline. + * stdio/tstgetline.c: New; test for getline. + + * Makeconfig (sysincludedir): Define and document. + * sysdeps/unix/snarf-ioctls, sysdeps/unix/Makefile: Use + ${sysincludedirs} in place of hard-coded /usr/include. + +Fri Mar 27 13:33:37 1992 Roland McGrath (roland@albert.gnu.ai.mit.edu) + + * string/Makefile (headers): Added endian.h. + + * sysdeps/ieee754/__drem.c: Fixed typo which made X and Y be the + same location. + + * sysdeps/generic/__lstat.c: #include + + * stdio/internals.c (flushbuf): Increment target as well as offset + when we write out the single char. + + * grp/Makefile (tests): Add testgrp (formerly bug1). + +Thu Mar 26 14:59:45 1992 Roland McGrath (roland@albert.gnu.ai.mit.edu) + + * stdio/fread.c: Don't read directly when we need to seek first. + +Wed Mar 25 02:34:49 1992 Roland McGrath (roland@albert.gnu.ai.mit.edu) + + * sysdeps/unix/bsd/alarm.c: There are 1000000 usecs in a sec. + + * sysdeps/unix/bsd/sun/ptrace.c: Removed. + + * stdio/fgets.c: For unbuffered stream, don't return EOF after + reading some data. + Added missing parens. + +Tue Mar 24 18:31:07 1992 Torbjorn Granlund (tege@hal) + + * sysdeps/i386/memset.c: Move code that puts C in all four nibbles of + X inside `if' statement. Include sysdeps/i386/memset.c (not bzero). + * sysdeps/i386/memchr.c: Rewrite to be faster. Include + sysdeps/generic/memchr.c (not bzero). + +Tue Mar 24 01:21:32 1992 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * io/Makefile (routines): Add getdirname. + * posix/unistd.h [__USE_GNU]: Declare getdirname. + * io/getdirname.c: New. + + * Makeconfig (stddef.h): Define and document. + * Makefile (headers): Use $(stddef.h) for stddef.h. + +Mon Mar 23 18:04:56 1992 Roland McGrath (roland@wookumz.gnu.ai.mit.edu) + + * sysdeps/posix/mktemp.c: Do PID % 100000 for 5 digits. + + * time/Makefile (tzfiles): Remove pacificnew; it won't compile. + (distribute): Put it here instead. + + * stdio/printf-prs.c [HAVE_LONGLONG]: Fixed missed var name change + from code snarf. + + * stdio/fgets.c: Return NULL when we get EOF. + + * posix/execvp.c, sysdeps/posix/putenv.c [! HAVE_GNU_LD]: Define + __environ as environ. + + * sysdeps/unix/bsd/Makefile, sysdeps/unix/Makefile: In rules to + compile generator programs, cd into $(objdir) first to avoid + braindead cc clobbering foo.o in cwdir. + + * sysdeps/m68k/setjmp.c: Deref fpregs array in asm. + + * time/Makefile (zones-%): Fixed generated rules. + + * math/Makefile (libm.a): Use r cmd to ar. + + * time/Makefile (zones-%): In echo commands, put \\\\n outside of + quotes instead of \\n inside single quotes. SysV echo is braindead. + + * io/fchown.c, io/fchmod.c, misc/bsd-compat.c: Fixed DEFUNs in fn + aliases. + + * time/Makefile (echo-zonenames): New target; tell user what all + timezones defined in all zone files are. + * Makeconfig (localtime): Comment about using above. + +Sun Mar 22 18:34:02 1992 Roland McGrath (roland@albert.gnu.ai.mit.edu) + + * time/australasia (NZ): Updated rules. + +Sat Mar 21 01:00:49 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * stdio/printf-prs.c [__GNUC__]: Define HAVE_LONGLONG. + Fri Mar 20 00:35:36 1992 Roland McGrath (roland@geech.gnu.ai.mit.edu) * Version 1.02. @@ -113,10 +428,6 @@ Sun Mar 15 00:01:05 1992 Roland McGrath (roland@albert.gnu.ai.mit.edu) - * sysdeps/unix/bsd/Makefile, sysdeps/unix/Makefile: In rules to - compile generator programs, cd into $(objdir) first to avoid - braindead cc clobbering foo.o in cwdir. - * Makerules (sysdep-Makefile): Do if ... else true to avoid bogus nonzero status. @@ -234,8 +545,6 @@ * Rules: Null out `objects' at end to shrink environment some. (+objs): Define with := from $(objects). (clean): Use that instead of $(objects). - - * sysdeps/i386/strlen.c: Use `repnz' instead of `repne'. * sysdeps/i386/setjmp.c: Doubled % where it wanted to be literal. diff -Nru glibc-1.02/INSTALL glibc-1.03/INSTALL --- glibc-1.02/INSTALL Fri Mar 20 19:47:33 1992 +++ glibc-1.03/INSTALL Thu Apr 9 02:11:21 1992 @@ -459,6 +459,8 @@ any improvements or extensions that they make and grant Carnegie Mellon the rights to redistribute these changes. + * The `tar.h' header file was written by David J. MacKenzie. +  Tag Table: diff -Nru glibc-1.02/Makeconfig glibc-1.03/Makeconfig --- glibc-1.02/Makeconfig Thu Mar 19 23:35:33 1992 +++ glibc-1.03/Makeconfig Mon Apr 6 03:54:22 1992 @@ -31,10 +31,6 @@ .. := ../ endif -# -# These are the configuration variables. -# - # You can put variables that are specific to a configuration in the file # Makeconfig in the object directory for that configuration. Variables # that do not vary between different configurations at your site can be @@ -63,6 +59,10 @@ include $(objdir)/Makeconfig endif endif + +# +# These are the configuration variables. +# # Common prefix for all installation directories. @@ -87,6 +87,12 @@ #trad-incldir = $(prefix)/include endif +# Define if the library should install its own . +# Do this unless you are using version 2.2 or later of GCC. +ifndef stddef.h +stddef.h = stddef.h +endif + # Where to install machine-independent data files. # These are the timezone database, and eventually the locale database. ifndef datadir @@ -98,11 +104,44 @@ bindir = $(prefix)/bin endif -# What timezone should be the installed default. -# This can be changed with `zic -l TIMEZONE' at any time. +# 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. +ifndef localtime localtime = Factory +endif + +# Where to install the "localtime" timezone file; this is file +# whose contents $(localtime) specifies. If this is a relative +# pathname, it is relative to $(datadir)/zoneinfo. +ifndef localtime-file +localtime-file = localtime +endif + +# What timezone's DST rules should be used when a POSIX-style TZ +# environment variable doesn't specify any rules. For 1003.1 compliance +# 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. +ifndef posixrules +posixrules = US/Eastern +endif + +# Where to install the "posixrules" timezone file; this is file +# whose contents $(posixrules) specifies. If this is a relative +# pathname, it is relative to $(datadir)/zoneinfo. +ifndef posixrules-file +posixrules-file = posixrules +endif +# Directory where your system's native header files live. +# This is used on Unix systems to generate some GNU libc header files. +ifndef sysincludedir +sysincludedir = /usr/include +endif + + # Commands to install files. ifndef INSTALL_DATA INSTALL_DATA = $(INSTALL) @@ -149,8 +188,7 @@ # Extra flags to pass to GCC. +gccwarn := -Wall -Wwrite-strings -Wpointer-arith -Wstrict-prototypes -+gccopt := -O -fstrength-reduce -fcombine-regs -+gccflags = $(+gccwarn) $(+gccopt) ++gccopt := -fstrength-reduce -fcombine-regs # This is the program that generates makefile # dependencies from C source files. @@ -195,7 +233,10 @@ # If using gcc, add flags that only it will grok. ifneq "$(findstring gcc,$(CC))" "" -+cflags := $(+cflags) $(+gccflags) ++cflags := $(+cflags) $(+gccwarn) +ifneq "$(filter -O,$(+cflags))" "" ++cflags := $(+cflags) $(+gccopt) +endif endif # gcc # Don't duplicate options if we inherited variables from the parent. diff -Nru glibc-1.02/Makefile glibc-1.03/Makefile --- glibc-1.02/Makefile Thu Mar 19 20:35:50 1992 +++ glibc-1.03/Makefile Tue Mar 24 00:22:00 1992 @@ -57,7 +57,7 @@ tests subdir_lint.out subdir_TAGS subdir_headers \ subdir_echo-headers subdir_echo-distinfo subdir_install -headers := features.h errno.h errnos.h limits.h stddef.h \ +headers := features.h errno.h errnos.h limits.h $(stddef.h) \ float.h fl.h headers: subdir_headers diff -Nru glibc-1.02/README glibc-1.03/README --- glibc-1.02/README Fri Mar 20 19:47:30 1992 +++ glibc-1.03/README Thu Apr 9 02:11:17 1992 @@ -1,4 +1,4 @@ -This directory contains the version 1.02 test release of the GNU C Library. +This directory contains the version 1.03 test release of the GNU C Library. Some bugs surely remain. As of this release, the GNU C library has been ported to only three machines: diff -Nru glibc-1.02/grp/Makefile glibc-1.03/grp/Makefile --- glibc-1.02/grp/Makefile Thu Jul 18 06:44:51 1991 +++ glibc-1.03/grp/Makefile Fri Mar 27 12:33:29 1992 @@ -1,4 +1,4 @@ -# Copyright (C) 1991 Free Software Foundation, Inc. +# Copyright (C) 1991, 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 @@ -23,5 +23,7 @@ routines := grpopen grpread fgetgrent getgrent getgrgid getgrnam \ initgroups setgroups + +tests := testgrp include ../Rules diff -Nru glibc-1.02/grp/testgrp.c glibc-1.03/grp/testgrp.c --- glibc-1.02/grp/testgrp.c +++ glibc-1.03/grp/testgrp.c Thu Apr 9 22:26:34 1992 @@ -0,0 +1,40 @@ +#include +#include +#include +#include +#include +#include +#include + +int +DEFUN_VOID(main) +{ + uid_t me; + struct passwd *my_passwd; + struct group *my_group; + char **members; + + me = getuid (); + my_passwd = getpwuid (me); + + printf ("My login name is %s.\n", my_passwd->pw_name); + printf ("My uid is %d.\n", (int)(my_passwd->pw_uid)); + printf ("My home directory is %s.\n", my_passwd->pw_dir); + printf ("My default shell is %s.\n", my_passwd->pw_shell); + + my_group = getgrgid (my_passwd->pw_gid); + if (!my_group) { + printf ("Couldn't find out about group %d.\n", (int)(my_passwd->pw_gid)); + exit (EXIT_FAILURE); + } + + printf ("My default group is %s (%d).\n", + my_group->gr_name, (int)(my_passwd->pw_gid)); + printf ("The members of this group are:\n"); + for (members = my_group->gr_mem; *members != NULL; ++members) + printf (" %s\n", *members); + exit (EXIT_SUCCESS); +} + + + diff -Nru glibc-1.02/hurd/Makefile glibc-1.03/hurd/Makefile --- glibc-1.02/hurd/Makefile Sat Feb 8 03:57:14 1992 +++ glibc-1.03/hurd/Makefile Thu Apr 9 21:43:34 1992 @@ -18,23 +18,55 @@ subdir := hurd -# XXX interfaces headers want to be in hurd/ -headers = hurd.h $(interface-headers) +interface-header-prefix = hurd/ +headers = hurd.h # $(interface-headers) -user-interfaces := process fs io -server-interfaces := +ifneq (,) +user-interfaces := auth process \ + exec core interrupt \ + fs io socket term +server-interfaces := misc +endif +routines = __pid2task __task2pid pid2task task2pid \ + __setauth setauth hurdports \ + chcore fchcore fchroot \ + hurdauth hurdid hurdpath hurdpid hurdsig hurdsock \ + dtable __getdport getdport openport setdtablesize \ + sigportdemux _hurd_start_sigthread \ + getuids getumask \ + _hurd_dead_recv \ + fopenport __fopenport \ + $(interface-routines) +aux := hurdsyms + +all: + + +# This rule needs to come before the implicit rules in Machrules. +__%.c: intr_rpc.awk %_rpc.c + gawk -v call=__$* -v rpc=__$*_rpc -f $^ > $@-new + mv $@-new $@ +# __%_rpc.c is made with mig by Machrules. +%_rpc.c: __%_rpc.c + sed s/MACH_MSG_OPTION_NONE/MACH_SEND_INTERRUPT/ $< > $@ + include ../mach/Machrules -routines := __pid2task __task2pid pid2task task2pid \ - __setauth setauth hurdports \ - chcore fchcore fchroot \ - hurdauth hurdid hurdpath hurdpid hurdsig hurdsock \ - dtable __getdport getdport openport setdtablesize \ - sigportdemux _hurd_start_sigthread \ - getuids getumask \ - _hurd_dead_recv \ - $(interface-routines) -aux := hurdsyms +ifdef user-interfaces +include hurdintr +endif +hurdintr: hurdintr.awk $(user-interfaces:%=%.defs) + awk -f $^ varname=intr-calls > $@-new + mv $@-new $@ + +# Make the INTR user stubs be defined as CALL_rpc. +migdefines := $(migdefines) $(foreach call,$(intr-calls),-D$(call)=$(call)_rpc) + +interface-routines := $(filter-out %_rpc,$(interface-routines)) \ + $(intr-calls:%=__% %) +dont_distribute = $(interface-routines:%=%.c) $(interface-headers) + +distribute := intr_rpc.awk hurdintr.awk include ../Rules diff -Nru glibc-1.02/hurd/__fopenport.c glibc-1.03/hurd/__fopenport.c --- glibc-1.02/hurd/__fopenport.c +++ glibc-1.03/hurd/__fopenport.c Sat Mar 21 17:36:13 1992 @@ -0,0 +1,31 @@ +/* Copyright (C) 1992 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include + + +/* Open a stream on PORT. MODE is as for fopen. */ + +FILE * +__fopenport (mach_port_t port, const char *mode) +{ + /* The default io functions in sysd-stdio.c use Hurd io ports as cookies. */ + return __fopencookie ((void *) port, mode, __default_io_functions); +} diff -Nru glibc-1.02/hurd/__getdport.c glibc-1.03/hurd/__getdport.c --- glibc-1.02/hurd/__getdport.c Fri Mar 20 22:27:32 1992 +++ glibc-1.03/hurd/__getdport.c Sun Mar 22 00:35:03 1992 @@ -18,30 +18,17 @@ #include -struct _hurd_dtable _hurd_dtable; +const struct + { + size_t n; + file_t (*getdport) (int fd); + } _hurd_getdport_fn; file_t __getdport (int fd) { - if (_hurd_dtable.d != NULL) + if (_hurd_init_dtable != NULL) { - /* We have a real descriptor table. */ - file_t dport; - int err = _HURD_DPORT_USE (fd, - __mach_port_mod_refs (__mach_task_self (), - (dport = port), - MACH_PORT_RIGHT_SEND, - 1)); - if (err) - { - errno = err; - return MACH_PORT_NULL; - } - else - return dport; - } - 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 || @@ -57,4 +44,6 @@ return _hurd_init_dtable[fd]; } } + else + return (*_hurd_getdport_fn.getdport) (fd); } diff -Nru glibc-1.02/hurd/__pid2task.c glibc-1.03/hurd/__pid2task.c --- glibc-1.02/hurd/__pid2task.c Sat Feb 1 02:05:34 1992 +++ glibc-1.03/hurd/__pid2task.c Fri Mar 20 23:13:15 1992 @@ -23,13 +23,14 @@ { error_t err; task_t task; - __mutex_lock (&_hurd_lock); - err = __proc_pid2task (_hurd_proc, pid, &task); - __mutex_unlock (&_hurd_lock); + + err = _HURD_PORT_USE (&_hurd_proc, + __proc_pid2task (port, pid, &task)); if (err) { errno = err; return MACH_PORT_NULL; } - return task; + else + return task; } diff -Nru glibc-1.02/hurd/__setauth.c glibc-1.03/hurd/__setauth.c --- glibc-1.02/hurd/__setauth.c Sat Feb 1 02:05:39 1992 +++ glibc-1.03/hurd/__setauth.c Sun Mar 22 00:19:49 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -18,23 +18,14 @@ #include -static inline void -reauth_io (io_t *server) -{ - if (*server != MACH_PORT_NULL && - __io_reauthenticate (*server) == POSIX_SUCCESS) - { - mach_port_t new; - if (__auth_user_authenticate (_hurd_auth, - *server, - &new) == POSIX_SUCCESS) - { - __mach_port_deallocate (__mach_task_self (), - *server); - *server = new; - } - } -} + + +/* Things in the library which want to be run when the auth port changes. */ +const struct + { + size_t n; + void (*fn[0]) (); + } _hurd_reauth_hook; /* Set the auth port to NEW, and reauthenticate @@ -46,7 +37,10 @@ auth_t old; int d; mach_port_t ignore; + void (**fn) (void); + /* Give the new send right a user reference. + This is a good way to check that it is valid. */ if (__mach_port_mod_refs (__mach_task_self (), new, MACH_PORT_RIGHT_SEND, 1)) { @@ -54,25 +48,41 @@ return -1; } + /* Install the new port in the _hurd_auth cell. */ __mutex_lock (&_hurd_idlock); - __mutex_lock (&_hurd_dtable_lock); - __mutex_lock (&_hurd_lock); - old = _hurd_auth; - _hurd_auth = new; + _hurd_port_set (&_hurd_auth, new); _hurd_id_valid = 0; __mutex_unlock (&_hurd_idlock); - __mach_port_deallocate (__mach_task_self (), old); - __proc_reauthenticate (_hurd_proc); - __auth_user_authenticate (_hurd_auth, _hurd_proc, &ignore); - if (ignore != MACH_PORT_NULL) + + /* Reauthenticate with the proc server. */ + if (!_HURD_PORT_USE (&_hurd_proc, + __proc_reauthenticate (port) || + __auth_user_authenticate (new, port, &ignore)) + && ignore != MACH_PORT_NULL) __mach_port_deallocate (__mach_task_self (), ignore); - if (_hurd_dtable.d == NULL) + + /* Reauthenticate the file descriptor table. */ + + if (_hurd_init_dtable != NULL) + /* We just have the simple table we got at startup. */ for (d = 0; d < _hurd_init_dtablesize; ++d) - reauth_io (&_hurd_init_dtable[d]); - else - for (d = 0; d < _hurd_dtable.size; ++d) - reauth_io (&_hurd_dtable.d[d]); - __mutex_unlock (&_hurd_dtable_lock); + if (_hurd_init_dtable[d] != MACH_PORT_NULL) + { + mach_port_t new; + if (! __io_reauthenticate (_hurd_init_dtable[d]) && + ! _HURD_PORT_USE (&_hurd_auth, + __auth_user_authenticate (_hurd_init_dtable[d], + &new))) + { + __mach_port_deallocate (__mach_task_self (), + _hurd_init_dtable[d]); + _hurd_init_dtable[d] = new; + } + } + + /* Run things which want to do reauthorization stuff. */ + for (fn = _hurd_reauth_hook.fn; *fn != NULL; ++fn) + (**fn) (); return 0; } diff -Nru glibc-1.02/hurd/__task2pid.c glibc-1.03/hurd/__task2pid.c --- glibc-1.02/hurd/__task2pid.c Sat Feb 1 02:05:28 1992 +++ glibc-1.03/hurd/__task2pid.c Fri Mar 20 23:11:40 1992 @@ -23,13 +23,9 @@ { error_t err; pid_t pid; - __mutex_lock (&_hurd_lock); - err = __proc_task2pid (_hurd_proc, task, &pid); - __mutex_unlock (&_hurd_lock); + err = _HURD_PORT_USE (&_hurd_proc, + __proc_task2pid (proc, task, &pid)); if (err) - { - errno = err; - return (pid_t) -1 - } + return __hurd_fail (err); return pid; } diff -Nru glibc-1.02/hurd/chcore.c glibc-1.03/hurd/chcore.c --- glibc-1.02/hurd/chcore.c Wed Oct 30 06:53:23 1991 +++ glibc-1.03/hurd/chcore.c Fri Mar 20 23:13:07 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -29,15 +29,11 @@ error_t err; file_t old, ccdir; - ccdir = __hurd_path_lookup (path, FS_LOOKUP_EXECUTE, 0); + ccdir = __path_lookup (path, FS_LOOKUP_EXECUTE, 0); if (ccdir == MACH_PORT_NULL) return -1; - __mutex_lock (&_hurd_lock); - old = _hurd_ccdir; - _hurd_ccdir = ccdir; - __mutex_unlock (&_hurd_lock); - __mach_port_deallocate (__mach_task_self (), old); + _hurd_port_set (&_hurd_ccdir, ccdir); return 0; } diff -Nru glibc-1.02/hurd/dtable.c glibc-1.03/hurd/dtable.c --- glibc-1.02/hurd/dtable.c Sat Feb 1 02:20:03 1992 +++ glibc-1.03/hurd/dtable.c Sun Mar 22 00:35:01 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -16,11 +16,22 @@ not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include #include #include #include #include + +struct _hurd_dtable _hurd_dtable; +struct mutex _hurd_dtable_lock; +int *_hurd_dtable_user_dealloc; + +const struct _hurd_dtable_resizes _hurd_dtable_resizes; + + +/* Initialize the file descriptor table at startup. */ + static void init_dtable (void) { @@ -28,24 +39,61 @@ __mutex_init (&_hurd_dtable_lock); + _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 OPEN_MAX descriptors. */ _hurd_dtable.size = (_hurd_init_dtablesize + OPEN_MAX - 1) / OPEN_MAX * OPEN_MAX; - _hurd_dtable.d = malloc (_hurd_init_dtablesize * sizeof (*_hurd_dtable.d)); + _hurd_dtable.d = malloc (_hurd_dtable.size * sizeof (*_hurd_dtable.d)); if (_hurd_dtable.d == NULL) - __libc_fatal ("hurd: Can't allocate descriptor table\n"); + __libc_fatal ("hurd: Can't allocate file descriptor table\n"); for (i = 0; i < _hurd_init_dtablesize; ++i) { - _hurd_dtable.d[i].server = _hurd_init_dtable[i]; - _hurd_dtable.d[i].isctty = -1; - _hurd_dtable.d[i].flags = 0; + struct _hurd_fd *const d = &_hurd_dtable.d[i]; + io_statbuf_t stb; + io_t ctty; + + _hurd_port_init (&d->port, _hurd_init_dtable[i]); + d->flags = 0; + + if (_hurd_ctty_fstype != 0 && + /* We have a controlling tty. Is this it? */ + ! __io_stat (d->port.port, &stb) && + stb.stb_fstype == _hurd_ctty_fstype && + stb.stb_fsid == _hurd_ctty_fsid && + stb.stb_fileid == _hurd_ctty_fileid && + /* This is a descriptor to our controlling tty. */ + ! __term_become_ctty (d->port.port, _hurd_pid, _hurd_pgrp, + _hurd_sigport, &ctty)) + { + /* Operations on CTTY return EBACKGROUND when we are not a + foreground user of the tty. */ + d->port.port = ctty; + ctty = _hurd_init_dtable[i]; + } + else + /* No ctty magic happening here. */ + ctty = MACH_PORT_NULL; + + _hurd_port_init (&d->ctty, ctty); } + + /* Initialize the remaining empty slots in the table. */ for (; i < _hurd_dtable.size; ++i) - _hurd_dtable.d[i].server = MACH_PORT_NULL; + { + _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; + } + /* Clear out the initial descriptor table. + Everything must use _hurd_dtable now. */ + __vm_deallocate (__mach_task_self (), + _hurd_init_dtable, + _hurd_init_dtablesize * sizeof (_hurd_init_dtable[0])); _hurd_init_dtable = NULL; _hurd_init_dtablesize = 0; } @@ -52,24 +100,107 @@ text_set_element (__libc_subinit, init_dtable); -/* Called on fork to install the dtable in NEWTASK. */ +/* Called by `getdport' to do its work. */ + +static file_t +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)); + if (err) + { + errno = err; + return MACH_PORT_NULL; + } + else + return dport; +} + +text_set_element (_hurd_getdport_fn, get_dtable_port); + +/* Called on fork to install the dtable in NEWTASK. + The dtable lock is held. */ static error_t fork_dtable (task_t newtask) { + error_t err; int i; - __mutex_lock (&_hurd_dtable_lock); - for (i = 0; i < _hurd_dtable.size; ++i) - if (err = __mach_port_insert_right (newtask, _hurd_dtable.d[i].server, - _hurd_dtable.d[i].server, - MACH_PORT_COPY_SEND)) - { - /* XXX for each fd with a cntlmap, reauth and re-map_cntl. */ - __mutex_unlock (&_hurd_dtable.lock); - return 1; - } + + err = 0; + + for (i = 0; !err && i < _hurd_dtable.size; ++i) + { + int dealloc, dealloc_ctty; + io_t port = _HURD_PORT_USE (&_hurd_dtable.d[i].port, &dealloc); + io_t ctty = _HURD_PORT_USE (&_hurd_dtable.d[i].ctty, &dealloc_ctty); + + if (port != MACH_PORT_NULL) + err = __mach_port_insert_right (newtask, port, port, + MACH_PORT_COPY_SEND); + if (!err && ctty != MACH_PORT_NULL) + err = __mach_port_insert_right (newtask, ctty, ctty, + MACH_PORT_COPY_SEND); + + _hurd_port_free (port, &dealloc); + _hurd_port_free (ctty, &dealloc_ctty); + + /* XXX for each fd with a cntlmap, reauth and re-map_cntl. */ + } __mutex_unlock (&_hurd_dtable_lock); - return 0; + return err; } text_set_element (_hurd_fork_hook, fork_dtable); +text_set_element (_hurd_fork_locks, _hurd_dtable_lock); + +/* Called to reauthenticate the dtable when the auth port changes. */ + +static void +reauth_dtable (void) +{ + int d; + + __mutex_lock (&_hurd_dtable_lock); + + for (d = 0; d < _hurd_dtable.size; ++d) + { + struct _hurd_fd *const d = &hurd_dtable.d[d]; + mach_port_t new, newctty; + + /* Take the descriptor cell's lock. */ + __spin_lock (&cell->port.lock); + + /* Reauthenticate the descriptor's port. */ + if (cell->port.port != MACH_PORT_NULL && + ! __io_reauthenticate (cell->port.port) && + ! _HURD_PORT_USE (&_hurd_auth, + __auth_user_authenticate (port, + cell->port.port, &new))) + { + /* Replace the port in the descriptor cell + with the newly reauthenticated port. */ + + if (cell->ctty.port != MACH_PORT_NULL && + ! __io_reauthenticate (cell->ctty.port) && + ! _HURD_PORT_USE (&_hurd_auth, + __auth_user_authenticate (port, + cell->ctty.port, + &newctty))) + _hurd_port_set (&cell->ctty, newctty); + + _hurd_port_locked_set (&cell->port, new); + } + else + /* Lost. Leave this descriptor cell alone. */ + __spin_unlock (&cell->port.lock); + } + + __mutex_unlock (&_hurd_dtable_lock); +} + +text_set_element (_hurd_reauth_hook, reauth_dtable); diff -Nru glibc-1.02/hurd/fchcore.c glibc-1.03/hurd/fchcore.c --- glibc-1.02/hurd/fchcore.c Mon Nov 11 22:20:40 1991 +++ glibc-1.03/hurd/fchcore.c Fri Mar 20 23:35:38 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -22,28 +22,20 @@ #include #include -/* Change the current directory core to FD. */ +/* Change the current core directory to FD. */ int DEFUN(fchcore, (fd), int fd) { - file_t old; + error_t err; + file_t ccdir; - __mutex_lock (&_hurd_dtable.lock); - if (fd < 0 || fd >= _hurd_dtable.size || - _hurd_dtable.d[fd].server == MACH_PORT_NULL) - { - __mutex_unlock (&_hurd_dtable.lock); - errno = EBADF; - return -1; - } - - __mach_port_mod_refs (__mach_task_self (), _hurd_dtable.d[fd].server, - MACH_PORT_RIGHT_SEND, 1); - __mutex_lock (&_hurd_lock); - old = _hurd_ccdir; - _hurd_ccdir = _hurd_dtable.d[fd].server; - __mutex_unlock (&_hurd_lock); - __mutex_unlock (&_hurd_dtable.lock); - __mach_port_deallocate (__mach_task_self (), old); + if (err = _HURD_DPORT_USE (fd, + __mach_port_mod_refs (__mach_task_self (), + (ccdir = port), + MACH_PORT_RIGHT_SEND, 1))) + return err; + + _hurd_port_set (&_hurd_ccdir, ccdir); + return 0; } diff -Nru glibc-1.02/hurd/fchroot.c glibc-1.03/hurd/fchroot.c --- glibc-1.02/hurd/fchroot.c Sat Feb 1 02:14:08 1992 +++ glibc-1.03/hurd/fchroot.c Fri Mar 20 23:57:32 1992 @@ -26,17 +26,16 @@ int DEFUN(fchroot, (fd), int fd) { - file_t old; - io_t port; + error_t err; + file_t crdir; - port = __getdport (fd); - if (port == MACH_PORT_NULL) - return -1; + if (err = _HURD_DPORT_USE (fd, + __mach_port_mod_refs (__mach_task_self (), + (crdir = port), + MACH_PORT_RIGHT_SEND, 1))) + return err; - __mutex_lock (&_hurd_lock); - old = _hurd_crdir; - _hurd_crdir = port; - __mutex_unlock (&_hurd_lock); - __mach_port_deallocate (__mach_task_self (), old); + _hurd_port_set (&_hurd_crdir, crdir); + return 0; } diff -Nru glibc-1.02/hurd/fopenport.c glibc-1.03/hurd/fopenport.c --- glibc-1.02/hurd/fopenport.c +++ glibc-1.03/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 -Nru glibc-1.02/hurd/getdport.c glibc-1.03/hurd/getdport.c --- glibc-1.02/hurd/getdport.c Wed Oct 30 10:07:08 1991 +++ glibc-1.03/hurd/getdport.c Sat Mar 21 00:15:40 1992 @@ -1,3 +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 (__getdport, getdport); diff -Nru glibc-1.02/hurd/getuids.c glibc-1.03/hurd/getuids.c --- glibc-1.02/hurd/getuids.c Sat Feb 1 02:19:58 1992 +++ glibc-1.03/hurd/getuids.c Fri Mar 20 23:58:57 1992 @@ -27,7 +27,8 @@ __mutex_lock (&_hurd_idlock); if (!_hurd_id_valid) { - error_t err = __auth_getids (_hurd_auth, &_hurd_id); + error_t err = _HURD_PORT_USE (&_hurd_auth, + __auth_getids (port, &_hurd_id)); if (err) { __mutex_unlock (&_hurd_idlock); diff -Nru glibc-1.02/hurd/hurd.h glibc-1.03/hurd/hurd.h --- glibc-1.02/hurd/hurd.h Fri Mar 20 19:09:01 1992 +++ glibc-1.03/hurd/hurd.h Thu Apr 2 01:20:19 1992 @@ -109,7 +109,6 @@ _hurd_port_locked_set (struct _hurd_port *port, mach_port_t newport) { mach_port_t old; - __spin_lock (&port->lock); if (port->user_dealloc == NULL) old = port->port; else @@ -134,7 +133,7 @@ /* Basic ports and info, initialized by startup. */ extern struct _hurd_port _hurd_proc, _hurd_auth; extern struct _hurd_port _hurd_ccdir, _hurd_cwdir, _hurd_crdir; -extern mode_t _hurd_umask; +extern volatile mode_t _hurd_umask; extern struct mutex _hurd_ctty_lock; extern int _hurd_ctty_fstype; @@ -153,38 +152,89 @@ extern size_t _hurd_init_dtablesize; /* File descriptor table. */ +struct _hurd_fd + { + struct _hurd_port port; + int flags; /* fcntl flags; locked by port.lock. */ + + /* Normal port to the ctty. Also locked by port.lock. + (The ctty.lock is only ever used when the port.lock is held.) */ + struct _hurd_port ctty; + }; + struct _hurd_dtable { int size; /* Number of elts in `d' array. */ - /* Individual descriptors are not locked. It is up to the user to - synchronize descriptor operations on a single descriptor. */ - struct - { - struct _hurd_port port; - /* Locked by port.lock. */ - int isctty; /* Is a port to the controlling tty. */ - int flags; /* fcntl flags. */ - } *d; + + /* 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; }; extern struct _hurd_dtable _hurd_dtable; + extern struct mutex _hurd_dtable_lock; /* Locks _hurd_dtable. */ -/* Allocate a new file descriptor and set it to PORT. */ +/* 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. + setdtablesize.c gives it one element: free. + If setdtablesize 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); +} + + +/* Allocate a new file descriptor and set it to PORT. + If the table is full, deallocate PORT, set errno, and return -1. */ static inline int -_hurd_dalloc (io_t port, int flags) +_hurd_dalloc (io_t port, io_t ctty, int flags) { int i; __mutex_lock (&hurd_dtable_lock); for (i = 0; i < _hurd_dtable.size; ++i) { - __typeof (&_hurd_dtable.d[i]) d = &_hurd_dtable.d[i]; + struct _hurd_fd *d = &_hurd_dtable.d[i]; __spin_lock (&d->port.lock); if (d->port.port == MACH_PORT_NULL) { - d->isctty = -1; - d->flags = flags; d->port.port = port; d->port.user_dealloc = NULL; + d->ctty.port = ctty; + d->ctty.user_dealloc = NULL; + d->flags = flags; __spin_unlock (&d->port.lock); __mutex_unlock (&hurd_dtable_lock); return i; @@ -193,43 +243,73 @@ } __mutex_unlock (&hurd_dtable_lock); __mach_port_deallocate (__mach_task_self (), port); + __mach_port_deallocate (__mach_task_self (), ctty); errno = EMFILE; return -1; } -/* Returns the port cell for FD, locked. */ -static inline struct _hurd_port * -_hurd_dport (int fd) +/* Returns the descriptor cell for FD in DTABLE, locked. */ +static inline struct _hurd_fd * +_hurd_dtable_fd (int fd, struct _hurd_dtable dtable) { - struct _hurd_port *port; - __mutex_lock (&_hurd_dtable.lock); - if (fd < 0 || fd >= _hurd_dtable.size || - _hurd_dtable.d[fd].server == MACH_PORT_NULL) - { - errno = EBADF; - port = NULL; - } + if (fd < 0 || fd >= dtable.size) + return NULL; else { - port = &_hurd_dtable.d[fd].port; - __spin_lock (&port->lock); + 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; } - __mutex_unlock (&_hurd_dtable.lock); - return port; +} + +struct _hurd_fd_user + { + struct _hurd_dtable dtable; + struct _hurd_fd *d; + }; + +/* Returns the descriptor cell for FD, locked. */ +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, 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);n } -/* Evaluate EXPR with the variable `port' bound to the port to FD. */ +/* 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) \ - ({ struct _hurd_port *__port = _hurd_dport (fd); \ - if (__port == NULL) \ + ({ int __dealloc_dt; \ + struct _hurd_fd_user __d = _hurd_fd (fd, &__dealloc_dt); \ + if (__cell.d == NULL) \ EBADF; \ else \ { \ - int __dealloc = 0; \ - io_t port = _hurd_port_locked_get (__port, &__dealloc); \ + int __dealloc = 0, __dealloc_ctty = 0; \ + io_t port = _hurd_port_locked_get (&__d.d->port, &__dealloc); \ + io_t ctty = _hurd_port_locked_get (&__d.d->ctty, &__dealloc_ctty); \ __typeof (expr) __result; \ __result = (expr); \ - _hurd_port_free (port, &__dealloc); \ + _hurd_port_free (&__d.d->port, port, &__dealloc); \ + if (ctty != MACH_PORT_NULL) \ + _hurd_port_free (&__d.d->ctty, ctty, &__dealloc_ctty); \ + _hurd_fd_done (__d, &__dealloc_dt); \ __result; \ } \ }) \ @@ -284,7 +364,6 @@ int suspended; /* If nonzero, sig_post signals `arrived'. */ struct condition arrived; - mach_port_t suspend_reply; /* Reply port for sig_post RPC. */ int vforked; /* Nonzero if this thread is a vfork child. */ struct @@ -326,10 +405,7 @@ /* Function run by the signal thread to receive from the signal port. */ extern void _hurd_sigport_receive (void); -/* Set the signal-receiving thread. */ -extern int sigsetthread (thread_t); - /* 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. @@ -340,6 +416,9 @@ 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 are @@ -362,8 +441,10 @@ /* Return EINTR. */ __err = EINTR; break; - case MACH_RCV_INTERRUPTED: /* RPC pending. */ - /* XXX */ ; + 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; diff -Nru glibc-1.02/hurd/hurdauth.c glibc-1.03/hurd/hurdauth.c --- glibc-1.02/hurd/hurdauth.c Mon Feb 10 20:33:26 1992 +++ glibc-1.03/hurd/hurdauth.c Wed Mar 25 19:16:25 1992 @@ -18,11 +18,11 @@ #include -auth_t _hurd_auth; +struct _hurd_port _hurd_auth; -static error_t -add_auth (sigthread_t me, - auth_t addauth) +error_t +__add_auth (sigthread_t me, + auth_t addauth) { error_t err; auth_t newauth; @@ -41,15 +41,10 @@ return POSIX_SUCCESS; } -#include "_Xadd_auth.c" - -asm (".stabs \"__hurd_sigport_ids\",23,0,0,23005"); /* XXX */ -text_set_element (_hurd_sigport_routines, _Xadd_auth); - -static error_t -del_auth (sigthread_t me, task_t task, - uid_t *uids, size_t nuids, - gid_t *gids, size_t ngids) +error_t +__del_auth (sigthread_t me, task_t task, + uid_t *uids, size_t nuids, + gid_t *gids, size_t ngids) { error_t err; auth_t newauth; @@ -103,8 +98,3 @@ return errno; return POSIX_SUCCESS; } - -#include "_Xdel_auth.c" - -asm (".stabs \"__hurd_sigport_ids\",23,0,0,23006"); /* XXX */ -text_set_element (_hurd_sigport_routines, _Xdel_auth); diff -Nru glibc-1.02/hurd/hurdintr.awk glibc-1.03/hurd/hurdintr.awk --- glibc-1.02/hurd/hurdintr.awk +++ glibc-1.03/hurd/hurdintr.awk Tue Mar 24 05:26:25 1992 @@ -0,0 +1,25 @@ +BEGIN { intr=0; wantcall=0; calls=""; } + +$1 == "/*" && $2 == "INTR" && $3 == "*/" { intr=1; } + +NF == 1 && $1 == "routine" { wantcall=1; next; } + +intr != 0 && wantcall == 0 && NF >= 2 && $1 == "routine" \ + { + if (substr($2, length($2)-2, 1) == "(") + calls = calls " " substr($2, 0, length($2)-1); + else calls = calls " " $2; + intr=0; + } + +wantcall != 0 && NF >= 1 \ + { + if (substr($1, length($1)-2, 1) == "(") + calls = calls " " substr($1, 0, length($1)-1); + else calls = calls " " $1; + intr=0; + } + +{ wantcall=0; } + +END { print varname " :=" calls; } diff -Nru glibc-1.02/hurd/hurdpid.c glibc-1.03/hurd/hurdpid.c --- glibc-1.02/hurd/hurdpid.c Wed Oct 30 06:53:17 1991 +++ glibc-1.03/hurd/hurdpid.c Wed Mar 25 19:17:47 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -17,7 +17,6 @@ Cambridge, MA 02139, USA. */ #include -#include pid_t _hurd_pid, _hurd_ppid, _hurd_pgrp; int _hurd_orphaned; @@ -25,15 +24,20 @@ static void init_pids (void) { - __proc_getpids (_hurd_proc, &_hurd_pid, &_hurd_ppid, &_hurd_orphaned); - __proc_getpgrp (_hurd_proc, _hurd_pid, &_hurd_pgrp); + int dealloc; + process_t proc = _hurd_port_get (&_hurd_proc, &dealloc); + + __proc_getpids (proc, &_hurd_pid, &_hurd_ppid, &_hurd_orphaned); + __proc_getpgrp (proc, _hurd_pid, &_hurd_pgrp); + + _hurd_port_free (proc, &dealloc); } text_set_element (__libc_subinit, init_pids); - -static error_t -proc_newids (sigthread_t me, - pid_t ppid, pid_t pgrp, int orphaned) + +error_t +__proc_newids (sigthread_t me, + pid_t ppid, pid_t pgrp, int orphaned) { _hurd_ppid = ppid; _hurd_pgrp = pgrp; @@ -40,8 +44,3 @@ _hurd_orphaned = orphaned; return POSIX_SUCCESS; } - -#include "_Xproc_newids.c" - -asm (".stabs \"__hurd_sigport_ids\",23,0,0,23002"); /* XXX */ -text_set_element (_hurd_sigport_routines, _Xproc_newids); diff -Nru glibc-1.02/hurd/hurdports.c glibc-1.03/hurd/hurdports.c --- glibc-1.02/hurd/hurdports.c Sat Feb 1 02:44:22 1992 +++ glibc-1.03/hurd/hurdports.c Sat Mar 21 00:14:44 1992 @@ -24,35 +24,49 @@ return _hurd_getport (&_hurd_##what, &_hurd_##lock); \ } -#define SET(lock, type, what) \ -int \ -set##what (type new) \ -{ \ - error_t err; \ - type old; \ - if (err = __mach_port_mod_refs (__mach_task_self (), new, \ - MACH_PORT_RIGHT_SEND, 1)) \ - { \ - errno = EINVAL; \ - return -1; \ - } \ - __mutex_lock (&_hurd_##lock); \ - old = _hurd_##what; \ - _hurd_##what = new; \ - __mutex_unlock (&_hurd_##lock); \ - __mach_port_deallocate (__mach_task_self (), old); \ - return 0; \ +static inline mach_port_t +get (struct _hurd_port *cell) +{ + mach_port_t result; + error_t err = _HURD_PORT_USE (cell, + __mach_port_mod_refs (__mach_task_self (), + (result = port), + MACH_PORT_RIGHT_SEND, + 1)); + if (err) + { + errno = err; + return MACH_PORT_NULL; + } + else + return result; } +#define GET(type, what) \ + type get##what (void) { return get (&what); } -#define GETSET(lock, type, what) \ - GET (lock, type, what) SET (lock, type, what) +static inline int +set (struct _hurd_port *cell, mach_port_t new) +{ + error_t err; + if (err = __mach_port_mod_refs (__mach_task_self (), new, + MACH_PORT_RIGHT_SEND, 1)) + { + errno = EINVAL; + return -1; + } + _hurd_port_set (cell, new); + return 0; +} +#define SET(type, what) \ + int set##what (type new) { return set (&what, new); } + +#define GETSET(type, what) \ + GET (type, what) SET (type, what) -GETSET (lock, process_t, proc) -GETSET (lock, file_t, ccdir) -GETSET (lock, file_t, cwdir) -GETSET (lock, file_t, crdir) -GET (lock, auth_t, auth) +GETSET (process_t, proc) +GETSET (file_t, ccdir) +GETSET (file_t, cwdir) +GETSET (file_t, crdir) -#define getsigthread siggetthread -#define setsigthread sigsetthread -GETSET (siglock, thread_t, sigthread) +/* setauth is nontrivial; see __setauth.c. */ +GET (auth_t, auth) diff -Nru glibc-1.02/hurd/hurdsig.c glibc-1.03/hurd/hurdsig.c --- glibc-1.02/hurd/hurdsig.c Fri Feb 7 18:19:39 1992 +++ glibc-1.03/hurd/hurdsig.c Sat Apr 4 06:26:03 1992 @@ -17,6 +17,7 @@ Cambridge, MA 02139, USA. */ #include +#include struct mutex _hurd_siglock; int _hurd_stopped; @@ -30,14 +31,6 @@ /* Linked-list of per-thread signal state. */ struct _hurd_sigstate *_hurd_sigstates; -static void -init_sig (void) -{ - __mutex_init (&_hurd_siglock); -} -text_set_element (__libc_subinit, init_sig); - - struct _hurd_sigstate * _hurd_thread_sigstate (thread_t thread) { @@ -66,41 +59,55 @@ /* Limit on size of core files. */ int _hurd_core_limit; -/* Call the core server to mummify us before we die. */ +/* Call the core server to mummify us before we die. + Returns nonzero if a core file was written. */ static inline int write_corefile (int signo, int sigcode) { error_t err; mach_port_t coreserver; + int dealloc_crdir, dealloc_ccdir; + file_t crdir, ccdir; if (_hurd_core_limit == 0) /* User doesn't want a core. */ return 0; - coreserver = __hurd_path_lookup (_SERVERS_CORE, 0, 0); + coreserver = __path_lookup (_SERVERS_CORE, 0, 0); if (coreserver == MACH_PORT_NULL) return 0; - if (err = __dir_lookup (_hurd_ccdir, "core", - FS_LOOKUP_WRITE|FS_LOOKUP_CREATE, - 0666 & ~_hurd_umask, - &file)) - return 0; - err = __core_dump_task (coreserver, - __mach_task_self (), - file, - signo, sigcode, - getenv ("GNUTARGET")); - __mach_port_deallocate (__mach_task_self (), coreserver); - if (!err && _hurd_core_limit != RLIM_INFINITY) + + ccdir = _hurd_port_get (&_hurd_ccdir, &dealloc_ccdir); + + crdir = _hurd_port_get (&_hurd_crdir, &dealloc_crdir); + err = __hurd_path_lookup (crdir, ccdir, "core" + FS_LOOKUP_WRITE|FS_LOOKUP_CREATE, + 0666 & ~_hurd_umask, + &file); + _hurd_port_free (crdir, &dealloc_crdir); + + if (!err) { - io_statbuf_t stb; - err = io_stat (file, &stb); - if (!err && stb.stb_size > _hurd_core_limit) - err = EFBIG; + err = __core_dump_task (coreserver, + __mach_task_self (), + file, + signo, sigcode, + getenv ("GNUTARGET")); + __mach_port_deallocate (__mach_task_self (), coreserver); + if (!err && _hurd_core_limit != RLIM_INFINITY) + { + io_statbuf_t stb; + err = __io_stat (file, &stb); + if (!err && stb.stb_size > _hurd_core_limit) + err = EFBIG; + } + __mach_port_deallocate (__mach_task_self (), file); + if (err) + (void) __dir_unlink (ccdir, "core"); } - __mach_port_deallocate (__mach_task_self (), file); - if (err) - (void) __dir_unlink (_hurd_ccdir, "core"); + + _hurd_port_free (ccdir, &dealloc_ccdir); + return !err; } @@ -107,6 +114,10 @@ extern const size_t _hurd_thread_state_count; +/* 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 @@ -120,7 +131,9 @@ extern error_t _hurd_thread_state (thread_t, void *state); extern int *_hurd_thread_pc (void *state); - /* Abort whatever the thread is doing, and fetch its state. */ + /* Abort whatever the thread is doing. + If it is in the mach_msg syscall doing the send, + the syscall will return MACH_SEND_INTERRUPTED. */ __thread_abort (ss->thread); _hurd_thread_state (ss->thread, state); @@ -127,9 +140,38 @@ if (_hurd_thread_pc (state) == &__mach_msg_trap_syscall_pc) { /* The thread was waiting for the RPC to return. - Abort the operation. The RPC will return POSIX_EINTR, - or mach_msg will return an interrupt error. */ - __interrupt_operation (ss->intr_port); + 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_request_port = ss->intr_port; + msg.header.msgh_reply_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_reply_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 (), + /* XXX */ + _hurd_thread_reply_port (ss->thread)); + 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; } @@ -148,21 +190,24 @@ { thread_t me = __mach_thread_self (); thread_t *threads; - size_t nthreads; + size_t nthreads, i; - for (__task_threads (__mach_task_self (), &list, &nthreads); - nthreads-- > 0; - __mach_port_deallocate (__mach_task_self (), *nthreads++)) - if (*nthreads != me) - { - struct _hurd_sigstate *ss = _hurd_thread_sigstate (*nthreads); - abort_rpcs (ss, signo, state); - __mutex_unlock (&ss->lock); - } + __task_threads (__mach_task_self (), &threads, &nthreads); + for (i = 0; i < nthreads; ++i) + { + if (threads[i] != me) + { + struct _hurd_sigstate *ss = _hurd_thread_sigstate (*nthreads); + abort_rpcs (ss, signo, state); + __mutex_unlock (&ss->lock); + } + __mach_port_deallocate (__mach_task_self (), threads[i]); + } } -/* SS->lock is held on entry and released before return. */ +/* Deliver a signal. + SS->lock is held on entry and released before return. */ error_t _hurd_internal_post_signal (reply_port_t reply, struct _hurd_sigstate *ss, @@ -176,6 +221,12 @@ if (ss->actions[signo].sa_handler == SIG_DFL) 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: @@ -223,7 +274,7 @@ } /* Handle receipt of a blocked signal. */ - if (((sigmask (signo) & ss->blocked) && act != ignore) || + if ((__sigismember (signo, &ss->blocked) && act != ignore) || (signo != SIGKILL && _hurd_stopped)) { __sigaddmember (signo, &ss->pending); @@ -238,35 +289,56 @@ switch (act) { case stop: - __sig_post_reply (reply, POSIX_SUCCESS, WILLSTOP); - __mutex_lock (&_hurd_lock); - __proc_dostop (_hurd_proc, __mach_thread_self ()); - __mutex_unlock (&_hurd_lock); - __mutex_unlock (&ss->lock); - abort_all_rpcs (signo, thread_state); - __proc_markstop (_hurd_proc, signo); + if (reply != MACH_PORT_NULL) + __sig_post_reply (reply, POSIX_SUCCESS); + _HURD_PORT_USE + (&_hurd_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_markstop (port, signo); + })); _hurd_stopped = 1; + + __mutex_lock (&ss->lock); + if (ss->suspended) + /* There is a sigsuspend waiting. Tell it to wake up. */ + __condition_signal (&ss->arrived); + else + __mutex_unlock (&ss->lock); + return MIG_NO_REPLY; /* Already replied. */ case ignore: - __sig_post_reply (reply, POSIX_SUCCESS, IGNBLK); + if (reply != MACH_PORT_NULL) + __sig_post_reply (reply, POSIX_SUCCESS); break; case core: case term: - __sig_post_reply (reply, POSIX_SUCCESS, CATCH); - __mutex_lock (&_hurd_lock); - __proc_dostop (_hurd_proc, __mach_thread_self ()); - abort_all_rpcs (signo, thread_state); - __proc_exit (_hurd_proc, - (W_EXITCODE (0, signo) | - (act == core && write_corefile (signo, sigcode) ? - WCOREDUMP : 0))); + if (reply != MACH_PORT_NULL) + __sig_post_reply (reply, POSIX_SUCCESS); + _HURD_PORT_USE + (&_hurd_proc, + ({ + __proc_dostop (port, __mach_thread_self ()); + abort_all_rpcs (signo, thread_state); + __proc_exit (port, + (W_EXITCODE (0, signo) | + (act == core && write_corefile (signo, sigcode) ? + WCOREDUMP : 0))) + })); __task_terminate (__mach_task_self ()); return MIG_NO_REPLY; /* Yeah, right. */ case handle: - __sig_post_reply (reply, POSIX_SUCCESS, CATCH); + if (reply != MACH_PORT_NULL) + __sig_post_reply (reply, POSIX_SUCCESS); __thread_suspend (ss->thread); abort_rpcs (ss, signo, thread_state); { @@ -294,13 +366,18 @@ NULL); } - __mutex_unlock (&ss->lock); + if (ss->suspended) + /* There is a sigsuspend waiting. Tell it to wake up. */ + __condition_signal (&ss->arrived); + else + __mutex_unlock (&ss->lock); + return MIG_NO_REPLY; } /* Called by the proc server to send a signal. */ -static error_t -sig_post (sigthread_t me, +error_t +__sig_post (sigthread_t me, mig_reply_port_t reply, int signo, mach_port_t refport) @@ -312,7 +389,7 @@ if (refport == __mach_task_self ()) /* Can send any signal. */ - ; + goto win; else if (refport == _hurd_cttyport) switch (signo) { @@ -320,46 +397,27 @@ case SIGQUIT: case SIGTSTP: case SIGHUP: - break; - default: - return EPERM; + goto win; } else { static mach_port_t sessport = MACH_PORT_NULL; if (sessport == MACH_PORT_NULL) - { - __mutex_lock (&_hurd_lock); - __proc_getsidport (_hurd_proc, &sessport); - __mutex_unlock (&_hurd_lock); - } - if (refport == sessport && signo != SIGCONT) - return EPERM; + _HURD_PORT_USE (&_hurd_proc, + __proc_getsidport (port, &sessport)); + if (sessport != MACH_PORT_NULL && + refport == sessport && signo == SIGCONT) + goto win; } - else - /* XXX async io? */ - return EPERM; - ss = _hurd_thread_sigstate (_hurd_sigthread); - if (ss->suspended) - { - /* There is a sigsuspend waiting. Let it take the signal. */ - ss->suspend_reply = reply; - __condition_broadcast (&ss->arrived); - return MIG_NO_REPLY; - } + /* XXX async io? */ + return EPERM; - return _hurd_internal_post_signal (reply, - signo, 0, - NULL); + win: + ss = _hurd_thread_sigstate (_hurd_sigthread); + return _hurd_internal_post_signal (reply, ss, signo, 0, NULL); } -#include "_Xsig_post.c" - -asm (".stabs \"__hurd_sigport_ids\",23,0,0,23000"); /* XXX */ -text_set_element (_hurd_sigport_routines, _Xsig_post); - - /* Called by the exception handler to take a signal. */ void _hurd_exc_post_signal (thread_t thread, int signo, int sigcode) @@ -367,4 +425,62 @@ (void) _hurd_internal_post_signal (MACH_PORT_NULL, _hurd_thread_sigstate (thread), signo, sigcode, NULL); +} + +void +_hurdsig_init (void) +{ + thread_t sigthread; + + __mutex_init (&_hurd_siglock); + + if (_hurd_sigport == MACH_PORT_NULL) + if (err = __mach_port_allocate (__mach_task_self (), + MACH_PORT_RIGHT_RECEIVE, + &_hurd_sigport)) + __libc_fatal ("hurd: Can't create signal port receive right\n"); + + if (err = __thread_create (__mach_task_self (), &sigthread)) + __libc_fatal ("hurd: Can't create signal thread\n"); + if (err = _hurd_start_sigthread (sigthread, _hurd_sigport_receive)) + __libc_fatal ("hurd: Can't start signal thread\n"); + _hurd_sigport_thread = sigthread; + + /* Make a send right to the signal port. */ + if (err = __mach_port_insert_right (__mach_task_self (), + _hurd_sigport, + MACH_PORT_RIGHT_MAKE_SEND)) + __libc_fatal ("hurd: Can't create send right to signal port\n"); + + /* Receive exceptions on the signal port. */ + __task_set_special_port (__mach_task_self (), + TASK_EXCEPTION, + _hurd_sigport); +} + +/* Make PROCSERVER be our proc server port. + Tell the proc server that we exist. */ + +void +_hurd_proc_init (process_t procserver, char **argv) +{ + mach_port_t oldsig, oldtask; + + _hurd_port_init (&_hurd_proc, procserver); + + /* Tell the proc server where our args and environment are. */ + __proc_setprocargs (procserver, argv, __environ); + + /* Initialize the signal code; Mach exceptions will become signals. + This sets _hurd_sigport; it must be run before _hurd_proc_init. */ + _hurdsig_init (); + + /* Give the proc server our task and signal ports. */ + __proc_setports (procserver, + _hurd_sigport, __mach_task_self (), + &oldsig, &oldtask); + if (oldsig != MACH_PORT_NULL) + __mach_port_deallocate (__mach_task_self (), oldsig); + if (oldtask != MACH_PORT_NULL) + __mach_port_deallocate (__mach_task_self (), oldtask); } diff -Nru glibc-1.02/hurd/hurdsock.c glibc-1.03/hurd/hurdsock.c --- glibc-1.02/hurd/hurdsock.c Sat Feb 8 03:14:52 1992 +++ glibc-1.03/hurd/hurdsock.c Sat Mar 21 00:21:38 1992 @@ -34,6 +34,16 @@ 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) { @@ -67,7 +77,7 @@ { char name[100]; sprintf (name, "%d", domain); - if (err = _HURD_PORT_USE (_hurd_crdir, + if (err = _HURD_PORT_USE (&_hurd_crdir, __hurd_path_lookup (port, sockdir, name, 0, 0, &servers[domain]))) diff -Nru glibc-1.02/hurd/intr_rpc.awk glibc-1.03/hurd/intr_rpc.awk --- glibc-1.02/hurd/intr_rpc.awk +++ glibc-1.03/hurd/intr_rpc.awk Tue Mar 24 21:17:49 1992 @@ -0,0 +1,28 @@ +# Icky intimate knowledge of MiG output. + +BEGIN { args=""; argsnext=0; echo=1; print "#include "; } + +$NF == rpc \ + { + for (i = 1; i < NF; ++i) printf "%s ", $i; + print call; + next; + } + +args == "" && $1 == "#else" { argsnext=1; print $0; next; } + +argsnext == 1 { args=$0; firstarg=substr($1, 2, length($1)-2); } + +{ argsnext=0; } + +/^{/ { echo=0; } + +echo == 1 { print $0; } + +/^}/ \ + { + print "{"; + print " return _HURD_EINTR_RPC (" firstarg ", " rpc args ");"; + print "}"; + echo = 1; + } diff -Nru glibc-1.02/hurd/openport.c glibc-1.03/hurd/openport.c --- glibc-1.02/hurd/openport.c Sat Feb 1 03:42:38 1992 +++ glibc-1.03/hurd/openport.c Sat Mar 21 00:23:35 1992 @@ -19,29 +19,25 @@ #include /* Open a file descriptor on a port. */ + int openport (io_t port) { int fd; - __mutex_lock (&_hurd_dtable.lock); - - fd = _hurd_dalloc (); - if (fd < 0) - { - __mutex_unlock (&_hurd_dtable.lock); - return -1; - } - + /* Give the port a new user reference. + This is a good way to check that it is valid. */ if (__mach_port_mod_refs (__mach_task_self (), port, MACH_PORT_RIGHT_SEND, 1)) { - __mutex_unlock (&_hurd_dtable.lock); errno = EINVAL; return -1; } - _hurd_dtable.d[fd].server = port; - __mutex_unlock (&_hurd_dtable.lock); - return 0; + fd = _hurd_dalloc (port, 0); + if (fd < 0) + /* The descriptor table is full. */ + __mach_port_deallocate (__mach_task_self (), port); + + return fd; } diff -Nru glibc-1.02/hurd/pid2task.c glibc-1.03/hurd/pid2task.c --- glibc-1.02/hurd/pid2task.c Fri Oct 25 19:45:07 1991 +++ glibc-1.03/hurd/pid2task.c Sun Mar 22 00:40:40 1992 @@ -1,3 +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 (__pid2task, pid2task); diff -Nru glibc-1.02/hurd/setauth.c glibc-1.03/hurd/setauth.c --- glibc-1.02/hurd/setauth.c Wed Oct 23 18:25:25 1991 +++ glibc-1.03/hurd/setauth.c Sun Mar 22 00:40:38 1992 @@ -1,3 +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 (__setauth, setauth); diff -Nru glibc-1.02/hurd/setdtablesize.c glibc-1.03/hurd/setdtablesize.c --- glibc-1.02/hurd/setdtablesize.c Sat Feb 1 03:42:32 1992 +++ glibc-1.03/hurd/setdtablesize.c Sun Mar 22 00:39:57 1992 @@ -18,23 +18,43 @@ #include +/* 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 (int size) +setdtablesize (size_t size) { int i; - __typeof (_hurd_dtable.d) table; + 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) - if (_hurd_dtable.d[i].server != MACH_PORT_NULL) - { - __mutex_unlock (&_hurd_dtable_lock); - errno = EBUSY; - return -1; - } + { + 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; + } + } - table = realloc (_hurd_dtable.d, size * sizeof (*table)); + /* 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); @@ -41,11 +61,26 @@ 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].server = MACH_PORT_NULL; + { + 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 -Nru glibc-1.02/hurd/task2pid.c glibc-1.03/hurd/task2pid.c --- glibc-1.02/hurd/task2pid.c Fri Oct 25 19:44:59 1991 +++ glibc-1.03/hurd/task2pid.c Sun Mar 22 00:40:45 1992 @@ -1,3 +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 (__task2pid, task2pid); diff -Nru glibc-1.02/io/Makefile glibc-1.03/io/Makefile --- glibc-1.02/io/Makefile Tue Mar 17 19:23:36 1992 +++ glibc-1.03/io/Makefile Tue Mar 24 00:39:48 1992 @@ -31,7 +31,7 @@ __open __close __read __write __lseek __access __fcntl __flock \ __dup __dup2 __pipe \ creat \ - __chdir getcwd getwd \ + __chdir getcwd getwd getdirname \ __chown __fchown \ ttyname __isatty \ __link __symlink __readlink \ diff -Nru glibc-1.02/io/chown.c glibc-1.03/io/chown.c --- glibc-1.02/io/chown.c Fri Mar 13 16:36:30 1992 +++ glibc-1.03/io/chown.c Wed Apr 1 22:13:54 1992 @@ -24,4 +24,4 @@ function_alias(chown, __chown, int, (file, owner, group), DEFUN(chown, (file, owner, group), - CONST char *file AND int owner AND int group)) + CONST char *file AND __uid_t owner AND __gid_t group)) diff -Nru glibc-1.02/io/fchmod.c glibc-1.03/io/fchmod.c --- glibc-1.02/io/fchmod.c Wed Jun 12 13:25:49 1991 +++ glibc-1.03/io/fchmod.c Mon Mar 23 17:08:29 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -17,6 +17,7 @@ Cambridge, MA 02139, USA. */ #include +#include #include #include @@ -23,4 +24,4 @@ #undef fchmod function_alias(fchmod, __fchmod, int, (fd, mode), - DEFUN(fchmod, (fd, mode), int fd AND int mode)) + DEFUN(fchmod, (fd, mode), int fd AND mode_ta mode)) diff -Nru glibc-1.02/io/fchown.c glibc-1.03/io/fchown.c --- glibc-1.02/io/fchown.c Fri Mar 13 16:36:27 1992 +++ glibc-1.03/io/fchown.c Mon Mar 23 17:08:34 1992 @@ -17,6 +17,7 @@ Cambridge, MA 02139, USA. */ #include +#include #include #include @@ -24,4 +25,4 @@ function_alias(fchown, __fchown, int, (fd, owner, group), DEFUN(fchown, (fd, owner, group), - int fd AND int owner AND int group)) + int fd AND uid_t owner AND gid_t group)) diff -Nru glibc-1.02/io/getdirname.c glibc-1.03/io/getdirname.c --- glibc-1.02/io/getdirname.c +++ glibc-1.03/io/getdirname.c Tue Mar 24 02:02:08 1992 @@ -0,0 +1,45 @@ +/* Copyright (C) 1992 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include +#include +#include + +/* Return a malloc'd string containing the current directory name. + If the environment variable `PWD' is set, and its value is correct, + that value is used. */ + +char * +DEFUN_VOID(get_current_dir_name) +{ + char *pwd; + struct stat dotstat, pwdstat; + + pwd = getenv ("PWD"); + if (pwd != NULL && + stat (".", &dotstat) == 0 && + stat (pwd, &pwdstat) == 0 && + pwdstat.st_dev == dotstat.st_dev && + pwdstat.st_ino == dotstat.st_ino) + /* The PWD value is correct. Use it. */ + return strdup (pwd); + + return getcwd ((char *) NULL, 0); +} diff -Nru glibc-1.02/locale/Makefile glibc-1.03/locale/Makefile --- glibc-1.02/locale/Makefile Wed Feb 12 13:14:42 1992 +++ glibc-1.03/locale/Makefile Thu Apr 2 19:26:33 1992 @@ -23,7 +23,7 @@ headers := locale.h localeinfo.h -routines := setlocale +routines := setlocale localeconv aux := C-collate C-ctype C-ctype_ct C-ctype_mb \ C-monetary C-numeric C-response C-time diff -Nru glibc-1.02/locale/localeconv.c glibc-1.03/locale/localeconv.c --- glibc-1.02/locale/localeconv.c +++ glibc-1.03/locale/localeconv.c Wed Jan 30 04:56:14 1991 @@ -0,0 +1,49 @@ +/* Copyright (C) 1991 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 1, or (at your option) +any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with the GNU C Library; see the file COPYING. If not, write to +the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include +#include +#include + + +/* Return monetary and numeric information about the current locale. */ +struct lconv * +DEFUN_VOID(localeconv) +{ + static struct lconv result; + + result.decimal_point = (char *) _numeric_info->decimal_point; + result.thousands_sep = (char *) _numeric_info->thousands_sep; + result.grouping = (char *) _numeric_info->grouping; + + result.int_curr_symbol = (char *) _monetary_info->int_curr_symbol; + result.currency_symbol = (char *) _monetary_info->currency_symbol; + result.mon_decimal_point = (char *) _monetary_info->mon_decimal_point; + result.mon_thousands_sep = (char *) _monetary_info->mon_thousands_sep; + result.mon_grouping = (char *) _monetary_info->mon_grouping; + result.positive_sign = (char *) _monetary_info->positive_sign; + result.negative_sign = (char *) _monetary_info->negative_sign; + result.frac_digits = _monetary_info->frac_digits; + result.p_cs_precedes = _monetary_info->p_cs_precedes; + result.p_sep_by_space = _monetary_info->p_sep_by_space; + result.n_cs_precedes = _monetary_info->p_cs_precedes; + result.n_sep_by_space = _monetary_info->n_sep_by_space; + result.p_sign_posn = _monetary_info->p_sign_posn; + result.n_sign_posn = _monetary_info->n_sign_posn; + + return &result; +} diff -Nru glibc-1.02/mach/Machrules glibc-1.03/mach/Machrules --- glibc-1.02/mach/Machrules +++ glibc-1.03/mach/Machrules Thu Apr 9 21:43:37 1992 @@ -0,0 +1,111 @@ +# Rules for MiG interfaces that want to go into the C library. + +# Copyright (C) 1991, 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. + +# Makefiles 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-header-prefix Directory prefix for interface header files. +# This file sets: +# interface-headers Names of generated interface header files. +# interface-routines Names of generated interface routines. +# All user stubs are put in individual files, prefixed with __, and a +# symbol-alias to the un-__'d form generated; header for both is put in +# foo.h. If a server interface is listed as __foo, then its routines are +# prefixed with __; server interfaces are written to foo_server.c and +# foo_server.h (or __foo_server.c and __foo_server.h). + +# Includers can also add to or modify `migdefines' to set MiG flags. + +all: + +include ../Makeconfig + +# Where to find interface definition files. +ifdef MIG_DEFS_PATH +vpath %.defs $(MIG_DEFS_PATH) +endif + +ifndef MIG +MIG = mig +endif +MIGFLAGS = -DMACH_IPC_COMPAT=0 -DSTANDALONE -DTypeCheck=0 \ + $(includes) $(migdefines) + +.SUFFIXES: .defs + +define \n + + +endef +ifdef user-interfaces +include interface-rules +endif +interface-rules: Makefile Machrules + (for interface in $(user-interfaces); do \ + echo "include .ir-$${interface}"; \ + done) > $@-new + mv $@-new $@ +.ir-%: %.uh Machrules + (echo 'define $*-calls' ;\ + awk '/^kern_return_t/ { print $$2 }' $< ;\ + echo 'endef' ;\ + echo '$*-calls := $$(subst $$('\\'n), ,$$($*-calls))' ;\ + echo '$$(patsubst %,foreign-%%c,$$($*-calls:%=__%)): $*.defs' ;\ + echo ' $$(MIG) < $$< $$(MIGFLAGS) -subrprefix __ -prefix __ -i ./foreign-__')\ + > $@-new + mv $@-new $@ +vpath Machrules ../mach + +%.c: foreign-%.c + (echo '#include '; cat $^) > $@ + +# MiG doesn't know how to make separate files for the server stubs. +foreign-__%_server.c %_server.h: %.defs + $(MIG) < $< $(MIGFLAGS) -subrprefix __ -prefix __ \ + -user /dev/null -header /dev/null \ + -server $@ -sheader $(@:__%.c=%.h) +foreign-%_server.c %_server.h: %.defs + $(MIG) < $< $(MIGFLAGS) -subrprefix __ \ + -user /dev/null -header /dev/null \ + -server $@ -sheader $(@:.c=.h) + +%.uh: %.defs + $(MIG) < $< $(MIGFLAGS) -subrprefix __ \ + -header $@ -server /dev/null -user /dev/null +%.__h: %.defs + $(MIG) < $< $(MIGFLAGS) -subrprefix __ -prefix __ \ + -header $@ -server /dev/null -user /dev/null + +$(interface-header-prefix)%.h: %.__h %.uh $(interface-header-prefix) +# The last line of foo.uh is "#endif _foo_user_". +# The first two lines of foo.__h are "#ifndef _foo_user_"/"#define _foo_user_". + (sed '$$d' < $<; tail +2 $(word 2,$^)) > $@ + +%.c: __%.c + (echo '#include '; \ + echo 'symbol_alias (__$*, $*)') > $@ + +interface-routines := $(foreach if,$(user-interfaces), \ + $(calls-$(if)) \ + $(addprefix __,$(calls-$(if)))) \ + $(server-interfaces:%=%_server) +interface-headers := $(addprefix $(interface-header-prefix),\ + $(user-interfaces:%=%.h) \ + $(server-interfaces:%=%_server.h)) diff -Nru glibc-1.02/mach/Makefile glibc-1.03/mach/Makefile --- glibc-1.02/mach/Makefile Fri Oct 25 22:10:22 1991 +++ glibc-1.03/mach/Makefile Fri Apr 10 13:10:05 1992 @@ -1,4 +1,4 @@ -# Copyright (C) 1991 Free Software Foundation, Inc. +# Copyright (C) 1991, 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 @@ -16,49 +16,95 @@ # not, write to the Free Software Foundation, Inc., 675 Mass Ave, # Cambridge, MA 02139, USA. -all: - subdir := mach -headers = mach_init.h +distribute = Machrules interface.awk mach-syscalls.awk # $(interfaces:%=%.defs) + +interface-header-prefix = mach/ +headers = mach_init.h \ + $(nope mach.h) \ + $(addprefix mach/,$(mach-headers)) \ + $(interface-headers) + ifneq (,) - $(addprefix mach/,$(interface-headers) \ - host_info.h kern_return.h \ - mach_param.h mach_types.h \ - memory_object.h \ - message.h mig_errors.h msg_type.h \ - policy.h port.h processor_info.h \ - std_types.h task_info.h task_special_ports.h \ - thread_info.h thread_special_ports.h \ - thread_status.h thread_switch.h time_value.h \ - vm_attributes.h vm_inherit.h vm_prot.h \ - vm_statistics.h) +mach-headers := host_info.h kern_return.h \ + mach_param.h mach_types.h \ + memory_object.h \ + message.h mig_errors.h msg_type.h \ + policy.h port.h processor_info.h \ + std_types.h task_info.h task_special_ports.h \ + thread_info.h thread_special_ports.h \ + thread_status.h thread_switch.h time_value.h \ + vm_attributes.h vm_inherit.h vm_prot.h \ + vm_statistics.h + +user-interfaces := mach_interface mach_port mach_host \ + device device_request device_reply \ + default_pager_object \ + memory_object_user memory_object_default +server-interfaces := __exc endif -user-interfaces := mach_interface mach_port \ - mach_host mach_debug \ - device device_request \ - default_page_object \ - memory_object_user \ - memory_object_default -server-interfaces := exc device_reply - -include Machrules +routines = $(interface-routines) \ + mach_init mach_init_syms \ + mig_strncpy mig_support msg \ + mach_msg_destroy mach_msg_server mach_msg_server_timeout \ + __mach_msg_destroy __mach_msg_server \ + devstream -routines := mach_init mach_init_syms \ - mig_strncpy mig_support msg \ - mach_traps mach_syscalls mach_shortcuts \ - mach_msg_destroy mach_msg_server mach_msg_server_timeout \ - __mach_msg_destroy __mach_msg_server \ - $(interface-routines) \ - devstream tests := hello +all: + + +# Define mach-syscalls and sysno-*. +#include mach-syscalls.mk +dont_distribute := syscall_sw.h +mach-syscalls.mk: syscall_sw.h mach-syscalls.awk + sed -n -e '/STANDALONE/,$$d' \ + -e 's/^kernel_trap(\(.*\),\([-0-9]*\),[0-9]*)$$/\1 \2/p' \ + < $< | awk -f $(word 2,$^) > $@-new + mv $@-new $@ + +ifdef mach-syscalls +$(mach-syscalls:%=__%.S): __%.S: mach-syscalls.mk + (echo '#include '; \ + echo 'SYSCALL_TRAP (__$*, $(sysno-$*))') > $@ +endif + +mach-shortcuts := $(patsubst syscall_%,%,$(filter syscall_%,$(mach-syscalls))) + +# Make the MiG stubs for $(mach-shortcuts) be CALL_rpc. +migdefines := $(migdefines) \ + $(foreach call,$(mach-shortcuts),-D$(call)=$(call)_rpc) + +# This rule needs to come before the implicit rules in Machrules. +__%.c: shortcut.awk __%_rpc.c + gawk -v call=__$* -v rpc=__$*_rpc -v syscall=__syscall_$* \ + -f $^ > $@-new + mv $@-new $@ + +include Machrules + +interface-routines := $(filter-out %_rpc,$(interface-routines)) \ + $(foreach call,$(mach-shortcuts),\ + __$(call) $(call) __syscall_$(call)) +dont_distribute := $(dont_distribute) \ + $(interface-routines:%=%.c) $(interface-headers) + include ../Rules +# There is already a mach.h, so mach.defs generates mach_interface.h. mach_interface.defs: mach.defs - ln $< $@ || cp $< $@ + ln -s $< $@ || cp $< $@ +# There is already a memory_object.h, +# so memory_object.defs generates memory_object_user.h. memory_object_user.defs: memory_object.defs - ln $< $@ || cp $< $@ + ln -s $< $@ || cp $< $@ + +# Be sure not to make these with implicit rules from foo.defs. +ifdef mach-headers +$(mach-headers): ; +endif diff -Nru glibc-1.02/mach/devstream.c glibc-1.03/mach/devstream.c --- glibc-1.02/mach/devstream.c Fri Mar 20 19:31:05 1992 +++ glibc-1.03/mach/devstream.c Sat Apr 4 03:04:53 1992 @@ -153,13 +153,12 @@ } FILE * -mach_open_devstream (device_t dev) +mach_open_devstream (device_t dev, const char *mode) { - FILE *stream = __newstream (); + FILE *stream = fopencookie (dev, mode, __default_io_functions); if (stream == NULL) return NULL; - stream->__cookie = (void *) dev; stream->__room_funcs.__input = input; stream->__room_funcs.__output = output; stream->__io_funcs.__close = device_close; diff -Nru glibc-1.02/mach/hello.c glibc-1.03/mach/hello.c --- glibc-1.02/mach/hello.c Fri Mar 20 19:30:37 1992 +++ glibc-1.03/mach/hello.c Sat Apr 4 03:05:03 1992 @@ -33,7 +33,7 @@ FILE *consf; device = pid2task (-2); - err = device_open (device, D_WRITE, "console", consdev); + err = device_open (device, D_WRITE, "console", &consdev); mach_port_deallocate (mach_task_self (), device); if (err) exit (err); diff -Nru glibc-1.02/mach/interface.awk glibc-1.03/mach/interface.awk --- glibc-1.02/mach/interface.awk +++ glibc-1.03/mach/interface.awk Tue Mar 24 03:51:26 1992 @@ -0,0 +1,22 @@ +BEGIN { wantcall=0; calls=""; } + +NF == 1 && ($1 == "routine" || $1 == "simpleroutine") \ + { wantcall=1; next; } + +wantcall == 0 && NF >= 2 && ($1 == "routine" || $1 == "simpleroutine") \ + { + if (substr($2, length($2)-2, 1) == "(") + calls = calls " " substr($2, 0, length($2)-1); + else calls = calls " " $2; + } + +wantcall == 1 && NF >= 1 \ + { + if (substr($1, length($1)-2, 1) == "(") + calls = calls " " substr($1, 0, length($1)-1); + else calls = calls " " $1; + } + +{ wantcall=0; } + +END { print varname " :=" calls; } diff -Nru glibc-1.02/mach/mach-syscalls.awk glibc-1.03/mach/mach-syscalls.awk --- glibc-1.02/mach/mach-syscalls.awk +++ glibc-1.03/mach/mach-syscalls.awk Thu Apr 2 22:08:11 1992 @@ -0,0 +1,8 @@ +BEGIN { calls="" } + +{ + calls = calls " " $1; + print "sysno-" $1 " = " $2; +} + +END { print "mach-syscalls := " calls } diff -Nru glibc-1.02/mach/mach_shortcuts.c glibc-1.03/mach/mach_shortcuts.c --- glibc-1.02/mach/mach_shortcuts.c Sat Oct 19 17:23:12 1991 +++ glibc-1.03/mach/mach_shortcuts.c @@ -1,13 +0,0 @@ -#include -#include - -#define SHORTCUT(name, number, args, typed_args) \ -kern_return_t __##name typed_args \ -{ \ - kern_return_t ret = __syscall_##name args; \ - if (ret == MACH_SEND_INTERRUPTED) \ - ret = __mig_##name args; \ - return ret; \ -} - -#include "mach_shortcuts.h" diff -Nru glibc-1.02/mach/mach_syscalls.c glibc-1.03/mach/mach_syscalls.c --- glibc-1.02/mach/mach_syscalls.c Sat Oct 19 17:00:09 1991 +++ glibc-1.03/mach/mach_syscalls.c @@ -1,10 +0,0 @@ -/* Aliases for basic Mach system calls: - mach_task_self -> __mach_task_self, etc. */ - -#include - -#define SYSCALL(name, number, type, args, typed_args) \ - function_alias (name, __##name, type, args, \ - name typed_args) - -#include "mach_syscalls.h" diff -Nru glibc-1.02/mach/mach_traps.S glibc-1.03/mach/mach_traps.S --- glibc-1.02/mach/mach_traps.S Sat Oct 19 17:40:44 1991 +++ glibc-1.03/mach/mach_traps.S @@ -1,15 +0,0 @@ -/* Traps for Mach basic system calls and kernel RPC shortcuts. */ - -#include - -#define SYSCALL(name, number, type, args, typed_args) \ - SYSCALL_TRAP (__##name, number) - -/* Basic syscalls. */ -#include "mach_syscalls.h" - -/* RPC shortcuts. */ -#define SHORTCUT(name, number, args, typed_args) \ - SYSCALL_TRAP (__syscall_##name, number) - -#include "mach_shortcuts.h" diff -Nru glibc-1.02/math/Makefile glibc-1.03/math/Makefile --- glibc-1.02/math/Makefile Fri Mar 20 18:01:53 1992 +++ glibc-1.03/math/Makefile Mon Mar 23 17:14:26 1992 @@ -37,7 +37,7 @@ $(objpfx)libm.a: - $(AR) c$(verbose) $@ + $(AR) cr$(verbose) $@ # Other dirs to look for source files (for dist). source_dirs = $(filter-out unused,$(shell find bsd -type d -print)) diff -Nru glibc-1.02/math/__finite.c glibc-1.03/math/__finite.c --- glibc-1.02/math/__finite.c Wed Jun 12 13:18:53 1991 +++ glibc-1.03/math/__finite.c Mon Mar 30 17:23:41 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -21,9 +21,9 @@ #undef __finite -/* Return nonzero if VALUE is finite (or NaN). */ +/* Return nonzero if VALUE is finite and not NaN. */ int DEFUN(__finite, (value), double value) { - return !__isinf(value); + return !__isinf (value) && !__isnan (value); } diff -Nru glibc-1.02/math/math.h glibc-1.03/math/math.h --- glibc-1.02/math/math.h Thu Mar 5 22:06:56 1992 +++ glibc-1.03/math/math.h Mon Mar 30 17:23:00 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -147,7 +147,7 @@ /* Return nonzero if VALUE is not a number. */ extern __CONSTVALUE int EXFUN(__isnan, (double __value)); -/* Return nonzero if VALUE is finite (or NaN). */ +/* Return nonzero if VALUE is finite and not NaN. */ extern __CONSTVALUE int EXFUN(__finite, (double __value)); #ifdef __OPTIMIZE__ #define __finite(value) (!__isinf(value)) diff -Nru glibc-1.02/math/test-math.c glibc-1.03/math/test-math.c --- glibc-1.02/math/test-math.c Fri Mar 20 18:01:03 1992 +++ glibc-1.03/math/test-math.c Wed Apr 1 01:22:06 1992 @@ -7,11 +7,49 @@ DEFUN_VOID(main) { CONST char str[] = "123.456"; - double x; + double x,y,z,h,li,lr,a,lrr; x = atof (str); printf ("%g %g\n", x, pow (10.0, 3.0)); - + + x = sinh(2.0); + + fprintf(stderr,"sinh(2.0) = %g\n", x); + + x = sinh(3.0); + + fprintf(stderr,"sinh(3.0) = %g\n", x); + + h = hypot(2.0,3.0); + + fprintf(stderr,"h=%g\n", h); + + a = atan2(3.0, 2.0); + + fprintf(stderr,"atan2(3,2) = %g\n", a); + + lr = pow(h,4.0); + + fprintf(stderr,"pow(%g,4.0) = %g\n", h, lr); + + lrr = lr; + + li = 4.0 * a; + + lr = lr / exp(a*5.0); + + fprintf(stderr,"%g / exp(%g * 5) = %g\n", lrr, exp(a*5.0), lr); + + lrr = li; + + li += 5.0 * log(h); + + fprintf(stderr,"%g + 5*log(%g) = %g\n", lrr, h, li); + + fprintf(stderr,"cos(%g) = %g, sin(%g) = %g\n", li, cos(li), li, sin(li)); + + fflush(stderr); + return 0; } diff -Nru glibc-1.02/misc/bsd-compat.c glibc-1.03/misc/bsd-compat.c --- glibc-1.02/misc/bsd-compat.c Sat Mar 14 23:13:55 1992 +++ glibc-1.03/misc/bsd-compat.c Mon Mar 23 17:24:58 1992 @@ -39,5 +39,5 @@ } #undef longjmp -function_alias_void(longjmp, siglongjmp, void, (env, val), - DEFUN(longjmp, (env, val), jmp_buf env AND int val)) +function_alias_void(longjmp, siglongjmp, (env, val), + DEFUN(longjmp, (env, val), CONST jmp_buf env AND int val)) diff -Nru glibc-1.02/misc/sys/ioctl.h glibc-1.03/misc/sys/ioctl.h --- glibc-1.02/misc/sys/ioctl.h Wed Jun 12 13:20:40 1991 +++ glibc-1.03/misc/sys/ioctl.h Wed Apr 1 01:33:12 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -51,8 +51,7 @@ }; #endif -#if defined(TIOCGETP) || defined(TIOCSETP) -/* Type of ARG for TIOCGETP and TIOCSETP requests. */ +/* Type of ARG for TIOCGETP and TIOCSETP requests (and gtty and stty). */ struct sgttyb { char sg_ispeed; /* Input speed. */ @@ -61,7 +60,6 @@ char sg_kill; /* Kill character. */ short int sg_flags; /* Mode flags. */ }; -#endif #if defined(TIOCGWINSZ) || defined(TIOCSWINSZ) /* Type of ARG for TIOCGWINSZ and TIOCSWINSZ requests. */ diff -Nru glibc-1.02/posix/Makefile glibc-1.03/posix/Makefile --- glibc-1.02/posix/Makefile Mon Feb 17 02:23:06 1992 +++ glibc-1.03/posix/Makefile Tue Apr 7 17:51:22 1992 @@ -23,7 +23,7 @@ headers := sys/utsname.h sys/times.h sys/wait.h sys/types.h unistd.h \ glob.h wordexp.h fnmatch.h gnu/wait.h gnu/types.h getopt.h \ - posix1_lim.h posix2_lim.h posix_opt.h local_lim.h + posix1_lim.h posix2_lim.h posix_opt.h local_lim.h tar.h distribute := confstr.h @@ -46,7 +46,7 @@ aux := init-posix environ tests := tstgetopt -others := logname getconf id +others := getconf include ../Rules diff -Nru glibc-1.02/posix/execvp.c glibc-1.03/posix/execvp.c --- glibc-1.02/posix/execvp.c Wed Jun 12 13:25:46 1991 +++ glibc-1.03/posix/execvp.c Mon Mar 23 17:42:06 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -24,6 +24,10 @@ #include #include #include + +#ifndef HAVE_GNU_LD +#define __environ environ +#endif /* Execute FILE, searching in the `PATH' environment variable if it contains no slashes, with arguments ARGV and environment from `environ'. */ diff -Nru glibc-1.02/posix/fork.c glibc-1.03/posix/fork.c --- glibc-1.02/posix/fork.c Wed Jun 12 13:26:18 1991 +++ glibc-1.03/posix/fork.c Wed Apr 1 01:22:35 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -21,5 +21,5 @@ #include #undef fork -function_alias(fork, __fork, int, (), +function_alias(fork, __fork, __pid_t, (), DEFUN_VOID(fork)) diff -Nru glibc-1.02/posix/getpid.c glibc-1.03/posix/getpid.c --- glibc-1.02/posix/getpid.c Wed Jun 12 13:26:56 1991 +++ glibc-1.03/posix/getpid.c Wed Apr 1 01:22:37 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -21,5 +21,5 @@ #include #undef getpid -function_alias(getpid, __getpid, int, (), +function_alias(getpid, __getpid, __pid_t, (), DEFUN_VOID(getpid)) diff -Nru glibc-1.02/posix/getppid.c glibc-1.03/posix/getppid.c --- glibc-1.02/posix/getppid.c Wed Jun 12 13:27:01 1991 +++ glibc-1.03/posix/getppid.c Wed Apr 1 01:22:26 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -22,4 +22,4 @@ #undef getppid -function_alias(getppid, __getppid, int, (), DEFUN_VOID(getppid)) +function_alias(getppid, __getppid, __pid_t, (), DEFUN_VOID(getppid)) diff -Nru glibc-1.02/posix/id.c glibc-1.03/posix/id.c --- glibc-1.02/posix/id.c Wed Jun 12 13:27:29 1991 +++ glibc-1.03/posix/id.c @@ -1,173 +0,0 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. -This file is part of the GNU C Library. - -The GNU C Library is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. - -The GNU C Library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with the GNU C Library; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA. */ - -#include -#include -#include -#include -#include -#include -#include -#include - - -static void -DEFUN(print_grpname, (id, parens), - gid_t id AND int parens) -{ - CONST struct group *CONST g = getgrgid(id); - if (g == NULL) - { - if (parens) - return; - else - { - fprintf(stderr, "Couldn't find name for group %d\n", id); - exit(EXIT_FAILURE); - } - } - - if (parens) - printf("(%s)", g->gr_name); - else - puts(g->gr_name); -} - -static void -DEFUN(print_pwdname, (id, parens), - uid_t id AND int parens) -{ - CONST struct passwd *CONST p = getpwuid(id); - if (p == NULL) - { - if (parens) - return; - else - { - fprintf(stderr, "Couldn't find name for user %d\n", (int) id); - exit(EXIT_FAILURE); - } - } - - if (parens) - printf("(%s)", p->pw_name); - else - puts(p->pw_name); -} - -int -DEFUN(main, (argc, argv), int argc AND char **argv) -{ - int print_gid = 1, print_uid = 1; - int real = 0, name = 0; - int error = 0; - register int c; - - uid_t ruid = getuid(), euid = geteuid(); - gid_t rgid = getgid(), egid = getegid(); - - while ((c = getopt(argc, argv, "gurn")) != -1) - switch (c) - { - default: - error = 1; - break; - - case 'g': - print_gid = 1; - print_uid = 0; - break; - - case 'u': - print_uid = 1; - print_gid = 0; - break; - - case 'r': - real = 1; - break; - - case 'n': - name = 1; - break; - } - - if (error || argc != optind) - { - fputs("Usage: id [-gurn]\n", stderr); - exit(EXIT_FAILURE); - } - - if (print_uid && !print_gid) - { - CONST uid_t uid = real ? ruid : euid; - if (name) - print_pwdname(uid, 0); - else - printf("%d\n", (int) uid); - } - else if (print_gid && !print_uid) - { - CONST gid_t gid = real ? rgid : egid; - if (name) - print_grpname(gid, 0); - else - printf("%d\n", (int) gid); - } - else - { -#if NGROUPS_MAX > 0 - gid_t groups[NGROUPS_MAX]; - int ngroups; - ngroups = getgroups(NGROUPS_MAX, groups); -#endif - - printf("uid=%d", (int) ruid); - print_pwdname(ruid, 1); - printf(" gid=%d", (int) rgid); - print_grpname(rgid, 1); - if (euid != ruid) - { - printf(" euid=%d", (int) euid); - print_pwdname(euid, 1); - } - if (egid != rgid) - { - printf(" egid=%d", (int) egid); - print_grpname(egid, 1); - } - -#if NGROUPS > 0 - if (ngroups > 0) - { - register size_t i; - printf(" groups=%d", (int) groups[0]); - print_grpname(groups[0], 1); - for (i = 1; i < ngroups; ++i) - { - printf(", %d", (int) groups[i]); - print_grpname(groups[i], 1); - } - } -#endif - - putchar('\n'); - } - - exit(EXIT_SUCCESS); -} diff -Nru glibc-1.02/posix/logname.c glibc-1.03/posix/logname.c --- glibc-1.02/posix/logname.c Wed Jun 12 13:27:41 1991 +++ glibc-1.03/posix/logname.c @@ -1,36 +0,0 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. -This file is part of the GNU C Library. - -The GNU C Library is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. - -The GNU C Library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with the GNU C Library; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA. */ - -#include -#include -#include -#include - -int -DEFUN_VOID(main) -{ - char *name = getlogin(); - if (name == NULL) - { - perror("logname: getlogin"); - exit(EXIT_FAILURE); - } - puts(name); - exit(EXIT_SUCCESS); - return EXIT_SUCCESS; -} diff -Nru glibc-1.02/posix/setgid.c glibc-1.03/posix/setgid.c --- glibc-1.02/posix/setgid.c Wed Jun 12 13:28:47 1991 +++ glibc-1.03/posix/setgid.c Wed Apr 1 01:22:46 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -23,4 +23,4 @@ #undef setgid function_alias(setgid, __setgid, int, (gid), - DEFUN(setgid, (gid), int gid)) + DEFUN(setgid, (gid), __gid_t gid)) diff -Nru glibc-1.02/posix/setpgid.c glibc-1.03/posix/setpgid.c --- glibc-1.02/posix/setpgid.c Wed Jun 12 13:28:54 1991 +++ glibc-1.03/posix/setpgid.c Wed Apr 1 01:22:48 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -18,8 +18,9 @@ #include #include +#include #include #undef setpgid function_alias(setpgid, __setpgrp, int, (pid, pgid), - DEFUN(setpgid, (pid, pgid), int pid AND int pgid)) + DEFUN(setpgid, (pid, pgid), pid_t pid AND pid_t pgid)) diff -Nru glibc-1.02/posix/setsid.c glibc-1.03/posix/setsid.c --- glibc-1.02/posix/setsid.c Wed Jun 12 13:29:02 1991 +++ glibc-1.03/posix/setsid.c Wed Apr 1 01:22:21 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -21,5 +21,5 @@ #include #undef setsid -function_alias(setsid, __setsid, int, (), +function_alias(setsid, __setsid, __pid_t, (), DEFUN_VOID(setsid)) diff -Nru glibc-1.02/posix/sys/wait.h glibc-1.03/posix/sys/wait.h --- glibc-1.02/posix/sys/wait.h Wed Oct 30 03:57:30 1991 +++ glibc-1.03/posix/sys/wait.h Mon Mar 30 17:44:44 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -34,6 +34,8 @@ /* Encoding of the status word. */ + +#include #ifdef __USE_BSD union __wait diff -Nru glibc-1.02/posix/tar.h glibc-1.03/posix/tar.h --- glibc-1.02/posix/tar.h +++ glibc-1.03/posix/tar.h Wed Apr 8 22:54:54 1992 @@ -0,0 +1,112 @@ +/* Extended tar format from POSIX.1. + Copyright (C) 1992 Free Software Foundation, Inc. + Written by David J. MacKenzie. + +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 _TAR_H + +#define _TAR_H 1 + + +/* A tar archive consists of 512-byte blocks. + Each file in the archive has a header block followed by 0+ data blocks. + Two blocks of NUL bytes indicate the end of the archive. */ + +/* The fields of header blocks: + All strings are stored as ISO 646 (approximately ASCII) strings. + + Fields are numeric unless otherwise noted below; numbers are ISO 646 + representations of octal numbers, with leading zeros as needed. + + linkname is only valid when typeflag==LNKTYPE. It doesn't use prefix; + files that are links to pathnames >100 chars long can not be stored + in a tar archive. + + If typeflag=={LNKTYPE,SYMTYPE,DIRTYPE} then size must be 0. + + devmajor and devminor are only valid for typeflag=={BLKTYPE,CHRTYPE}. + + chksum contains the sum of all 512 bytes in the header block, + treating each byte as an 8-bit unsigned value and treating the + 8 bytes of chksum as blank characters. + + uname and gname are used in preference to uid and gid, if those + names exist locally. + + Field Name Byte Offset Length in Bytes Field Type + name 0 100 NUL-terminated if NUL fits + mode 100 8 + uid 108 8 + gid 116 8 + size 124 12 + mtime 136 12 + chksum 148 8 + typeflag 156 1 see below + linkname 157 100 NUL-terminated if NUL fits + magic 257 6 must be TMAGIC (NUL term.) + version 263 2 must be TVERSION + uname 265 32 NUL-terminated + gname 297 32 NUL-terminated + devmajor 329 8 + devminor 337 8 + prefix 345 155 NUL-terminated if NUL fits + + If the first character of prefix is '\0', the file name is name; + otherwise, it is prefix/name. Files whose pathnames don't fit in that + length can not be stored in a tar archive. */ + +/* The bits in mode: */ +#define TSUID 04000 +#define TSGID 02000 +#define TSVTX 01000 +#define TUREAD 00400 +#define TUWRITE 00200 +#define TUEXEC 00100 +#define TGREAD 00040 +#define TGWRITE 00020 +#define TGEXEC 00010 +#define TOREAD 00004 +#define TOWRITE 00002 +#define TOEXEC 00001 + +/* The values for typeflag: + Values 'A'-'Z' are reserved for custom implementations. + All other values are reserved for future POSIX.1 revisions. */ + +#define REGTYPE '0' /* Regular file (preferred code). */ +#define AREGTYPE '\0' /* Regular file (alternate code). */ +#define LNKTYPE '1' /* Hard link. */ +#define SYMTYPE '2' /* Symbolic link (hard if not supported). */ +#define CHRTYPE '3' /* Character special. */ +#define BLKTYPE '4' /* Block special. */ +#define DIRTYPE '5' /* Directory. */ +#define FIFOTYPE '6' /* Named pipe. */ +#define CONTTYPE '7' /* Contiguous file */ + /* (regular file if not supported). */ + +/* Contents of magic field and its length. */ +#define TMAGIC "ustar" +#define TMAGLEN 6 + +/* Contents of the version field and its length. */ +#define TVERSION "00" +#define TVERSLEN 2 + + +#endif /* tar.h */ diff -Nru glibc-1.02/posix/unistd.h glibc-1.03/posix/unistd.h --- glibc-1.02/posix/unistd.h Tue Mar 17 18:07:22 1992 +++ glibc-1.03/posix/unistd.h Wed Apr 1 01:22:23 1992 @@ -204,6 +204,13 @@ big as necessary. */ extern char *EXFUN(getcwd, (char *__buf, size_t __size)); +#ifdef __USE_GNU +/* Return a malloc'd string containing the current directory name. + If the environment variable `PWD' is set, and its value is correct, + that value is used. */ +extern char *EXFUN(get_current_dir_name, (NOARGS)); +#endif + #ifdef __USE_BSD /* Put the absolute pathname of the current working directory in BUF. If successful, return BUF. If not, put an error message in @@ -419,7 +426,7 @@ If the calling process is the super-user, set the real and effective group IDs, and the saved set-group-ID to GID; if not, the effective group ID is set to GID. */ -extern int EXFUN(setgid, (int __gid)); +extern int EXFUN(setgid, (__gid_t __gid)); #ifdef __USE_BSD /* Set the real group ID of the calling process to RGID, diff -Nru glibc-1.02/posix/vfork.c glibc-1.03/posix/vfork.c --- glibc-1.02/posix/vfork.c Wed Jun 12 13:29:56 1991 +++ glibc-1.03/posix/vfork.c Wed Apr 1 01:22:28 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -21,5 +21,5 @@ #include #undef vfork -function_alias(vfork, __vfork, int, (), +function_alias(vfork, __vfork, __pid_t, (), DEFUN_VOID(vfork)) diff -Nru glibc-1.02/pwd/getpw.c glibc-1.03/pwd/getpw.c --- glibc-1.02/pwd/getpw.c Wed Jun 12 13:31:25 1991 +++ glibc-1.03/pwd/getpw.c Mon Apr 6 02:41:00 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -26,23 +26,23 @@ in the given buffer. This knows the format that the caller will expect, but this need not be the format of the password file. */ int -DEFUN(getpw, (uid, buf), int uid AND register char *buf) +DEFUN(getpw, (uid, buf), __uid_t uid AND register char *buf) { register struct passwd *p; - if (uid < 0 || buf == NULL) + if (buf == NULL) { errno = EINVAL; - return(-1); + return -1; } - p = getpwuid(uid); + p = getpwuid (uid); if (p == NULL) - return(-1); + return -1; - if (sprintf(buf, "%s:%s:%d:%d:%s:%s:%s", p->pw_name, p->pw_passwd, - p->pw_uid, p->pw_gid, p->pw_gecos, p->pw_dir, p->pw_shell) < 0) - return(-1); + if (sprintf (buf, "%s:%s:%u:%u:%s:%s:%s", p->pw_name, p->pw_passwd, + p->pw_uid, p->pw_gid, p->pw_gecos, p->pw_dir, p->pw_shell) < 0) + return -1; - return(0); + return 0; } diff -Nru glibc-1.02/pwd/putpwent.c glibc-1.03/pwd/putpwent.c --- glibc-1.02/pwd/putpwent.c Wed Jun 12 13:31:44 1991 +++ glibc-1.03/pwd/putpwent.c Mon Apr 6 02:53:28 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -30,11 +30,13 @@ if (p == NULL || stream == NULL) { errno = EINVAL; - return(-1); + return -1; } - if (fprintf(stream, "%s:%s:%d:%d:%s:%s\n", p->pw_name, p->pw_passwd, - p->pw_uid, p->pw_gid, p->pw_gecos, p->pw_shell) < 0) + if (fprintf (stream, "%s:%s:%u:%u:%s:%s\n", + p->pw_name, p->pw_passwd, + p->pw_uid, p->pw_gid, + p->pw_gecos, p->pw_shell) < 0) return(-1); return(0); diff -Nru glibc-1.02/setjmp/tst-setjmp.c glibc-1.03/setjmp/tst-setjmp.c --- glibc-1.02/setjmp/tst-setjmp.c Wed Jun 12 13:33:17 1991 +++ glibc-1.03/setjmp/tst-setjmp.c Thu Apr 9 21:35:19 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -53,7 +53,7 @@ jump(value + 1); } - if (lose) + if (lose || value != 10) puts("Test FAILED!"); else puts("Test succeeded!"); diff -Nru glibc-1.02/signal/Makefile glibc-1.03/signal/Makefile --- glibc-1.02/signal/Makefile Wed Feb 12 13:38:55 1992 +++ glibc-1.03/signal/Makefile Wed Apr 1 02:07:16 1992 @@ -31,6 +31,7 @@ __sigblock __sigstmsk __sigpause __sigvec \ sigstack sigintr \ sigempty sigfillset sigaddset sigdelset sigismem \ + sigret __sigret \ gsignal ssignal tests := tst-signal diff -Nru glibc-1.02/signal/kill.c glibc-1.03/signal/kill.c --- glibc-1.02/signal/kill.c Wed Jun 12 13:55:36 1991 +++ glibc-1.03/signal/kill.c Wed Apr 1 01:22:40 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -23,4 +23,4 @@ #undef kill function_alias(kill, __kill, int, (pid, sig), - DEFUN(kill, (pid, sig), int pid AND int sig)) + DEFUN(kill, (pid, sig), __pid_t pid AND int sig)) diff -Nru glibc-1.02/signal/signal.h glibc-1.03/signal/signal.h --- glibc-1.02/signal/signal.h Tue Dec 31 15:49:17 1991 +++ glibc-1.03/signal/signal.h Wed Apr 1 01:16:15 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -47,7 +47,7 @@ /* Send signal SIG to process number PID. If PID is zero, send SIG to all processes in the current process's process group. If PID is < -1, send SIG to all processes in process group - PID. */ -extern __pid_t EXFUN(__kill, (__pid_t __pid, int __sig)); +extern int EXFUN(__kill, (__pid_t __pid, int __sig)); #ifdef __USE_POSIX extern int EXFUN(kill, (int __pid, int __sig)); #ifdef __OPTIMIZE__ diff -Nru glibc-1.02/signal/sigret.c glibc-1.03/signal/sigret.c --- glibc-1.02/signal/sigret.c +++ glibc-1.03/signal/sigret.c Thu Apr 9 22:10:30 1992 @@ -0,0 +1,26 @@ +/* Copyright (C) 1992 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include + +#undef sigreturn + +function_alias(sigreturn, __sigreturn, int, (context), + DEFUN(sigreturn, (context), CONST struct sigcontext *context)) diff -Nru glibc-1.02/signal/tst-signal.c glibc-1.03/signal/tst-signal.c --- glibc-1.02/signal/tst-signal.c Thu Jan 24 15:29:09 1991 +++ glibc-1.03/signal/tst-signal.c Thu Apr 9 21:37:33 1992 @@ -35,10 +35,10 @@ if (!win) { - puts("Didn't get any signal."); + puts("Didn't get any signal. Test FAILED!"); exit(EXIT_FAILURE); } - puts("Got a signal."); + puts("Got a signal. Test succeeded."); exit(EXIT_SUCCESS); } diff -Nru glibc-1.02/stdio/Makefile glibc-1.03/stdio/Makefile --- glibc-1.02/stdio/Makefile Fri Mar 20 21:46:22 1992 +++ glibc-1.03/stdio/Makefile Mon Mar 30 16:15:06 1992 @@ -50,7 +50,8 @@ routines := $(strip $(routines)) aux := errlist siglist defs syms-stdio glue -tests := bug1 bug2 bug3 bug4 bug5 tst-printf tstscanf test_rdwr test-popen +tests := bug1 bug2 bug3 bug4 bug5 tst-printf tstscanf test_rdwr test-popen \ + tstgetline include ../Rules diff -Nru glibc-1.02/stdio/__getdelim.c glibc-1.03/stdio/__getdelim.c --- glibc-1.02/stdio/__getdelim.c Tue Mar 17 17:30:56 1992 +++ glibc-1.03/stdio/__getdelim.c Mon Mar 30 17:06:01 1992 @@ -95,6 +95,9 @@ } else { + /* Leave space for the terminating null. */ + --copy; + if (!stream->__seen || stream->__buffer == NULL || stream->__pushed_back) { /* Do one with getc to allocate a buffer. */ @@ -125,8 +128,8 @@ i = stream->__get_limit - stream->__bufp; } - if (i > copy - 1) - i = copy - 1; + if (i > copy) + i = copy; found = (char *) __memccpy ((PTR) p, stream->__bufp, terminator, i); if (found != NULL) @@ -151,6 +154,8 @@ *n = size; p = line + len; copy = size - len; + /* Leave space for the terminating null. */ + --copy; } } } diff -Nru glibc-1.02/stdio/bug1.c glibc-1.03/stdio/bug1.c --- glibc-1.02/stdio/bug1.c Mon Aug 26 16:22:08 1991 +++ glibc-1.03/stdio/bug1.c Thu Apr 9 22:47:24 1992 @@ -1,20 +1,28 @@ #include #include +#include int -main (void) +DEFUN_VOID(main) { char *bp; size_t size; FILE *stream; + int lose = 0; stream = open_memstream (&bp, &size); fprintf (stream, "hello"); fflush (stream); printf ("buf = %s, size = %d\n", bp, size); + lose |= size != 5; + lose |= strncmp (bp, "hello", size); fprintf (stream, ", world"); fclose (stream); printf ("buf = %s, size = %d\n", bp, size); + lose |= size != 12; + lose |= strncmp (bp, "hello, world", 12); - return 0; + puts (lose ? "Test FAILED!" : "Test succeeded."); + + return lose; } diff -Nru glibc-1.02/stdio/bug2.c glibc-1.03/stdio/bug2.c --- glibc-1.02/stdio/bug2.c Tue Feb 25 21:40:02 1992 +++ glibc-1.03/stdio/bug2.c Thu Apr 9 21:55:15 1992 @@ -2,9 +2,10 @@ #include int -main (void) +DEFUN_VOID(main) { int i; + puts ("This should print \"wow = I\" for I from 0 to 39 inclusive."); for (i = 0; i < 40; i++) printf ("%s = %d\n", "wow", i); return 0; diff -Nru glibc-1.02/stdio/bug3.c glibc-1.03/stdio/bug3.c --- glibc-1.02/stdio/bug3.c Fri Mar 6 18:51:35 1992 +++ glibc-1.03/stdio/bug3.c Thu Apr 9 22:43:48 1992 @@ -1,5 +1,6 @@ #include #include +#include int main () @@ -8,11 +9,44 @@ int i; f = fopen("bugtest", "w+"); - for (i=0; i<9000; i++) { - putc('x', f); - } - fseek(f, 8180L, 0); - fwrite("Where does this text go?", 1, 24, f); + for (i=0; i<9000; i++) + putc ('x', f); + fseek (f, 8180L, 0); + fwrite ("Where does this text go?", 1, 24, f); + fflush (f); + + rewind (f); + for (i=0; i<9000; i++) + { + int j; + + if ((j = getc(f)) != 'x') + { + if (i != 8180) + { + printf ("Test FAILED!"); + return 1; + } + else + { + char buf[25]; + + buf[0] = j; + fread (buf + 1, 1, 23, f); + buf[24] = '\0'; + if (strcmp (buf, "Where does this text go?") != 0) + { + printf ("%s\nTest FAILED!\n", buf); + return 1; + } + i += 23; + } + } + } + fclose(f); + + puts ("Test succeeded."); + return 0; } diff -Nru glibc-1.02/stdio/bug4.c glibc-1.03/stdio/bug4.c --- glibc-1.02/stdio/bug4.c Thu Mar 5 21:24:11 1992 +++ glibc-1.03/stdio/bug4.c Thu Apr 9 22:16:38 1992 @@ -3,6 +3,7 @@ #endif #include #include +#include int stdio_block_read = 1, stdio_block_write = 1; @@ -35,5 +36,15 @@ fread(buffer, 1, 31, f); fwrite(buffer, 1, 31, stdout); fclose(f); - return 0; + + if (!memcmp (buffer, "Where does this text come from?", 31)) + { + puts ("\nTest succeeded."); + return 0; + } + else + { + puts ("\nTest FAILED!"); + return 1; + } } diff -Nru glibc-1.02/stdio/bug5.c glibc-1.03/stdio/bug5.c --- glibc-1.02/stdio/bug5.c Fri Mar 6 18:51:21 1992 +++ glibc-1.03/stdio/bug5.c Thu Apr 9 21:54:43 1992 @@ -11,7 +11,7 @@ static char buf[8192]; int -main (int argc, char **argv) +DEFUN_VOID(main) { FILE *in; FILE *out; @@ -21,20 +21,39 @@ /* Create a test file. */ in = fopen (inname, "w+"); - if (in == NULL) perror (inname); + if (in == NULL) + { + perror (inname); + return 1; + } for (i = 0; i < 1000; ++i) fprintf (in, "%d\n", i); out = fopen (outname, "w"); - if (out == NULL) perror (outname); - if (fseek (in, 0L, SEEK_SET) != 0) abort (); + if (out == NULL) + { + perror (outname); + return 1; + } + if (fseek (in, 0L, SEEK_SET) != 0) + abort (); putc (getc (in), out); i = fread (buf, 1, sizeof (buf), in); - if (i == 0) perror (inname); - if (fwrite (buf, 1, i, out) != i) perror (outname); + if (i == 0) + { + perror ("fread"); + return 1; + } + if (fwrite (buf, 1, i, out) != i) + { + perror ("fwrite"); + return 1; + } fclose (in); fclose (out); + puts ("There should be no further output from this test."); + fflush (stdout); execlp ("cmp", "cmp", inname, outname, (char *) NULL); perror ("execlp: cmp"); exit (1); diff -Nru glibc-1.02/stdio/fgets.c glibc-1.03/stdio/fgets.c --- glibc-1.02/stdio/fgets.c Tue Mar 17 19:51:35 1992 +++ glibc-1.03/stdio/fgets.c Wed Apr 1 02:00:43 1992 @@ -48,7 +48,7 @@ while (--n > 0 && (c = getc (stream)) != EOF) if ((*p++ = c) == '\n') break; - if (c == EOF) + if (c == EOF && (p == s || ferror (stream))) return NULL; *p = '\0'; return s; @@ -58,7 +58,7 @@ --n; if (n > 0 && - !stream->__seen || stream->__buffer == NULL || stream->__pushed_back) + (!stream->__seen || stream->__buffer == NULL || stream->__pushed_back)) { /* Do one with getc to allocate a buffer. */ int c = getc (stream); @@ -87,6 +87,7 @@ if (c == EOF) break; *p++ = c; + --n; if (c == '\n') { *p = '\0'; @@ -112,7 +113,9 @@ p += i; } - if (p > s) - *p = '\0'; + if (p == s) + return NULL; + + *p = '\0'; return ferror (stream) ? NULL : s; } diff -Nru glibc-1.02/stdio/fopen.c glibc-1.03/stdio/fopen.c --- glibc-1.02/stdio/fopen.c Tue Mar 17 19:18:37 1992 +++ glibc-1.03/stdio/fopen.c Sat Mar 21 17:29:22 1992 @@ -24,7 +24,7 @@ #include -#define badmode() return((errno = EINVAL), 0) +#define badmode() return ((errno = EINVAL), 0) /* Dissect the given mode string into an __io_mode. */ int @@ -33,9 +33,9 @@ register unsigned char i; if (mode == NULL) - badmode(); + badmode (); - memset((PTR) mptr, 0, sizeof(*mptr)); + memset ((PTR) mptr, 0, sizeof (*mptr)); switch (*mode) { @@ -49,7 +49,7 @@ mptr->__read = 1; break; default: - badmode(); + badmode (); } for (i = 1; i < 3; ++i) @@ -69,7 +69,7 @@ } if (!mptr->__read && !mptr->__write) - badmode(); + badmode (); mptr->__exclusive = *mode == 'x'; @@ -91,20 +91,20 @@ return NULL; } - if (!__getmode(mode, &m)) + if (!__getmode (mode, &m)) return NULL; - stream = __newstream(); + stream = __newstream (); if (stream == NULL) return NULL; - cookie = __stdio_open(filename, m, &fd); + cookie = __stdio_open (filename, m, &fd); if (cookie == NULL) { if (fd < 0) { int save = errno; - (void) fclose(stream); + (void) fclose (stream); errno = save; return NULL; } diff -Nru glibc-1.02/stdio/fopncook.c glibc-1.03/stdio/fopncook.c --- glibc-1.02/stdio/fopncook.c Wed Jun 12 14:08:47 1991 +++ glibc-1.03/stdio/fopncook.c Sat Mar 21 17:31:29 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -31,10 +31,10 @@ __io_mode m; FILE *f; - if (!__getmode(mode, &m)) + if (!__getmode (mode, &m)) return NULL; - f = __newstream(); + f = __newstream (); if (f == NULL) return NULL; diff -Nru glibc-1.02/stdio/fread.c glibc-1.03/stdio/fread.c --- glibc-1.02/stdio/fread.c Thu Mar 5 17:06:11 1992 +++ glibc-1.03/stdio/fread.c Thu Mar 26 14:59:38 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -82,7 +82,8 @@ using a user-specified input buffer filling/expanding function, so we don't do it in that case. */ if (to_read >= stream->__bufsize && - stream->__room_funcs.__input == default_func) + stream->__room_funcs.__input == default_func && + stream->__offset == stream->__target) { /* Read directly into the user's buffer. */ if (stream->__io_funcs.__read != NULL) diff -Nru glibc-1.02/stdio/internals.c glibc-1.03/stdio/internals.c --- glibc-1.02/stdio/internals.c Fri Mar 6 20:20:46 1992 +++ glibc-1.03/stdio/internals.c Fri Mar 27 16:42:14 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -293,8 +293,11 @@ if ((*fp->__io_funcs.__write)(fp->__cookie, &cc, 1) < 1) fp->__error = 1; else - /* Record that we've moved forward in the file. */ - ++fp->__offset; + { + /* Record that we've moved forward in the file. */ + ++fp->__offset; + ++fp->__target; + } } else /* Just put C in the buffer. */ diff -Nru glibc-1.02/stdio/perror.c glibc-1.03/stdio/perror.c --- glibc-1.02/stdio/perror.c Tue Jan 14 21:36:23 1992 +++ glibc-1.03/stdio/perror.c Wed Mar 25 18:09:27 1992 @@ -20,11 +20,14 @@ #include #include +#ifndef HAVE_GNU_LD +#define _sys_errlist sys_errlist +#define _sys_nerr sys_nerr +#endif /* Defined in sys_errlist.c. */ extern CONST char *CONST _sys_errlist[]; extern CONST int _sys_nerr; - /* Print a line on stderr consisting of the text in S, a colon, a space, a message describing the meaning of the contents of `errno' and a newline. diff -Nru glibc-1.02/stdio/printf-prs.c glibc-1.03/stdio/printf-prs.c --- glibc-1.02/stdio/printf-prs.c Fri Jan 10 23:57:26 1992 +++ glibc-1.03/stdio/printf-prs.c Mon Mar 23 17:46:14 1992 @@ -23,6 +23,10 @@ #include #include +#ifdef __GNUC__ +#define HAVE_LONGLONG +#endif + extern printf_arginfo_function *__printf_arginfo_table[]; size_t @@ -117,7 +121,7 @@ break; case 'l': #ifdef HAVE_LONGLONG - if (is_long) + if (info.is_long) /* A double `l' is equivalent to an `L'. */ info.is_long_double = 1; else diff -Nru glibc-1.02/stdio/psignal.c glibc-1.03/stdio/psignal.c --- glibc-1.02/stdio/psignal.c Wed Jun 12 14:10:17 1991 +++ glibc-1.03/stdio/psignal.c Wed Apr 1 03:08:53 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -20,6 +20,10 @@ #include #include + +#ifndef HAVE_GNU_LD +#define _sys_siglist sys_siglist +#endif /* Defined in sys_siglist.c. */ extern CONST char *CONST _sys_siglist[]; diff -Nru glibc-1.02/stdio/test-popen.c glibc-1.03/stdio/test-popen.c --- glibc-1.02/stdio/test-popen.c Wed Aug 7 21:12:26 1991 +++ glibc-1.03/stdio/test-popen.c Thu Apr 9 22:02:26 1992 @@ -2,7 +2,8 @@ #include #include -void write_data (FILE *stream) +void +DEFUN(write_data, (stream), FILE *stream) { int i; for (i=0; i<100; i++) @@ -13,20 +14,51 @@ } } -void main (void) +void +DEFUN(read_data, (stream), FILE *stream) { - FILE *output; + int i, j; + + for (i=0; i<100; i++) + { + if (fscanf (stream, "%d\n", &j) != 1 || j != i) + { + if (ferror (stream)) + perror ("fscanf"); + puts ("Test FAILED!"); + exit (1); + } + } +} + +int +DEFUN_VOID(main) +{ + FILE *output, *input; int status; - output = popen ("/usr/ucb/more", "w"); - if (!output) { - fprintf (stderr, "Could not run more.\n"); - exit (1); + output = popen ("/bin/cat >tstpopen.tmp", "w"); + if (output == NULL) + { + perror ("popen"); + puts ("Test FAILED!"); + exit (1); } write_data (output); status = pclose (output); fprintf (stderr, "pclose returned %d\n", status); - exit (0); + input = fopen ("tstpopen.tmp", "r"); + if (input == NULL) + { + perror ("tstpopen.tmp"); + puts ("Test FAILED!"); + exit (1); + } + read_data (input); + (void) fclose (input); + + puts (status ? "Test FAILED!" : "Test succeeded."); + exit (status); } diff -Nru glibc-1.02/stdio/tst-printf.c glibc-1.03/stdio/tst-printf.c --- glibc-1.02/stdio/tst-printf.c Tue Mar 17 18:07:12 1992 +++ glibc-1.03/stdio/tst-printf.c Mon Apr 6 22:24:10 1992 @@ -108,6 +108,9 @@ printf("g-style < .1:\t\"%g\"\n", 0.001234); printf("g-style big:\t\"%.60g\"\n", 1e20); + printf (" %6.5lf\n", .099999999860301614); + printf (" %6.5lf\n", .1); + #define FORMAT "|%12.4f|%12.4e|%12.4g|\n" printf (FORMAT, 0.0, 0.0, 0.0); printf (FORMAT, 1.0, 1.0, 1.0); diff -Nru glibc-1.02/stdio/tstgetline.c glibc-1.03/stdio/tstgetline.c --- glibc-1.02/stdio/tstgetline.c +++ glibc-1.03/stdio/tstgetline.c Mon Mar 30 17:18:36 1992 @@ -0,0 +1,46 @@ +/* Copyright (C) 1992 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include + +int +DEFUN_VOID(main) +{ + char *buf = NULL; + size_t size = 0; + ssize_t len; + + while ((len = getline (&buf, &size, stdin)) != -1) + { + printf ("bufsize %u; read %d: ", size, len); + if (fwrite (buf, len, 1, stdout) != 1) + { + perror ("fwrite"); + return 1; + } + } + + if (ferror (stdin)) + { + perror ("getline"); + return 1; + } + + return 0; +} diff -Nru glibc-1.02/stdio/tstgetline.input glibc-1.03/stdio/tstgetline.input --- glibc-1.02/stdio/tstgetline.input +++ glibc-1.03/stdio/tstgetline.input Mon Mar 30 16:15:51 1992 @@ -0,0 +1,3 @@ +xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy +z diff -Nru glibc-1.02/stdlib/Makefile glibc-1.03/stdlib/Makefile --- glibc-1.02/stdlib/Makefile Tue Mar 17 16:30:02 1992 +++ glibc-1.03/stdlib/Makefile Mon Mar 30 20:45:17 1992 @@ -37,6 +37,6 @@ system distribute := exit.h -tests := tst-strtol tst-strtod abortme +tests := tst-strtol tst-strtod include ../Rules diff -Nru glibc-1.02/stdlib/abortme.c glibc-1.03/stdlib/abortme.c --- glibc-1.02/stdlib/abortme.c Tue Mar 17 16:28:32 1992 +++ glibc-1.03/stdlib/abortme.c @@ -1,9 +0,0 @@ -#include -#include - -int -DEFUN_VOID(main) -{ - abort (); - return 1; -} diff -Nru glibc-1.02/stdlib/alloca.h glibc-1.03/stdlib/alloca.h --- glibc-1.02/stdlib/alloca.h Mon Feb 17 02:09:44 1992 +++ glibc-1.03/stdlib/alloca.h Wed Apr 1 01:26:05 1992 @@ -23,7 +23,8 @@ #define __need_size_t #include -/* Remove any previous definition. */ +/* Remove any previous definitions. */ +#undef __alloca #undef alloca /* Allocate a block that will be freed when the calling function exits. */ @@ -34,8 +35,6 @@ #define __alloca(size) __builtin_alloca(size) #endif /* GCC. */ -#ifdef __OPTIMIZE__ #define alloca(size) __alloca(size) -#endif /* Optimizing. */ #endif /* alloca.h */ diff -Nru glibc-1.02/string/Makefile glibc-1.03/string/Makefile --- glibc-1.02/string/Makefile Tue Feb 25 21:34:23 1992 +++ glibc-1.03/string/Makefile Fri Mar 27 16:47:56 1992 @@ -21,7 +21,7 @@ # subdir := string -headers := string.h strings.h bstring.h memory.h +headers := string.h strings.h bstring.h memory.h endian.h routines := strcat strchr strcmp strcoll strcpy strcspn strdup \ strerror strlen strncat strncmp strncpy strpbrk \ diff -Nru glibc-1.02/string/strerror.c glibc-1.03/string/strerror.c --- glibc-1.02/string/strerror.c Wed Jun 12 14:20:04 1991 +++ glibc-1.03/string/strerror.c Wed Mar 25 18:09:41 1992 @@ -20,11 +20,14 @@ #include #include +#ifndef HAVE_GNU_LD +#define _sys_errlist sys_errlist +#define _sys_nerr sys_nerr +#endif /* Defined in stdio/sys_errlist.c. */ extern CONST char *CONST _sys_errlist[]; extern CONST int _sys_nerr; - /* Return a string descibing the errno code in ERRNUM. The storage is good only until the next call to strerror. diff -Nru glibc-1.02/string/strsignal.c glibc-1.03/string/strsignal.c --- glibc-1.02/string/strsignal.c Wed Jun 12 14:20:24 1991 +++ glibc-1.03/string/strsignal.c Wed Apr 1 03:08:50 1992 @@ -22,7 +22,11 @@ #include -/* Defined in stdio/sys_siglist.c. */ +#ifndef HAVE_GNU_LD +#define _sys_siglist sys_siglist +#endif + +/* Defined in , 1992siglist.c. */ extern CONST char *CONST _sys_siglist[]; diff -Nru glibc-1.02/string/testcopy.c glibc-1.03/string/testcopy.c --- glibc-1.02/string/testcopy.c Tue Mar 17 19:01:45 1992 +++ glibc-1.03/string/testcopy.c Thu Apr 9 22:19:48 1992 @@ -20,6 +20,7 @@ #include #include +#include #include #include @@ -103,6 +104,8 @@ } } } + + puts ("Test succeeded."); return 0; } diff -Nru glibc-1.02/sysdeps/generic/Dist glibc-1.03/sysdeps/generic/Dist --- glibc-1.02/sysdeps/generic/Dist Tue Dec 10 00:05:01 1991 +++ glibc-1.03/sysdeps/generic/Dist Wed Apr 1 03:18:26 1992 @@ -1,3 +1,4 @@ +make_siglist.c signame.c signame.h det_endian.c ../../math/bsd/common_source/mathimpl.h ../../math/bsd/common/trig.h diff -Nru glibc-1.02/sysdeps/generic/Makefile glibc-1.03/sysdeps/generic/Makefile --- glibc-1.02/sysdeps/generic/Makefile Fri Mar 6 19:32:57 1992 +++ glibc-1.03/sysdeps/generic/Makefile Wed Apr 1 03:13:11 1992 @@ -1,3 +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. + ifeq ($(subdir),math) ifndef math-twiddled @@ -12,7 +30,7 @@ bsdmath_dirs := $(bsdmath_dirs) common common_source endif - + ifeq ($(subdir),string) dont_distribute := $(dont_distribute) endian.h # Generated. endif @@ -22,6 +40,21 @@ mv $@-tmp $@ $(objpfx)det_endian: $(sysdep_dir)/generic/det_endian.c - $(CC) $< -o $@ + cd $(objdir); $(CC) $(<:$(objpfx)%=%) -o $(@:$(objpfx)%=%) before-compile := $(before-compile) $(objpfx)endian.h + +ifeq ($(subdir),stdio) + +ifeq "$(filter $(objpfx)siglist.c,$(before-compile))" "" +before-compile := $(before-compile) $(objpfx)siglist.c +$(objpfx)siglist.c: $(objpfx)make_siglist + @rm -f $@ + $< > $@-tmp + mv $@-tmp $@ + +$(objpfx)make_siglist: $(sysdep_dir)/generic/make_siglist.c + cd $(objdir); $(CC) $< -o $(@:$(objpfx)%=%) +endif + +endif diff -Nru glibc-1.02/sysdeps/generic/__lstat.c glibc-1.03/sysdeps/generic/__lstat.c --- glibc-1.02/sysdeps/generic/__lstat.c Thu Mar 5 17:16:11 1992 +++ glibc-1.03/sysdeps/generic/__lstat.c Fri Mar 27 16:50:07 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -20,6 +20,7 @@ #include #include #include +#include function_alias (__lstat, __stat, int, (file, buf), DEFUN(__lstat, (file, buf), diff -Nru glibc-1.02/sysdeps/generic/frexp.c glibc-1.03/sysdeps/generic/frexp.c --- glibc-1.02/sysdeps/generic/frexp.c Wed Jun 12 14:22:19 1991 +++ glibc-1.03/sysdeps/generic/frexp.c Mon Mar 30 17:30:53 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -24,6 +24,8 @@ double DEFUN(frexp, (value, exp), double value AND int *exp) { - *exp = (int) __logb(value); - return value / ldexp(1.0, *exp); + /* Add one to the exponent of the number, + so we have one digit before the binary point. */ + *exp = (int) __logb (value) + 1; + return ldexp (value, - *exp); } diff -Nru glibc-1.02/sysdeps/generic/make_siglist.c glibc-1.03/sysdeps/generic/make_siglist.c --- glibc-1.02/sysdeps/generic/make_siglist.c +++ glibc-1.03/sysdeps/generic/make_siglist.c Wed Apr 1 03:10:28 1992 @@ -0,0 +1,52 @@ +/* Copyright (C) 1991, 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 General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with the GNU C Library; see the file COPYING. If not, write to +the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include +#include + + +/* Make a definition for sys_siglist. */ + + +#undef SYS_SIGLIST_MISSING +#include "signame.c" + + +int +main() +{ + register int i; + + init_sigs (); + + puts ("#include \"ansidecl.h\"\n#include \n"); + + puts ("#ifndef HAVE_GNU_LD"); + puts ("#define _sys_siglist\tsys_siglist"); + puts ("#endif"); + + puts ("\n/* This is a list of all known signal numbers. */"); + + puts ("\nCONST char *CONST _sys_siglist[] =\n {"); + + for (i = 0; i < NSIG; ++i) + printf (" \"%s\",\n", sys_siglist[i]); + + puts (" NULL\n };\n"); + + exit (0); +} diff -Nru glibc-1.02/sysdeps/generic/memcmp.c glibc-1.03/sysdeps/generic/memcmp.c --- glibc-1.02/sysdeps/generic/memcmp.c Wed Aug 7 19:56:05 1991 +++ glibc-1.03/sysdeps/generic/memcmp.c Wed Apr 1 14:27:44 1992 @@ -77,7 +77,7 @@ len -= 1; if (OP_T_THRES <= 3 * OPSIZ && len == 0) goto do0; - /* Fall through to do4. */ + /* Fall through. */ } do @@ -106,7 +106,6 @@ if (res != 0) return res; - do0: srcp1 += 4 * OPSIZ; srcp2 += 4 * OPSIZ; len -= 4; @@ -113,6 +112,9 @@ } while (len != 0); + /* This is the right position for do0. Please don't move + it into the loop. */ + do0: return a1 - b1; } @@ -177,7 +179,7 @@ len -= 1; if (OP_T_THRES <= 3 * OPSIZ && len == 0) goto do0; - /* Fall through to do4. */ + /* Fall through. */ } do @@ -210,7 +212,6 @@ if (res != 0) return res; - do0: srcp1 += 4 * OPSIZ; srcp2 += 4 * OPSIZ; len -= 4; @@ -217,6 +218,9 @@ } while (len != 0); + /* This is the right position for do0. Please don't move + it into the loop. */ + do0: x = MERGE(a2, shl, a3, shr); return x - b3; } diff -Nru glibc-1.02/sysdeps/generic/printf_fp.c glibc-1.03/sysdeps/generic/printf_fp.c --- glibc-1.02/sysdeps/generic/printf_fp.c Fri Aug 2 01:05:18 1991 +++ glibc-1.03/sysdeps/generic/printf_fp.c Thu Apr 9 01:43:26 1992 @@ -1,4 +1,10 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Floating-point printing for `printf'. + This is an implementation of a restricted form of the `Dragon4' + algorithm described in "How to Print Floating-Point Numbers Accurately", + by Guy L. Steele, Jr. and Jon L. White, presented at the ACM SIGPLAN '90 + Conference on Programming Language Design and Implementation. + +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 @@ -37,6 +43,36 @@ ++done; \ } while (0) +#if FLT_RADIX != 2 + +double +frexp (double f, int *e) +{ + #error "Don't know how to extract fraction and exponent from `double'." +} + +#undef ldexp +#ifdef __GNUC__ +inline +#endif +static double +ldexp (double f, int e) +{ + while (e > 0) + { + f *= FLT_RADIX; + --e; + } + while (e < 0) + { + f /= FLT_RADIX; + ++e; + } +} + +#endif + + int DEFUN(__printf_fp, (s, info, args), FILE *s AND CONST struct printf_info *info AND va_list *args) @@ -43,35 +79,48 @@ { int done = 0; - LONG_DOUBLE fpnum; - double fpart, ipart; - int exp; + /* Decimal point character. */ + CONST char *CONST decimal = _numeric_info->decimal_point; + + LONG_DOUBLE fpnum; /* Input. */ int is_neg; - int showdot; - char ework[30]; - char *CONST eworkend = &ework[sizeof(ework) - 1]; - char fwork[LDBL_DIG]; - char iwork[LDBL_DIG + (LDBL_MAX_10_EXP > -LDBL_MIN_10_EXP ? - LDBL_MAX_10_EXP : -LDBL_MIN_10_EXP)]; - char *iworkend = &iwork[sizeof(iwork) - 1]; - register char *fw, *ew, *iw; + LONG_DOUBLE f; /* Fraction. */ - /* Decimal point character. */ - CONST char *CONST decimal = _numeric_info->decimal_point; + int e; /* Base-2 exponent of the input. */ + CONST int p = DBL_MANT_DIG; /* Internal precision. */ + LONG_DOUBLE scale, scale10; /* Scale factor. */ + LONG_DOUBLE loerr, hierr; /* Potential error in the fraction. */ + int k; /* Digits to the left of the decimal point. */ + int cutoff; /* Where to stop generating digits. */ + LONG_DOUBLE r, r2, r10; /* Remainder. */ + int roundup; + int low, high; + char digit; + + int j; - char type = tolower(info->spec); - CONST char pad = info->pad; + char type = tolower (info->spec); int prec = info->prec; int width = info->width; + /* This algorithm has the nice property of not needing a buffer. + However, to get the padding right for %g format, we need to know + the length of the number before printing it. */ + char *buf = __alloca ((prec > LDBL_DIG ? prec : LDBL_DIG) + + LDBL_MAX_10_EXP + 3); /* Dot, e, exp. sign. */ + register char *bp = buf; +#define put(c) *bp++ = (c) + + /* Fetch the argument value. */ if (info->is_long_double) - fpnum = va_arg(*args, LONG_DOUBLE); + fpnum = va_arg (*args, LONG_DOUBLE); else - fpnum = (LONG_DOUBLE) va_arg(*args, double); + fpnum = (LONG_DOUBLE) va_arg (*args, double); #ifdef HANDLE_SPECIAL - HANDLE_SPECIAL(done, s, info, fpnum); + /* Allow for machine-dependent (or floating point format-dependent) code. */ + HANDLE_SPECIAL (done, s, info, fpnum); #endif #ifndef IS_NEGATIVE @@ -78,7 +127,7 @@ #define IS_NEGATIVE(num) ((num) < 0) #endif - is_neg = IS_NEGATIVE(fpnum); + is_neg = IS_NEGATIVE (fpnum); if (is_neg) fpnum = - fpnum; @@ -90,279 +139,361 @@ if (prec == 0) prec = 1; - if (fpnum == 0 || fpnum >= 1e-4 && fpnum < pow(10.0, (double) prec)) - type = 'f'; + if (fpnum != 0) + { + if (fpnum < 1e-4) + type = 'e'; + else + { + f = 10; + j = prec; + if (j > p) + j = p; + while (--j > 0) + { + f *= 10; + if (f > fpnum) + { + type = 'e'; + break; + } + } + } + } /* For 'g'/'G' format, the precision specifies "significant digits", not digits to come after the decimal point. */ - --prec; + --prec; } - - /* Break FPNUM into fractional and integral parts. */ - fpart = modf((double) fpnum, &ipart); - - /* Initialize the exponent to zero. */ - exp = 0; - /* Convert the fractional part into FWORK. */ - fw = fwork; - if (fpart != 0.0) + if (fpnum == 0) + /* Special case for zero. + The general algorithm does not work for zero. */ + { + put ('0'); + if (tolower (info->spec) != 'g' || info->alt) + { + if (prec > 0 || info->alt) + put (*decimal); + while (--prec > 0) + put ('0'); + } + if (type == 'e') + { + put (info->spec); + put ('+'); + put ('0'); + put ('0'); + } + } + else { - int p = prec; + /* Split the number into a fraction and base-2 exponent. */ + f = frexp (fpnum, &e); + + /* Scale the fractional part by the highest possible number of + significant bits of fraction. We want to represent the + fractional part as a (very) large integer. */ + f = ldexp (f, p); + + cutoff = -prec; + + roundup = 0; - /* Decrement EXP for each leading zero. */ - while (fpart != 0) + if (e > p) { - double digit; - fpart = modf(fpart * 10.0, &digit); - if (digit == 0) - --exp; - else - { - /* Found the first nonzero digit. */ - *fw++ = '0' + (unsigned int) digit; - --p; - break; - } + /* The exponent is bigger than the number of fractional digits. */ + r = ldexp (f, e - p); + scale = 1; + /* The number is (E - P) factors of two larger than + the fraction can represent; this is the potential error. */ + loerr = ldexp (1.0, e - p); + } + else + { + /* The number of fractional digits is greater than the exponent. + Scale by the difference factors of two. */ + r = f; + scale = ldexp (1.0, p - e); + loerr = 1.0; } + hierr = loerr; + + /* Fixup. */ - if (type == 'f') - /* In %f format, the leading zeros count - towards filling the precision. */ - p -= - exp; - - /* Convert the digits remaining up to the precision. */ - while (fpart != 0.0 && p-- > 0) - { - double digit; - fpart = modf(fpart * 10.0, &digit); - *fw++ = '0' + (unsigned int) digit; + if (f == ldexp (1.0, p - 1)) + { + /* Account for unequal gaps. */ + hierr = ldexp (hierr, 1); + r = ldexp (r, 1); + scale = ldexp (scale, 1); } - if (fpart != 0.0) + scale10 = ceil (scale / 10.0); + k = 0; + while (r < scale10) { - /* The fractional part has more digits than - the precision, so we need to round it. */ - double digit; - (void) modf(fpart * 10.0, &digit); - if ((unsigned int) digit >= 5) - { - /* Round up. */ + --k; + r *= 10; + loerr *= 10; + hierr *= 10; + } + do + { + r2 = 2 * r; - if (prec == 0) - /* We're not printing any fractional digits, - so bump the integer part. */ - ++ipart; - else - { - register char *p = fw - 1; - while (*p == '9' && p > fwork) - *p-- = '0'; - if (*p == '9' && p == fwork) - { - /* 123.9999999... rounded up to 124; - increment the integer part and - zero the fractional part. */ - ++ipart; - *p = '0'; - } - else - ++*p; - } + while (r2 + hierr >= 2 * scale) + { + scale *= 10; + ++k; } - } - /* Record in PREC how many digits we have converted. */ - prec -= fw - fwork; - } + /* Perform any necessary adjustment of loerr and hierr to + take into account the formatting requirements. */ - /* Convert the integer part into IWORK. */ - iw = iworkend; - if (ipart == 0) - /* Make sure there is a digit before the decimal point. */ - *iw-- = '0'; - else - { - while (ipart != 0) + if (type == 'e') + cutoff += k; /* CutOffMode == "relative". */ + /* Otherwise CutOffMode == "absolute". */ + + { /* CutOffAdjust. */ + int a = cutoff - k; + double y = scale; + while (a > 0) + { + y *= 10; + --a; + } + while (a < 0) + { + y = ceil (y / 10); + ++a; + } + /* y == ceil (scale * pow (10.0, (double) (cutoff - k))) */ + if (y > loerr) + loerr = y; + if (y > hierr) + { + hierr = y; + roundup = 1; + } + } /* End CutOffAdjust. */ + } while (r2 + hierr >= 2 * scale); + + /* End Fixup. */ + + /* First digit. */ + --k; + r10 = r * 10; + digit = '0' + (unsigned int) floor (r10 / scale); + r = fmod (r10, scale); + loerr *= 10; + hierr *= 10; + + low = 2 * r < loerr; + if (roundup) + high = 2 * r >= (2 * scale) - hierr; + else + high = 2 * r > (2 * scale) - hierr; + + if (low || high || k == cutoff) { - *iw-- = '0' + (unsigned int) ((modf(ipart / 10, &ipart) + .01) * 10); - - /* Increment the exponent to account for this decimal place. */ - ++exp; + if ((high && !low) || (2 * r > scale)) + ++digit; } - /* The exponent now accounts for each digit converted. - We don't want to count the first digit, so decrement it. */ - --exp; - } + if (type == 'e') + { + /* Exponential notation. */ - if (type != 'f') - { - /* The digits of IPART after the first are in the fractional part. */ - prec -= (iworkend - iw) - 1; + int expt = k; /* Base-10 exponent. */ - if (prec < 0) - { - /* We have converted more digits than the precision specifies. */ + /* Find the magnitude of the exponent. */ + j = 1; + do + j *= 10; + while (j <= expt); - if (- prec >= fw - fwork) - { - /* All of FWORK is excess precision. Toss FWORK, - and round the value printed in IWORK as necessary. */ + /* Write the first digit. */ + put (digit); - prec += fw - fwork; - fw = fwork; + if (low || high || k == cutoff) + { + if (prec > 0 || info->alt) + put (*decimal); + } + else + { + put (*decimal); - if (prec < 0) + /* First post-decimal digit. */ + --k; + r10 = r * 10; + digit = '0' + (unsigned int) floor (r10 / scale); + r = fmod (r10, scale); + loerr *= 10; + hierr *= 10; + + low = 2 * r < loerr; + if (roundup) + high = 2 * r >= (2 * scale) - hierr; + else + high = 2 * r > (2 * scale) - hierr; + + if (low || high || k == cutoff) + { + if ((high && !low) || (2 * r > scale)) + ++digit; + put (digit); + } + else { - /* Still more rounding to be done. */ - iworkend -= - prec; - if (*iworkend - '0' >= 5) + put (digit); + + /* Remaining digits. */ + while (1) { - /* Round up. */ - register char *p = iworkend; - while (*p == '9' && p > iw) - *p-- = '0'; - if (*p == '9' && p == iw) + --k; + r10 = r * 10; + digit = '0' + (unsigned int) floor (r10 / scale); + r = fmod (r10, scale); + loerr *= 10; + hierr *= 10; + + low = 2 * r < loerr; + if (roundup) + high = 2 * r >= (2 * scale) - hierr; + else + high = 2 * r > (2 * scale) - hierr; + + if (low || high || k == cutoff) { - *p = '0'; - *iw-- = '1'; + if ((high && !low) || (2 * r > scale)) + ++digit; + put (digit); + break; } - else - ++*p; + + put (digit); } } } - else - { - /* Round -PREC digits off the value printed in FWORK. */ - fw -= (-prec) - 1; - if (*fw - '0' >= 5) - { - /* Round up. */ - register char *p = fw - 1; - while (*p == '9' && p > fwork) - *p-- = '0'; - ++*p; - } - if (type == 'g' && !info->alt) - /* Trim trailing zeros. */ - while (fw > fwork && fw[-1] == '0') - --fw; + if (tolower (info->spec) != 'g' || info->alt) + /* Pad with zeros. */ + while (k-- >= cutoff) + put ('0'); + + /* Write the exponent. */ + put (isupper (info->spec) ? 'E' : 'e'); + put (expt < 0 ? '-' : '+'); + expt = abs (expt); + if (expt < 10) + /* Exponent always has at least two digits. */ + put ('0'); + do + { + j /= 10; + put ('0' + (expt / j)); + expt %= j; } - - prec = 0; + while (j > 1); } - } - - if (!info->alt && tolower(info->spec) == 'g') - { - /* Remove trailing zeros from the fractional part. */ - while (fw > fwork && fw[-1] == '0') - --fw; - if (type != 'f' && fw == fwork) - /* All but the first digit in IWORK is also in the fractional part. - Remove trailing zeros there as well. */ - while (iworkend > iw + 1 && *iworkend == '0') - --iworkend; + else + { + /* Decimal fraction notation. */ - /* Make sure we don't add more zeros for the precision. */ - prec = 0; - } + if (k < 0) + { + put ('0'); + if (prec > 0 || info->alt) + put (*decimal); + } - showdot = (info->alt || fw > fwork || prec > 0 || - (type == 'f' ? exp < 0 : iworkend - iw > 1)); + /* Write leading fractional zeros. */ + j = 0; + while (--j > k) + put ('0'); - ew = eworkend; - if (type != 'f') - { - /* Convert the exponent in EWORK. */ - CONST int eneg = exp < 0; - if (eneg) - exp = - exp; - while (exp > 0) - { - *ew-- = '0' + (exp % 10); - exp /= 10; + if (low || high || k == cutoff) + put (digit); + else + while (1) + { + put (digit); + + --k; + digit = '0' + (unsigned int) floor ((r * 10) / scale); + r = fmod (r * 10, scale); + loerr *= 10; + hierr *= 10; + + low = 2 * r < loerr; + if (roundup) + high = 2 * r >= (2 * scale) - hierr; + else + high = 2 * r > (2 * scale) - hierr; + + if (low || high || k == cutoff) + { + if ((high && !low) || (2 * r > scale)) + ++digit; + put (digit); + break; + } + + if (k == -1) + put (*decimal); + } + while (k > 0) + { + put ('0'); + --k; + } + if (k == 0 && (prec > 0 || info->alt)) + { + put (*decimal); + while (prec-- > 0) + put ('0'); + } } - /* Add leading zeros to ensure at least two digits. */ - while (eworkend - ew < 2) - *ew-- = '0'; - *ew-- = eneg ? '-' : '+'; - *ew-- = isupper(info->spec) ? 'E' : 'e'; } - width -= iworkend - iw; - if (showdot) - --width; - width -= prec; - width -= fw - fwork; - width -= eworkend - ew; +#undef put + + /* The number is all converted in BUF. + Now write it with sign and appropriate padding. */ if (is_neg || info->showsign || info->space) --width; - if (!info->left && pad == ' ') + width -= bp - buf; + + if (!info->left && info->pad == ' ') + /* Pad with spaces on the left. */ while (width-- > 0) - outchar(' '); + outchar (' '); + /* Write the sign. */ if (is_neg) - outchar('-'); + outchar ('-'); else if (info->showsign) - outchar('+'); + outchar ('+'); else if (info->space) - outchar(' '); + outchar (' '); - if (!info->left && pad == '0') + if (!info->left && info->pad == '0') + /* Pad with zeros on the left. */ while (width-- > 0) - outchar('0'); - - if (type == 'f') - { - /* Write the integral part. */ - while (++iw <= iworkend) - outchar(*iw); - if (showdot) - { - /* Write the dot and the leading zeros of the fractional part. */ - outchar(*decimal); - while (exp++ < 0) - outchar ('0'); - } - } - else - { - /* Write the first digit of the integer part. */ - outchar(*++iw); - if (showdot) - { - /* Write the decimal point and the remaining digits of IPART, - which EXP makes the beginning of the fractional part. */ - outchar (*decimal); - while (++iw <= iworkend) - outchar (*iw); - } - } + outchar ('0'); - /* Write the fractional part. */ - { - register CONST char *p; - for (p = fwork; p < fw; ++p) - outchar(*p); - } - - /* Pad with zeros to the precision. */ - while (prec-- > 0) - outchar ('0'); - - /* Write the exponent. */ - while (++ew <= eworkend) - outchar(*ew); + if (fwrite (buf, bp - buf, 1, s) != 1) + return -1; + done += bp - buf; if (info->left) + /* Pad with spaces on the right. */ while (width-- > 0) - outchar(' '); + outchar (' '); return done; } diff -Nru glibc-1.02/sysdeps/generic/signame.c glibc-1.03/sysdeps/generic/signame.c --- glibc-1.02/sysdeps/generic/signame.c +++ glibc-1.03/sysdeps/generic/signame.c Mon Jun 3 19:37:23 1991 @@ -0,0 +1,248 @@ +/* Convert between signal names and numbers. + Copyright (C) 1990 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; see the file COPYING. If not, write to +the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include +#include +#include "signame.h" + +#ifdef __STDC__ +#define CONST const +#else +#define CONST +#endif + +#ifdef SYS_SIGLIST_MISSING +/* There is too much variation in Sys V signal numbers and names, so + we must initialize them at runtime. */ + +static CONST char undoc[] = "unknown signal"; + +CONST char *sys_siglist[NSIG]; +#endif /* SYS_SIGLIST_MISSING */ + +/* Table of abbreviations for signals. Note: A given number can + appear more than once with different abbreviations. */ +typedef struct + { + int number; + CONST char *abbrev; + } num_abbrev; +static num_abbrev sig_table[NSIG*2]; +/* Number of elements of sig_table used. */ +static int sig_table_nelts = 0; + +/* Enter signal number NUMBER into the tables with ABBREV and NAME. */ +static void +init_sig (number, abbrev, name) + int number; + CONST char *abbrev; + CONST char *name; +{ +#ifdef SYS_SIGLIST_MISSING + sys_siglist[number] = name; +#endif + sig_table[sig_table_nelts].number = number; + sig_table[sig_table_nelts++].abbrev = abbrev; +} + +static void +init_sigs () +{ +#ifdef SYS_SIGLIST_MISSING + int i; + /* Initialize signal names. */ + for (i = 0; i < NSIG; i++) + sys_siglist[i] = undoc; +#endif /* SYS_SIGLIST_MISSING */ + + /* Initialize signal names. */ +#if defined (SIGHUP) + init_sig (SIGHUP, "HUP", "Hangup"); +#endif +#if defined (SIGINT) + init_sig (SIGINT, "INT", "Interrupt"); +#endif +#if defined (SIGQUIT) + init_sig (SIGQUIT, "QUIT", "Quit"); +#endif +#if defined (SIGILL) + init_sig (SIGILL, "ILL", "Illegal Instruction"); +#endif +#if defined (SIGTRAP) + init_sig (SIGTRAP, "TRAP", "Trace/breakpoint trap"); +#endif + /* If SIGIOT == SIGABRT, we want to print it as SIGABRT because + SIGABRT is in ANSI and POSIX.1 and SIGIOT isn't. */ +#if defined (SIGABRT) + init_sig (SIGABRT, "ABRT", "Aborted"); +#endif +#if defined (SIGIOT) + init_sig (SIGIOT, "IOT", "IOT trap"); +#endif +#if defined (SIGEMT) + init_sig (SIGEMT, "EMT", "EMT trap"); +#endif +#if defined (SIGFPE) + init_sig (SIGFPE, "FPE", "Floating point exception"); +#endif +#if defined (SIGKILL) + init_sig (SIGKILL, "KILL", "Killed"); +#endif +#if defined (SIGBUS) + init_sig (SIGBUS, "BUS", "Bus error"); +#endif +#if defined (SIGSEGV) + init_sig (SIGSEGV, "SEGV", "Segmentation fault"); +#endif +#if defined (SIGSYS) + init_sig (SIGSYS, "SYS", "Bad system call"); +#endif +#if defined (SIGPIPE) + init_sig (SIGPIPE, "PIPE", "Broken pipe"); +#endif +#if defined (SIGALRM) + init_sig (SIGALRM, "ALRM", "Alarm clock"); +#endif +#if defined (SIGTERM) + init_sig (SIGTERM, "TERM", "Terminated"); +#endif +#if defined (SIGUSR1) + init_sig (SIGUSR1, "USR1", "User defined signal 1"); +#endif +#if defined (SIGUSR2) + init_sig (SIGUSR2, "USR2", "User defined signal 2"); +#endif + /* If SIGCLD == SIGCHLD, we want to print it as SIGCHLD because that + is what is in POSIX.1. */ +#if defined (SIGCHLD) + init_sig (SIGCHLD, "CHLD", "Child exited"); +#endif +#if defined (SIGCLD) + init_sig (SIGCLD, "CLD", "Child exited"); +#endif +#if defined (SIGPWR) + init_sig (SIGPWR, "PWR", "Power failure"); +#endif +#if defined (SIGTSTP) + init_sig (SIGTSTP, "TSTP", "Stopped"); +#endif +#if defined (SIGTTIN) + init_sig (SIGTTIN, "TTIN", "Stopped (tty input)"); +#endif +#if defined (SIGTTOU) + init_sig (SIGTTOU, "TTOU", "Stopped (tty output)"); +#endif +#if defined (SIGSTOP) + init_sig (SIGSTOP, "STOP", "Stopped (signal)"); +#endif +#if defined (SIGXCPU) + init_sig (SIGXCPU, "XCPU", "CPU time limit exceeded"); +#endif +#if defined (SIGXFSZ) + init_sig (SIGXFSZ, "XFSZ", "File size limit exceeded"); +#endif +#if defined (SIGVTALRM) + init_sig (SIGVTALRM, "VTALRM", "Virtual timer expired"); +#endif +#if defined (SIGPROF) + init_sig (SIGPROF, "PROF", "Profiling timer expired"); +#endif +#if defined (SIGWINCH) + /* "Window size changed" might be more accurate, but even if that + is all that it means now, perhaps in the future it will be + extended to cover other kinds of window changes. */ + init_sig (SIGWINCH, "WINCH", "Window changed"); +#endif +#if defined (SIGCONT) + init_sig (SIGCONT, "CONT", "Continued"); +#endif +#if defined (SIGURG) + init_sig (SIGURG, "URG", "Urgent I/O condition"); +#endif +#if defined (SIGIO) + /* "I/O pending" has also been suggested. A disadvantage is + that signal only happens when the process has + asked for it, not everytime I/O is pending. Another disadvantage + is the confusion from giving it a different name than under Unix. */ + init_sig (SIGIO, "IO", "I/O possible"); +#endif +#if defined (SIGWIND) + init_sig (SIGWIND, "WIND", "SIGWIND"); +#endif +#if defined (SIGPHONE) + init_sig (SIGPHONE, "PHONE", "SIGPHONE"); +#endif +#if defined (SIGPOLL) + init_sig (SIGPOLL, "POLL", "I/O possible"); +#endif +#if defined (SIGLOST) + init_sig (SIGLOST, "LOST", "Resource lost"); +#endif +} + +/* Return the abbreviation for signal NUMBER. */ +char * +sig_abbrev (number) + int number; +{ + int i; + + if (sig_table_nelts == 0) + init_sigs (); + + for (i = 0; i < sig_table_nelts; i++) + if (sig_table[i].number == number) + return (char *)sig_table[i].abbrev; + return NULL; +} + +/* Return the signal number for an ABBREV, or -1 if there is no + signal by that name. */ +int +sig_number (abbrev) + CONST char *abbrev; +{ + int i; + + if (sig_table_nelts == 0) + init_sigs (); + + /* Skip over "SIG" if present. */ + if (abbrev[0] == 'S' && abbrev[1] == 'I' && abbrev[2] == 'G') + abbrev += 3; + + for (i = 0; i < sig_table_nelts; i++) + if (abbrev[0] == sig_table[i].abbrev[0] + && strcmp (abbrev, sig_table[i].abbrev) == 0) + return sig_table[i].number; + return -1; +} + +#if defined (SYS_SIGLIST_MISSING) +/* Print to standard error the name of SIGNAL, preceded by MESSAGE and + a colon, and followed by a newline. */ +void +psignal (signal, message) + int signal; + CONST char *message; +{ + if (signal <= 0 || signal >= NSIG) + fprintf (stderr, "%s: unknown signal", message); + else + fprintf (stderr, "%s: %s\n", message, sys_siglist[signal]); +} +#endif diff -Nru glibc-1.02/sysdeps/generic/signame.h glibc-1.03/sysdeps/generic/signame.h --- glibc-1.02/sysdeps/generic/signame.h +++ glibc-1.03/sysdeps/generic/signame.h Mon Jun 3 19:37:24 1991 @@ -0,0 +1,42 @@ +/* Convert between signal names and numbers. + Copyright (C) 1990 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; see the file COPYING. If not, write to +the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifdef __STDC__ +/* Return the abbreviation (e.g. ABRT, FPE, etc.) for signal NUMBER. + Do not return this as a const char *. The caller might want to + assign it to a char *. */ +char *sig_abbrev (int number); + +/* Return the signal number for an ABBREV, or -1 if there is no + signal by that name. */ +int sig_number (const char *abbrev); + +/* Print to standard error the name of SIGNAL, preceded by MESSAGE and + a colon, and followed by a newline. */ +void psignal (int signal, const char *message); + +/* Names for signals from 0 to NSIG-1. */ +extern const char *sys_siglist[]; + +#else + +char *sig_abbrev (); +int sig_number (); +void psignal (); +extern char *sys_siglist[]; + +#endif diff -Nru glibc-1.02/sysdeps/generic/wordcopy.c glibc-1.03/sysdeps/generic/wordcopy.c --- glibc-1.02/sysdeps/generic/wordcopy.c Sat Jan 11 19:19:15 1992 +++ glibc-1.03/sysdeps/generic/wordcopy.c Wed Apr 1 14:28:05 1992 @@ -73,7 +73,7 @@ goto do6; case 0: -if (OP_T_THRES <= 3 * OPSIZ && len == 0) + if (OP_T_THRES <= 3 * OPSIZ && len == 0) return; a0 = ((op_t *) srcp)[0]; srcp -= 0 * OPSIZ; @@ -122,6 +122,8 @@ } while (len != 0); + /* This is the right position for do0. Please don't move + it into the loop. */ do0: ((op_t *) dstp)[0] = a1; } @@ -205,6 +207,8 @@ } while (len != 0); + /* This is the right position for do0. Please don't move + it into the loop. */ do0: ((op_t *) dstp)[0] = MERGE (a2, sh_1, a3, sh_2); } @@ -309,6 +313,8 @@ } while (len != 0); + /* This is the right position for do0. Please don't move + it into the loop. */ do0: ((op_t *) dstp)[7] = a1; } @@ -392,6 +398,8 @@ } while (len != 0); + /* This is the right position for do0. Please don't move + it into the loop. */ do0: ((op_t *) dstp)[3] = MERGE (a0, sh_1, a1, sh_2); } diff -Nru glibc-1.02/sysdeps/i386/__longjmp.c glibc-1.03/sysdeps/i386/__longjmp.c --- glibc-1.02/sysdeps/i386/__longjmp.c Thu Mar 12 19:35:27 1992 +++ glibc-1.03/sysdeps/i386/__longjmp.c Wed Apr 8 01:05:54 1992 @@ -27,25 +27,39 @@ #endif +#define REGS \ + REG (bx);\ + REG (si);\ + REG (di);\ + REG (bp);\ + REG (sp) + +#define REG(xx) register long int xx asm (#xx) +REGS; +#undef REG + /* Jump to the position specified by ENV, causing the setjmp call there to return VAL, or 1 if VAL is 0. */ __NORETURN void -DEFUN(__longjmp, (env, val), CONST jmp_buf env AND int val) +DEFUN(__longjmp, (env, val), + CONST jmp_buf env AND + int val) { - register long int bp asm("bp"), ax asm("ax"); + /* We specify explicit registers because, when not optimizing, + the compiler will generate code that uses the frame pointer + after it's been munged. */ + + register CONST __typeof (env[0]) *e asm ("cx"); + register int v asm ("ax"); + + e = env; + v = val == 0 ? 1 : val; - if (env[0].__bp != bp) - { - asm("movl %0, %%ebx" : : "g" (env[0].__bx) : "bx"); - asm("movl %0, %%esi" : : "g" (env[0].__si) : "si"); - asm("movl %0, %%edi" : : "g" (env[0].__di) : "di"); - asm("movl %0, %%ebp" : : "g" (env[0].__bp) : "bp"); - asm("movl %0, %%esp" : : "g" (env[0].__sp) : "sp"); - } +#define REG(xx) xx = (long int) e->__##xx + REGS; - ax = val == 0 ? 1 : val; - asm volatile ("jmp %*%0" : : "g" (env[0].__dx)); + asm volatile ("jmp %*%0" : : "g" (e->__pc), "a" (v)); /* NOTREACHED */ abort (); diff -Nru glibc-1.02/sysdeps/i386/jmp_buf.h glibc-1.03/sysdeps/i386/jmp_buf.h --- glibc-1.02/sysdeps/i386/jmp_buf.h Fri Dec 14 04:29:54 1990 +++ glibc-1.03/sysdeps/i386/jmp_buf.h Thu Apr 2 01:57:06 1992 @@ -2,5 +2,8 @@ typedef struct { - long int __bx, __si, __di, __bp, __sp, __dx; + long int __bx, __si, __di; + PTR __bp; + PTR __sp; + PTR __pc; } __jmp_buf[1]; diff -Nru glibc-1.02/sysdeps/i386/memchr.c glibc-1.03/sysdeps/i386/memchr.c --- glibc-1.02/sysdeps/i386/memchr.c Tue Mar 17 18:43:15 1992 +++ glibc-1.03/sysdeps/i386/memchr.c Wed Apr 1 02:00:40 1992 @@ -28,17 +28,20 @@ DEFUN(memchr, (str, c, len), CONST PTR str AND int c AND size_t len) { + PTR retval; asm("cld\n" /* Search forward. */ - "orl %0,%0\n" /* Reset zero flag, to handle LEN == 0. */ - "repnz\n" /* Search for C. */ + "testl %1,%1\n" /* Clear Z flag, to handle LEN == 0. */ + "repne\n" /* Search for C in al. */ "scasb\n" - "jz 1f\n" /* Jump if we found something equal to C */ - "movl %4,%0\n" /* Nothing found. Return NULL. */ - "1:decl %0" : /* edi has been incremented. Return edi-1. */ - "=D" (str) : "c" (len), "0" (str), "a" (c), "n" (1)); - return str; + "movl %2,%0\n" /* Set %0 to 0 (without affecting Z flag) */ + "jnz 1f\n" /* Jump if we found nothing equal to C */ + "leal -1(%1),%0\n" /* edi has been incremented. Return edi-1. */ + "1:" : + "=a" (retval), "=D" (str), "=c" (len) : + "0" (c), "1" (str), "2" (len)); + return retval; } #else -#include +#include #endif diff -Nru glibc-1.02/sysdeps/i386/memset.c glibc-1.03/sysdeps/i386/memset.c --- glibc-1.02/sysdeps/i386/memset.c Wed Mar 11 18:10:15 1992 +++ glibc-1.03/sysdeps/i386/memset.c Tue Mar 24 18:37:01 1992 @@ -34,10 +34,7 @@ improves code very much indeed. */ register op_t x asm("ax"); - /* Fill X with four copies of the char we want to fill with. */ x = (unsigned char) c; - x |= (x << 8); - x |= (x << 16); /* Clear the direction flag, so filling will move forward. */ asm volatile("cld"); @@ -45,6 +42,10 @@ /* This threshold value is optimal. */ if (len >= 12) { + /* Fill X with four copies of the char we want to fill with. */ + x |= (x << 8); + x |= (x << 16); + /* There are at least some bytes to set. No need to test for LEN == 0 in this alignment loop. */ @@ -76,5 +77,5 @@ } #else -#include +#include #endif diff -Nru glibc-1.02/sysdeps/i386/setjmp.c glibc-1.03/sysdeps/i386/setjmp.c --- glibc-1.02/sysdeps/i386/setjmp.c Wed Mar 11 17:30:01 1992 +++ glibc-1.03/sysdeps/i386/setjmp.c Thu Apr 2 02:31:00 1992 @@ -21,21 +21,31 @@ #include +#define REGS \ + REG (bx);\ + REG (si);\ + REG (di) + +#define REG(xx) register long int xx asm (#xx) +REGS; +#undef REG + /* Save the current program position in ENV and return 0. */ int DEFUN(__setjmp, (env), jmp_buf env) { - asm ("movl %%ebx, %0" : "=g" (env[0].__bx)); - asm ("movl %%esi, %0" : "=g" (env[0].__si)); - asm ("movl %%edi, %0" : "=g" (env[0].__di)); - asm ("movl %%ebp, %0" : "=g" (env[0].__bp)); - asm volatile ("popl %%edx\n" - "movl %%edx, %0\n" - "movl %%esp, %1\n" - "xorl %%eax, %%eax\n" - "jmp *%%edx\n" : - "=g" (env[0].__dx), "=g" (env[0].__sp)); + /* Save the general registers. */ +#define REG(xx) env[0].__##xx = xx + REGS; + + /* Save the return PC. */ + env[0].__pc = (PTR) ((PTR *) &env)[-1]; + + /* Save caller's FP, not our own. */ + env[0].__bp = (PTR) ((PTR *) &env)[-2]; + + /* Save caller's SP, not our own. */ + env[0].__sp = (PTR) &env; - /* NOTREACHED */ return 0; } diff -Nru glibc-1.02/sysdeps/i386/strlen.c glibc-1.03/sysdeps/i386/strlen.c --- glibc-1.02/sysdeps/i386/strlen.c Wed Mar 11 17:28:55 1992 +++ glibc-1.03/sysdeps/i386/strlen.c Wed Apr 1 01:38:39 1992 @@ -27,7 +27,7 @@ int cnt; asm("cld\n" /* Search forward. */ - "repnz\n" /* Look for a zero byte. */ + "repne\n" /* Look for a zero byte. */ "scasb" /* %0, %1, %3 */ : "=c" (cnt) : "D" (str), "0" (-1), "a" (0)); diff -Nru glibc-1.02/sysdeps/ieee754/__drem.c glibc-1.03/sysdeps/ieee754/__drem.c --- glibc-1.02/sysdeps/ieee754/__drem.c Fri Mar 6 12:53:39 1992 +++ glibc-1.03/sysdeps/ieee754/__drem.c Mon Apr 6 02:59:19 1992 @@ -50,14 +50,12 @@ ux.d = x; uy.d = y; #define x ux.d -#define y ux.d +#define y uy.d uy.ieee.negative = 0; - if (!__finite (x)) + if (!__finite (x) || y == 0.0) return NAN; - else if (y == 0.0) - return 0.0 / 0.0; else if (__isnan (y)) return y; else if (__isinf (y)) @@ -101,7 +99,7 @@ if (x >= b) x -= y; } - ux.ieee.negative = negative; + ux.ieee.negative ^= negative; return x; } } diff -Nru glibc-1.02/sysdeps/ieee754/__logb.c glibc-1.03/sysdeps/ieee754/__logb.c --- glibc-1.02/sysdeps/ieee754/__logb.c Fri Mar 6 12:28:32 1992 +++ glibc-1.03/sysdeps/ieee754/__logb.c Mon Mar 30 19:41:06 1992 @@ -18,6 +18,7 @@ #include #include +#include #include "ieee754.h" /* Return the base 2 signed integral exponent of X. */ @@ -34,5 +35,12 @@ return - HUGE_VAL; u.d = x; - return u.ieee.exponent - 1023; + + if (u.ieee.exponent == 0) + /* A denormalized number. + Multiplying by 2 ** DBL_MANT_DIG normalizes it; + we then subtract the DBL_MANT_DIG we added to the exponent. */ + return (__logb (x * ldexp (1.0, DBL_MANT_DIG)) - DBL_MANT_DIG); + + return (int) u.ieee.exponent - (DBL_MAX_EXP - 1); } diff -Nru glibc-1.02/sysdeps/ieee754/fl.h glibc-1.03/sysdeps/ieee754/fl.h --- glibc-1.02/sysdeps/ieee754/fl.h Thu Feb 6 20:56:16 1992 +++ glibc-1.03/sysdeps/ieee754/fl.h Mon Mar 30 17:42:36 1992 @@ -64,8 +64,15 @@ #ifdef __USE_GNU /* IEEE Not A Number. */ -#define __nan_bytes { 0xff, 0x80, 0, 1, 0, 0, 0, 0 } +#include + +#ifdef __BIG_ENDIAN +#define __nan_bytes { 0x7f, 0xf8, 0, 0, 0, 0, 0, 0 } +#else +#define __nan_bytes { 0, 0, 0, 0, 0, 0, 0xf8, 0x7f } +#endif + #ifdef __GNUC__ #define NAN \ (__extension__ ((union { unsigned char __c[8]; \ @@ -83,7 +90,14 @@ /* Used by and functions for overflow. */ /* IEEE positive infinity. */ + +#include + +#ifdef __BIG_ENDIAN #define __huge_val_bytes { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 } +#else +#define __huge_val_bytes { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f } +#endif #ifdef __GNUC__ #define HUGE_VAL \ diff -Nru glibc-1.02/sysdeps/ieee754/ieee754.h glibc-1.03/sysdeps/ieee754/ieee754.h --- glibc-1.02/sysdeps/ieee754/ieee754.h Thu Mar 5 18:47:26 1992 +++ glibc-1.03/sysdeps/ieee754/ieee754.h Mon Mar 30 18:34:49 1992 @@ -27,16 +27,16 @@ { #ifdef __BIG_ENDIAN unsigned int negative:1; - int exponent:11; - /* Together these comprise the signed mantissa. */ - int mantissa0:20; + unsigned int exponent:11; + /* Together these comprise the mantissa. */ + unsigned int mantissa0:20; unsigned int mantissa1:32; #endif #ifdef __LITTLE_ENDIAN - /* Together these comprise the signed mantissa. */ + /* Together these comprise the mantissa. */ unsigned int mantissa1:32; - int mantissa0:20; - int exponent:11; + unsigned int mantissa0:20; + unsigned int exponent:11; unsigned int negative:1; #endif } ieee; diff -Nru glibc-1.02/sysdeps/ieee754/ldexp.c glibc-1.03/sysdeps/ieee754/ldexp.c --- glibc-1.02/sysdeps/ieee754/ldexp.c Fri Mar 6 21:57:16 1992 +++ glibc-1.03/sysdeps/ieee754/ldexp.c Mon Mar 30 20:42:50 1992 @@ -37,6 +37,7 @@ #include #include +#include #include "ieee754.h" double @@ -44,38 +45,97 @@ double x AND int exp) { union ieee754_double u; + unsigned int exponent; + u.d = x; #define x u.d - if (__finite (x)) + exponent = u.ieee.exponent; + + /* The order of the tests is carefully chosen to handle + the usual case first, with no branches taken. */ + + if (exponent != 0) { - unsigned int k; + /* X is nonzero and not denormalized. */ - if (exp < -2100) - return 3e-39 * 3e-39; /* Cause underflow. */ - else if (exp > 2100) - return 1.7e308 + 1.7e308; /* Cause overflow. */ - - if (u.ieee.exponent == 0) - return ldexp (x * ldexp (1.0, 54), exp - 54); - - k = u.ieee.exponent + exp; - if (k > 0) - { - if (k < 2047) - u.ieee.exponent = k; - else - return 1.7e308 + 1.7e308; /* Cause overflow. */ - } - else if (k > -54) - { + if (exponent <= DBL_MAX_EXP - DBL_MIN_EXP + 1) + { + /* X is finite. When EXP < 0, overflow is actually underflow. */ + + exponent += exp; + + if (exponent != 0) + { + if (exponent <= DBL_MAX_EXP - DBL_MIN_EXP + 1) + { + /* In range. */ + u.ieee.exponent = exponent; + return x; + } + + if (exp >= 0) + overflow: + { + CONST int negative = u.ieee.negative; + u.d = HUGE_VAL; + u.ieee.negative = negative; + errno = ERANGE; + return u.d; + } + + if (exponent <= - (unsigned int) (DBL_MANT_DIG + 1)) + { + /* Underflow. */ + CONST int negative = u.ieee.negative; + u.d = 0.0; + u.ieee.negative = negative; + errno = ERANGE; + return u.d; + } + } + /* Gradual underflow. */ u.ieee.exponent = 1; - x *= ldexp (1.0, k - 1); + u.d *= ldexp (1.0, (int) exponent - 1); + if (u.ieee.mantissa0 == 0 && u.ieee.mantissa1 == 0) + /* Underflow. */ + errno = ERANGE; + return u.d; + } + + /* X is +-infinity or NaN. */ + if (u.ieee.mantissa0 == 0 && u.ieee.mantissa1 == 0) + { + /* X is +-infinity. */ + if (exp >= 0) + goto overflow; + else + { + /* (infinity * number < 1). With infinite precision, + (infinity / finite) would be infinity, but otherwise it's + safest to regard (infinity / 2) as indeterminate. The + infinity might be (2 * finite). */ + CONST int negative = u.ieee.negative; + u.d = NAN; + u.ieee.negative = negative; + errno = EDOM; + return u.d; + } } - else - return 3e-39 * 3e-39; /* Cause underflow. */ + + /* X is NaN. */ + errno = EDOM; + return u.d; } - return x; + /* X is zero or denormalized. */ + if (u.ieee.mantissa0 == 0 && u.ieee.mantissa1 == 0) + /* X is +-0.0. */ + return x; + + /* X is denormalized. + Multiplying by 2 ** DBL_MANT_DIG normalizes it; + we then subtract the DBL_MANT_DIG we added to the exponent. */ + return ldexp (x * ldexp (1.0, DBL_MANT_DIG), exp - DBL_MANT_DIG); } diff -Nru glibc-1.02/sysdeps/ieee754/printf_fp.c glibc-1.03/sysdeps/ieee754/printf_fp.c --- glibc-1.02/sysdeps/ieee754/printf_fp.c Thu Mar 5 17:43:06 1992 +++ glibc-1.03/sysdeps/ieee754/printf_fp.c Wed Apr 8 02:08:39 1992 @@ -26,7 +26,7 @@ do \ { \ register CONST int outc = (x); \ - if (putc(outc, s) == EOF) \ + if (putc (outc, s) == EOF) \ return -1; \ else \ ++done; \ @@ -44,12 +44,12 @@ int is_neg; CONST char *string; - if (__isnan((double) fpnum)) + if (__isnan ((double) fpnum)) { string = "NaN"; is_neg = 0; } - else if (__isinf((double) fpnum)) + else if (__isinf ((double) fpnum)) { string = "Inf"; is_neg = fpnum < 0; @@ -67,24 +67,24 @@ if (!info->left) while (width-- > 0) - outchar(' '); + outchar (' '); if (is_neg) - outchar('-'); + outchar ('-'); else if (info->showsign) - outchar('+'); + outchar ('+'); else if (info->space) - outchar(' '); + outchar (' '); { register size_t len = 3; while (len-- > 0) - outchar(*string++); + outchar (*string++); } if (info->left) while (width-- > 0) - outchar(' '); + outchar (' '); return done; } @@ -92,7 +92,7 @@ #define HANDLE_SPECIAL(done, s, info, fpnum) \ { \ - int more_done = special_ieee754(s, info, fpnum); \ + int more_done = special_ieee754 (s, info, fpnum); \ if (more_done == -1) \ return -1; \ else if (more_done != 0) \ @@ -115,7 +115,7 @@ return u.ieee.negative; } -#define IS_NEGATIVE(num) is_neg_ieee754(num) +#define IS_NEGATIVE(num) is_neg_ieee754 (num) #endif diff -Nru glibc-1.02/sysdeps/m68k/setjmp.c glibc-1.03/sysdeps/m68k/setjmp.c --- glibc-1.02/sysdeps/m68k/setjmp.c Wed Mar 11 18:09:53 1992 +++ glibc-1.03/sysdeps/m68k/setjmp.c Mon Mar 23 17:26:36 1992 @@ -46,7 +46,7 @@ #if defined(__HAVE_68881__) || defined(__HAVE_FPU__) /* Save floating-point (68881) registers FP0 through FP7. */ - asm volatile("fmovem%.x fp0-fp7, %0" : : "m" (env[0].__fpregs)); + asm volatile("fmovem%.x fp0-fp7, %0" : : "m" (env[0].__fpregs[0])); #endif return 0; diff -Nru glibc-1.02/sysdeps/mach/hurd/Makefile glibc-1.03/sysdeps/mach/hurd/Makefile --- glibc-1.02/sysdeps/mach/hurd/Makefile Mon Feb 10 00:19:24 1992 +++ glibc-1.03/sysdeps/mach/hurd/Makefile Sat Mar 21 17:43:14 1992 @@ -1,4 +1,4 @@ -# Copyright (C) 1991 Free Software Foundation, Inc. +# Copyright (C) 1991, 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 @@ -18,10 +18,10 @@ errno.texinfo = $(..)manual/errno.texinfo -$(objpfx)errnos.h: $(errno.texinfo) $(objpfx)errnos.awk +$(objpfx)errnos.h: $(errno.texinfo) $(..)sysdeps/mach/hurd/errnos.awk awk -f $(word 2,$^) $< > $@-tmp mv $@-tmp $@ -$(objpfx)sys_errlist.c: $(errno.texinfo) $(objpfx)sys_errlist.awk +$(objpfx)sys_errlist.c: $(errno.texinfo) $(..)sysdeps/mach/hurd/sys_errlist.awk grep '^@comment.###errno:' $< | sort -n +3 | \ awk -f $(word 2,$^) > $@-tmp mv $@-tmp $@ diff -Nru glibc-1.02/sysdeps/mach/hurd/__access.c glibc-1.03/sysdeps/mach/hurd/__access.c --- glibc-1.02/sysdeps/mach/hurd/__access.c Sat Feb 1 03:52:30 1992 +++ glibc-1.03/sysdeps/mach/hurd/__access.c Sat Mar 21 21:03:31 1992 @@ -17,9 +17,8 @@ Cambridge, MA 02139, USA. */ #include -#include -#include #include +#include /* Test for access to FILE by our real user and group IDs. */ int @@ -26,14 +25,10 @@ DEFUN(__access, (file, type), CONST char *file AND int type) { error_t err; - const char *name; - file_t rdir, dir, file; + file_t crdir, cwdir, rcrdir, rcwdir, io; + int dealloc_crdir, dealloc_cwdir; int flags; - dir = __hurd_path_split (file, &name); - if (dir == MACH_PORT_NULL) - return -1; - /* Set up _hurd_rid_auth. */ __mutex_lock (&_hurd_idlock); if (!_hurd_id_valid) @@ -60,12 +55,23 @@ goto lose; } - if (err = __io_reauthenticate (dir)) - goto lose; - - err = __auth_user_authenticate (_hurd_rid_auth, dir, &rdir); + crdir = _hurd_port_get (&_hurd_crdir, &dealloc_crdir); + err = __io_reauthenticate (crdir); + if (!err) + { + err = __auth_user_authenticate (_hurd_rid_auth, crdir, &rcrdir); + __mach_port_deallocate (__mach_task_self (), crdir); + } + _hurd_port_free (crdir, &dealloc_crdir); + cwdir = _hurd_port_get (&_hurd_cwdir, &dealloc_cwdir); + err = __io_reauthenticate (cwdir); + if (!err) + { + err = __auth_user_authenticate (_hurd_rid_auth, cwdir, &rcwdir); + __mach_port_deallocate (__mach_task_self (), cwdir); + } __mutex_unlock (&_hurd_idlock); - __mach_port_deallocate (__mach_task_self (), dir); + _hurd_port_free (cwdir, &dealloc_cwdir); if (err) return __hurd_fail (err); @@ -77,17 +83,16 @@ if (type & X_OK) flags |= FS_LOOKUP_EXECUTE; - /* XXX auth for crdir on retries from /? */ - err = __dir_lookup (rdir, name, flags, &file); - __mach_port_deallocate (__mach_task_self (), rdir); + err = __hurd_path_lookup (rcrdir, rcwdir, file, flags, 0, &io); + __mach_port_deallocate (__mach_task_self (), rcrdir); + __mach_port_deallocate (__mach_task_self (), rcwdir); if (err) return __hurd_fail (err); - __mach_port_deallocate (__mach_task_self (), file); + __mach_port_deallocate (__mach_task_self (), io); return 0; lose: __mutex_unlock (&_hurd_idlock); - __mach_port_deallocate (__mach_task_self (), dir); return __hurd_fail (err); } diff -Nru glibc-1.02/sysdeps/mach/hurd/__chdir.c glibc-1.03/sysdeps/mach/hurd/__chdir.c --- glibc-1.02/sysdeps/mach/hurd/__chdir.c Wed Oct 30 07:53:53 1991 +++ glibc-1.03/sysdeps/mach/hurd/__chdir.c Sat Mar 21 18:01:17 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -17,26 +17,20 @@ Cambridge, MA 02139, USA. */ #include -#include -#include #include +#include /* Change the current directory to PATH. */ int DEFUN(__chdir, (path), CONST char *path) { - error_t err; - file_t old, cwdir; + file_t cwdir; - cwdir = __hurd_path_lookup (path, FS_LOOKUP_EXECUTE, 0); + cwdir = __path_lookup (path, FS_LOOKUP_EXECUTE, 0); if (cwdir == MACH_PORT_NULL) return -1; - __mutex_lock (&_hurd_lock); - old = _hurd_cwdir; - _hurd_cwdir = cwdir; - __mutex_unlock (&_hurd_lock); - __mach_port_deallocate (__mach_task_self (), old); + _hurd_port_set (&_hurd_cwdir, cwdir); return 0; } diff -Nru glibc-1.02/sysdeps/mach/hurd/__chmod.c glibc-1.03/sysdeps/mach/hurd/__chmod.c --- glibc-1.02/sysdeps/mach/hurd/__chmod.c Wed Oct 23 14:13:22 1991 +++ glibc-1.03/sysdeps/mach/hurd/__chmod.c Sat Mar 21 21:03:30 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -20,6 +20,7 @@ #include #include #include +#include /* Change the protections of FILE to MODE. */ int @@ -26,7 +27,7 @@ DEFUN(__chmod, (file, mode), CONST char *file AND mode_t mode) { error_t err; - file_t port = __hurd_path_lookup (file, 0, 0); + file_t port = __path_lookup (file, 0, 0); if (port == MACH_PORT_NULL) return -1; err = __file_chmod (port, mode); diff -Nru glibc-1.02/sysdeps/mach/hurd/__chown.c glibc-1.03/sysdeps/mach/hurd/__chown.c --- glibc-1.02/sysdeps/mach/hurd/__chown.c Wed Oct 23 14:14:10 1991 +++ glibc-1.03/sysdeps/mach/hurd/__chown.c Sat Mar 21 21:03:26 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -20,6 +20,7 @@ #include #include #include +#include /* Change the owner and group of FILE. */ int @@ -27,7 +28,7 @@ CONST char *file AND uid_t owner AND gid_t group) { error_t err; - file_t port = __hurd_path_lookup (file, 0, 0); + file_t port = __path_lookup (file, 0, 0); if (port == MACH_PORT_NULL) return -1; err = __file_chown (port, owner, group); diff -Nru glibc-1.02/sysdeps/mach/hurd/__close.c glibc-1.03/sysdeps/mach/hurd/__close.c --- glibc-1.02/sysdeps/mach/hurd/__close.c Sat Feb 1 05:01:02 1992 +++ glibc-1.03/sysdeps/mach/hurd/__close.c Sat Mar 21 20:18:03 1992 @@ -25,11 +25,11 @@ int DEFUN(__close, (fd), int fd) { - file_t server; + struct _hurd_fd *d; + io_t port, ctty; __mutex_lock (&_hurd_dtable_lock); - if (fd < 0 || fd >= _hurd_dtable.size || - _hurd_dtable.d[fd].server == MACH_PORT_NULL) + if (fd < 0 || fd >= _hurd_dtable.size) { __mutex_unlock (&_hurd_dtable_lock); errno = EBADF; @@ -36,11 +36,26 @@ return -1; } - server = _hurd_dtable.d[fd].server; - _hurd_dtable.d[fd].server = MACH_PORT_NULL; - /* ctty? XXX */ + d = &_hurd_dtable.d[fd]; + __spin_lock (d->port); + port = d->port.port; + ctty = d->ctty.port; + d->port.port = d->ctty.port = MACH_PORT_NULL; + d->port.user_dealloc = d->ctty.user_dealloc = NULL; + d->flags = 0; + __spin_unlock (&d->port); + __mutex_unlock (&_hurd_dtable_lock); - __mach_port_deallocate (__mach_task_self (), server); + if (port == MACH_PORT_NULL) + { + errno = EBADF; + return -1; + } + + __mach_port_deallocate (__mach_task_self (), port); + if (ctty != MACH_PORT_NULL) + __mach_port_deallocate (__mach_task_self (), ctty); + return 0; } diff -Nru glibc-1.02/sysdeps/mach/hurd/__dup.c glibc-1.03/sysdeps/mach/hurd/__dup.c --- glibc-1.02/sysdeps/mach/hurd/__dup.c Sat Feb 1 05:04:46 1992 +++ glibc-1.03/sysdeps/mach/hurd/__dup.c Sat Mar 21 22:35:22 1992 @@ -27,26 +27,44 @@ DEFUN(__dup, (fd), int fd) { int new; + int dealloc, dealloc_ctty; + io_t port, ctty; + int flags; + int dealloc_dt; + struct _hurd_fd_user d; - __mutex_lock (&_hurd_dtable_lock); - if (fd < 0 || fd >= _hurd_dtable.size || - _hurd_dtable.d[fd].server == MACH_PORT_NULL) + /* Extract the ports and flags from FD. */ + d = _hurd_fd (fd, &dealloc_dt); + if (d.d == NULL) { - __mutex_unlock (&_hurd_dtable_lock); + badf: errno = EBADF; return -1; } - new = _hurd_dalloc (); - if (new < 0) + flags = d.d->flags; + ctty = _hurd_port_get (&d.d->ctty, &dealloc_ctty); + port = _hurd_port_locked_get (&d.d->port, &dealloc); /* Unlocks D.d. */ + + if (port == MACH_PORT_NULL) + goto badf; + + /* Get a new descriptor. */ + new = _hurd_dalloc (port, ctty, flags); + if (new >= 0) { - __mutex_unlock (&_hurd_dtable_lock); - return -1; + /* Give the ports each a user ref for the new descriptor. */ + __mach_port_mod_refs (__mach_task_self (), port, + MACH_PORT_RIGHT_SEND, 1); + if (ctty != MACH_PORT_NULL) + __mach_port_mod_refs (__mach_task_self (), ctty, + MACH_PORT_RIGHT_SEND, 1); } - _hurd_dtable.d[new].server = _hurd_dtable.d[fd].server; - __mach_port_mod_refs (__mach_task_self (), _hurd_dtable.d[fd].server, - MACH_PORT_RIGHT_SEND, 1); - __mutex_unlock (&_hurd_dtable_lock); + _hurd_port_free (&d->port, port, &dealloc); + if (ctty != MACH_PORT_NULL) + _hurd_port_free (&d->ctty, ctty, &dealloc_ctty); + + _hurd_fd_done (d, &dealloc_dt); return new; } diff -Nru glibc-1.02/sysdeps/mach/hurd/__dup2.c glibc-1.03/sysdeps/mach/hurd/__dup2.c --- glibc-1.02/sysdeps/mach/hurd/__dup2.c Sat Feb 1 05:16:19 1992 +++ glibc-1.03/sysdeps/mach/hurd/__dup2.c Sat Mar 21 22:35:20 1992 @@ -24,25 +24,58 @@ /* Duplicate FD to FD2, closing the old FD2 and making FD2 be - open the same file as FD is. Return FD2 or -1. */ + open on the same file as FD is. Return FD2 or -1. */ int DEFUN(__dup2, (fd, fd2), int fd AND int fd2) { - __mutex_lock (&_hurd_dtable_lock); - if (fd < 0 || fd >= _hurd_dtable.size || - _hurd_dtable.d[fd].server == MACH_PORT_NULL || - fd2 < 0 || fd2 >= _hurd_dtable.size) + int dealloc_dt; + struct _hurd_fd_user d, d2; + io_t port, ctty; + int dealloc, dealloc_ctty; + + /* Extract the ports and flags from FD. */ + d = _hurd_fd (fd, &dealloc_dt); + if (d.d == NULL) { - __mutex_unlock (&_hurd_dtable_lock); + badf: errno = EBADF; return -1; } - if (_hurd_dtable.d[fd2].server != MACH_PORT_NULL) - __mach_port_deallocate (__mach_task_self (), _hurd_dtable.d[fd2].server); - _hurd_dtable.d[fd2] = _hurd_dtable.d[fd]; - __mach_port_mod_refs (__mach_task_self (), _hurd_dtable.d[fd].server, - MACH_PORT_RIGHT_SEND, 1); + flags = d->flags; + ctty = _hurd_port_get (&d.d->ctty, &dealloc_ctty); + port = _hurd_port_locked_get (&d.d->port, &dealloc); /* Unlocks D.d. */ + + __mutex_lock (&_hurd_dtable_lock); + if (fd2 < 0 || fd2 >= _hurd_dtable.size) + { + errno = EBADF; + fd2 = -1; + } + else + { + d2 = &_hurd_dtable.d[fd2]; + __spin_lock (&d2->port.lock); + d2->flags = flags; + _hurd_port_set (&d2->ctty, ctty); + _hurd_port_locked_set (&d2->port, port); /* Unlocks D2. */ + } __mutex_unlock (&_hurd_dtable_lock); + + if (fd2 >= 0) + { + /* Give the ports each a user ref for the new descriptor. */ + __mach_port_mod_refs (__mach_task_self (), port, + MACH_PORT_RIGHT_SEND, 1); + if (ctty != MACH_PORT_NULL) + __mach_port_mod_refs (__mach_task_self (), ctty, + MACH_PORT_RIGHT_SEND, 1); + } + + _hurd_port_free (&d.d->port, port, &dealloc); + if (ctty != MACH_PORT_NULL) + _hurd_port_free (&d.d->ctty, ctty, &dealloc_ctty); + + _hurd_fd_done (d, &dealloc_dt); return fd2; } diff -Nru glibc-1.02/sysdeps/mach/hurd/__execve.c glibc-1.03/sysdeps/mach/hurd/__execve.c --- glibc-1.02/sysdeps/mach/hurd/__execve.c Sun Mar 8 16:06:06 1992 +++ glibc-1.03/sysdeps/mach/hurd/__execve.c Sat Mar 21 20:52:57 1992 @@ -38,6 +38,8 @@ struct _hurd_port *port_cells[INIT_PORT_MAX]; file_t *dtable; int dtablesize; + struct _hurd_port *dtable_cells; + int *dealloc_dtable; int i; char *const *p; task_t task; @@ -44,10 +46,12 @@ int flags; struct _hurd_sigstate *ss; - file = __hurd_path_lookup (path, FS_LOOKUP_EXECUTE, 0); + /* Get a port to the file we want to execute. */ + file = __path_lookup (path, FS_LOOKUP_EXECUTE, 0); if (file == MACH_PORT_NULL) return -1; + /* Pack the arguments into an array with nulls separating the elements. */ argslen = 0; p = argv; while (*p != NULL) @@ -55,8 +59,9 @@ args = __alloca (argslen); ap = args; for (p = argv; *p != NULL; ++p) - ap = __memccpy (ap, *p, '\0', UINT_MAX); + ap = __memccpy (ap, *p, '\0', ULONG_MAX); + /* Pack the environment into an array with nulls separating the elements. */ envlen = 0; p = envp; while (*p != NULL) @@ -64,8 +69,9 @@ env = __alloca (envlen); ap = env; for (p = envp; *p != NULL; ++p) - ap = __memccpy (ap, *p, '\0', UINT_MAX); + ap = __memccpy (ap, *p, '\0', ULONG_MAX); + /* Load up the ports to give to the new program. */ #define port(idx, cell) \ case idx: \ port_cells[i] = &cell; \ @@ -83,7 +89,9 @@ port_cells[i] = NULL; break; } - for (i = 0; i < INIT_PORT_MAX; ++i) + + /* Load up the ints to give the new program. */ + for (i = 0; i < INIT_INT_MAX; ++i) switch (i) { case INIT_UMASK: @@ -117,33 +125,68 @@ if (ss->actions[i].sa_handler == SIG_IGN) ints[INIT_SIGIGN] |= __sigmask (i); + /* We hold the sigstate lock until the exec has failed so that no signal + 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. */ + +#if 0 if (ss->vforked) { /* This thread is vfork'd. */ task = MACH_PORT_NULL; - flags = FS_EXEC_NEWTASK; + flags = EXEC_NEWTASK; } else +#endif { task = __mach_task_self (); flags = 0; } + /* Pack up the descriptor table to give the new program. */ __mutex_lock (&_hurd_dtable_lock); if (_hurd_dtable.d != NULL) { dtablesize = _hurd_dtable.size; - dtable = __alloca (dtablesize * sizeof (file_t)); + dtable = __alloca (dtablesize * sizeof (dtable[0])); + dealloc_dtable = __alloca (dtablesize * sizeof (dealloc_dtable[0])); + dtable_cells = __alloca (dtablesize * sizeof (dealloc_cells[0])); for (i = 0; i < dtablesize; ++i) - if (_hurd_dtable.d[i].flags & FD_CLOEXEC) - dtable[i] = MACH_PORT_NULL; - else - dtable[i] = _hurd_dtable.d[i].server; + { + struct _hurd_fd *const = &_hurd_dtable.d[i]; + __spin_lock (&d->port.lock); + if (d->flags & FD_CLOEXEC) + { + dtable[i] = MACH_PORT_NULL; + __spin_unlock (&d->port.lock); + } + else + { + /* If this is a descriptor to our controlling tty, + we want to give the normal port, not the foreground port. */ + dtable[i] = _hurd_port_get (&d->ctty, &dealloc_dtable[i]); + if (dtable[i] == MACH_PORT_NULL) + { + dtable[i] = _hurd_port_locked_get (&d->port, + &dealloc_dtable[i]); + dtable_cells[i] = &d->port; + } + else + { + __spin_unlock (&d->port.lock); + dtable_cells[i] = &d->ctty; + } + } + } } else { dtable = _hurd_init_dtable; dtablesize = _hurd_init_dtablesize; + dealloc_dtable = NULL; + dealloc_cells = NULL; } err = __file_exec (file, task, @@ -152,21 +195,26 @@ ints, INIT_INT_MAX, ports, INIT_PORT_MAX, flags); - /* We must hold the dtable lock while doing the file_exec to avoid - the dtable entries being deallocated before we send them. */ - __mutex_unlock (&_hurd_dtable_lock); + + /* Safe to let signals happen now. */ + __mutex_unlock (&ss->lock); for (i = 0; i < INIT_PORT_MAX; ++i) if (port_cells[i] != NULL) - _hurd_port_free (ports_cells[i], ports[i], dealloc_ports[i]); + _hurd_port_free (ports_cells[i], ports[i], &dealloc_ports[i]); - if (err) - return __hurd_fail (err); + if (dealloc_dtable != NULL) + for (i = 0; i < dtablesize; ++i) + if (dtable[i] != MACH_PORT_NULL) + _hurd_port_free (dtable_cells[i], dtable[i], &dealloc_dtable[i]); +#if 0 if (ss->vforked) longjmp (ss->vfork_saved.continuation, 1); +#endif - __mutex_unlock (&ss->lock); + if (err) + return __hurd_fail (err); /* That's interesting. */ return 0; diff -Nru glibc-1.02/sysdeps/mach/hurd/__fchmod.c glibc-1.03/sysdeps/mach/hurd/__fchmod.c --- glibc-1.02/sysdeps/mach/hurd/__fchmod.c Sat Feb 1 05:29:36 1992 +++ glibc-1.03/sysdeps/mach/hurd/__fchmod.c Sat Mar 21 20:54:46 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -27,20 +27,9 @@ DEFUN(__fchmod, (fd, mode), int fd AND mode_t mode) { error_t err; - io_t server; - __mutex_lock (&_hurd_dtable.lock); - if (fd < 0 || fd >= _hurd_dtable.size || - _hurd_dtable.d[fd].server == MACH_PORT_NULL) - { - __mutex_unlock (&_hurd_dtable.lock); - errno = EBADF; - return -1; - } - server = _hurd_dtable.d[fd].server; - __mutex_unlock (&_hurd_dtable.lock); - - if (err = __file_chmod (server, mode)) + if (err = _HURD_DPORT_USE (fd, __file_chmod (port, mode))) return __hurd_fail (err); + return 0; } diff -Nru glibc-1.02/sysdeps/mach/hurd/__fchown.c glibc-1.03/sysdeps/mach/hurd/__fchown.c --- glibc-1.02/sysdeps/mach/hurd/__fchown.c Wed Oct 23 18:48:46 1991 +++ glibc-1.03/sysdeps/mach/hurd/__fchown.c Thu Apr 2 00:28:28 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -27,20 +27,9 @@ int fd AND uid_t owner AND gid_t group) { error_t err; - io_t server; - __mutex_lock (&_hurd_dtable.lock); - if (fd < 0 || fd >= _hurd_dtable.size || - _hurd_dtable.d[fd].server == MACH_PORT_NULL) - { - __mutex_unlock (&_hurd_dtable.lock); - errno = EBADF; - return -1; - } - server = _hurd_dtable.d[fd].server; - __mutex_unlock (&_hurd_dtable.lock); - - if (err = __file_chown (server, owner, group)) + if (err = _HURD_DPORT_USE (fd, __file_chown (port, owner, group))) return __hurd_fail (err); + return 0; } diff -Nru glibc-1.02/sysdeps/mach/hurd/__fcntl.c glibc-1.03/sysdeps/mach/hurd/__fcntl.c --- glibc-1.02/sysdeps/mach/hurd/__fcntl.c Fri Feb 14 08:22:09 1992 +++ glibc-1.03/sysdeps/mach/hurd/__fcntl.c Sat Mar 21 22:39:15 1992 @@ -26,22 +26,17 @@ DEFUN(__fcntl, (fd, cmd), int fd AND int cmd DOTS) { va_list ap; - struct _hurd_port *p = _hurd_dport (fd); - io_t port; - int dealloc; + int dealloc_dt; + struct _hurd_fd_user d = _hurd_fd (fd, &dealloc_dt); + io_t port, ctty; + int dealloc, dealloc_ctty; int result; - if (p == NULL) + if (d.d == NULL) { errno = EBADF; return -1; } - if (p->port == MACH_PORT_NULL) - { - __spin_unlock (&p->lock); - errno = EBADF; - return -1; - } va_start (ap, cmd); @@ -50,11 +45,13 @@ case F_GETLK: case F_SETLK: case F_SETLKW: + __spin_unlock (&d.d->lock); errno = ENOSYS; result = -1; break; default: + __spin_unlock (&d.d->lock); errno = EINVAL; result = -1; break; @@ -61,48 +58,73 @@ case F_DUPFD: { - int new; - __typeof (_hurd_dtable.d[fd]) old; - old = _hurd_dtable.d[fd]; - _hurd_dtable.d[fd].user_dealloc = &dealloc; - __spin_unlock (&_hurd_dtable.d[fd].user_dealloc); - port = _hurd_port_locked_get (p, &dealloc); - __mutex_lock (&hurd_dtable_lock); - for (new = va_arg (ap, int); new < _hurd_dtable.size; ++new) - { - __typeof (&_hurd_dtable.d[new]) d = &_hurd_dtable.d[new]; - __spin_lock (&d->port.lock); - if (d->port.port == MACH_PORT_NULL) + int fd2 = va_arg (args, int); + int flags; + + /* Extract the ports and flags from FD. */ + flags = d->flags; + ctty = _hurd_port_get (&d->ctty, &dealloc_ctty); + port = _hurd_port_locked_get (&d->port, &dealloc); /* Unlocks D. */ + + if (port == MACH_PORT_NULL) + goto badf; + + __mutex_lock (&_hurd_dtable_lock); + if (fd2 < 0 || fd2 >= _hurd_dtable.size) + { + errno = EBADF; + fd2 = -1; + } + else + { + while (fd2 < _hurd_dtable.size) + { + struct _hurd_fd *d2 = &_hurd_dtable.d[fd2]; + __spin_lock (&d2->port.lock); + if (d2->port.port == MACH_PORT_NULL) + { + d2->flags = flags; + _hurd_port_set (&d2->ctty, ctty); + _hurd_port_locked_set (&d2->port, port); /* Unlocks D2. */ + break; + } + else + __spin_unlock (&d2->port.lock); + } + if (fd2 == _hurd_dtable.size) { - *d = old; - d->port.user_dealloc = NULL; - __spin_unlock (&d->port.lock); - __mutex_unlock (&hurd_dtable_lock); - result = new; - if (!dealloc) - __mach_port_mod_refs (__mach_task_self (), old.port.port, - MACH_PORT_RIGHT_SEND, 1); - goto win; + errno = EMFILE; + fd2 = -1; } - __spin_unlock (&d->port.lock); + } + __mutex_unlock (&_hurd_dtable_lock); + + if (fd2 >= 0) + { + /* Give the ports each a user ref for the new descriptor. */ + __mach_port_mod_refs (__mach_task_self (), port, + MACH_PORT_RIGHT_SEND, 1); + if (ctty != MACH_PORT_NULL) + __mach_port_mod_refs (__mach_task_self (), ctty, + MACH_PORT_RIGHT_SEND, 1); } - __mutex_unlock (&hurd_dtable_lock); - errno = EMFILE; - result = -1; - win: + + _hurd_port_free (port, &dealloc); + if (ctty != MACH_PORT_NULL) + _hurd_port_free (ctty, &dealloc_ctty); + + result = fd2; break; } case F_GETFD: - { - result = _hurd_dtable.d[fd].flags; - __spin_unlock (&_hurd_dtable.d[fd].lock); - break; - } + result = d.d->flags; + __spin_unlock (&d.d->lock); + break; case F_SETFD: - _hurd_dtable.d[fd].flags = va_arg (ap, int); - __spin_unlock (&_hurd_dtable.d[fd].lock); + d.d->flags = va_arg (ap, int); + __spin_unlock (&d.d->lock); result = 0; break; @@ -110,7 +132,7 @@ { error_t err; int nonblock, append; - port = _hurd_port_locked_get (p, &dealloc); + port = _hurd_port_locked_get (d.d, &dealloc); /* Unlocks D.d. */ err = __io_get_nonblock (port, &nonblock); if (!err) err = __io_get_append (port, &append); @@ -130,7 +152,7 @@ { int flags = va_arg (ap, int); error_t err; - port = _hurd_port_locked_get (p, &dealloc); + port = _hurd_port_locked_get (d.d, &dealloc); /* Unlocks D.d. */ err = __io_mod_nonblock (port, flags & O_NONBLOCK); if (!err) err = __io_mod_append (port, flags & O_APPEND); @@ -148,7 +170,7 @@ case F_GETOWN: { error_t err; - port = _hurd_port_locked_get (p, &dealloc); + port = _hurd_port_locked_get (d.d, &dealloc); /* Unlocks D.d. */ if (err = __io_get_owner (port, &result)) { errno = err; @@ -162,7 +184,7 @@ { pid_t owner = va_arg (ap, pid_t); error_t err; - port = _hurd_port_locked_get (p, &dealloc); + port = _hurd_port_locked_get (d.d, &dealloc); /* Unlocks D.d. */ if (err = __io_set_owner (port, owner)) { errno = err; @@ -174,6 +196,8 @@ break; } } + + _hurd_fd_done (d, &dealloc_dt); va_end (ap); diff -Nru glibc-1.02/sysdeps/mach/hurd/__flock.c glibc-1.03/sysdeps/mach/hurd/__flock.c --- glibc-1.02/sysdeps/mach/hurd/__flock.c Wed Mar 4 19:45:30 1992 +++ glibc-1.03/sysdeps/mach/hurd/__flock.c Sat Mar 21 21:16:31 1992 @@ -28,10 +28,9 @@ int fd AND int operation) { error_t err; - file_t file = _hurd_dport (fd); - if (file == MACH_PORT_NULL) - return -1; - if (err = __file_lock (file, operation)) + + if (err = _HURD_DPORT_USE (fd, __file_lock (port, operation))) return __hurd_fail (err); + return 0; } diff -Nru glibc-1.02/sysdeps/mach/hurd/__fork.c glibc-1.03/sysdeps/mach/hurd/__fork.c --- glibc-1.02/sysdeps/mach/hurd/__fork.c Fri Jan 31 20:06:34 1992 +++ glibc-1.03/sysdeps/mach/hurd/__fork.c Sun Mar 22 00:03:51 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -21,6 +21,16 @@ #include #include + +/* Things that want to be locked while forking. */ +const struct + { + size_t n; + mutex_t locks[0]; + } _hurd_fork_locks; + +/* Things that want to be called when we have forked, + with the above all locked. */ const struct { size_t n; @@ -27,18 +37,36 @@ error_t (*fn[0]) (task_t); } _hurd_fork_hook; + +/* Resume all other threads in the current task. */ +static inline void +start_threads (void) +{ + thread_t *threads, me = __mach_thread_self (); + size_t nthreads, i; + + __task_threads (__mach_task_self (), &threads, &nthreads); + + for (i = 0; i < nthreads; ++i) + { + if (threads[i] != me) + __thread_resume (threads[i]); + __mach_port_deallocate (__mach_task_self (), threads[i]); + } + + __vm_deallocate (__mach_task_self (), threads, nthreads * sizeof (*threads)); +} + /* Clone the calling process, creating an exact copy. Return -1 for errors, 0 to the new process, and the process ID of the new process to the old process. */ -int +pid_t DEFUN_VOID(__fork) { jmp_buf env; + pid_t pid; - if (setjmp (env)) - /* Child fork. Return zero. */ - return (pid_t) 0; - else + if (!setjmp (env)) { error_t err; process_t newproc; @@ -47,47 +75,64 @@ thread_t *threads; size_t nthreads; char state[_hurd_thread_state_count]; - pid_t child; + + mach_port_t proc, auth, crdir, cwdir, ccdir; - __mutex_lock (&_hurd_lock); + /* Lock things that want to be locked before we fork. */ + mutex_t lockp; + for (lockp = _hurd_fork_locks.locks; *lockp != NULL; ++lockp) + __mutex_lock (*lockp); + + __spin_lock (&_hurd_proc.lock); + __spin_lock (&_hurd_auth.lock); + __spin_lock (&_hurd_crdir.lock); + __spin_lock (&_hurd_cwdir.lock); + __spin_lock (&_hurd_ccdir.lock); + newtask = MACH_PORT_NULL; sigport = MACH_PORT_NULL; newproc = MACH_PORT_NULL; - if (err = __task_create (__mach_task_self (), 1, &newtask)) - goto lose; - if (err = __mach_port_allocate (__mach_task_self (), - MACH_PORT_RIGHT_RECEIVE, &sigport)) - goto lose; + err = __task_create (__mach_task_self (), 1, &newtask); - if (err = __proc_register (_hurd_proc, newtask, sigport, &newproc)) - goto lose; + /* Save the names of the ports we will give to the child. */ + proc = _hurd_proc.port; + auth = _hurd_auth.port; + crdir = _hurd_crdir.port; + cwdir = _hurd_cwdir.port; + ccdir = _hurd_ccdir.port; + + __spin_unlock (&_hurd_proc.lock); + __spin_unlock (&_hurd_auth.lock); + __spin_unlock (&_hurd_crdir.lock); + __spin_unlock (&_hurd_cwdir.lock); + __spin_unlock (&_hurd_ccdir.lock); - if (err = __mach_port_insert_right (newtask, _hurd_sigport, - sigport, MACH_PORT_MOVE_RECEIVE)) + if (err) goto lose; - if (err = __mach_port_insert_right (newtask, _hurd_proc, newproc, - MACH_PORT_MOVE_SEND)) + /* Suspend the task so we can resume the threads as we create them, + but have them all start at once at the end. */ + if (err = __task_suspend (newtask)) goto lose; -#define cpysnd(port) \ - if (err = __mach_port_insert_right (newtask, (port), (port), \ - MACH_PORT_COPY_SEND)) \ - goto lose; else - - cpysnd (_hurd_ccdir); - cpysnd (_hurd_crdir); - cpysnd (_hurd_cwdir); - - __mutex_unlock (&_hurd_lock); - - for (i = 0; i < _hurd_fork_hook.n; ++i) - if (err = (*_hurd_fork_hook.fn[i]) (newtask)) - goto lose; - - __proc_dostop (_hurd_proc, __mach_thread_self ()); + /* Stop all other threads while we create the new task and extract + the port names its address space is using. Otherwise another + thread could run just after we create the new task, and change the + port cells before we extract the ports from them. Then we would + insert the ports into the new task with names other than the ones + it is expecting. + + We keep _hurd_proc.lock held while calling the proc server to + avoid the deadlock situation which could result if another thread + were to take the lock and then be suspended. */ + + __spin_lock (&_hurd_proc.lock); + err = __proc_dostop (_hurd_proc.port, __mach_thread_self ()); + __spin_unlock (&_hurd_proc.lock); + if (err) + goto lose; if (err = __task_threads (__mach_task_self (), &threads, &nthreads)) { @@ -95,49 +140,128 @@ have no way to start them up. We can at least try to resume the signal thread. */ __thread_resume (_hurd_sigport_thread); + /* XXX ? */ goto lose; } - /* Suspend the task so we can resume the threads as we create them, - but have them all start at once at the end. */ - __task_suspend (newtask); - while (nthreads-- > 0) + /* Create a thread in the child task for each thread in the parent, + and copy the thread states. The exception is the thread running + this code. Its state is not copied to the child; instead, + the corresponding thread in the child returns from the `setjmp' + call above. */ + for (i = 0; i < nthreads; ++i) { - thread_t = *threads++; + const thread_t t = threads[i]; thread_t new = MACH_PORT_NULL; - if (!err) - err = __thread_create (newtask, &new); - if (!err && t == __mach_thread_self ()) + if (err = __thread_create (newtask, &new)) + break; + + if (t == me) /* Make the thread in the new task do a longjmp to ENV. */ err = _hurd_thread_longjmp (new, env, 1); - if (!err && t == _hurd_sigport_thread) - /* Give the thread port for the sigport thread the - same name in the child, so its copy of _hurd_sigport_thread - will be right. */ - err = __mach_port_insert_right (newtask, t, new, - MACH_PORT_COPY_SEND); - - if (!err) - err = _hurd_thread_state (t, state); - __thread_resume (t); - if (!err) + else { - err = _hurd_thread_set_state (new, state); - __thread_resume (new); + /* Copy the thread state from parent to child, + and resume the thread in the parent task. */ + err = _hurd_thread_state (t, state); + if (err) + (void) __thread_resume (t); + else + { + err = __thread_resume (t); + if (err) + (void) _hurd_thread_set_state (new, state); + else + err = _hurd_thread_set_state (new, state); + if (err) + (void) __thread_resume (new); + else + err = __thread_resume (new); + } } - __mach_port_deallocate (__mach_task_self (), t); + + if (!err) + /* Give the thread port the same name in the child. */ + err = __mach_port_insert_right (newtask, t, new, + MACH_PORT_MOVE_SEND); if (new != MACH_PORT_NULL) __mach_port_deallocate (__mach_task_self (), new); + + if (err) + break; + } + /* If we got an error in one of the threads, + resume and deallocate the remaining thread ports. */ + while (i < nthreads) + { + __thread_resume (threads[i]); + __mach_port_deallocate (__mach_task_self (), threads[i]); + ++i; } + __vm_deallocate (__mach_task_self (), + threads, nthreads * sizeof (*threads)); + + /* Create the message port to be used by the child. */ + if (err = __mach_port_allocate (__mach_task_self (), + MACH_PORT_RIGHT_RECEIVE, &sigport)) + goto lose; + + /* Register the child with the proc server. */ + if (err = _HURD_PORT_USE (&_hurd_proc, + __proc_register (port, + newtask, sigport, &newproc))) + goto lose; + + + /* Insert the ports used by the library into the child task. */ + + /* Give the child's message port the same name the parent's + message port has in the parent task. The child's signal + thread will listen on SIGPORT. */ + if (err = __mach_port_insert_right (newtask, _hurd_sigport, sigport, + MACH_PORT_MOVE_RECEIVE)) + goto lose; + + /* Give the child's proc port the same name as the parent's + proc port has in the parent task. */ + if (err = __mach_port_insert_right (newtask, proc, newproc, + MACH_PORT_MOVE_SEND)) + goto lose; + + /* Copy the standard ports into the child task, + with the names that were the standard ports' names + in the parent task at the time the child task was created. */ +#define cpysnd(copy) \ + if (err = _HURD_PORT_USE \ + (&_hurd_##copy, \ + __mach_port_insert_right (newtask, \ + copy, port, \ + MACH_PORT_COPY_SEND))) \ + goto lose; else + + cpysnd (auth); + cpysnd (ccdir); + cpysnd (crdir); + cpysnd (cwdir); + + /* Run things that want to be run to set + other things up in the child task. */ + for (i = 0; i < _hurd_fork_hook.n; ++i) + if (err = (*_hurd_fork_hook.fn[i]) (newtask)) + goto lose; + if (!err) - /* Start the task up. */ + /* Start the child task up. */ err = __task_resume (newtask); if (!err) - err = __proc_task2pid (_hurd_proc, newtask, &child); + /* Get the PID of the child from the proc server. */ + err = _HURD_PORT_USE (&_hurd_proc, + __proc_task2pid (port, newtask, &pid)); lose: + if (newtask != MACH_PORT_NULL) { if (err) @@ -148,8 +272,21 @@ __mach_port_deallocate (__mach_task_self (), sigport); if (newproc != MACH_PORT_NULL) __mach_port_deallocate (__mach_task_self (), newproc); + if (err) - return __hurd_fail (err); - return child; + { + errno = err; + pid = -1; + } } + else + /* We are the child task. */ + pid = 0; + + /* Unlock things we locked before creating the child task. + They are locked in both the parent and child tasks. */ + for (lockp = _hurd_fork_locks.locks; *lockp != NULL; ++lockp) + __mutex_unlock (*lockp); + + return pid; } diff -Nru glibc-1.02/sysdeps/mach/hurd/__getdents.c glibc-1.03/sysdeps/mach/hurd/__getdents.c --- glibc-1.02/sysdeps/mach/hurd/__getdents.c +++ glibc-1.03/sysdeps/mach/hurd/__getdents.c Sun Mar 22 00:50:30 1992 @@ -0,0 +1,42 @@ +/* Copyright (C) 1992 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include +#include +#include + +ssize_t +DEFUN(__getdirentries, (fd, buf, nbytes, basep), + int fd AND PTR buf AND size_t nbytes AND off_t *basep) +{ + error_t err; + int amount; + + /* Fault before taking any locks. */ + *(volatile off_t *) basep = *basep; + + err = _HURD_DPORT_USE (fd, + __dir_readdir (port, buf, nbytes, *basep, + basep, &amount)); + if (err) + return __hurd_fail (err); + + return amount; +} diff -Nru glibc-1.02/sysdeps/mach/hurd/__getegid.c glibc-1.03/sysdeps/mach/hurd/__getegid.c --- glibc-1.02/sysdeps/mach/hurd/__getegid.c Wed Oct 30 07:53:50 1991 +++ glibc-1.03/sysdeps/mach/hurd/__getegid.c Sun Mar 22 01:22:17 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -29,7 +29,8 @@ __mutex_lock (&_hurd_idlock); if (!_hurd_id_valid) { - error_t err = __auth_getids (_hurd_auth, &_hurd_id); + error_t err = _HURD_PORT_USE (&_hurd_auth, + __auth_getids (port, &_hurd_id)); if (err) { __mutex_unlock (&_hurd_idlock); @@ -38,10 +39,8 @@ _hurd_id_valid = 1; } if (_hurd_id.ngroups == 0) - { - errno = ENOENT; - egid = -1; - } + /* We have no effective gids. Return the real gid. */ + egid = _hurd_id.rgid; else egid = _hurd_id.gids[0]; __mutex_unlock (&_hurd_idlock); diff -Nru glibc-1.02/sysdeps/mach/hurd/__geteuid.c glibc-1.03/sysdeps/mach/hurd/__geteuid.c --- glibc-1.02/sysdeps/mach/hurd/__geteuid.c Wed Oct 30 07:53:49 1991 +++ glibc-1.03/sysdeps/mach/hurd/__geteuid.c Sun Mar 22 01:22:20 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -29,7 +29,8 @@ __mutex_lock (&_hurd_idlock); if (!_hurd_id_valid) { - error_t err = __auth_getids (_hurd_auth, &_hurd_id); + error_t err = _HURD_PORT_USE (&_hurd_auth, + __auth_getids (port, &_hurd_id)); if (err) { __mutex_unlock (&_hurd_idlock); @@ -38,10 +39,8 @@ _hurd_id_valid = 1; } if (_hurd_id.nuids == 0) - { - errno = ENOENT; - euid = -1; - } + /* We have no effective uids. Return the real uid. */ + euid = _hurd_id.ruid; else euid = _hurd_id.uids[0]; __mutex_unlock (&_hurd_idlock); diff -Nru glibc-1.02/sysdeps/mach/hurd/__getgid.c glibc-1.03/sysdeps/mach/hurd/__getgid.c --- glibc-1.02/sysdeps/mach/hurd/__getgid.c Wed Oct 30 07:53:47 1991 +++ glibc-1.03/sysdeps/mach/hurd/__getgid.c Sun Mar 22 01:22:24 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -29,7 +29,8 @@ __mutex_lock (&_hurd_idlock); if (!_hurd_id_valid) { - error_t err = __auth_getids (_hurd_auth, &_hurd_id); + error_t err = _HURD_PORT_USE (&_hurd_auth, + __auth_getids (port, &_hurd_id)); if (err) { __mutex_unlock (&_hurd_idlock); diff -Nru glibc-1.02/sysdeps/mach/hurd/__getgrps.c glibc-1.03/sysdeps/mach/hurd/__getgrps.c --- glibc-1.02/sysdeps/mach/hurd/__getgrps.c Mon Nov 11 22:49:05 1991 +++ glibc-1.03/sysdeps/mach/hurd/__getgrps.c Sun Mar 22 01:22:26 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -22,7 +22,7 @@ #include int -getgroups (int n, gid_t *gidset) +__getgroups (int n, gid_t *gidset) { int ngids; @@ -29,7 +29,8 @@ __mutex_lock (&_hurd_idlock); if (!_hurd_id_valid) { - error_t err = __auth_getids (_hurd_auth, &_hurd_id); + error_t err = _HURD_PORT_USE (&_hurd_auth, + __auth_getids (port, &_hurd_id)); if (err) { __mutex_unlock (&_hurd_idlock); diff -Nru glibc-1.02/sysdeps/mach/hurd/__gethstnm.c glibc-1.03/sysdeps/mach/hurd/__gethstnm.c --- glibc-1.02/sysdeps/mach/hurd/__gethstnm.c Sat Feb 1 05:44:29 1992 +++ glibc-1.03/sysdeps/mach/hurd/__gethstnm.c Sun Mar 22 01:22:35 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -29,10 +29,8 @@ char *name AND size_t len) { error_t err; - __mutex_lock (&_hurd_lock); - err = __proc_gethostname (_hurd_proc, name, len); - __mutex_unlock (&_hurd_lock); - if (err) + if (err = _HURD_PORT_USE (&_hurd_proc, + __proc_gethostname (port, name, len))) return __hurd_fail (err); return 0; } diff -Nru glibc-1.02/sysdeps/mach/hurd/__getpgrp.c glibc-1.03/sysdeps/mach/hurd/__getpgrp.c --- glibc-1.02/sysdeps/mach/hurd/__getpgrp.c Sat Feb 1 05:44:25 1992 +++ glibc-1.03/sysdeps/mach/hurd/__getpgrp.c Sun Mar 22 01:22:29 1992 @@ -31,10 +31,8 @@ if (pid == 0) return _hurd_pgrp; - __mutex_lock (&_hurd_lock); - err = __proc_getpgrp (_hurd_proc, pid, &pgrp); - __mutex_unlock (&_hurd_lock); - if (err) + if (err = _HURD_PORT_USE (&_hurd_proc, + __proc_getpgrp (port, pid, &pgrp))) return __hurd_fail (err); return pgrp; diff -Nru glibc-1.02/sysdeps/mach/hurd/__getuid.c glibc-1.03/sysdeps/mach/hurd/__getuid.c --- glibc-1.02/sysdeps/mach/hurd/__getuid.c Wed Oct 30 07:53:44 1991 +++ glibc-1.03/sysdeps/mach/hurd/__getuid.c Sun Mar 22 01:22:14 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -29,7 +29,8 @@ __mutex_lock (&_hurd_idlock); if (!_hurd_id_valid) { - error_t err = __auth_getids (_hurd_auth, &_hurd_id); + error_t err = _HURD_PORT_USE (&_hurd_auth, + __auth_getids (port, &_hurd_id)); if (err) { __mutex_unlock (&_hurd_idlock); diff -Nru glibc-1.02/sysdeps/mach/hurd/__kill.c glibc-1.03/sysdeps/mach/hurd/__kill.c --- glibc-1.02/sysdeps/mach/hurd/__kill.c Mon Feb 10 20:29:25 1992 +++ glibc-1.03/sysdeps/mach/hurd/__kill.c Sat Apr 4 12:15:33 1992 @@ -30,6 +30,7 @@ error_t err; mach_port_t portbuf[10]; mach_port_t *ports = portbuf; + mach_port_t refport; /* XXX */ size_t nports = 10, i; mach_port_t proc; int dealloc_proc; @@ -60,17 +61,19 @@ err = __proc_getsidport (proc, &refport); } - _hurd_port_free (proc, &dealloc_proc); + _hurd_port_free (&_hurd_proc, proc, &dealloc_proc); for (i = 0; i < nports; ++i) { + if (!err && signo == SIGKILL) + err = __task_terminate (refport); /* XXX */ if (!err) - err = __sig_post (ports[i], sig, refport); + err = __sig_post (ports[i], sig, refport); /* XXX */ __mach_port_deallocate (__mach_task_self (), ports[i]); } if (refport != MACH_PORT_NULL) - __mach_port_deallocate (__mach_task_self (), refport); + __mach_port_deallocate (__mach_task_self (), refport); /* XXX */ if (ports != portbuf) __vm_deallocate (__mach_task_self (), ports, nports * sizeof (ports[0])); diff -Nru glibc-1.02/sysdeps/mach/hurd/__link.c glibc-1.03/sysdeps/mach/hurd/__link.c --- glibc-1.02/sysdeps/mach/hurd/__link.c Sat Feb 1 14:52:20 1992 +++ glibc-1.03/sysdeps/mach/hurd/__link.c Sun Mar 22 01:29:38 1992 @@ -30,9 +30,10 @@ file_t oldfile, linknode, todir; CONST char *toname; - oldfile = __hurd_path_lookup (from, 0, 0); + oldfile = __path_lookup (from, 0, 0); if (oldfile == MACH_PORT_NULL) return -1; + err = __file_getlinknode (oldfile, &linknode); if (err == EOPNOTSUPP) linknode = oldfile; @@ -40,7 +41,8 @@ __mach_port_deallocate (__mach_task_self (), oldfile); if (err) return __hurd_fail (err); - todir = __hurd_path_split (to, &toname); + + todir = __path_split (to, &toname); if (todir != MACH_PORT_NULL) { err = __dir_link (linknode, todir, toname); diff -Nru glibc-1.02/sysdeps/mach/hurd/__lseek.c glibc-1.03/sysdeps/mach/hurd/__lseek.c --- glibc-1.02/sysdeps/mach/hurd/__lseek.c Sat Feb 1 14:53:11 1992 +++ glibc-1.03/sysdeps/mach/hurd/__lseek.c Sun Mar 22 02:20:29 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -25,20 +25,8 @@ DEFUN(__lseek, (fd, offset, whence), int fd AND off_t offset AND int whence) { error_t err; - io_t server; - - __mutex_lock (&_hurd_dtable_lock); - if (fd < 0 || fd >= _hurd_dtable.size || - _hurd_dtable.d[fd].server == MACH_PORT_NULL) - { - __mutex_unlock (&_hurd_dtable_lock); - errno = EBADF; - return -1; - } - server = _hurd_dtable.d[fd].server; - __mutex_unlock (&_hurd_dtable_lock); - - if (err = __file_seek (server, offset, whence, &offset)) + if (err = _HURD_DPORT_USE (fd, + __file_seek (port, offset, whence, &offset))) return __hurd_fail (err); return offset; } diff -Nru glibc-1.02/sysdeps/mach/hurd/__mknod.c glibc-1.03/sysdeps/mach/hurd/__mknod.c --- glibc-1.02/sysdeps/mach/hurd/__mknod.c Wed Oct 30 07:55:36 1991 +++ glibc-1.03/sysdeps/mach/hurd/__mknod.c Sun Mar 22 01:36:25 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -29,7 +29,6 @@ CONST char *path AND mode_t mode AND dev_t dev) { const char *name; - file_t dir = __hurd_path_split (path, &name); file_t node; error_t err; const char *translator; @@ -47,29 +46,26 @@ return -1; } - if (err = __dir_lookup (dir, name, - FS_LOOKUP_CREATE|FS_LOOKUP_EXCL|FS_LOOKUP_WRITE, - mode & 0777, - &node)) - goto lose; - - if (err = __io_write (node, &dev, sizeof (dev), &n)) /* XXX */ - goto lose; - if (n != sizeof (dev)) - { - err = POSIX_EIO; - goto lose; - } + node = __path_lookup (path, + FS_LOOKUP_CREATE|FS_LOOKUP_EXCL|FS_LOOKUP_WRITE, + mode & 0777, + &node); + if (node == MACH_PORT_NULL) + return -1; + + err = __file_set_translator (node, + FS_GOAWAY_DONT, + translator, strlen (translator) + 1, + MACH_PORT_NULL); + + if (!err) + err = __io_write (node, &dev, sizeof (dev), &n); + if (!err && n != sizeof (dev)) + err = EIO; - err = __dir_set_translator (dir, name, FS_TRANS_EXCL, FS_GOAWAY_DONT, - translator, MACH_PORT_NULL); if (err) /* XXX The node still exists.... */ - goto lose; + return __hurd_fail (err); return 0; - - lose: - __mach_port_deallocate (__mach_task_self (), dir); - return __hurd_fail (err); } diff -Nru glibc-1.02/sysdeps/mach/hurd/__open.c glibc-1.03/sysdeps/mach/hurd/__open.c --- glibc-1.02/sysdeps/mach/hurd/__open.c Wed Oct 30 08:13:58 1991 +++ glibc-1.03/sysdeps/mach/hurd/__open.c Sun Mar 22 01:58:47 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* 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 @@ -30,8 +30,7 @@ error_t err; mode_t mode; int fl; - int fd; - file_t port; + io_t port, ctty; switch (oflag & O_ACCMODE) { @@ -71,40 +70,61 @@ if (oflag & O_EXCL) fl |= FS_LOOKUP_EXCL; - __mutex_lock (&_hurd_dtable.lock); - fd = _hurd_dalloc (); - if (fd < 0) - { - __mutex_unlock (&_hurd_dtable.lock); - return -1; - } + port = __path_lookup (file, fl, mode); + if (port == MACH_PORT_NULL) + return -1; - port = __hurd_path_lookup (file, fl, mode); - - if (port != MACH_PORT_NULL && !_hurd_hasctty && !(oflag & O_NOCTTY)) + ctty = MACH_PORT_NULL; + if (!(oflag & O_NOCTTY)) { - mach_port_t cttyid; io_statbuf_t stb; err = __io_stat (port, &stb); if (!err) - err = __term_getctty (port, &cttyid); - if (!err) { - err = __proc_set_ctty (_hurd_proc, cttyid); - __mach_port_deallocate (__mach_task_self (), cttyid); - if (!err) + io_t fg_port = MACH_PORT_NULL; + + __mutex_lock (&_hurd_ctty_lock); + if (_hurd_ctty_fstype == 0) + { + /* We have no controlling tty. + Try to make this it. */ + mach_port_t cttyid; + err = __term_getctty (port, &cttyid); + if (!err) + { + err = __term_become_ctty (port, _hurd_pid, _hurd_pgrp, + _hurd_sigport, &fg_port); + if (err) + __mach_port_deallocate (__mach_task_self (), cttyid); + } + } + else if (stb.stb_fstype == _hurd_ctty_fstype && + stb.stb_fsid.val[0] == _hurd_ctty_fsid.val[0] && + stb.stb_fsid.val[1] == _hurd_ctty_fsid.val[1] && + stb.stb_fileno == _hurd_ctty_fileno) + /* This is our controlling tty. */ + err = __term_become_ctty (port, _hurd_pid, _hurd_pgrp, + _hurd_sigport, &fg_port); + + if (fg_port != MACH_PORT_NULL) { - _hurd_dtable.d[fd].isctty = 1; - _hurd_hasctty = 1; - _hurd_ctty_fstype = stb.stb_fstype; - _hurd_ctty_fsid = stb.stb_fsid; - _hurd_ctty_fileid = stb.stb_file_id; + int fd = _hurd_dalloc (fg_port, port, 0); + if (fd >= 0 && _hurd_ctty_fstype == 0) + { + /* We have a new controlling tty. */ + _hurd_ctty_port = cttyid; + _hurd_ctty_fstype = stb.stb_fstype; + _hurd_ctty_fsid = stb.stb_fsid; + _hurd_ctty_fileno = stb.stb_fileno; + } + __mutex_unlock (&_hurd_ctty_lock); + return fd; } + else + __mutex_unlock (&_hurd_ctty_lock); } } - _hurd_dtable.d[fd].server = port; - __mutex_unlock (&_hurd_dtable.lock); - return port == MACH_PORT_NULL ? -1 : fd; + return _hurd_dalloc (port, MACH_PORT_NULL, 0); } diff -Nru glibc-1.02/sysdeps/mach/hurd/__pipe.c glibc-1.03/sysdeps/mach/hurd/__pipe.c --- glibc-1.02/sysdeps/mach/hurd/__pipe.c Sat Feb 8 02:34:11 1992 +++ glibc-1.03/sysdeps/mach/hurd/__pipe.c Sun Mar 22 02:01:25 1992 @@ -56,10 +56,18 @@ __socket_shutdown (sock1, 1); __socket_shutdown (sock2, 0); - d1 = _hurd_dalloc (sock1, 0); - d2 = _hurd_dalloc (sock2, 0); - if (d1 < 0 || d2 < 0) - return -1; + d1 = _hurd_dalloc (sock1, MACH_PORT_NULL, 0); + if (d1 < 0) + { + __mach_port_deallocate (__mach_task_self (), sock2); + return -1; + } + d2 = _hurd_dalloc (sock2, MACH_PORT_NULL, 0); + if (d2 < 0) + { + (void) close (d1); + return __hurd_fail (EMFILE); + } fds[0] = d1; fds[2] = d2; diff -Nru glibc-1.02/sysdeps/mach/hurd/__read.c glibc-1.03/sysdeps/mach/hurd/__read.c --- glibc-1.02/sysdeps/mach/hurd/__read.c Mon Nov 11 23:11:39 1991 +++ glibc-1.03/sysdeps/mach/hurd/__read.c Wed Mar 25 20:06:31 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -27,27 +27,42 @@ int fd AND PTR buf AND size_t nbytes) { error_t err; - io_t server; - int isctty; char *data; size_t nread; - __mutex_lock (&_hurd_dtable.lock); - if (fd < 0 || fd >= _hurd_dtable.size || - _hurd_dtable.d[fd].server == MACH_PORT_NULL) - { - __mutex_unlock (&_hurd_dtable.lock); - errno = EBADF; - return -1; - } - - server = _hurd_dtable.d[fd].server; - isctty = _hurd_ctty_check (fd); - __mutex_unlock (&_hurd_dtable.lock); - data = buf; - err = __io_read (server, isctty, _hurd_pid, _hurd_pgrp, - &data, &nread, -1, nbytes); + _HURD_DPORT_USE + (fd, + ({ + call: + err = __io_read (port, &data, &nread, -1, nbytes); + if (ctty != MACH_PORT_NULL && err == EBACKGROUND) + { + struct _hurd_sigstate *ss + = _hurd_thread_sigstate (__mach_thread_self ()); + 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; + __sigaddmember (SIGTTIN, &ss->pending); + __mutex_unlock (&ss->lock); + /* XXX deliver pending signals */ + if (restart) + goto call; + else + err = EINTR; /* XXX Is this right? */ + } + } + })); if (err) return __hurd_fail (err); diff -Nru glibc-1.02/sysdeps/mach/hurd/__readlink.c glibc-1.03/sysdeps/mach/hurd/__readlink.c --- glibc-1.02/sysdeps/mach/hurd/__readlink.c Wed Oct 23 18:43:13 1991 +++ glibc-1.03/sysdeps/mach/hurd/__readlink.c Wed Mar 25 19:32:41 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -19,6 +19,8 @@ #include #include #include +#include +#include /* Read the contents of the symbolic link PATH into no more than LEN bytes of BUF. The contents are not null-terminated. @@ -27,11 +29,10 @@ DEFUN(__readlink, (path, buf, len), CONST char *path AND char *buf AND size_t len) { - io_statbuf_t stb; error_t err; - char *p; - file_t file = __hurd_path_lookup (path, FS_LOOKUP_READ|FS_LOOKUP_NOLINK, 0); + file_t file; + file = __path_lookup (path, FS_LOOKUP_READ|FS_LOOKUP_NOTRANS, 0); if (file == MACH_PORT_NULL) return -1; @@ -38,12 +39,18 @@ p = buf; while (len > 0) { - size_t nread; - err = __io_read (file, p, len, &nread); + char *s = p; + size_t nread = len; + err = __io_read (file, &s, &nread); if (err) break; if (nread == 0) break; + if (s != p) + { + memcpy (p, s, nread); + __vm_deallocate (__mach_task_self (), s, nread); + } len -= nread; p += nread; } diff -Nru glibc-1.02/sysdeps/mach/hurd/__rmdir.c glibc-1.03/sysdeps/mach/hurd/__rmdir.c --- glibc-1.02/sysdeps/mach/hurd/__rmdir.c Wed Oct 30 08:13:56 1991 +++ glibc-1.03/sysdeps/mach/hurd/__rmdir.c Wed Mar 25 19:33:15 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -20,8 +20,8 @@ #include #include #include +#include - /* Remove the directory PATH. */ int DEFUN(__rmdir, (path), CONST char *path) @@ -28,7 +28,7 @@ { error_t err; const char *name; - file_t parent = __hurd_path_split (path, &name); + file_t parent = __path_split (path, &name); if (parent == MACH_PORT_NULL) return -1; err = __dir_rmdir (parent, name); diff -Nru glibc-1.02/sysdeps/mach/hurd/__select.c glibc-1.03/sysdeps/mach/hurd/__select.c --- glibc-1.02/sysdeps/mach/hurd/__select.c Mon Nov 11 23:11:37 1991 +++ glibc-1.03/sysdeps/mach/hurd/__select.c Wed Mar 25 19:54:57 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -34,7 +34,13 @@ int i; mach_port_t port; int got; + struct _hurd_dtable dtable; + int dealloc_dtable; *dealloc, *types; + mach_port_t *ports; + struct _hurd_fd *cells; + error_t err; + /* If we're going to bomb, do it before we acquire any locks. */ if (readfds != NULL) *(volatile fd_set *) readfds; @@ -43,11 +49,6 @@ if (exceptfds != NULL) *(volatile fd_set *) exceptfds; - __mutex_lock (&_hurd_dtable.lock); - - if (nfds > _hurd_dtable.size) - nfds = _hurd_dtable.size; - if (timeout != NULL && timeout->tv_sec == 0 && timeval->tv_usec == 0) port = MACH_PORT_NULL; else @@ -57,8 +58,16 @@ MACH_PORT_RIGHT_RECEIVE, &port); } - /* Do an io_select on each interesting FD. */ - got = 0; + dtable = _hurd_dtable_use (&dealloc_dtable); + + if (nfds > _hurd_dtable.size) + nfds = _hurd_dtable.size; + + /* Collect the ports for interesting FDs. */ + cells = __alloca (nfds * sizeof (*cells)); + ports = __alloca (nfds * sizeof (*ports)); + types = __alloca (nfds * sizeof (*types)); + dealloc = __alloca (nfds * sizeof (*dealloc)); for (i = 0; i < nfds; ++i) { int type = 0; @@ -68,38 +77,38 @@ type |= SELECT_WRITE; if (exceptfds != NULL && FD_ISSET (i, exceptfds)) type |= SELECT_URG; + types[i] = type; if (type) { - int result; - error_t err = __io_select (_hurd_dtable.d[i], type, port, i, - &result); - if (result & (SELECT_READ|SELECT_WRITE|SELECT_URG)) + cells[i] = _hurd_dtable_fd (i, dtable); + ports[i] = _hurd_port_locked_get (&cells[i]->port, &dealloc[i]); + if (ports[i] == MACH_PORT_NULL) { - if (readfds != NULL) - if (result & SELECT_READ) - FD_SET (i, readfds); - else - FD_CLR (i, readfds); - if (writefds != NULL) - if (result & SELECT_WRITE) - FD_SET (i, writefds); - else - FD_CLR (i, writefds); - if (exceptfds != NULL) - if (result & SELECT_URG) - FD_SET (i, exceptfds); - else - FD_CLR (i, exceptfds); - ++got; + while (i-- > 0) + _hurd_port_free (&cells[i]->port, &dealloc[i]); + _hurd_dtable_done (dtable, &dealloc_dtable); + errno = EBADF; + return -1; } } } - /* XXX Need to lock those fds so they don't change before select is done. */ - - __mutex_unlock (&_hurd_dtable.lock); + /* Send them all io_select calls. */ + got = 0; + err = 0; + for (i = 0; i < nfds; ++i) + if (types[i]) + { + if (!err) + { + err = __io_select (ports[i], types[i], port, i, &types[i]); + if (types[i]) + ++got; + } + _hurd_port_free (&cells[i]->port, ports[i], &dealloc[i]); + } - if (got == 0 && port != MACH_PORT_NULL) + if (!err && got == 0 && port != MACH_PORT_NULL) { struct { @@ -115,8 +124,8 @@ 0); mach_msg_option_t options = (timeval == NULL ? 0 : MACH_RCV_TIMEOUT); receive: - switch (__mach_msg (&msg, MACH_RCV_MSG | options, 0, sizeof (msg), - port, timeout, MACH_PORT_NULL)) + switch (err = __mach_msg (&msg, MACH_RCV_MSG | options, 0, sizeof (msg), + port, timeout, MACH_PORT_NULL)) { case MACH_MSG_SUCCESS: { @@ -129,21 +138,7 @@ (msg.result & (SELECT_READ|SELECT_WRITE|SELECT_URG)) && msg.tag >= 0 && msg.tag < nfds) { - if (readfds != NULL) - if (msg.result & SELECT_READ) - FD_SET (msg.tag, readfds); - else - FD_CLR (msg.tag, readfds); - if (writefds != NULL) - if (msg.result & SELECT_WRITE) - FD_SET (msg.tag, writefds); - else - FD_CLR (msg.tag, writefds); - if (exceptfds != NULL) - if (msg.result & SELECT_URG) - FD_SET (msg.tag, exceptfds); - else - FD_CLR (msg.tag, exceptfds); + types[i] = msg.result; ++got; if (msg.msgh_remote_port != MACH_PORT_NULL) { @@ -166,12 +161,8 @@ } case MACH_RCV_TIMED_OUT: + err = 0; break; - - default: - errno = EIO; /* XXX ??? */ - got = -1; - break; } } @@ -182,6 +173,31 @@ select call to use the port. The notification might be valid, but the descriptor may have changed to a different server. */ __mach_port_destroy (port); + + if (err) + return __hurd_fail (err); + + /* Set the user bitarrays. */ + for (i = 0; i < nfds; ++i) + if (types[i] & (SELECT_READ|SELECT_WRITE|SELECT_URG)) + { + if (readfds != NULL) + if (types[i] & SELECT_READ) + FD_SET (i, readfds); + else + FD_CLR (i, readfds); + if (writefds != NULL) + if (types[i] & SELECT_WRITE) + FD_SET (i, writefds); + else + FD_CLR (i, writefds); + if (exceptfds != NULL) + if (types[i] & SELECT_URG) + FD_SET (i, exceptfds); + else + FD_CLR (i, exceptfds); + ++got; + } return got; } diff -Nru glibc-1.02/sysdeps/mach/hurd/__setgid.c glibc-1.03/sysdeps/mach/hurd/__setgid.c --- glibc-1.02/sysdeps/mach/hurd/__setgid.c Wed Oct 30 09:02:36 1991 +++ glibc-1.03/sysdeps/mach/hurd/__setgid.c Thu Apr 2 00:43:41 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -33,7 +33,8 @@ __mutex_lock (&_hurd_idlock); if (!_hurd_id_valid) { - error_t err = __auth_getids (_hurd_auth, &_hurd_id); + error_t err = _HURD_PORT_USE (&_hurd_auth, + __auth_getids (port, &_hurd_id)); if (err) { __mutex_unlock (&_hurd_idlock); @@ -57,7 +58,7 @@ sizeof (_hurd_id.gids[0]))) { __mutex_unlock (&_hurd_idlock); - errno = ENOMEM; /* ? */ + errno = ENOMEM; /* XXX ? */ return -1; } else @@ -69,16 +70,15 @@ _hurd_id.rgid = _hurd_id.gids[0]; - if (err = auth_makeauth (_hurd_auth, &_hurd_id, &newauth)) - { - _hurd_id_valid = 0; - __mutex_unlock (&_hurd_idlock); - return __hurd_fail (err); - } - else - { - int err = __setauth (newauth); - __mach_port_deallocate (__mach_task_self (), newauth); - return err; - } + err = _HURD_PORT_USE (&_hurd_auth, + __auth_makeauth (port, &_hurd_id, &newauth)); + _hurd_id_valid = 0; + __mutex_unlock (&_hurd_idlock); + + if (err) + return __hurd_fail (err); + + err = __setauth (newauth); + __mach_port_deallocate (__mach_task_self (), newauth); + return err; } diff -Nru glibc-1.02/sysdeps/mach/hurd/__setpgrp.c glibc-1.03/sysdeps/mach/hurd/__setpgrp.c --- glibc-1.02/sysdeps/mach/hurd/__setpgrp.c Wed Oct 23 14:40:02 1991 +++ glibc-1.03/sysdeps/mach/hurd/__setpgrp.c Wed Mar 25 19:57:59 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -26,7 +26,8 @@ int DEFUN(__setpgrp, (pid, pgid), pid_t pid AND pid_t pgid) { - error_t err = __proc_setpgrp (_hurd_proc, pid, pgid); + error_t err = _HURD_PORT_USE (&_hurd_proc, + __proc_setpgrp (port, pid, pgid)); if (err) return __hurd_fail (err); return 0; diff -Nru glibc-1.02/sysdeps/mach/hurd/__setregid.c glibc-1.03/sysdeps/mach/hurd/__setregid.c --- glibc-1.02/sysdeps/mach/hurd/__setregid.c Wed Oct 30 09:02:34 1991 +++ glibc-1.03/sysdeps/mach/hurd/__setregid.c Thu Apr 2 00:43:39 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -29,7 +29,8 @@ __mutex_lock (&_hurd_idlock); if (!_hurd_id_valid) { - error_t err = __auth_getids (_hurd_auth, &_hurd_id); + error_t err = _HURD_PORT_USE (&_hurd_auth, + __auth_getids (port, &_hurd_id)); if (err) { __mutex_unlock (&_hurd_idlock); @@ -53,7 +54,7 @@ sizeof (_hurd_id.gids[0]))) { __mutex_unlock (&_hurd_idlock); - errno = ENOMEM; /* ? */ + errno = ENOMEM; /* XXX ? */ return -1; } else @@ -65,16 +66,15 @@ _hurd_id.rgid = rgid; - if (err = auth_makeauth (_hurd_auth, &_hurd_id, &newauth)) - { - _hurd_id_valid = 0; - __mutex_unlock (&_hurd_idlock); - return __hurd_fail (err); - } - else - { - int err = __setauth (newauth); - __mach_port_deallocate (__mach_task_self (), newauth); - return err; - } + err = _HURD_PORT_USE (&_hurd_auth, + __auth_makeauth (port, &_hurd_id, &newauth)); + _hurd_id_valid = 0; + __mutex_unlock (&_hurd_idlock); + + if (err) + return __hurd_fail (err); + + err = __setauth (newauth); + __mach_port_deallocate (__mach_task_self (), newauth); + return err; } diff -Nru glibc-1.02/sysdeps/mach/hurd/__setreuid.c glibc-1.03/sysdeps/mach/hurd/__setreuid.c --- glibc-1.02/sysdeps/mach/hurd/__setreuid.c Wed Oct 23 19:20:07 1991 +++ glibc-1.03/sysdeps/mach/hurd/__setreuid.c Thu Apr 2 00:43:42 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -29,7 +29,8 @@ __mutex_lock (&_hurd_idlock); if (!_hurd_id_valid) { - error_t err = __auth_getids (_hurd_auth, &_hurd_id); + error_t err = _HURD_PORT_USE (&_hurd_auth, + __auth_getids (port, &_hurd_id)); if (err) { __mutex_unlock (&_hurd_idlock); @@ -52,7 +53,7 @@ if (_hurd_id.nuids == sizeof (_hurd_id.uids) / sizeof (_hurd_id.uids[0])) { __mutex_unlock (&_hurd_idlock); - errno = ENOMEM; /* ? */ + errno = ENOMEM; /* XXX ? */ return -1; } else @@ -64,16 +65,15 @@ _hurd_id.ruid = ruid; - if (err = auth_makeauth (_hurd_auth, &_hurd_id, &newauth)) - { - _hurd_id_valid = 0; - __mutex_unlock (&_hurd_idlock); - return __hurd_fail (err); - } - else - { - int err = __setauth (newauth); - __mach_port_deallocate (__mach_task_self (), newauth); - return err; - } + err = _HURD_PORT_USE (&_hurd_auth, + __auth_makeauth (port, &_hurd_id, &newauth)); + _hurd_id_valid = 0; + __mutex_unlock (&_hurd_idlock); + + if (err) + return __hurd_fail (err); + + err = __setauth (newauth); + __mach_port_deallocate (__mach_task_self (), newauth); + return err; } diff -Nru glibc-1.02/sysdeps/mach/hurd/__setsid.c glibc-1.03/sysdeps/mach/hurd/__setsid.c --- glibc-1.02/sysdeps/mach/hurd/__setsid.c Fri Oct 25 20:27:25 1991 +++ glibc-1.03/sysdeps/mach/hurd/__setsid.c Wed Mar 25 20:00:08 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -27,7 +27,7 @@ int DEFUN_VOID(__setsid) { - error_t err = __proc_setsid (_hurd_proc); + error_t err = _HURD_PORT_USE (&_hurd_proc, __proc_setsid (port)); if (err) return __hurd_fail (err); return 0; diff -Nru glibc-1.02/sysdeps/mach/hurd/__settod.c glibc-1.03/sysdeps/mach/hurd/__settod.c --- glibc-1.02/sysdeps/mach/hurd/__settod.c Wed Oct 30 09:02:33 1991 +++ glibc-1.03/sysdeps/mach/hurd/__settod.c Wed Mar 25 20:00:46 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -41,10 +41,9 @@ err = __host_set_time (hostpriv, tv); __mach_port_deallocate (__mach_task_self (), hostpriv); + if (err) - { - errno = EIO; /* ??? */ - return -1; - } + return __hurd_fail (err); + return 0; } diff -Nru glibc-1.02/sysdeps/mach/hurd/__setuid.c glibc-1.03/sysdeps/mach/hurd/__setuid.c --- glibc-1.02/sysdeps/mach/hurd/__setuid.c Wed Oct 23 18:24:33 1991 +++ glibc-1.03/sysdeps/mach/hurd/__setuid.c Thu Apr 2 00:43:44 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -33,7 +33,8 @@ __mutex_lock (&_hurd_idlock); if (!_hurd_id_valid) { - error_t err = __auth_getids (_hurd_auth, &_hurd_id); + error_t err = _HURD_PORT_USE (&_hurd_auth, + __auth_getids (port, &_hurd_id)); if (err) { __mutex_unlock (&_hurd_idlock); @@ -68,16 +69,15 @@ _hurd_id.ruid = _hurd_id.uids[0]; - if (err = auth_makeauth (_hurd_auth, &_hurd_id, &newauth)) - { - _hurd_id_valid = 0; - __mutex_unlock (&_hurd_idlock); - return __hurd_fail (err); - } - else - { - int err = __setauth (newauth); - __mach_port_deallocate (__mach_task_self (), newauth); - return err; - } + err = _HURD_PORT_USE (&_hurd_auth, + __auth_makeauth (port, &_hurd_id, &newauth)); + _hurd_id_valid = 0; + __mutex_unlock (&_hurd_idlock); + + if (err) + return __hurd_fail (err); + + err = __setauth (newauth); + __mach_port_deallocate (__mach_task_self (), newauth); + return err; } diff -Nru glibc-1.02/sysdeps/mach/hurd/__sigact.c glibc-1.03/sysdeps/mach/hurd/__sigact.c --- glibc-1.02/sysdeps/mach/hurd/__sigact.c Sat Feb 1 14:58:29 1992 +++ glibc-1.03/sysdeps/mach/hurd/__sigact.c Wed Mar 25 20:03:40 1992 @@ -51,24 +51,8 @@ old = ss->actions[sig]; if (act != NULL) - { - /* If SIG is to be ignored, remove it from the pending set. */ - if (a.sa_handler == SIG_IGN) - __sigdelmember (sig, &ss->pending); - else - switch (sig) - { - case SIGCONT: - case SIGIO: - case SIGURG: - case SIGCHLD: - case SIGWINCH: - if (a.sa_handler == SIG_DFL) - __sigdelmember (sig, &ss->pending); - } - - ss->actions[sig] = a; - } + ss->actions[sig] = a; + __mutex_unlock (&ss->lock); if (oact != NULL) diff -Nru glibc-1.02/sysdeps/mach/hurd/__sigproc.c glibc-1.03/sysdeps/mach/hurd/__sigproc.c --- glibc-1.02/sysdeps/mach/hurd/__sigproc.c Sat Feb 1 15:02:07 1992 +++ glibc-1.03/sysdeps/mach/hurd/__sigproc.c Wed Mar 25 20:06:35 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -64,23 +64,9 @@ ss->blocked &= ~_SIG_CANT_BLOCK; - pending = ss->pending & ~ss->blocked; - for (i = 1; i < NSIG; ++i) - if (pending & __sigmask (i)) - { - /* Post the first pending signal. - This call will deal with the remaining pending signals. - The call releases SS->lock. */ - int ignore; - __sigdelmember (i, &ss->pending); - (void) _hurd_internal_post_signal (MACH_PORT_NULL, - ss, - signo, - ss->sigcodes[signo], - 0, 0, &ignore, - NULL); - break; - } + if (ss->pending & ~ss->blocked) + /* XXX deliver pending signals */ + ; } __mutex_unlock (&ss->lock); diff -Nru glibc-1.02/sysdeps/mach/hurd/__symlink.c glibc-1.03/sysdeps/mach/hurd/__symlink.c --- glibc-1.02/sysdeps/mach/hurd/__symlink.c Wed Oct 23 18:36:12 1991 +++ glibc-1.03/sysdeps/mach/hurd/__symlink.c Wed Mar 25 20:11:05 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -27,17 +27,13 @@ DEFUN(__symlink, (from, to), CONST char *from AND CONST char *to) { error_t err; - file_t todir; - const char *toname; file_t node; - todir = __hurd_path_split (to, &toname); - if (todir == MACH_PORT_NULL) + node = __path_lookup (to, FS_LOOKUP_CREATE|FS_LOOKUP_WRITE|FS_LOOKUP_EXCL, + 0777 & _hurd_umask); + if (node == MACH_PORT_NULL) return -1; - err = __dir_lookup (todir, toname, - FS_LOOKUP_CREATE|FS_LOOKUP_WRITE|FS_LOOKUP_EXCL, - 0777 & umask, - &file); + if (!err) { size_t to_write = strlen (from); @@ -44,19 +40,20 @@ while (to_write > 0) { size_t wrote; - if (err = __io_write (file, from, strlen (from), -1, &wrote)) + if (err = __io_write (node, from, to_write, -1, &wrote)) break; to_write -= wrote; from += wrote; } - __mach_port_deallocate (__mach_task_self (), file); } if (!err) - err = __dir_set_translator (todir, toname, FS_TRANS_EXCL, FS_GOAWAY_DONT, - _HURD_SYMLINK, - MACH_PORT_NULL); - __mach_port_deallocate (__mach_task_self (), todir); + err = __file_set_translator (node, FS_TRANS_EXCL, 0, + _HURD_SYMLINK, MACH_PORT_NULL); + + /* XXX can leave half-finished file */ + + __mach_port_deallocate (__mach_task_self (), node); if (err) return __hurd_fail (err); diff -Nru glibc-1.02/sysdeps/mach/hurd/__umask.c glibc-1.03/sysdeps/mach/hurd/__umask.c --- glibc-1.02/sysdeps/mach/hurd/__umask.c Wed Oct 30 09:02:31 1991 +++ glibc-1.03/sysdeps/mach/hurd/__umask.c Wed Mar 25 20:12:08 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -25,9 +25,8 @@ DEFUN(__umask, (mask), mode_t mask) { mode_t omask; - __mutex_lock (&_hurd_lock); + mask &= 0777; omask = _hurd_umask; - _hurd_umask = mask & 0777; - __mutex_unlock (&_hurd_lock); + _hurd_umask = mask; return omask; } diff -Nru glibc-1.02/sysdeps/mach/hurd/__unlink.c glibc-1.03/sysdeps/mach/hurd/__unlink.c --- glibc-1.02/sysdeps/mach/hurd/__unlink.c Wed Oct 23 10:18:56 1991 +++ glibc-1.03/sysdeps/mach/hurd/__unlink.c Wed Mar 25 20:16:45 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -20,6 +20,7 @@ #include #include #include +#include /* Remove the link named NAME. */ @@ -30,7 +31,7 @@ file_t dir; CONST char *file; - dir = __hurd_path_split (name, &file); + dir = __path_split (name, &file); if (dir == MACH_PORT_NULL) return -1; diff -Nru glibc-1.02/sysdeps/mach/hurd/__utimes.c glibc-1.03/sysdeps/mach/hurd/__utimes.c --- glibc-1.02/sysdeps/mach/hurd/__utimes.c Mon Oct 28 21:37:31 1991 +++ glibc-1.03/sysdeps/mach/hurd/__utimes.c Wed Mar 25 20:16:42 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -28,7 +28,7 @@ CONST char *file AND struct timeval tvp[2]) { error_t err; - file_t f = __hurd_path_lookup (file, 0, 0); + file_t f = __path_lookup (file, 0, 0); if (f == MACH_PORT_NULL) return -1; err = __file_utimes (f, &tvp[0], &tvp[1]); diff -Nru glibc-1.02/sysdeps/mach/hurd/__wait4.c glibc-1.03/sysdeps/mach/hurd/__wait4.c --- glibc-1.02/sysdeps/mach/hurd/__wait4.c Sat Feb 1 15:06:19 1992 +++ glibc-1.03/sysdeps/mach/hurd/__wait4.c Wed Mar 25 20:13:48 1992 @@ -28,18 +28,9 @@ { pid_t dead; error_t err; - if (options & WNOHANG) - { - __mutex_lock (&_hurd_lock); - err = __proc_wait (_hurd_proc, pid, stat_loc, options, usage, &dead); - __mutex_unlock (&_hurd_lock); - } - else - { - process_t proc = _hurd_getport (&_hurd_proc, &_hurd_lock); - err = __proc_wait (proc, pid, stat_loc, options, usage, &dead); - __mach_port_deallocate (__mach_task_self (), proc); - } + + err = _HURD_PORT_USE (&_hurd_proc, __proc_wait (port, pid, stat_loc, + options, usage, &dead)); if (err) return __hurd_fail (err); return dead; diff -Nru glibc-1.02/sysdeps/mach/hurd/__write.c glibc-1.03/sysdeps/mach/hurd/__write.c --- glibc-1.02/sysdeps/mach/hurd/__write.c Wed Oct 23 16:09:34 1991 +++ glibc-1.03/sysdeps/mach/hurd/__write.c Wed Mar 25 20:16:04 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -26,28 +26,44 @@ int fd AND CONST PTR buf AND size_t nbytes) { error_t err; - io_t server; - int isctty; size_t wrote; - __mutex_lock (&_hurd_dtable.lock); - if (fd < 0 || fd >= _hurd_dtable.size || - _hurd_dtable.d[fd].server == MACH_PORT_NULL) - { - __mutex_unlock (&_hurd_dtable.lock); - errno = EBADF; - return -1; - } - - server = _hurd_dtable.d[fd].server; - isctty = _hurd_ctty_check (fd); - __mutex_unlock (&_hurd_dtable.lock); + data = buf; + _HURD_DPORT_USE + (fd, + ({ + call: + err = __io_write (port, buf, nbytes, -1, &wrote); + if (ctty != MACH_PORT_NULL && err == EBACKGROUND) + { + struct _hurd_sigstate *ss + = _hurd_thread_sigstate (__mach_thread_self ()); + if (_hurd_orphaned || + __sigismember (SIGTTOU, &ss->blocked) || + ss->actions[SIGTTOU].sa_handler == SIG_IGN) + { + /* We are orphaned, or are blocking or ignoring SIGTTOU. + Return EIO instead of stopping. */ + __mutex_unlock (&ss->lock); + err = EIO; + } + else + { + const int restart = ss->actions[SIGTTOI].sa_flags & SA_RESTART; + __sigaddmember (SIGTTOU, &ss->pending); + __mutex_unlock (&ss->lock); + /* XXX deliver pending signals */ + if (restart) + goto call; + else + err = EINTR; /* XXX Is this right? */ + } + } + })); - err = __io_write (server, isctty, _hurd_pid, _hurd_pgrp, - buf, nbytes, -1, &wrote); - if (err) return __hurd_fail (err); return wrote; } + diff -Nru glibc-1.02/sysdeps/mach/hurd/_exit.c glibc-1.03/sysdeps/mach/hurd/_exit.c --- glibc-1.02/sysdeps/mach/hurd/_exit.c Sat Feb 1 15:06:24 1992 +++ glibc-1.03/sysdeps/mach/hurd/_exit.c Wed Mar 25 20:16:39 1992 @@ -26,12 +26,16 @@ /* Does not return (when applied to the calling task). */ extern volatile void __task_terminate (task_t); +#if 0 struct _hurd_sigstate *ss = _hurd_thread_sigstate (__mach_thread_self ()); +#endif - __proc_exit (_hurd_proc, status); + _HURD_PORT_USE (&_hurd_proc, __proc_exit (port, status)); +#if 0 if (ss->vforked) longjmp (ss->vfork_saved.continuation, 1); +#endif __task_terminate (__mach_task_self ()); } diff -Nru glibc-1.02/sysdeps/mach/hurd/accept.c glibc-1.03/sysdeps/mach/hurd/accept.c --- glibc-1.02/sysdeps/mach/hurd/accept.c Sat Feb 8 02:15:22 1992 +++ glibc-1.03/sysdeps/mach/hurd/accept.c Wed Mar 25 20:18:49 1992 @@ -45,5 +45,5 @@ return __hurd_fail (err); } - return _hurd_dalloc (new, 0); + return _hurd_dalloc (new, MACH_PORT_NULL, 0); } diff -Nru glibc-1.02/sysdeps/mach/hurd/bind.c glibc-1.03/sysdeps/mach/hurd/bind.c --- glibc-1.02/sysdeps/mach/hurd/bind.c Sat Feb 8 02:15:19 1992 +++ glibc-1.03/sysdeps/mach/hurd/bind.c Wed Mar 25 20:22:58 1992 @@ -26,12 +26,19 @@ DEFUN(bind, (fd, addr, len), int fd AND struct sockaddr *addr AND size_t len) { - return _HURD_DPORT_USE + error_t err; + + _HURD_DPORT_USE (fd, ({ - error_t err; addr_port_t aport; err = __socket_create_address (port, addr, len, &aport, 1); - err ? __hurd_fail (err) : 0; - })); + if (!err) + err = __socket_bind (port, aport); + __mach_port_deallocate (__mach_task_self (), aport); + })); + + if (err) + return __hurd_fail (err); + return 0; } diff -Nru glibc-1.02/sysdeps/mach/hurd/chflags.c glibc-1.03/sysdeps/mach/hurd/chflags.c --- glibc-1.02/sysdeps/mach/hurd/chflags.c Wed Oct 23 18:56:00 1991 +++ glibc-1.03/sysdeps/mach/hurd/chflags.c Thu Apr 2 00:28:43 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -26,7 +26,7 @@ DEFUN(chflags, (file, flags), CONST char *file AND int flags) { error_t err; - file_t port = __hurd_path_lookup (file, 0, 0); + file_t port = __path_lookup (file, 0, 0); if (port == MACH_PORT_NULL) return -1; err = __file_chflags (port, flags); diff -Nru glibc-1.02/sysdeps/mach/hurd/chroot.c glibc-1.03/sysdeps/mach/hurd/chroot.c --- glibc-1.02/sysdeps/mach/hurd/chroot.c Wed Oct 30 09:02:27 1991 +++ glibc-1.03/sysdeps/mach/hurd/chroot.c Thu Apr 2 00:28:40 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -29,15 +29,11 @@ error_t err; file_t old, crdir; - crdir = __hurd_path_lookup (path, FS_LOOKUP_EXECUTE, 0); + crdir = __path_lookup (path, FS_LOOKUP_EXECUTE, 0); if (crdir == MACH_PORT_NULL) return -1; - __mutex_lock (&_hurd_lock); - old = _hurd_crdir; - _hurd_crdir = crdir; - __mutex_lock (&_hurd_lock); - __mach_port_deallocate (__mach_task_self (), old); + _hurd_port_set (&_hurd_crdir, crdir); return 0; } diff -Nru glibc-1.02/sysdeps/mach/hurd/defs.c glibc-1.03/sysdeps/mach/hurd/defs.c --- glibc-1.02/sysdeps/mach/hurd/defs.c Wed Oct 30 11:10:46 1991 +++ glibc-1.03/sysdeps/mach/hurd/defs.c Thu Apr 2 00:28:37 1992 @@ -1,6 +1,6 @@ /* Definitions of global stdio data structures. -Copyright (C) 1991 Free Software Foundation, Inc. +Copyright (C) 1991, 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 @@ -50,6 +50,6 @@ void DEFUN_VOID(_cleanup) { - (void) fclose((FILE *) NULL); + (void) fclose ((FILE *) NULL); } -text_set_element(__libc_atexit, _cleanup); +text_set_element (__libc_atexit, _cleanup); diff -Nru glibc-1.02/sysdeps/mach/hurd/fchflags.c glibc-1.03/sysdeps/mach/hurd/fchflags.c --- glibc-1.02/sysdeps/mach/hurd/fchflags.c Wed Oct 23 18:57:10 1991 +++ glibc-1.03/sysdeps/mach/hurd/fchflags.c Thu Apr 2 00:28:31 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -26,20 +26,9 @@ DEFUN(fchflags, (fd, flags), int fd AND int flags) { error_t err; - io_t server; - __mutex_lock (&_hurd_dtable.lock); - if (fd < 0 || fd >= _hurd_dtable.size || - _hurd_dtable.d[fd].server == MACH_PORT_NULL) - { - __mutex_unlock (&_hurd_dtable.lock); - errno = EBADF; - return -1; - } - server = _hurd_dtable.d[fd].server; - __mutex_unlock (&_hurd_dtable.lock); - - if (err = __file_chflags (server, flags)) + if (err = _HURD_DPORT_USE (fd, __file_chflags (port, flags))) return __hurd_fail (err); + return 0; } diff -Nru glibc-1.02/sysdeps/mach/hurd/fsync.c glibc-1.03/sysdeps/mach/hurd/fsync.c --- glibc-1.02/sysdeps/mach/hurd/fsync.c Wed Oct 30 09:02:24 1991 +++ glibc-1.03/sysdeps/mach/hurd/fsync.c Thu Apr 2 00:14:18 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -25,15 +25,8 @@ int DEFUN(fsync, (fd), int fd) { - error_t err; - file_t server; - __mutex_lock (&_hurd_dtable.lock); - server = _hurd_dport (fd); - if (server == MACH_PORT_NULL) - return -1; - __mutex_unlock (&_hurd_dtable.lock); - - if (err = __file_sync (server)) + error_t err = _HURD_DPORT_USE (fd, __file_sync (port)); + if (err) return __hurd_fail (err); return 0; } diff -Nru glibc-1.02/sysdeps/mach/hurd/ftruncate.c glibc-1.03/sysdeps/mach/hurd/ftruncate.c --- glibc-1.02/sysdeps/mach/hurd/ftruncate.c Fri Oct 25 20:26:26 1991 +++ glibc-1.03/sysdeps/mach/hurd/ftruncate.c Thu Apr 2 00:28:26 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -26,20 +26,7 @@ int fd AND off_t length) { error_t err; - file_t server; - - __mutex_lock (&_hurd_dtable.lock); - if (fd < 0 || fd >= _hurd_dtable.size || - _hurd_dtable.d[fd].server == MACH_PORT_NULL) - { - __mutex_unlock (&_hurd_dtable.lock); - errno = EBADF; - return -1; - } - server = _hurd_dtable.d[fd].server; - __mutex_unlock (&_hurd_dtable.lock); - - if (err = __file_truncate (server, length)) + if (err = _HURD_DPORT_USE (fd, __file_truncate (port, length))) return __hurd_fail (err); return 0; } diff -Nru glibc-1.02/sysdeps/mach/hurd/gethostid.c glibc-1.03/sysdeps/mach/hurd/gethostid.c --- glibc-1.02/sysdeps/mach/hurd/gethostid.c Fri Oct 25 20:30:27 1991 +++ glibc-1.03/sysdeps/mach/hurd/gethostid.c Thu Apr 2 00:28:24 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -26,7 +26,7 @@ { long int hostid; error_t err; - if (err = __proc_gethostid (_hurd_proc, &hostid)) + if (err = _HURD_PORT_USE (&_hurd_proc, __proc_gethostid (port, &hostid))) return __hurd_fail (err); return hostid; } diff -Nru glibc-1.02/sysdeps/mach/hurd/getlogin.c glibc-1.03/sysdeps/mach/hurd/getlogin.c --- glibc-1.02/sysdeps/mach/hurd/getlogin.c Mon Nov 11 23:11:32 1991 +++ glibc-1.03/sysdeps/mach/hurd/getlogin.c Thu Apr 2 00:28:20 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -30,10 +30,11 @@ static char login[1024]; error_t err; - if (err = __proc_getlogin (_hurd_proc, login)) + if (err = _HURD_PORT_USE (&_hurd_proc, __proc_getlogin (port, login))) { - errno = __hurd_errno (err); + errno = err; return NULL; } + return login; } diff -Nru glibc-1.02/sysdeps/mach/hurd/getprio.c glibc-1.03/sysdeps/mach/hurd/getprio.c --- glibc-1.02/sysdeps/mach/hurd/getprio.c Wed Oct 23 20:41:59 1991 +++ glibc-1.03/sysdeps/mach/hurd/getprio.c Thu Apr 2 00:35:14 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -30,7 +30,8 @@ enum __priority_which which AND int who) { int prio; - error_t err = __proc_getpriority (_hurd_proc, which, who, &prio); + error_t err = _HURD_PORT_USE (&_hurd_proc, + __proc_getpriority (port, which, who, &prio)); if (err) return __hurd_fail (err); return prio; diff -Nru glibc-1.02/sysdeps/mach/hurd/i386/sigcontext.h glibc-1.03/sysdeps/mach/hurd/i386/sigcontext.h --- glibc-1.02/sysdeps/mach/hurd/i386/sigcontext.h Fri Feb 7 18:02:22 1992 +++ glibc-1.03/sysdeps/mach/hurd/i386/sigcontext.h Thu Apr 2 00:37:46 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -26,7 +26,7 @@ sigset_t sc_mask; /* Blocked signals to restore. */ /* Port this thread is doing an interruptible RPC on. */ - unsigned long int intr_port; + unsigned long int sc_intr_port; /* Segment registers (not used). */ int sc_gs; diff -Nru glibc-1.02/sysdeps/mach/hurd/i386/start.c glibc-1.03/sysdeps/mach/hurd/i386/start.c --- glibc-1.02/sysdeps/mach/hurd/i386/start.c Wed Oct 30 12:02:02 1991 +++ glibc-1.03/sysdeps/mach/hurd/i386/start.c Fri Apr 3 22:46:09 1992 @@ -2,8 +2,9 @@ asm volatile ("movl %0, %%esp" : : "g" (sp) : "%esp") #define GET_STACK(low, high) \ ({ \ - register vm_address_t ax asm ("%eax"), sp asm ("%esp"); \ - high = sp; \ + register vm_address_t ax asm ("%eax"); \ + high = ~0U; \ low = ax; \ }) +#define LOSE asm ("hlt") #include diff -Nru glibc-1.02/sysdeps/mach/hurd/rename.c glibc-1.03/sysdeps/mach/hurd/rename.c --- glibc-1.02/sysdeps/mach/hurd/rename.c Wed Oct 23 20:34:41 1991 +++ glibc-1.03/sysdeps/mach/hurd/rename.c Thu Apr 2 00:38:37 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -28,10 +28,10 @@ file_t olddir, newdir; const char *oldname, *newname; - olddir = __hurd_path_split (old, &oldname); + olddir = __path_split (old, &oldname); if (olddir == MACH_PORT_NULL) return -1; - newdir = __hurd_path_split (new, &newname); + newdir = __path_split (new, &newname); if (newdir == MACH_PORT_NULL) { __mach_port_deallocate (__mach_task_self (), olddir); diff -Nru glibc-1.02/sysdeps/mach/hurd/setgroups.c glibc-1.03/sysdeps/mach/hurd/setgroups.c --- glibc-1.02/sysdeps/mach/hurd/setgroups.c Mon Nov 11 23:11:30 1991 +++ glibc-1.03/sysdeps/mach/hurd/setgroups.c Thu Apr 2 00:44:04 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -42,7 +42,8 @@ __mutex_lock (&_hurd_idlock); if (!_hurd_id_valid) { - error_t err = __auth_getids (_hurd_auth, &_hurd_id); + error_t err = _HURD_PORT_USE (&_hurd_auth, + __auth_getids (port, &_hurd_id)); if (err) { __mutex_unlock (&_hurd_idlock); @@ -54,10 +55,16 @@ _hurd_id.ngroups = n; memcpy (_hurd_id.groups, groups, n * sizeof (gid_t)); _hurd_id_valid = 0; - err = __auth_makeauth (_hurd_auth, &_hurd_id, &newauth); + + err = _HURD_PORT_USE (&_hurd_auth, + __auth_makeauth (port, &_hurd_id, &newauth)); + _hurd_id_valid = 0; __mutex_unlock (&_hurd_idlock); + if (err) return __hurd_fail (err); - return __setauth (newauth); + err = __setauth (newauth); + __mach_port_deallocate (__mach_task_self (), newauth); + return err; } diff -Nru glibc-1.02/sysdeps/mach/hurd/sethostid.c glibc-1.03/sysdeps/mach/hurd/sethostid.c --- glibc-1.02/sysdeps/mach/hurd/sethostid.c Fri Oct 25 20:30:56 1991 +++ glibc-1.03/sysdeps/mach/hurd/sethostid.c Thu Apr 2 00:51:44 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -25,7 +25,7 @@ int DEFUN(sethostid, (id), long int id) { - error_t err = __proc_sethostid (_hurd_proc, id); + error_t err = _HURD_PORT_USE (&_hurd_proc, __proc_sethostid (port, id)); if (err) return __hurd_fail (err); return 0; diff -Nru glibc-1.02/sysdeps/mach/hurd/sethostnam.c glibc-1.03/sysdeps/mach/hurd/sethostnam.c --- glibc-1.02/sysdeps/mach/hurd/sethostnam.c Fri Oct 25 20:31:41 1991 +++ glibc-1.03/sysdeps/mach/hurd/sethostnam.c Thu Apr 2 00:51:41 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -26,7 +26,8 @@ DEFUN(sethostname, (name, len), CONST char *name AND size_t len) { - error_t err = __proc_sethostname (_hurd_proc, name, len); + error_t err = _HURD_PORT_USE (&_hurd_proc, + __proc_sethostname (port, name, len)); if (err) return __hurd_fail (err); return 0; diff -Nru glibc-1.02/sysdeps/mach/hurd/setlogin.c glibc-1.03/sysdeps/mach/hurd/setlogin.c --- glibc-1.02/sysdeps/mach/hurd/setlogin.c Mon Oct 28 21:32:47 1991 +++ glibc-1.03/sysdeps/mach/hurd/setlogin.c Thu Apr 2 00:51:38 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -25,7 +25,7 @@ DEFUN(setlogin, (name), CONST char *name) { error_t err; - if (err = __proc_setlogin (_hurd_proc, name)) + if (err = _HURD_PORT_USE (&_hurd_proc, __proc_setlogin (port, name))) return __hurd_fail (err); return 0; } diff -Nru glibc-1.02/sysdeps/mach/hurd/setrlimit.c glibc-1.03/sysdeps/mach/hurd/setrlimit.c --- glibc-1.02/sysdeps/mach/hurd/setrlimit.c Fri Nov 1 22:40:32 1991 +++ glibc-1.03/sysdeps/mach/hurd/setrlimit.c Thu Apr 2 00:51:35 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -41,7 +41,7 @@ case RLIMIT_CORE: _hurd_core_limit = rlimits->rlim_cur; - break; + return 0; case RLIMIT_DATA: return _hurd_set_data_limit (rlimits); @@ -53,6 +53,4 @@ errno = ENOSYS; return -1; } - - return 0; } diff -Nru glibc-1.02/sysdeps/mach/hurd/sigsuspend.c glibc-1.03/sysdeps/mach/hurd/sigsuspend.c --- glibc-1.02/sysdeps/mach/hurd/sigsuspend.c Fri Nov 15 22:26:01 1991 +++ glibc-1.03/sysdeps/mach/hurd/sigsuspend.c Thu Apr 2 00:51:31 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -43,25 +43,11 @@ while ((pending = ss->pending & ~ss->blocked) == 0) __condition_wait (&ss->arrived, &ss->lock); ss->suspended = 0; + __mutex_unlock (&ss->lock); - for (sig = 1; sig < NSIG; ++sig) - if (pending & __sigmask (sig)) - { - /* Post the first pending signal. - This call will handle any more pending signals, - and it will release SS->lock before returning. */ - (void) _hurd_internal_post_signal (ss->suspend_reply, - ss, - signo, - ss->sigcodes[signo], - 0, 0, &ignore, - &omask); - /* We've been interrupted! And a good thing, too. - Otherwise we'd never return. - That's right; this function always returns an error. */ - errno = EINTR; - return -1; - } - - __libc_fatal ("sigsuspend: Woken up by nonexistent signal.\n"); + /* We've been interrupted! And a good thing, too. + Otherwise we'd never return. + That's right; this function always returns an error. */ + errno = EINTR; + return -1; } diff -Nru glibc-1.02/sysdeps/mach/hurd/sleep.c glibc-1.03/sysdeps/mach/hurd/sleep.c --- glibc-1.02/sysdeps/mach/hurd/sleep.c Sat Feb 8 03:51:08 1992 +++ glibc-1.03/sysdeps/mach/hurd/sleep.c Thu Apr 2 00:51:25 1992 @@ -36,8 +36,8 @@ recv = _hurd_dead_recv (); before = time ((time_t *) NULL); - __mach_msg (NULL, MACH_MSG_OPTION_TIMEOUT, 0, 0, - recv, seconds * 1000, MACH_PORT_NULL); + (void) __mach_msg (NULL, MACH_MSG_OPTION_TIMEOUT|MACH_MSG_RCV_INTERRUPT, + 0, 0, recv, seconds * 1000, MACH_PORT_NULL); after = time ((time_t *) NULL); return (after - before); diff -Nru glibc-1.02/sysdeps/mach/hurd/socket.c glibc-1.03/sysdeps/mach/hurd/socket.c --- glibc-1.02/sysdeps/mach/hurd/socket.c Sat Feb 8 02:15:21 1992 +++ glibc-1.03/sysdeps/mach/hurd/socket.c Thu Apr 2 01:09:55 1992 @@ -37,5 +37,5 @@ if (err = __socket_create (server, type, protocol, &sock)) return __hurd_fail (err); - return _hurd_dalloc (sock, 0); + return _hurd_dalloc (sock, MACH_PORT_NULL, 0); } diff -Nru glibc-1.02/sysdeps/mach/hurd/start.c glibc-1.03/sysdeps/mach/hurd/start.c --- glibc-1.02/sysdeps/mach/hurd/start.c Fri Jan 31 20:22:38 1992 +++ glibc-1.03/sysdeps/mach/hurd/start.c Mon Apr 6 21:13:39 1992 @@ -23,8 +23,7 @@ /* The first piece of initialized data. */ int __data_start = 0; -process_t _hurd_proc; -file_t _hurd_ccdir, _hurd_cwdir, _hurd_crdir; +struct _hurd_port _hurd_proc, _hurd_ccdir, _hurd_cwdir, _hurd_crdir; mode_t _hurd_umask; int _hurd_ctty_fstype; fsid_t _hurd_ctty_fsid; @@ -35,7 +34,7 @@ mach_port_t *_hurd_init_dtable; size_t _hurd_init_dtablesize; -volatile int errno; +volatile int errno; /* XXX wants to be per-thread */ char **__environ; @@ -54,6 +53,10 @@ #error "Machine-dependent stack startup code needs to exist." #endif +#ifndef LOSE +#define LOSE __task_terminate (__mach_task_self ()) +#endif + static int count (char *, size_t); static void makevec (char *, size_t, char **); @@ -65,12 +68,12 @@ _start (void) { error_t err; - mach_port_t in_bootstrap, passed_bootstrap; + mach_port_t in_bootstrap; char *args, *env; mach_port_t *portarray; int *intarray; size_t argslen, envlen, portarraysize, intarraysize; - int dealloc_args, dealloc_env; + int flags; int argc, envc; char **argv; @@ -83,129 +86,73 @@ __mach_init (); if (_cthread_init_routine != NULL) - SET_SP ((*_cthread_init_routine) ()); + { /* XXXXXXXXXXXXXXXXXXXXXXXX */ + void *newsp = (*_cthread_init_routine) (); + SET_SP (newsp); + if (newsp < _hurd_stack_low || newsp > _hurd_stack_high) + __vm_deallocate (__mach_task_self (), + _hurd_stack_low, + _hurd_stack_high - _hurd_stack_low); + } if (err = __task_get_special_port (__mach_task_self (), TASK_BOOTSTRAP_PORT, &in_bootstrap)) - _exit (err); - - err = __exec_startup (in_bootstrap, - &args, &argslen, &dealloc_args, - &env, &envlen, &dealloc_env, - &_hurd_init_dtable, &_hurd_init_dtablesize, - &portarray, &portarraysize, - &intarray, &intarraysize, - &passed_bootstrap); - __mach_port_deallocate (__mach_task_self (), in_bootstrap); - if (err) - _exit (err); - - /* 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, - passed_bootstrap); - __mach_port_deallocate (__mach_task_self (), passed_bootstrap); - - argc = count (args, argslen); - envc = count (env, envlen); - - if (err = __vm_allocate (__mach_task_self (), - &argv, round_page ((argc + 1 + envc + 1) * - sizeof (char *)), - 1)) - __libc_fatal ("hurd: Can't allocate space for args and env\n"); - __environ = &argv[argc + 1]; - - makevec (args, argslen, argv); - makevec (env, envlen, __environ); - - __mutex_init (&_hurd_lock); - for (i = 0; i < portarraysize; ++i) - switch (i) - { -#define initport(upper, lower) \ - case INIT_PORT_##upper: _hurd_##lower = portarray[i]; break - - initport (PROC, proc); - initport (CCDIR, ccdir); - initport (CWDIR, cwdir); - initport (CRDIR, crdir); - initport (AUTH, auth); + LOSE; - default: - /* Wonder what that could be. */ - __mach_port_deallocate (__mach_task_self (), portarray[i]); - break; - } + if (in_bootstrap != MACH_PORT_NULL) + { + err = __exec_startup (in_bootstrap, + &flags, + &args, &argslen, &env, &envlen, + &_hurd_init_dtable, &_hurd_init_dtablesize, + &portarray, &portarraysize, + &intarray, &intarraysize); + __mach_port_deallocate (__mach_task_self (), in_bootstrap); + } - if (intarraysize > INIT_UMASK) - _hurd_umask = intarray[INIT_UMASK] & 0777; + if (err || in_bootstrap == MACH_PORT_NULL) + { + static char *noargs = NULL, *noenv = NULL; + argc = 0; + argv = &null; + __environ = &noenv; + _hurd_init_dtable = NULL; + _hurd_init_dtablesize = 0; + portarray = NULL; + portarraysize = 0; + intarray = NULL; + intarraysize = 0; + } else - _hurd_umask = 0022; /* XXX */ - if (intarraysize > INIT_CTTY_FILEID) /* Knows that these are sequential. */ { - _hurd_ctty_fstype = intarray[INIT_CTTY_FSTYPE]; - _hurd_ctty_fsid.val[0] = intarray[INIT_CTTY_FSID1]; - _hurd_ctty_fsid.val[1] = intarray[INIT_CTTY_FSID2]; - _hurd_ctty_fileid = intarray[INIT_CTTY_FILEID]; + /* Turn the block of null-separated strings we were passed for the + arguments and environment into vectors of pointers to strings. */ + + argc = count (args, argslen); + envc = count (env, envlen); + + if (err = __vm_allocate (__mach_task_self (), + &argv, round_page ((argc + 1 + envc + 1) * + sizeof (char *)), + 1)) + __libc_fatal ("hurd: Can't allocate space for argv and environ\n"); + __environ = &argv[argc + 1]; + + makevec (args, argslen, argv); + makevec (env, envlen, __environ); } - { - struct _hurd_sigstate *ss; - thread_t sigthread; - mach_port_t oldsig, oldtask; - int i; - sigset_t ignored = ((nints > INIT_SIGIGN ? intarray[INIT_SIGIGN] : 0) - & ~_SIG_CANT_IGNORE); - - ss = _hurd_thread_sigstate (__mach_thread_self ()); - ss->blocked = nints > INIT_SIGMASK ? intarray[INIT_SIGMASK] : 0; - ss->blocked &= ~_SIG_CANT_BLOCK; - __sigemptyset (&ss->pending); - for (i = 1; i < NSIG; ++i) - ss->actions[i].sa_handler - = __sigismember (i, &ignored) ? SIG_IGN : SIG_DFL; - __mutex_unlock (&ss->lock); - - if (err = __mach_port_allocate (__mach_task_self (), - MACH_PORT_RIGHT_RECEIVE, - &_hurd_sigport)) - __libc_fatal ("hurd: Can't create signal port receive right\n"); - - if (err = __thread_create (__mach_task_self (), &sigthread)) - __libc_fatal ("hurd: Can't create signal thread\n"); - if (err = _hurd_start_sigthread (sigthread, _hurd_sigport_receive)) - __libc_fatal ("hurd: Can't start signal thread\n"); - _hurd_sigport_thread = sigthread; - - /* Make a send right to the signal port. */ - if (err = __mach_port_insert_right (__mach_task_self (), - _hurd_sigport, - MACH_PORT_RIGHT_MAKE_SEND)) - __libc_fatal ("hurd: Can't create send right to signal port\n"); - - /* Receive exceptions on the signal port. */ - __task_set_special_port (__mach_task_self (), - TASK_EXCEPTION, - _hurd_sigport); - - /* Give the proc server our task and signal ports. */ - __proc_setports (_hurd_proc, _hurd_sigport, __mach_task_self (), - &oldsig, &oldtask); - if (oldsig != MACH_PORT_NULL) - __mach_port_deallocate (__mach_task_self (), oldsig); - if (oldtask != MACH_PORT_NULL) - __mach_port_deallocate (__mach_task_self (), oldtask); - - /* Free the send right we gave to the proc server. */ - __mach_port_deallocate (__mach_task_self (), _hurd_sigport); - } + /* Initialize library data structures, start signal processing, etc. */ + _hurd_init (argv, + portarray, portarraysize, + intarray, intarraysize); - /* Tell the proc server where our args and environment are. */ - __proc_setprocargs (_hurd_proc, argv, __environ); + /* Random library initialization. */ __libc_init (argc, argv, __environ); + + /* Finally, run the user program. */ (_cthread_exit_routine != NULL ? *_cthread_exit_routine : exit) (main (argc, argv, __environ)); } @@ -254,4 +201,68 @@ } argv[argc] = NULL; +} + +/* Initialize the library data structures from the + ints and ports passed to us by the exec server. + + PORTARRAY and INTARRAY are vm_deallocate'd. */ + +void +_hurd_init (char **argv, + mach_port_t *portarray, size_t portarraysize, + int *intarray, size_t intarraysize) +{ + int i; + + /* See what ports we were passed. */ + for (i = 0; i < portarraysize; ++i) + switch (i) + { +#define initport(upper, lower) \ + case INIT_PORT_##upper: \ + _hurd_port_init (&_hurd_##lower, portarray[i]); \ + break + + /* Install the standard ports in their cells. */ + initport (CCDIR, ccdir); + initport (CWDIR, cwdir); + initport (CRDIR, crdir); + initport (AUTH, auth); + + case INIT_PORT_PROC: + /* Install the proc port and tell the proc server we exist. */ + _hurd_proc_init (portarray[i], 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]); + /* FALLTHROUGH */ + + default: + /* Wonder what that could be. */ + __mach_port_deallocate (__mach_task_self (), portarray[i]); + break; + } + + if (intarraysize > INIT_UMASK) + _hurd_umask = intarray[INIT_UMASK] & 0777; + else + _hurd_umask = 0022; /* XXX */ + if (intarraysize > INIT_CTTY_FILEID) /* Knows that these are sequential. */ + { + _hurd_ctty_fstype = intarray[INIT_CTTY_FSTYPE]; + _hurd_ctty_fsid.val[0] = intarray[INIT_CTTY_FSID1]; + _hurd_ctty_fsid.val[1] = intarray[INIT_CTTY_FSID2]; + _hurd_ctty_fileid = intarray[INIT_CTTY_FILEID]; + } + + + /* All done with init ints and ports. */ + __vm_deallocate (__mach_task_self (), intarray, nints * sizeof (int)); + __vm_deallocate (__mach_task_self (), + portarray, nports * sizeof (mach_port_t)); } diff -Nru glibc-1.02/sysdeps/mach/hurd/sync.c glibc-1.03/sysdeps/mach/hurd/sync.c --- glibc-1.02/sysdeps/mach/hurd/sync.c Wed Oct 23 10:38:25 1991 +++ glibc-1.03/sysdeps/mach/hurd/sync.c Thu Apr 2 01:09:48 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -24,7 +24,7 @@ int DEFUN_VOID(sync) { - error_t err = __file_syncfs (_hurd_crdir, 1, 1); + error_t err = _HURD_PORT_USE (&_hurd_crdir, __file_syncfs (port, 1, 1)); if (err) return __hurd_fail (err); return 0; diff -Nru glibc-1.02/sysdeps/mach/hurd/sysd-stdio.c glibc-1.03/sysdeps/mach/hurd/sysd-stdio.c --- glibc-1.02/sysdeps/mach/hurd/sysd-stdio.c Sat Nov 16 17:32:58 1991 +++ glibc-1.03/sysdeps/mach/hurd/sysd-stdio.c Thu Apr 2 01:15:06 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -65,7 +65,7 @@ } /* Move COOKIE's file position *POS bytes, according to WHENCE. - The old file position is stored in *POS. + The current file position is stored in *POS. Returns zero if successful, nonzero if not. */ int DEFUN(__stdio_seek, (cookie, pos, whence), @@ -117,7 +117,7 @@ if (m.__exclusive) flags |= FS_LOOKUP_EXCL; - file = __hurd_path_lookup (filename, flags, 0666 & ~_hurd_umask); + file = __path_lookup (filename, flags, 0666 & ~_hurd_umask); if (file == MACH_PORT_NULL) { *fdptr = -1; diff -Nru glibc-1.02/sysdeps/mach/hurd/truncate.c glibc-1.03/sysdeps/mach/hurd/truncate.c --- glibc-1.02/sysdeps/mach/hurd/truncate.c Wed Oct 23 20:46:14 1991 +++ glibc-1.03/sysdeps/mach/hurd/truncate.c Thu Apr 2 01:15:22 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -27,7 +27,7 @@ CONST char *path AND off_t length) { error_t err; - file_t file = __hurd_path_lookup (path, FS_LOOKUP_WRITE, 0); + file_t file = __path_lookup (path, FS_LOOKUP_WRITE, 0); if (file == MACH_PORT_NULL) return -1; diff -Nru glibc-1.02/sysdeps/mach/hurd/usleep.c glibc-1.03/sysdeps/mach/hurd/usleep.c --- glibc-1.02/sysdeps/mach/hurd/usleep.c Sun Feb 9 23:55:26 1992 +++ glibc-1.03/sysdeps/mach/hurd/usleep.c Thu Apr 2 01:12:21 1992 @@ -25,11 +25,17 @@ DEFUN(usleep, (useconds), unsigned int useconds) { mach_port_t recv; + struct timeval before, after; recv = _hurd_dead_recv (); - __mach_msg (NULL, MACH_MSG_OPTION_TIMEOUT, 0, 0, - recv, useconds, MACH_PORT_NULL); + if (__gettimeofday (&before, NULL) < 0) + return useconds; + (void) __mach_msg (NULL, MACH_MSG_OPTION_TIMEOUT|MACH_RCV_INTERRUPT, + 0, 0, recv, useconds, MACH_PORT_NULL); + if (__gettimeofday (&after, NULL) < 0) + return 0; - return 0; + return (((after.tv_sec - before.tv_sec) * 1000) + + (after.tv_usec - before.tv_usec)); } diff -Nru glibc-1.02/sysdeps/mach/i386/sysdep.h glibc-1.03/sysdeps/mach/i386/sysdep.h --- glibc-1.02/sysdeps/mach/i386/sysdep.h Sat Nov 16 00:05:28 1991 +++ glibc-1.03/sysdeps/mach/i386/sysdep.h Fri Apr 3 00:33:17 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -17,15 +17,16 @@ Cambridge, MA 02139, USA. */ #define ENTRY(name) \ + .text; \ .globl _##name; \ .align 4; \ _##name##: #define SYSCALL_TRAP(name, number) \ - .text; \ - .align 4 \ ENTRY (name) \ lea number, %eax; \ - lcall $7, $0 \ - ENTRY (name##_syscall_pc) \ + /* lcall $7, $0; */ \ + /* Above loses; GAS bug. */ \ + .byte 0x9a, 0, 0, 0, 0, 7, 0; \ + _##name##_syscall_pc: \ ret diff -Nru glibc-1.02/sysdeps/posix/__dup2.c glibc-1.03/sysdeps/posix/__dup2.c --- glibc-1.02/sysdeps/posix/__dup2.c Fri Mar 20 00:42:35 1992 +++ glibc-1.03/sysdeps/posix/__dup2.c Wed Apr 1 01:39:55 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -42,7 +42,7 @@ if (fd == fd2) return fd2; - /* This is not atomic. */, 1992 + /* This is not atomic. */ save = errno; (void) close (fd2); diff -Nru glibc-1.02/sysdeps/posix/__gettod.c glibc-1.03/sysdeps/posix/__gettod.c --- glibc-1.02/sysdeps/posix/__gettod.c Tue Jan 14 21:38:16 1992 +++ glibc-1.03/sysdeps/posix/__gettod.c Wed Apr 1 01:42:46 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -42,9 +42,9 @@ CONST time_t timer = tv->tv_sec; CONST struct tm *tm; - long int save_timezone = __timezone; - long int save_daylight = __daylight; - CONST char *save_tzname[2]; + CONST long int save_timezone = __timezone; + CONST long int save_daylight = __daylight; + char *save_tzname[2]; save_tzname[0] = __tzname[0]; save_tzname[1] = __tzname[1]; diff -Nru glibc-1.02/sysdeps/posix/__sigvec.c glibc-1.03/sysdeps/posix/__sigvec.c --- glibc-1.02/sysdeps/posix/__sigvec.c Wed Oct 30 06:11:29 1991 +++ glibc-1.03/sysdeps/posix/__sigvec.c Mon Apr 6 02:44:12 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -93,7 +93,7 @@ if (convert_mask(&n->sa_mask, vec->sv_mask) < 0) return -1; n->sa_flags = (((vec->sv_flags & SV_ONSTACK) ? SA_ONSTACK : 0) | - (!(vec->sv_flags & SV_INTERRUPT) ? SA_ONSTACK : 0)); + (!(vec->sv_flags & SV_INTERRUPT) ? SA_RESTART : 0)); } if (__sigaction(sig, n, &old) < 0) diff -Nru glibc-1.02/sysdeps/posix/mktemp.c glibc-1.03/sysdeps/posix/mktemp.c --- glibc-1.02/sysdeps/posix/mktemp.c Wed Jan 29 16:11:21 1992 +++ glibc-1.03/sysdeps/posix/mktemp.c Mon Mar 23 18:18:37 1992 @@ -51,7 +51,7 @@ count %= sizeof(letters) - 1; if (sprintf(&template[len - 6], "%c%.5u", - c, (unsigned int) pid % 10000) != 6) + c, (unsigned int) pid % 100000) != 6) return NULL; return template; diff -Nru glibc-1.02/sysdeps/posix/putenv.c glibc-1.03/sysdeps/posix/putenv.c --- glibc-1.02/sysdeps/posix/putenv.c Wed Jun 12 14:31:46 1991 +++ glibc-1.03/sysdeps/posix/putenv.c Mon Mar 23 17:42:09 1992 @@ -22,6 +22,10 @@ #include #include +#ifndef HAVE_GNU_LD +#define __environ environ +#endif + /* Put STRING, which is of the form "NAME=VALUE", in the environment. */ int DEFUN(putenv, (string), CONST char *string) diff -Nru glibc-1.02/sysdeps/posix/sysd-stdio.c glibc-1.03/sysdeps/posix/sysd-stdio.c --- glibc-1.02/sysdeps/posix/sysd-stdio.c Fri Mar 20 00:49:49 1992 +++ glibc-1.03/sysdeps/posix/sysd-stdio.c Wed Apr 1 01:44:29 1992 @@ -90,17 +90,17 @@ /* Move COOKIE's file position *POS bytes, according to WHENCE. - The current file position is stored in *POS. + The new file position is stored in *POS. Returns zero if successful, nonzero if not. */ int DEFUN(__stdio_seek, (cookie, pos, whence), PTR cookie AND fpos_t *pos AND int whence) { - off_t old; - old = __lseek(*(int *) cookie, (off_t) *pos, whence); - if (old < 0) + off_t new; + new = __lseek(*(int *) cookie, (off_t) *pos, whence); + if (new < 0) return 1; - *pos = (fpos_t) old; + *pos = (fpos_t) new; return 0; } diff -Nru glibc-1.02/sysdeps/posix/system.c glibc-1.03/sysdeps/posix/system.c --- glibc-1.02/sysdeps/posix/system.c Fri Mar 13 16:45:09 1992 +++ glibc-1.03/sysdeps/posix/system.c Wed Apr 1 01:48:47 1992 @@ -40,7 +40,7 @@ int DEFUN(system, (line), register CONST char *line) { - int status; + int status, save; pid_t pid; struct sigaction sa, intr, quit; sigset_t block, omask; @@ -50,24 +50,36 @@ sa.sa_handler = SIG_IGN; sa.sa_flags = 0; - if (__sigemptyset(&sa.sa_mask) < 0) - return -1; - if (__sigaction(SIGINT, &sa, &intr) < 0) + __sigemptyset (&sa.sa_mask); + + if (__sigaction (SIGINT, &sa, &intr) < 0) return -1; - if (__sigaction(SIGQUIT, &sa, &quit) < 0) + if (__sigaction (SIGQUIT, &sa, &quit) < 0) { - (void) __sigaction(SIGINT, &intr, (struct sigaction *) NULL); + save = errno; + (void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL); + errno = save; return -1; } - if (__sigemptyset(&block) < 0 || __sigaddset(&block, SIGCHLD) < 0 || - __sigprocmask(SIG_BLOCK, &block, &omask) < 0) + + __sigemptyset (&block); + __sigaddset (&block, SIGCHLD); + save = errno; + if (__sigprocmask(SIG_BLOCK, &block, &omask) < 0) { - (void) __sigaction(SIGINT, &intr, (struct sigaction *) NULL); - (void) __sigaction(SIGQUIT, &quit, (struct sigaction *) NULL); - return -1; + if (errno == ENOSYS) + errno = save; + else + { + save = errno; + (void) __sigaction(SIGINT, &intr, (struct sigaction *) NULL); + (void) __sigaction(SIGQUIT, &quit, (struct sigaction *) NULL); + errno = save; + return -1; + } } - pid = FORK(); + pid = FORK (); if (pid == (pid_t) 0) { /* Child side. */ @@ -78,13 +90,13 @@ new_argv[3] = NULL; /* Restore the signals. */ - (void) __sigaction(SIGINT, &intr, (struct sigaction *) NULL); - (void) __sigaction(SIGQUIT, &quit, (struct sigaction *) NULL); - (void) __sigprocmask(SIG_SETMASK, &omask, (sigset_t *) NULL); + (void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL); + (void) __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL); + (void) __sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL); /* Exec the shell. */ - (void) __execve(SHELL_PATH, (char *CONST *) new_argv, __environ); - _exit(127); + (void) __execve (SHELL_PATH, (char *CONST *) new_argv, __environ); + _exit (127); } else if (pid < (pid_t) 0) /* The fork failed. */ @@ -105,14 +117,20 @@ } while (child != pid); } #else - if (__waitpid(pid, &status, 0) != pid) + if (__waitpid (pid, &status, 0) != pid) status = -1; #endif - if ((__sigaction(SIGINT, &intr, (struct sigaction *) NULL) | - __sigaction(SIGQUIT, &quit, (struct sigaction *) NULL) | - __sigprocmask(SIG_SETMASK, &omask, (sigset_t *) NULL)) != 0) - return -1; + save = errno; + if ((__sigaction (SIGINT, &intr, (struct sigaction *) NULL) | + __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL) | + __sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL)) != 0) + { + if (errno == ENOSYS) + errno = save; + else + return -1; + } return status; } diff -Nru glibc-1.02/sysdeps/stub/__getgrps.c glibc-1.03/sysdeps/stub/__getgrps.c --- glibc-1.02/sysdeps/stub/__getgrps.c Sun Mar 8 15:46:04 1992 +++ glibc-1.03/sysdeps/stub/__getgrps.c Wed Apr 1 01:51:20 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -21,6 +21,7 @@ #include #include #include +#include /* If SIZE is zero, return the number of supplementary groups @@ -29,11 +30,10 @@ int DEFUN(__getgroups, (size, list), int size AND gid_t *list) { - if (list == NULL) - { - errno = EINVAL; - return -1; - } +#if defined (NGROUPS_MAX) && NGROUPS_MAX == 0 + /* The system has no supplementary groups. */ + return 0; +#endif errno = ENOSYS; return -1; @@ -40,10 +40,10 @@ } -#ifdef HAVE_GNU_LD +#if defined (HAVE_GNU_LD) && !(defined (NGROUPS_MAX) && NGROUPS_MAX == 0) #include -stub_warning(__getgroups); +stub_warning (__getgroups); #endif /* GNU stabs. */ diff -Nru glibc-1.02/sysdeps/stub/__sigret.c glibc-1.03/sysdeps/stub/__sigret.c --- glibc-1.02/sysdeps/stub/__sigret.c +++ glibc-1.03/sysdeps/stub/__sigret.c Wed Apr 1 02:07:03 1992 @@ -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 +#include +#include + +int +DEFUN(__sigreturn, (context), CONST struct sigcontext *context) +{ + errno = ENOSYS; + return -1; +} diff -Nru glibc-1.02/sysdeps/stub/sysd-stdio.c glibc-1.03/sysdeps/stub/sysd-stdio.c --- glibc-1.02/sysdeps/stub/sysd-stdio.c Fri Mar 20 00:49:45 1992 +++ glibc-1.03/sysdeps/stub/sysd-stdio.c Wed Apr 1 01:43:44 1992 @@ -42,7 +42,7 @@ } /* Move COOKIE's file position *POS bytes, according to WHENCE. - The current file position is stored in *POS. + The new file position is stored in *POS. Returns zero if successful, nonzero if not. */ int DEFUN(__stdio_seek, (cookie, pos, whence), diff -Nru glibc-1.02/sysdeps/unix/Makefile glibc-1.03/sysdeps/unix/Makefile --- glibc-1.02/sysdeps/unix/Makefile Sun Mar 15 00:19:42 1992 +++ glibc-1.03/sysdeps/unix/Makefile Mon Mar 30 16:08:49 1992 @@ -25,7 +25,7 @@ mv $@-tmp $@ $(objpfx)make-errnos: $(objpfx)make-errnos.c - $(CC) $< -o $@ + cd $(objdir); $(CC) $(<:$(objpfx)%=%) -o $(@:$(objpfx)%=%) $(objpfx)make-errnos.c: $(sysdep_dir)/unix/errnos-tmpl.c \ $(sysdep_dir)/unix/errnos.awk $(objpfx)errnos @@ -32,7 +32,8 @@ awk -f $(word 2,$^) errnos="`tr '\012' ' ' < $(word 3,$^)`" $< > $@-tmp mv $@-tmp $@ -$(objpfx)errnos: $(wildcard /usr/include/errno.h /usr/include/sys/errno.h) +$(objpfx)errnos: $(wildcard $(sysincludedir)/errno.h \ + $(sysincludedir)/sys/errno.h) cat $^ | sed -n 's/^#define[ ]*\(E[A-Z0-9]*\)[ ]*[0-9][0-9]*[ ]*.*$$/\1/p' > $@-tmp mv $@-tmp $@ @@ -43,7 +44,7 @@ endif -$(objpfx)sys/param.h: /usr/include/sys/param.h $(objpfx)sys/ +$(objpfx)sys/param.h: $(sysincludedir)/sys/param.h $(objpfx)sys/ (echo '#ifndef _GNU_SYS_PARAM_H'; \ echo '#define _GNU_SYS_PARAM_H 1'; \ awk < $< \ @@ -61,7 +62,7 @@ mv $@-tmp $@ $(objpfx)make-ioctls: $(objpfx)make-ioctls.c - $(CC) $< -o $@ + cd $(objdir); $(CC) $(<:$(objpfx)%=%) -o $(@:$(objpfx)%=%) $(objpfx)make-ioctls.c: $(sysdep_dir)/unix/ioctls-tmpl.c \ $(sysdep_dir)/unix/ioctls.awk $(objpfx)ioctls @@ -68,7 +69,7 @@ awk -f $(word 2,$^) requests="`cat $(word 3,$^)`" $< > $@-tmp mv $@-tmp $@ -$(objpfx)ioctls: $(sysdep_dir)/unix/snarf-ioctls /usr/include/sys/ioctl.h +$(objpfx)ioctls: $(sysdep_dir)/unix/snarf-ioctls $(sysincludedir)/sys/ioctl.h $(dir $<)$(notdir $<) $(word 2,$^) | tr '\012' ' ' > $@-tmp mv $@-tmp $@ @@ -81,6 +82,6 @@ mv $@-tmp $@ $(objpfx)make_errlist: $(sysdep_dir)/unix/make_errlist.c - $(CC) $< -o $@ + cd $(objdir); $(CC) $< -o $(@:$(objpfx)%=%) endif diff -Nru glibc-1.02/sysdeps/unix/bsd/Makefile glibc-1.03/sysdeps/unix/bsd/Makefile --- glibc-1.02/sysdeps/unix/bsd/Makefile Tue Mar 17 18:10:04 1992 +++ glibc-1.03/sysdeps/unix/bsd/Makefile Wed Apr 1 03:12:06 1992 @@ -20,7 +20,7 @@ $(dir $<)$(notdir $<) > $@-tmp mv $@-tmp $@ $(objpfx)make-local_lim: $(sysdep_dir)/unix/bsd/make-local_lim.c - $(CC) $< -o $@ + cd $(objdir); $(CC) $(<:$(objpfx)%=%) -o $(@:$(objpfx)%=%) before-compile := $(before-compile) $(objpfx)local_lim.h @@ -38,13 +38,13 @@ mv $@-tmp $@ $(objpfx)glue-ctype: $(sysdep_dir)/unix/bsd/glue-ctype.c - $(CC) $< -o $@ + cd $(objdir); $(CC) $< -o $(@:$(objpfx)%=%) endif ifeq ($(subdir),stdio) -before-compile: $(objpfx)siglist.c +before-compile := $(before-compile) $(objpfx)siglist.c $(objpfx)siglist.c: $(objpfx)make_siglist @rm -f $@ $< > $@-tmp @@ -51,6 +51,6 @@ mv $@-tmp $@ $(objpfx)make_siglist: $(sysdep_dir)/unix/bsd/make_siglist.c - $(CC) $< -o $@ + cd $(objdir); $(CC) $< -o $(@:$(objpfx)%=%) endif diff -Nru glibc-1.02/sysdeps/unix/bsd/alarm.c glibc-1.03/sysdeps/unix/bsd/alarm.c --- glibc-1.02/sysdeps/unix/bsd/alarm.c Wed Jun 12 17:33:24 1991 +++ glibc-1.03/sysdeps/unix/bsd/alarm.c Wed Mar 25 18:11:54 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -44,9 +44,9 @@ if (old.it_value.tv_usec > 0 && old_seconds == 0) /* Make sure we don't return zero (which says that there is no alarm at all) if there is an alarm set - to go off in less than 500 microseconds. */ + to go off in less than half a second. */ ++old_seconds; else - old_seconds += old.it_value.tv_usec / 1000; + old_seconds += old.it_value.tv_usec / 1000000; return old_seconds; } diff -Nru glibc-1.02/sysdeps/unix/bsd/getlogin.c glibc-1.03/sysdeps/unix/bsd/getlogin.c --- glibc-1.02/sysdeps/unix/bsd/getlogin.c Fri Mar 6 10:43:32 1992 +++ glibc-1.03/sysdeps/unix/bsd/getlogin.c @@ -1,90 +0,0 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. -This file is part of the GNU C Library. - -The GNU C Library is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. - -The GNU C Library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with the GNU C Library; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA. */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -/* Defined in ttyname.c. */ -extern char *__ttyname; - -/* Return the login name of the user, or NULL if it can't be determined. - The returned pointer, if not NULL, is good only until the next call. */ - -char * -DEFUN_VOID(getlogin) -{ - char save_tty_pathname[PATH_MAX]; - char *save_ttyname; - char *real_tty_path; - char *result = NULL; - FILE *f; - static struct utmp ut; - - if (__ttyname == NULL) - save_ttyname = NULL; - else - save_ttyname = strcpy (save_tty_pathname, __ttyname); - - { - int err; - int d = __open ("/dev/tty", 0); - if (d < 0) - return NULL; - - real_tty_path = ttyname (d); - err = errno; - (void) close (d); - - if (real_tty_path == NULL) - { - errno = err; - return NULL; - } - } - - real_tty_path += 5; /* Remove "/dev/". */ - - f = fopen ("/etc/utmp", "r"); - if (f != NULL) - { - while (fread ((PTR) &ut, sizeof(ut), 1, f) == 1) - if (!strncmp (ut.ut_line, real_tty_path, sizeof (ut.ut_line))) - { - result = ut.ut_name; - /* The name is not null-terminated if - it is as long as sizeof (ut.ut_name). */ - result[sizeof (ut.ut_name)] = '\0'; - break; - } - (void) fclose (f); - } - - if (save_ttyname != NULL) - strcpy (__ttyname, save_ttyname); - if (result == NULL) - errno = ENOENT; - return result; -} diff -Nru glibc-1.02/sysdeps/unix/bsd/i386/Implies glibc-1.03/sysdeps/unix/bsd/i386/Implies --- glibc-1.02/sysdeps/unix/bsd/i386/Implies +++ glibc-1.03/sysdeps/unix/bsd/i386/Implies Tue Jul 30 17:46:50 1991 @@ -0,0 +1 @@ +unix/i386 diff -Nru glibc-1.02/sysdeps/unix/bsd/i386/__setgid.S glibc-1.03/sysdeps/unix/bsd/i386/__setgid.S --- glibc-1.02/sysdeps/unix/bsd/i386/__setgid.S +++ glibc-1.03/sysdeps/unix/bsd/i386/__setgid.S Tue Jul 30 19:00:18 1991 @@ -0,0 +1,25 @@ +/* Copyright (C) 1991 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include + +ENTRY (__setgid) + popl %eax /* Return PC. */ + pushl (%esp) + pushl %eax + jmp ___setregid diff -Nru glibc-1.02/sysdeps/unix/bsd/i386/__setuid.S glibc-1.03/sysdeps/unix/bsd/i386/__setuid.S --- glibc-1.02/sysdeps/unix/bsd/i386/__setuid.S +++ glibc-1.03/sysdeps/unix/bsd/i386/__setuid.S Tue Jul 30 19:00:16 1991 @@ -0,0 +1,25 @@ +/* Copyright (C) 1991 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include + +ENTRY (__setuid) + popl %eax /* Return PC. */ + pushl (%esp) + pushl %eax + jmp ___setreuid diff -Nru glibc-1.02/sysdeps/unix/bsd/i386/__vfork.S glibc-1.03/sysdeps/unix/bsd/i386/__vfork.S --- glibc-1.02/sysdeps/unix/bsd/i386/__vfork.S +++ glibc-1.03/sysdeps/unix/bsd/i386/__vfork.S Tue Jul 30 18:54:53 1991 @@ -0,0 +1,2 @@ +#define fork vfork +#include diff -Nru glibc-1.02/sysdeps/unix/bsd/i386/__wait3.S glibc-1.03/sysdeps/unix/bsd/i386/__wait3.S --- glibc-1.02/sysdeps/unix/bsd/i386/__wait3.S +++ glibc-1.03/sysdeps/unix/bsd/i386/__wait3.S Tue Jul 30 19:03:37 1991 @@ -0,0 +1,32 @@ +/* Copyright (C) 1991 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include + +.globl syscall_error +ENTRY (__wait3) + movl 8(%esp), %ecx + movl 12(%esp), %edx + pushl $0xdf; popf /* Set all the condition codes. */ + lcall $7, $0 + je syscall_error + movl 4(%esp), %ecx + orl %ecx, %ecx + je 1f + movl %edx, (%ecx) +1: ret diff -Nru glibc-1.02/sysdeps/unix/bsd/make-local_lim.c glibc-1.03/sysdeps/unix/bsd/make-local_lim.c --- glibc-1.02/sysdeps/unix/bsd/make-local_lim.c Wed Jun 12 17:33:51 1991 +++ glibc-1.03/sysdeps/unix/bsd/make-local_lim.c Mon Apr 6 02:46:46 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -31,9 +31,13 @@ { { "NGROUPS_MAX", NGROUPS }, { "ARG_MAX", NCARGS }, +#ifdef MAXUPRC { "CHILD_MAX", MAXUPRC }, +#endif { "OPEN_MAX", NOFILE }, +#ifdef MAXLINK { "LINK_MAX", MAXLINK }, +#endif { "MAX_CANON", CANBSIZ }, { "NAME_MAX", 255 }, { "PATH_MAX", MAXPATHLEN }, diff -Nru glibc-1.02/sysdeps/unix/bsd/make_siglist.c glibc-1.03/sysdeps/unix/bsd/make_siglist.c --- glibc-1.02/sysdeps/unix/bsd/make_siglist.c Wed Jun 12 15:35:14 1991 +++ glibc-1.03/sysdeps/unix/bsd/make_siglist.c Wed Apr 1 03:08:57 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -28,16 +28,20 @@ { register int i; - puts("#include \"ansidecl.h\"\n#include \n"); + puts ("#include \"ansidecl.h\"\n#include \n"); - puts("\n/* This is a list of all known signal numbers. */"); + puts ("#ifndef HAVE_GNU_LD"); + puts ("#define _sys_siglist\tsys_siglist"); + puts ("#endif"); - puts("\nCONST char *CONST _sys_siglist[] =\n {"); + puts ("\n/* This is a list of all known signal numbers. */"); + puts ("\nCONST char *CONST _sys_siglist[] =\n {"); + for (i = 0; i < NSIG; ++i) - printf(" \"%s\",\n", sys_siglist[i]); + printf (" \"%s\",\n", sys_siglist[i]); - puts(" NULL\n };\n"); + puts (" NULL\n };\n"); - exit(0); + exit (0); } diff -Nru glibc-1.02/sysdeps/unix/bsd/opendir.c glibc-1.03/sysdeps/unix/bsd/opendir.c --- glibc-1.02/sysdeps/unix/bsd/opendir.c Wed Jun 12 17:34:22 1991 +++ glibc-1.03/sysdeps/unix/bsd/opendir.c Mon Mar 30 16:58:40 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -36,15 +36,12 @@ struct stat statbuf; int fd; - fd = __open(name, O_RDONLY); + fd = __open (name, O_RDONLY); if (fd < 0) return NULL; - { - int flags = FD_CLOEXEC; - if (fcntl(fd, F_SETFD, &flags) < 0) - return NULL; - } + if (fcntl (fd, F_SETFD, FD_CLOEXEC) < 0) + return NULL; dirp = (DIR *) malloc(sizeof(DIR) + NAME_MAX); if (dirp == NULL) diff -Nru glibc-1.02/sysdeps/unix/bsd/readdir.c glibc-1.03/sysdeps/unix/bsd/readdir.c --- glibc-1.02/sysdeps/unix/bsd/readdir.c Wed Jun 12 17:36:05 1991 +++ glibc-1.03/sysdeps/unix/bsd/readdir.c Wed Apr 1 01:53:32 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -36,6 +36,10 @@ } #endif +#ifndef D_NAMLEN +#define D_NAMLEN(d) ((d)->d_namlen) +#endif + /* Read a directory entry from DIRP. */ struct dirent * DEFUN(readdir, (dirp), DIR *dirp) @@ -66,9 +70,9 @@ /* Not a deleted file. */ register struct dirent *d = &dirp->__entry; d->d_fileno = (ino_t) dp->d_ino; - d->d_namlen = (size_t) dp->d_namlen; + d->d_namlen = (size_t) D_NAMLEN (dp); if (d->d_namlen > NAME_MAX) - d->d_namlen = NAME_MAX; + d->d_namlen = NAME_MAX; /* XXX ? */ (void) strncpy(d->d_name, dp->d_name, d->d_namlen + 1); return d; } diff -Nru glibc-1.02/sysdeps/unix/bsd/sun/ptrace.c glibc-1.03/sysdeps/unix/bsd/sun/ptrace.c --- glibc-1.02/sysdeps/unix/bsd/sun/ptrace.c Mon Oct 1 16:49:27 1990 +++ glibc-1.03/sysdeps/unix/bsd/sun/ptrace.c @@ -1,3 +0,0 @@ -#define PTRACE_5ARGS_OK - -#include <../sysdeps/unix/ptrace.c> diff -Nru glibc-1.02/sysdeps/unix/getlogin.c glibc-1.03/sysdeps/unix/getlogin.c --- glibc-1.02/sysdeps/unix/getlogin.c +++ glibc-1.03/sysdeps/unix/getlogin.c Fri Mar 6 10:43:32 1992 @@ -0,0 +1,90 @@ +/* Copyright (C) 1991 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +/* Defined in ttyname.c. */ +extern char *__ttyname; + +/* Return the login name of the user, or NULL if it can't be determined. + The returned pointer, if not NULL, is good only until the next call. */ + +char * +DEFUN_VOID(getlogin) +{ + char save_tty_pathname[PATH_MAX]; + char *save_ttyname; + char *real_tty_path; + char *result = NULL; + FILE *f; + static struct utmp ut; + + if (__ttyname == NULL) + save_ttyname = NULL; + else + save_ttyname = strcpy (save_tty_pathname, __ttyname); + + { + int err; + int d = __open ("/dev/tty", 0); + if (d < 0) + return NULL; + + real_tty_path = ttyname (d); + err = errno; + (void) close (d); + + if (real_tty_path == NULL) + { + errno = err; + return NULL; + } + } + + real_tty_path += 5; /* Remove "/dev/". */ + + f = fopen ("/etc/utmp", "r"); + if (f != NULL) + { + while (fread ((PTR) &ut, sizeof(ut), 1, f) == 1) + if (!strncmp (ut.ut_line, real_tty_path, sizeof (ut.ut_line))) + { + result = ut.ut_name; + /* The name is not null-terminated if + it is as long as sizeof (ut.ut_name). */ + result[sizeof (ut.ut_name)] = '\0'; + break; + } + (void) fclose (f); + } + + if (save_ttyname != NULL) + strcpy (__ttyname, save_ttyname); + if (result == NULL) + errno = ENOENT; + return result; +} diff -Nru glibc-1.02/sysdeps/unix/i386/bsd/Implies glibc-1.03/sysdeps/unix/i386/bsd/Implies --- glibc-1.02/sysdeps/unix/i386/bsd/Implies Tue Jul 30 17:46:50 1991 +++ glibc-1.03/sysdeps/unix/i386/bsd/Implies @@ -1 +0,0 @@ -unix/i386 diff -Nru glibc-1.02/sysdeps/unix/i386/bsd/__setgid.S glibc-1.03/sysdeps/unix/i386/bsd/__setgid.S --- glibc-1.02/sysdeps/unix/i386/bsd/__setgid.S Tue Jul 30 19:00:18 1991 +++ glibc-1.03/sysdeps/unix/i386/bsd/__setgid.S @@ -1,25 +0,0 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. -This file is part of the GNU C Library. - -The GNU C Library is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. - -The GNU C Library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with the GNU C Library; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA. */ - -#include - -ENTRY (__setgid) - popl %eax /* Return PC. */ - pushl (%esp) - pushl %eax - jmp ___setregid diff -Nru glibc-1.02/sysdeps/unix/i386/bsd/__setuid.S glibc-1.03/sysdeps/unix/i386/bsd/__setuid.S --- glibc-1.02/sysdeps/unix/i386/bsd/__setuid.S Tue Jul 30 19:00:16 1991 +++ glibc-1.03/sysdeps/unix/i386/bsd/__setuid.S @@ -1,25 +0,0 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. -This file is part of the GNU C Library. - -The GNU C Library is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. - -The GNU C Library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with the GNU C Library; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA. */ - -#include - -ENTRY (__setuid) - popl %eax /* Return PC. */ - pushl (%esp) - pushl %eax - jmp ___setreuid diff -Nru glibc-1.02/sysdeps/unix/i386/bsd/__vfork.S glibc-1.03/sysdeps/unix/i386/bsd/__vfork.S --- glibc-1.02/sysdeps/unix/i386/bsd/__vfork.S Tue Jul 30 18:54:53 1991 +++ glibc-1.03/sysdeps/unix/i386/bsd/__vfork.S @@ -1,2 +0,0 @@ -#define fork vfork -#include diff -Nru glibc-1.02/sysdeps/unix/i386/bsd/__wait3.S glibc-1.03/sysdeps/unix/i386/bsd/__wait3.S --- glibc-1.02/sysdeps/unix/i386/bsd/__wait3.S Tue Jul 30 19:03:37 1991 +++ glibc-1.03/sysdeps/unix/i386/bsd/__wait3.S @@ -1,32 +0,0 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. -This file is part of the GNU C Library. - -The GNU C Library is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. - -The GNU C Library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with the GNU C Library; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA. */ - -#include - -.globl syscall_error -ENTRY (__wait3) - movl 8(%esp), %ecx - movl 12(%esp), %edx - pushl $0xdf; popf /* Set all the condition codes. */ - lcall $7, $0 - je syscall_error - movl 4(%esp), %ecx - orl %ecx, %ecx - je 1f - movl %edx, (%ecx) -1: ret diff -Nru glibc-1.02/sysdeps/unix/i386/sysdep.h glibc-1.03/sysdeps/unix/i386/sysdep.h --- glibc-1.02/sysdeps/unix/i386/sysdep.h Thu Mar 12 00:48:25 1992 +++ glibc-1.03/sysdeps/unix/i386/sysdep.h Wed Apr 1 01:57:07 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -37,7 +37,9 @@ .align 4; \ ENTRY (name) \ lea SYS_##syscall_name, %eax; \ - lcall $7, $0; \ + /* lcall $7, $0; */ \ + /* Above loses; GAS bug. */ \ + .byte 0x9a, 0, 0, 0, 0, 7, 0 jb syscall_error #else #define PSEUDO(name, syscall_name) \ @@ -46,7 +48,9 @@ .align 4 \ ENTRY (name) \ lea SYS_/**/syscall_name, %eax; \ - lcall $7, $0 \ + /* lcall $7, $0; */ \ + /* Above loses; GAS bug. */ \ + .byte 0x9a, 0, 0, 0, 0, 7, 0 jb syscall_error #endif diff -Nru glibc-1.02/sysdeps/unix/i386/sysv/Implies glibc-1.03/sysdeps/unix/i386/sysv/Implies --- glibc-1.02/sysdeps/unix/i386/sysv/Implies Mon Feb 17 00:46:10 1992 +++ glibc-1.03/sysdeps/unix/i386/sysv/Implies @@ -1 +0,0 @@ -unix/sysv diff -Nru glibc-1.02/sysdeps/unix/i386/sysv/time.S glibc-1.03/sysdeps/unix/i386/sysv/time.S --- glibc-1.02/sysdeps/unix/i386/sysv/time.S Tue Jul 30 17:45:01 1991 +++ glibc-1.03/sysdeps/unix/i386/sysv/time.S @@ -1,26 +0,0 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. -This file is part of the GNU C Library. - -The GNU C Library is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. - -The GNU C Library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with the GNU C Library; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA. */ - -#include - -SYSCALL (time) - movl 4(%esp,1), %edx - testl %edx, %edx - je null - movl %eax, (%edx) -null: ret diff -Nru glibc-1.02/sysdeps/unix/make_errlist.c glibc-1.03/sysdeps/unix/make_errlist.c --- glibc-1.02/sysdeps/unix/make_errlist.c Wed Jun 12 15:35:08 1991 +++ glibc-1.03/sysdeps/unix/make_errlist.c Mon Mar 30 16:40:55 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -24,21 +24,25 @@ extern char *sys_errlist[]; int -main() +main () { register int i; - puts("#include \"ansidecl.h\"\n#include \n"); + puts ("#include \"ansidecl.h\"\n#include \n"); + puts ("\n/* This is a list of all known `errno' codes. */\n"); - puts("\n/* This is a list of all known `errno' codes. */"); + puts ("#ifndef HAVE_GNU_LD"); + puts ("#define _sys_nerr\tsys_nerr"); + puts ("#define _sys_errlist\tsys_errlist"); + puts ("#endif"); - printf("\nCONST int _sys_nerr = %d;\n\n", sys_nerr); - puts("CONST char *CONST _sys_errlist[] =\n {"); + printf ("\nCONST int _sys_nerr = %d;\n\n", sys_nerr); + puts ("CONST char *CONST _sys_errlist[] =\n {"); for (i = 0; i < sys_nerr; ++i) - printf(" \"%s\",\n", sys_errlist[i]); + printf (" \"%s\",\n", sys_errlist[i]); - puts(" NULL\n };"); + puts (" NULL\n };"); - exit(0); + exit (0); } diff -Nru glibc-1.02/sysdeps/unix/snarf-ioctls glibc-1.03/sysdeps/unix/snarf-ioctls --- glibc-1.02/sysdeps/unix/snarf-ioctls Thu Mar 12 16:21:56 1992 +++ glibc-1.03/sysdeps/unix/snarf-ioctls Mon Mar 30 16:06:50 1992 @@ -16,6 +16,8 @@ # along with the GNU C Library; see the file COPYING. If not, write to # the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. +sysincludedir=${sysincludedir-/usr/include} + for file in $*; do sed -n 's/^#define[ ]*\([A-Z][A-Z0-9_]*\)[ ][ ]*[^ ].*$/\1/p' \ < $file @@ -25,7 +27,7 @@ export snarfexclude included="`sed -n < $file \ - -e 's,^#include[ ]*<\(.*\)>.*$,/usr/include/\1,p' \ + -e 's,^#include[ ]*<\(.*\)>.*$,'${sysincludedir}'/\1,p'\ | sed $snarfexclude`" if [ "$included" ]; then $0 $included diff -Nru glibc-1.02/sysdeps/unix/sysv/Makefile glibc-1.03/sysdeps/unix/sysv/Makefile --- glibc-1.02/sysdeps/unix/sysv/Makefile Thu Mar 5 17:29:59 1992 +++ glibc-1.03/sysdeps/unix/sysv/Makefile Wed Apr 1 03:18:22 1992 @@ -16,9 +16,29 @@ # not, write to the Free Software Foundation, Inc., 675 Mass Ave, # Cambridge, MA 02139, USA. -ifeq ($(subdir), io) +ifeq ($(subdir),io) -sysdep-routines := $(sysdep-routines) sys_stat sys_fstat \ +sysdep_routines := $(sysdep-routines) sys_stat sys_fstat \ __utssys + +endif + +ifeq ($(subdir), misc) + +sysdep_headers := $(sysdep_headers) termio.h +dont_distribute := $(dont_distribute) termio.h # Generated. + +# termio.h is just like sysv_termio.h except it uses the same +# names for everything that System V termio does. sysv_termio.h +# is necessary to including in __tcgetatr.c, etc., because +# some of the names in termio.h conflict with termios.h +# The C library doesn't actually use termio.h, but we generate +# it for those application programs which use it. +$(objpfx)termio.h: $(..)sysdeps/unix/sysv/sysv_termio.h + sed < $< > $@-tmp \ + -e 's/_SYSV_//' \ + -e 's/^#define[ ]*_T/#define T/'\ + -e 's/__sysv_termio/termio/' + mv $@-tmp $@ endif diff -Nru glibc-1.02/sysdeps/unix/sysv/__gethstnm.c glibc-1.03/sysdeps/unix/sysv/__gethstnm.c --- glibc-1.02/sysdeps/unix/sysv/__gethstnm.c +++ glibc-1.03/sysdeps/unix/sysv/__gethstnm.c Wed Apr 1 02:27:08 1992 @@ -0,0 +1,36 @@ +/* Copyright (C) 1992 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include +#include + +/* Put the name of the current host in no more than LEN bytes of NAME. + The result is null-terminated if LEN is large enough for the full + name and the terminator. */ +int +DEFUN(__gethostname, (name, len), + char *name AND size_t len) +{ + struct utsname buf; + if (uname (&buf) < 0) + return -1; + strncpy (name, buf.nodename, len); + return 0; +} diff -Nru glibc-1.02/sysdeps/unix/sysv/__sigact.c glibc-1.03/sysdeps/unix/sysv/__sigact.c --- glibc-1.02/sysdeps/unix/sysv/__sigact.c +++ glibc-1.03/sysdeps/unix/sysv/__sigact.c Wed Apr 1 02:16:18 1992 @@ -0,0 +1,74 @@ +/* Copyright (C) 1992 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include +#include +#include + + +/* If ACT is not NULL, change the action for SIG to *ACT. + If OACT is not NULL, put the old action for SIG in *OACT. */ +int +DEFUN(__sigaction, (sig, act, oact), + int sig AND CONST struct sigaction *act AND struct sigaction *oact) +{ + sighandler_t handler; + int save; + + if (sig <= 0 || sig >= NSIG) + { + errno = EINVAL; + return -1; + } + + if (act == NULL) + { + if (oact == NULL) + return 0; + /* Race condition, but this is the only way to do it. */ + handler = signal (sig, SIG_IGN); + if (handler == SIG_ERR) + return -1; + save = errno; + (void) signal (sig, handler); + errno = save; + } + else + { + if (act->sa_flags != 0 || act->sa_mask != 0) + { + errno = ENOSYS; + return -1; + } + + handler = signal (sig, act->sa_handler); + if (handler == SIG_ERR) + return -1; + } + + if (oact != NULL) + { + oact->sa_handler = handler; + oact->sa_mask = 0; + oact->sa_flags = 0; + } + + return 0; +} diff -Nru glibc-1.02/sysdeps/unix/sysv/__tcgetatr.c glibc-1.03/sysdeps/unix/sysv/__tcgetatr.c --- glibc-1.02/sysdeps/unix/sysv/__tcgetatr.c Thu Mar 5 18:45:31 1992 +++ glibc-1.03/sysdeps/unix/sysv/__tcgetatr.c Wed Apr 1 02:32:30 1992 @@ -161,8 +161,8 @@ termios_p->c_cc[VSTART] = '\021'; /* XON (^Q). */ termios_p->c_cc[VSTOP] = '\023'; /* XOFF (^S). */ termios_p->c_cc[VSUSP] = '\0'; /* System V release 3 lacks job control. */ - termios_p->c_cc[VMIN] = -1; - termios_p->c_cc[VTIME] = -1; + termios_p->c_cc[VMIN] = buf.c_cc[_SYSV_VMIN]; + termios_p->c_cc[VTIME] = buf.c_cc[_SYSV_VTIME]; return 0; } diff -Nru glibc-1.02/sysdeps/unix/sysv/fcntlbits.h glibc-1.03/sysdeps/unix/sysv/fcntlbits.h --- glibc-1.02/sysdeps/unix/sysv/fcntlbits.h Tue Mar 17 19:21:54 1992 +++ glibc-1.03/sysdeps/unix/sysv/fcntlbits.h Wed Apr 1 02:42:34 1992 @@ -50,7 +50,8 @@ short int l_whence; /* Where `l_start' is relative to (like `lseek'). */ __off_t l_start; /* Offset where the lock begins. */ __off_t l_len; /* Size of the locked area; zero means until EOF. */ - __pid_t l_pid; /* Process holding the lock. */ + short int l_sysid; + short int l_pid; /* Process holding the lock. */ }; #define __F_RDLCK 1 /* Read lock. */ diff -Nru glibc-1.02/sysdeps/unix/sysv/i386/Implies glibc-1.03/sysdeps/unix/sysv/i386/Implies --- glibc-1.02/sysdeps/unix/sysv/i386/Implies +++ glibc-1.03/sysdeps/unix/sysv/i386/Implies Wed Apr 1 22:17:48 1992 @@ -0,0 +1 @@ +unix/i386 diff -Nru glibc-1.02/sysdeps/unix/sysv/i386/__sigret.S glibc-1.03/sysdeps/unix/sysv/i386/__sigret.S --- glibc-1.02/sysdeps/unix/sysv/i386/__sigret.S +++ glibc-1.03/sysdeps/unix/sysv/i386/__sigret.S Wed Apr 1 02:08:26 1992 @@ -0,0 +1,24 @@ +/* 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 + +ENTRY (__sigreturn) + addl $4, %esp + .byte 0x9a, 0, 0, 0, 0, 0xf, 0 + /* NOTREACHED */ diff -Nru glibc-1.02/sysdeps/unix/sysv/i386/signal.S glibc-1.03/sysdeps/unix/sysv/i386/signal.S --- glibc-1.02/sysdeps/unix/sysv/i386/signal.S +++ glibc-1.03/sysdeps/unix/sysv/i386/signal.S Wed Apr 1 02:10:17 1992 @@ -0,0 +1,31 @@ +/* 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 + +/* This is just a standard system call, except we need to load %edx + with the address of the `__sigreturn' function. */ + + .globl syscall_error + .globl ___sigreturn +ENTRY (signal) + lea SYS_signal, %eax + lea ___sigreturn, %edx + .byte 0x9a, 0, 0, 0, 0, 7, 0 + jb syscall_error + ret diff -Nru glibc-1.02/sysdeps/unix/sysv/i386/time.S glibc-1.03/sysdeps/unix/sysv/i386/time.S --- glibc-1.02/sysdeps/unix/sysv/i386/time.S +++ glibc-1.03/sysdeps/unix/sysv/i386/time.S Tue Jul 30 17:45:01 1991 @@ -0,0 +1,26 @@ +/* Copyright (C) 1991 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include + +SYSCALL (time) + movl 4(%esp,1), %edx + testl %edx, %edx + je null + movl %eax, (%edx) +null: ret diff -Nru glibc-1.02/sysdeps/unix/sysv/local_lim.h glibc-1.03/sysdeps/unix/sysv/local_lim.h --- glibc-1.02/sysdeps/unix/sysv/local_lim.h Mon Feb 17 04:25:39 1992 +++ glibc-1.03/sysdeps/unix/sysv/local_lim.h Wed Apr 1 02:42:32 1992 @@ -16,7 +16,7 @@ not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#define NGROUPS_MAX 16 +#define NGROUPS_MAX 0 /* No supplementary groups. */ #define ARG_MAX 5120 #define CHILD_MAX 25 #define OPEN_MAX 60 diff -Nru glibc-1.02/sysdeps/unix/sysv/r4/Makefile glibc-1.03/sysdeps/unix/sysv/r4/Makefile --- glibc-1.02/sysdeps/unix/sysv/r4/Makefile +++ glibc-1.03/sysdeps/unix/sysv/r4/Makefile Wed Apr 1 02:59:48 1992 @@ -0,0 +1,23 @@ +# 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. + +ifeq ($(subdir),dirent) + +sysdep_routines := $(sysdep_routines) sys_getdents + +endif diff -Nru glibc-1.02/sysdeps/unix/sysv/r4/__access.S glibc-1.03/sysdeps/unix/sysv/r4/__access.S --- glibc-1.02/sysdeps/unix/sysv/r4/__access.S +++ glibc-1.03/sysdeps/unix/sysv/r4/__access.S Wed Apr 1 02:14:24 1992 @@ -0,0 +1,2 @@ +/* SVR4 has the BSD `access' function. */ +#include diff -Nru glibc-1.02/sysdeps/unix/sysv/r4/closedir.c glibc-1.03/sysdeps/unix/sysv/r4/closedir.c --- glibc-1.02/sysdeps/unix/sysv/r4/closedir.c +++ glibc-1.03/sysdeps/unix/sysv/r4/closedir.c Wed Apr 1 02:50:00 1992 @@ -0,0 +1 @@ +#include diff -Nru glibc-1.02/sysdeps/unix/sysv/r4/opendir.c glibc-1.03/sysdeps/unix/sysv/r4/opendir.c --- glibc-1.02/sysdeps/unix/sysv/r4/opendir.c +++ glibc-1.03/sysdeps/unix/sysv/r4/opendir.c Wed Apr 1 02:49:19 1992 @@ -0,0 +1 @@ +#include diff -Nru glibc-1.02/sysdeps/unix/sysv/r4/readdir.c glibc-1.03/sysdeps/unix/sysv/r4/readdir.c --- glibc-1.02/sysdeps/unix/sysv/r4/readdir.c +++ glibc-1.03/sysdeps/unix/sysv/r4/readdir.c Wed Apr 1 02:52:23 1992 @@ -0,0 +1,42 @@ +/* Copyright (C) 1992 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include +#include "bsddir.h" + +#define D_NAMLEN(d) (strlen ((d)->d_name)) + +/* Put into BUF up to NBYTES bytes of `struct direct's read from FD. + Return the number of bytes actually read. + This is similar in spirit but not quite the same as the Sun + getdirentries call. */ +extern int EXFUN(__getdents, (int fd, struct direct *buf, size_t nbytes)); + +#define READ_DIRECTORY \ +{ \ + int bytes = __getdents (dirp->__fd, \ + (struct direct *) dirp->__data, \ + dirp->__allocation); \ + if (bytes <= 0) \ + return NULL; \ + dirp->__size = (size_t) bytes; \ +} + +#include diff -Nru glibc-1.02/sysdeps/unix/sysv/r4/rewinddir.c glibc-1.03/sysdeps/unix/sysv/r4/rewinddir.c --- glibc-1.02/sysdeps/unix/sysv/r4/rewinddir.c +++ glibc-1.03/sysdeps/unix/sysv/r4/rewinddir.c Wed Apr 1 02:49:48 1992 @@ -0,0 +1 @@ +#include diff -Nru glibc-1.02/sysdeps/unix/sysv/r4/seekdir.c glibc-1.03/sysdeps/unix/sysv/r4/seekdir.c --- glibc-1.02/sysdeps/unix/sysv/r4/seekdir.c +++ glibc-1.03/sysdeps/unix/sysv/r4/seekdir.c Wed Apr 1 02:49:36 1992 @@ -0,0 +1 @@ +#include diff -Nru glibc-1.02/sysdeps/unix/sysv/r4/telldir.c glibc-1.03/sysdeps/unix/sysv/r4/telldir.c --- glibc-1.02/sysdeps/unix/sysv/r4/telldir.c +++ glibc-1.03/sysdeps/unix/sysv/r4/telldir.c Wed Apr 1 02:49:29 1992 @@ -0,0 +1 @@ +#include diff -Nru glibc-1.02/sysdeps/unix/sysv/signum.h glibc-1.03/sysdeps/unix/sysv/signum.h --- glibc-1.02/sysdeps/unix/sysv/signum.h Mon Feb 17 04:31:55 1992 +++ glibc-1.03/sysdeps/unix/sysv/signum.h Wed Apr 1 03:03:07 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -48,9 +48,12 @@ #define SIGPIPE 13 /* Broken pipe (POSIX). */ #define SIGALRM 14 /* Alarm clock (POSIX). */ #define SIGTERM 15 /* Termination (ANSI). */ -#define SIGCHLD 16 /* Child status has changed (POSIX). */ +#define SIGUSR1 16 /* User-defined signal 1 (POSIX). */ +#define SIGUSR2 17 /* User-defined signal 2 (POSIX). */ +#define SIGCHLD 18 /* Child status has changed (POSIX). */ #define SIGCLD SIGCHLD /* Same as SIGCHLD (System V). */ +#define SIGPWR 19 /* Power failure restart (System V). */ #endif /* included. */ -#define _NSIG 17 /* Biggest signal number + 1. */ +#define _NSIG 20 /* Biggest signal number + 1. */ diff -Nru glibc-1.02/sysdeps/unix/sysv/sysv_termio.h glibc-1.03/sysdeps/unix/sysv/sysv_termio.h --- glibc-1.02/sysdeps/unix/sysv/sysv_termio.h Thu Mar 5 18:45:32 1992 +++ glibc-1.03/sysdeps/unix/sysv/sysv_termio.h Wed Apr 1 02:42:30 1992 @@ -29,7 +29,11 @@ #define _SYSV_VERASE 2 #define _SYSV_VKILL 3 #define _SYSV_VEOF 4 +/* This field means VEOF if ICANON, VMIN if not. */ +#define _SYSV_VMIN 4 #define _SYSV_VEOL 5 +/* This field means VEOL if ICANON, VTIME if not. */ +#define _SYSV_VTIME 5 #define _SYSV_VEOL2 6 /* Flags in c_iflag. */ @@ -42,6 +46,7 @@ #define _SYSV_INLCR 0x40 #define _SYSV_IGNCR 0x80 #define _SYSV_ICRNL 0x100 +#define _SYSV_IUCLC 0x200 #define _SYSV_IXON 0x400 #define _SYSV_IXANY 0x800 #define _SYSV_IXOFF 0x1000 @@ -99,7 +104,30 @@ /* Flags in c_oflag. */ #define _SYSV_OPOST 1 +#define _SYSV_OLCUC 2 #define _SYSV_ONLCR 4 +#define _SYSV_NLDLY 0x100 +#define _SYSV_NL0 0 +#define _SYSV_NL1 0x100 +#define _SYSV_CRDLY 0x600 +#define _SYSV_CR0 0 +#define _SYSV_CR1 0x200 +#define _SYSV_CR2 0x400 +#define _SYSV_CR3 0x600 +#define _SYSV_TABDLY 0x1800 +#define _SYSV_TAB0 0 +#define _SYSV_TAB1 0x0800 +#define _SYSV_TAB2 0x1000 +#define _SYSV_XTABS 0x1800 +#define _SYSV_BSDLY 0x2000 +#define _SYSV_BS0 0 +#define _SYSV_BS1 0x2000 +#define _SYSV_VTDLY 0x4000 +#define _SYSV_VT0 0 +#define _SYSV_VT1 0x4000 +#define _SYSV_FFDLY 0x8000 +#define _SYSV_FF0 0 +#define _SYSV_FF1 0x8000 /* ioctl's. */ diff -Nru glibc-1.02/sysdeps/unix/sysv/tcflow.c glibc-1.03/sysdeps/unix/sysv/tcflow.c --- glibc-1.02/sysdeps/unix/sysv/tcflow.c +++ glibc-1.03/sysdeps/unix/sysv/tcflow.c Wed Apr 1 02:39:04 1992 @@ -0,0 +1,45 @@ +/* Copyright (C) 1992 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include +#include +#include + +#include "sysv_termio.h" + +/* Suspend or restart transmission on FD. */ +int +DEFUN(tcflow, (fd, action), int fd AND int action) +{ + switch (action) + { + case TCOOFF: + return __ioctl (fd, _TCXONC, 0); + case TCOON: + return __ioctl (fd, _TCXONC, 1); + case TCIOFF: + return __ioctl (fd, _TCXONC, 2); + case TCION: + return __ioctl (fd, _TCXONC, 3); + default: + errno = EINVAL; + return -1; + } +} diff -Nru glibc-1.02/sysdeps/unix/sysv/tcsetattr.c glibc-1.03/sysdeps/unix/sysv/tcsetattr.c --- glibc-1.02/sysdeps/unix/sysv/tcsetattr.c Thu Mar 5 18:45:40 1992 +++ glibc-1.03/sysdeps/unix/sysv/tcsetattr.c Wed Apr 1 02:32:34 1992 @@ -189,8 +189,16 @@ buf.c_cc[_SYSV_VQUIT] = termios_p->c_cc[VQUIT]; buf.c_cc[_SYSV_VERASE] = termios_p->c_cc[VERASE]; buf.c_cc[_SYSV_VKILL] = termios_p->c_cc[VKILL]; - buf.c_cc[_SYSV_VEOF] = termios_p->c_cc[VEOF]; - buf.c_cc[_SYSV_VEOL] = termios_p->c_cc[VEOL]; + if (buf.c_lflag & _SYSV_ICANON) + { + buf.c_cc[_SYSV_VEOF] = termios_p->c_cc[VEOF]; + buf.c_cc[_SYSV_VEOL] = termios_p->c_cc[VEOL]; + } + else + { + buf.c_cc[_SYSV_VMIN] = termios_p->c_cc[VMIN]; + buf.c_cc[_SYSV_VTIME] = termios_p->c_cc[VTIME]; + } buf.c_cc[_SYSV_VEOL2] = termios_p->c_cc[VEOL2]; if (__ioctl (fd, ioctl_function, &buf) < 0) diff -Nru glibc-1.02/tar.h glibc-1.03/tar.h --- glibc-1.02/tar.h +++ glibc-1.03/tar.h Thu Apr 9 21:22:07 1992 @@ -0,0 +1 @@ +#include diff -Nru glibc-1.02/time/Makefile glibc-1.03/time/Makefile --- glibc-1.02/time/Makefile Mon Mar 16 05:17:59 1992 +++ glibc-1.03/time/Makefile Mon Apr 6 03:52:17 1992 @@ -35,8 +35,10 @@ tests := test_time tzfiles := africa antarctica asia australasia europe northamerica \ - southamerica pacificnew etcetera factory systemv -distribute := $(distribute) $(tzfiles) leapseconds + southamerica etcetera factory systemv +# pacificnew doesn't compile; if it is to be used, it should be included in +# northamerica. +distribute := $(distribute) $(tzfiles) leapseconds pacificnew install := zic zdump @@ -51,6 +53,9 @@ ifdef localtime zonenames := $(zonenames) localtime endif +ifdef posixrules +zonenames := $(zonenames) posixrules +endif install-data := $(addprefix zoneinfo/,$(zonenames)) @@ -62,12 +67,16 @@ (echo 'define $*-zones' ;\ awk '$$1 == "Zone" { print $$2 } $$1 == "Link" { print $$3 }' $^;\ echo 'endef' ;\ - echo '$*-zones := $$(subst $$(\\n), ,$$($*-zones))' ;\ + echo '$*-zones := $$(subst $$('\\\\n'), ,$$($*-zones))' ;\ echo 'ifdef $*-zones' ;\ - echo '$$(addprefix %/,$$($*-zones)): \' ;\ + echo '$$(addprefix zoneinfo/%/,$$($*-zones)): \' ;\ echo '$< $$(objpfx)zic leapseconds zoneinfo/' ;\ echo ' $$(tzcompile)' ;\ echo 'endif' ;\ + echo 'define zonenames' ;\ + echo '$$($*-zones)' ;\ + echo 'endef' ;\ + echo 'zonenames := $$(subst $$('\\\\n'), ,$$(zonenames))' ;\ ) > $@ zonenames: Makefile (for file in $(tzfiles); do \ @@ -74,6 +83,10 @@ echo "include zones-$$file"; \ done) > $@ +.PHONY: echo-zonenames +echo-zonenames: zonenames + @echo 'Known zones: $(zonenames)' + # Make all the zoneinfo files. .PHONY: zones zoneinfo zones: zoneinfo @@ -80,7 +93,7 @@ zoneinfo: $(foreach file,$(tzfiles),$(addprefix zoneinfo/,$($(file)-zones))) define tzcompile -$(word 2,$^) -d zoneinfo -L $(word 3,$^) $< +$(word 2,$^) -d $(patsubst %/,%,$(word 4,$^)) -L $(word 3,$^) $< endef ifdef localtime @@ -88,8 +101,19 @@ $(word 2,$^) -d zoneinfo -l $(<:zoneinfo/%=%) zoneinfo: zoneinfo/localtime endif +ifdef posixrules +zoneinfo/posixrules: zoneinfo/$(posixrules) $(objpfx)zic + $(word 2,$^) -d zoneinfo -p $(<:zoneinfo/%=%) +zoneinfo: zoneinfo/posixrules +endif $(objpfx)zic: $(objpfx)scheck.o $(objpfx)ialloc.o $(objpfx)emkdir.o -$(objpfx)tzfile.o: tzfile.c - $(COMPILE.c) -DTZDIR='"$(datadir)/zoneinfo"' $< $(OUTPUT_OPTION) +$(objpfx)tzfile.o: tzfile.c; $(tz-cc) +$(objpfx)zic.o: zic.c; $(tz-cc) +define tz-cc +$(COMPILE.c) -DTZDIR='"$(datadir)/zoneinfo"' \ + -DTZDEFAULT='"$(localtime-file)"' \ + -DTZDEFRULES='"$(posixrules-file)"' \ + $< $(OUTPUT_OPTION) +endef diff -Nru glibc-1.02/time/__tzset.c glibc-1.03/time/__tzset.c --- glibc-1.02/time/__tzset.c Fri Mar 13 16:36:33 1992 +++ glibc-1.03/time/__tzset.c Mon Apr 6 03:46:58 1992 @@ -25,6 +25,12 @@ #include #include +#ifndef HAVE_GNU_LD +#define __tzname tzname +#define __daylight daylight +#define __timezone timezone +#endif + extern int __use_tzfile; extern void EXFUN(__tzfile_read, (CONST char *file)); extern int EXFUN(__tzfile_compute, (time_t, struct tm)); @@ -144,7 +150,7 @@ tz_rules[0].offset = *tz++ == '-' ? 1L : -1L; else tz_rules[0].offset = -1L; - switch (sscanf(tz, "%hu:%hu:%hu", &hh, &mm, &ss)) + switch (sscanf (tz, "%hu:%hu:%hu", &hh, &mm, &ss)) { default: return; @@ -189,34 +195,29 @@ tz_rules[1].offset = *tz++ == '-' ? 1L : -1L; else tz_rules[1].offset = -1L; - if (*tz != '\0') + + switch (sscanf (tz, "%hu:%hu:%hu", &hh, &mm, &ss)) { - switch (sscanf(tz, "%hu:%hu:%hu", &hh, &mm, &ss)) - { - default: - hh = 0; - case 1: - mm = 0; - case 2: - ss = 0; - case 3: - break; - } - tz_rules[1].offset *= (min(ss, 59) + (min(mm, 59) * 60) + - (min(hh, 12) * (60 * 60))); - for (l = 0; l < 3; ++l) - { - while (isdigit(*tz)) - ++tz; - if (l < 2 && *tz == ':') - ++tz; - } + default: + /* Default to one hour later than standard time. */ + tz_rules[1].offset *= abs (tz_rules[0].offset); + hh = 1; + + case 1: + mm = 0; + case 2: + ss = 0; + case 3: + break; } - else + tz_rules[1].offset *= (min(ss, 59) + (min(mm, 59) * 60) + + (min(hh, 12) * (60 * 60))); + for (l = 0; l < 3; ++l) { - /* Default to one hour later than standard time. */ - tz_rules[1].offset *= abs(tz_rules[0].offset); - tz_rules[1].offset += 60 * 60; + while (isdigit(*tz)) + ++tz; + if (l < 2 && *tz == ':') + ++tz; } /* If no standard or DST offset was given, default to GMT @@ -226,6 +227,15 @@ if (*tz_rules[1].name == '\0') tz_rules[1].offset = tz_rules[0].offset + (60 * 60); + if (*tz == '\0' || tz[0] == ',' && tz[1] == '\0') + { + /* There is no rule. See if there is a default rule file. */ + __tzfile_default (tz_rules[0].name, tz_rules[1].name, + tz_rules[0].offset, tz_rules[1].offset); + if (__use_tzfile) + return; + } + /* Figure out the standard <-> DST rules. */ for (whichrule = 0; whichrule < 2; ++whichrule) { @@ -257,12 +267,14 @@ } else if (*tz == 'M') { + int n; tzr->type = M; - if (sscanf(tz, "M%hu.%hu.%hu", &tzr->m, &tzr->n, &tzr->d) != 3) - return; - else if (tzr->m < 1 || tzr->m > 12 || tzr->n < 1 || - tzr->n > 5 || tzr->d > 6) + if (sscanf (tz, "M%hu.%hu.%hu%n", + &tzr->m, &tzr->n, &tzr->d, &n) != 3 || + tzr->m < 1 || tzr->m > 12 || + tzr->n < 1 || tzr->n > 5 || tzr->d > 6) return; + tz += n; } else if (*tz == '\0') { @@ -270,13 +282,13 @@ tzr->type = M; if (tzr == &tz_rules[0]) { - tzr->m = 3; + tzr->m = 4; tzr->n = 1; tzr->d = 0; } else { - tzr->m = 8; + tzr->m = 10; tzr->n = 5; tzr->d = 0; } diff -Nru glibc-1.02/time/australasia glibc-1.03/time/australasia --- glibc-1.02/time/australasia Mon Sep 9 22:26:27 1991 +++ glibc-1.03/time/australasia Sun Mar 22 17:33:57 1992 @@ -87,14 +87,17 @@ # New Zealand, from Elz' asia 1.1 # Elz says "no guarantees" -# From U. S. Naval Observatory (January 19, 1989): -# NEW ZEALAND 12 H AHEAD OF UTC (EXCLUDING CHATHAM ISLAND) -# NEW ZEALAND 13 H AHEAD OF UTC OCT 30, '88-MAR 4, '89 -# NEW ZEALAND 12H45M AHEAD OF UTC CHATHAM ISLAND - +# the 1989/90 year was a trial of an extended "daylight saving" period. +# This trial was deemed successful and the extended period adopted for +# subsequent years (with the addition of a further week at the start). +# source -- phone call to Ministry of Internal Affairs Head Office. +# Mark Davies , 3 Oct 1990. # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule NZ 1974 max - Oct lastSun 2:00 1:00 D -Rule NZ 1975 max - Mar Sun>=1 3:00 0 S +Rule NZ 1974 1988 - Oct lastSun 2:00 1:00 D +Rule NZ 1989 only - Oct 8 2:00 1:00 D +Rule NZ 1990 max - Oct Sun>=1 2:00 1:00 D +Rule NZ 1975 1989 - Mar Sun>=1 3:00 0 S +Rule NZ 1990 max - Mar Sun>=15 3:00 0 S # Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL] Zone NZ 12:00 NZ NZ%sT # New Zealand diff -Nru glibc-1.02/time/localtime.c glibc-1.03/time/localtime.c --- glibc-1.02/time/localtime.c Wed Jun 12 17:48:38 1991 +++ glibc-1.03/time/localtime.c Thu Apr 9 22:21:44 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -26,6 +26,12 @@ #include +#ifndef HAVE_GNU_LD +#define __tzname tzname +#define __daylight daylight +#define __timezone timezone +#endif + /* Return the `struct tm' representation of *TIMER in the local timezone. */ struct tm * DEFUN(localtime, (timer), CONST time_t *timer) @@ -43,10 +49,12 @@ if (tp == NULL) return NULL; - if (!__tz_compute(*timer, *tp)) + if (!__tz_compute (*timer, *tp)) return NULL; tp = __offtime(timer, __timezone); tp->tm_isdst = __daylight; + tp->tm_gmtoff = __timezone; + tp->tm_zone = __tzname[__daylight]; return tp; } diff -Nru glibc-1.02/time/strftime.c glibc-1.03/time/strftime.c --- glibc-1.02/time/strftime.c Mon Aug 26 20:35:54 1991 +++ glibc-1.03/time/strftime.c Mon Apr 6 01:45:50 1992 @@ -4,7 +4,7 @@ e */ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -31,6 +31,12 @@ #include #include #include + +#ifndef HAVE_GNU_LD +#define __tzname tzname +#define __daylight daylight +#define __timezone timezone +#endif #define add(n, f) \ diff -Nru glibc-1.02/time/time.h glibc-1.03/time/time.h --- glibc-1.02/time/time.h Sat Mar 7 20:10:15 1992 +++ glibc-1.03/time/time.h Mon Apr 6 03:15:42 1992 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 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 @@ -83,6 +83,8 @@ int tm_wday; /* Day of week. [0-6] */ int tm_yday; /* Days in year.[0-365] */ int tm_isdst; /* DST. [-1/0/1]*/ + long int tm_gmtoff; /* Seconds west of UTC. */ + CONST char *tm_zone;/* Timezone abbreviation. */ }; #endif /* included. */ @@ -156,7 +158,6 @@ #ifdef __USE_POSIX /* Same as above. */ extern char *tzname[2]; -#define tzname __tzname extern long int EXFUN(__tzname_max, (NOARGS)); @@ -169,8 +170,6 @@ #ifdef __USE_SVID extern int daylight; extern long int timezone; -#define daylight __daylight -#define timezone __timezone #endif diff -Nru glibc-1.02/time/tzfile.c glibc-1.03/time/tzfile.c --- glibc-1.02/time/tzfile.c Mon Mar 16 07:24:21 1992 +++ glibc-1.03/time/tzfile.c Mon Apr 6 22:09:43 1992 @@ -26,6 +26,12 @@ #define NOID #include +#ifndef HAVE_GNU_LD +#define __tzname tzname +#define __daylight daylight +#define __timezone timezone +#endif + int __use_tzfile = 0; struct ttinfo @@ -33,7 +39,7 @@ long int offset; /* Seconds east of GMT. */ unsigned char isdst; /* Used to set tm_isdst. */ unsigned char idx; /* Index into `zone_names'. */ - unsigned int isstd:1; /* Transition times are standard time. */ + unsigned char isstd; /* Transition times are standard time. */ }; struct leap @@ -143,6 +149,9 @@ fread((PTR) type_idxs, 1, num_transitions, f) != num_transitions) goto lose; + for (i = 0; i < num_transitions; ++i) + transitions[i] = uc2ul (&transitions[i]); + for (i = 0; i < num_types; ++i) { unsigned char x[4]; @@ -184,8 +193,47 @@ lose:; (void) fclose(f); } + +void +DEFUN(__tzfile_default, (std, dst, stdoff, dstoff), + char *std AND char *dst AND + long int stdoff AND long int dstoff) +{ + size_t stdlen, dstlen; + + __tzfile_read (TZDEFRULES); + if (!__use_tzfile) + return; + + if (num_types != 2) + { + __use_tzfile = 0; + return; + } + + free (zone_names); + stdlen = strlen (std) + 1; + dstlen = strlen (dst) + 1; + zone_names = malloc (stdlen + dstlen); + if (zone_names == NULL) + { + __use_tzfile = 0; + return; + } + memcpy (zone_names, std, stdlen); + memcpy (&zone_names[stdlen], dst, dstlen); + types[0].idx = 0; + types[0].isdst = 0; + if (std[0] != '\0') + types[0].offset = stdoff; + types[1].idx = stdlen; + types[1].isdst = 1; + if (dst[0] != '\0') + types[1].offset = dstoff; +} + int DEFUN(__tzfile_compute, (timer, tm), time_t timer AND struct tm tm) { diff -Nru glibc-1.02/version.c glibc-1.03/version.c --- glibc-1.02/version.c Fri Mar 20 19:36:09 1992 +++ glibc-1.03/version.c Thu Apr 9 02:02:31 1992 @@ -20,7 +20,7 @@ #include CONST char __libc_release[] = "beta"; -CONST char __libc_version[] = "1.02"; +CONST char __libc_version[] = "1.03"; void DEFUN_VOID(__libc_print_version)