From patchwork Mon Apr 4 19:27:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yaakov Selkowitz X-Patchwork-Id: 65028 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp64760lbc; Mon, 4 Apr 2016 12:27:55 -0700 (PDT) X-Received: by 10.66.192.195 with SMTP id hi3mr55689100pac.149.1459798075080; Mon, 04 Apr 2016 12:27:55 -0700 (PDT) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id n5si2243223paq.141.2016.04.04.12.27.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Apr 2016 12:27:55 -0700 (PDT) Received-SPF: pass (google.com: domain of newlib-return-13443-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org; spf=pass (google.com: domain of newlib-return-13443-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=newlib-return-13443-patch=linaro.org@sourceware.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=w3bEQNm90PYpXnKZEXuzYOMDzpdCwle aNBFKNrk1Ss5aKJNJvzClwv5w9tqdhxkwNb+cS/DVue5j3dVpJJNtHj3Zsb4ytMc 2dR/u1x2/zrcOfjLysyJ2ujtgKe9Z+q0qw0VbMsT7mDViIAZrLCDA30RlhhCIpIc LTLAyTh4X+lA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=PZSk6az5WKc+CY1TfOEDvbUJAFo=; b=i5K75 U0GVQdtIyHDVgXuapB994mpTeyLxQj2o3SP+tZZPt7CbW5+c+Cmuxb34H4oHAdFi sJfm/zTd5G7KzGHYwBmZDon3CkX9ALY4/PJ1Gx09TD+AYc4KersSSiJUoTCTiqoH Gr0qvu/+oLhNMkTqxPJ+lpixahETpukibbdKs0= Received: (qmail 49476 invoked by alias); 4 Apr 2016 19:27:45 -0000 Mailing-List: contact newlib-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: newlib-owner@sourceware.org Delivered-To: mailing list newlib@sourceware.org Received: (qmail 49460 invoked by uid 89); 4 Apr 2016 19:27:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=UD:glibc.git, glibcgit, glibc.git, functioning X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 04 Apr 2016 19:27:28 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5B4DF804E2 for ; Mon, 4 Apr 2016 19:27:27 +0000 (UTC) Received: from localhost.localdomain (ovpn-116-26.rdu2.redhat.com [10.10.116.26]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u34JRQaK003775 (version=TLSv1/SSLv3 cipher=AES256-SHA256 bits=256 verify=NO) for ; Mon, 4 Apr 2016 15:27:26 -0400 From: Yaakov Selkowitz To: newlib@sourceware.org Subject: [PATCH v2] math: guard BSD finite/isinf/isnan functions properly in math.h Date: Mon, 4 Apr 2016 14:27:10 -0500 Message-Id: <1459798030-10720-1-git-send-email-yselkowi@redhat.com> In-Reply-To: <1459550970-3424-1-git-send-email-yselkowi@redhat.com> References: <1459550970-3424-1-git-send-email-yselkowi@redhat.com> Now that we have properly functioning feature test macros, the BSD floating-point classification functions can go into math.h instead of the non-standard ieeefp.h, and not under the C99 guard: http://man7.org/linux/man-pages/man3/finite.3.html The isnan function was in earlier versions of SUS but removed starting with POSIX.1-2001, compare: http://pubs.opengroup.org/onlinepubs/007908799/xsh/math.h.html http://pubs.opengroup.org/onlinepubs/009695399/basedefs/math.h.html Note that the isinf and isnan functions (but not the variants) conflict with functions by the same name in C++11, hence they (and only they) need to be hidden: https://sourceware.org/git/?p=glibc.git;a=commit;h=d9b965fa56350d6eea9f7f438a0714c7ffbb183f https://sourceware.org/git/?p=glibc.git;a=commit;h=3c47c83a9730c20e602694505b9278c25637b0d0 Signed-off-by: Yaakov Selkowitz --- newlib/libc/include/ieeefp.h | 13 ------------- newlib/libc/include/math.h | 25 +++++++++++++++++++------ 2 files changed, 19 insertions(+), 19 deletions(-) -- 2.7.4 diff --git a/newlib/libc/include/ieeefp.h b/newlib/libc/include/ieeefp.h index 2ffa456..2c04284 100644 --- a/newlib/libc/include/ieeefp.h +++ b/newlib/libc/include/ieeefp.h @@ -241,19 +241,6 @@ typedef int fp_rdi; fp_rdi _EXFUN(fpgetroundtoi,(void)); fp_rdi _EXFUN(fpsetroundtoi,(fp_rdi)); -#undef isnan -#undef isinf - -int _EXFUN(isnan, (double)); -int _EXFUN(isinf, (double)); -int _EXFUN(finite, (double)); - - - -int _EXFUN(isnanf, (float)); -int _EXFUN(isinff, (float)); -int _EXFUN(finitef, (float)); - #define __IEEE_DBL_EXPBIAS 1023 #define __IEEE_FLT_EXPBIAS 127 diff --git a/newlib/libc/include/math.h b/newlib/libc/include/math.h index e5d6123..798fc6d 100644 --- a/newlib/libc/include/math.h +++ b/newlib/libc/include/math.h @@ -137,6 +137,25 @@ extern double fmod _PARAMS((double, double)); #endif /* ! defined (__math_68881) */ #endif /* ! defined (_REENT_ONLY) */ +#if __MISC_VISIBLE +extern int finite _PARAMS((double)); +extern int finitef _PARAMS((float)); +extern int finitel _PARAMS((long double)); +extern int isinff _PARAMS((float)); +extern int isnanf _PARAMS((float)); +#ifdef __CYGWIN__ /* not implemented in newlib yet */ +extern int isinfl _PARAMS((long double)); +extern int isnanl _PARAMS((long double)); +#endif +#if !defined(__cplusplus) || __cplusplus < 201103L +extern int isinf _PARAMS((double)); +#endif +#endif /* __MISC_VISIBLE */ +#if (__MISC_VISIBLE || (__XSI_VISIBLE && __XSI_VISIBLE < 600)) \ + && (!defined(__cplusplus) || __cplusplus < 201103L) +extern int isnan _PARAMS((double)); +#endif + #if __ISO_C_VISIBLE >= 1999 /* ISO C99 types and macros. */ @@ -289,15 +308,10 @@ extern int __signbitd (double x); fpclassify(__a) == FP_NAN || fpclassify(__b) == FP_NAN;})) #endif -/* Non ANSI long double precision functions. */ - -extern int finitel _PARAMS((long double)); - /* Non ANSI double precision functions. */ extern double infinity _PARAMS((void)); extern double nan _PARAMS((const char *)); -extern int finite _PARAMS((double)); extern double copysign _PARAMS((double, double)); extern double logb _PARAMS((double)); extern int ilogb _PARAMS((double)); @@ -396,7 +410,6 @@ extern float fmaf _PARAMS((float, float, float)); extern float infinityf _PARAMS((void)); extern float nanf _PARAMS((const char *)); -extern int finitef _PARAMS((float)); extern float copysignf _PARAMS((float, float)); extern float logbf _PARAMS((float)); extern int ilogbf _PARAMS((float));