From patchwork Fri Nov 3 21:12:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 834108 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-86723-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="DyKodaxK"; 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 3yTF6b6xXCz9s81 for ; Sat, 4 Nov 2017 08:13:11 +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=JL2P1sTWR5Rg+92XEQFHM8qDIioZT RL9++pTDn8CAWXyorD5Hyht1auxT99v7Ai+SCmZQHAQX+t4NPdZn3+7A25eIe+jG A/MsjNYv2+W6U0MLFfGZwh+ZYRNbKrApfgrZuU4HmGEJSnsCCeKjeDJbwYjflOAv 9hEOP+b2rz67AA= 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=XfRQ8gT1LXvIesydsCarS5xPhsc=; b=DyK odaxKeZxMoTwgl7YzaK3z47ir+igKbIP8elu4C5h29aRfiogO3r4owqHvisDID6Z Z6ifFfHupFkv7CNARhFNTRtfhqznU85s2yleKaO7fmwtG77nibQc6tOIPm2h/GaV SP+sddao3jjZ2wXYvqmhWmc6PIwto92Y4m5YIzlA= Received: (qmail 114701 invoked by alias); 3 Nov 2017 21:13:03 -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 114060 invoked by uid 89); 3 Nov 2017 21:13:03 -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 21:12:53 +0000 From: Joseph Myers To: Subject: Handle more _FloatN, _FloatNx types in tgmath.h [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 improves how handles such types. Use of #error is added for cases of distinct types that are not supported by the header, to indicate that additional work on the header would be needed if, for example, _Float16 support were added to glibc. Given that #error, types with the same format as other types are handled automatically by the sizeof-based logic, so the only case needing special handling is that where _Float64x exists, has the same format as _Float128, does not have the same format as long double, and is not a typedef for _Float128. In this case (which will apply for powerpc64le once _Float64x support is added to glibc), the __builtin_types_compatible_p calls testing for _Float128 need corresponding calls testing for _Float64x, which this patch adds. Tested for x86_64. Committed. 2017-11-03 Joseph Myers * math/tgmath.h [__HAVE_DISTINCT_FLOAT16 || __HAVE_DISTINCT_FLOAT32 || __HAVE_DISTINCT_FLOAT64 || __HAVE_DISTINCT_FLOAT32X || __HAVE_DISTINCT_FLOAT64X || __HAVE_DISTINCT_FLOAT128X]: Use #error. [__HAVE_DISTINCT_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT) && __HAVE_FLOAT64X && !__HAVE_FLOAT64X_LONG_DOUBLE && __HAVE_FLOATN_NOT_TYPEDEF] (__TGMATH_F128): Handle _Float64x the same as _Float128. [__HAVE_DISTINCT_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT) && __HAVE_FLOAT64X && !__HAVE_FLOAT64X_LONG_DOUBLE && __HAVE_FLOATN_NOT_TYPEDEF] (__TGMATH_CF128): Likewise. diff --git a/math/tgmath.h b/math/tgmath.h index 243813c..108c1a1 100644 --- a/math/tgmath.h +++ b/math/tgmath.h @@ -115,18 +115,45 @@ __real_integer_type (__typeof__ (+(expr))), \ __complex_integer_type (__typeof__ (+(expr)))) +# 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 + /* Expand to text that checks if ARG_COMB has type _Float128, and if so calls the appropriately suffixed FCT (which may include a cast), or FCT and CFCT for complex functions, with arguments ARG_CALL. */ # if __HAVE_DISTINCT_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT) -# define __TGMATH_F128(arg_comb, fct, arg_call) \ +# if (!__HAVE_FLOAT64X \ + || __HAVE_FLOAT64X_LONG_DOUBLE \ + || !__HAVE_FLOATN_NOT_TYPEDEF) +# define __TGMATH_F128(arg_comb, fct, arg_call) \ __builtin_types_compatible_p (__typeof (+(arg_comb)), _Float128) \ ? fct ## f128 arg_call : -# define __TGMATH_CF128(arg_comb, fct, cfct, arg_call) \ +# define __TGMATH_CF128(arg_comb, fct, cfct, arg_call) \ __builtin_types_compatible_p (__typeof (+__real__ (arg_comb)), _Float128) \ ? (__expr_is_real (arg_comb) \ ? fct ## f128 arg_call \ : cfct ## f128 arg_call) : +# else +/* _Float64x is a distinct type at the C language level, which must be + handled like _Float128. */ +# define __TGMATH_F128(arg_comb, fct, arg_call) \ + (__builtin_types_compatible_p (__typeof (+(arg_comb)), _Float128) \ + || __builtin_types_compatible_p (__typeof (+(arg_comb)), _Float64x)) \ + ? fct ## f128 arg_call : +# define __TGMATH_CF128(arg_comb, fct, cfct, arg_call) \ + (__builtin_types_compatible_p (__typeof (+__real__ (arg_comb)), _Float128) \ + || __builtin_types_compatible_p (__typeof (+__real__ (arg_comb)), \ + _Float64x)) \ + ? (__expr_is_real (arg_comb) \ + ? fct ## f128 arg_call \ + : cfct ## f128 arg_call) : +# endif # else # define __TGMATH_F128(arg_comb, fct, arg_call) /* Nothing. */ # define __TGMATH_CF128(arg_comb, fct, cfct, arg_call) /* Nothing. */