1
##### http://autoconf-archive.cryp.to/ax_c_referenceable_passed_va_list.html
5
# AX_C_REFERENCEABLE_PASSED_VA_LIST
9
# Checks whether f(va_list va){ &va; } works as expected.
11
# This macro uses compile-time detection and so is cross-compile
14
# C99 mentioned passing a pointer to va_list to other functions
15
# (footnote 212 of "7.15 Variable arguments <stdarg.h>"). However,
16
# f(va_list va) { &va; } produces broken pointer on some environments
17
# such as gcc on x86_64, although { va_list va; &va; } works as
18
# expected. See the detection code of this file and any of pages
19
# http://www.gnu.org/software/autoconf/manual/html_node/Function-Portability.html,
20
# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14557, and
21
# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20951 for further
24
# Although C99 does not define the operations f(va_list va) { &va; }
25
# and &va itself as standard (footnotes are declared as "normative
26
# part, information only"), certain situations need it. This macro
27
# provides a type detection about va_list implementation to deal with
30
# Following workaround will probably work on such environments
31
# although it does not ensure to be safe and portable. At least it is
32
# working on x86_64-unknown-linux-gnu:
38
# #if HAVE_REFERENCEABLE_PASSED_VA_LIST
41
# vap = (va_list *)va;
51
# Copyright (c) 2006 YAMAMOTO Kengo <yamaken AT bp.iij4u.or.jp>
53
# Copying and distribution of this file, with or without
54
# modification, are permitted in any medium without royalty provided
55
# the copyright notice and this notice are preserved.
57
AC_DEFUN([AX_C_REFERENCEABLE_PASSED_VA_LIST], [
58
AC_CACHE_CHECK([whether f(va_list va){ &va; } works as expected],
59
[ax_cv_c_referenceable_passed_va_list],
63
volatile va_list g_va;
68
/* typeof(callee_va) differs from typeof(caller_va) by a compiler trick, if
69
* va_list is implemented as an array. On such environment, this copy
79
va_start(caller_va, last);
80
vf(caller_va); /* passed as &caller_va[0] if va_list is an array type */
85
main(int argc, char *argv[])
87
f(0xdeadbeef, 0xfedbeef, 0xfeedee);
92
[ax_cv_c_referenceable_passed_va_list=yes],
93
[ax_cv_c_referenceable_passed_va_list=no])])
94
if test "x$ax_cv_c_referenceable_passed_va_list" = xyes; then
95
AC_DEFINE([HAVE_REFERENCEABLE_PASSED_VA_LIST], [1],
96
[Define to 1 if f(va_list va){ &va; } works as expected.])