diff options
Diffstat (limited to 'gl/m4/malloc.m4')
| -rw-r--r-- | gl/m4/malloc.m4 | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/gl/m4/malloc.m4 b/gl/m4/malloc.m4 index 910ac922..fe5befc2 100644 --- a/gl/m4/malloc.m4 +++ b/gl/m4/malloc.m4 | |||
| @@ -1,25 +1,40 @@ | |||
| 1 | # malloc.m4 serial 9 | 1 | # malloc.m4 serial 10 |
| 2 | dnl Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc. |
| 3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
| 4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
| 5 | dnl with or without modifications, as long as this notice is preserved. | 5 | dnl with or without modifications, as long as this notice is preserved. |
| 6 | 6 | ||
| 7 | # gl_FUNC_MALLOC_GNU | ||
| 8 | # ------------------ | ||
| 9 | # Test whether 'malloc (0)' is handled like in GNU libc, and replace malloc if | ||
| 10 | # it is not. | ||
| 11 | AC_DEFUN([gl_FUNC_MALLOC_GNU], | ||
| 12 | [ | ||
| 13 | AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) | ||
| 14 | dnl _AC_FUNC_MALLOC_IF is defined in Autoconf. | ||
| 15 | _AC_FUNC_MALLOC_IF( | ||
| 16 | [AC_DEFINE([HAVE_MALLOC], [1], | ||
| 17 | [Define to 1 if your system has a GNU libc compatible 'malloc' | ||
| 18 | function, and to 0 otherwise.])], | ||
| 19 | [AC_DEFINE([HAVE_MALLOC], [0]) | ||
| 20 | gl_REPLACE_MALLOC | ||
| 21 | ]) | ||
| 22 | ]) | ||
| 23 | |||
| 7 | # gl_FUNC_MALLOC_POSIX | 24 | # gl_FUNC_MALLOC_POSIX |
| 8 | # -------------------- | 25 | # -------------------- |
| 9 | # Test whether 'malloc' is POSIX compliant (sets errno to ENOMEM when it | 26 | # Test whether 'malloc' is POSIX compliant (sets errno to ENOMEM when it |
| 10 | # fails), and replace malloc if it is not. | 27 | # fails), and replace malloc if it is not. |
| 11 | AC_DEFUN([gl_FUNC_MALLOC_POSIX], | 28 | AC_DEFUN([gl_FUNC_MALLOC_POSIX], |
| 12 | [ | 29 | [ |
| 30 | AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) | ||
| 13 | AC_REQUIRE([gl_CHECK_MALLOC_POSIX]) | 31 | AC_REQUIRE([gl_CHECK_MALLOC_POSIX]) |
| 14 | if test $gl_cv_func_malloc_posix = yes; then | 32 | if test $gl_cv_func_malloc_posix = yes; then |
| 15 | HAVE_MALLOC_POSIX=1 | ||
| 16 | AC_DEFINE([HAVE_MALLOC_POSIX], [1], | 33 | AC_DEFINE([HAVE_MALLOC_POSIX], [1], |
| 17 | [Define if the 'malloc' function is POSIX compliant.]) | 34 | [Define if the 'malloc' function is POSIX compliant.]) |
| 18 | else | 35 | else |
| 19 | AC_LIBOBJ([malloc]) | 36 | gl_REPLACE_MALLOC |
| 20 | HAVE_MALLOC_POSIX=0 | ||
| 21 | fi | 37 | fi |
| 22 | AC_SUBST([HAVE_MALLOC_POSIX]) | ||
| 23 | ]) | 38 | ]) |
| 24 | 39 | ||
| 25 | # Test whether malloc, realloc, calloc are POSIX compliant, | 40 | # Test whether malloc, realloc, calloc are POSIX compliant, |
| @@ -39,3 +54,9 @@ AC_DEFUN([gl_CHECK_MALLOC_POSIX], | |||
| 39 | ], [gl_cv_func_malloc_posix=yes], [gl_cv_func_malloc_posix=no]) | 54 | ], [gl_cv_func_malloc_posix=yes], [gl_cv_func_malloc_posix=no]) |
| 40 | ]) | 55 | ]) |
| 41 | ]) | 56 | ]) |
| 57 | |||
| 58 | AC_DEFUN([gl_REPLACE_MALLOC], | ||
| 59 | [ | ||
| 60 | AC_LIBOBJ([malloc]) | ||
| 61 | REPLACE_MALLOC=1 | ||
| 62 | ]) | ||
