[Top][All Lists]
[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, 27 Oct 2008 11:35:59 +0200 |
2008-10-27 Paolo Bonzini <address@hidden>
* lib/autoconf/types.m4 (_AC_TYPE_INT_BODY, _AC_TYPE_UNSIGNED_INT_BODY):
New.
(_AC_TYPE_INT, _AC_TYPE_UNSIGNED_INT): Define and use a shell function.
---
lib/autoconf/types.m4 | 84 ++++++++++++++++++++++++++++++++-----------------
1 files changed, 55 insertions(+), 29 deletions(-)
diff --git a/lib/autoconf/types.m4 b/lib/autoconf/types.m4
index 34ca65b..152f332 100644
--- a/lib/autoconf/types.m4
+++ b/lib/autoconf/types.m4
@@ -642,56 +642,82 @@ AC_DEFUN([AC_TYPE_UINT16_T], [_AC_TYPE_UNSIGNED_INT(16)])
AC_DEFUN([AC_TYPE_UINT32_T], [_AC_TYPE_UNSIGNED_INT(32)])
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_TYPE_INT_BODY
+# -----------------
+# Shell function body for _AC_TYPE_INT
+m4_define([_AC_TYPE_INT_BODY],
+[ AS_LINENO_PUSH([$[]1])
+ AC_CACHE_CHECK([for int$[]2_t], [$[]3],
+ [AS_VAR_SET([$[]3], [no])
+ for ac_type in 'int$[]2_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 << ($[]2 - 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 << ($[]2 - 2)) - 1) * 2 + 1)
+ < ($ac_type) (((($ac_type) 1 << ($[]2 - 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$[]2_t],
+ [AS_VAR_SET([$[]3], [yes])],
+ [AS_VAR_SET([$[]3], [$ac_type])])])])
+ AS_VAR_IF([$[]3], [no], [], [break])
done])
- case $ac_cv_c_int$1_t in #(
+ AS_LINENO_POP
+])# _AC_TYPE_INT_BODY
+
+# _AC_TYPE_INT(NBITS)
+# -------------------
+AC_DEFUN([_AC_TYPE_INT],
+[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.])],
+ [$0_BODY])]dnl
+[ac_func_c_find_intX_t "$LINENO" "$1" "ac_cv_c_int$1_t"
+case $ac_cv_c_int$1_t in #(
no|yes) ;; #(
*)
AC_DEFINE_UNQUOTED([int$1_t], [$ac_cv_c_int$1_t],
[Define to the type of a signed integer type of width exactly $1 bits
if such a type exists and the standard includes do not define it.]);;
- esac
+esac
])# _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_TYPE_UNSIGNED_INT_BODY
+# --------------------------
+m4_define([_AC_TYPE_UNSIGNED_INT_BODY],
+[ AS_LINENO_PUSH([$[]1])
+ AC_CACHE_CHECK([for uint$[]2_t], $[]3,
+ [AS_VAR_SET([$[]3], [no])
+ for ac_type in 'uint$[]2_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 >> ($[]2 - 1) == 1]])],
+ [AS_CASE([$ac_type], [uint$[]2_t],
+ [AS_VAR_SET([$[]3], [yes])],
+ [AS_VAR_SET([$[]3], [$ac_type])])])
+ AS_VAR_IF([$[]3], [no], [], [break])
done])
- case $ac_cv_c_uint$1_t in #(
+ AS_LINENO_POP
+])# _AC_TYPE_UNSIGNED_INT_BODY
+
+
+# _AC_TYPE_UNSIGNED_INT(NBITS)
+# ----------------------------
+AC_DEFUN([_AC_TYPE_UNSIGNED_INT],
+[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.])],
+ [$0_BODY])]dnl
+[ac_func_c_find_uintX_t "$LINENO" "$1" "ac_cv_c_uint$1_t"
+case $ac_cv_c_uint$1_t in #(
no|yes) ;; #(
*)
m4_bmatch([$1], [^\(8\|32\|64\)$],
--
1.5.5
- [PATCH 12/12] use a shell function for AC_TYPE_INTx_T, Paolo Bonzini, 2008/10/20
- [PATCH 12/12] use a shell function for AC_TYPE_INTx_T,
Paolo Bonzini <=
- Re: [PATCH 12/12] use a shell function for AC_TYPE_INTx_T, Eric Blake, 2008/10/27
- Re: [PATCH 12/12] use a shell function for AC_TYPE_INTx_T, Paolo Bonzini, 2008/10/27
- Re: [PATCH 12/12] use a shell function for AC_TYPE_INTx_T, Paolo Bonzini, 2008/10/28
- Re: [PATCH 12/12] use a shell function for AC_TYPE_INTx_T, Eric Blake, 2008/10/28
- Re: [PATCH 12/12] use a shell function for AC_TYPE_INTx_T, Paolo Bonzini, 2008/10/28
- Re: [PATCH 12/12] use a shell function for AC_TYPE_INTx_T, Eric Blake, 2008/10/28
- Re: [PATCH 12/12] use a shell function for AC_TYPE_INTx_T, Ralf Wildenhues, 2008/10/28
- Re: [PATCH 12/12] use a shell function for AC_TYPE_INTx_T, Paolo Bonzini, 2008/10/28
- Re: [PATCH 12/12] use a shell function for AC_TYPE_INTx_T, Eric Blake, 2008/10/28
- Re: [PATCH 12/12] use a shell function for AC_TYPE_INTx_T, Paolo Bonzini, 2008/10/28