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