aboutsummaryrefslogtreecommitdiff
path: root/libiberty
diff options
context:
space:
mode:
authorKaveh R. Ghazi <ghazi@caip.rutgers.edu>1998-11-13 16:36:04 +0000
committerKaveh Ghazi <ghazi@gcc.gnu.org>1998-11-13 16:36:04 +0000
commita9acf74156d05a933295cba9b800c2c6759296f5 (patch)
tree3ba8d1fed8bcc7504da2c11d5b6e63f2bdf140e3 /libiberty
parent67d0f6ab5e3c6fba25e59702f09f44694a0c968b (diff)
downloadgcc-a9acf74156d05a933295cba9b800c2c6759296f5.zip
gcc-a9acf74156d05a933295cba9b800c2c6759296f5.tar.gz
gcc-a9acf74156d05a933295cba9b800c2c6759296f5.tar.bz2
configure.in: Check for calloc.
* configure.in: Check for calloc. * calloc.c: New file. * xmalloc.c (xcalloc): New function. From-SVN: r23642
Diffstat (limited to 'libiberty')
-rw-r--r--libiberty/ChangeLog8
-rw-r--r--libiberty/calloc.c26
-rwxr-xr-xlibiberty/configure129
-rw-r--r--libiberty/configure.in3
-rw-r--r--libiberty/xmalloc.c36
5 files changed, 137 insertions, 65 deletions
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog
index d4a9015..d2aaa31 100644
--- a/libiberty/ChangeLog
+++ b/libiberty/ChangeLog
@@ -1,3 +1,11 @@
+Fri Nov 13 19:18:05 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * configure.in: Check for calloc.
+
+ * calloc.c: New file.
+
+ * xmalloc.c (xcalloc): New function.
+
Fri Nov 13 08:51:46 EST 1998 Andrew MacLeod <amacleod@cygnus.com>
*cplus-dem.c (demangle_prefix): Use the last "__"
diff --git a/libiberty/calloc.c b/libiberty/calloc.c
new file mode 100644
index 0000000..c8c0a78
--- /dev/null
+++ b/libiberty/calloc.c
@@ -0,0 +1,26 @@
+#include "ansidecl.h"
+#include "libiberty.h"
+
+#ifdef ANSI_PROTOTYPES
+#include <stddef.h>
+#else
+#define size_t unsigned long
+#endif
+
+/* For systems with larger pointers than ints, this must be declared. */
+PTR malloc PARAMS ((size_t));
+
+PTR
+calloc (nelem, elsize)
+ size_t nelem, elsize;
+{
+ register PTR ptr;
+
+ if (nelem == 0 || elsize == 0)
+ nelem = elsize = 1;
+
+ ptr = malloc (nelem * elsize);
+ if (ptr) bzero (ptr, nelem * elsize);
+
+ return ptr;
+}
diff --git a/libiberty/configure b/libiberty/configure
index cf36e1e..b52584e 100755
--- a/libiberty/configure
+++ b/libiberty/configure
@@ -1077,6 +1077,7 @@ funcs="$funcs basename"
funcs="$funcs bcmp"
funcs="$funcs bcopy"
funcs="$funcs bzero"
+funcs="$funcs calloc"
funcs="$funcs clock"
funcs="$funcs getcwd"
funcs="$funcs getpagesize"
@@ -1116,15 +1117,15 @@ checkfuncs="getrusage on_exit psignal strerror strsignal sysconf times"
# These are neither executed nor required, but they help keep
# autoheader happy without adding a bunch of text to acconfig.h.
if test "x" = "y"; then
- for ac_func in asprintf atexit basename bcmp bcopy bzero clock getcwd
+ for ac_func in asprintf atexit basename bcmp bcopy bzero calloc clock getcwd
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1123: checking for $ac_func" >&5
+echo "configure:1124: 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 <<EOF
-#line 1128 "configure"
+#line 1129 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -1147,7 +1148,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:1151: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1152: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -1174,12 +1175,12 @@ done
for ac_func in getpagesize index insque memchr memcmp memcpy memmove
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1178: checking for $ac_func" >&5
+echo "configure:1179: 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 <<EOF
-#line 1183 "configure"
+#line 1184 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -1202,7 +1203,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:1206: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1207: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -1229,12 +1230,12 @@ done
for ac_func in memset random rename rindex sigsetmask strcasecmp
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1233: checking for $ac_func" >&5
+echo "configure:1234: 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 <<EOF
-#line 1238 "configure"
+#line 1239 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -1257,7 +1258,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:1261: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1262: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -1284,12 +1285,12 @@ done
for ac_func in strchr strdup strncasecmp strrchr strstr strtod strtol
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1288: checking for $ac_func" >&5
+echo "configure:1289: 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 <<EOF
-#line 1293 "configure"
+#line 1294 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -1312,7 +1313,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:1316: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1317: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -1339,12 +1340,12 @@ done
for ac_func in strtoul tmpnam vasprintf vfprintf vprintf vsprintf waitpid
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1343: checking for $ac_func" >&5
+echo "configure:1344: 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 <<EOF
-#line 1348 "configure"
+#line 1349 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -1367,7 +1368,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:1371: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1372: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -1406,12 +1407,12 @@ EOF
for ac_func in getrusage on_exit psignal strerror strsignal sysconf times
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1410: checking for $ac_func" >&5
+echo "configure:1411: 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 <<EOF
-#line 1415 "configure"
+#line 1416 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -1434,7 +1435,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:1438: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1439: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -1589,7 +1590,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:1593: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:1594: 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.
@@ -1599,11 +1600,11 @@ ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS
cross_compiling=$ac_cv_prog_cc_cross
cat > conftest.$ac_ext <<EOF
-#line 1603 "configure"
+#line 1604 "configure"
#include "confdefs.h"
main(){return(0);}
EOF
-if { (eval echo configure:1607: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1608: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; 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
@@ -1623,19 +1624,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:1627: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:1628: 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:1634: checking for $ac_func" >&5
+echo "configure:1635: 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 <<EOF
-#line 1639 "configure"
+#line 1640 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -1658,7 +1659,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:1662: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1663: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -1687,19 +1688,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:1691: checking for working alloca.h" >&5
+echo "configure:1692: 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 <<EOF
-#line 1696 "configure"
+#line 1697 "configure"
#include "confdefs.h"
#include <alloca.h>
int main() {
char *p = alloca(2 * sizeof(int));
; return 0; }
EOF
-if { (eval echo configure:1703: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1704: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
ac_cv_header_alloca_h=yes
else
@@ -1720,12 +1721,12 @@ EOF
fi
echo $ac_n "checking for alloca""... $ac_c" 1>&6
-echo "configure:1724: checking for alloca" >&5
+echo "configure:1725: 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 <<EOF
-#line 1729 "configure"
+#line 1730 "configure"
#include "confdefs.h"
#ifdef __GNUC__
@@ -1748,7 +1749,7 @@ int main() {
char *p = (char *) alloca(1);
; return 0; }
EOF
-if { (eval echo configure:1752: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1753: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
ac_cv_func_alloca_works=yes
else
@@ -1780,12 +1781,12 @@ EOF
echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6
-echo "configure:1784: checking whether alloca needs Cray hooks" >&5
+echo "configure:1785: 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 <<EOF
-#line 1789 "configure"
+#line 1790 "configure"
#include "confdefs.h"
#if defined(CRAY) && ! defined(CRAY2)
webecray
@@ -1810,12 +1811,12 @@ echo "$ac_t""$ac_cv_os_cray" 1>&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:1814: checking for $ac_func" >&5
+echo "configure:1815: 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 <<EOF
-#line 1819 "configure"
+#line 1820 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -1838,7 +1839,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:1842: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1843: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -1865,7 +1866,7 @@ done
fi
echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6
-echo "configure:1869: checking stack direction for C alloca" >&5
+echo "configure:1870: 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
@@ -1873,7 +1874,7 @@ else
ac_cv_c_stack_direction=0
else
cat > conftest.$ac_ext <<EOF
-#line 1877 "configure"
+#line 1878 "configure"
#include "confdefs.h"
find_stack_direction ()
{
@@ -1892,7 +1893,7 @@ main ()
exit (find_stack_direction() < 0);
}
EOF
-if { (eval echo configure:1896: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1897: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
ac_cv_c_stack_direction=1
else
@@ -1914,12 +1915,12 @@ EOF
fi
echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:1918: checking for ANSI C header files" >&5
+echo "configure:1919: 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 <<EOF
-#line 1923 "configure"
+#line 1924 "configure"
#include "confdefs.h"
#include <stdlib.h>
#include <stdarg.h>
@@ -1927,7 +1928,7 @@ else
#include <float.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1931: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1932: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -1944,7 +1945,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
-#line 1948 "configure"
+#line 1949 "configure"
#include "confdefs.h"
#include <string.h>
EOF
@@ -1962,7 +1963,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
-#line 1966 "configure"
+#line 1967 "configure"
#include "confdefs.h"
#include <stdlib.h>
EOF
@@ -1983,7 +1984,7 @@ if test "$cross_compiling" = yes; then
:
else
cat > conftest.$ac_ext <<EOF
-#line 1987 "configure"
+#line 1988 "configure"
#include "confdefs.h"
#include <ctype.h>
#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -1994,7 +1995,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
exit (0); }
EOF
-if { (eval echo configure:1998: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1999: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
:
else
@@ -2018,12 +2019,12 @@ EOF
fi
echo $ac_n "checking for pid_t""... $ac_c" 1>&6
-echo "configure:2022: checking for pid_t" >&5
+echo "configure:2023: 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 <<EOF
-#line 2027 "configure"
+#line 2028 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
@@ -2052,17 +2053,17 @@ fi
ac_safe=`echo "vfork.h" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for vfork.h""... $ac_c" 1>&6
-echo "configure:2056: checking for vfork.h" >&5
+echo "configure:2057: 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
-#line 2061 "configure"
+#line 2062 "configure"
#include "confdefs.h"
#include <vfork.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2066: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2067: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -2087,18 +2088,18 @@ else
fi
echo $ac_n "checking for working vfork""... $ac_c" 1>&6
-echo "configure:2091: checking for working vfork" >&5
+echo "configure:2092: 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:2097: checking for vfork" >&5
+echo "configure:2098: 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 <<EOF
-#line 2102 "configure"
+#line 2103 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char vfork(); below. */
@@ -2121,7 +2122,7 @@ vfork();
; return 0; }
EOF
-if { (eval echo configure:2125: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2126: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_vfork=yes"
else
@@ -2143,7 +2144,7 @@ fi
ac_cv_func_vfork_works=$ac_cv_func_vfork
else
cat > conftest.$ac_ext <<EOF
-#line 2147 "configure"
+#line 2148 "configure"
#include "confdefs.h"
/* Thanks to Paul Eggert for this test. */
#include <stdio.h>
@@ -2238,7 +2239,7 @@ main() {
}
}
EOF
-if { (eval echo configure:2242: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2243: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
ac_cv_func_vfork_works=yes
else
@@ -2265,19 +2266,19 @@ fi
fi
for v in $vars; do
echo $ac_n "checking for $v""... $ac_c" 1>&6
-echo "configure:2269: checking for $v" >&5
+echo "configure:2270: 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 <<EOF
-#line 2274 "configure"
+#line 2275 "configure"
#include "confdefs.h"
int *p;
int main() {
extern int $v; p = &$v;
; return 0; }
EOF
-if { (eval echo configure:2281: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2282: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "libiberty_cv_var_$v=yes"
else
@@ -2303,12 +2304,12 @@ EOF
for ac_func in $checkfuncs
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2307: checking for $ac_func" >&5
+echo "configure:2308: 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 <<EOF
-#line 2312 "configure"
+#line 2313 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -2331,7 +2332,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:2335: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2336: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
diff --git a/libiberty/configure.in b/libiberty/configure.in
index ee82459..78bf960 100644
--- a/libiberty/configure.in
+++ b/libiberty/configure.in
@@ -117,6 +117,7 @@ funcs="$funcs basename"
funcs="$funcs bcmp"
funcs="$funcs bcopy"
funcs="$funcs bzero"
+funcs="$funcs calloc"
funcs="$funcs clock"
funcs="$funcs getcwd"
funcs="$funcs getpagesize"
@@ -156,7 +157,7 @@ checkfuncs="getrusage on_exit psignal strerror strsignal sysconf times"
# These are neither executed nor required, but they help keep
# autoheader happy without adding a bunch of text to acconfig.h.
if test "x" = "y"; then
- AC_CHECK_FUNCS(asprintf atexit basename bcmp bcopy bzero clock getcwd)
+ AC_CHECK_FUNCS(asprintf atexit basename bcmp bcopy bzero calloc clock getcwd)
AC_CHECK_FUNCS(getpagesize index insque memchr memcmp memcpy memmove)
AC_CHECK_FUNCS(memset random rename rindex sigsetmask strcasecmp)
AC_CHECK_FUNCS(strchr strdup strncasecmp strrchr strstr strtod strtol)
diff --git a/libiberty/xmalloc.c b/libiberty/xmalloc.c
index b88105a..4f39014 100644
--- a/libiberty/xmalloc.c
+++ b/libiberty/xmalloc.c
@@ -36,6 +36,7 @@ Boston, MA 02111-1307, USA. */
/* For systems with larger pointers than ints, these must be declared. */
PTR malloc PARAMS ((size_t));
PTR realloc PARAMS ((PTR, size_t));
+PTR calloc PARAMS ((size_t, size_t));
PTR sbrk PARAMS ((ptrdiff_t));
#endif
@@ -95,6 +96,41 @@ xmalloc (size)
}
PTR
+xcalloc (nelem, elsize)
+ size_t nelem, elsize;
+{
+ PTR newmem;
+
+ if (nelem == 0 || elsize == 0)
+ nelem = elsize = 1;
+
+ newmem = calloc (nelem, elsize);
+ if (!newmem)
+ {
+#if ! defined (_WIN32) || defined (__CYGWIN32__)
+ extern char **environ;
+ size_t allocated;
+
+ if (first_break != NULL)
+ allocated = (char *) sbrk (0) - first_break;
+ else
+ allocated = (char *) sbrk (0) - (char *) &environ;
+ fprintf (stderr,
+ "\n%s%sCan not allocate %lu bytes after allocating %lu bytes\n",
+ name, *name ? ": " : "",
+ (unsigned long) (nelem * elsize), (unsigned long) allocated);
+#else
+ fprintf (stderr,
+ "\n%s%sCan not allocate %lu bytes\n",
+ name, *name ? ": " : "",
+ (unsigned long) (nelem * elsize));
+#endif /* ! _WIN32 || __CYGWIN32 __ */
+ xexit (1);
+ }
+ return (newmem);
+}
+
+PTR
xrealloc (oldmem, size)
PTR oldmem;
size_t size;