[PATCH][util-macros][V2] xorg-macros.m4.in: remove option, use autoconf cache for XORG_CHECK_MALLOC_ZERO

Ross Burton ross.burton at intel.com
Fri Oct 11 05:24:45 PDT 2013


Improve configure speed by checking the autoconf cache before compiling and
running the test.

As this means cross-compilation environments can trivially seed this cache as
appropriate, remove the cross-compiling value (which for embedded systems using
uclibc is wrong).

Finally remove the configure option as the autoconf site cache is a better way
of setting this value for cross-compiled environments.

Signed-off-by: Ross Burton <ross.burton at intel.com>
---
 xorg-macros.m4.in |   21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/xorg-macros.m4.in b/xorg-macros.m4.in
index 18c33e9..a675c94 100644
--- a/xorg-macros.m4.in
+++ b/xorg-macros.m4.in
@@ -1312,15 +1312,9 @@ AC_SUBST([XORG_MALLOC_DEBUG_ENV],[$malloc_debug_env])
 # malloc(0) returns NULL.  Packages should add one of these cflags to
 # their AM_CFLAGS (or other appropriate *_CFLAGS) to use them.
 AC_DEFUN([XORG_CHECK_MALLOC_ZERO],[
-AC_ARG_ENABLE(malloc0returnsnull,
-	AS_HELP_STRING([--enable-malloc0returnsnull],
-		       [malloc(0) returns NULL (default: auto)]),
-	[MALLOC_ZERO_RETURNS_NULL=$enableval],
-	[MALLOC_ZERO_RETURNS_NULL=auto])
-
-AC_MSG_CHECKING([whether malloc(0) returns NULL])
-if test "x$MALLOC_ZERO_RETURNS_NULL" = xauto; then
-	AC_RUN_IFELSE([AC_LANG_PROGRAM([
+AC_CACHE_CHECK([whether malloc(0) returns NULL],
+               [xorg_cv_malloc0_returns_null],
+               [AC_RUN_IFELSE([AC_LANG_PROGRAM([
 #include <stdlib.h>
 ],[
     char *m0, *r0, *c0, *p;
@@ -1330,13 +1324,10 @@ if test "x$MALLOC_ZERO_RETURNS_NULL" = xauto; then
     c0 = calloc(0,10);
     exit((m0 == 0 || r0 == 0 || c0 == 0) ? 0 : 1);
 ])],
-		[MALLOC_ZERO_RETURNS_NULL=yes],
-		[MALLOC_ZERO_RETURNS_NULL=no],
-		[MALLOC_ZERO_RETURNS_NULL=yes])
-fi
-AC_MSG_RESULT([$MALLOC_ZERO_RETURNS_NULL])
+               [xorg_cv_malloc0_returns_null=yes],
+               [xorg_cv_malloc0_returns_null=no])])
 
-if test "x$MALLOC_ZERO_RETURNS_NULL" = xyes; then
+if test "x$xorg_cv_malloc0_returns_null" = xyes; then
 	MALLOC_ZERO_CFLAGS="-DMALLOC_0_RETURNS_NULL"
 	XMALLOC_ZERO_CFLAGS=$MALLOC_ZERO_CFLAGS
 	XTMALLOC_ZERO_CFLAGS="$MALLOC_ZERO_CFLAGS -DXTMALLOC_BC"
-- 
1.7.10.4



More information about the xorg-devel mailing list