From d11ec6f0d9fae7524090b3e5ea52e031e617f90f Mon Sep 17 00:00:00 2001 From: Zack Weinberg Date: Mon, 29 May 2000 19:33:52 +0000 Subject: [PATCH] hashtab.c, [...]: Include string.h if HAVE_STRING_H. * hashtab.c, partition.c, sort.c, xmemdup.c: Include string.h if HAVE_STRING_H. * pexecute.c, xexit.c: Include stdlib.h if HAVE_STDLIB_H. * objalloc.c: Include config.h. Include stdlib.h and don't declare malloc or free if HAVE_STDLIB_H. * strerror.c, strsignal.c: Include stdlib.h if HAVE_STDLIB_H, else declare malloc without prototype. Include string.h if HAVE_STRING_H, else declare memset without prototype. Don't include stddef.h. From-SVN: r34254 --- libiberty/ChangeLog | 12 ++++++++++++ libiberty/hashtab.c | 4 ++++ libiberty/objalloc.c | 7 +++++++ libiberty/partition.c | 4 ++++ libiberty/pexecute.c | 3 +++ libiberty/sort.c | 3 +++ libiberty/strerror.c | 19 +++++++++++-------- libiberty/strsignal.c | 19 +++++++++++-------- libiberty/xexit.c | 3 +++ libiberty/xmemdup.c | 3 +++ 10 files changed, 61 insertions(+), 16 deletions(-) diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index e61cec3f3339..adeb3c26ec2f 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,3 +1,15 @@ +2000-05-29 Zack Weinberg + + * hashtab.c, partition.c, sort.c, xmemdup.c: Include string.h + if HAVE_STRING_H. + * pexecute.c, xexit.c: Include stdlib.h if HAVE_STDLIB_H. + * objalloc.c: Include config.h. Include stdlib.h and don't + declare malloc or free if HAVE_STDLIB_H. + * strerror.c, strsignal.c: Include stdlib.h if HAVE_STDLIB_H, + else declare malloc without prototype. Include string.h if + HAVE_STRING_H, else declare memset without prototype. Don't + include stddef.h. + 2000-05-23 Mike Stump * Makefile.in (xmalloc.o): Add dependency for config.h, fixes make diff --git a/libiberty/hashtab.c b/libiberty/hashtab.c index f3ee301fd550..57b40417c959 100644 --- a/libiberty/hashtab.c +++ b/libiberty/hashtab.c @@ -41,6 +41,10 @@ Boston, MA 02111-1307, USA. */ #include #endif +#ifdef HAVE_STRING_H +#include +#endif + #include #include "libiberty.h" diff --git a/libiberty/objalloc.c b/libiberty/objalloc.c index 57754a861052..50995691e330 100644 --- a/libiberty/objalloc.c +++ b/libiberty/objalloc.c @@ -18,6 +18,8 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "ansidecl.h" +#include "config.h" + #include "objalloc.h" /* Get a definition for NULL. */ @@ -33,11 +35,16 @@ Boston, MA 02111-1307, USA. */ #include #endif +#ifdef HAVE_STDLIB_H +#include +#else /* For systems with larger pointers than ints, this must be declared. */ extern PTR malloc PARAMS ((size_t)); extern void free PARAMS ((PTR)); #endif +#endif + /* These routines allocate space for an object. Freeing allocated space may or may not free all more recently allocated space. diff --git a/libiberty/partition.c b/libiberty/partition.c index c1d584774bfa..52fb128d7bfe 100644 --- a/libiberty/partition.c +++ b/libiberty/partition.c @@ -27,6 +27,10 @@ #include #endif +#ifdef HAVE_STRING_H +#include +#endif + #include "libiberty.h" #include "partition.h" diff --git a/libiberty/pexecute.c b/libiberty/pexecute.c index 56ddec78dd83..f1aea9db7f0e 100644 --- a/libiberty/pexecute.c +++ b/libiberty/pexecute.c @@ -35,6 +35,9 @@ Boston, MA 02111-1307, USA. */ #ifdef HAVE_UNISTD_H #include #endif +#ifdef HAVE_STDLIB_H +#include +#endif #define ISSPACE (x) isspace(x) #ifdef HAVE_SYS_WAIT_H #include diff --git a/libiberty/sort.c b/libiberty/sort.c index b66a9e1e8567..da2d660b6f5d 100644 --- a/libiberty/sort.c +++ b/libiberty/sort.c @@ -28,6 +28,9 @@ Boston, MA 02111-1307, USA. */ #ifdef HAVE_STDLIB_H #include #endif +#ifdef HAVE_STRING_H +#include +#endif #ifndef UCHAR_MAX #define UCHAR_MAX ((unsigned char)(-1)) diff --git a/libiberty/strerror.c b/libiberty/strerror.c index 644cc75462ae..0dd2220cd73d 100644 --- a/libiberty/strerror.c +++ b/libiberty/strerror.c @@ -25,14 +25,17 @@ /* Routines imported from standard C runtime libraries. */ -#ifdef __STDC__ -#include -extern void *malloc (size_t size); /* 4.10.3.3 */ -extern void *memset (void *s, int c, size_t n); /* 4.11.6.1 */ -#else /* !__STDC__ */ -extern char *malloc (); /* Standard memory allocater */ -extern char *memset (); -#endif /* __STDC__ */ +#ifdef HAVE_STDLIB_H +#include +#else +extern PTR malloc (); +#endif + +#ifdef HAVE_STRING_H +#include +#else +extern PTR memset (); +#endif #ifndef MAX # define MAX(a,b) ((a) > (b) ? (a) : (b)) diff --git a/libiberty/strsignal.c b/libiberty/strsignal.c index c7bb10c441c4..5625323b71b3 100644 --- a/libiberty/strsignal.c +++ b/libiberty/strsignal.c @@ -23,14 +23,17 @@ /* Routines imported from standard C runtime libraries. */ -#ifdef __STDC__ -#include -extern void *malloc (size_t size); /* 4.10.3.3 */ -extern void *memset (void *s, int c, size_t n); /* 4.11.6.1 */ -#else /* !__STDC__ */ -extern char *malloc (); /* Standard memory allocater */ -extern char *memset (); -#endif /* __STDC__ */ +#ifdef HAVE_STDLIB_H +#include +#else +extern PTR malloc (); +#endif + +#ifdef HAVE_STRING_H +#include +#else +extern PTR memset (); +#endif /* Undefine the macro we used to hide the definition of sys_siglist found in the system header files. */ diff --git a/libiberty/xexit.c b/libiberty/xexit.c index 431bbe02991a..7aa52ac7599c 100644 --- a/libiberty/xexit.c +++ b/libiberty/xexit.c @@ -21,6 +21,9 @@ Boston, MA 02111-1307, USA. */ #include "libiberty.h" #include +#ifdef HAVE_STDLIB_H +#include +#endif /* This variable is set by xatexit if it is called. This way, xmalloc doesn't drag xatexit into the link. */ diff --git a/libiberty/xmemdup.c b/libiberty/xmemdup.c index f780041aa133..fdb17a547f3a 100644 --- a/libiberty/xmemdup.c +++ b/libiberty/xmemdup.c @@ -9,6 +9,9 @@ #include "libiberty.h" #include /* For size_t. */ +#ifdef HAVE_STRING_H +#include +#endif PTR xmemdup (input, copy_size, alloc_size) -- 2.39.2