[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 12/12] use a shell function for AC_TYPE_INTx_T
From: |
Paolo Bonzini |
Subject: |
Re: [PATCH 12/12] use a shell function for AC_TYPE_INTx_T |
Date: |
Tue, 28 Oct 2008 07:41:35 +0100 |
User-agent: |
Thunderbird 2.0.0.17 (Macintosh/20080914) |
Paolo Bonzini wrote:
>>> +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' \
>> Should that be "int$[]2_t", rather than '', since we want shell expansion of
>> $2
>> to take place in creating $ac_type?
>
> Indeed.
>
>>> +# _AC_TYPE_INT(NBITS)
>>> +# -------------------
>>> +AC_DEFUN([_AC_TYPE_INT],
>> A comment describing this m4 macro would be nice. (And several other macros
>> touched by this patch).
>
> Ok.
Here's the patch with the above changes.
Paolo
2008-10-28 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 | 95 ++++++++++++++++++++++++++++++++++---------------
1 files changed, 66 insertions(+), 29 deletions(-)
diff --git a/lib/autoconf/types.m4 b/lib/autoconf/types.m4
index f310cd1..cc95a24 100644
--- a/lib/autoconf/types.m4
+++ b/lib/autoconf/types.m4
@@ -642,56 +642,93 @@ 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)
+# -------------------
+# Set a variable ac_cv_c_intNBITS_t to `yes' if intNBITS_t is available,
+# `no' if it is not and no replacement types could be found, and a C type
+# if it is not available but a replacement signed integer type of width
+# exactly NBITS bits was found. In the third case, intNBITS_t is AC_DEFINEd
+# to type, as well.
+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
+# --------------------------
+# Shell function body for _AC_TYPE_UNSIGNED_INT.
+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)
+# ----------------------------
+# Set a variable ac_cv_c_uintNBITS_t to `yes' if uintNBITS_t is available,
+# `no' if it is not and no replacement types could be found, and a C type
+# if it is not available but a replacement unsigned integer type of width
+# exactly NBITS bits was found. In the third case, uintNBITS_t is AC_DEFINEd
+# to type, as well.
+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, 2008/10/27
- 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, 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
- 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, Ralf Wildenhues, 2008/10/28