aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1996-01-21 10:01:05 +0000
committerRoland McGrath <roland@gnu.org>1996-01-21 10:01:05 +0000
commitbbed653cda6007426e8291a5d32963552cc4f417 (patch)
tree881a95cad53014826d7906027926e00bc45dbca3
parenteb63bdd072eafe6aba40d254a71fd87285f497da (diff)
downloadglibc-bbed653cda6007426e8291a5d32963552cc4f417.tar
glibc-bbed653cda6007426e8291a5d32963552cc4f417.tar.gz
glibc-bbed653cda6007426e8291a5d32963552cc4f417.tar.bz2
glibc-bbed653cda6007426e8291a5d32963552cc4f417.zip
Sun Jan 21 00:55:25 1996 Roland McGrath <roland@churchy.gnu.ai.mit.edu>cvs/libc-960121
* sysdeps/unix/sysv/linux/shmat.c: Include sys/shm.h instead of sys/sem.h. * stdlib/stdlib.h [__USE_SVID]: Declare a64l, l64a. * stdlib/l64a.c: Use 6-bit numbers as indices in CONV_TABLE, not literal byte values. * misc/bsd-compat.c (getpgrp): Define with prototype. * misc/init-misc.c (__progname_full): New variable. (program_invocation_name, program_invocation_short_name): New aliases. (__init_misc): Define with prototype. Set __progname_full. * misc/progname.c: File removed. * misc/Makefile (aux): Remove progname. * misc/hsearch_r.c (isprime): Define with prototype. * sysdeps/unix/sysv/linux/seteuid.c: Just include unix/bsd version. * sysdeps/unix/bsd/seteuid.c: Disallow arg of -1. * sysdeps/unix/bsd/setegid.c: Likewise.
-rw-r--r--ChangeLog24
-rw-r--r--misc/Makefile2
-rw-r--r--misc/bsd-compat.c5
-rw-r--r--misc/error.c21
-rw-r--r--misc/hsearch_r.c21
-rw-r--r--misc/init-misc.c16
-rw-r--r--misc/progname.c53
-rw-r--r--stdlib/l64a.c4
-rw-r--r--stdlib/stdlib.h13
-rw-r--r--sysdeps/unix/bsd/setegid.c13
-rw-r--r--sysdeps/unix/bsd/seteuid.c13
-rw-r--r--sysdeps/unix/sysv/linux/seteuid.c37
-rw-r--r--sysdeps/unix/sysv/linux/shmat.c2
13 files changed, 93 insertions, 131 deletions
diff --git a/ChangeLog b/ChangeLog
index f41f575b0a..50785a204f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+Sun Jan 21 00:55:25 1996 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
+
+ * sysdeps/unix/sysv/linux/shmat.c: Include sys/shm.h instead of
+ sys/sem.h.
+
+ * stdlib/stdlib.h [__USE_SVID]: Declare a64l, l64a.
+
+ * stdlib/l64a.c: Use 6-bit numbers as indices in CONV_TABLE, not
+ literal byte values.
+
+ * misc/bsd-compat.c (getpgrp): Define with prototype.
+
+ * misc/init-misc.c (__progname_full): New variable.
+ (program_invocation_name, program_invocation_short_name): New aliases.
+ (__init_misc): Define with prototype. Set __progname_full.
+ * misc/progname.c: File removed.
+ * misc/Makefile (aux): Remove progname.
+
+ * misc/hsearch_r.c (isprime): Define with prototype.
+
+ * sysdeps/unix/sysv/linux/seteuid.c: Just include unix/bsd version.
+ * sysdeps/unix/bsd/seteuid.c: Disallow arg of -1.
+ * sysdeps/unix/bsd/setegid.c: Likewise.
+
Fri Jan 19 13:28:59 1996 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* sysdeps/unix/sysv/linux/tcdrain.c: Define tcdrain, not
diff --git a/misc/Makefile b/misc/Makefile
index 775d6c6bb3..4a5546634e 100644
--- a/misc/Makefile
+++ b/misc/Makefile
@@ -53,7 +53,7 @@ routines := brk sbrk sstk ioctl \
efgcvt efgcvt_r \
hsearch hsearch_r tsearch \
err error
-aux := progname init-misc
+aux := init-misc
distribute := bsd-compat.c
extra-objs := bsd-compat.o
install-lib := libbsd-compat.a libg.a
diff --git a/misc/bsd-compat.c b/misc/bsd-compat.c
index 2bcef9f9d4..ad593b9e1c 100644
--- a/misc/bsd-compat.c
+++ b/misc/bsd-compat.c
@@ -1,6 +1,6 @@
/* BSD-compatible versions of functions where BSD and POSIX.1 conflict.
-Copyright (C) 1991, 1992, 1994, 1995 Free Software Foundation, Inc.
+Copyright (C) 1991, 1992, 1994, 1995, 1996 Free Software 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,8 +25,7 @@ Cambridge, MA 02139, USA. */
extern pid_t __getpgid __P ((pid_t));
pid_t
-getpgrp (pid)
- pid_t pid;
+getpgrp (pid_t pid)
{
return __getpgid (pid);
}
diff --git a/misc/error.c b/misc/error.c
index da3c6ee1b2..cdba470656 100644
--- a/misc/error.c
+++ b/misc/error.c
@@ -1,5 +1,5 @@
/* error.c -- error handler for noninteractive utilities
- Copyright (C) 1990, 91, 92, 93, 94, 95 Free Software Foundation, Inc.
+ Copyright (C) 1990, 91, 92, 93, 94, 95, 96 Free Software Foundation, Inc.
This file is part of the GNU C Library. Its master source is NOT part of
the C library, however. The master source lives in /gd/gnu/lib.
@@ -47,23 +47,27 @@ Cambridge, MA 02139, USA. */
void exit ();
#endif
-/* This variable is incremented each time `error' is called. */
-unsigned int error_message_count;
-
/* If NULL, error will flush stdout, then print on stderr the program
name, a colon and a space. Otherwise, error will call this
function without parameters instead. */
-void (*error_print_progname) () = NULL;
+void (*error_print_progname) ();
+
+/* This variable is incremented each time `error' is called. */
+unsigned int error_message_count;
#ifdef _LIBC
+/* In the GNU C library, there is a predefined variable for this. */
+
#define program_name program_invocation_name
-#endif
+#include <errno.h>
+
+#else
/* The calling program should define program_name and set it to the
name of the executing program. */
extern char *program_name;
-#if HAVE_STRERROR || _LIBC
+#if HAVE_STRERROR
# ifndef strerror /* On some systems, strerror is a macro */
char *strerror ();
# endif
@@ -80,7 +84,8 @@ private_strerror (errnum)
return "Unknown system error";
}
#define strerror private_strerror
-#endif
+#endif /* HAVE_STRERROR */
+#endif /* _LIBC */
/* Print the program name and error message MESSAGE, which is a printf-style
format string with optional args.
diff --git a/misc/hsearch_r.c b/misc/hsearch_r.c
index 5ea1d5e6c8..86dbe793c0 100644
--- a/misc/hsearch_r.c
+++ b/misc/hsearch_r.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1995 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc.
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>
This file is part of the GNU C Library.
@@ -31,7 +31,7 @@ Boston, MA 02111-1307, USA. */
Instead the interface of all functions is extended to take an argument
which describes the current status. */
typedef struct _ENTRY
-{
+{
int used;
ENTRY entry;
}
@@ -44,8 +44,7 @@ _ENTRY;
a) the code is (most probably) called a few times per program run and
b) the number is small because the table must fit in the core */
static int
-isprime (number)
- unsigned int number;
+isprime (unsigned int number)
{
/* no even number will be passed */
unsigned int div = 3;
@@ -61,7 +60,7 @@ isprime (number)
Test for an existing table are done. We allocate one element
more as the found prime number says. This is done for more effective
indexing as explained in the comment for the hsearch function.
- The contents of the table is zeroed, especially the field used
+ The contents of the table is zeroed, especially the field used
becomes zero. */
int
hcreate_r (nel, htab)
@@ -114,7 +113,7 @@ hdestroy_r (htab)
/* free used memory */
free (htab->table);
- /* the sign for an existing table is an value != NULL in htable */
+ /* the sign for an existing table is an value != NULL in htable */
htab->table = NULL;
}
@@ -124,7 +123,7 @@ hdestroy_r (htab)
probably strings of chars. The function for generating a number of the
strings is simple but fast. It can be replaced by a more complex function
like ajw (see [Aho,Sethi,Ullman]) if the needs are shown.
-
+
We use an trick to speed up the lookup. The table is created by hcreate
with one more element available. This enables us to use the index zero
special. This index will never be used because we store the first hash
@@ -144,7 +143,7 @@ hsearch_r (item, action, retval, htab)
unsigned int len = strlen (item.key);
unsigned int idx;
- /* If table is full and another entry should be entered return with
+ /* If table is full and another entry should be entered return with
error. */
if (action == ENTER && htab->filled == htab->size)
{
@@ -178,7 +177,7 @@ hsearch_r (item, action, retval, htab)
if (htab->table[idx].used == hval
&& strcmp (item.key, htab->table[idx].entry.key) == 0)
{
- if (action == ENTER)
+ if (action == ENTER)
htab->table[idx].entry.data = item.data;
*retval = &htab->table[idx].entry;
@@ -187,7 +186,7 @@ hsearch_r (item, action, retval, htab)
/* Second hash function, as suggested in [Knuth] */
hval2 = 1 + hval % (htab->size - 2);
-
+
do
{
/* Because SIZE is prime this guarantees to step through all
@@ -201,7 +200,7 @@ hsearch_r (item, action, retval, htab)
if (htab->table[idx].used == hval
&& strcmp (item.key, htab->table[idx].entry.key) == 0)
{
- if (action == ENTER)
+ if (action == ENTER)
htab->table[idx].entry.data = item.data;
*retval = &htab->table[idx].entry;
diff --git a/misc/init-misc.c b/misc/init-misc.c
index 9fb876beb0..44531a5e77 100644
--- a/misc/init-misc.c
+++ b/misc/init-misc.c
@@ -1,5 +1,5 @@
/* Define and initialize `__progname'.
-Copyright (C) 1994, 1995 Free Software Foundation, Inc.
+Copyright (C) 1994, 1995, 1996 Free Software 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,14 +18,15 @@ not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include <string.h>
+#include <errno.h>
+char *__progname_full = (char *) "";
char *__progname = (char *) "";
+weak_alias (__progname_full, program_invocation_name)
+weak_alias (__progname, program_invocation_short_name)
void
-__init_misc (argc, argv, envp)
- int argc;
- char **argv;
- char **envp;
+__init_misc (int argc, char **argv, char **envp)
{
if (argv && argv[0])
{
@@ -34,9 +35,6 @@ __init_misc (argc, argv, envp)
__progname = argv[0];
else
__progname = p + 1;
+ __progname_full = argv[0];
}
}
-
-#ifdef HAVE_GNU_LD
-text_set_element (__libc_subinit, __init_misc);
-#endif
diff --git a/misc/progname.c b/misc/progname.c
deleted file mode 100644
index d4efac976d..0000000000
--- a/misc/progname.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/* Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
-
-The GNU C Library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
-
-The GNU C Library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with the GNU C Library; see the file COPYING.LIB. If
-not, write to the Free Software Foundation, Inc., 675 Mass Ave,
-Cambridge, MA 02139, USA. */
-
-#ifdef HAVE_GNU_LD
-
-#include <ansidecl.h>
-#include <string.h>
-
-/* These must be initialized data definitions. Common definitions satisfy
- references to these variables, but do not cause the whole file to be
- linked in, and so omit the set-up function. */
-char *program_invocation_name = NULL;
-char *program_invocation_short_name = NULL;
-
-static void
-DEFUN(set_progname, (argc, argv, envp),
- int argc AND char **argv AND char **envp)
-{
- char *p;
-
- if (argv && argv[0])
- {
- program_invocation_name = argv[0];
- p = strrchr (argv[0], '/');
- if (p == NULL)
- program_invocation_short_name = argv[0];
- else
- program_invocation_short_name = p + 1;
- }
- else
- program_invocation_name = program_invocation_short_name = 0;
-
- (void) &set_progname; /* Avoid "defined but not used" warning. */
-}
-
-text_set_element (__libc_subinit, set_progname);
-
-#endif
diff --git a/stdlib/l64a.c b/stdlib/l64a.c
index ad19a3b6eb..ac2cb64804 100644
--- a/stdlib/l64a.c
+++ b/stdlib/l64a.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, August 1995.
@@ -43,7 +43,7 @@ l64a (n)
for (cnt = 5; cnt >= 0; --cnt)
{
- result[cnt] = n & 0x3f;
+ result[cnt] = conv_table[n & 0x3f];
n >>= 6;
}
diff --git a/stdlib/stdlib.h b/stdlib/stdlib.h
index 09418afb28..7c9c68974b 100644
--- a/stdlib/stdlib.h
+++ b/stdlib/stdlib.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 92, 93, 94, 95, 96 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -156,6 +156,17 @@ extern __inline long int atol (__const char *__nptr)
#endif /* Optimizing GCC >=2. */
+#ifdef __USE_SVID
+/* Convert N to base 64 using the digits "./0-9A-Za-z", least-significant
+ digit first. Returns a pointer to static storage overwritten by the
+ next call. */
+extern char *l64a __P ((long int __n));
+
+/* Read a number from a string in base 64 as above. */
+extern long int a64l __P ((const char *));
+#endif
+
+
/* Return a random integer between 0 and RAND_MAX inclusive. */
extern int rand __P ((void));
/* Seed the random number generator with the given number. */
diff --git a/sysdeps/unix/bsd/setegid.c b/sysdeps/unix/bsd/setegid.c
index 85ebea2c96..c4a3780f6d 100644
--- a/sysdeps/unix/bsd/setegid.c
+++ b/sysdeps/unix/bsd/setegid.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1996 Free Software 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,12 +16,19 @@ 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 <ansidecl.h>
+#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
int
-DEFUN(setegid, (gid), gid_t gid)
+setegid (gid)
+ gid_t gid;
{
+ if (gid == (gid_t) ~0)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
return __setregid (-1, gid);
}
diff --git a/sysdeps/unix/bsd/seteuid.c b/sysdeps/unix/bsd/seteuid.c
index a4be2d98a3..f6aa37f153 100644
--- a/sysdeps/unix/bsd/seteuid.c
+++ b/sysdeps/unix/bsd/seteuid.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1996 Free Software 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,12 +16,19 @@ 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 <ansidecl.h>
+#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
int
-DEFUN(seteuid, (uid), uid_t uid)
+seteuid (uid)
+ uid_t uid;
{
+ if (uid == (uid_t) ~0)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
return __setreuid (-1, uid);
}
diff --git a/sysdeps/unix/sysv/linux/seteuid.c b/sysdeps/unix/sysv/linux/seteuid.c
index 850f3c5656..37fb72c020 100644
--- a/sysdeps/unix/sysv/linux/seteuid.c
+++ b/sysdeps/unix/sysv/linux/seteuid.c
@@ -1,36 +1 @@
-/* Copyright (C) 1995 Free Software 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 <errno.h>
-#include <unistd.h>
-#include <sys/types.h>
-
-int
-__seteuid (uid)
- uid_t uid;
-{
- if (uid == (uid_t) ~0)
- {
- errno = EINVAL;
- return -1;
- }
-
- return __setreuid (-1, uid);
-}
-
-weak_alias (__seteuid, seteuid)
+#include <sysdeps/unix/bsd/seteuid.c>
diff --git a/sysdeps/unix/sysv/linux/shmat.c b/sysdeps/unix/sysv/linux/shmat.c
index 1efef29215..b74b8a56ec 100644
--- a/sysdeps/unix/sysv/linux/shmat.c
+++ b/sysdeps/unix/sysv/linux/shmat.c
@@ -17,7 +17,7 @@ License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-#include <sys/sem.h>
+#include <sys/shm.h>
/* Attach the shared memory segment associated with SHMID to the data
segment of the calling process. SHMADDR and SHMFLG determine how