From patchwork Wed Nov 21 13:51:44 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 200765 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 285EC2C0079 for ; Thu, 22 Nov 2012 00:52:06 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1354110727; h=Comment: DomainKey-Signature:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=7yudRfj r0rCCyeJevHBAowjr8/s=; b=HeSkTuaKZUSTNGjEIeb03F6w7bmLMd/2EWxS4Bt 4XDpacXAegfOiob4JyWGZGhO8Cx+YMjTTzDewCzvpWLBaH7zh8dvkduQ4NTtGrTt hKQ5c+yUKnxpgKqT/5BF8IQxriWn5LkIV37LrCvIHNLJkcsmWkozHq+XA9va6efi X5Q0= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=Kzzug+fhl2l/8nJ8sggmkFqz+t9LiyY6UH2F77OGM7ud85hLyk8FKsCDPDZL72 ndZBc8gwTLK8XUqUNbmIn0TblqDntr+VTu47oOh0ergcM7VG6vNGhSawjRFZrJ81 Wp+AxAp6txAIA1eDx3MvXtnP7iS08SCrpiTX174CHp7JQ=; Received: (qmail 13980 invoked by alias); 21 Nov 2012 13:51:57 -0000 Received: (qmail 13964 invoked by uid 22791); 21 Nov 2012 13:51:55 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from mx02.qsc.de (HELO mx02.qsc.de) (213.148.130.14) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 21 Nov 2012 13:51:47 +0000 Received: from [192.168.178.25] (port-92-195-100-57.dynamic.qsc.de [92.195.100.57]) by mx02.qsc.de (Postfix) with ESMTP id 9D81027646; Wed, 21 Nov 2012 14:51:44 +0100 (CET) Message-ID: <50ACDC70.1010408@net-b.de> Date: Wed, 21 Nov 2012 14:51:44 +0100 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121025 Thunderbird/16.0.2 MIME-Version: 1.0 To: gcc patches Subject: [libquadmath, patch, committed] PR55225: Add a configure check whether math.h has signgam Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org POSIX's lgamma uses signgam – and hence has "extern int signgam" in math.h. However, C99's lgamma doesn't mention signgam – and systems exist where math.h doesn't include it. Solution: A configure check. Comitted as Rev. 193695. Tobias 2012-11-21 Tobias Burnus PR libquadmath/55225 * math/lgammaq.c (lgammaq): Use local variable if math.h does not provide signgam. * acinclude.m4 (LIBQUAD_CHECK_MATH_H_SIGNGAM): New check. * configure.ac: Use it. * configure: Regenerate. * config.h.in: Regenerate. diff --git a/libquadmath/acinclude.m4 b/libquadmath/acinclude.m4 index 38e0808..ab73fb5 100644 --- a/libquadmath/acinclude.m4 +++ b/libquadmath/acinclude.m4 @@ -10,3 +10,20 @@ AC_DEFUN([AM_PROG_LIBTOOL]) AC_DEFUN([AC_LIBTOOL_DLOPEN]) AC_DEFUN([AC_PROG_LD]) ]) + +dnl Check whether POSIX's signgam is defined in math.h. +AC_DEFUN([LIBQUAD_CHECK_MATH_H_SIGNGAM], [ + AC_CACHE_CHECK([whether the math.h includes POSIX's signgam], + libgfor_cv_have_math_h_signgam, [ + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -Werror" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include +void foo(void) { signgam = 1; }]], [])], + libgfor_cv_have_math_h_signgam=yes, + libgfor_cv_have_math_h_signgam=no) + CFLAGS="$save_CFLAGS"]) + if test $libgfor_cv_have_math_h_signgam = yes; then + AC_DEFINE(HAVE_MATH_H_SIGNGAM, 1, + [Define to 1 if the math.h includes POSIX's signgam.]) + fi]) diff --git a/libquadmath/configure.ac b/libquadmath/configure.ac index d3bfb04..c547da8 100644 --- a/libquadmath/configure.ac +++ b/libquadmath/configure.ac @@ -113,6 +113,7 @@ AC_SUBST(toolexecdir) AC_SUBST(toolexeclibdir) AC_CHECK_HEADERS(fenv.h langinfo.h locale.h wchar.h wctype.h limits.h ctype.h printf.h errno.h) +LIBQUAD_CHECK_MATH_H_SIGNGAM # If available, sqrtl and cbrtl speed up the calculation - # but they are not required diff --git a/libquadmath/math/lgammaq.c b/libquadmath/math/lgammaq.c index 485939a..eef62db 100644 --- a/libquadmath/math/lgammaq.c +++ b/libquadmath/math/lgammaq.c @@ -69,7 +69,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "quadmath-imp.h" -#include /* For extern int signgam. */ + +#ifdef HAVE_MATH_H_SIGNGAM +#include /* For POSIX's extern int signgam. */ +#endif static const __float128 PIQ = 3.1415926535897932384626433832795028841972E0Q; static const __float128 MAXLGM = 1.0485738685148938358098967157129705071571E4928Q; @@ -759,6 +762,9 @@ lgammaq (__float128 x) { __float128 p, q, w, z, nx; int i, nn; +#ifndef HAVE_MATH_H_SIGNGAM + int signgam; +#endif signgam = 1; diff --git a/libquadmath/config.h.in b/libquadmath/config.h.in index ea3f10c..9d18cc3 100644 --- a/libquadmath/config.h.in +++ b/libquadmath/config.h.in @@ -45,6 +45,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_LOCALE_H +/* Define to 1 if the math.h includes POSIX's signgam. */ +#undef HAVE_MATH_H_SIGNGAM + /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H diff --git a/libquadmath/configure b/libquadmath/configure index 1677671..0ea6e07 100755 --- a/libquadmath/configure +++ b/libquadmath/configure @@ -11947,6 +11947,43 @@ fi done + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the math.h includes POSIX's signgam" >&5 +$as_echo_n "checking whether the math.h includes POSIX's signgam... " >&6; } +if test "${libgfor_cv_have_math_h_signgam+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -Werror" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +void foo(void) { signgam = 1; } +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + libgfor_cv_have_math_h_signgam=yes +else + libgfor_cv_have_math_h_signgam=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS="$save_CFLAGS" +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libgfor_cv_have_math_h_signgam" >&5 +$as_echo "$libgfor_cv_have_math_h_signgam" >&6; } + if test $libgfor_cv_have_math_h_signgam = yes; then + +$as_echo "#define HAVE_MATH_H_SIGNGAM 1" >>confdefs.h + + fi + # If available, sqrtl and cbrtl speed up the calculation - # but they are not required if test x$gcc_no_link != xyes; then