Browse Source

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.
OPENBSD_5_9
guenther 8 years ago
parent
commit
c8272cfe98
22 changed files with 54 additions and 26 deletions
  1. +3
    -1
      src/lib/libc/crypt/arc4random.c
  2. +2
    -1
      src/lib/libc/crypt/arc4random_uniform.c
  3. +2
    -1
      src/lib/libc/stdlib/abort.c
  4. +2
    -1
      src/lib/libc/stdlib/abs.c
  5. +2
    -1
      src/lib/libc/stdlib/atoi.c
  6. +2
    -1
      src/lib/libc/stdlib/div.c
  7. +2
    -1
      src/lib/libc/stdlib/erand48.c
  8. +2
    -1
      src/lib/libc/stdlib/exit.c
  9. +2
    -2
      src/lib/libc/stdlib/getenv.c
  10. +2
    -1
      src/lib/libc/stdlib/lcong48.c
  11. +8
    -1
      src/lib/libc/stdlib/malloc.c
  12. +2
    -1
      src/lib/libc/stdlib/qsort.c
  13. +1
    -0
      src/lib/libc/stdlib/rand.c
  14. +2
    -1
      src/lib/libc/stdlib/reallocarray.c
  15. +4
    -3
      src/lib/libc/stdlib/setenv.c
  16. +2
    -1
      src/lib/libc/stdlib/srand48.c
  17. +2
    -1
      src/lib/libc/stdlib/strtol.c
  18. +3
    -2
      src/lib/libc/stdlib/strtoll.c
  19. +2
    -1
      src/lib/libc/stdlib/strtonum.c
  20. +2
    -1
      src/lib/libc/stdlib/strtoul.c
  21. +3
    -2
      src/lib/libc/stdlib/strtoull.c
  22. +2
    -1
      src/lib/libc/stdlib/system.c

+ 3
- 1
src/lib/libc/crypt/arc4random.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: arc4random.c,v 1.53 2015/09/10 18:53:50 bcook Exp $ */
/* $OpenBSD: arc4random.c,v 1.54 2015/09/13 08:31:47 guenther Exp $ */
/*
* Copyright (c) 1996, David Mazieres <dm@uun.org>
@ -186,6 +186,7 @@ arc4random(void)
_ARC4_UNLOCK();
return val;
}
DEF_WEAK(arc4random);
void
arc4random_buf(void *buf, size_t n)
@ -194,3 +195,4 @@ arc4random_buf(void *buf, size_t n)
_rs_random_buf(buf, n);
_ARC4_UNLOCK();
}
DEF_WEAK(arc4random_buf);

+ 2
- 1
src/lib/libc/crypt/arc4random_uniform.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: arc4random_uniform.c,v 1.1 2014/07/12 13:24:54 deraadt Exp $ */
/* $OpenBSD: arc4random_uniform.c,v 1.2 2015/09/13 08:31:47 guenther Exp $ */
/*
* Copyright (c) 2008, Damien Miller <djm@openbsd.org>
@ -54,3 +54,4 @@ arc4random_uniform(uint32_t upper_bound)
return r % upper_bound;
}
DEF_WEAK(arc4random_uniform);

+ 2
- 1
src/lib/libc/stdlib/abort.c View File

@ -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);

+ 2
- 1
src/lib/libc/stdlib/abs.c View File

@ -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);

+ 2
- 1
src/lib/libc/stdlib/atoi.c View File

@ -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);

+ 2
- 1
src/lib/libc/stdlib/div.c View File

@ -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);

+ 2
- 1
src/lib/libc/stdlib/erand48.c View File

@ -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);

+ 2
- 1
src/lib/libc/stdlib/exit.c View File

@ -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);

+ 2
- 2
src/lib/libc/stdlib/getenv.c View File

@ -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);

+ 2
- 1
src/lib/libc/stdlib/lcong48.c View File

@ -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);

+ 8
- 1
src/lib/libc/stdlib/malloc.c View File

@ -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)


+ 2
- 1
src/lib/libc/stdlib/qsort.c View File

@ -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);

+ 1
- 0
src/lib/libc/stdlib/rand.c View File

@ -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,


+ 2
- 1
src/lib/libc/stdlib/reallocarray.c View File

@ -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);

+ 4
- 3
src/lib/libc/stdlib/setenv.c View File

@ -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);

+ 2
- 1
src/lib/libc/stdlib/srand48.c View File

@ -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);

+ 2
- 1
src/lib/libc/stdlib/strtol.c View File

@ -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);

+ 3
- 2
src/lib/libc/stdlib/strtoll.c View File

@ -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);

+ 2
- 1
src/lib/libc/stdlib/strtonum.c View File

@ -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);

+ 2
- 1
src/lib/libc/stdlib/strtoul.c View File

@ -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);

+ 3
- 2
src/lib/libc/stdlib/strtoull.c View File

@ -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);

+ 2
- 1
src/lib/libc/stdlib/system.c View File

@ -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);

Loading…
Cancel
Save