summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-01-18 16:49:48 -0500
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-01-18 17:04:50 -0500
commitd6a195a3c373f67632cb98d6e6e14f974ef062f9 (patch)
tree3da905e430e6710ba8863b1673bb988f30979df6 /m4
parent2b3987a863975f5a1fa1754725e3d07a5d4f6478 (diff)
build-sys: add autoconf macro to pick macro for x32 compatibility
Diffstat (limited to 'm4')
-rw-r--r--m4/sd_check_max_int_size.m427
1 files changed, 27 insertions, 0 deletions
diff --git a/m4/sd_check_max_int_size.m4 b/m4/sd_check_max_int_size.m4
new file mode 100644
index 0000000000..a4230b5ee8
--- /dev/null
+++ b/m4/sd_check_max_int_size.m4
@@ -0,0 +1,27 @@
+dnl Find what INT_MAX define to use for a type
+
+#serial 1
+
+ifdef([AC_TR_SH],[], [
+define([AC_TR_SH],
+ [patsubst(translit([[$1]], [*+], [pp]), [[^a-zA-Z0-9_]], [_])])
+define([AC_TR_CPP],
+ [patsubst(translit([[$1]],
+ [*abcdefghijklmnopqrstuvwxyz],
+ [PABCDEFGHIJKLMNOPQRSTUVWXYZ]),
+ [[^A-Z0-9_]], [_])])
+])
+
+AC_DEFUN([SD_CHECK_MAX_INT_SIZE],
+ [AC_CHECK_SIZEOF([long],,)
+ AC_CHECK_SIZEOF([long long],,)
+ AC_CHECK_SIZEOF([$1],,[$2])
+ AS_CASE([$ac_cv_sizeof_[]AC_TR_SH($1)],
+ [$ac_cv_sizeof_long], [sd_type_max=LONG_MAX],
+ [$ac_cv_sizeof_long_long], [sd_type_max=LONG_LONG_MAX],
+ [AC_MSG_ERROR([Don't know how to map $1 to an integer])])
+ AC_DEFINE_UNQUOTED(AC_TR_CPP($1_MAX), [$sd_type_max],
+ [what int to use to maximize $1])
+ AC_MSG_CHECKING([what int to to use to maximize $1])
+ AC_MSG_RESULT([$sd_type_max])
+])