apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r554963 - in /apr/apr/trunk: build/apr_common.m4 configure.in
Date Tue, 10 Jul 2007 14:39:04 GMT
Author: davi
Date: Tue Jul 10 07:39:03 2007
New Revision: 554963

URL: http://svn.apache.org/viewvc?view=rev&rev=554963
Log:
Improve detection of the printf format identifiers for apr_ssize_t and apr_size_t
using the gcc (and icc) built-in __builtin_types_compatible_p (used to determine
if two types are the same). This could also be achieved with another gcc extension
(type redeclaration), but using the built-in seems more forward compatible.

Modified:
    apr/apr/trunk/build/apr_common.m4
    apr/apr/trunk/configure.in

Modified: apr/apr/trunk/build/apr_common.m4
URL: http://svn.apache.org/viewvc/apr/apr/trunk/build/apr_common.m4?view=diff&rev=554963&r1=554962&r2=554963
==============================================================================
--- apr/apr/trunk/build/apr_common.m4 (original)
+++ apr/apr/trunk/build/apr_common.m4 Tue Jul 10 07:39:03 2007
@@ -959,3 +959,17 @@
 
 AC_SUBST(MKDEP)
 ])
+
+dnl
+dnl APR_CHECK_TYPES_COMPATIBLE(TYPE-1, TYPE-2, [ACTION-IF-TRUE])
+dnl
+dnl Try to determine whether two types are the same. Only works
+dnl for gcc and icc.
+dnl
+AC_DEFUN([APR_CHECK_TYPES_COMPATIBLE], [
+define([apr_cvname], apr_cv_typematch_[]translit([$1], [ ], [_])_[]translit([$2], [ ], [_]))
+AC_CACHE_CHECK([whether $1 and $2 are the same], apr_cvname, [
+AC_TRY_COMPILE(AC_INCLUDES_DEFAULT, [
+    int foo[0 - !__builtin_types_compatible_p($1, $2)];
+], [apr_cvname=yes $3], [apr_cvname=no])])
+])

Modified: apr/apr/trunk/configure.in
URL: http://svn.apache.org/viewvc/apr/apr/trunk/configure.in?view=diff&rev=554963&r1=554962&r2=554963
==============================================================================
--- apr/apr/trunk/configure.in (original)
+++ apr/apr/trunk/configure.in Tue Jul 10 07:39:03 2007
@@ -1330,26 +1330,83 @@
     socklen_t_value="int"
 fi
 
+# Basically, we have tried to figure out the correct format strings
+# for APR types which vary between platforms, but we don't always get
+# it right.
+case $host in
+   s390*linux*)
+       # uniquely, the 31-bit Linux/s390 uses "unsigned long int"
+       # for size_t rather than "unsigned int":
+       size_t_fmt="lu"
+       ssize_t_fmt="ld"
+       ;;
+   *-os2*)
+       size_t_fmt="lu"
+       ;;
+   *-solaris*)
+       pid_t_fmt="ld"
+       ;;
+   *aix4*|*aix5*)
+       ssize_t_fmt="ld"
+       size_t_fmt="ld"
+       ;;
+    *beos*)
+        ssize_t_fmt="ld"
+        size_t_fmt="ld"
+        ;;
+    *apple-darwin*)
+        osver=`uname -r`
+        case $osver in
+           [[0-7]].*)
+              ssize_t_fmt="d"
+              ;;
+           *)
+              ssize_t_fmt="ld"
+              ;;
+        esac
+        size_t_fmt="lu"
+        ;;
+esac
+
+APR_CHECK_TYPES_COMPATIBLE(ssize_t, int, [ssize_t_fmt="d"])
+APR_CHECK_TYPES_COMPATIBLE(ssize_t, long, [ssize_t_fmt="ld"])
+APR_CHECK_TYPES_COMPATIBLE(size_t, unsigned int, [size_t_fmt="u"])
+APR_CHECK_TYPES_COMPATIBLE(size_t, unsigned long, [size_t_fmt="lu"])
+
 APR_CHECK_SIZEOF_EXTENDED([#include <sys/types.h>], ssize_t, 8)
 
-if test "$ac_cv_sizeof_ssize_t" = "$ac_cv_sizeof_int"; then
-    ssize_t_fmt='#define APR_SSIZE_T_FMT "d"'
+AC_MSG_CHECKING([which format to use for apr_ssize_t])
+if test -n "$ssize_t_fmt"; then
+    AC_MSG_RESULT(%$ssize_t_fmt)
+elif test "$ac_cv_sizeof_ssize_t" = "$ac_cv_sizeof_int"; then
+    ssize_t_fmt="d"
+    AC_MSG_RESULT(%d)
 elif test "$ac_cv_sizeof_ssize_t" = "$ac_cv_sizeof_long"; then
-    ssize_t_fmt='#define APR_SSIZE_T_FMT "ld"'
+    ssize_t_fmt="ld"
+    AC_MSG_RESULT(%ld)
 else
-    ssize_t_fmt='#error Can not determine the proper size for ssize_t'
+    AC_ERROR([could not determine the proper format for apr_ssize_t])
 fi
 
+ssize_t_fmt="#define APR_SSIZE_T_FMT \"$ssize_t_fmt\""
+
 APR_CHECK_SIZEOF_EXTENDED([#include <stddef.h>], size_t, 8)
 
-if test "$ac_cv_sizeof_size_t" = "$ac_cv_sizeof_int"; then
-    size_t_fmt='#define APR_SIZE_T_FMT "d"'
+AC_MSG_CHECKING([which format to use for apr_size_t])
+if test -n "$size_t_fmt"; then
+    AC_MSG_RESULT(%$size_t_fmt)
+elif test "$ac_cv_sizeof_size_t" = "$ac_cv_sizeof_int"; then
+    size_t_fmt="d"
+    AC_MSG_RESULT(%d)
 elif test "$ac_cv_sizeof_size_t" = "$ac_cv_sizeof_long"; then
-    size_t_fmt='#define APR_SIZE_T_FMT "ld"'
+    size_t_fmt="ld"
+    AC_MSG_RESULT(%ld)
 else
-    size_t_fmt='#error Can not determine the proper size for size_t'
+    AC_ERROR([could not determine the proper format for apr_size_t])
 fi
 
+size_t_fmt="#define APR_SIZE_T_FMT \"$size_t_fmt\""
+
 APR_CHECK_SIZEOF_EXTENDED([#include <sys/types.h>], off_t, 8)
 
 if test "${ac_cv_sizeof_off_t}${apr_cv_use_lfs64}" = "4yes"; then
@@ -1419,45 +1476,6 @@
 else
     bigendian=0
 fi
-
-# Basically, we have tried to figure out the correct format strings
-# for APR types which vary between platforms, but we don't always get 
-# it right.  If you find that we don't get it right for your platform, 
-# you can override our decision below.
-case $host in
-   s390*linux*)
-       # uniquely, the 31-bit Linux/s390 uses "unsigned long int"
-       # for size_t rather than "unsigned int":
-       size_t_fmt='#define APR_SIZE_T_FMT "lu"'
-       ssize_t_fmt='#define APR_SSIZE_T_FMT "ld"'
-       ;;
-   *-os2*)
-       size_t_fmt='#define APR_SIZE_T_FMT "lu"'
-       ;;
-   *-solaris*)
-       pid_t_fmt='#define APR_PID_T_FMT "ld"'
-       ;;
-   *aix4*|*aix5*)
-       ssize_t_fmt='#define APR_SSIZE_T_FMT "ld"'
-       size_t_fmt='#define APR_SIZE_T_FMT "ld"'
-       ;;
-    *beos*)
-        ssize_t_fmt='#define APR_SSIZE_T_FMT "ld"'
-        size_t_fmt='#define APR_SIZE_T_FMT "ld"'
-        ;;
-    *apple-darwin*)
-        osver=`uname -r`
-        case $osver in
-           [[0-7]].*)
-              ssize_t_fmt='#define APR_SSIZE_T_FMT "d"'
-              ;;
-           *)
-              ssize_t_fmt='#define APR_SSIZE_T_FMT "ld"'
-              ;;
-        esac
-        size_t_fmt='#define APR_SIZE_T_FMT "lu"'
-        ;;
-esac
 
 APR_CHECK_SIZEOF_EXTENDED([#include <sys/types.h>
 #include <sys/uio.h>],struct iovec,0)



Mime
View raw message