summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorLucas De Marchi <lucas.demarchi@profusion.mobi>2013-01-02 15:16:32 +0000
committerLucas De Marchi <lucas.demarchi@profusion.mobi>2013-01-02 15:16:32 +0000
commit1282bb2754113f30ff7af96c785e9bc070a45c26 (patch)
treef93faf8548618da5ee58383555300bce960e9677 /m4
parenta34941c17f57caeb448ba46e0a4b91a9671da7b8 (diff)
efl: use compile-time chec for type of va_list
Using AC_TRY_RUN is bad for crosscompiling since you can't run the binary you compiled (if you are not using a canadian crosstoolchain). In this case the check is omitted and HAVE_VA_LIST_AS_ARRAY remains undefined, which is wrong if you are compiling in a x86_64 for an ARM architecture. SVN revision: 82000
Diffstat (limited to 'm4')
-rw-r--r--m4/ac_valist.m455
1 files changed, 23 insertions, 32 deletions
diff --git a/m4/ac_valist.m4 b/m4/ac_valist.m4
index a4d6a24..8016a06 100644
--- a/m4/ac_valist.m4
+++ b/m4/ac_valist.m4
@@ -1,45 +1,36 @@
1dnl That code is public domain and can be freely used or copied. 1dnl Copyright (C) 2013 ProFUSION embedded systems
2dnl Originally snatched from somewhere... 2dnl This code is public domain and can be freely used or copied.
3 3
4dnl Macro for checking if va_list is an array 4dnl Macro for checking if va_list is an array
5 5
6dnl Usage: AC_C_VA_LIST_AS_ARRAY 6dnl Usage: AC_C_VA_LIST_AS_ARRAY
7dnl call AC_DEFINE for HAVE_VA_LIST_AS_ARRAY 7dnl call AC_DEFINE for HAVE_VA_LIST_AS_ARRAY if for this architecture
8dnl if for this architecture va_list is defined as an array 8dnl va_list is defined as an array
9 9
10AC_DEFUN([AC_C_VA_LIST_AS_ARRAY], 10AC_DEFUN([AC_C_VA_LIST_AS_ARRAY],
11[ 11[
12
13AC_MSG_CHECKING([whether va_list is defined as an array]) 12AC_MSG_CHECKING([whether va_list is defined as an array])
14 13AC_COMPILE_IFELSE(
15AC_CACHE_VAL([ac_cv_valistasarray], 14 [AC_LANG_PROGRAM(
16 [AC_TRY_RUN( 15 [[
17 [
18#include <stdlib.h> 16#include <stdlib.h>
19#include <stdarg.h> 17#include <stdarg.h>
20void foo(int i, ...) 18
21{ 19#define BUILD_ASSERT(cond) \
22 va_list ap1, ap2; 20 do { (void) sizeof(char [1 - 2*!(cond)]); } while(0)
23 va_start(ap1, i); 21 ]],
24 ap2 = ap1; 22 [[
25 if (va_arg(ap2, int) != 123 || va_arg(ap1, int) != 123) 23va_list ap;
26 exit(1); 24BUILD_ASSERT(__builtin_types_compatible_p(typeof(ap),
27 va_end(ap1); 25 typeof(&(ap)[0])));
28} 26return 0;
29int main(void) 27 ]])],
30{ 28 [have_va_list_as_array="no"],
31 foo(0, 123); 29 [have_va_list_as_array="yes"])
32 return(0); 30
33} 31AC_MSG_RESULT([${have_va_list_as_array}])
34 ], 32
35 [ac_cv_valistasarray="no"], 33if test "x${have_va_list_as_array}" = "xyes" ; then
36 [ac_cv_valistasarray="yes"],
37 [ac_cv_valistasarray="no"]
38 )])
39
40AC_MSG_RESULT($ac_cv_valistasarray)
41
42if test "x${ac_cv_valistasarray}" = "xyes" ; then
43 AC_DEFINE([HAVE_VA_LIST_AS_ARRAY], [1], [Define to 1 if va_list is an array]) 34 AC_DEFINE([HAVE_VA_LIST_AS_ARRAY], [1], [Define to 1 if va_list is an array])
44fi 35fi
45 36