autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 12/12] use a shell function for AC_TYPE_INTx_T


From: Paolo Bonzini
Subject: [PATCH 12/12] use a shell function for AC_TYPE_INTx_T
Date: Mon, 20 Oct 2008 15:35:59 +0200

2008-10-14  Paolo Bonzini  <address@hidden>

        * lib/autoconf/general.m4 (_AC_TYPE_INT, _AC_TYPE_UNSIGNED_INT): Use
        a shell function.
---
 lib/autoconf/types.m4 |   68 +++++++++++++++++++++++++++++++++----------------
 1 files changed, 46 insertions(+), 22 deletions(-)

diff --git a/lib/autoconf/types.m4 b/lib/autoconf/types.m4
index 4af94bf..3a1a023 100644
--- a/lib/autoconf/types.m4
+++ b/lib/autoconf/types.m4
@@ -641,27 +641,39 @@ AC_DEFUN([AC_TYPE_UINT64_T], [_AC_TYPE_UNSIGNED_INT(64)])
 
 # _AC_TYPE_INT(NBITS)
 # -------------------
-AC_DEFUN([_AC_TYPE_INT],
-[
-  AC_CACHE_CHECK([for int$1_t], [ac_cv_c_int$1_t],
-    [ac_cv_c_int$1_t=no
-     for ac_type in 'int$1_t' 'int' 'long int' \
+AC_DEFUN([_AC_TYPE_INT_PREPARE],
+[AC_REQUIRE_SHELL_FN([ac_func_c_find_intX_t],
+  [AS_FUNCTION_DESCRIBE([ac_func_c_find_intX_t], [LINENO BITS], 
+    [Finds a signed integer type with width BITS, setting a cache variable
+     accordingly.])], [
+  AS_LINENO_PUSH([$[]1])
+  ac_width=[$]2
+  AS_VAR_PUSHDEF([ac_Type], [ac_cv_c_int${ac_width}_t])dnl
+  AC_CACHE_CHECK([for int${ac_width}_t], [ac_Type],
+    [AS_VAR_SET([ac_Type], [no])
+     for ac_type in 'int${ac_width}_t' 'int' 'long int' \
         'long long int' 'short int' 'signed char'; do
        AC_COMPILE_IFELSE(
         [AC_LANG_BOOL_COMPILE_TRY(
            [AC_INCLUDES_DEFAULT],
-           [[0 < ($ac_type) (((($ac_type) 1 << ($1 - 2)) - 1) * 2 + 1)]])],
+           [[0 < ($ac_type) (((($ac_type) 1 << ($ac_width - 2)) - 1) * 2 + 
1)]])],
         [AC_COMPILE_IFELSE(
            [AC_LANG_BOOL_COMPILE_TRY(
               [AC_INCLUDES_DEFAULT],
-              [[($ac_type) (((($ac_type) 1 << ($1 - 2)) - 1) * 2 + 1)
-                < ($ac_type) (((($ac_type) 1 << ($1 - 2)) - 1) * 2 + 2)]])],
+              [[($ac_type) (((($ac_type) 1 << ($ac_width - 2)) - 1) * 2 + 1)
+                < ($ac_type) (((($ac_type) 1 << ($ac_width - 2)) - 1) * 2 + 
2)]])],
            [],
-           [AS_CASE([$ac_type], [int$1_t],
-              [ac_cv_c_int$1_t=yes],
-              [ac_cv_c_int$1_t=$ac_type])])])
-       test "$ac_cv_c_int$1_t" != no && break
+           [AS_CASE([$ac_type], [int${ac_width}_t],
+              [AS_VAR_SET([ac_Type], [yes])],
+              [AS_VAR_SET([ac_Type], [$ac_type])])])])
+       AS_VAR_IF([ac_Type], [no], [], [break])
      done])
+  AS_LINENO_POP
+])])
+
+AC_DEFUN([_AC_TYPE_INT],
+[AC_REQUIRE([_AC_TYPE_INT_PREPARE])
+  ac_func_c_find_intX_t "$LINENO" "$1"
   case $ac_cv_c_int$1_t in #(
   no|yes) ;; #(
   *)
@@ -673,21 +685,33 @@ AC_DEFUN([_AC_TYPE_INT],
 
 # _AC_TYPE_UNSIGNED_INT(NBITS)
 # ----------------------------
-AC_DEFUN([_AC_TYPE_UNSIGNED_INT],
-[
-  AC_CACHE_CHECK([for uint$1_t], [ac_cv_c_uint$1_t],
-    [ac_cv_c_uint$1_t=no
-     for ac_type in 'uint$1_t' 'unsigned int' 'unsigned long int' \
+AC_DEFUN([_AC_TYPE_UNSIGNED_INT_PREPARE],
+[AC_REQUIRE_SHELL_FN([ac_func_c_find_uintX_t],
+  [AS_FUNCTION_DESCRIBE([ac_func_c_find_uintX_t], [LINENO BITS], 
+    [Finds an unsigned integer type with width BITS, setting a cache variable
+     accordingly.])], [
+  AS_LINENO_PUSH([$[]1])
+  ac_width=[$]2
+  AS_VAR_PUSHDEF([ac_Type], [ac_cv_c_uint${ac_width}_t])dnl
+  AC_CACHE_CHECK([for uint${ac_width}_t], ac_Type,
+    [AS_VAR_SET([ac_Type], [no])
+     for ac_type in 'uint${ac_width}_t' 'unsigned int' 'unsigned long int' \
         'unsigned long long int' 'unsigned short int' 'unsigned char'; do
        AC_COMPILE_IFELSE(
         [AC_LANG_BOOL_COMPILE_TRY(
            [AC_INCLUDES_DEFAULT],
-           [[($ac_type) -1 >> ($1 - 1) == 1]])],
-        [AS_CASE([$ac_type], [uint$1_t],
-           [ac_cv_c_uint$1_t=yes],
-           [ac_cv_c_uint$1_t=$ac_type])])
-       test "$ac_cv_c_uint$1_t" != no && break
+           [[($ac_type) -1 >> ($ac_width - 1) == 1]])],
+        [AS_CASE([$ac_type], [uint${ac_width}_t],
+           [AS_VAR_SET([ac_Type], [yes])],
+           [AS_VAR_SET([ac_Type], [$ac_type])])])
+       AS_VAR_IF([ac_Type], [no], [], [break])
      done])
+  AS_LINENO_POP
+])])
+
+AC_DEFUN([_AC_TYPE_UNSIGNED_INT],
+[AC_REQUIRE([_AC_TYPE_UNSIGNED_INT_PREPARE])
+  ac_func_c_find_uintX_t "$LINENO" "$1"
   case $ac_cv_c_uint$1_t in #(
   no|yes) ;; #(
   *)
-- 
1.5.5





reply via email to

[Prev in Thread] Current Thread [Next in Thread]