From patchwork Thu Dec 28 17:20:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 758599 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp4114693wrw; Thu, 28 Dec 2023 09:21:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IGlbS0wx2KFt0ZtCnpjkZXzCcj6LB7JuHGj+oF4cCEk1Cec5CYQGlFCOx/ew91up/svYyWw X-Received: by 2002:a05:6808:298:b0:3bb:ce19:82b6 with SMTP id z24-20020a056808029800b003bbce1982b6mr1839295oic.40.1703784068348; Thu, 28 Dec 2023 09:21:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1703784068; cv=pass; d=google.com; s=arc-20160816; b=fkLrrB+3k936qm/WhlKO9l2AhHWN13Gjwyzdg0gKfqk3CuJlQymAyQ+VxmX2THKNFB XpeRLsSvnNGr6w2TOVhVi1YbtBsphmXSoFLlo8x9RV0W4URW7vLsLkGVjBGovWQj95sr m9eeJS2NL6gRDJrhet9h3SXF+fTSqWSWL4U8HXvJ4n+CWmq9nrGX7J3S1jBFEFJvE/MG rZE8x/Wt1rcWarQcawWGnapljnlolb3enLFU+DyXW3gNux4z0U6KNFHyuuyUuk0GAYym rfYgW33hEptkzDiqQGy7o8ZfPeRqWZ1c7oz7TCAg9wsoA1QUmkRoJBRyiVuC+To4ICIh incg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=m5Bjf8y1Be9hhOdfnd0D5Fk5Skb5ohpdAFSHnEcAXEE=; fh=dHLBnA+MhGtNtN2B2JMAELi4oD+gmgMg7DL8H0jYbkI=; b=YBzbsVMHiJD3M7TFfcaI2MlNfdU4y+DgqSSt1LbBjlBiECrTl155aG4G9gL+iC0iCZ +1TX94jRAtpp0xy5pgVF072RCUwx2BO6r8T5ss7SWfyYERc2ikyluKT4EAUlAq1z+sf+ lqu/3NCaXW7Qd6qC3Lp4fEUMtg5tRHhyW6Ubcnj5X84a1BJVkCT47KJVMCUK0lqm/Vg5 u79EH6evwlLcGjiKcVOOLHtgPzSQq3Vo+0pAeYb1+zIOslTC3KJcf/xJhPQtZWG0uBTT QIFS1VN2LAYwgzaO7JEKzLCMihiWTJQr3M1ORd3wD3IT1dCKLrHqdoEPuf+iiWqux+co ikJg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SXIQh2Uo; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id z12-20020a0cda8c000000b0067f74f4aa5asi18494862qvj.532.2023.12.28.09.21.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 09:21:08 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SXIQh2Uo; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E1A753858C3A for ; Thu, 28 Dec 2023 17:21:07 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-ot1-x335.google.com (mail-ot1-x335.google.com [IPv6:2607:f8b0:4864:20::335]) by sourceware.org (Postfix) with ESMTPS id 5BE973858C33 for ; Thu, 28 Dec 2023 17:20:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5BE973858C33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5BE973858C33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::335 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784038; cv=none; b=oh/2sAuv2BDrcHaQoSdjzgj7rvFaz9m9is0vwOe8EhanNaJrarEenOSeWPwLdfighTPM7SMc/ZCHqjAyFxEgSkNMv9gcfCvzqtdgQbCafrsffJ4nixDPOd/a78AOREX273TjdRIWWjDIGaqddQyMZhK1axx9DmawB+7qn286u2Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784038; c=relaxed/simple; bh=f6MCGGB7zrDe8wdKBZMhj1wcv4XtJ4IUloERqQsECqM=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=sPjX1GyftKVDw7rVCa0JYl1WsJo6Nh3Sy0b7zuGcfV7bn1bAYUMn+GpDDcDFB4dtqObfcgxysYyGgIX1HFOotvAMKgUu53G8TSZSuD24gvccQEVWlHgqUif6isHTD6SqS6RVFGNDkkSWczAL0eoQGDEZ2Z1yYzxLojUAerFD4Hc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ot1-x335.google.com with SMTP id 46e09a7af769-6dc1fdc19b6so326593a34.0 for ; Thu, 28 Dec 2023 09:20:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703784032; x=1704388832; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=m5Bjf8y1Be9hhOdfnd0D5Fk5Skb5ohpdAFSHnEcAXEE=; b=SXIQh2Uo35HR3DFRdJWMD3IaGiklujFacMy1fW7/dVCDpfHrHyIVYsjcgqxCZWI5I8 vc9D0huz+v1ROQjqOK4aWEdjqCgUCLMQP0Iy1QUJGQ4uUASIMCWnj9CZlkzlF6cLU6xL m11991iW9WgDSVRq6WzCNqB6W9g5rAdvW8rbWgId7tanReQbbLErKaQInnrhQrNie5ku 4wPhCNX/XaxVCeTlgbKBAicp7qoncR4PsaFpiw9IRuz9FW87qUxbs2bIHX4AZuUT7OfF UpWjsMb+h3Vq3TX346AUSiN7bgKPW1HcIAVtXC7u5bOoUA7WTujHYWyt8lPkpdVGARPV s4NQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703784032; x=1704388832; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=m5Bjf8y1Be9hhOdfnd0D5Fk5Skb5ohpdAFSHnEcAXEE=; b=rEi0Pq78I8swv+vkK2hUWTG7DOJskpF0ObDvGx6OZP69UhBdk6dsavFc6N3hasqYzL MMl+ehdI/30pnYidM6wz+urk540Prw8lcHzUNzRd0dvui4JZqiyC0L38jIYzTR9Nqbex 27k+yoJ/6N+VvjjebCXuSGq6WeeJsjJRi2RxLZhIFSQi3uyUsGcATHA8IY3E/9/EzmaZ gdJr7iWrxOXySQVAWaiZIDI/E/HG6r+akq5YSUW8hSDzTZYQCkI6qFK4/83FZ8k7CFT4 ka21MUP6zUOXLAn8eLeNkFkxFqjkOBTEvRXRbSUpQCDoE16KNhFo2OLCYv1jS2jPOMXe w6sQ== X-Gm-Message-State: AOJu0YydAIoHo5aBT4ocKjO30HT7yYm1rvA2VnNsXInYVOJanT3ahwDb A970fBo10Xujwvc/18u3iwwXCNSaLtIZDr6CIjsWkvAZznE= X-Received: by 2002:a9d:4d99:0:b0:6db:c4cd:4a1 with SMTP id u25-20020a9d4d99000000b006dbc4cd04a1mr8755584otk.41.1703784031699; Thu, 28 Dec 2023 09:20:31 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c1:bd9:84dc:8a87:ea0:57d7]) by smtp.gmail.com with ESMTPSA id q7-20020aa79827000000b006d9a94a03a8sm9593839pfl.77.2023.12.28.09.20.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 09:20:30 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 01/12] math: Reformat Makefile. Date: Thu, 28 Dec 2023 14:20:15 -0300 Message-Id: <20231228172026.2013007-2-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> References: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-8.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_STOCKTIP, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patch=linaro.org@sourceware.org Reflow all long lines adding comment terminators. Sort all reflowed text using scripts/sort-makefile-lines.py. No code generation changes observed in binary artifacts. No regressions on x86_64 and i686. Reviewed-by: H.J. Lu --- math/Makefile | 844 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 685 insertions(+), 159 deletions(-) diff --git a/math/Makefile b/math/Makefile index a9daae09de..5a912c55bd 100644 --- a/math/Makefile +++ b/math/Makefile @@ -22,87 +22,279 @@ subdir := math include ../Makeconfig # Installed header files. -headers := math.h bits/mathcalls.h \ - fpu_control.h complex.h bits/cmathcalls.h fenv.h \ - bits/fenv.h bits/mathdef.h tgmath.h \ - bits/math-vector.h finclude/math-vector-fortran.h \ - bits/libm-simd-decl-stubs.h bits/iscanonical.h \ - bits/flt-eval-method.h bits/fp-fast.h bits/fp-logb.h \ - bits/long-double.h bits/mathcalls-helper-functions.h \ - bits/floatn.h bits/floatn-common.h bits/mathcalls-narrow.h +headers := \ + math.h \ + bits/mathcalls.h \ + fpu_control.h \ + complex.h \ + bits/cmathcalls.h \ + fenv.h \ + bits/fenv.h \ + bits/mathdef.h \ + tgmath.h \ + bits/math-vector.h \ + finclude/math-vector-fortran.h \ + bits/libm-simd-decl-stubs.h \ + bits/iscanonical.h \ + bits/flt-eval-method.h \ + bits/fp-fast.h \ + bits/fp-logb.h \ + bits/long-double.h \ + bits/mathcalls-helper-functions.h \ + bits/floatn.h \ + bits/floatn-common.h \ + bits/mathcalls-narrow.h + # headers # FPU support code. -aux := setfpucw fpu_control +aux := \ + fpu_control \ + setfpucw \ + # aux # Build the -lm library. extra-libs := libm extra-libs-others = $(extra-libs) -libm-support = s_lib_version s_matherr s_signgam \ - fclrexcpt fgetexcptflg fraiseexcpt fsetexcptflg \ - ftestexcept fegetround fesetround fegetenv feholdexcpt \ - fesetenv feupdateenv fedisblxcpt feenablxcpt \ - fegetexcept fesetexcept fetestexceptflag fegetmode \ - fesetmode +libm-support = \ + fclrexcpt \ + fedisblxcpt \ + feenablxcpt \ + fegetenv \ + fegetexcept \ + fegetmode \ + fegetround \ + feholdexcpt \ + fesetenv \ + fesetexcept \ + fesetmode\ + fesetround \ + fetestexceptflag \ + feupdateenv \ + fgetexcptflg \ + fraiseexcpt \ + fsetexcptflg \ + ftestexcept \ + s_lib_version \ + s_matherr \ + s_signgam \ + # libm-support # Wrappers for these functions generated per type using a file named # _template.c and the appropriate math-type-macros-.h. -gen-libm-calls = cargF conjF cimagF crealF cabsF e_scalbF s_cacosF \ - s_cacoshF s_ccosF s_ccoshF s_casinF s_csinF s_casinhF \ - k_casinhF s_csinhF k_casinhF s_csinhF s_catanhF s_catanF \ - s_ctanF s_ctanhF s_cexpF s_clogF s_cprojF s_csqrtF \ - s_cpowF s_clog10F s_fdimF s_nextdownF s_fmaxF s_fminF \ - s_nanF s_iseqsigF s_canonicalizeF s_significandF \ - w_ilogbF w_llogbF \ - w_log1pF w_scalblnF s_fmaxmagF s_fminmagF w_acosF \ - w_acoshF w_asinF w_atan2F w_atanhF w_coshF w_exp10F \ - w_exp2F w_fmodF w_hypotF w_j0F w_j1F w_jnF w_logF \ - w_log10F w_log2F w_powF w_remainderF w_scalbF \ - w_sinhF w_sqrtF \ - w_tgammaF w_lgammaF w_lgammaF_r w_expF e_exp2F \ - s_fmaximumF s_fmaximum_magF s_fmaximum_numF \ - s_fmaximum_mag_numF s_fminimumF s_fminimum_magF \ - s_fminimum_numF s_fminimum_mag_numF - -libm-calls = \ - e_acosF e_acoshF e_asinF e_atan2F e_atanhF e_coshF e_expF e_fmodF \ - e_hypotF e_j0F e_j1F e_jnF e_lgammaF_r e_logF e_log10F e_powF \ - e_remainderF e_sinhF e_sqrtF e_gammaF_r \ - e_ilogbF \ - k_tanF s_asinhF s_atanF s_cbrtF \ - s_ceilF s_cosF s_erfF s_expm1F s_fabsF \ - s_floorF s_log1pF s_logbF \ - s_nextafterF s_nexttowardF s_rintF s_scalblnF \ - s_sinF s_tanF s_tanhF \ - s_fpclassifyF s_truncF \ - s_remquoF e_log2F s_roundF s_nearbyintF s_sincosF \ - s_fmaF s_lrintF s_llrintF s_lroundF s_llroundF e_exp10F \ - s_issignalingF $(calls:s_%=m_%) x2y2m1F \ - gamma_productF lgamma_negF lgamma_productF \ - s_nextupF s_totalorderF s_totalordermagF s_getpayloadF \ - s_setpayloadF s_setpayloadsigF s_roundevenF s_fromfpF s_ufromfpF \ - s_fromfpxF s_ufromfpxF $(gen-libm-calls) - -libm-compat-calls = \ - w_acosF_compat w_acoshF_compat w_asinF_compat w_atan2F_compat \ - w_atanhF_compat w_coshF_compat w_exp2F_compat w_exp10F_compat \ - w_fmodF_compat w_hypotF_compat w_j0F_compat w_j1F_compat \ - w_jnF_compat w_log2F_compat w_log10F_compat w_logF_compat \ - w_powF_compat w_remainderF_compat w_scalbF_compat \ - w_sinhF_compat w_sqrtF_compat w_tgammaF_compat \ - w_lgammaF_r_compat w_lgammaF_compat2 w_expF_compat \ - w_lgamma_compatF k_standardF - -libm-narrow-fns = add div fma mul sqrt sub -libm-narrow-types-basic = s_fF s_f32xFf64 -libm-narrow-types-ldouble-yes = s_fFl s_dFl -libm-narrow-types-float128-yes = s_f32Ff128 s_f64Ff128 s_f64xFf128 -libm-narrow-types-float128-alias-yes = s_f64xFf128 -libm-narrow-types = $(libm-narrow-types-basic) \ - $(libm-narrow-types-ldouble-$(long-double-fcts)) \ - $(libm-narrow-types-float128-$(float128-fcts)) \ - $(libm-narrow-types-float128-alias-$(float128-alias-fcts)) +gen-libm-calls = \ + cabsF \ + cargF \ + cimagF \ + conjF \ + crealF \ + e_exp2F \ + e_scalbF \ + k_casinhF \ + k_casinhF \ + s_cacosF \ + s_cacoshF \ + s_canonicalizeF \ + s_casinF \ + s_casinhF \ + s_catanF \ + s_catanhF \ + s_ccosF \ + s_ccoshF \ + s_cexpF \ + s_clog10F \ + s_clogF \ + s_cpowF \ + s_cprojF \ + s_csinF \ + s_csinhF \ + s_csinhF \ + s_csqrtF \ + s_ctanF \ + s_ctanhF \ + s_fdimF \ + s_fmaxF \ + s_fmaximumF \ + s_fmaximum_magF \ + s_fmaximum_mag_numF \ + s_fmaximum_numF \ + s_fmaxmagF \ + s_fminF \ + s_fminimumF \ + s_fminimum_magF \ + s_fminimum_mag_numF \ + s_fminimum_numF \ + s_fminmagF \ + s_iseqsigF \ + s_nanF \ + s_nextdownF \ + s_significandF \ + w_acosF \ + w_acoshF \ + w_asinF \ + w_atan2F \ + w_atanhF \ + w_coshF \ + w_exp10F \ + w_exp2F \ + w_expF \ + w_fmodF \ + w_hypotF \ + w_ilogbF \ + w_j0F \ + w_j1F \ + w_jnF \ + w_lgammaF \ + w_lgammaF_r \ + w_llogbF \ + w_log10F \ + w_log1pF \ + w_log2F \ + w_logF \ + w_powF \ + w_remainderF \ + w_scalbF \ + w_scalblnF \ + w_sinhF \ + w_sqrtF \ + w_tgammaF \ + # gen-libm-calls + +libm-calls = \ + $(calls:s_%=m_%) \ + $(gen-libm-calls) \ + e_acosF \ + e_acoshF \ + e_asinF \ + e_atan2F \ + e_atanhF \ + e_coshF \ + e_exp10F \ + e_expF \ + e_fmodF \ + e_gammaF_r \ + e_hypotF \ + e_ilogbF \ + e_j0F \ + e_j1F \ + e_jnF \ + e_lgammaF_r \ + e_log10F \ + e_log2F \ + e_logF \ + e_powF \ + e_remainderF \ + e_sinhF \ + e_sqrtF \ + gamma_productF \ + k_tanF \ + lgamma_negF \ + lgamma_productF \ + s_asinhF \ + s_atanF \ + s_cbrtF \ + s_ceilF \ + s_cosF \ + s_erfF \ + s_expm1F \ + s_fabsF \ + s_floorF \ + s_fmaF \ + s_fpclassifyF \ + s_fromfpF \ + s_fromfpxF \ + s_getpayloadF \ + s_issignalingF \ + s_llrintF \ + s_llroundF \ + s_log1pF \ + s_logbF \ + s_lrintF \ + s_lroundF \ + s_nearbyintF \ + s_nextafterF \ + s_nexttowardF \ + s_nextupF \ + s_remquoF \ + s_rintF \ + s_roundF \ + s_roundevenF \ + s_scalblnF \ + s_setpayloadF \ + s_setpayloadsigF \ + s_sinF \ + s_sincosF \ + s_tanF \ + s_tanhF \ + s_totalorderF \ + s_totalordermagF \ + s_truncF \ + s_ufromfpF \ + s_ufromfpxF \ + x2y2m1F \ + # libm-calls + +libm-compat-calls = \ + k_standardF \ + w_acosF_compat \ + w_acoshF_compat \ + w_asinF_compat \ + w_atan2F_compat \ + w_atanhF_compat \ + w_coshF_compat \ + w_exp10F_compat \ + w_exp2F_compat \ + w_expF_compat \ + w_fmodF_compat \ + w_hypotF_compat \ + w_j0F_compat \ + w_j1F_compat\ + w_jnF_compat \ + w_lgammaF_compat2 \ + w_lgammaF_r_compat \ + w_lgamma_compatF \ + w_log10F_compat \ + w_log2F_compat \ + w_logF_compat \ + w_powF_compat \ + w_remainderF_compat \ + w_scalbF_compat \ + w_sinhF_compat \ + w_sqrtF_compat \ + w_tgammaF_compat \ + # libm-compat-calls + +libm-narrow-fns = \ + add \ + div \ + fma \ + mul \ + sqrt \ + sub \ + # libm-narrow-fns +libm-narrow-types-basic = \ + s_f32xFf64 \ + s_fF \ + # libm-narrow-types-basic +libm-narrow-types-ldouble-yes = \ + s_dFl \ + s_fFl \ + # libm-narrow-types-ldouble-yes +libm-narrow-types-float128-yes = \ + s_f32Ff128 \ + s_f64Ff128 \ + s_f64xFf128 \ + # libm-narrow-types-float128-yes +libm-narrow-types-float128-alias-yes = \ + s_f64xFf128 \ + # libm-narrow-types-float128-alias-yes +libm-narrow-types = \ + $(libm-narrow-types-basic) \ + $(libm-narrow-types-float128-$(float128-fcts)) \ + $(libm-narrow-types-float128-alias-$(float128-alias-fcts)) \ + $(libm-narrow-types-ldouble-$(long-double-fcts)) \ + # libm-narrow-types # Type specific routine support. # @@ -115,33 +307,65 @@ libm-narrow-types = $(libm-narrow-types-basic) \ # Finally, note that types is an intentionally recursive variable. # We only know the full set of supported types for the target machine # after the Rules makefile has been parsed. -types-basic = $(type-ldouble-$(long-double-fcts)) double float +types-basic = \ + $(type-ldouble-$(long-double-fcts)) \ + double \ + float \ + # types-basic # Like types, but includes types whose functions alias those for # another type. -test-types-basic = ldouble double float +test-types-basic = \ + double \ + float \ + ldouble \ + # test-types-basic # long double support type-ldouble-suffix := l -type-ldouble-routines := t_sincosl k_sinl k_cosl k_sincosl s_iscanonicall \ - e_rem_pio2l +type-ldouble-routines := \ + e_rem_pio2l \ + k_cosl \ + k_sincosl \ + k_sinl \ + s_iscanonicall \ + t_sincosl \ + # type-ldouble-routines type-ldouble-yes := ldouble # double support type-double-suffix := -type-double-routines := branred k_rem_pio2 \ - sincostab math_err e_exp_data e_log_data \ - e_log2_data e_pow_log_data +type-double-routines := \ + branred \ + e_exp_data \ + e_log2_data \ + e_log_data \ + e_pow_log_data \ + k_rem_pio2 \ + math_err \ + sincostab \ + # type-double-routines # float support type-float-suffix := f -type-float-routines := math_errf e_exp2f_data e_logf_data \ - e_log2f_data e_powf_log2_data s_sincosf_data +type-float-routines := \ + e_exp2f_data \ + e_log2f_data \ + e_logf_data \ + e_powf_log2_data \ + math_errf \ + s_sincosf_data \ + # type-float-routines # _Float128 support type-float128-suffix := f128 -type-float128-routines := t_sincosf128 k_sinf128 k_cosf128 k_sincosf128 \ - e_rem_pio2f128 +type-float128-routines := \ + e_rem_pio2f128 \ + k_cosf128 \ + k_sincosf128 \ + k_sinf128 \ + t_sincosf128 \ + # type-float128-routines type-float128-yes := float128 # _Float64x may be supported, only as an alias type. @@ -151,11 +375,20 @@ type-float64x-yes := float64x type-ibm128-suffix := l type-ibm128-yes := ibm128 -types = $(types-basic) $(type-float128-$(float128-fcts)) -test-types = $(test-types-basic) $(type-float128-$(float128-fcts)) \ - float32 float64 $(type-float128-$(float128-alias-fcts)) \ - float32x $(type-float64x-$(float64x-alias-fcts)) \ - $(type-ibm128-$(ibm128-fcts)) +types = \ + $(type-float128-$(float128-fcts)) \ + $(types-basic) \ + # types +test-types = \ + $(test-types-basic) \ + $(type-float128-$(float128-alias-fcts)) \ + $(type-float128-$(float128-fcts)) \ + $(type-float64x-$(float64x-alias-fcts)) \ + $(type-ibm128-$(ibm128-fcts)) \ + float32 \ + float32x \ + float64 \ + # test-types # Pairs of types for which narrowing functions should be tested (this # variable has more entries than libm-narrow-types because it includes @@ -163,14 +396,25 @@ test-types = $(test-types-basic) $(type-float128-$(float128-fcts)) \ # for other types). This definition embeds the assumption that if # _Float64x is supported, so is _Float128, and vice versa (they may or # may not have the same format). -test-type-pairs = float-double float-ldouble double-ldouble \ - float32-float64 float32-float32x float32x-float64 \ - $(test-type-pairs-f64xf128-$(float128-fcts)) \ - $(test-type-pairs-f64xf128-$(float128-alias-fcts)) -test-type-pairs-f64xf128-yes = float32-float64x float32-float128 \ - float64-float64x float64-float128 \ - float32x-float64x float32x-float128 \ - float64x-float128 +test-type-pairs = \ + $(test-type-pairs-f64xf128-$(float128-alias-fcts)) \ + $(test-type-pairs-f64xf128-$(float128-fcts)) \ + double-ldouble \ + float-double \ + float-ldouble \ + float32-float32x \ + float32-float64 \ + float32x-float64 \ + # test-type-pairs +test-type-pairs-f64xf128-yes = \ + float32-float128 \ + float32-float64x \ + float32x-float128 \ + float32x-float64x \ + float64-float128 \ + float64-float64x \ + float64x-float128 \ + # test-type-pairs-f64xf128-yes # For each of the basic types (float, double, long double), replace the # occurrences of 'F' in arg 1 with the appropriate suffix for the type. @@ -193,8 +437,17 @@ libm-routines = $(strip $(libm-support) \ # and we don't want to have to link every program with -lm. # In libm-calls (above), list m_foo in place of s_foo for any # routine that should be compiled separately for its libc and libm versions. -calls = s_isinfF s_isnanF s_finiteF s_copysignF s_modfF s_scalbnF s_frexpF \ - s_signbitF $(gen-calls) +calls = \ + $(gen-calls) \ + s_copysignF \ + s_finiteF \ + s_frexpF \ + s_isinfF \ + s_isnanF \ + s_modfF \ + s_scalbnF \ + s_signbitF \ + # calls gen-calls = s_ldexpF generated += $(foreach s,.c .S,$(call type-foreach, $(calls:s_%=m_%$(s)))) routines = $(call type-foreach, $(calls)) @@ -205,8 +458,14 @@ libm-shared-only-routines = $(call type-foreach, $(calls:s_%=m_%)) ifeq ($(build-mathvec),yes) # We need to install libm.so and libm.a as linker scripts # for transparent use of vector math library. -install-lib-ldscripts := libm.so libm.a -install-others = $(inst_libdir)/libm.so $(inst_libdir)/libm.a +install-lib-ldscripts := \ + libm.a \ + libm.so \ + # install-lib-ldscripts +install-others = \ + $(inst_libdir)/libm.a \ + $(inst_libdir)/libm.so \ + # install-others $(inst_libdir)/libm.so: $(common-objpfx)format.lds \ $(libm) \ $(libmvec) \ @@ -234,42 +493,95 @@ $(inst_libdir)/libm.a: $(common-objpfx)format.lds \ endif # Rules for the test suite. -tests = test-matherr-3 test-fenv basic-test \ - test-misc test-fpucw test-fpucw-ieee tst-definitions test-tgmath \ - test-tgmath-ret bug-nextafter bug-nexttoward bug-tgmath1 \ - test-tgmath-int test-tgmath2 test-powl tst-CMPLX tst-CMPLX2 test-snan \ - test-fenv-tls test-fenv-preserve test-fenv-return \ - test-nearbyint-except test-fenv-clear \ - test-nearbyint-except-2 test-signgam-uchar test-signgam-uchar-init \ - test-signgam-uint test-signgam-uint-init test-signgam-ullong \ - test-signgam-ullong-init test-nan-overflow test-nan-payload \ - test-fexcept test-fexcept-traps test-fesetexcept \ - test-fesetexcept-traps test-fetestexceptflag test-femode \ - test-femode-traps test-iszero-excess-precision \ - test-iseqsig-excess-precision test-flt-eval-method \ - test-fp-ilogb-constants test-fp-llogb-constants \ - test-narrow-macros \ - test-nan-const $(tests-static) +tests = \ + $(tests-static) \ + bug-nextafter \ + bug-nexttoward \ + bug-tgmath1 \ + test-femode \ + test-femode-traps \ + test-fenv basic-test \ + test-fenv-clear \ + test-fenv-preserve \ + test-fenv-return \ + test-fenv-tls \ + test-fesetexcept \ + test-fesetexcept-traps \ + test-fetestexceptflag \ + test-fexcept \ + test-fexcept-traps \ + test-flt-eval-method \ + test-fp-ilogb-constants \ + test-fp-llogb-constants \ + test-fpucw \ + test-fpucw-ieee \ + test-iseqsig-excess-precision \ + test-iszero-excess-precision \ + test-matherr-3 \ + test-misc \ + test-nan-const \ + test-nan-overflow \ + test-nan-payload \ + test-narrow-macros \ + test-nearbyint-except \ + test-nearbyint-except-2 \ + test-powl \ + test-signgam-uchar \ + test-signgam-uchar-init \ + test-signgam-uint \ + test-signgam-uint-init \ + test-signgam-ullong \ + test-signgam-ullong-init \ + test-snan \ + test-tgmath \ + test-tgmath-int \ + test-tgmath-ret \ + test-tgmath2 \ + tst-CMPLX \ + tst-CMPLX2 \ + tst-definitions \ + # tests ifneq ($(config-cflags-signaling-nans),) -tests += test-fe-snans-always-signal +tests += \ + test-fe-snans-always-signal \ + # tests endif -tests-static = test-fpucw-static test-fpucw-ieee-static \ - test-signgam-uchar-static test-signgam-uchar-init-static \ - test-signgam-uint-static test-signgam-uint-init-static \ - test-signgam-ullong-static test-signgam-ullong-init-static +tests-static = \ + test-fpucw-ieee-static \ + test-fpucw-static \ + test-signgam-uchar-init-static \ + test-signgam-uchar-static \ + test-signgam-uint-init-static \ + test-signgam-uint-static \ + test-signgam-ullong-init-static \ + test-signgam-ullong-static \ + # tests-static # The tested symbols matherr, _LIB_VERSION have been removed in glibc 2.27. ifeq ($(have-GLIBC_2.26)$(build-shared),yesyes) -tests += test-matherr test-matherr-2 +tests += \ + test-matherr \ + test-matherr-2 \ + # tests endif # These tests use internal (unexported) GMP functions and are linked # statically to obtain access to these functions. -tests-static += atest-exp atest-sincos atest-exp2 +tests-static += \ + atest-exp \ + atest-exp2 \ + atest-sincos \ + # tests-static ifneq (,$(CXX)) -tests += test-math-isinff test-math-iszero test-math-issignaling \ - test-math-iscanonical test-math-cxx11 test-math-iseqsig +tests += \ + test-math-cxx11 \ + test-math-iscanonical \ + test-math-iseqsig \ + test-math-isinff \ + test-math-issignaling \ + test-math-iszero \ + # tests endif libm-vec-tests = $(addprefix test-,$(libmvec-tests)) @@ -286,35 +598,167 @@ $(objpfx)libm-test-ulps.h: $(ulps-file) gen-libm-test.py $(make-target-directory) $(PYTHON) gen-libm-test.py -u $< -H $@ -libm-test-funcs-auto = acos acosh asin asinh atan atan2 atanh cabs cacos \ - cacosh carg casin casinh catan catanh cbrt ccos ccosh \ - cexp clog clog10 cos cosh cpow csin csinh csqrt ctan \ - ctanh erf erfc exp exp10 exp2 expm1 fma hypot j0 j1 jn \ - lgamma log log10 log1p log2 pow sin sincos sinh sqrt \ - tan tanh tgamma y0 y1 yn -libm-test-funcs-noauto = canonicalize ceil cimag conj copysign cproj creal \ - fabs fdim floor fmax fmaximum fmaximum_mag \ - fmaximum_mag_num fmaximum_num fmaxmag fmin fminimum \ - fminimum_mag fminimum_mag_num fminimum_num fminmag \ - fmod fpclassify frexp fromfp fromfpx getpayload \ - ilogb iscanonical iseqsig isfinite isgreater \ - isgreaterequal isinf isless islessequal \ - islessgreater isnan isnormal issignaling issubnormal \ - isunordered iszero llogb llrint llround logb lrint \ - lround modf nearbyint nextafter nextdown nexttoward \ - nextup remainder remquo rint round roundeven scalb \ - scalbln scalbn setpayload setpayloadsig signbit \ - significand totalorder totalordermag trunc ufromfp \ - ufromfpx compat_totalorder compat_totalordermag -libm-test-funcs-compat = compat_totalorder compat_totalordermag -libm-test-funcs-narrow = add div fma mul sqrt sub -libm-test-funcs-all = $(libm-test-funcs-auto) $(libm-test-funcs-noauto) +libm-test-funcs-auto = \ + acos \ + acosh \ + asin \ + asinh \ + atan \ + atan2 \ + atanh \ + cabs \ + cacos \ + cacosh \ + carg \ + casin \ + casinh \ + catan \ + catanh \ + cbrt \ + ccos \ + ccosh \ + cexp \ + clog \ + clog10 \ + cos \ + cosh \ + cpow \ + csin \ + csinh \ + csqrt \ + ctan \ + ctanh \ + erf \ + erfc \ + exp \ + exp2 \ + exp10 \ + expm1 \ + fma \ + hypot \ + j0 \ + j1 \ + jn \ + lgamma \ + log \ + log10 \ + log1p \ + log2 \ + pow \ + sin \ + sincos \ + sinh \ + sqrt \ + tan \ + tanh \ + tgamma \ + y0 \ + y1 \ + yn \ + # libm-test-funcs-auto +libm-test-funcs-noauto = \ + canonicalize \ + ceil \ + cimag \ + compat_totalorder \ + compat_totalordermag \ + conj \ + copysign \ + cproj \ + creal \ + fabs \ + fdim \ + floor \ + fmax \ + fmaximum \ + fmaximum_mag \ + fmaximum_mag_num \ + fmaximum_num \ + fmaxmag \ + fmin \ + fminimum \ + fminimum_mag \ + fminimum_mag_num \ + fminimum_num \ + fminmag \ + fmod \ + fpclassify \ + frexp \ + fromfp \ + fromfpx \ + getpayload \ + ilogb \ + iscanonical \ + iseqsig \ + isfinite \ + isgreater \ + isgreaterequal \ + isinf \ + isless \ + islessequal \ + islessgreater \ + isnan \ + isnormal \ + issignaling \ + issubnormal \ + isunordered \ + iszero \ + llogb \ + llrint \ + llround \ + logb \ + lrint \ + lround \ + modf \ + nearbyint \ + nextafter \ + nextdown \ + nexttoward \ + nextup \ + remainder \ + remquo \ + rint \ + round \ + roundeven \ + scalb \ + scalbln \ + scalbn \ + setpayload \ + setpayloadsig \ + signbit \ + significand \ + totalorder \ + totalordermag \ + trunc \ + ufromfp \ + ufromfpx \ + # libm-test-funcs-noauto +libm-test-funcs-compat = \ + compat_totalorder \ + compat_totalordermag \ + # libm-test-funcs-compat +libm-test-funcs-narrow = \ + add \ + div \ + fma \ + mul \ + sqrt \ + sub \ + # libm-test-funcs-narrow +libm-test-funcs-all = \ + $(libm-test-funcs-auto) \ + $(libm-test-funcs-noauto) \ + # libm-test-funcs-all libm-test-c-auto = $(foreach f,$(libm-test-funcs-auto),libm-test-$(f).c) libm-test-c-noauto = $(foreach f,$(libm-test-funcs-noauto),libm-test-$(f).c) libm-test-c-narrow = $(foreach f,$(libm-test-funcs-narrow),\ libm-test-narrow-$(f).c) -generated += libm-test-ulps.h $(libm-test-c-auto) $(libm-test-c-noauto) \ - $(libm-test-c-narrow) +generated += \ + $(libm-test-c-auto) \ + $(libm-test-c-narrow) \ + $(libm-test-c-noauto) \ + libm-test-ulps.h \ + # generated libm-tests-base-normal = $(foreach t,$(test-types),test-$(t)) libm-tests-base-narrow = $(foreach t,$(test-type-pairs),test-$(t)) @@ -374,19 +818,101 @@ $(foreach t,$(libm-tests-base),\ $(objpfx)$(t)-compat_totalordermag.o): $(objpfx)libm-test-totalordermag.c # _Float128x omitted as not supported by gen-tgmath-tests.py. -tgmath3-narrow-types = f d f16 f32 f64 f128 f32x f64x +tgmath3-narrow-types = \ + d \ + f \ + f16 \ + f32 \ + f128 \ + f32x \ + f64 \ + f64x \ + # tgmath3-narrow-types tgmath3-narrow-macros = $(foreach t,$(tgmath3-narrow-types), \ $(foreach f,$(libm-narrow-fns),$(t)$(f))) -tgmath3-macros = atan2 cbrt ceil copysign erf erfc exp10 exp2 expm1 fdim \ - floor fma fmax fmin fmod frexp hypot ilogb ldexp lgamma \ - llrint llround log10 log1p log2 logb lrint lround nearbyint \ - nextafter nexttoward remainder remquo rint round scalbn \ - scalbln tgamma trunc acos asin atan acosh asinh atanh cos \ - sin tan cosh sinh tanh exp log pow sqrt fabs carg cimag conj \ - cproj creal roundeven nextup nextdown fminmag fmaxmag \ - fmaximum fmaximum_mag fmaximum_num fmaximum_mag_num \ - fminimum fminimum_mag fminimum_num fminimum_mag_num llogb \ - fromfp fromfpx ufromfp ufromfpx scalb $(tgmath3-narrow-macros) +tgmath3-macros = \ + $(tgmath3-narrow-macros) \ + acos \ + acosh \ + asin \ + asinh \ + atan \ + atan2 \ + atanh \ + carg \ + cbrt \ + ceil \ + cimag \ + conj \ + copysign \ + cos \ + cosh \ + cproj \ + creal \ + erf \ + erfc \ + exp \ + exp2 \ + exp10 \ + expm1 \ + fabs \ + fdim \ + floor \ + fma \ + fmax \ + fmaximum \ + fmaximum_mag \ + fmaximum_mag_num \ + fmaximum_num \ + fmaxmag \ + fmin \ + fminimum \ + fminimum_mag \ + fminimum_mag_num \ + fminimum_num \ + fminmag \ + fmod \ + frexp \ + fromfp \ + fromfpx \ + hypot \ + ilogb \ + ldexp \ + lgamma \ + llogb \ + llrint \ + llround \ + log \ + log10 \ + log1p \ + log2 \ + logb \ + lrint \ + lround \ + nearbyint \ + nextafter \ + nextdown \ + nexttoward \ + nextup \ + pow \ + remainder \ + remquo \ + rint \ + round \ + roundeven \ + scalb \ + scalbln \ + scalbn \ + sin \ + sinh \ + sqrt \ + tan \ + tanh \ + tgamma \ + trunc \ + ufromfp \ + ufromfpx \ + # tgmath3-macros tgmath3-macro-tests = $(addprefix test-tgmath3-,$(tgmath3-macros)) tests += $(tgmath3-macro-tests) generated += $(addsuffix .c,$(tgmath3-macro-tests)) From patchwork Thu Dec 28 17:20:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 758598 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp4114561wrw; Thu, 28 Dec 2023 09:20:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IFOIqbP/JW0D0ebxY2S4Ah+ofy4U7Zx7EEGJ5B+E8OHmH/hOsSSQTfLnxjlVCjM4ls00I2A X-Received: by 2002:a05:6808:2204:b0:3bb:6d95:8b28 with SMTP id bd4-20020a056808220400b003bb6d958b28mr12152660oib.46.1703784052221; Thu, 28 Dec 2023 09:20:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1703784052; cv=pass; d=google.com; s=arc-20160816; b=uU2s/AeTxApG4PMMK7RZTUjTteHqpjYHqs8avkejL2kUBD9IzhDq50rDB60dOr1N4Q 6mIzSjBnp3NbrQ1ZJOlf4/5fhsIicFiGba6XfJNkYF3wyMBCtb1v5UZ9a9QInyPXwKnW q3t+OjCvy25/nwE7LSoLQGaYj04e723mhfj0602+RlA16+SJM3Mpw9y2UTR8bz0a+4d0 4fgMi0nFIIIA7rTEh23mXvSMmCRobNqvqnX5xncg0C++ZEjecOX0KAmgNTiecJ3C1FFp y7zUj+pMKgHPpyeyoAoehpUBRrJsa5JPmUgQgnVJVe6ac5ZAI3oe/39J9DX2dZhLyNVl q3LQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=Huesn2m2L4ex/SQtx9e/pU9r+ZSuhfpItQ8FOCLXjKk=; fh=dHLBnA+MhGtNtN2B2JMAELi4oD+gmgMg7DL8H0jYbkI=; b=Pe95PKvbmqyzArY4nYLkctzdTdKcDdY+eIjNSQNPIwTXQoTQfJ03HPGnIeUtynbPNG 72J79/bHsYFiXmFsLNcMiY1YrqoA8a4mj658vaIYlm8zU5iXCatmD9E81n1LSGAC6vT/ Rf27iS+sybkadaKi/OAPscKg+AVHCsv7CV3ZBeguo5fytw5dU8HnC5/3ROKwkMwjPPNs n5kVrFjgy2Acuq+8mXxlTWwgxG/d/gIjJ/DzT+ygHd2MnZjAlKN99V8zUCR8PkH2fnIO EYaJFE+Xg3YAxdmWykgByRDwxzi44M6YJyVb6ECYhEkhzccnIU4Sf31HAgkJtEveXjNn Qm/A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BolqM8BB; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id r17-20020a0c9e91000000b0067f79531c05si17170241qvd.593.2023.12.28.09.20.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 09:20:52 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BolqM8BB; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B8A0538582A9 for ; Thu, 28 Dec 2023 17:20:51 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by sourceware.org (Postfix) with ESMTPS id 561453858285 for ; Thu, 28 Dec 2023 17:20:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 561453858285 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 561453858285 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::433 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784036; cv=none; b=PwpQ125AesEZTHv4XsbtZuZuJeVT+73q71S6H9mnutULoVgu18yEvUngZpH7Jl+ByX4fvn+uGi1PwWEAKR6N/gSwHW0NWFCHKhFAZqVCJ1YdCr6o2hrmlDaopYCjs4YKklFyja97UT1vvoOHPNA8ON55ckv2toAnOE6R7dAGiEs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784036; c=relaxed/simple; bh=icbRRebo28bwbUjUPuHOu3TxXraa51y2/MbekaP6VW0=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=HAb3z7j54+Hdqi2MOAqOgrCYWqYpIVMZYfXQrZMK9OlISEIa8kp8bH5yWLcdmEjZZXSrIKn9/GCsP3HNrhtAFbCNNvylev6hlINT2DKw20zJUBrdb2jrdqjWa98Br+yOZjK1rlhsKsnLSmBKdp1KJ9xdIz0cpb3qwuX5W7DSbJs= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-6d9ac5bd128so1319177b3a.0 for ; Thu, 28 Dec 2023 09:20:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703784033; x=1704388833; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=Huesn2m2L4ex/SQtx9e/pU9r+ZSuhfpItQ8FOCLXjKk=; b=BolqM8BB1EGpYGIcONVeiMPhiZp7Lk0r5MzbsTbc6+NJYX4IKuib4dmI2ifCNNEAnM 1NZ2GJl9U7vCjvNrGeQFstqFGpjMV18c37v/DMjQEcO2NqoOdxoPht4MI9qB02sOFLTV s8Qay3P2VkXuYLl/Hx/zjNESWqxFvQUn6adtXyeY8xaHA5xqKvpdtIxtQtXpJ9FMH8I+ 9pe5z3wm+a8hf24x6XUXRtNAw+fAipaFJTFUoDNAPFBFMoLf/qeEKOT9z+NdOX4mOYiA o1lPeCqwpDXSWk6RML3pz4LqdBXXQSV39O0ZCyuwH7p3aVenjJfoa45ZMrsNaBAUqmRz jmtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703784033; x=1704388833; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Huesn2m2L4ex/SQtx9e/pU9r+ZSuhfpItQ8FOCLXjKk=; b=k6VScDrE3HNA+/GE+cF0OXOVrjxkiKtB2sPu4NOvh5laZsFbARpnqdxETrQ/H9anSt 54P0Kq1ibHjuswJsBT0IGfERWE5BM8Vp5/0Uanrz5c3X87mkERo0P8CEut9Go73UJpe7 ofB5G76v0ov554kWeoT9JZPSgWCGJQPyIYRP0gUrpNptmCPdlqtmmXpXgqLIe0bXVB7h gLKXibXQegCuZV56dW1vlFELn7dXu6i8Xe6GTiZvm76Nlwc9g4JDHYrvpLVc8RDlFcTN 6TQo99BMlpveko0ZTjE6w08wDoxPfwdEc6E7RGzL4otdMFa0i7GhWvZPHl9Se+dWsLD2 OhmQ== X-Gm-Message-State: AOJu0Yw9BxrYhxxMqj3LGLlXeJkY+H3ioiZkTB/NJDDDjUpSpFGNGln1 uNtFkiv8at1C/Yqfs8a5i62zLB9kxdEsOrVW3pX1/sfLWGg= X-Received: by 2002:a05:6a20:734d:b0:196:65bd:7855 with SMTP id v13-20020a056a20734d00b0019665bd7855mr502116pzc.53.1703784033664; Thu, 28 Dec 2023 09:20:33 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c1:bd9:84dc:8a87:ea0:57d7]) by smtp.gmail.com with ESMTPSA id q7-20020aa79827000000b006d9a94a03a8sm9593839pfl.77.2023.12.28.09.20.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 09:20:32 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 02/12] powerpc: Add missing arch flags on rounding ifunc variants Date: Thu, 28 Dec 2023 14:20:16 -0300 Message-Id: <20231228172026.2013007-3-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> References: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patch=linaro.org@sourceware.org The ifunc variants now uses the powerpc implementation which in turn uses the compiler builtin. Without the proper -mcpu switch the builtin does not generate the expected optimization. Checked on powerpc-linux-gnu. Reviewed-by: H.J. Lu Reviewed-by: Peter Bergner --- sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile index 64317506c6..2f5c0eded6 100644 --- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile +++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile @@ -34,6 +34,12 @@ CFLAGS-s_modff-power5+.c = -mcpu=power5+ CFLAGS-s_logbl-power7.c = -mcpu=power7 CFLAGS-s_logb-power7.c = -mcpu=power7 CFLAGS-s_logbf-power7.c = -mcpu=power7 +CFLAGS-s_round-power5+.c += -mcpu=power5+ +CFLAGS-s_roundf-power5+.c += -mcpu=power5+ +CFLAGS-s_floor-power5+.c += -mcpu=power5+ +CFLAGS-s_floorf-power5+.c += -mcpu=power5+ +CFLAGS-s_trunc-power5+.c += -mcpu=power5+ +CFLAGS-s_truncf-power5+.c += -mcpu=power5+ # These files quiet sNaNs in a way that is optimized away without # -fsignaling-nans. From patchwork Thu Dec 28 17:20:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 758600 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp4114950wrw; Thu, 28 Dec 2023 09:21:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IFi0dmayVqYbA7K5e3YBmrlX+wE5Oko/s8mE5lFBDaHv3Etlc1lx5m3aolmKqDDCpCOYmmI X-Received: by 2002:a05:622a:254:b0:427:f8c2:5bee with SMTP id c20-20020a05622a025400b00427f8c25beemr1628225qtx.129.1703784110620; Thu, 28 Dec 2023 09:21:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1703784110; cv=pass; d=google.com; s=arc-20160816; b=PvKGNFTTn7K3Y8Z7A61+y663ltoRBunw1UJIFQcjKf7nXB1JASn5NCQJAsuhaR1BPU n4OVbaFO6MaJlPhzlq8F7tWhBn9tOJR8Bln5gvGsfx2E9syBHg8Wjiy8rH477pLGiAIF bcugfEpkjJiVN6W+X1dWV3SPpUKap/8ia83cZ2DBju3ZV/x0HunWifSG6J5gd3Yf3rdD CnNbW6fRuOr+4z8BTKZoWnnzESOh+KEdLYQyYOSHG1w48c5K8L2OY0eKqSVbHwoBTKms ljfO5Ynrbei8ZNMM9KUgc3PWZ4rbysu2i2eJSuTTZJi7WeBNyX5P+Hh62Xzedtzypmqj axsg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=vfEZIsPGLvLl4/X3BIN733T0zrZmwn4k8C+goMzfFGc=; fh=dHLBnA+MhGtNtN2B2JMAELi4oD+gmgMg7DL8H0jYbkI=; b=FswiKoAT8bDZrnJ00vxpxscB6FNqLk7ot9kHg5H80XtLiHD40aQ2lXxn1BcnKCeyVU 4bltn4NZI9BmI4CXBHHXPe4VxcZbtfbyUdWjnzUao4al6uVWB7B7xR8mh3bVUqdCAB41 f1a/j3OiNr0tjQRebsUsW01u9QOVDwmS1jLnNdjmhQdZekU0szB35d/l2eHdkB/g1JZn DP2JA2NuqIBjvvMCv61vJr6rveK+SwuRmi+xZhvciAlKCDIIV3Zx4jtVOGptQ9KE/FsV jugI8nOoooUXp4VmVXoB3tclsio684gL0kuaWxKwQLax4jjGmJp6PhQFAtwH5NLYIUhK 936w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gww5hQCH; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id c13-20020a05622a024d00b0042775bb6607si17501848qtx.774.2023.12.28.09.21.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 09:21:50 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gww5hQCH; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 30B7838582BF for ; Thu, 28 Dec 2023 17:21:50 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by sourceware.org (Postfix) with ESMTPS id B9453385843E for ; Thu, 28 Dec 2023 17:20:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B9453385843E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B9453385843E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::436 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784039; cv=none; b=wmcJGmvmRv1qLriau1oeQwVeN8VAcd5B4Kn3S00t/6+H8hEl9HjKzMo8zowOOjsou0UsgfBB0jxqelRiIQ2bYffJL7eWnCSjc93qRoL8jkqe8zuPDu+5a9uzIUik+df0C4pAJyaO7jVOQY5IzI0c5LnnLlZ63xcNC0e+cbRmQ0E= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784039; c=relaxed/simple; bh=m9fTcXt2h+YDHnP5Nqh91hW5rgCc2fhNFFiV/dORuHs=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=JYDDSnRH2/hygIrLMLxjWB3kexDmMm5jo/OLzGrmH8cuB4XKZloh74IsRvjTXrgpvEcZISo6OAyUedu3iTYS5nlbT6lSoSG4h2YXeFha/lfrt6rL94PrPDYWOI2Q1Hb8EFhR4KNytvW2052xP2MAh1uxA3PGujAkCclwUNjRuoA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-6d9bf6f24f3so1163590b3a.2 for ; Thu, 28 Dec 2023 09:20:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703784035; x=1704388835; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=vfEZIsPGLvLl4/X3BIN733T0zrZmwn4k8C+goMzfFGc=; b=gww5hQCH2O92c/gHFvQCb3zntcGm+UV5+JtAWhLzUo3tAW3DmH9d79h/fFiQtlniTX nwrGq4Kq2nDwVAMjQQQHhA4yDT1B3YSjmpp9YiUZJTlwxh7uuoVGOj5OCVsMiKWtZs5z qnQFxrH1hLZQ3a5JeI46MMVOQJbCCniQ90cmFpR8MMJXqI0jBX/fa0pC/ffjx6uIg4vf NSCB75MHnz1EB8VFqY19SsVEIVt3LNyTlm/GhcWOk9VVDoBXCDhxGBsz/Nxb4eCFhuUo 6/0vSIWU6tTr1syQ34jnTYaPHVoBDOTFg6SLuMyXBzChJq107ScOVJ5y1g/YnQ4Wsj+c m5Ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703784035; x=1704388835; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vfEZIsPGLvLl4/X3BIN733T0zrZmwn4k8C+goMzfFGc=; b=ZSYDH+37QTpuTEz0urCylonDGwT98+12FRHQOSyb54AACLqAfgVOaauFvU9JP08vqY sCAZxlJmBhQ5Gkf0COeQGEy3Eq0mEaLXA0dct9z2x4K0lV1D7uaACnKB9J4xA6QtsG9P 4LiYbPDlKyQ52596bbBSqKvqJYJR14VUlq9R7C8TfK744Earrrjt9MbuyTEV0sPsQNmV 8Eefpsbalp/T4XeUBdP+jCvFU9NZq/LtbVKsYJDLtlwkcqunoV3tCMXuF9Fkfir++Zp8 JxbT2Icfh0rYk3XJEzbQhWV2UJnce5xX1F9HWs6tPJoF2jZw7imDzLOWxuoAn+Lp+XDW +TPQ== X-Gm-Message-State: AOJu0YzSXPkdlh5N6BcNKQ5eTpdfvxVfdDwgsAIDE2ThZ8xCIqZKzVQ0 p2s8xzyCV8zp37InJgXLXyA50arQIM4ZJK7tB12u36Dy/nk= X-Received: by 2002:a62:a518:0:b0:6d9:cdf5:cc45 with SMTP id v24-20020a62a518000000b006d9cdf5cc45mr2547665pfm.63.1703784035200; Thu, 28 Dec 2023 09:20:35 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c1:bd9:84dc:8a87:ea0:57d7]) by smtp.gmail.com with ESMTPSA id q7-20020aa79827000000b006d9a94a03a8sm9593839pfl.77.2023.12.28.09.20.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 09:20:34 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 03/12] math: Add test to check if ceil raise inexact floating-point exception Date: Thu, 28 Dec 2023 14:20:17 -0300 Message-Id: <20231228172026.2013007-4-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> References: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patch=linaro.org@sourceware.org It is not allowed anymore on ISO C23. --- math/Makefile | 5 +++ math/test-ceil-except-2.c | 67 ++++++++++++++++++++++++++++++ math/test-ceil-except.c | 85 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 157 insertions(+) create mode 100644 math/test-ceil-except-2.c create mode 100644 math/test-ceil-except.c diff --git a/math/Makefile b/math/Makefile index 5a912c55bd..4fc7842313 100644 --- a/math/Makefile +++ b/math/Makefile @@ -498,6 +498,8 @@ tests = \ bug-nextafter \ bug-nexttoward \ bug-tgmath1 \ + test-ceil-except \ + test-ceil-except-2 \ test-femode \ test-femode-traps \ test-fenv basic-test \ @@ -989,6 +991,9 @@ CFLAGS-test-fe-snans-always-signal.c += $(config-cflags-signaling-nans) CFLAGS-test-nan-const.c += -fno-builtin +CFLAGS-test-ceil-except.c += -fno-builtin +CFLAGS-test-ceil-except-2.c += -fno-builtin + include ../Rules gen-all-calls = $(gen-libm-calls) $(gen-calls) diff --git a/math/test-ceil-except-2.c b/math/test-ceil-except-2.c new file mode 100644 index 0000000000..c25956a402 --- /dev/null +++ b/math/test-ceil-except-2.c @@ -0,0 +1,67 @@ +/* Test ceil functions do not disable exception traps. + Copyright (C) 2023 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include + +#ifndef FE_INEXACT +# define FE_INEXACT 0 +#endif + +#define TEST_FUNC(NAME, FLOAT, SUFFIX) \ +static int \ +NAME (void) \ +{ \ + int result = 0; \ + volatile FLOAT a, b __attribute__ ((unused)); \ + a = 1.5; \ + /* ceil must work when traps on "inexact" are enabled. */ \ + b = ceil ## SUFFIX (a); \ + /* And it must have left those traps enabled. */ \ + if (fegetexcept () == FE_INEXACT) \ + puts ("PASS: " #FLOAT); \ + else \ + { \ + puts ("FAIL: " #FLOAT); \ + result = 1; \ + } \ + return result; \ +} + +TEST_FUNC (float_test, float, f) +TEST_FUNC (double_test, double, ) +TEST_FUNC (ldouble_test, long double, l) + +static int +do_test (void) +{ + if (feenableexcept (FE_INEXACT) == -1) + { + puts ("enabling FE_INEXACT traps failed, cannot test"); + return 77; + } + int result = float_test (); + feenableexcept (FE_INEXACT); + result |= double_test (); + feenableexcept (FE_INEXACT); + result |= ldouble_test (); + return result; +} + +#include diff --git a/math/test-ceil-except.c b/math/test-ceil-except.c new file mode 100644 index 0000000000..cd0717a96f --- /dev/null +++ b/math/test-ceil-except.c @@ -0,0 +1,85 @@ +/* Test ceil functions do not clear exceptions. + Copyright (C) 2015-2023 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include +#include + +#include + +#ifndef FE_INVALID +# define FE_INVALID 0 +#endif + +static bool any_supported = false; + +#define TEST_FUNC(NAME, FLOAT, SUFFIX) \ +static int \ +NAME (void) \ +{ \ + int result = 0; \ + if (!EXCEPTION_TESTS (FLOAT)) \ + return 0; \ + any_supported = true; \ + volatile FLOAT a, b __attribute__ ((unused)); \ + a = 1.0; \ + /* ceil must not clear already-raised exceptions. */ \ + feraiseexcept (FE_ALL_EXCEPT); \ + b = ceil ## SUFFIX (a); \ + if (fetestexcept (FE_ALL_EXCEPT) == FE_ALL_EXCEPT) \ + puts ("PASS: " #FLOAT); \ + else \ + { \ + puts ("FAIL: " #FLOAT); \ + result = 1; \ + } \ + /* But it mustn't lose exceptions from sNaN arguments. */ \ + if (SNAN_TESTS (FLOAT)) \ + { \ + static volatile FLOAT snan = __builtin_nans ## SUFFIX (""); \ + volatile FLOAT c __attribute__ ((unused)); \ + feclearexcept (FE_ALL_EXCEPT); \ + c = ceil ## SUFFIX (snan); \ + if (fetestexcept (FE_INVALID) == FE_INVALID) \ + puts ("PASS: " #FLOAT " sNaN"); \ + else \ + { \ + puts ("FAIL: " #FLOAT " sNaN"); \ + result = 1; \ + } \ + } \ + return result; \ +} + +TEST_FUNC (float_test, float, f) +TEST_FUNC (double_test, double, ) +TEST_FUNC (ldouble_test, long double, l) + +static int +do_test (void) +{ + int result = float_test (); + result |= double_test (); + result |= ldouble_test (); + if (!any_supported) + return 77; + return result; +} + +#include From patchwork Thu Dec 28 17:20:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 758601 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp4115000wrw; Thu, 28 Dec 2023 09:21:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IELx59JMiO2Tq8P1+vNM6AyndOjN0XAt/292DFulrWOrQ+v8o6EmVayvATcqQODnDOAVH7C X-Received: by 2002:a05:622a:13d4:b0:427:a33e:8b97 with SMTP id p20-20020a05622a13d400b00427a33e8b97mr15073783qtk.5.1703784116209; Thu, 28 Dec 2023 09:21:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1703784116; cv=pass; d=google.com; s=arc-20160816; b=MWC2yKU8dqBGFcaU1hVOQu8v8MocWbWNIbjS1o+hgfmahRYlvxyEJlHg7sguBUM2Gb S8zNtmGP9JhXA+8t7Ug1njtLP8TyVtvykgi31kYThj2hnw6XbPEuNoq6PpQ31HkPQR/K LAJb+I+/ajQMXyWBQsLJScuLxiwW1VonfhZRJS62o26MwsysfgmAYb//WpoV8HcFyY2T I4hG3CZJHITmKtlbW1W+4sG99u5QD0Y0JniaR23sikQox0wR7mNL3eCIpgGQmJET+mTA 5+BKrRRNttT6NNjiSsDZkhMvhgVeU7OVr5imJtvEc9/LPNrT9kNyoJnaV+7MuECD0+k9 hyxg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=R/imacu5+KSGgiyc9Jl0JvYjneQJ+wlkM+brgCqe4fI=; fh=dHLBnA+MhGtNtN2B2JMAELi4oD+gmgMg7DL8H0jYbkI=; b=KhfBccXfeWoKBGQAu2jy83rOZduai032mSVlRe1RN+yJjqu4BKa2vLGyISvMATbZ/B TkB1kfRbVLhH+EKt680zrfnty105P/SyEPbQSHp1/LAZUP4dElEoiwYGqDICd/y9YPje 98P8R0pRF2wg2sPSLozuo3TWGvAzrEEZC0h3eZl12lxJMIz04L8SlU6KockiXXYR6e3L eOZkmj6mqYPekLerxvYVVBeWHaUiJWWWIYVJz78qNChKfgR3RqIZuP/1CkT8vsNK/HBh Ug3ReQA7aK7RKuQjmwAEbb/kvd81RUQKFxYCzSUxrc1Xjiw6Fpj1Ws8gCH4f+bJEWJQ1 ugiw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="D0BBR/r5"; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id t20-20020a05622a149400b00427921cdd07si16559140qtx.407.2023.12.28.09.21.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 09:21:56 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="D0BBR/r5"; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C6CDC38582A5 for ; Thu, 28 Dec 2023 17:21:55 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by sourceware.org (Postfix) with ESMTPS id 54E873858282 for ; Thu, 28 Dec 2023 17:20:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 54E873858282 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 54E873858282 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::429 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784042; cv=none; b=bNcfJvgDJX4waOgLdk8Cz6Ma8J62ZKR5H0ilqKkJOjn2q4XNJB+K0lWDAPsMOGvbeFbGEXZZRmwta6GHwd9w3y4hpopxUAiERaJ8HWs9hIEPaiLo5F6oJ1UNt0G6rZAfclK8WzDcp9BHnQIKLiKnpGIXunxukOJxvHhpP0dRRHE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784042; c=relaxed/simple; bh=0Lx1BUvKNpjpegvnNvDiRteHtbH/ad96hxjvyKtSttM=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=aWGuUl/XwtTx5sf4t8ACkWc3AM3nO3AS0cGHf2jXf0DWKwxKLj8j38cG333vfa09t8UxLAEgjbKtPtU7Xslsu9HMy+qeaKDxXws5+33Q2nkI7jiWadsdIuvQswOQmxxJ9DCW6r+5qKiAZ/qYkfhNPOj/sTkoron6E4lumoAlKAg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-6d9aa51571fso3074092b3a.3 for ; Thu, 28 Dec 2023 09:20:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703784037; x=1704388837; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=R/imacu5+KSGgiyc9Jl0JvYjneQJ+wlkM+brgCqe4fI=; b=D0BBR/r5aMAMG4TA++GOm3/X492vTMNa4SmlN02+HVcF3wVnlGnwYYzchoTDeX3BQb Mvx748fOLzStjYVxsndVcY5J3gI/AnVI26FJxQVwyOG5AC/z/A7mFNsZN1BqbKPG6KV4 bRmaz6sx05D5zTOUe4mu/LVd1TnNVpCvddyiWzYtOkGnv5aFn7zlakeCa2WzZuZEyCCi fEhSWn0cHeamJCYYqtJCwOklYy3FXPye5Cv1DPfEho06QG6T1SlKzSLQykDOzRkisLJU Qn2h14enYxGEnEx/31or6YIh8PEDMC/ls98smvxXEnq35I71mojWIuUL/Dy2LeqEknxa iWsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703784037; x=1704388837; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=R/imacu5+KSGgiyc9Jl0JvYjneQJ+wlkM+brgCqe4fI=; b=T14p8cZsjvnPbE3zpynO+aiextnGdIZbsG8bhRuTm8yifa6h3PC+r+N+4kz+sCX4qK lSIedp4Sksa3vGI5W9OEa9yhODOQBVzrvuLK1Y3olaNv+RD3HL0CRadgSDv0EmNodjZ0 fxFpzazcYI/WEAE00bufqVG9BdnskpJfxmr5K9rcJJMsq/AVP6bqiDp84ZxqeAH1na/2 mGKsjEKwMKP3bqnWo4i6QGnsSwzR8UytAuc6Diiw//Md4q0XnbZRdTlgHZJrpJ8ypHKd n62Em6SuDQo5X0XXW11lRxQgCI1/R7LGlHl+/wQV2S4FSaMNwKz1Z+s7DpG9DP9R/YAq eBAA== X-Gm-Message-State: AOJu0YwHkLNpTueOofFAuK/x+uhEUj5td+up9m9ZFzEbIHFDsVesj0Tt sWWIYzUqmn8wcDHqneMaM8yK6heLBZHY+eACi7dL35bOrw8= X-Received: by 2002:a05:6a00:1254:b0:6d9:c784:9c8f with SMTP id u20-20020a056a00125400b006d9c7849c8fmr7263700pfi.36.1703784036807; Thu, 28 Dec 2023 09:20:36 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c1:bd9:84dc:8a87:ea0:57d7]) by smtp.gmail.com with ESMTPSA id q7-20020aa79827000000b006d9a94a03a8sm9593839pfl.77.2023.12.28.09.20.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 09:20:36 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 04/12] math: Add test to check if floor raise inexact floating-point exception Date: Thu, 28 Dec 2023 14:20:18 -0300 Message-Id: <20231228172026.2013007-5-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> References: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patch=linaro.org@sourceware.org It is not allowed anymore on ISO C23. --- math/Makefile | 4 ++ math/test-floor-except-2.c | 67 ++++++++++++++++++++++++++++++ math/test-floor-except.c | 85 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 156 insertions(+) create mode 100644 math/test-floor-except-2.c create mode 100644 math/test-floor-except.c diff --git a/math/Makefile b/math/Makefile index 4fc7842313..19e234874a 100644 --- a/math/Makefile +++ b/math/Makefile @@ -512,6 +512,8 @@ tests = \ test-fetestexceptflag \ test-fexcept \ test-fexcept-traps \ + test-floor-except \ + test-floor-except-2 \ test-flt-eval-method \ test-fp-ilogb-constants \ test-fp-llogb-constants \ @@ -993,6 +995,8 @@ CFLAGS-test-nan-const.c += -fno-builtin CFLAGS-test-ceil-except.c += -fno-builtin CFLAGS-test-ceil-except-2.c += -fno-builtin +CFLAGS-test-floor-except.c += -fno-builtin +CFLAGS-test-floor-except-2.c += -fno-builtin include ../Rules diff --git a/math/test-floor-except-2.c b/math/test-floor-except-2.c new file mode 100644 index 0000000000..01b22f984b --- /dev/null +++ b/math/test-floor-except-2.c @@ -0,0 +1,67 @@ +/* Test floor functions do not disable exception traps. + Copyright (C) 2023 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include + +#ifndef FE_INEXACT +# define FE_INEXACT 0 +#endif + +#define TEST_FUNC(NAME, FLOAT, SUFFIX) \ +static int \ +NAME (void) \ +{ \ + int result = 0; \ + volatile FLOAT a, b __attribute__ ((unused)); \ + a = 1.5; \ + /* floor must work when traps on "inexact" are enabled. */ \ + b = floor ## SUFFIX (a); \ + /* And it must have left those traps enabled. */ \ + if (fegetexcept () == FE_INEXACT) \ + puts ("PASS: " #FLOAT); \ + else \ + { \ + puts ("FAIL: " #FLOAT); \ + result = 1; \ + } \ + return result; \ +} + +TEST_FUNC (float_test, float, f) +TEST_FUNC (double_test, double, ) +TEST_FUNC (ldouble_test, long double, l) + +static int +do_test (void) +{ + if (feenableexcept (FE_INEXACT) == -1) + { + puts ("enabling FE_INEXACT traps failed, cannot test"); + return 77; + } + int result = float_test (); + feenableexcept (FE_INEXACT); + result |= double_test (); + feenableexcept (FE_INEXACT); + result |= ldouble_test (); + return result; +} + +#include diff --git a/math/test-floor-except.c b/math/test-floor-except.c new file mode 100644 index 0000000000..fe77866ddc --- /dev/null +++ b/math/test-floor-except.c @@ -0,0 +1,85 @@ +/* Test floor functions do not clear exceptions. + Copyright (C) 2015-2023 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include +#include + +#include + +#ifndef FE_INVALID +# define FE_INVALID 0 +#endif + +static bool any_supported = false; + +#define TEST_FUNC(NAME, FLOAT, SUFFIX) \ +static int \ +NAME (void) \ +{ \ + int result = 0; \ + if (!EXCEPTION_TESTS (FLOAT)) \ + return 0; \ + any_supported = true; \ + volatile FLOAT a, b __attribute__ ((unused)); \ + a = 1.0; \ + /* floor must not clear already-raised exceptions. */ \ + feraiseexcept (FE_ALL_EXCEPT); \ + b = floor ## SUFFIX (a); \ + if (fetestexcept (FE_ALL_EXCEPT) == FE_ALL_EXCEPT) \ + puts ("PASS: " #FLOAT); \ + else \ + { \ + puts ("FAIL: " #FLOAT); \ + result = 1; \ + } \ + /* But it mustn't lose exceptions from sNaN arguments. */ \ + if (SNAN_TESTS (FLOAT)) \ + { \ + static volatile FLOAT snan = __builtin_nans ## SUFFIX (""); \ + volatile FLOAT c __attribute__ ((unused)); \ + feclearexcept (FE_ALL_EXCEPT); \ + c = floor ## SUFFIX (snan); \ + if (fetestexcept (FE_INVALID) == FE_INVALID) \ + puts ("PASS: " #FLOAT " sNaN"); \ + else \ + { \ + puts ("FAIL: " #FLOAT " sNaN"); \ + result = 1; \ + } \ + } \ + return result; \ +} + +TEST_FUNC (float_test, float, f) +TEST_FUNC (double_test, double, ) +TEST_FUNC (ldouble_test, long double, l) + +static int +do_test (void) +{ + int result = float_test (); + result |= double_test (); + result |= ldouble_test (); + if (!any_supported) + return 77; + return result; +} + +#include From patchwork Thu Dec 28 17:20:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 758603 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp4115177wrw; Thu, 28 Dec 2023 09:22:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IE7PxnaXDx7wQayDfqowuIO7iYHPrYY4OvU255Ojbmg7ko9u3Us+donXrzINg3brLxMgho8 X-Received: by 2002:a05:6808:f10:b0:3b9:e7f5:39b8 with SMTP id m16-20020a0568080f1000b003b9e7f539b8mr15397176oiw.36.1703784142641; Thu, 28 Dec 2023 09:22:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1703784142; cv=pass; d=google.com; s=arc-20160816; b=qlHZeFXA54JatPD3QDfIhWI4nk7I6Lh8/NwcTGRDuM+oEwbebV/dxuIljRtBfPH5kd 9Z23JtFtaOx6ktkCiOicfdhY+WjUq0LfhcaC8lw7T80k7G1+MUHNBmkrQbkqx9ACRAn1 uDgjSaoDIM3VoR77F00Osx/V9Y5C/MJ+58lt7BUvueRkX+0JRgfx4TgNi25LnD0FLPFI BvCcdEzg6JfQ7h88S8uBmnpmABkgRCb79SzdmkF2kJetq3FnC0BTj9al9iYU0F/FTZ0Q DEAl20xkHz/KzuK2iae0Q3r4Hn79hgFIaGFJ0SM54sKN4XuPcuHoIAxmpDzhiNa7VBdE FXOQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=jYCR0Es9t9c5ayU2ClkHYO27pEUSNvGDcJ87yJNQxaE=; fh=dHLBnA+MhGtNtN2B2JMAELi4oD+gmgMg7DL8H0jYbkI=; b=asTma2jOSapT9cqo8h5JwbDA3ur5hRwQJ7lWpdrFfb8Wfeu6wMF8eCXzbjercuwc5E HGLj4N4utsatouftavWJhNVk0RwwnRP9tWMU9x8/X7q7BqVkB6srM3CcT7XLIek24J6C u5CbFSERjnFtyThJgf1wAloK/M7nmD7bdNFMwETk4ZGS39BilxqrbgRh5XWq/J5UjGC7 kZAD7LSagl0rav0TfcHaF19e+xPFg6ZE/2X+tYpWzwTxkNb8e9ut7DIb8W1l75SV9cZZ nRMumaXlyHsmYvs9Gkb58No+/tpYSb2J3B8v7ubUCHumMOsAUtnt4WddKDB+tAG4FLBX 9idA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ArIHerb8; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id w8-20020a05622a190800b00419628da454si17621575qtc.177.2023.12.28.09.22.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 09:22:22 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ArIHerb8; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3D529385829D for ; Thu, 28 Dec 2023 17:22:22 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oo1-xc2c.google.com (mail-oo1-xc2c.google.com [IPv6:2607:f8b0:4864:20::c2c]) by sourceware.org (Postfix) with ESMTPS id AA3AC3858C36 for ; Thu, 28 Dec 2023 17:20:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AA3AC3858C36 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org AA3AC3858C36 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::c2c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784044; cv=none; b=glUrAtWwnH98HNZs+b3oyteM3qeUCbVtNqsiOOQQODPFigwqlY2hgZXXMjVIc7CqgsAXm7h4myMyL/Iv/yGkJnWI6pKm20vPmqDOl6myOLq1wPsI9s1jGIl0fed3fIMdJBDkYLEtUADgRN/uk4fSqlA8uSW+oBl+dASLR3neD6g= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784044; c=relaxed/simple; bh=BHsfWGMLCtderjDLsmqkIZqsyGo5HVhwwXD4ZWsLGH8=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=MKizTBTbnNAV2UM8DDGHep+rsMX0UC5XMx+T/xzcYxlV9AtZLhEVOMqLXt8UKQYqA32aYgfIL2g4xYbdIBR+HM0SpNWZnA7yBI9GjYzXyl8vvjx6xXb/plqBeIJdIWcLcXh3wAUubCUW6tZ2vAmy4n3QE7eclvJ0fG1GRLTtVH8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oo1-xc2c.google.com with SMTP id 006d021491bc7-594965fbb3cso2032994eaf.1 for ; Thu, 28 Dec 2023 09:20:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703784038; x=1704388838; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=jYCR0Es9t9c5ayU2ClkHYO27pEUSNvGDcJ87yJNQxaE=; b=ArIHerb8OyRYHuUZ+iuemwksf4zBamvfHcEBIkPTn47QhmnkfDDINQbOTI30OMpeO9 z3sn/EJe46sV6jTSRpCoL26wvhUMVao0Thbwrtw5SWPSfO4i0af9hC1/UpqQMxg8vs70 HI1zQQvqJ7vUsLQp3rpvYlRFz6moTs5DKbflm3nEvHk1IvHtZYAypSRm1EfvcoxaP1wk o0s3Mjn9BDlA6dvm+enGBO8/W8PVU/BXhmoAcLI80AUbau7j9ySNFSII9r4Q3tEpWIh9 JdbyieFpvoMGFFOaFvqk8k272/LQWg5drH5F8+kq/VcaCEyT+LBlLCvBOtw+zSTK1HnW gwoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703784038; x=1704388838; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jYCR0Es9t9c5ayU2ClkHYO27pEUSNvGDcJ87yJNQxaE=; b=obzQxm3coRLa1YwHZ0U6JuFn7KCdpHcq05b11vSePLo4T3hxKAO6PiZYnBvHeQsY6h vXCdaYHJpPIuQEJZwR/ShVWf58xQNe6K7M83kjkhB7hZXT6hSJ2TpQ2Kxy11M/mUUXSF xoD5sKYCZ40HKFbRRcIuiq4BBeiZxmfOvDqm9yUNv39V/02zG0sTWakWWK872Q3Jn/HT TOnZLUFj0wR2A8OSe6Lc6hem1BhxWrxdVXwd9VcuYNqQ5Q06PcwV42t+TZULsM3h8LJt XO8DVgG9JoJolUV0L6FnuN/rOX0ZfUwpZ/hi9JbK3HEYmQsVoqG7aczERueWoNs5NRPb ksSQ== X-Gm-Message-State: AOJu0Yx7FzZQ1XdapOjHXAtExtYCZibQb6k2I9Cl2O0M4WH2aejzFdfA WXqUNHDiFWelnJhfbDMauSeMym+ikILpMwT181KONqilRSg= X-Received: by 2002:a05:6359:4c06:b0:172:f31a:6bfb with SMTP id kj6-20020a0563594c0600b00172f31a6bfbmr14104588rwc.51.1703784038309; Thu, 28 Dec 2023 09:20:38 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c1:bd9:84dc:8a87:ea0:57d7]) by smtp.gmail.com with ESMTPSA id q7-20020aa79827000000b006d9a94a03a8sm9593839pfl.77.2023.12.28.09.20.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 09:20:37 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 05/12] math: Add test to check if trunc raise inexact floating-point exception Date: Thu, 28 Dec 2023 14:20:19 -0300 Message-Id: <20231228172026.2013007-6-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> References: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patch=linaro.org@sourceware.org It is not allowed anymore on ISO C23. --- math/Makefile | 4 ++ math/test-trunc-except-2.c | 67 ++++++++++++++++++++++++++++++ math/test-trunc-except.c | 85 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 156 insertions(+) create mode 100644 math/test-trunc-except-2.c create mode 100644 math/test-trunc-except.c diff --git a/math/Makefile b/math/Makefile index 19e234874a..7ae107170c 100644 --- a/math/Makefile +++ b/math/Makefile @@ -541,6 +541,8 @@ tests = \ test-tgmath-int \ test-tgmath-ret \ test-tgmath2 \ + test-trunc-except \ + test-trunc-except-2 \ tst-CMPLX \ tst-CMPLX2 \ tst-definitions \ @@ -997,6 +999,8 @@ CFLAGS-test-ceil-except.c += -fno-builtin CFLAGS-test-ceil-except-2.c += -fno-builtin CFLAGS-test-floor-except.c += -fno-builtin CFLAGS-test-floor-except-2.c += -fno-builtin +CFLAGS-test-trunc-except.c += -fno-builtin +CFLAGS-test-trunc-except-2.c += -fno-builtin include ../Rules diff --git a/math/test-trunc-except-2.c b/math/test-trunc-except-2.c new file mode 100644 index 0000000000..29716efc0b --- /dev/null +++ b/math/test-trunc-except-2.c @@ -0,0 +1,67 @@ +/* Test trunc functions do not disable exception traps. + Copyright (C) 2023 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include + +#ifndef FE_INEXACT +# define FE_INEXACT 0 +#endif + +#define TEST_FUNC(NAME, FLOAT, SUFFIX) \ +static int \ +NAME (void) \ +{ \ + int result = 0; \ + volatile FLOAT a, b __attribute__ ((unused)); \ + a = 1.5; \ + /* trunc must work when traps on "inexact" are enabled. */ \ + b = trunc ## SUFFIX (a); \ + /* And it must have left those traps enabled. */ \ + if (fegetexcept () == FE_INEXACT) \ + puts ("PASS: " #FLOAT); \ + else \ + { \ + puts ("FAIL: " #FLOAT); \ + result = 1; \ + } \ + return result; \ +} + +TEST_FUNC (float_test, float, f) +TEST_FUNC (double_test, double, ) +TEST_FUNC (ldouble_test, long double, l) + +static int +do_test (void) +{ + if (feenableexcept (FE_INEXACT) == -1) + { + puts ("enabling FE_INEXACT traps failed, cannot test"); + return 77; + } + int result = float_test (); + feenableexcept (FE_INEXACT); + result |= double_test (); + feenableexcept (FE_INEXACT); + result |= ldouble_test (); + return result; +} + +#include diff --git a/math/test-trunc-except.c b/math/test-trunc-except.c new file mode 100644 index 0000000000..c9e341de0d --- /dev/null +++ b/math/test-trunc-except.c @@ -0,0 +1,85 @@ +/* Test trunc functions do not clear exceptions. + Copyright (C) 2015-2023 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include +#include + +#include + +#ifndef FE_INVALID +# define FE_INVALID 0 +#endif + +static bool any_supported = false; + +#define TEST_FUNC(NAME, FLOAT, SUFFIX) \ +static int \ +NAME (void) \ +{ \ + int result = 0; \ + if (!EXCEPTION_TESTS (FLOAT)) \ + return 0; \ + any_supported = true; \ + volatile FLOAT a, b __attribute__ ((unused)); \ + a = 1.0; \ + /* trunc must not clear already-raised exceptions. */ \ + feraiseexcept (FE_ALL_EXCEPT); \ + b = trunc ## SUFFIX (a); \ + if (fetestexcept (FE_ALL_EXCEPT) == FE_ALL_EXCEPT) \ + puts ("PASS: " #FLOAT); \ + else \ + { \ + puts ("FAIL: " #FLOAT); \ + result = 1; \ + } \ + /* But it mustn't lose exceptions from sNaN arguments. */ \ + if (SNAN_TESTS (FLOAT)) \ + { \ + static volatile FLOAT snan = __builtin_nans ## SUFFIX (""); \ + volatile FLOAT c __attribute__ ((unused)); \ + feclearexcept (FE_ALL_EXCEPT); \ + c = trunc ## SUFFIX (snan); \ + if (fetestexcept (FE_INVALID) == FE_INVALID) \ + puts ("PASS: " #FLOAT " sNaN"); \ + else \ + { \ + puts ("FAIL: " #FLOAT " sNaN"); \ + result = 1; \ + } \ + } \ + return result; \ +} + +TEST_FUNC (float_test, float, f) +TEST_FUNC (double_test, double, ) +TEST_FUNC (ldouble_test, long double, l) + +static int +do_test (void) +{ + int result = float_test (); + result |= double_test (); + result |= ldouble_test (); + if (!any_supported) + return 77; + return result; +} + +#include From patchwork Thu Dec 28 17:20:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 758602 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp4115081wrw; Thu, 28 Dec 2023 09:22:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IF117YlkF6IPiT79bt6Brjy46Opeg8mS1au6uHD/7PTOlT2WgJlL72Fd7oPamaxMtGuPFRF X-Received: by 2002:a05:622a:448:b0:423:f8f1:dfda with SMTP id o8-20020a05622a044800b00423f8f1dfdamr12910193qtx.25.1703784127522; Thu, 28 Dec 2023 09:22:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1703784127; cv=pass; d=google.com; s=arc-20160816; b=WHq6iel7dBBWPHQxrqTjlwPiVDsDhR1V7x0AySWPxnzEo6R16K33M6IgyU/nqRoyoj phJkqzMSDVZPbpJFZgh+ZKQ6RqBg6Six6Y1eYeam+EmgwPGW4DT+jHeyJt3hqBk9rFGM c2n4EaErxkNdPmjQ0UmBosJj6Fk/cIpLr9iN+csXXRERJTABdwAVbit01Dlxvg+U/DTZ smHeBy/4vMjO/UUXpnNerIP5StGB36HmLar5KWkDFYRYxTIXjQjLLTuD092Ueb5UCW2e wKAJwQGGbiJhyFBcyU4Z9O+cL+wxh/vFBpJYb994gAp4rVV0QRby4XV7PaIhKcdIFbG+ D3Gw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=G7DAyBPI7iRaNkh70Jq9qwomvSbfKt3p52V+XD56U4Y=; fh=dHLBnA+MhGtNtN2B2JMAELi4oD+gmgMg7DL8H0jYbkI=; b=BVZ7sCmyUFfSO9bmOBWXTyGeE3+fdAFEJIAbqKYD2z89O0qa9kuhD1CUtRNW+hUCfy iDoPPgujmiJRFKTzbJeAeIUk61WdkeSfNcVsC0s/98N4dxcYyXwMnRKvRm4vNXfAzNk8 hfDiVW4Cynp0Su0gfCRdyXFdCIVUVabeKco2Riry1WJJbSESYrMp5MZWOAfe6F3W21Yd Yso1n/ewLOK3fh0Dms6N8yecekPYfBvwnBrt7uEzhKfc9VoPe/kBUIIOLiHPPSsEOVoY 8DdjXbVrN7Vdyijfy12AFEPM/Fq+41ec1Hjj/95akiUBGYfdp1hYAgwgiKweARzJoMvG 9eZw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="C/uLHaEr"; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id e10-20020ac84e4a000000b0042775d5bfbdsi16840340qtw.616.2023.12.28.09.22.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 09:22:07 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="C/uLHaEr"; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 64D8938582B5 for ; Thu, 28 Dec 2023 17:22:06 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by sourceware.org (Postfix) with ESMTPS id 432AD385828A for ; Thu, 28 Dec 2023 17:20:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 432AD385828A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 432AD385828A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::435 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784044; cv=none; b=epLeJeG6PuC3P3fzIaZrZsM3y13xgZdLgsYD4/DmuR0qoehksDR02fA6Wc4E/l3TcLs6jqqyGdlV4W7n6k0KRCsMcEX/lCf/2SUbRxUDp7k+fizTwJqIrx1Ul4yWCxslYIVJk0WQ/0fxq0bBmIP1nrcRyQBVl0ustEqwWhWgSLA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784044; c=relaxed/simple; bh=7LbP0bZAu0KPhjphY2MiUjWs3zO1ol6lJ3u9fop6GiU=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=gLMA9PWh/9w7WsWoF2cU5UobxKKaLQBmPqshD7MaeEw0MBwI7mVmpc7gHliCiZd8K9DPr3vBqkA7mi4kAvedDjdrDklraLaIIYOz7awLr1a2r50J9YD6UEl9baUdhF9P41G3Dr+hDRCGIqnk4NHPPuNl6+rL9B1o6lPRWg5s/ac= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-6d9b267007fso1235078b3a.3 for ; Thu, 28 Dec 2023 09:20:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703784040; x=1704388840; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=G7DAyBPI7iRaNkh70Jq9qwomvSbfKt3p52V+XD56U4Y=; b=C/uLHaErfdqusaP2ZYoc2bwjhQwhouOLaEfXmOAQ331UGQW0epkhMN03WqqgNVnsho SypYA9nr/TgNjAot+/BLcEsX5+OnTS/SXgWgzQT9aIMVUIgWg4J0IUNBf/AQHSBy9j7B 86/TiWLzPt2P4nvxdSkAB+/hyjbHlTeinsmwb4cbi7NeoB7HmlFuBGKuEPerOo/rvFhX 6FkeF8mH/oXD9YHxxwxWvE55U3KYg8BtfAX6dBtXPk5WkE9OJQRRiluka7OJHgzpxGk7 F1zzhCTrriSR5n9xH+qTr2RA4jx0L1dtV5e9Qwx15CIGDc4usR/68uwt7dHHUT07QIvC AgJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703784040; x=1704388840; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=G7DAyBPI7iRaNkh70Jq9qwomvSbfKt3p52V+XD56U4Y=; b=TyDotLdjgmOj06zbBAwPrdS8bE6MxFbqzc9znc7+gXmPuNZzoceIzcLemb9n1vN3SY OJTk9AEE6zI/vSXY7K4LRInPiPEj8sdZLPnYjxB1uAkjQY0aoEAiC5URtwzh1LMhk4Ek D2xFyo4l6RkOW/2iK3tWl8XgrWR4gIHIVgy3bxxyUM7M7jtHCQnpPKHrBKCbCfQ/77Ow pJLQX28IXF7zxZ3hBmFWmMo5ysIlbRjiGgkOJcffxkvHn8Un62bEuHH1sg4Eatm5muwU BXOnzEhSpqPkheUY7BfDi6h35jTWR4cL0ID43Y9yhRYae6jz1wSrZ0d7a7w1aVTQIn/f ytOQ== X-Gm-Message-State: AOJu0Ywl7jnSIaDstAvChSBz42rD9xfA+JdVBAZI6Mhfmsd2q3MF9Ivg iyNEmg33I+RKC2UzLfXbJcuv+nJSu90ytEqjW7Oc+LOGCQ8= X-Received: by 2002:a05:6a00:1acb:b0:6d9:ed3e:af5b with SMTP id f11-20020a056a001acb00b006d9ed3eaf5bmr2960269pfv.2.1703784039799; Thu, 28 Dec 2023 09:20:39 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c1:bd9:84dc:8a87:ea0:57d7]) by smtp.gmail.com with ESMTPSA id q7-20020aa79827000000b006d9a94a03a8sm9593839pfl.77.2023.12.28.09.20.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 09:20:39 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 06/12] math: Add test to check if round raise inexact floating-point exception Date: Thu, 28 Dec 2023 14:20:20 -0300 Message-Id: <20231228172026.2013007-7-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> References: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patch=linaro.org@sourceware.org It is not allowed anymore on ISO C23. --- math/Makefile | 4 ++ math/test-round-except-2.c | 67 ++++++++++++++++++++++++++++++ math/test-round-except.c | 85 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 156 insertions(+) create mode 100644 math/test-round-except-2.c create mode 100644 math/test-round-except.c diff --git a/math/Makefile b/math/Makefile index 7ae107170c..dfe24a8c03 100644 --- a/math/Makefile +++ b/math/Makefile @@ -530,6 +530,8 @@ tests = \ test-nearbyint-except \ test-nearbyint-except-2 \ test-powl \ + test-round-except \ + test-round-except-2 \ test-signgam-uchar \ test-signgam-uchar-init \ test-signgam-uint \ @@ -1001,6 +1003,8 @@ CFLAGS-test-floor-except.c += -fno-builtin CFLAGS-test-floor-except-2.c += -fno-builtin CFLAGS-test-trunc-except.c += -fno-builtin CFLAGS-test-trunc-except-2.c += -fno-builtin +CFLAGS-test-round-except.c += -fno-builtin +CFLAGS-test-round-except-2.c += -fno-builtin include ../Rules diff --git a/math/test-round-except-2.c b/math/test-round-except-2.c new file mode 100644 index 0000000000..dffc02e91f --- /dev/null +++ b/math/test-round-except-2.c @@ -0,0 +1,67 @@ +/* Test round functions do not disable exception traps. + Copyright (C) 2023 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include + +#ifndef FE_INEXACT +# define FE_INEXACT 0 +#endif + +#define TEST_FUNC(NAME, FLOAT, SUFFIX) \ +static int \ +NAME (void) \ +{ \ + int result = 0; \ + volatile FLOAT a, b __attribute__ ((unused)); \ + a = 1.5; \ + /* round must work when traps on "inexact" are enabled. */ \ + b = round ## SUFFIX (a); \ + /* And it must have left those traps enabled. */ \ + if (fegetexcept () == FE_INEXACT) \ + puts ("PASS: " #FLOAT); \ + else \ + { \ + puts ("FAIL: " #FLOAT); \ + result = 1; \ + } \ + return result; \ +} + +TEST_FUNC (float_test, float, f) +TEST_FUNC (double_test, double, ) +TEST_FUNC (ldouble_test, long double, l) + +static int +do_test (void) +{ + if (feenableexcept (FE_INEXACT) == -1) + { + puts ("enabling FE_INEXACT traps failed, cannot test"); + return 77; + } + int result = float_test (); + feenableexcept (FE_INEXACT); + result |= double_test (); + feenableexcept (FE_INEXACT); + result |= ldouble_test (); + return result; +} + +#include diff --git a/math/test-round-except.c b/math/test-round-except.c new file mode 100644 index 0000000000..cd43c964ab --- /dev/null +++ b/math/test-round-except.c @@ -0,0 +1,85 @@ +/* Test round functions do not clear exceptions. + Copyright (C) 2015-2023 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include +#include + +#include + +#ifndef FE_INVALID +# define FE_INVALID 0 +#endif + +static bool any_supported = false; + +#define TEST_FUNC(NAME, FLOAT, SUFFIX) \ +static int \ +NAME (void) \ +{ \ + int result = 0; \ + if (!EXCEPTION_TESTS (FLOAT)) \ + return 0; \ + any_supported = true; \ + volatile FLOAT a, b __attribute__ ((unused)); \ + a = 1.0; \ + /* round must not clear already-raised exceptions. */ \ + feraiseexcept (FE_ALL_EXCEPT); \ + b = round ## SUFFIX (a); \ + if (fetestexcept (FE_ALL_EXCEPT) == FE_ALL_EXCEPT) \ + puts ("PASS: " #FLOAT); \ + else \ + { \ + puts ("FAIL: " #FLOAT); \ + result = 1; \ + } \ + /* But it mustn't lose exceptions from sNaN arguments. */ \ + if (SNAN_TESTS (FLOAT)) \ + { \ + static volatile FLOAT snan = __builtin_nans ## SUFFIX (""); \ + volatile FLOAT c __attribute__ ((unused)); \ + feclearexcept (FE_ALL_EXCEPT); \ + c = round ## SUFFIX (snan); \ + if (fetestexcept (FE_INVALID) == FE_INVALID) \ + puts ("PASS: " #FLOAT " sNaN"); \ + else \ + { \ + puts ("FAIL: " #FLOAT " sNaN"); \ + result = 1; \ + } \ + } \ + return result; \ +} + +TEST_FUNC (float_test, float, f) +TEST_FUNC (double_test, double, ) +TEST_FUNC (ldouble_test, long double, l) + +static int +do_test (void) +{ + int result = float_test (); + result |= double_test (); + result |= ldouble_test (); + if (!any_supported) + return 77; + return result; +} + +#include From patchwork Thu Dec 28 17:20:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 758605 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp4115555wrw; Thu, 28 Dec 2023 09:23:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IHEGjW9ub/rBTa98/ZaWc6XLnB/LIMLc4p1NNdXISE+KkFWyHfPMO36SRInXcRKkHN1BbsR X-Received: by 2002:a05:622a:1483:b0:425:4043:41a5 with SMTP id t3-20020a05622a148300b00425404341a5mr13107758qtx.81.1703784196938; Thu, 28 Dec 2023 09:23:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1703784196; cv=pass; d=google.com; s=arc-20160816; b=kwcZ1Soh3D/k2Wzu9y1Nh2l8fnzUDXmrEAAmdoC6mP/cHKXWn45sqOKAyXX7Dq8Q2i 0LW5qntzlMcMl4HiCamgSXVopZYjCo4AxqkOyAuC3PUwp6rUfVQGKPoy3zVaI6K3czsa WXbi5+UURV7lGvqTvIrRxuQzEEk0ynabDdjqQqeI3XEDB1vEsDFIPK4wrsgt6/dHUvpB 8o6aktxJ50DAVUEXAMOw7VtWFKyhzsO+7sy/WbTn7929bO4nwXL9i/Ppb4B+n22Se2Bn vw8nNmeEVahC2iHRJ6FTbZysqwxbpmu+BD1A0YMlm1hlu2vBeQEXRFMOQCg2cZw5fxdq I2RQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=+NbhUyx25vjdS6Rhk8Zdirg4THsnNQU8QR+D2Twnb8Y=; fh=dHLBnA+MhGtNtN2B2JMAELi4oD+gmgMg7DL8H0jYbkI=; b=Ss3ZTY70kt5SWwJPjnJVt56wQ1H23n4tTkgqdvIbYXLVmnFzzLSTRkkEmmEEubyLwR IdQ0uH0a/hXMpmVVk0GNiYZS3wgNPZk7kN7GMqLApj+Mf7KjCf322qIHt/a4Z89Aoh8G M5zz5kZfGkE2RHAwTqbLNsa8zHiBqZMMA0YaVLb1YiSUZBjqTKJMQSjkCxkSUFJ0rfN3 TMt9kxF8XL7NBNYQrMjJYgKOckU5dq+AHw2nrkdi8r1lIQgnVyFYxTc4j/woIBdeP0q8 WumnFElovN/pW4EOCeZ5pd3YfP6adxGsPHK0dOYNcdaVcqLtAhzDCEBGLp6wdzSAgabu dK+Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lf3OxaO+; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id g10-20020ac8580a000000b00427f8d3b919si1603186qtg.4.2023.12.28.09.23.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 09:23:16 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lf3OxaO+; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 847753858013 for ; Thu, 28 Dec 2023 17:23:16 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by sourceware.org (Postfix) with ESMTPS id 6ABD03858286 for ; Thu, 28 Dec 2023 17:20:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6ABD03858286 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6ABD03858286 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::436 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784045; cv=none; b=ta+vPxfR1A9yScNVfuOmBlL9Bnx8Sy0Iale/LxnAtltTTzjlyzMpHBPANbnLAOjhteYYu7f9aiQ7xjSYS0BIDdFaXyKul2aZPNBfeo/VwqGRf0vchMovSzIk0hQEMsVzmLY8NcudWe5SCKIM+AJAChRAkJFge+8BKIZNp9vQuhY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784045; c=relaxed/simple; bh=iccIFjLRfp4IHbcfo8DyFNAJ2jg78Xfxd8GNb3JH0HQ=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=d6UEUu2I78J+IOjJ4KOuaaneObIRUnlGt16t5OsIBu21/6uyjCRKLVlK4rksBKpirhVaqHXIrh/55QfYcI2NmLJl7W0kCfzb84OTs7jIsCNWymnfLVxLZLcPWwB1y6Ldlg9Py+J/7QHJQkJVyqnuJSCNPwzvmF1YtraDbIKB+WU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-6d98f6e8de1so1816266b3a.0 for ; Thu, 28 Dec 2023 09:20:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703784042; x=1704388842; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=+NbhUyx25vjdS6Rhk8Zdirg4THsnNQU8QR+D2Twnb8Y=; b=lf3OxaO+2++mHcgLPUcJ8hoRAaKVySBYWlV9DM+EeCW4VA3jd7R74PcIZE/QBbxqIa LIHG65dRID87m0ulroRU+y3J3JqV4sfcqUQ9saDPwP3UelaJPYIbfsHCXJbmaI5Itjp3 1e8ku+iySIzq/Ye1Po6fD28flipkMNZ1UQZvXjnfe7u1nc+BgUbSqICTk5rzZTalTHj0 7ShrcKxYWSKCPOCK72USCfjmwCRJoYyGBDer9+2pCmMWKmBuMHc+jaoFiIjXs8tqdNxv b1MDN3rfpRGr6RnZrBMrSqWkj5TH1sYrSZkft5ZI9xWmC+vbphKdYanyPpl4xMFS6jT8 kDmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703784042; x=1704388842; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+NbhUyx25vjdS6Rhk8Zdirg4THsnNQU8QR+D2Twnb8Y=; b=KyFKjgYMF81qXoWuu2imI1TiiVIFLeR2sqds7RaZn7AokGwNrbX5UYKR13QFf2TvjP C5TWmix37xqoricBivTLMmoHqgZhS7AH+wwJkETJOudjMc2iExkl2DMX3tMgpISN6u1y 0tQakDIh3UOY6pq9zp4zHL3aRb/Zg1k/oz9W65XbbCsgaBMkgv7VY1iyNSxVadpMvRY/ 83gBFpj/v7NG1syHydNceynGJh+uKL+Vi4FdxJHbsE+Iyij1XKQZ46LOeQk6t5jmCvnE 1THzdO1mNrnsyunO+CGtihlVn8jeeq0hhkvfuJfuHS2D8ilf26hPg0KiQMxz3jS2OB8m sOLw== X-Gm-Message-State: AOJu0YyeyB4mWOyUCVKSFShSsIxKZSkUD1XrIbx7De0rNwEYxkbDZkSM Z06KerFKC8bPxMNUNfOKuu/c1xu3gpE1culUgH/+bziKXcQ= X-Received: by 2002:a05:6a00:1889:b0:6d9:bcc4:4d08 with SMTP id x9-20020a056a00188900b006d9bcc44d08mr3402608pfh.56.1703784041773; Thu, 28 Dec 2023 09:20:41 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c1:bd9:84dc:8a87:ea0:57d7]) by smtp.gmail.com with ESMTPSA id q7-20020aa79827000000b006d9a94a03a8sm9593839pfl.77.2023.12.28.09.20.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 09:20:41 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 07/12] x86: Do not raise inexact exception on ceill Date: Thu, 28 Dec 2023 14:20:21 -0300 Message-Id: <20231228172026.2013007-8-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> References: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patch=linaro.org@sourceware.org It is not allowed anymore on ISO C23. Checked on x86_64-linux-gnu and i686-linux-gnu. --- sysdeps/i386/fpu/s_ceill.S | 39 ------------------------------------ sysdeps/x86/fpu/s_ceill.c | 38 +++++++++++++++++++++++++++++++++++ sysdeps/x86_64/fpu/s_ceill.S | 34 ------------------------------- 3 files changed, 38 insertions(+), 73 deletions(-) delete mode 100644 sysdeps/i386/fpu/s_ceill.S create mode 100644 sysdeps/x86/fpu/s_ceill.c delete mode 100644 sysdeps/x86_64/fpu/s_ceill.S diff --git a/sysdeps/i386/fpu/s_ceill.S b/sysdeps/i386/fpu/s_ceill.S deleted file mode 100644 index a551fce7f9..0000000000 --- a/sysdeps/i386/fpu/s_ceill.S +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Public domain. - */ - -#include -#include - -RCSID("$NetBSD: $") - -ENTRY(__ceill) - fldt 4(%esp) - subl $32,%esp - cfi_adjust_cfa_offset (32) - - fnstenv 4(%esp) /* store fpu environment */ - - /* We use here %edx although only the low 1 bits are defined. - But none of the operations should care and they are faster - than the 16 bit operations. */ - movl $0x0800,%edx /* round towards +oo */ - orl 4(%esp),%edx - andl $0xfbff,%edx - movl %edx,(%esp) - fldcw (%esp) /* load modified control word */ - - frndint /* round */ - - /* Preserve "invalid" exceptions from sNaN input. */ - fnstsw - andl $0x1, %eax - orl %eax, 8(%esp) - - fldenv 4(%esp) /* restore original environment */ - - addl $32,%esp - cfi_adjust_cfa_offset (-32) - ret -END (__ceill) -libm_alias_ldouble (__ceil, ceil) diff --git a/sysdeps/x86/fpu/s_ceill.c b/sysdeps/x86/fpu/s_ceill.c new file mode 100644 index 0000000000..96c901e383 --- /dev/null +++ b/sysdeps/x86/fpu/s_ceill.c @@ -0,0 +1,38 @@ +/* Return smallest integral value not less than argument. x86 version. + Copyright (C) 2023 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#define NO_MATH_REDIRECT +#include +#include +#include + +long double +__ceill (long double x) +{ + fenv_t fenv; + long double r; + + libc_feholdexcept_setround_387 (&fenv, FE_UPWARD); + asm volatile ("frndint" : "=t" (r) : "0" (x)); + /* Preserve "invalid" exceptions from sNaN input. */ + fenv.__status_word |= libc_fetestexcept_387 (FE_INVALID); + libc_fesetenv_387 (&fenv); + + return r; +} +libm_alias_ldouble (__ceil, ceil) diff --git a/sysdeps/x86_64/fpu/s_ceill.S b/sysdeps/x86_64/fpu/s_ceill.S deleted file mode 100644 index 16dbecd56d..0000000000 --- a/sysdeps/x86_64/fpu/s_ceill.S +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Public domain. - */ - -#include -#include - - -ENTRY(__ceill) - fldt 8(%rsp) - - fnstenv -28(%rsp) /* store fpu environment */ - - /* We use here %edx although only the low 1 bits are defined. - But none of the operations should care and they are faster - than the 16 bit operations. */ - movl $0x0800,%edx /* round towards +oo */ - orl -28(%rsp),%edx - andl $0xfbff,%edx - movl %edx,-32(%rsp) - fldcw -32(%rsp) /* load modified control word */ - - frndint /* round */ - - /* Preserve "invalid" exceptions from sNaN input. */ - fnstsw - andl $0x1, %eax - orl %eax, -24(%rsp) - - fldenv -28(%rsp) /* restore original environment */ - - ret -END (__ceill) -libm_alias_ldouble (__ceil, ceil) From patchwork Thu Dec 28 17:20:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 758606 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp4115603wrw; Thu, 28 Dec 2023 09:23:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IGLa94mIe9jTODQJ4E+5CKg7Wb7F8PUYlRokc1zUfWwhHDJ0bHVfxFHOudmj8+M/H+Pikk1 X-Received: by 2002:a05:622a:1356:b0:425:4043:8d57 with SMTP id w22-20020a05622a135600b0042540438d57mr12817231qtk.114.1703784203262; Thu, 28 Dec 2023 09:23:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1703784203; cv=pass; d=google.com; s=arc-20160816; b=JJDO/AzOLG9A95Cu3iPAL/ALvxK1Yjd4Elajc9JaoFwuwjLBYWWZ03F/GGGriPNKLo 1eEbmM3pcYcbGPHKrkkrYypjZ2K104BBOwhzMvhGk4Mjfbhh+t+H+qByFZJQGrKmsqqP L2C9KxFJVlBapT+TDFAR5V0gGgtSPYxtrf6CX1AemaOmDTuIW7pWdSve3VL0G130j97X X9ruKV8TkenIXw2sSUr6rsUUWERKs4EIU9akDdsmmfRyG+hiSNOSddbJNN1KsEfemzrf AtwYk5Z8S7ORj0X/GAGMfVqXygYAkwzg6ThB9dy8tOwAWxpFe6wb5AggkW4tDmKEumNH t/cA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=wWgi00RdRAG3+ge5c7GtYVas/IOMOL1HlHbPRCVFcDc=; fh=dHLBnA+MhGtNtN2B2JMAELi4oD+gmgMg7DL8H0jYbkI=; b=mPV4U5rNZ0vCHrh8v95XR7azGBKoX5bOAV8iXTnQMeNuRu76DYWD8Kynx4KBZsQJWh sgg51l9dURViYibfcybC8uLzjlV2rNuL8q8zUsQjo8kkbumUoKflLZLIQa5REnLqsSHl KaCtbM6M6yT30BgMZ0KBJmO1FJi7iP6bFRaI62iJeNXBBHsHZpi25FB0sltwp6BonKDk yn8AZSFLOGxb8JRkHSOeHskCPwBhEMvOYHTe59a6jmAmBPhmaIwR7x2ZD5/uWB7O/zPl XQBOi9ZftDVgeUSCegc54iR1iSxSIHpc0Tp1lbSanCfryhpQtmGSklXhXvuE08IB0xrl R1+g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ygkCwpnG; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id g18-20020ac87d12000000b0042785dc2685si17313108qtb.513.2023.12.28.09.23.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 09:23:23 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ygkCwpnG; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D4F2938582B9 for ; Thu, 28 Dec 2023 17:23:21 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by sourceware.org (Postfix) with ESMTPS id EB19C385829F for ; Thu, 28 Dec 2023 17:20:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EB19C385829F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org EB19C385829F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::536 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784048; cv=none; b=RSAfK6lcOS+aGQpnarAXQJ2DgvaFj4RAcc2YrI1OBnln9jQK504hD7V4JlGoBwdQkSq4VKvtxUQC+l1K6yhN0Okj6Q6tl7VYEMr7DBTGhzkQlKrSV3ntrZ1kzdDWK0BrVH5kKf8/1ZuzFV3habzbac5fBLnU+UIetqFXpIJt8Cs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784048; c=relaxed/simple; bh=lnHACzmx0VPJkz/RKocha4/9EZ6Ug05fxfsGdijW3pA=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=vzwp/sbi267Ir0LBQhw4aH540lgDuZTBcmPkho4KBzwhOLPhX1FojjM9qXe40EtNocjGrI6N8vX6Gw5zC0ncGmJXIeqy3qShrrcwqnEkPqyj+IADc4ghwdsE+YoGzHZrXJdlyidh0o1W02SHAUL+3y7q3aaddSbhj1NGGAuDMec= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-5cd8667c59eso4686883a12.2 for ; Thu, 28 Dec 2023 09:20:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703784043; x=1704388843; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=wWgi00RdRAG3+ge5c7GtYVas/IOMOL1HlHbPRCVFcDc=; b=ygkCwpnGMJKFQy8UAzN2zLa/oKdDiUHJsl7qLxPsoxtuwgyEujGy0II7ym5/ZNu6Th L/aeAnimDe36HcWEEl/OO+srDtTvAJURThB0eF9/tQ6pnl5GuyID/RTHXmBT5BWlJJIV Y0IuPfs6SyYdlpvvBt1PTVGJDvWAREaZamaOSMnRWI2pVkuP8Ui3kf6tJwUK4u4nHGQl 6G0PKQPGT+BNBdD2vVJeP0C5/w9FuP+Plp1yy3ABbFYAgulZ3XMR1llS4GT2g/GEoMvB D4bIBR6fJFxOMM+TURJjRv2xnFEv+bG5mtYdABatF9Ynxzw1SscACUuIoFKQ46WQHX50 T69Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703784043; x=1704388843; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wWgi00RdRAG3+ge5c7GtYVas/IOMOL1HlHbPRCVFcDc=; b=ZPsYKXm/dEm7Jh9DxH7P/pCEEdKA5dKtCZCPC6F4R4041C4Iu1X2roGWZSdo3oj9E2 N+zaCNn26fQ+TtHCSoIMkxa+KRGThfslrj0XLYEPdghlO1mRT4kk06eJvVC3eZ66MuRt zuKS4Z6MYb3ReRhywMhShEPcS9TNcdYlZDihuRo8Nxflgi2y2UVXLUg9IQinhOU6HGYZ baPCcS2AT70rSi9jyIy1VH5vmid63MBXwREYF4hodgjXKeeHHuH7C7GC4RbW6Y/o8glX 663EuZ7Eh0Cws82fzz0Vh7PLhVWVW5JMJVNxwZoofkHX6lJp1jvB1ERoU0Cc4xcLEowC KPgQ== X-Gm-Message-State: AOJu0Yzk5AqarLYLuws3mPg7mLXxniI0opX1vQWkv7Lr5otSRwDhPB0W 7oZaRGXqUV9rdb4a8/Cjd+OKcScJRPMPvN7xBivwz+E22E0= X-Received: by 2002:a05:6a20:7d83:b0:196:376c:fb73 with SMTP id v3-20020a056a207d8300b00196376cfb73mr2481823pzj.49.1703784043551; Thu, 28 Dec 2023 09:20:43 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c1:bd9:84dc:8a87:ea0:57d7]) by smtp.gmail.com with ESMTPSA id q7-20020aa79827000000b006d9a94a03a8sm9593839pfl.77.2023.12.28.09.20.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 09:20:42 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 08/12] x86: Do not raise inexact exception on floorl Date: Thu, 28 Dec 2023 14:20:22 -0300 Message-Id: <20231228172026.2013007-9-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> References: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patch=linaro.org@sourceware.org It is not allowed anymore on ISO C23. Checked on x86_64-linux-gnu and i686-linux-gnu. --- sysdeps/i386/fpu/s_floorl.S | 39 ----------------------------------- sysdeps/x86/fpu/s_floorl.c | 38 ++++++++++++++++++++++++++++++++++ sysdeps/x86_64/fpu/s_floorl.S | 33 ----------------------------- 3 files changed, 38 insertions(+), 72 deletions(-) delete mode 100644 sysdeps/i386/fpu/s_floorl.S create mode 100644 sysdeps/x86/fpu/s_floorl.c delete mode 100644 sysdeps/x86_64/fpu/s_floorl.S diff --git a/sysdeps/i386/fpu/s_floorl.S b/sysdeps/i386/fpu/s_floorl.S deleted file mode 100644 index 3ec28b477b..0000000000 --- a/sysdeps/i386/fpu/s_floorl.S +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Public domain. - */ - -#include -#include - -RCSID("$NetBSD: $") - -ENTRY(__floorl) - fldt 4(%esp) - subl $32,%esp - cfi_adjust_cfa_offset (32) - - fnstenv 4(%esp) /* store fpu environment */ - - /* We use here %edx although only the low 1 bits are defined. - But none of the operations should care and they are faster - than the 16 bit operations. */ - movl $0x400,%edx /* round towards -oo */ - orl 4(%esp),%edx - andl $0xf7ff,%edx - movl %edx,(%esp) - fldcw (%esp) /* load modified control word */ - - frndint /* round */ - - /* Preserve "invalid" exceptions from sNaN input. */ - fnstsw - andl $0x1, %eax - orl %eax, 8(%esp) - - fldenv 4(%esp) /* restore original environment */ - - addl $32,%esp - cfi_adjust_cfa_offset (-32) - ret -END (__floorl) -libm_alias_ldouble (__floor, floor) diff --git a/sysdeps/x86/fpu/s_floorl.c b/sysdeps/x86/fpu/s_floorl.c new file mode 100644 index 0000000000..edaf5e954f --- /dev/null +++ b/sysdeps/x86/fpu/s_floorl.c @@ -0,0 +1,38 @@ +/* Return largest integral value not less than argument. x86 version. + Copyright (C) 2023 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#define NO_MATH_REDIRECT +#include +#include +#include + +long double +__floorl (long double x) +{ + fenv_t fenv; + long double r; + + libc_feholdexcept_setround_387 (&fenv, FE_DOWNWARD); + asm volatile ("frndint" : "=t" (r) : "0" (x)); + /* Preserve "invalid" exceptions from sNaN input. */ + fenv.__status_word |= libc_fetestexcept_387 (FE_INVALID); + libc_fesetenv_387 (&fenv); + + return r; +} +libm_alias_ldouble (__floor, floor) diff --git a/sysdeps/x86_64/fpu/s_floorl.S b/sysdeps/x86_64/fpu/s_floorl.S deleted file mode 100644 index b74d1a4d6b..0000000000 --- a/sysdeps/x86_64/fpu/s_floorl.S +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Public domain. - */ - -#include -#include - -ENTRY(__floorl) - fldt 8(%rsp) - - fnstenv -28(%rsp) /* store fpu environment */ - - /* We use here %edx although only the low 1 bits are defined. - But none of the operations should care and they are faster - than the 16 bit operations. */ - movl $0x400,%edx /* round towards -oo */ - orl -28(%rsp),%edx - andl $0xf7ff,%edx - movl %edx,-32(%rsp) - fldcw -32(%rsp) /* load modified control word */ - - frndint /* round */ - - /* Preserve "invalid" exceptions from sNaN input. */ - fnstsw - andl $0x1, %eax - orl %eax, -24(%rsp) - - fldenv -28(%rsp) /* restore original environment */ - - ret -END (__floorl) -libm_alias_ldouble (__floor, floor) From patchwork Thu Dec 28 17:20:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 758607 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp4115681wrw; Thu, 28 Dec 2023 09:23:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IHbCMvEZfrMbFbr2rtxKY9SloDYKismDRgavMaQzDfdyYBZyNw8fKTYZIbOhrlToQyW1hI4 X-Received: by 2002:a05:6214:62a:b0:67f:9eb:f1ec with SMTP id a10-20020a056214062a00b0067f09ebf1ecmr16696179qvx.56.1703784211816; Thu, 28 Dec 2023 09:23:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1703784211; cv=pass; d=google.com; s=arc-20160816; b=QV1Aqo2+F4c2C9ZN6Nhxphsa+D3V1DdCC130JmPGxXHz00mm+96zXZqoIvXZFuujAy u0AVgjTCBQjpY+vv1i8skylfzrv5e4RXwpi6pLVbcwV0Kbql2YGc7vL1dU0au3emuEsf iP6kZRv01xksH1bACeB0NMPXrQv1YEedQ9Le7IXFRAjhGvvRmUmulkCM4FChupiY6S1L HgKW5EuRHnV+3SztbYHqrkZs7pBW8RlFZFcbnIOJskMo1WwU6L9yzfQcb68zfwwt63Jq mwrKISG6yYKe31eq1hfwlMwflGetxYs8pjDhPef+urLJQcfD+w8+AUJ+2SNBpZm8qiPy 6/Og== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=fPFbCo5zJQ/DhKLz/wo4gqZYgwvZ1TiNCDqnPQy/l+Q=; fh=dHLBnA+MhGtNtN2B2JMAELi4oD+gmgMg7DL8H0jYbkI=; b=YwdmQU/mDHpWP8gzSeynN7VziWnxultpAlSc/g6X/wKSUBYcSWXYzCTovHRB8vXdKx UR+mH5Nu5FFZvejryVLVzQj34JDephVebrfQRYJ2zb0FjoffkIRrTJgGt6ZVOtcDN4lW 9bUMqEjrwy6COME94xvydzfOt9u8wrkXcUnIE/N8FxvdlDleg9z5QoTTzLxHp9VC/Rf/ WlrYCE2aWNCKd0SOHUd2rvQrUhdpgOY+FkjtKC+B+qOXT6VIr7RuZa+3THuE8+Lzhr0q Q12hm8A2C3pM6BDJOQa+ACKp7D/ZHnUtlpHsvEx2LA/J2VzCcjV2mfJUToYwCfwTSayi OlHQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hfHNu1bz; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id s15-20020a0ce30f000000b0067f87ec5939si15725364qvl.324.2023.12.28.09.23.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 09:23:31 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hfHNu1bz; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 685F638582A6 for ; Thu, 28 Dec 2023 17:23:31 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by sourceware.org (Postfix) with ESMTPS id A459D385841A for ; Thu, 28 Dec 2023 17:20:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A459D385841A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A459D385841A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::429 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784050; cv=none; b=dZ14rv0TxeNQYJ+twBCvLUwYkc2i/EciN5xnbBS09BGnARE9zZ8YoMU5mLrLigpFWnQkOCFhnbvX2gAx69l6BZCe2T4NhBMy5bWwgBytV0EaQo8rkGXyq4U/66VEaZ+Q51N+/7AYirixYbCahNdQSR8aA3Ck+2v5NA5IdniBLYk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784050; c=relaxed/simple; bh=APmPneg9e9H+Z2LkqQtP3cFsiPjFfGEFus6reP8+IKA=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=ccKLH68LmlM7qtaZWLngubf2zjcFYwtl4ya4Jqbaw9wOzV4lXIcBZbXo1J1jU0iW98C49k0YfAK/YQ0lpdpCs25jkAyJkZJZaPn0v864aqI36acv44A5ZSIWb2f7xYMXgN1DjYsZQxw7OjfzKhY2FFr87FVTyN3Y0R+6Acj3nsA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-6d9cb95ddd1so951728b3a.1 for ; Thu, 28 Dec 2023 09:20:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703784045; x=1704388845; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=fPFbCo5zJQ/DhKLz/wo4gqZYgwvZ1TiNCDqnPQy/l+Q=; b=hfHNu1bz7HelpE2e1+2/trkP9pTjiksPsmQeKzaXOsvkc7h+tR8tZcs8ObpeC5EOpq 1UGcYHJlYeH7+gYwPGmSPnBhqsDd74FWoGq0jV1Yp4vSmB56qwT7ki2IaeVqWMbUG+Qm p+UwUiS2dgteyKaeJk0JsjHdKyQEk8ErlYYI9APBzxJDk/xwqZnIsyG5SCsv5sYWMXbp 8I0BU/gkaVDuSYxsTARQ3vEtGlMLK/BQUmyRA8eE0iUeqIvUMu9MYIBStTV0/buFdxcB 9ESRGgTwUn+jGLHr3AlGIxN/GMqldpjeI41AxvCzMWqm+fa6znlaEaI9mXQRjL5GegzL qeMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703784045; x=1704388845; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fPFbCo5zJQ/DhKLz/wo4gqZYgwvZ1TiNCDqnPQy/l+Q=; b=isczxbK2obvy4sclu8lqtgD9pVKxrH4oQwwDmP7luPtphmKZYuuBFOfvXF82+1qLDR hh3cr0zZwhVCdPQ+H6jNmmdfdu/oBKFRkQjgwnlaJSkLqdPKghOuOw6LgBZKFMMVaEtt fYr4OWXucbNv/RaYKn+B2F2rDc4jYf8imDOSqts+Nvq/wFGG1U1ooWGQWVqWAWZxBe+N D0qFcROKdIA3hxn/krCTFgXeLr0d2YxofEv/gM3aMpiS2IJ86+Id/0eugPT5WZeEVdtu 8QKveXKVIij+XYmFso2k+dNAFF5dK8DDNFdpHEJZcREoOlqH1WmBJu2KIkCmKXa283rb nunQ== X-Gm-Message-State: AOJu0YyDpoIgge33Lb5XcgtO3jYIrH2FsRLZxyfB0hTAG5tSBPnBqfed VnIDzcSSIgqr1SlYQcgVY/Ow9bJ/ALUnlZdPwIfXkNy0pFg= X-Received: by 2002:a05:6a00:1d28:b0:6d9:aa4b:3800 with SMTP id a40-20020a056a001d2800b006d9aa4b3800mr4363471pfx.19.1703784045189; Thu, 28 Dec 2023 09:20:45 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c1:bd9:84dc:8a87:ea0:57d7]) by smtp.gmail.com with ESMTPSA id q7-20020aa79827000000b006d9a94a03a8sm9593839pfl.77.2023.12.28.09.20.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 09:20:44 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 09/12] x86: Do not raise inexact exception on truncl Date: Thu, 28 Dec 2023 14:20:23 -0300 Message-Id: <20231228172026.2013007-10-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> References: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patch=linaro.org@sourceware.org It is not allowed anymore on ISO C23. Checked on x86_64-linux-gnu and i686-linux-gnu. --- .../fpu/s_truncl.S => x86/fpu/s_truncl.c} | 40 +++++++++---------- sysdeps/x86_64/fpu/s_truncl.S | 36 ----------------- 2 files changed, 19 insertions(+), 57 deletions(-) rename sysdeps/{i386/fpu/s_truncl.S => x86/fpu/s_truncl.c} (61%) delete mode 100644 sysdeps/x86_64/fpu/s_truncl.S diff --git a/sysdeps/i386/fpu/s_truncl.S b/sysdeps/x86/fpu/s_truncl.c similarity index 61% rename from sysdeps/i386/fpu/s_truncl.S rename to sysdeps/x86/fpu/s_truncl.c index cfd4e75252..249b307004 100644 --- a/sysdeps/i386/fpu/s_truncl.S +++ b/sysdeps/x86/fpu/s_truncl.c @@ -1,5 +1,5 @@ -/* Truncate long double value. - Copyright (C) 1997-2023 Free Software Foundation, Inc. +/* Round to integer, toward zero. x86 version. + Copyright (C) 2023 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -16,25 +16,23 @@ License along with the GNU C Library; if not, see . */ +#define NO_MATH_REDIRECT +#include +#include #include -#include -ENTRY(__truncl) - fldt 4(%esp) - subl $32, %esp - cfi_adjust_cfa_offset (32) - fnstenv 4(%esp) - movl $0xc00, %edx - orl 4(%esp), %edx - movl %edx, (%esp) - fldcw (%esp) - frndint - fnstsw - andl $0x1, %eax - orl %eax, 8(%esp) - fldenv 4(%esp) - addl $32, %esp - cfi_adjust_cfa_offset (-32) - ret -END(__truncl) +long double +__truncl (long double x) +{ + fenv_t fenv; + long double r; + + libc_feholdexcept_setround_387 (&fenv, FE_TOWARDZERO); + asm volatile ("frndint" : "=t" (r) : "0" (x)); + /* Preserve "invalid" exceptions from sNaN input. */ + fenv.__status_word |= libc_fetestexcept_387 (FE_INVALID); + libc_fesetenv_387 (&fenv); + + return r; +} libm_alias_ldouble (__trunc, trunc) diff --git a/sysdeps/x86_64/fpu/s_truncl.S b/sysdeps/x86_64/fpu/s_truncl.S deleted file mode 100644 index 8d319e68b0..0000000000 --- a/sysdeps/x86_64/fpu/s_truncl.S +++ /dev/null @@ -1,36 +0,0 @@ -/* Truncate long double value. - Copyright (C) 1997-2023 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include - -ENTRY(__truncl) - fldt 8(%rsp) - fnstenv -28(%rsp) - movl $0xc00, %edx - orl -28(%rsp), %edx - movl %edx, -32(%rsp) - fldcw -32(%rsp) - frndint - fnstsw - andl $0x1, %eax - orl %eax, -24(%rsp) - fldenv -28(%rsp) - ret -END(__truncl) -libm_alias_ldouble (__trunc, trunc) From patchwork Thu Dec 28 17:20:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 758608 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp4116045wrw; Thu, 28 Dec 2023 09:24:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IHb+ZEkXVNAm0mgy/suaUIGswklbMXOglFkx1AqRPRpabJsn2za05bDg74uS3NrrXSW88yl X-Received: by 2002:a05:620a:15b5:b0:781:481a:ad1a with SMTP id f21-20020a05620a15b500b00781481aad1amr8022856qkk.54.1703784268360; Thu, 28 Dec 2023 09:24:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1703784268; cv=pass; d=google.com; s=arc-20160816; b=QUqMSlFqYL6CtnA85c1ZVpofK7+vEQCItb4nNwkfNXkEN+xQ3dRhIoFvQP7BDEv0gI SStLHQll5qg9Np570KT5sJcWC8rGmDyHShYmdktYKPL7m10W0Jtrg3nRj7kDeXJU5Nuv hCE1Rw9hIpexQsppRYDwGeI+6q3c0H+nTimkXPRFHz8OAD88VzRj6YBUAh9RbDVpTNzD UYTu6KZZbiAYLUertojGVra2SKH81La6PRuNWFIQpS6fPjAaaJIRPN2wiaCP3I1aNB3d QERB2Omj6yJASAXkqZ8eCx+lQno37ViC1II/aHcNe5PHwaDyDPDdHbKIucUx3xkIq6a3 lYYQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=E7XT36BDRDRv2ECRkleLFmh2oLzr2LBN3XN55zu8I98=; fh=dHLBnA+MhGtNtN2B2JMAELi4oD+gmgMg7DL8H0jYbkI=; b=ljNYprYx7sOhlJUenOjnvhyL/rA9+DbQLcsmXxMBUv3jQ5waHg2Vv8Az6sTwJ4OwkH XRVA6qFcJgHg4nxSWRtk7+yIdiH4gBOxdfFCeTZbJNQgOyY/mFvw+oaodDTVUu7R1vWO gscPfOVfLMRyfdHkvATRxZKWNJxFd+fyjd+n5j6SI7BIZPuuqO59clXnOdugdpuWOD7p FCygroC7+ptTYRBGbNqVxW114rFLrHfTiMMSQvjcy6weM7Jb8zn6G1Jr8T9soe9n8lwI J7O6W18Qdwf/t2GMI4KP2P68TAAbsU7B7ydhAyT2o039OA8EKD4FhkVMwxJoMzwIo8g6 nlRg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HAgC43CF; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id v24-20020a05620a123800b007811b138946si16489690qkj.751.2023.12.28.09.24.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 09:24:28 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HAgC43CF; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EA56D3858296 for ; Thu, 28 Dec 2023 17:24:27 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by sourceware.org (Postfix) with ESMTPS id 2279F385842C for ; Thu, 28 Dec 2023 17:20:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2279F385842C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2279F385842C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::435 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784050; cv=none; b=hWbjip6P/6m23UFMTJyB3c6/AQWfl7sHyOuvxVPqKtGhRGovT7o/aaN+9Xz4Pdk365F+BmbDmVSihUWFSSN7zvX/dLrzXiI44MBneiKtSoPxb7GU/piUWhyUrUSyEmveyyYi2L8IjA5ZJiMzxOlrTN6AhsSWyytLBOBexltMPa0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784050; c=relaxed/simple; bh=Fyf/Ec11BxuJoVcKbZMh9bSiwbRwSaF+LgXnKbza1ec=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=nhnmu1y9zb//deB+0vkeNXy8mro8ngp78FUv4OU9SLrzD9HA3Odc5b3r2brBKEFuIu5S7WDMkebZvGRlxKDc3IqOCBxjSy/qmPpyoJ+6h6elY6nQmAz1w5ID5hjEpbZA5qhdJRgVoIaCrKCwZUf6dGrZEBWe4aSLfeoeeivHWfk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-6da202aa138so503178b3a.2 for ; Thu, 28 Dec 2023 09:20:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703784047; x=1704388847; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=E7XT36BDRDRv2ECRkleLFmh2oLzr2LBN3XN55zu8I98=; b=HAgC43CF9fzxzztqH1plIs90oARd7bvVCIRGpktj8r4/S807oGf0zRPTNyqd2CqdN0 7Bx/K7npnwNeXnYm6wAxQJ4ldqjdlkTFOkkunt+zEKBa+INvSWDqt06ieGOImFQB+0Mr RxJifIa/fauXAxgaiEHPCJVoKzJz7MbbyJmIkon5iP+CaK/fFrznWpDATSCkil+8J9DH 9Ok9ZKWi7y8aqa92qi67Nm+EoKgAa9x6Cjt1XsoZK/DGAbAdysi0pyf1st25K6ll3gCO P9guPr9KbLPmadPdNHDFWuWqLq5a1YbFdUCW15OzA9jIdlwfWqJ8DEzuqlgalT7bimdW GW1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703784047; x=1704388847; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=E7XT36BDRDRv2ECRkleLFmh2oLzr2LBN3XN55zu8I98=; b=QwHqZtdsbvjeTFnj4G2+QDXpdEZPtLzEeSlat3+GAGKIGYYisvV1DTo03dMkQBu7iE XQ+wULbK2IVxCz0b8fJ8vY5PoxcNYq4sMznEjRVANmAi6YsGqM4oLIrB88acobLIwuDL fcs7Q9gYARrdnBBIVGTSQGjOqjX7mpg9KYCAudMvlO6AMYkROujtO+ozqOdSypMq/g+n U9AuGZdNCXDroGkSNpopl3nFloD2o36VXv6Hwt8h4BSorK9Wx6ta3ZcQyeYlv2RjJUXG /Pb/TyLB01vRTsUAXeFBVYD3/2a3NCevVHtdRPPDfsVpKIGsi1JgSud8hjEyhwAcQIk7 VVUA== X-Gm-Message-State: AOJu0Yy8/UXFePx86MNxyLo3sj8KBE9FjkORZfJ/oHwNnTpuDFznp5EU ZKImo7QvWEV7jydrSCDmP/0eLcyYZM9bKDQtVSEWA1xRVJ4= X-Received: by 2002:aa7:90d8:0:b0:6d9:aa94:a38b with SMTP id k24-20020aa790d8000000b006d9aa94a38bmr7859888pfk.5.1703784046618; Thu, 28 Dec 2023 09:20:46 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c1:bd9:84dc:8a87:ea0:57d7]) by smtp.gmail.com with ESMTPSA id q7-20020aa79827000000b006d9a94a03a8sm9593839pfl.77.2023.12.28.09.20.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 09:20:46 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 10/12] x86: Do not raise inexact exception on floor/floorf Date: Thu, 28 Dec 2023 14:20:24 -0300 Message-Id: <20231228172026.2013007-11-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> References: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patch=linaro.org@sourceware.org It is not allowed anymore on ISO C23. Checked on x86_64-linux-gnu and i686-linux-gnu. --- sysdeps/i386/fpu/s_floor.S | 34 --------------------------------- sysdeps/i386/fpu/s_floor.c | 38 +++++++++++++++++++++++++++++++++++++ sysdeps/i386/fpu/s_floorf.S | 34 --------------------------------- sysdeps/i386/fpu/s_floorf.c | 38 +++++++++++++++++++++++++++++++++++++ 4 files changed, 76 insertions(+), 68 deletions(-) delete mode 100644 sysdeps/i386/fpu/s_floor.S create mode 100644 sysdeps/i386/fpu/s_floor.c delete mode 100644 sysdeps/i386/fpu/s_floorf.S create mode 100644 sysdeps/i386/fpu/s_floorf.c diff --git a/sysdeps/i386/fpu/s_floor.S b/sysdeps/i386/fpu/s_floor.S deleted file mode 100644 index 7143fdcc9a..0000000000 --- a/sysdeps/i386/fpu/s_floor.S +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Public domain. - */ - -#include -#include - -RCSID("$NetBSD: s_floor.S,v 1.4 1995/05/09 00:01:59 jtc Exp $") - -ENTRY(__floor) - fldl 4(%esp) - subl $32,%esp - cfi_adjust_cfa_offset (32) - - fnstenv 4(%esp) /* store fpu environment */ - - /* We use here %edx although only the low 1 bits are defined. - But none of the operations should care and they are faster - than the 16 bit operations. */ - movl $0x400,%edx /* round towards -oo */ - orl 4(%esp),%edx - andl $0xf7ff,%edx - movl %edx,(%esp) - fldcw (%esp) /* load modified control word */ - - frndint /* round */ - - fldenv 4(%esp) /* restore original environment */ - - addl $32,%esp - cfi_adjust_cfa_offset (-32) - ret -END (__floor) -libm_alias_double (__floor, floor) diff --git a/sysdeps/i386/fpu/s_floor.c b/sysdeps/i386/fpu/s_floor.c new file mode 100644 index 0000000000..90ba61da92 --- /dev/null +++ b/sysdeps/i386/fpu/s_floor.c @@ -0,0 +1,38 @@ +/* Return largest integral value not less than argument. i386 version. + Copyright (C) 2023 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#define NO_MATH_REDIRECT +#include +#include +#include + +double +__floor (double x) +{ + fenv_t fenv; + double r; + + libc_feholdexcept_setround_387 (&fenv, FE_DOWNWARD); + asm volatile ("frndint" : "=t" (r) : "0" (x)); + /* Preserve "invalid" exceptions from sNaN input. */ + fenv.__status_word |= libc_fetestexcept_387 (FE_INVALID); + libc_fesetenv_387 (&fenv); + + return r; +} +libm_alias_double (__floor, floor) diff --git a/sysdeps/i386/fpu/s_floorf.S b/sysdeps/i386/fpu/s_floorf.S deleted file mode 100644 index 8fad9c0698..0000000000 --- a/sysdeps/i386/fpu/s_floorf.S +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Public domain. - */ - -#include -#include - -RCSID("$NetBSD: s_floorf.S,v 1.3 1995/05/09 00:04:32 jtc Exp $") - -ENTRY(__floorf) - flds 4(%esp) - subl $32,%esp - cfi_adjust_cfa_offset (32) - - fnstenv 4(%esp) /* store fpu environment */ - - /* We use here %edx although only the low 1 bits are defined. - But none of the operations should care and they are faster - than the 16 bit operations. */ - movl $0x400,%edx /* round towards -oo */ - orl 4(%esp),%edx - andl $0xf7ff,%edx - movl %edx,(%esp) - fldcw (%esp) /* load modified control word */ - - frndint /* round */ - - fldenv 4(%esp) /* restore original environment */ - - addl $32,%esp - cfi_adjust_cfa_offset (-32) - ret -END (__floorf) -libm_alias_float (__floor, floor) diff --git a/sysdeps/i386/fpu/s_floorf.c b/sysdeps/i386/fpu/s_floorf.c new file mode 100644 index 0000000000..0e7e8223a8 --- /dev/null +++ b/sysdeps/i386/fpu/s_floorf.c @@ -0,0 +1,38 @@ +/* Return largest integral value not less than argument. i386 version. + Copyright (C) 2023 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#define NO_MATH_REDIRECT +#include +#include +#include + +float +__floorf (float x) +{ + fenv_t fenv; + float r; + + libc_feholdexcept_setround_387 (&fenv, FE_DOWNWARD); + asm volatile ("frndint" : "=t" (r) : "0" (x)); + /* Preserve "invalid" exceptions from sNaN input. */ + fenv.__status_word |= libc_fetestexcept_387 (FE_INVALID); + libc_fesetenv_387 (&fenv); + + return r; +} +libm_alias_float (__floor, floor) From patchwork Thu Dec 28 17:20:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 758609 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp4116352wrw; Thu, 28 Dec 2023 09:25:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IEdWL7zpmmeU9O1NvvL0rxkljz4NrQIVs5Ygp+ftYSH/l25cWENyG8IidsyFSqnB2tUqQEF X-Received: by 2002:ae9:c210:0:b0:77f:32ab:4989 with SMTP id j16-20020ae9c210000000b0077f32ab4989mr10503658qkg.133.1703784313152; Thu, 28 Dec 2023 09:25:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1703784313; cv=pass; d=google.com; s=arc-20160816; b=ucrFTL2HFI0HvlIAiU5joISxM0AYqTEvmOvzjkMxp2XrZkIvivN8wVER2QnwsvLjLy PNpwlRlF/N41khDzIa2GkcMNg7HOB/W8nV26DS3peKgvKQwWYqKu9sFytMibWtxC4Oaa gJIFMgG6ssouKB9vx4aWJ69QJuCMquq+GK4eLlwPhIDncp+IdUYHxiuGLdkr0x4L6Fjo E10Tj/ZY33UzPI6MZ8ak6ML7lr1TRu0RFuJM5KMDT/cP4Py41fa9Qngn8uqOGPrNXWtp AIt2TP45ae54clFezmoLxKXSLHHKxoS41EeoOtvNElqBkARR9YCWgG7lb5hw6OFpmnxw GlJA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=76aBXE3UrOPVF+O7d9VzYNthTJeLJTw6ogbUAjN8z+0=; fh=dHLBnA+MhGtNtN2B2JMAELi4oD+gmgMg7DL8H0jYbkI=; b=YoeBz9xuvLSC1q8tkqbLjGyNgMAftVK0EDaIhMUG3SKJVK6+Gi+maIv5QK5SsPCFyR 7zdR8Fv/d+s+O+TnmbMckTJQPYoVEgJ+aQ7TgAHDr2v/o40rABT9OitrVquc9OYCDKBB t34C8GiijHRyooVgAVxufxhKU94Gd6vvL8o8d/Lquae6ilwXP8TzIgJHeWWvQAgq8qaC lXnte+8pi0zYL1tFmBgud5Y/39kGTgmr7bDPE/OkOuZkNVFFyKJC4kIH4XrqbcnjUGxz 0e50wBT5mrp6mBf7HK6geMx+ii7PwdkE/iTUpTzzhbSkPFh11jrDZjzEjQTGm7hEqCIh IMZg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="SaWtldn/"; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id p26-20020a05620a113a00b0078155486896si5688365qkk.644.2023.12.28.09.25.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 09:25:13 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="SaWtldn/"; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C3411385842C for ; Thu, 28 Dec 2023 17:25:12 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oa1-x33.google.com (mail-oa1-x33.google.com [IPv6:2001:4860:4864:20::33]) by sourceware.org (Postfix) with ESMTPS id C39E038582B3 for ; Thu, 28 Dec 2023 17:20:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C39E038582B3 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C39E038582B3 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:4860:4864:20::33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784052; cv=none; b=tkl7m4dQZg2WCspwGkBRlYqpyiIRbt6pxHiliOuSr97LeKJ7Tv+LR4tIk5Y8KHLwMRV54WYTwm+r+9+WPdJfHRDVXoDGnivZBODrJl3Tb76HXELzrMLQc0Gb4P1CfE1x305W2qMS+e9mhe+NSm3m7j+vl/kIcA1rWWumJ3VG744= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784052; c=relaxed/simple; bh=NO5XYk+qncsfEiGHVdntk+f4jc1W/NdZGwux3E14TC4=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=v+C4SddEYw2EYLqt7ehzVLVmOIj0pv+QLIem63QhNw7KQqHdu1Q2NgYI8S21yFZGisGAunMUZ1iIhFOQxteKS63++hXHGs4ii120s4aMnUL2ND6ydC2caPzgcPRg5rOWoslI1lF7HVfx2oxdGLJhtUi1YzyUbPAN+7H/YFIouK0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-204520717b3so3526554fac.0 for ; Thu, 28 Dec 2023 09:20:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703784048; x=1704388848; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=76aBXE3UrOPVF+O7d9VzYNthTJeLJTw6ogbUAjN8z+0=; b=SaWtldn/FvbagikVsIIFDuanFVapTPuKPstGiRwy6T4ima2UhZk1PSEmZP8d0aMmOI I5M5Y6R9v4PNPJ6w7GnpwZfEhxh4QyTwWsmRllW/Bd8WoeGFWSexzgfnGW1+hlyl/Ots TIaN24KaCh8+nP1gM3ksoCdQZ9HWmDJmdsEWkqkzSZHLykI4XAWK+7MhodC0AmMXFxNH of6V8x9OiL9VZUkGUlgv0VEfu8A/UTxA79rDMsskPvqxjhfw9Fpjfh4pCg35nSHZDfqs SarZNPmKPhz1xDxvb3A9fAALTZq96Qb14t5UayYbwn+Wj68RMa7TO32oAirtQFZt0b3u hGOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703784048; x=1704388848; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=76aBXE3UrOPVF+O7d9VzYNthTJeLJTw6ogbUAjN8z+0=; b=q7KjCQli2LqrGVhnskE6tuvtXk292lU4uwe8oR3ilSq4iiWNq4eJVyj5V6AWl9FclT emApqvgjgFMFJLT8SG33c/3L0fKXBv0aasaXSCcMDdzkpkrTYHCJ4ZSpWxPOT5dECdev hU8G/BuZnXg0snp3f5jpbAvRGc7xLW9W5gO9yNwdn788oS/w8R/IcH9vBfYEDczio7p1 O0ffS4PcsXV/EFKJ1iL1nRxvLT5LSK03QQZOv+PHbIntpwpUTAjbJjpjHfTkG1YqLVUa baS6mXBmHSPMDfHHM5fD5iAjRDRRbbhYguE5Vc4TWtKZMPsAemycnvonMlcz9gW3+L2/ gVdw== X-Gm-Message-State: AOJu0YztAlzcEblQR/gTMlBuUCvaDcl97kv2n2sDx7yTDzOX6kJmUnP5 P/B2OxX8HLfsY8quEK07o0Q6khM4U62+NiixumuIcq5KI44= X-Received: by 2002:a05:6870:2194:b0:204:4093:b89b with SMTP id l20-20020a056870219400b002044093b89bmr12228921oae.31.1703784048180; Thu, 28 Dec 2023 09:20:48 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c1:bd9:84dc:8a87:ea0:57d7]) by smtp.gmail.com with ESMTPSA id q7-20020aa79827000000b006d9a94a03a8sm9593839pfl.77.2023.12.28.09.20.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 09:20:47 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 11/12] i386: Do not raise inexact exception on ceil/ceilf Date: Thu, 28 Dec 2023 14:20:25 -0300 Message-Id: <20231228172026.2013007-12-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> References: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patch=linaro.org@sourceware.org It is not allowed anymore on ISO C23. Checked on x86_64-linux-gnu and i686-linux-gnu. --- sysdeps/i386/fpu/s_ceil.S | 34 ---------------------------------- sysdeps/i386/fpu/s_ceil.c | 38 ++++++++++++++++++++++++++++++++++++++ sysdeps/i386/fpu/s_ceilf.S | 34 ---------------------------------- sysdeps/i386/fpu/s_ceilf.c | 38 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 76 insertions(+), 68 deletions(-) delete mode 100644 sysdeps/i386/fpu/s_ceil.S create mode 100644 sysdeps/i386/fpu/s_ceil.c delete mode 100644 sysdeps/i386/fpu/s_ceilf.S create mode 100644 sysdeps/i386/fpu/s_ceilf.c diff --git a/sysdeps/i386/fpu/s_ceil.S b/sysdeps/i386/fpu/s_ceil.S deleted file mode 100644 index 99984f9b8d..0000000000 --- a/sysdeps/i386/fpu/s_ceil.S +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Public domain. - */ - -#include -#include - -RCSID("$NetBSD: s_ceil.S,v 1.4 1995/05/08 23:52:13 jtc Exp $") - -ENTRY(__ceil) - fldl 4(%esp) - subl $32,%esp - cfi_adjust_cfa_offset (32) - - fnstenv 4(%esp) /* store fpu environment */ - - /* We use here %edx although only the low 1 bits are defined. - But none of the operations should care and they are faster - than the 16 bit operations. */ - movl $0x0800,%edx /* round towards +oo */ - orl 4(%esp),%edx - andl $0xfbff,%edx - movl %edx,(%esp) - fldcw (%esp) /* load modified control word */ - - frndint /* round */ - - fldenv 4(%esp) /* restore original environment */ - - addl $32,%esp - cfi_adjust_cfa_offset (-32) - ret -END (__ceil) -libm_alias_double (__ceil, ceil) diff --git a/sysdeps/i386/fpu/s_ceil.c b/sysdeps/i386/fpu/s_ceil.c new file mode 100644 index 0000000000..ec948ef83f --- /dev/null +++ b/sysdeps/i386/fpu/s_ceil.c @@ -0,0 +1,38 @@ +/* Return smallest integral value not less than argument. i386 version. + Copyright (C) 2023 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#define NO_MATH_REDIRECT +#include +#include +#include + +double +__ceil (double x) +{ + fenv_t fenv; + double r; + + libc_feholdexcept_setround_387 (&fenv, FE_UPWARD); + asm volatile ("frndint" : "=t" (r) : "0" (x)); + /* Preserve "invalid" exceptions from sNaN input. */ + fenv.__status_word |= libc_fetestexcept_387 (FE_INVALID); + libc_fesetenv_387 (&fenv); + + return r; +} +libm_alias_double (__ceil, ceil) diff --git a/sysdeps/i386/fpu/s_ceilf.S b/sysdeps/i386/fpu/s_ceilf.S deleted file mode 100644 index 03e8e22609..0000000000 --- a/sysdeps/i386/fpu/s_ceilf.S +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Public domain. - */ - -#include -#include - -RCSID("$NetBSD: s_ceilf.S,v 1.3 1995/05/08 23:52:44 jtc Exp $") - -ENTRY(__ceilf) - flds 4(%esp) - subl $32,%esp - cfi_adjust_cfa_offset (32) - - fnstenv 4(%esp) /* store fpu environment */ - - /* We use here %edx although only the low 1 bits are defined. - But none of the operations should care and they are faster - than the 16 bit operations. */ - movl $0x0800,%edx /* round towards +oo */ - orl 4(%esp),%edx - andl $0xfbff,%edx - movl %edx,(%esp) - fldcw (%esp) /* load modified control word */ - - frndint /* round */ - - fldenv 4(%esp) /* restore original environment */ - - addl $32,%esp - cfi_adjust_cfa_offset (-32) - ret -END (__ceilf) -libm_alias_float (__ceil, ceil) diff --git a/sysdeps/i386/fpu/s_ceilf.c b/sysdeps/i386/fpu/s_ceilf.c new file mode 100644 index 0000000000..36159610b2 --- /dev/null +++ b/sysdeps/i386/fpu/s_ceilf.c @@ -0,0 +1,38 @@ +/* Return largest integral value not less than argument. i386 version. + Copyright (C) 2023 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#define NO_MATH_REDIRECT +#include +#include +#include + +float +__ceilf (float x) +{ + fenv_t fenv; + float r; + + libc_feholdexcept_setround_387 (&fenv, FE_UPWARD); + asm volatile ("frndint" : "=t" (r) : "0" (x)); + /* Preserve "invalid" exceptions from sNaN input. */ + fenv.__status_word |= libc_fetestexcept_387 (FE_INVALID); + libc_fesetenv_387 (&fenv); + + return r; +} +libm_alias_float (__ceil, ceil) From patchwork Thu Dec 28 17:20:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 758604 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp4115552wrw; Thu, 28 Dec 2023 09:23:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IE4RWFx+VqLqNkHMYVIV1oFCPS7WtkU9cDolPdD1oZefUxI7Qbi6GKSicC1Y7ZzHXyYPGrd X-Received: by 2002:a05:6214:2aab:b0:67f:6982:ed93 with SMTP id js11-20020a0562142aab00b0067f6982ed93mr15301592qvb.60.1703784196546; Thu, 28 Dec 2023 09:23:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1703784196; cv=pass; d=google.com; s=arc-20160816; b=y32WyCeAk0ZzykFecF7FpjwC3OG7eQnN3KA1Iw1FvkBRuKHT//t+ZhSDNQIGNbY2LI BQamttKvhDnj6pecPv9gtfpAvFXIF11xDo2uxsms9LNLcQdzaSKcTTAGckVU4xe/BOAS P8eV62GawvEXrWpiQQXfUbO9ourO2rksSB165Hjmz6QvxFK/Cx3OCW6q4amqJhPxtfxk k5YUJQslVi/lEjw6MXLPz9Tt2ApqknD1hdFkE+lh+jnqqvF6tT4lnx4LMj2LFV1WFbHJ cCwLFHmwryvqOzjMEno5WY6ppz6DM/MbC3HTUbsbxjE0D1vwvQo4wBEWcg1GrMPbkcYl jwlw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=w/9PHEFPptWXcVnPOvZucTuCoSC877hTCncf9odbS5g=; fh=dHLBnA+MhGtNtN2B2JMAELi4oD+gmgMg7DL8H0jYbkI=; b=wTHydT5MExobNxmRHvyOgAq3PzQ4KOvmhv4lqW7ZwWXpscBTcP2yNOkUee/uGS6d2z s9n6bchsLOjG0tfgwabBBGgxqjxyP6wEayowZDHLZFUc/gC8QlAoqr8H7VxdV0R253Oe z1XhxL78gUu1P+HBEhuzHzjJJHxGOVTwyIFAYg8J6MV6oyLPZjShnw63n7wg0d0IVWtb zQPUrpsTSyqMbRDGRKKlDoYOup3HJusy4C1OdnerP5xd02zpDOo/GeEQOXJW+2+mLz/Z voRRwB8ga5aX8l9aUdEba1qzVCSifltRo42hoywyp3AH+5sypQ1QKlBBPK+7OMK2z7A/ gOUA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LBhBwTNj; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id a9-20020a0ce389000000b0067f982ddf03si13978706qvl.509.2023.12.28.09.23.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 09:23:16 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LBhBwTNj; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2393938582A6 for ; Thu, 28 Dec 2023 17:23:16 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by sourceware.org (Postfix) with ESMTPS id 5C9973858002 for ; Thu, 28 Dec 2023 17:20:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5C9973858002 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5C9973858002 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::42b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784054; cv=none; b=x+srz2HO+ijxljjJWIg9wEAZpUEyVy2g+F0YR13s8sqPxJTyz02BsUgkjrZj9K+ee4RaWyUOCBI4PTdzb8DLEAh+Uw2tTISrUBljxeLV+1t6uDo0nPxqrjW22RMET6DRtZVCn9HrM1irr8J7di2K8y9MfILRqCmFO8nSj0QRjl8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784054; c=relaxed/simple; bh=D1yDmR5qcLzfU4mCnflNeZnmm0PZuf08hTKF6ZZ10IM=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=GxTqAiNm6UwtRLI05xnTLAkq1R9kqm3bD59TEE6LgaZOYUK4/+oYP9z699/dHFfWjYLw1e6To0iAgcZxPCaLOTW+AF9D1E6zSVMxXP37/in00hGCHKeWO+Aqj0tJsell62Q1bc8bESUvTBEtRLgzMTuzCHjJXMNFWCuFGh+J7YU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-6d099d316a8so5751034b3a.0 for ; Thu, 28 Dec 2023 09:20:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703784050; x=1704388850; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=w/9PHEFPptWXcVnPOvZucTuCoSC877hTCncf9odbS5g=; b=LBhBwTNjWVb4e+UW3nRpwPUQnWmInQ6B1ITIm4AUxlw6jfaRM55vhVCVTXAnizGj00 NKlFckWiZqL2jDG6maKE164b9SrsUaluas7ohB4iuQ/NzZYkKnthOtEnbycC8oBBph55 2WJUWlNR085ljNuSU+BgQo7UZjvWv+qKDC45VIje0T+J8epsX/M1CMwYgh5BFUSfaKCS kEY3M8l5YPmx/5fULJuMjrOiFzRdnZN/KnXU4XGl/D9VOTyWXS7N/HcVFm8JYX5LlRYq G1J0CzsqPHweGp/AsuRjYogGGGiorqIdl5fysJC7Lq6sReHMDS47oOJbhigq5QLIaG/X PpCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703784050; x=1704388850; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=w/9PHEFPptWXcVnPOvZucTuCoSC877hTCncf9odbS5g=; b=fLIDCgR/CCzXizrNptN7zXPhywGYcNzUvd33SY0cw9qRVIvvVQw70sJUdOmG8wIavC ZatNFxLAZId7x1OckqeQFEekH4Xb64EjN9GK5I19FGn1gvkUjOJWbdvDKkA/+3fff0rW dbBOBcDXBwp4Ta9uPbOkODz5O4YlBP32VaaHt5Dxa87X/aEfnSlzPDUBnCKIaj8br99i 7i+MLOHiD99H8KKdADHZKuEVkftcOEtjdggQppxi2K2Z5vWapsny0PnurJD3q6NoJjDL NxiUtuHFmJyPNz6UTGxFg78U4cqefRAea0ktxqY3cEpgsn/3LWXlYA5lx9rFzsqu7fvU enfA== X-Gm-Message-State: AOJu0YzMpDwnYiE0THw1ZDhMeNJ/usSMgsj4QIZT0kHrPF4MWTff7UK6 w6Yo6m8vetp0j6kczJyNSvh1uo4W8Xy+9Tjss1O7XvYznUo= X-Received: by 2002:a05:6a20:8825:b0:195:bda4:4b2d with SMTP id c37-20020a056a20882500b00195bda44b2dmr4972533pzf.102.1703784049819; Thu, 28 Dec 2023 09:20:49 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c1:bd9:84dc:8a87:ea0:57d7]) by smtp.gmail.com with ESMTPSA id q7-20020aa79827000000b006d9a94a03a8sm9593839pfl.77.2023.12.28.09.20.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 09:20:49 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 12/12] i386: Do not raise inexact exception on trunc/truncf Date: Thu, 28 Dec 2023 14:20:26 -0300 Message-Id: <20231228172026.2013007-13-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> References: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patch=linaro.org@sourceware.org It is not allowed anymore on ISO C23. Checked on x86_64-linux-gnu and i686-linux-gnu. --- sysdeps/i386/fpu/{s_trunc.S => s_trunc.c} | 37 +++++++++++---------- sysdeps/i386/fpu/{s_truncf.S => s_truncf.c} | 37 +++++++++++---------- 2 files changed, 38 insertions(+), 36 deletions(-) rename sysdeps/i386/fpu/{s_trunc.S => s_trunc.c} (61%) rename sysdeps/i386/fpu/{s_truncf.S => s_truncf.c} (61%) diff --git a/sysdeps/i386/fpu/s_trunc.S b/sysdeps/i386/fpu/s_trunc.c similarity index 61% rename from sysdeps/i386/fpu/s_trunc.S rename to sysdeps/i386/fpu/s_trunc.c index 145288bc8e..b071ad9750 100644 --- a/sysdeps/i386/fpu/s_trunc.S +++ b/sysdeps/i386/fpu/s_trunc.c @@ -1,5 +1,5 @@ -/* Truncate double value. - Copyright (C) 1997-2023 Free Software Foundation, Inc. +/* Round to integer, toward zero. i386 version. + Copyright (C) 2023 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -16,22 +16,23 @@ License along with the GNU C Library; if not, see . */ -#include +#define NO_MATH_REDIRECT +#include +#include #include -ENTRY(__trunc) - fldl 4(%esp) - subl $32, %esp - cfi_adjust_cfa_offset (32) - fnstenv 4(%esp) - movl $0xc00, %edx - orl 4(%esp), %edx - movl %edx, (%esp) - fldcw (%esp) - frndint - fldenv 4(%esp) - addl $32, %esp - cfi_adjust_cfa_offset (-32) - ret -END(__trunc) +double +__trunc (double x) +{ + fenv_t fenv; + double r; + + libc_feholdexcept_setround_387 (&fenv, FE_TOWARDZERO); + asm volatile ("frndint" : "=t" (r) : "0" (x)); + /* Preserve "invalid" exceptions from sNaN input. */ + fenv.__status_word |= libc_fetestexcept_387 (FE_INVALID); + libc_fesetenv_387 (&fenv); + + return r; +} libm_alias_double (__trunc, trunc) diff --git a/sysdeps/i386/fpu/s_truncf.S b/sysdeps/i386/fpu/s_truncf.c similarity index 61% rename from sysdeps/i386/fpu/s_truncf.S rename to sysdeps/i386/fpu/s_truncf.c index 7bdf0e5111..86d46ff660 100644 --- a/sysdeps/i386/fpu/s_truncf.S +++ b/sysdeps/i386/fpu/s_truncf.c @@ -1,5 +1,5 @@ -/* Truncate float value. - Copyright (C) 1997-2023 Free Software Foundation, Inc. +/* Round to integer, toward zero. i386 version. + Copyright (C) 2023 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -16,22 +16,23 @@ License along with the GNU C Library; if not, see . */ -#include +#define NO_MATH_REDIRECT +#include +#include #include -ENTRY(__truncf) - flds 4(%esp) - subl $32, %esp - cfi_adjust_cfa_offset (32) - fnstenv 4(%esp) - movl $0xc00, %edx - orl 4(%esp), %edx - movl %edx, (%esp) - fldcw (%esp) - frndint - fldenv 4(%esp) - addl $32, %esp - cfi_adjust_cfa_offset (-32) - ret -END(__truncf) +float +__truncf (float x) +{ + fenv_t fenv; + float r; + + libc_feholdexcept_setround_387 (&fenv, FE_TOWARDZERO); + asm volatile ("frndint" : "=t" (r) : "0" (x)); + /* Preserve "invalid" exceptions from sNaN input. */ + fenv.__status_word |= libc_fetestexcept_387 (FE_INVALID); + libc_fesetenv_387 (&fenv); + + return r; +} libm_alias_float (__trunc, trunc)