diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index 34ebae2b526..00bf5d61e7e 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,3 +1,10 @@ +Thu Apr 15 23:00:55 1999 Mumit Khan + + * configure.in (checkfuncs): Check for sbrk. + * config.in: Rebuilt. + * configure: Likewise. + * xmalloc.c: Use HAVE_SBRK instead of the host specific definitions. + 1999-04-12 Jim Blandy Fix from Marcus Daniels: diff --git a/libiberty/config.in b/libiberty/config.in index ba72d865eaf..520729f894e 100644 --- a/libiberty/config.in +++ b/libiberty/config.in @@ -106,6 +106,9 @@ /* Define if you have the memset function. */ #undef HAVE_MEMSET +/* Define if you have the mkstemps function. */ +#undef HAVE_MKSTEMPS + /* Define if you have the on_exit function. */ #undef HAVE_ON_EXIT @@ -121,6 +124,9 @@ /* Define if you have the rindex function. */ #undef HAVE_RINDEX +/* Define if you have the sbrk function. */ +#undef HAVE_SBRK + /* Define if you have the sigsetmask function. */ #undef HAVE_SIGSETMASK diff --git a/libiberty/configure b/libiberty/configure index f7ba4b21902..f086a975174 100755 --- a/libiberty/configure +++ b/libiberty/configure @@ -1183,7 +1183,7 @@ funcs="$funcs waitpid" vars="sys_errlist sys_nerr sys_siglist" -checkfuncs="getrusage on_exit psignal strerror strsignal sysconf times" +checkfuncs="getrusage on_exit psignal strerror strsignal sysconf times sbrk" # These are neither executed nor required, but they help keep # autoheader happy without adding a bunch of text to acconfig.h. @@ -1525,6 +1525,61 @@ if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then #define $ac_tr_func 1 EOF +else + echo "$ac_t""no" 1>&6 +fi +done + + for ac_func in sbrk +do +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:1537: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:1565: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <&6 fi @@ -1677,7 +1732,7 @@ EOF # We haven't set the list of objects yet. Use the standard autoconf # tests. This will only work if the compiler works. echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:1681: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 +echo "configure:1736: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. @@ -1688,12 +1743,12 @@ cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext << EOF -#line 1692 "configure" +#line 1747 "configure" #include "confdefs.h" main(){return(0);} EOF -if { (eval echo configure:1697: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1752: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cc_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then @@ -1719,19 +1774,19 @@ if test $ac_cv_prog_cc_works = no; then { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:1723: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:1778: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 cross_compiling=$ac_cv_prog_cc_cross for ac_func in $funcs do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:1730: checking for $ac_func" >&5 +echo "configure:1785: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1813: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -1783,19 +1838,19 @@ done # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works # for constant arguments. Useless! echo $ac_n "checking for working alloca.h""... $ac_c" 1>&6 -echo "configure:1787: checking for working alloca.h" >&5 +echo "configure:1842: checking for working alloca.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_alloca_h'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { char *p = alloca(2 * sizeof(int)); ; return 0; } EOF -if { (eval echo configure:1799: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1854: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_header_alloca_h=yes else @@ -1816,12 +1871,12 @@ EOF fi echo $ac_n "checking for alloca""... $ac_c" 1>&6 -echo "configure:1820: checking for alloca" >&5 +echo "configure:1875: checking for alloca" >&5 if eval "test \"`echo '$''{'ac_cv_func_alloca_works'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1908: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_func_alloca_works=yes else @@ -1881,12 +1936,12 @@ EOF echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6 -echo "configure:1885: checking whether alloca needs Cray hooks" >&5 +echo "configure:1940: checking whether alloca needs Cray hooks" >&5 if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&6 if test $ac_cv_os_cray = yes; then for ac_func in _getb67 GETB67 getb67; do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:1915: checking for $ac_func" >&5 +echo "configure:1970: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1998: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -1966,7 +2021,7 @@ done fi echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6 -echo "configure:1970: checking stack direction for C alloca" >&5 +echo "configure:2025: checking stack direction for C alloca" >&5 if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1974,7 +2029,7 @@ else ac_cv_c_stack_direction=0 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:2052: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_c_stack_direction=1 else @@ -2015,12 +2070,12 @@ EOF fi echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 -echo "configure:2019: checking for ANSI C header files" >&5 +echo "configure:2074: checking for ANSI C header files" >&5 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -2028,7 +2083,7 @@ else #include EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2032: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2087: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2045,7 +2100,7 @@ rm -f conftest* if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -2063,7 +2118,7 @@ fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -2084,7 +2139,7 @@ if test "$cross_compiling" = yes; then : else cat > conftest.$ac_ext < #define ISLOWER(c) ('a' <= (c) && (c) <= 'z') @@ -2095,7 +2150,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); exit (0); } EOF -if { (eval echo configure:2099: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:2154: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else @@ -2119,12 +2174,12 @@ EOF fi echo $ac_n "checking for pid_t""... $ac_c" 1>&6 -echo "configure:2123: checking for pid_t" >&5 +echo "configure:2178: checking for pid_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_pid_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -2153,17 +2208,17 @@ fi ac_safe=`echo "vfork.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for vfork.h""... $ac_c" 1>&6 -echo "configure:2157: checking for vfork.h" >&5 +echo "configure:2212: checking for vfork.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2167: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2222: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2188,18 +2243,18 @@ else fi echo $ac_n "checking for working vfork""... $ac_c" 1>&6 -echo "configure:2192: checking for working vfork" >&5 +echo "configure:2247: checking for working vfork" >&5 if eval "test \"`echo '$''{'ac_cv_func_vfork_works'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test "$cross_compiling" = yes; then echo $ac_n "checking for vfork""... $ac_c" 1>&6 -echo "configure:2198: checking for vfork" >&5 +echo "configure:2253: checking for vfork" >&5 if eval "test \"`echo '$''{'ac_cv_func_vfork'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2281: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_vfork=yes" else @@ -2244,7 +2299,7 @@ fi ac_cv_func_vfork_works=$ac_cv_func_vfork else cat > conftest.$ac_ext < @@ -2339,7 +2394,7 @@ main() { } } EOF -if { (eval echo configure:2343: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:2398: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_func_vfork_works=yes else @@ -2366,19 +2421,19 @@ fi fi for v in $vars; do echo $ac_n "checking for $v""... $ac_c" 1>&6 -echo "configure:2370: checking for $v" >&5 +echo "configure:2425: checking for $v" >&5 if eval "test \"`echo '$''{'libiberty_cv_var_$v'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2437: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "libiberty_cv_var_$v=yes" else @@ -2404,12 +2459,12 @@ EOF for ac_func in $checkfuncs do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:2408: checking for $ac_func" >&5 +echo "configure:2463: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2491: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else diff --git a/libiberty/configure.in b/libiberty/configure.in index 9a496720050..da33ca9487b 100644 --- a/libiberty/configure.in +++ b/libiberty/configure.in @@ -154,7 +154,7 @@ funcs="$funcs waitpid" vars="sys_errlist sys_nerr sys_siglist" -checkfuncs="getrusage on_exit psignal strerror strsignal sysconf times" +checkfuncs="getrusage on_exit psignal strerror strsignal sysconf times sbrk" # These are neither executed nor required, but they help keep # autoheader happy without adding a bunch of text to acconfig.h. @@ -168,6 +168,7 @@ if test "x" = "y"; then AC_DEFINE(HAVE_SYS_NERR) AC_DEFINE(HAVE_SYS_SIGLIST) AC_CHECK_FUNCS(getrusage on_exit psignal strerror strsignal sysconf times) + AC_CHECK_FUNCS(sbrk) fi # For each of these functions, if the host does not provide the diff --git a/libiberty/xmalloc.c b/libiberty/xmalloc.c index 1bc15c99cd6..be25c5aca19 100644 --- a/libiberty/xmalloc.c +++ b/libiberty/xmalloc.c @@ -43,22 +43,22 @@ PTR sbrk PARAMS ((ptrdiff_t)); /* The program name if set. */ static const char *name = ""; -#if ! defined (_WIN32) || defined (__CYGWIN__) || defined (_UWIN) +#ifdef HAVE_SBRK /* The initial sbrk, set when the program name is set. Not used for win32 ports other than cygwin32. */ static char *first_break = NULL; -#endif /* ! _WIN32 || __CYGWIN__ || _UWIN */ +#endif /* HAVE_SBRK */ void xmalloc_set_program_name (s) const char *s; { name = s; -#if ! defined (_WIN32) || defined (__CYGWIN__) || defined (_UWIN) +#ifdef HAVE_SBRK /* Win32 ports other than cygwin32 don't have brk() */ if (first_break == NULL) first_break = (char *) sbrk (0); -#endif /* ! _WIN32 || __CYGWIN__ || _UWIN */ +#endif /* HAVE_SBRK */ } PTR @@ -72,7 +72,7 @@ xmalloc (size) newmem = malloc (size); if (!newmem) { -#if ! defined (_WIN32) || defined (__CYGWIN__) || defined (_UWIN) +#ifdef HAVE_SBRK extern char **environ; size_t allocated; @@ -84,12 +84,12 @@ xmalloc (size) "\n%s%sCan not allocate %lu bytes after allocating %lu bytes\n", name, *name ? ": " : "", (unsigned long) size, (unsigned long) allocated); -#else +#else /* HAVE_SBRK */ fprintf (stderr, "\n%s%sCan not allocate %lu bytes\n", name, *name ? ": " : "", (unsigned long) size); -#endif /* ! _WIN32 || __CYGWIN__ || _UWIN */ +#endif /* HAVE_SBRK */ xexit (1); } return (newmem); @@ -107,7 +107,7 @@ xcalloc (nelem, elsize) newmem = calloc (nelem, elsize); if (!newmem) { -#if ! defined (_WIN32) || defined (__CYGWIN__) || defined (_UWIN) +#ifdef HAVE_SBRK extern char **environ; size_t allocated; @@ -119,12 +119,12 @@ xcalloc (nelem, elsize) "\n%s%sCan not allocate %lu bytes after allocating %lu bytes\n", name, *name ? ": " : "", (unsigned long) (nelem * elsize), (unsigned long) allocated); -#else +#else /* HAVE_SBRK */ fprintf (stderr, "\n%s%sCan not allocate %lu bytes\n", name, *name ? ": " : "", (unsigned long) (nelem * elsize)); -#endif /* ! _WIN32 || __CYGWIN__ || _UWIN */ +#endif /* HAVE_SBRK */ xexit (1); } return (newmem); @@ -145,7 +145,7 @@ xrealloc (oldmem, size) newmem = realloc (oldmem, size); if (!newmem) { -#if ! defined (_WIN32) || defined (__CYGWIN__) || defined (_UWIN) +#ifdef HAVE_SBRK extern char **environ; size_t allocated; @@ -157,12 +157,12 @@ xrealloc (oldmem, size) "\n%s%sCan not reallocate %lu bytes after allocating %lu bytes\n", name, *name ? ": " : "", (unsigned long) size, (unsigned long) allocated); -#else /* ! _WIN32 || __CYGWIN__ || _UWIN */ +#else /* HAVE_SBRK */ fprintf (stderr, "\n%s%sCan not reallocate %lu bytes\n", name, *name ? ": " : "", (unsigned long) size); -#endif /* ! _WIN32 || __CYGWIN__ || _UWIN */ +#endif /* HAVE_SBRK */ xexit (1); } return (newmem);