1dnl Copyright (c) 2008 The NetBSD Foundation, Inc. 2dnl All rights reserved. 3dnl 4dnl Redistribution and use in source and binary forms, with or without 5dnl modification, are permitted provided that the following conditions 6dnl are met: 7dnl 1. Redistributions of source code must retain the above copyright 8dnl notice, this list of conditions and the following disclaimer. 9dnl 2. Redistributions in binary form must reproduce the above copyright 10dnl notice, this list of conditions and the following disclaimer in the 11dnl documentation and/or other materials provided with the distribution. 12dnl 13dnl THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND 14dnl CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 15dnl INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 16dnl MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17dnl IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY 18dnl DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19dnl DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 20dnl GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21dnl INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 22dnl IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23dnl OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 24dnl IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 26AC_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 34static void test_printf(const char *, ...) 35 __attribute__((__format__(__printf__, 1, 2))); 36 37static void 38test_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 57AC_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 85AC_DEFUN([ATF_ATTRIBUTE_UNUSED], [ 86 AC_MSG_CHECKING(whether __attribute__((__unused__)) is supported) 87 AC_COMPILE_IFELSE( 88 [AC_LANG_PROGRAM([ 89static void 90function(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 104AC_DEFUN([ATF_MODULE_DEFS], [ 105 ATF_ATTRIBUTE_FORMAT_PRINTF 106 ATF_ATTRIBUTE_NORETURN 107 ATF_ATTRIBUTE_UNUSED 108]) 109