From a1d4c778d77635386fcf96264a3d654b7d6beaf6 Mon Sep 17 00:00:00 2001 From: Alain Magloire Date: Sun, 4 Mar 2001 05:29:16 +0000 Subject: Much taking from fetish an gnu tar. --- m4/Makefile.am | 4 ++++ m4/error.m4 | 11 +++++++++ m4/malloc.m4 | 35 ++++++++++++++++++++++++++++ m4/realloc.m4 | 35 ++++++++++++++++++++++++++++ m4/strerror_r.m4 | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 154 insertions(+) create mode 100644 m4/error.m4 create mode 100644 m4/malloc.m4 create mode 100644 m4/realloc.m4 create mode 100644 m4/strerror_r.m4 (limited to 'm4') diff --git a/m4/Makefile.am b/m4/Makefile.am index 21cd7d19..ec93d4bd 100644 --- a/m4/Makefile.am +++ b/m4/Makefile.am @@ -5,6 +5,7 @@ EXTRA_DIST = decl.m4 \ djgpp.m4 \ dosfile.m4 \ envsep.m4 \ + error.m4 \ gettext.m4 \ glibc.m4 \ header.m4 \ @@ -14,10 +15,13 @@ EXTRA_DIST = decl.m4 \ isc-posix.m4 \ largefile.m4 \ lcmessage.m4 \ + malloc.m4 \ missing.m4 \ progtest.m4 \ + realloc.m4 \ regex.m4 \ sanity.m4 \ + strerror_r.m4 \ uintmax_t.m4 \ ulonglong.m4 \ xstrtoumax.m4 diff --git a/m4/error.m4 b/m4/error.m4 new file mode 100644 index 00000000..eb0f776b --- /dev/null +++ b/m4/error.m4 @@ -0,0 +1,11 @@ +#serial 1 + +dnl FIXME: put these prerequisite-only *.m4 files in a separate +dnl directory -- otherwise, they'll conflict with existing files. + +dnl These are the prerequisite macros for GNU's error.c file. +AC_DEFUN(jm_PREREQ_ERROR, +[ + AC_CHECK_FUNCS(strerror strerror_r vprintf doprnt) + AC_HEADER_STDC +]) diff --git a/m4/malloc.m4 b/m4/malloc.m4 new file mode 100644 index 00000000..4978eaf6 --- /dev/null +++ b/m4/malloc.m4 @@ -0,0 +1,35 @@ +#serial 3 + +dnl From Jim Meyering. +dnl Determine whether malloc accepts 0 as its argument. +dnl If it doesn't, arrange to use the replacement function. +dnl + +AC_DEFUN(jm_FUNC_MALLOC, +[ + dnl xmalloc.c requires that this symbol be defined so it doesn't + dnl mistakenly use a broken malloc -- as it might if this test were omitted. + AC_DEFINE_UNQUOTED(HAVE_DONE_WORKING_MALLOC_CHECK, 1, + [Define if the malloc check has been performed. ]) + + AC_CACHE_CHECK([for working malloc], jm_cv_func_working_malloc, + [AC_TRY_RUN([ + char *malloc (); + int + main () + { + exit (malloc (0) ? 0 : 1); + } + ], + jm_cv_func_working_malloc=yes, + jm_cv_func_working_malloc=no, + dnl When crosscompiling, assume malloc is broken. + jm_cv_func_working_malloc=no) + ]) + if test $jm_cv_func_working_malloc = no; then + AC_SUBST(LIBOBJS) + LIBOBJS="$LIBOBJS malloc.$ac_objext" + AC_DEFINE_UNQUOTED(malloc, rpl_malloc, + [Define to rpl_malloc if the replacement function should be used.]) + fi +]) diff --git a/m4/realloc.m4 b/m4/realloc.m4 new file mode 100644 index 00000000..bfbef0c1 --- /dev/null +++ b/m4/realloc.m4 @@ -0,0 +1,35 @@ +#serial 3 + +dnl From Jim Meyering. +dnl Determine whether realloc works when both arguments are 0. +dnl If it doesn't, arrange to use the replacement function. +dnl + +AC_DEFUN(jm_FUNC_REALLOC, +[ + dnl xmalloc.c requires that this symbol be defined so it doesn't + dnl mistakenly use a broken realloc -- as it might if this test were omitted. + AC_DEFINE_UNQUOTED(HAVE_DONE_WORKING_REALLOC_CHECK, 1, + [Define if the realloc check has been performed. ]) + + AC_CACHE_CHECK([for working realloc], jm_cv_func_working_realloc, + [AC_TRY_RUN([ + char *realloc (); + int + main () + { + exit (realloc (0, 0) ? 0 : 1); + } + ], + jm_cv_func_working_realloc=yes, + jm_cv_func_working_realloc=no, + dnl When crosscompiling, assume realloc is broken. + jm_cv_func_working_realloc=no) + ]) + if test $jm_cv_func_working_realloc = no; then + AC_SUBST(LIBOBJS) + LIBOBJS="$LIBOBJS realloc.$ac_objext" + AC_DEFINE_UNQUOTED(realloc, rpl_realloc, + [Define to rpl_realloc if the replacement function should be used.]) + fi +]) diff --git a/m4/strerror_r.m4 b/m4/strerror_r.m4 new file mode 100644 index 00000000..60832623 --- /dev/null +++ b/m4/strerror_r.m4 @@ -0,0 +1,69 @@ +#serial 1002, but ported to autoconf 2.13 by eggert +# Experimental replacement for the function in the latest CVS autoconf. +# If the compile-test says strerror_r doesn't work, then resort to a +# `run'-test that works on BeOS and segfaults on DEC Unix. +# Use with the error.c file in ../lib. + +undefine([AC_FUNC_STRERROR_R]) + +# AC_FUNC_STRERROR_R +# ------------------ +AC_DEFUN([AC_FUNC_STRERROR_R], +[jm_CHECK_DECLARATION(strerror_r, [#include ]) +test $jm_cv_func_decl_strerror_r != yes +AC_DEFINE_UNQUOTED(HAVE_DECL_STRERROR_R, $?, + [Define to 1 if strerror_r is declared.]) +AC_CHECK_FUNCS([strerror_r]) +if test $ac_cv_func_strerror_r = yes; then + AC_CHECK_HEADERS(string.h) + AC_CACHE_CHECK([for working strerror_r], + ac_cv_func_strerror_r_works, + [ + AC_TRY_COMPILE( + [ +# include +# if HAVE_STRING_H +# include +# endif + ], + [ + char buf[100]; + char x = *strerror_r (0, buf, sizeof buf); + ], + ac_cv_func_strerror_r_works=yes, + ac_cv_func_strerror_r_works=no + ) + if test $ac_cv_func_strerror_r_works = no; then + # strerror_r seems not to work, but now we have to choose between + # systems that have relatively inaccessible declarations for the + # function. BeOS and DEC UNIX 4.0 fall in this category, but the + # former has a strerror_r that returns char*, while the latter + # has a strerror_r that returns int. + # This test should segfault on the DEC system. + AC_TRY_RUN( + [ +# include +# include +# include + + extern char *strerror_r (); + + int + main () + { + char buf[100]; + char x = *strerror_r (0, buf, sizeof buf); + exit (!isalpha (x)); + } + ], + ac_cv_func_strerror_r_works=yes, + ac_cv_func_strerror_r_works=no, + ac_cv_func_strerror_r_works=no) + fi + ]) + if test $ac_cv_func_strerror_r_works = yes; then + AC_DEFINE_UNQUOTED(HAVE_WORKING_STRERROR_R, 1, + [Define to 1 if strerror_r returns a string.]) + fi +fi +])# AC_FUNC_STRERROR_R -- cgit v1.2.1