summaryrefslogtreecommitdiff
path: root/lib/libc/stdlib
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/stdlib')
-rw-r--r--lib/libc/stdlib/Makefile.inc5
-rw-r--r--lib/libc/stdlib/abort.c15
-rw-r--r--lib/libc/stdlib/getenv.c44
-rw-r--r--lib/libc/stdlib/heapsort.c3
-rw-r--r--lib/libc/stdlib/ldiv.32
-rw-r--r--lib/libc/stdlib/qsort.c12
-rw-r--r--lib/libc/stdlib/strhash.c2
7 files changed, 31 insertions, 52 deletions
diff --git a/lib/libc/stdlib/Makefile.inc b/lib/libc/stdlib/Makefile.inc
index 81e8ed030903..de3d864b36ea 100644
--- a/lib/libc/stdlib/Makefile.inc
+++ b/lib/libc/stdlib/Makefile.inc
@@ -14,10 +14,10 @@ SRCS+= abort.c atexit.c atof.c atoi.c atol.c bsearch.c calloc.c div.c \
MAN3+= stdlib/abort.3 stdlib/abs.3 stdlib/alloca.3 stdlib/atexit.3 \
stdlib/atof.3 stdlib/atoi.3 stdlib/atol.3 stdlib/bsearch.3 \
- stdlib/calloc.3 stdlib/div.3 stdlib/exit.3 \
+ stdlib/calloc.3 stdlib/div.3 stdlib/exit.3 stdlib/free.3 \
stdlib/getenv.3 stdlib/getopt.3 stdlib/getsubopt.3 stdlib/labs.3 \
stdlib/ldiv.3 stdlib/malloc.3 stdlib/memory.3 stdlib/qsort.3 \
- stdlib/radixsort.3 stdlib/rand.3 stdlib/random.3 \
+ stdlib/radixsort.3 stdlib/rand.3 stdlib/random.3 stdlib/realloc.3 \
stdlib/realpath.3 stdlib/strtod.3 stdlib/strtol.3 stdlib/strtoul.3 \
stdlib/system.3
@@ -27,4 +27,3 @@ MLINKS+=rand.3 srand.3
MLINKS+=random.3 initstate.3 random.3 setstate.3 random.3 srandom.3
MLINKS+=strtol.3 strtoq.3
MLINKS+=strtoul.3 strtouq.3
-MLINKS+=malloc.3 free.3 malloc.3 realloc.3
diff --git a/lib/libc/stdlib/abort.c b/lib/libc/stdlib/abort.c
index f41500739fec..e56e7e97d6b1 100644
--- a/lib/libc/stdlib/abort.c
+++ b/lib/libc/stdlib/abort.c
@@ -35,14 +35,10 @@
static char sccsid[] = "@(#)abort.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
-#include <signal.h>
+#include <sys/signal.h>
#include <stdlib.h>
#include <stddef.h>
#include <unistd.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-#endif
void
abort()
@@ -55,24 +51,15 @@ abort()
* any errors -- X311J doesn't allow abort to return anyway.
*/
sigdelset(&mask, SIGABRT);
-#ifdef _THREAD_SAFE
- (void) _thread_sys_sigprocmask(SIG_SETMASK, &mask, (sigset_t *)NULL);
-#else
(void)sigprocmask(SIG_SETMASK, &mask, (sigset_t *)NULL);
-#endif
(void)kill(getpid(), SIGABRT);
/*
* if SIGABRT ignored, or caught and the handler returns, do
* it again, only harder.
*/
-#ifdef _THREAD_SAFE
- (void) _thread_sys_signal(SIGABRT, SIG_DFL);
- (void) _thread_sys_sigprocmask(SIG_SETMASK, &mask, (sigset_t *)NULL);
-#else
(void)signal(SIGABRT, SIG_DFL);
(void)sigprocmask(SIG_SETMASK, &mask, (sigset_t *)NULL);
-#endif
(void)kill(getpid(), SIGABRT);
exit(1);
}
diff --git a/lib/libc/stdlib/getenv.c b/lib/libc/stdlib/getenv.c
index a6bbd355d93f..7407e0b81749 100644
--- a/lib/libc/stdlib/getenv.c
+++ b/lib/libc/stdlib/getenv.c
@@ -39,7 +39,20 @@ static char sccsid[] = "@(#)getenv.c 8.1 (Berkeley) 6/4/93";
#include <stddef.h>
#include <string.h>
-inline char *__findenv __P((const char *, int *));
+char *__findenv __P((const char *, int *));
+
+/*
+ * getenv --
+ * Returns ptr to value associated with name, if any, else NULL.
+ */
+char *
+getenv(name)
+ const char *name;
+{
+ int offset;
+
+ return (__findenv(name, &offset));
+}
/*
* __findenv --
@@ -50,42 +63,25 @@ inline char *__findenv __P((const char *, int *));
*
* This routine *should* be a static; don't use it.
*/
-inline char *
+char *
__findenv(name, offset)
register const char *name;
int *offset;
{
extern char **environ;
- register int len, i;
+ register int len;
register const char *np;
- register char **p, *cp;
+ register char **p, *c;
if (name == NULL || environ == NULL)
return (NULL);
for (np = name; *np && *np != '='; ++np)
continue;
len = np - name;
- for (p = environ; (cp = *p) != NULL; ++p) {
- for (np = name, i = len; i && *cp; i--)
- if (*cp++ != *np++)
- break;
- if (i == 0 && *cp++ == '=') {
+ for (p = environ; (c = *p) != NULL; ++p)
+ if (strncmp(c, name, len) == 0 && c[len] == '=') {
*offset = p - environ;
- return (cp);
+ return (c + len + 1);
}
- }
return (NULL);
}
-
-/*
- * getenv --
- * Returns ptr to value associated with name, if any, else NULL.
- */
-char *
-getenv(name)
- const char *name;
-{
- int offset;
-
- return (__findenv(name, &offset));
-}
diff --git a/lib/libc/stdlib/heapsort.c b/lib/libc/stdlib/heapsort.c
index 964955381ea2..d800064f648a 100644
--- a/lib/libc/stdlib/heapsort.c
+++ b/lib/libc/stdlib/heapsort.c
@@ -38,9 +38,10 @@
static char sccsid[] = "@(#)heapsort.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
+#include <sys/types.h>
#include <errno.h>
-#include <stddef.h>
#include <stdlib.h>
+#include <stddef.h>
/*
* Swap two areas of size number of bytes. Although qsort(3) permits random
diff --git a/lib/libc/stdlib/ldiv.3 b/lib/libc/stdlib/ldiv.3
index 2b61499e4ecd..a68952f94b26 100644
--- a/lib/libc/stdlib/ldiv.3
+++ b/lib/libc/stdlib/ldiv.3
@@ -44,7 +44,7 @@
.Sh SYNOPSIS
.Fd #include <stdlib.h>
.Ft ldiv_t
-.Fn ldiv "long num" "long denom"
+.Fn ldiv "int num" "int denom"
.Sh DESCRIPTION
The
.Fn ldiv
diff --git a/lib/libc/stdlib/qsort.c b/lib/libc/stdlib/qsort.c
index 7c3d2133a064..49f53495a10a 100644
--- a/lib/libc/stdlib/qsort.c
+++ b/lib/libc/stdlib/qsort.c
@@ -32,17 +32,13 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-#if 0
static char sccsid[] = "@(#)qsort.c 8.1 (Berkeley) 6/4/93";
-#endif
-static const char rcsid[] =
- "$Id$";
#endif /* LIBC_SCCS and not lint */
+#include <sys/types.h>
#include <stdlib.h>
-typedef int cmp_t __P((const void *, const void *));
-static inline char *med3 __P((char *, char *, char *, cmp_t *));
+static inline char *med3 __P((char *, char *, char *, int (*)()));
static inline void swapfunc __P((char *, char *, int, int));
#define min(a, b) (a) < (b) ? a : b
@@ -88,7 +84,7 @@ swapfunc(a, b, n, swaptype)
static inline char *
med3(a, b, c, cmp)
char *a, *b, *c;
- cmp_t *cmp;
+ int (*cmp)();
{
return cmp(a, b) < 0 ?
(cmp(b, c) < 0 ? b : (cmp(a, c) < 0 ? c : a ))
@@ -99,7 +95,7 @@ void
qsort(a, n, es, cmp)
void *a;
size_t n, es;
- cmp_t *cmp;
+ int (*cmp)();
{
char *pa, *pb, *pc, *pd, *pl, *pm, *pn;
int d, r, swaptype, swap_cnt;
diff --git a/lib/libc/stdlib/strhash.c b/lib/libc/stdlib/strhash.c
index 1ccda325d447..860d52a5212e 100644
--- a/lib/libc/stdlib/strhash.c
+++ b/lib/libc/stdlib/strhash.c
@@ -1,5 +1,5 @@
#ifndef lint
-static char *rcsid = "$Header: /home/ncvs/src/lib/libc/stdlib/strhash.c,v 1.4.4.1 1996/02/11 09:05:56 jkh Exp $";
+static char *rcsid = "$Header: /pub/FreeBSD/FreeBSD-CVS/src/lib/libc/stdlib/strhash.c,v 1.4.4.1 1996/02/11 09:05:56 jkh Exp $";
#endif
/*