edbus codegen: Initial commit
[platform/upstream/eldbus.git] / m4 / ac_valist.m4
1 dnl That code is public domain and can be freely used or copied.
2 dnl Originally snatched from somewhere...
3
4 dnl Macro for checking if va_list is an array
5
6 dnl Usage: AC_C_VA_LIST_AS_ARRAY
7 dnl call AC_DEFINE for HAVE_VA_LIST_AS_ARRAY
8 dnl if for this architecture va_list is defined as an array
9
10 AC_DEFUN([AC_C_VA_LIST_AS_ARRAY],
11 [
12
13 AC_MSG_CHECKING([whether va_list is defined as an array])
14
15 AC_CACHE_VAL([ac_cv_valistasarray],
16    [AC_TRY_RUN(
17        [
18 #include <stdlib.h>
19 #include <stdarg.h>
20 void foo(int i, ...)
21 {
22         va_list ap1, ap2;
23         va_start(ap1, i);
24         ap2 = ap1;
25         if (va_arg(ap2, int) != 123 || va_arg(ap1, int) != 123)
26                 exit(1);
27         va_end(ap1);
28 }
29 int main(void)
30 {
31         foo(0, 123);
32         return(0);
33 }
34        ],
35        [ac_cv_valistasarray="no"],
36        [ac_cv_valistasarray="yes"],
37        [ac_cv_valistasarray="no"]
38     )])
39
40 AC_MSG_RESULT($ac_cv_valistasarray)
41
42 if 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])
44 fi
45
46 ])
47
48 dnl End of ac_valist.m4