1dnl Copyright 2010 The Kyua Authors. 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 are 6dnl met: 7dnl 8dnl * Redistributions of source code must retain the above copyright 9dnl notice, this list of conditions and the following disclaimer. 10dnl * Redistributions in binary form must reproduce the above copyright 11dnl notice, this list of conditions and the following disclaimer in the 12dnl documentation and/or other materials provided with the distribution. 13dnl * Neither the name of Google Inc. nor the names of its contributors 14dnl may be used to endorse or promote products derived from this software 15dnl without specific prior written permission. 16dnl 17dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18dnl "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19dnl LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20dnl A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21dnl OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22dnl SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23dnl LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24dnl DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25dnl THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26dnl (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27dnl OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 29dnl 30dnl KYUA_ATTRIBUTE_NORETURN 31dnl 32dnl Checks if the current compiler has a way to mark functions that do not 33dnl return and defines ATTRIBUTE_NORETURN to the appropriate string. 34dnl 35AC_DEFUN([KYUA_ATTRIBUTE_NORETURN], [ 36 dnl This check is overly simple and should be fixed. For example, 37 dnl Sun's cc does support the noreturn attribute but CC (the C++ 38 dnl compiler) does not. And in that case, CC just raises a warning 39 dnl during compilation, not an error. 40 AC_CACHE_CHECK( 41 [whether __attribute__((noreturn)) is supported], 42 [kyua_cv_attribute_noreturn], [ 43 AC_RUN_IFELSE([AC_LANG_PROGRAM([], [ 44#if ((__GNUC__ == 2 && __GNUC_MINOR__ >= 5) || __GNUC__ > 2) 45 return 0; 46#else 47 return 1; 48#endif 49 ])], 50 [kyua_cv_attribute_noreturn=yes], 51 [kyua_cv_attribute_noreturn=no]) 52 ]) 53 if test "${kyua_cv_attribute_noreturn}" = yes; then 54 attribute_value="__attribute__((noreturn))" 55 else 56 attribute_value="" 57 fi 58 AC_SUBST([ATTRIBUTE_NORETURN], [${attribute_value}]) 59]) 60 61 62dnl 63dnl KYUA_ATTRIBUTE_PURE 64dnl 65dnl Checks if the current compiler has a way to mark functions as pure. 66dnl 67AC_DEFUN([KYUA_ATTRIBUTE_PURE], [ 68 AC_CACHE_CHECK( 69 [whether __attribute__((__pure__)) is supported], 70 [kyua_cv_attribute_pure], [ 71 AC_COMPILE_IFELSE( 72 [AC_LANG_PROGRAM([ 73static int function(int, int) __attribute__((__pure__)); 74 75static int 76function(int a, int b) 77{ 78 return a + b; 79}], [ 80 return function(3, 4); 81])], 82 [kyua_cv_attribute_pure=yes], 83 [kyua_cv_attribute_pure=no]) 84 ]) 85 if test "${kyua_cv_attribute_pure}" = yes; then 86 attribute_value="__attribute__((__pure__))" 87 else 88 attribute_value="" 89 fi 90 AC_SUBST([ATTRIBUTE_PURE], [${attribute_value}]) 91]) 92 93 94dnl 95dnl KYUA_ATTRIBUTE_UNUSED 96dnl 97dnl Checks if the current compiler has a way to mark parameters as unused 98dnl so that the -Wunused-parameter warning can be avoided. 99dnl 100AC_DEFUN([KYUA_ATTRIBUTE_UNUSED], [ 101 AC_CACHE_CHECK( 102 [whether __attribute__((__unused__)) is supported], 103 [kyua_cv_attribute_unused], [ 104 AC_COMPILE_IFELSE( 105 [AC_LANG_PROGRAM([ 106static void 107function(int a __attribute__((__unused__))) 108{ 109}], [ 110 function(3); 111 return 0; 112])], 113 [kyua_cv_attribute_unused=yes], 114 [kyua_cv_attribute_unused=no]) 115 ]) 116 if test "${kyua_cv_attribute_unused}" = yes; then 117 attribute_value="__attribute__((__unused__))" 118 else 119 attribute_value="" 120 fi 121 AC_SUBST([ATTRIBUTE_UNUSED], [${attribute_value}]) 122]) 123