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