summaryrefslogtreecommitdiff
path: root/lib/libc/stdlib
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2015-09-13 08:31:49 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2015-09-13 08:31:49 +0000
commit219271e05791f714c6773e2c340b9b4edd65ecb5 (patch)
tree29048a1ccab17cccae97e6c48797ebf9cd39b82b /lib/libc/stdlib
parent2223ad9f29c5814db092acde717ec2b6862fce5f (diff)
Wrap <stdlib.h> so that calls go direct and the symbols not in the
C standard are all weak. Apply __{BEGIN,END}_HIDDEN_DECLS to gdtoa{,imp}.h, hiding the arch-specific __strtorx, __ULtox_D2A, __strtorQ, __ULtoQ_D2A symbols.
Diffstat (limited to 'lib/libc/stdlib')
-rw-r--r--lib/libc/stdlib/abort.c3
-rw-r--r--lib/libc/stdlib/abs.c3
-rw-r--r--lib/libc/stdlib/atoi.c3
-rw-r--r--lib/libc/stdlib/div.c3
-rw-r--r--lib/libc/stdlib/erand48.c3
-rw-r--r--lib/libc/stdlib/exit.c3
-rw-r--r--lib/libc/stdlib/getenv.c4
-rw-r--r--lib/libc/stdlib/lcong48.c3
-rw-r--r--lib/libc/stdlib/malloc.c9
-rw-r--r--lib/libc/stdlib/qsort.c3
-rw-r--r--lib/libc/stdlib/rand.c1
-rw-r--r--lib/libc/stdlib/reallocarray.c3
-rw-r--r--lib/libc/stdlib/setenv.c7
-rw-r--r--lib/libc/stdlib/srand48.c3
-rw-r--r--lib/libc/stdlib/strtol.c3
-rw-r--r--lib/libc/stdlib/strtoll.c5
-rw-r--r--lib/libc/stdlib/strtonum.c3
-rw-r--r--lib/libc/stdlib/strtoul.c3
-rw-r--r--lib/libc/stdlib/strtoull.c5
-rw-r--r--lib/libc/stdlib/system.c3
20 files changed, 49 insertions, 24 deletions
diff --git a/lib/libc/stdlib/abort.c b/lib/libc/stdlib/abort.c
index dd057710ff2..903bfa78e18 100644
--- a/lib/libc/stdlib/abort.c
+++ b/lib/libc/stdlib/abort.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: abort.c,v 1.17 2014/05/14 21:54:20 tedu Exp $ */
+/* $OpenBSD: abort.c,v 1.18 2015/09/13 08:31:47 guenther Exp $ */
/*
* Copyright (c) 1985 Regents of the University of California.
* All rights reserved.
@@ -61,3 +61,4 @@ abort(void)
(void)raise(SIGABRT);
_exit(1);
}
+DEF_STRONG(abort);
diff --git a/lib/libc/stdlib/abs.c b/lib/libc/stdlib/abs.c
index 5d2fbae69f1..0e39cc55367 100644
--- a/lib/libc/stdlib/abs.c
+++ b/lib/libc/stdlib/abs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: abs.c,v 1.5 2005/08/08 08:05:36 espie Exp $ */
+/* $OpenBSD: abs.c,v 1.6 2015/09/13 08:31:47 guenther Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
@@ -35,3 +35,4 @@ abs(int j)
{
return(j < 0 ? -j : j);
}
+DEF_STRONG(abs);
diff --git a/lib/libc/stdlib/atoi.c b/lib/libc/stdlib/atoi.c
index b0842678e2f..7c9eb1331b0 100644
--- a/lib/libc/stdlib/atoi.c
+++ b/lib/libc/stdlib/atoi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: atoi.c,v 1.5 2005/08/08 08:05:36 espie Exp $ */
+/* $OpenBSD: atoi.c,v 1.6 2015/09/13 08:31:47 guenther Exp $ */
/*
* Copyright (c) 1988 Regents of the University of California.
* All rights reserved.
@@ -35,3 +35,4 @@ atoi(const char *str)
{
return((int)strtol(str, (char **)NULL, 10));
}
+DEF_STRONG(atoi);
diff --git a/lib/libc/stdlib/div.c b/lib/libc/stdlib/div.c
index f7ac2db4b04..beaa428c7a8 100644
--- a/lib/libc/stdlib/div.c
+++ b/lib/libc/stdlib/div.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: div.c,v 1.5 2005/08/08 08:05:36 espie Exp $ */
+/* $OpenBSD: div.c,v 1.6 2015/09/13 08:31:47 guenther Exp $ */
/*
* Copyright (c) 1990 Regents of the University of California.
* All rights reserved.
@@ -69,3 +69,4 @@ div(int num, int denom)
}
return (r);
}
+DEF_STRONG(div);
diff --git a/lib/libc/stdlib/erand48.c b/lib/libc/stdlib/erand48.c
index 2ffeaa6e710..20d6a2dd690 100644
--- a/lib/libc/stdlib/erand48.c
+++ b/lib/libc/stdlib/erand48.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: erand48.c,v 1.3 2005/08/08 08:05:36 espie Exp $ */
+/* $OpenBSD: erand48.c,v 1.4 2015/09/13 08:31:47 guenther Exp $ */
/*
* Copyright (c) 1993 Martin Birgmeier
* All rights reserved.
@@ -22,3 +22,4 @@ erand48(unsigned short xseed[3])
ldexp((double) xseed[1], -32) +
ldexp((double) xseed[2], -16);
}
+DEF_WEAK(erand48);
diff --git a/lib/libc/stdlib/exit.c b/lib/libc/stdlib/exit.c
index 83fe3d2de56..d30b91ed46a 100644
--- a/lib/libc/stdlib/exit.c
+++ b/lib/libc/stdlib/exit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: exit.c,v 1.12 2007/09/03 14:40:16 millert Exp $ */
+/* $OpenBSD: exit.c,v 1.13 2015/09/13 08:31:47 guenther Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
@@ -57,3 +57,4 @@ exit(int status)
__cxa_finalize(NULL);
_exit(status);
}
+DEF_STRONG(exit);
diff --git a/lib/libc/stdlib/getenv.c b/lib/libc/stdlib/getenv.c
index fd8482e9e3c..6ddad9225a3 100644
--- a/lib/libc/stdlib/getenv.c
+++ b/lib/libc/stdlib/getenv.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getenv.c,v 1.10 2010/08/23 22:31:50 millert Exp $ */
+/* $OpenBSD: getenv.c,v 1.11 2015/09/13 08:31:47 guenther Exp $ */
/*
* Copyright (c) 1987, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +31,6 @@
#include <stdlib.h>
#include <string.h>
-char *__findenv(const char *name, int len, int *offset);
/*
* __findenv --
@@ -79,3 +78,4 @@ getenv(const char *name)
;
return (__findenv(name, (int)(np - name), &offset));
}
+DEF_STRONG(getenv);
diff --git a/lib/libc/stdlib/lcong48.c b/lib/libc/stdlib/lcong48.c
index 5b297ddbfc1..f03083e3c87 100644
--- a/lib/libc/stdlib/lcong48.c
+++ b/lib/libc/stdlib/lcong48.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lcong48.c,v 1.5 2015/08/27 04:33:31 guenther Exp $ */
+/* $OpenBSD: lcong48.c,v 1.6 2015/09/13 08:31:47 guenther Exp $ */
/*
* Copyright (c) 1993 Martin Birgmeier
* All rights reserved.
@@ -33,3 +33,4 @@ lcong48_deterministic(unsigned short p[7])
__rand48_mult[2] = p[5];
__rand48_add = p[6];
}
+DEF_WEAK(lcong48_deterministic);
diff --git a/lib/libc/stdlib/malloc.c b/lib/libc/stdlib/malloc.c
index 5e5dafbd179..0967fe3a088 100644
--- a/lib/libc/stdlib/malloc.c
+++ b/lib/libc/stdlib/malloc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: malloc.c,v 1.174 2015/04/06 09:18:51 tedu Exp $ */
+/* $OpenBSD: malloc.c,v 1.175 2015/09/13 08:31:47 guenther Exp $ */
/*
* Copyright (c) 2008, 2010, 2011 Otto Moerbeek <otto@drijf.net>
* Copyright (c) 2012 Matthew Dempsky <matthew@openbsd.org>
@@ -211,6 +211,7 @@ extern char *__progname;
#ifdef MALLOC_STATS
void malloc_dump(int);
+PROTO_NORMAL(malloc_dump);
static void malloc_exit(void);
#define CALLER __builtin_return_address(0)
#else
@@ -1186,6 +1187,7 @@ malloc(size_t size)
errno = saved_errno;
return r;
}
+DEF_STRONG(malloc);
static void
ofree(void *p)
@@ -1289,6 +1291,7 @@ free(void *ptr)
_MALLOC_UNLOCK();
errno = saved_errno;
}
+DEF_STRONG(free);
static void *
@@ -1429,6 +1432,7 @@ realloc(void *ptr, size_t size)
errno = saved_errno;
return r;
}
+DEF_STRONG(realloc);
/*
@@ -1476,6 +1480,7 @@ calloc(size_t nmemb, size_t size)
errno = saved_errno;
return r;
}
+DEF_STRONG(calloc);
static void *
mapalign(struct dir_info *d, size_t alignment, size_t sz, int zero_fill)
@@ -1609,6 +1614,7 @@ err:
errno = saved_errno;
return res;
}
+DEF_STRONG(posix_memalign);
#ifdef MALLOC_STATS
@@ -1853,6 +1859,7 @@ malloc_dump(int fd)
malloc_dump1(fd, pool);
errno = saved_errno;
}
+DEF_WEAK(malloc_dump);
static void
malloc_exit(void)
diff --git a/lib/libc/stdlib/qsort.c b/lib/libc/stdlib/qsort.c
index 2a51c776349..1d9b1e91221 100644
--- a/lib/libc/stdlib/qsort.c
+++ b/lib/libc/stdlib/qsort.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: qsort.c,v 1.12 2014/06/12 14:54:25 millert Exp $ */
+/* $OpenBSD: qsort.c,v 1.13 2015/09/13 08:31:47 guenther Exp $ */
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
@@ -149,3 +149,4 @@ loop: SWAPINIT(a, es);
}
/* qsort(pn - r, r / es, es, cmp);*/
}
+DEF_STRONG(qsort);
diff --git a/lib/libc/stdlib/rand.c b/lib/libc/stdlib/rand.c
index f163581e8d7..7054b81c647 100644
--- a/lib/libc/stdlib/rand.c
+++ b/lib/libc/stdlib/rand.c
@@ -39,6 +39,7 @@ rand_r(u_int *seed)
*seed = *seed * 1103515245 + 12345;
return (*seed % ((u_int)RAND_MAX + 1));
}
+DEF_WEAK(rand_r);
#if defined(APIWARN)
__warn_references(rand_r,
diff --git a/lib/libc/stdlib/reallocarray.c b/lib/libc/stdlib/reallocarray.c
index ed3244e22f7..baea252a874 100644
--- a/lib/libc/stdlib/reallocarray.c
+++ b/lib/libc/stdlib/reallocarray.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: reallocarray.c,v 1.2 2014/12/08 03:45:00 bcook Exp $ */
+/* $OpenBSD: reallocarray.c,v 1.3 2015/09/13 08:31:47 guenther Exp $ */
/*
* Copyright (c) 2008 Otto Moerbeek <otto@drijf.net>
*
@@ -36,3 +36,4 @@ reallocarray(void *optr, size_t nmemb, size_t size)
}
return realloc(optr, size * nmemb);
}
+DEF_WEAK(reallocarray);
diff --git a/lib/libc/stdlib/setenv.c b/lib/libc/stdlib/setenv.c
index 10b55445f76..e55a1feb6f9 100644
--- a/lib/libc/stdlib/setenv.c
+++ b/lib/libc/stdlib/setenv.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: setenv.c,v 1.15 2014/10/08 05:33:31 deraadt Exp $ */
+/* $OpenBSD: setenv.c,v 1.16 2015/09/13 08:31:47 guenther Exp $ */
/*
* Copyright (c) 1987 Regents of the University of California.
* All rights reserved.
@@ -32,8 +32,6 @@
#include <stdlib.h>
#include <string.h>
-char *__findenv(const char *name, int len, int *offset);
-
extern char **environ;
static char **lastenv; /* last value of environ */
@@ -81,6 +79,7 @@ putenv(char *str)
environ[cnt + 1] = NULL;
return (0);
}
+DEF_WEAK(putenv);
/*
* setenv --
@@ -147,6 +146,7 @@ setenv(const char *name, const char *value, int rewrite)
;
return (0);
}
+DEF_WEAK(setenv);
/*
* unsetenv(name) --
@@ -178,3 +178,4 @@ unsetenv(const char *name)
}
return (0);
}
+DEF_WEAK(unsetenv);
diff --git a/lib/libc/stdlib/srand48.c b/lib/libc/stdlib/srand48.c
index ce4b45225dc..d41391d4452 100644
--- a/lib/libc/stdlib/srand48.c
+++ b/lib/libc/stdlib/srand48.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: srand48.c,v 1.5 2015/08/27 04:33:31 guenther Exp $ */
+/* $OpenBSD: srand48.c,v 1.6 2015/09/13 08:31:48 guenther Exp $ */
/*
* Copyright (c) 1993 Martin Birgmeier
* All rights reserved.
@@ -35,3 +35,4 @@ srand48_deterministic(long seed)
__rand48_mult[2] = RAND48_MULT_2;
__rand48_add = RAND48_ADD;
}
+DEF_WEAK(srand48_deterministic);
diff --git a/lib/libc/stdlib/strtol.c b/lib/libc/stdlib/strtol.c
index 86cec350864..49465e28ee8 100644
--- a/lib/libc/stdlib/strtol.c
+++ b/lib/libc/stdlib/strtol.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: strtol.c,v 1.10 2014/09/13 20:10:12 schwarze Exp $ */
+/* $OpenBSD: strtol.c,v 1.11 2015/09/13 08:31:48 guenther Exp $ */
/*
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
@@ -148,3 +148,4 @@ strtol(const char *nptr, char **endptr, int base)
*endptr = (char *) (any ? s - 1 : nptr);
return (acc);
}
+DEF_STRONG(strtol);
diff --git a/lib/libc/stdlib/strtoll.c b/lib/libc/stdlib/strtoll.c
index cf82c8e1a6f..0ba51da77e8 100644
--- a/lib/libc/stdlib/strtoll.c
+++ b/lib/libc/stdlib/strtoll.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: strtoll.c,v 1.8 2014/09/13 20:10:12 schwarze Exp $ */
+/* $OpenBSD: strtoll.c,v 1.9 2015/09/13 08:31:48 guenther Exp $ */
/*
* Copyright (c) 1992 The Regents of the University of California.
* All rights reserved.
@@ -151,5 +151,6 @@ strtoll(const char *nptr, char **endptr, int base)
*endptr = (char *) (any ? s - 1 : nptr);
return (acc);
}
+DEF_STRONG(strtoll);
-__strong_alias(strtoq, strtoll);
+__weak_alias(strtoq, strtoll);
diff --git a/lib/libc/stdlib/strtonum.c b/lib/libc/stdlib/strtonum.c
index 1aeee3467b8..ad22d1c30c5 100644
--- a/lib/libc/stdlib/strtonum.c
+++ b/lib/libc/stdlib/strtonum.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: strtonum.c,v 1.7 2013/04/17 18:40:58 tedu Exp $ */
+/* $OpenBSD: strtonum.c,v 1.8 2015/09/13 08:31:48 guenther Exp $ */
/*
* Copyright (c) 2004 Ted Unangst and Todd Miller
@@ -63,3 +63,4 @@ strtonum(const char *numstr, long long minval, long long maxval,
return (ll);
}
+DEF_WEAK(strtonum);
diff --git a/lib/libc/stdlib/strtoul.c b/lib/libc/stdlib/strtoul.c
index 2aa41b76e4a..98e8abcbdba 100644
--- a/lib/libc/stdlib/strtoul.c
+++ b/lib/libc/stdlib/strtoul.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: strtoul.c,v 1.9 2014/09/13 20:10:12 schwarze Exp $ */
+/* $OpenBSD: strtoul.c,v 1.10 2015/09/13 08:31:48 guenther Exp $ */
/*
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
@@ -107,3 +107,4 @@ strtoul(const char *nptr, char **endptr, int base)
*endptr = (char *) (any ? s - 1 : nptr);
return (acc);
}
+DEF_STRONG(strtoul);
diff --git a/lib/libc/stdlib/strtoull.c b/lib/libc/stdlib/strtoull.c
index 846417630f9..a5d07de6cff 100644
--- a/lib/libc/stdlib/strtoull.c
+++ b/lib/libc/stdlib/strtoull.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: strtoull.c,v 1.7 2014/09/13 20:10:12 schwarze Exp $ */
+/* $OpenBSD: strtoull.c,v 1.8 2015/09/13 08:31:48 guenther Exp $ */
/*
* Copyright (c) 1992 The Regents of the University of California.
* All rights reserved.
@@ -109,5 +109,6 @@ strtoull(const char *nptr, char **endptr, int base)
*endptr = (char *) (any ? s - 1 : nptr);
return (acc);
}
+DEF_STRONG(strtoull);
-__strong_alias(strtouq, strtoull);
+__weak_alias(strtouq, strtoull);
diff --git a/lib/libc/stdlib/system.c b/lib/libc/stdlib/system.c
index 14ddcae8d3e..2a50ec74900 100644
--- a/lib/libc/stdlib/system.c
+++ b/lib/libc/stdlib/system.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: system.c,v 1.8 2005/08/08 08:05:37 espie Exp $ */
+/* $OpenBSD: system.c,v 1.9 2015/09/13 08:31:48 guenther Exp $ */
/*
* Copyright (c) 1988 The Regents of the University of California.
* All rights reserved.
@@ -72,3 +72,4 @@ system(const char *command)
(void)signal(SIGQUIT, quitsave);
return (pid == -1 ? -1 : pstat);
}
+DEF_STRONG(system);