~ubuntu-branches/ubuntu/hardy/uim/hardy

« back to all changes in this revision

Viewing changes to sigscheme/m4/ax_c_referenceable_passed_va_list.m4

  • Committer: Bazaar Package Importer
  • Author(s): Masahito Omote
  • Date: 2007-04-21 03:46:09 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20070421034609-gpcurkutp8vaysqj
Tags: 1:1.4.1-3
* Switch to dh_gtkmodules for the gtk 2.10 transition (Closes:
  #419318)
  - debian/control: Add ${misc:Depends} and remove libgtk2.0-bin on
    uim-gtk2.0.
  - debian/uim-gtk2.0.post{inst,rm}: Removed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
##### http://autoconf-archive.cryp.to/ax_c_referenceable_passed_va_list.html
 
2
#
 
3
# SYNOPSIS
 
4
#
 
5
#   AX_C_REFERENCEABLE_PASSED_VA_LIST
 
6
#
 
7
# DESCRIPTION
 
8
#
 
9
#   Checks whether f(va_list va){ &va; } works as expected.
 
10
#
 
11
#   This macro uses compile-time detection and so is cross-compile
 
12
#   ready.
 
13
#
 
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
 
22
#   information.
 
23
#
 
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
 
28
#   the operation.
 
29
#
 
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:
 
33
#
 
34
#    f(va_list va)
 
35
#    {
 
36
#      va_list *vap;
 
37
#
 
38
#    #if HAVE_REFERENCEABLE_PASSED_VA_LIST
 
39
#        vap = &va;
 
40
#    #else
 
41
#        vap = (va_list *)va;
 
42
#    #endif
 
43
#    }
 
44
#
 
45
# LAST MODIFICATION
 
46
#
 
47
#   2006-12-12
 
48
#
 
49
# COPYLEFT
 
50
#
 
51
#   Copyright (c) 2006 YAMAMOTO Kengo <yamaken AT bp.iij4u.or.jp>
 
52
#
 
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.
 
56
 
 
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],
 
60
    [AC_LINK_IFELSE([[
 
61
#include <stdarg.h>
 
62
 
 
63
volatile va_list g_va;
 
64
 
 
65
void
 
66
vf(va_list callee_va)
 
67
{
 
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
 
70
   * operation fails. */
 
71
  g_va = callee_va;
 
72
}
 
73
 
 
74
void
 
75
f(int last, ...)
 
76
{
 
77
  va_list caller_va;
 
78
 
 
79
  va_start(caller_va, last);
 
80
  vf(caller_va);  /* passed as &caller_va[0] if va_list is an array type */
 
81
  va_end(caller_va);
 
82
}
 
83
 
 
84
int
 
85
main(int argc, char *argv[])
 
86
{
 
87
  f(0xdeadbeef, 0xfedbeef, 0xfeedee);
 
88
 
 
89
  return 0;
 
90
}
 
91
      ]],
 
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.])
 
97
  fi
 
98
])