[PATCH] fix off_t/rlim_t size checks when cross-compiling

Mike Frysinger vapier at gentoo.org
Sun Sep 12 08:01:47 UTC 2010


The current off_t/rlim_t size checks (wrt size of long long) use AC_RUN
which obviously doesn't work when cross-compiling.  While we don't hit any
configure errors, the fall back code is pretty dumb (which is to say there
isn't any).  Considering the code in question though, we can use some fun
compiler tricks with sizeof and array lengths to turn it into a pure build
test and avoid the RUN issue completely.

* acinclude.m4 (AC_OFF_T_IS_LONG_LONG, AC_RLIM_T_IS_LONG_LONG): Convert
	from AC_RUN_IFELSE to AC_COMPILE_IFELSE.

Signed-off-by: Mike Frysinger <vapier at gentoo.org>
---
note: all the systems i tested seem to return "no" for both of these, so
	i couldnt find any which test otherwise to double check my work.  but
	it looks sane enough :P.

 acinclude.m4 |   28 ++++++++--------------------
 1 files changed, 8 insertions(+), 20 deletions(-)

diff --git a/acinclude.m4 b/acinclude.m4
index 708f8cc..5e61d15 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -232,16 +232,10 @@ dnl ### A macro to determine if off_t is a long long
 AC_DEFUN([AC_OFF_T_IS_LONG_LONG],
 [AC_MSG_CHECKING(for long long off_t)
 AC_CACHE_VAL(ac_cv_have_long_long_off_t,
-[AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <sys/types.h>
-main () {
-	if (sizeof (off_t) == sizeof (long long) &&
-	    sizeof (off_t) > sizeof (long))
-	    return 0;
-	return 1;
-}
-]])],[ac_cv_have_long_long_off_t=yes],[ac_cv_have_long_long_off_t=no],[# Should try to guess here
-ac_cv_have_long_long_off_t=no
-])])
+[AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <sys/types.h>
+char a[(sizeof (off_t) == sizeof (long long) &&
+        sizeof (off_t) > sizeof (long)) - 1];
+]])],[ac_cv_have_long_long_off_t=yes],[ac_cv_have_long_long_off_t=no])])
 AC_MSG_RESULT($ac_cv_have_long_long_off_t)
 if test "$ac_cv_have_long_long_off_t" = yes
 then
@@ -253,18 +247,12 @@ dnl ### A macro to determine if rlim_t is a long long
 AC_DEFUN([AC_RLIM_T_IS_LONG_LONG],
 [AC_MSG_CHECKING(for long long rlim_t)
 AC_CACHE_VAL(ac_cv_have_long_long_rlim_t,
-[AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <sys/types.h>
+[AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <sys/types.h>
 #include <sys/time.h>
 #include <sys/resource.h>
-main () {
-	if (sizeof (rlim_t) == sizeof (long long) &&
-	    sizeof (rlim_t) > sizeof (long))
-	    return 0;
-	return 1;
-}
-]])],[ac_cv_have_long_long_rlim_t=yes],[ac_cv_have_long_long_rlim_t=no],[# Should try to guess here
-ac_cv_have_long_long_rlim_t=no
-])])
+char a[(sizeof (rlim_t) == sizeof (long long) &&
+        sizeof (rlim_t) > sizeof (long)) - 1];
+]])],[ac_cv_have_long_long_rlim_t=yes],[ac_cv_have_long_long_rlim_t=no])])
 AC_MSG_RESULT($ac_cv_have_long_long_rlim_t)
 if test "$ac_cv_have_long_long_rlim_t" = yes
 then
-- 
1.7.2





More information about the Strace-devel mailing list