Debian Codegraph @

m4/module-defs.m4

raw
1 dnl Copyright (c) 2008 The NetBSD Foundation, Inc.
2 dnl All rights reserved.
3 dnl
4 dnl Redistribution and use in source and binary forms, with or without
5 dnl modification, are permitted provided that the following conditions
6 dnl are met:
7 dnl 1. Redistributions of source code must retain the above copyright
8 dnl notice, this list of conditions and the following disclaimer.
9 dnl 2. Redistributions in binary form must reproduce the above copyright
10 dnl notice, this list of conditions and the following disclaimer in the
11 dnl documentation and/or other materials provided with the distribution.
12 dnl
13 dnl THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
14 dnl CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
15 dnl INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16 dnl MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 dnl IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
18 dnl DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 dnl DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
20 dnl GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 dnl INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
22 dnl IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23 dnl OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
24 dnl IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
26 AC_DEFUN([ATF_ATTRIBUTE_FORMAT_PRINTF], [
27 AC_MSG_CHECKING(
28 [whether __attribute__((__format__(__printf__, a, b))) is supported])
29 AC_COMPILE_IFELSE(
30 [AC_LANG_PROGRAM([
31 #include <stdarg.h>
32 #include <stdio.h>
33
34 static void test_printf(const char *, ...)
35 __attribute__((__format__(__printf__, 1, 2)));
36
37 static void
38 test_printf(const char *format, ...)
39 {
40 va_list ap;
41
42 va_start(ap, format);
43 vprintf(format, ap);
44 va_end(ap);
45 }], [
46 test_printf("foo %s", "bar");
47 return 0;
48 ])],
49 [AC_MSG_RESULT(yes)
50 value="__attribute__((__format__(__printf__, a, b)))"],
51 [AC_MSG_RESULT(no)
52 value=""]
53 )
54 AC_SUBST([ATTRIBUTE_FORMAT_PRINTF], [${value}])
55 ])
56
57 AC_DEFUN([ATF_ATTRIBUTE_NORETURN], [
58 dnl XXX This check is overly simple and should be fixed. For example,
59 dnl Sun's cc does support the noreturn attribute but CC (the C++
60 dnl compiler) does not. And in that case, CC just raises a warning
61 dnl during compilation, not an error, which later breaks the
62 dnl atf-c++/t_pkg_config:cxx_build check.
63 AC_CACHE_CHECK(
64 [whether __attribute__((__noreturn__)) is supported],
65 [kyua_cv_attribute_noreturn], [
66 AC_RUN_IFELSE(
67 [AC_LANG_PROGRAM([], [
68 #if ((__GNUC__ == 2 && __GNUC_MINOR__ >= 5) || __GNUC__ > 2)
69 return 0;
70 #else
71 return 1;
72 #endif
73 ])],
74 [kyua_cv_attribute_noreturn=yes],
75 [kyua_cv_attribute_noreturn=no])
76 ])
77 if test x"${kyua_cv_attribute_noreturn}" = xyes; then
78 value="__attribute__((__noreturn__))"
79 else
80 value=""
81 fi
82 AC_SUBST([ATTRIBUTE_NORETURN], [${value}])
83 ])
84
85 AC_DEFUN([ATF_ATTRIBUTE_UNUSED], [
86 AC_MSG_CHECKING(whether __attribute__((__unused__)) is supported)
87 AC_COMPILE_IFELSE(
88 [AC_LANG_PROGRAM([
89 static void
90 function(int a __attribute__((__unused__)))
91 {
92 }], [
93 function(3);
94 return 0;
95 ])],
96 [AC_MSG_RESULT(yes)
97 value="__attribute__((__unused__))"],
98 [AC_MSG_RESULT(no)
99 value=""]
100 )
101 AC_SUBST([ATTRIBUTE_UNUSED], [${value}])
102 ])
103
104 AC_DEFUN([ATF_MODULE_DEFS], [
105 ATF_ATTRIBUTE_FORMAT_PRINTF
106 ATF_ATTRIBUTE_NORETURN
107 ATF_ATTRIBUTE_UNUSED
108 ])