From patchwork Fri Nov 3 23:50:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 834143 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-86758-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="F7dLCeSp"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yTJcp4WG7z9sNr for ; Sat, 4 Nov 2017 10:51:06 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; q=dns; s=default; b=gclb0wLrIYSsfoI0WmyxMP7duztx9 PrrDZH1dR24V8skb6gjFuM9Wpfo6gxQdSY1xMBdn/SOj1pILztXBMxihwTjv/03Q Fgrx31h6R3RJWJBOAzkmdp+USNSC7igv9ISxLqjEUqgRuhVZM++6x2vip/B8BsXs Q8irv9f+CiEKdA= 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:date:from:to:subject:message-id:mime-version :content-type; s=default; bh=ctQlWqCNgyuwfkglvDR/qGi3TXk=; b=F7d LCeSpkAU2lIX4TM0noS1i7FDlYCiptugvGqs3OfSreWEIV3DHSP80dzjuEm1GFVy qkgLhcOvIP2GAVVTUkNkHEXwjzNjteVZjLUJQ3xadKXIKnbvY40vdDSXcYq4mW2t 6a9H1so2mjJTSlWdFl4thZl3YEsE1CPdiZ7biVos= Received: (qmail 88791 invoked by alias); 3 Nov 2017 23:50:59 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 88782 invoked by uid 89); 3 Nov 2017 23:50:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS, URIBL_RED autolearn=ham version=3.3.2 spammy= X-HELO: relay1.mentorg.com Date: Fri, 3 Nov 2017 23:50:49 +0000 From: Joseph Myers To: Subject: Handle more _FloatN, _FloatNx types in __MATH_TG [committed] Message-ID: User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To SVR-IES-MBX-03.mgc.mentorg.com (139.181.222.3) Continuing the preparation for additional _FloatN / _FloatNx type support, this patch prepares __MATH_TG to handle more such types. Various unhandled cases, which do not correspond to any current glibc configuration, have explicit #errors added. _Float32 and _Float64x are then handled appropriately in the _Generic case, which is the only one, other than the cases where use of sizeof is sufficient, where they should ever be explicit types at the language level instead of typedefs. There is no need to handle _Float64 or _Float32x explicitly there because the default case calling a double function is correct for those types. Tested for x86_64. Committed. 2017-11-03 Joseph Myers * math/math.h [__HAVE_DISTINCT_FLOAT16 || __HAVE_DISTINCT_FLOAT32 || __HAVE_DISTINCT_FLOAT64 || __HAVE_DISTINCT_FLOAT32X || __HAVE_DISTINCT_FLOAT64X || __HAVE_DISTINCT_FLOAT128X]: Use #error. [__NO_LONG_DOUBLE_MATH && __HAVE_DISTINCT_FLOAT128]: Likewise. [__HAVE_DISTINCT_FLOAT128 && !__HAVE_GENERIC_SELECTION && __HAVE_FLOATN_NOT_TYPEDEF]: Likewise. [__HAVE_DISTINCT_FLOAT128 && __HAVE_GENERIC_SELECTION] (__MATH_TG_F32): New macro. [__HAVE_DISTINCT_FLOAT128 && __HAVE_GENERIC_SELECTION] (__MATH_TG_F64X): Likewise. [__HAVE_DISTINCT_FLOAT128 && __HAVE_GENERIC_SELECTION] (__MATH_TG): Use __MATH_TG_F32 and __MATH_TG_F64X. diff --git a/math/math.h b/math/math.h index 326fd8e..f6d1fee 100644 --- a/math/math.h +++ b/math/math.h @@ -489,6 +489,14 @@ extern long double __REDIRECT_NTH (nexttowardl, extern int signgam; #endif +#if (__HAVE_DISTINCT_FLOAT16 \ + || __HAVE_DISTINCT_FLOAT32 \ + || __HAVE_DISTINCT_FLOAT64 \ + || __HAVE_DISTINCT_FLOAT32X \ + || __HAVE_DISTINCT_FLOAT64X \ + || __HAVE_DISTINCT_FLOAT128X) +# error "Unsupported _FloatN or _FloatNx types for ." +#endif /* Depending on the type of TG_ARG, call an appropriately suffixed version of FUNC with arguments (including parentheses) ARGS. @@ -500,17 +508,39 @@ extern int signgam; return the same type (FUNC may include a cast if necessary rather than being a single identifier). */ #ifdef __NO_LONG_DOUBLE_MATH +# if __HAVE_DISTINCT_FLOAT128 +# error "Distinct _Float128 without distinct long double not supported." +# endif # define __MATH_TG(TG_ARG, FUNC, ARGS) \ (sizeof (TG_ARG) == sizeof (float) ? FUNC ## f ARGS : FUNC ARGS) #elif __HAVE_DISTINCT_FLOAT128 # if __HAVE_GENERIC_SELECTION -# define __MATH_TG(TG_ARG, FUNC, ARGS) \ +# if __HAVE_FLOATN_NOT_TYPEDEF && __HAVE_FLOAT32 +# define __MATH_TG_F32(FUNC, ARGS) _Float32: FUNC ## f ARGS, +# else +# define __MATH_TG_F32(FUNC, ARGS) +# endif +# if __HAVE_FLOATN_NOT_TYPEDEF && __HAVE_FLOAT64X +# if __HAVE_FLOAT64X_LONG_DOUBLE +# define __MATH_TG_F64X(FUNC, ARGS) _Float64x: FUNC ## l ARGS, +# else +# define __MATH_TG_F64X(FUNC, ARGS) _Float64x: FUNC ## f128 ARGS, +# endif +# else +# define __MATH_TG_F64X(FUNC, ARGS) +# endif +# define __MATH_TG(TG_ARG, FUNC, ARGS) \ _Generic ((TG_ARG), \ float: FUNC ## f ARGS, \ + __MATH_TG_F32 (FUNC, ARGS) \ default: FUNC ARGS, \ long double: FUNC ## l ARGS, \ + __MATH_TG_F64X (FUNC, ARGS) \ _Float128: FUNC ## f128 ARGS) # else +# if __HAVE_FLOATN_NOT_TYPEDEF +# error "Non-typedef _FloatN but no _Generic." +# endif # define __MATH_TG(TG_ARG, FUNC, ARGS) \ __builtin_choose_expr \ (__builtin_types_compatible_p (__typeof (TG_ARG), float), \