From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yw1-x1131.google.com (mail-yw1-x1131.google.com [IPv6:2607:f8b0:4864:20::1131]) by sourceware.org (Postfix) with ESMTPS id 6713C3858D20 for ; Mon, 6 Nov 2023 16:51:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6713C3858D20 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 6713C3858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699289463; cv=none; b=AguaqP9D4nPpvUmm0IfLKypdJHPeKAW5bHhnfNgkZBNZ4rAEUECD4+sWyn7o6MZfcg+LV+Gu4cuJQTDhGohJbjuAiOq6TUksjJhkV1pIKaY3pBExQAj+Gc7A/PJE6p51wXSmQDJyo3qTx3P+Q14bOrqKB++tu5lMi5FbL8Mdw8Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699289463; c=relaxed/simple; bh=p6VY1K3ql02TQIHa1u4E8tdrtHbfoXu5kolx6JiXm4I=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=rDybMY2fmiQ2qaO2e0b5QNuE/U1HN9bH0Vm4OGHKxLj3CbviCVmbGeooXJ4RnyBxNPjX2S3KmjTL0J9aEkyjBpvHUigiCNTS44yDeijBf0npOLOKWEE4ZqR3fdJQUIDJK78+N47pVoAMUGS0VE4CV8KfzCO1l5OFWUAw/msIvMM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-yw1-x1131.google.com with SMTP id 00721157ae682-5a7b91faf40so55002677b3.1 for ; Mon, 06 Nov 2023 08:51:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699289461; x=1699894261; darn=sourceware.org; h=content-transfer-encoding:in-reply-to:organization:from:references :to:content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=f8T9/n0+GxbqCvLyEKYkdfIlYulpzADXaMdKE9inFyo=; b=kLLXzjwpeNm7NPwmeielwISapzjkHuf/Aooen2+5J3uDTL/m/z2IExc9kZogIc1Lf7 kM53vIeHDdEv2jjIv8IlXFTfnHC5tyON1D82k2Up0JWxe8MtojkfDmnLoBEms0YOF1kt AJn/pvw5b6c7hF/dXoIg72ZSf0qltCdUC5SjtbFzQtgmqKy/R2/+t6MfHez06yPYLVZS /C4U+k5+2xp5WBVcwqSoIRJejoP4qbEBmcANiRT+G+xULLLrjAX3G89SPFmGBguVOS+4 jJ507q6PeO0XolVP04C6jQZCEHQETCkyF0cbHP47MEwdKYAY2/ynLmpDdlJe18fw2Jq6 XLqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699289461; x=1699894261; h=content-transfer-encoding:in-reply-to:organization:from:references :to:content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=f8T9/n0+GxbqCvLyEKYkdfIlYulpzADXaMdKE9inFyo=; b=r7S3FLT5TsrJ6P9m+GGyG0DNhp0ckMmWbxAqDZDPQme7mw+ICZOYWDVPMS2fg9siaX B7E6Mffpob/Q2DoNKX3dYGdUjzj9Up8QZqHo51UNdk1fJHR0o/TIOHA+1sXZ28nt1yFS asrUs9EF8bGqMZKddG/LrETCDbzeb3WF6UB6xUVdy0AbQDQvIPro7bYi7MKUFCppYj9U D0+21448fBq3EMtbGQY20OmLtyXXq+RRiQNVodsAoEUJqiibL7fS+cGUB9JyHgCsxYuZ qopRlaN0OgfsJZQ3VRppukb+qA6/xCwTi8ldSs1qMjg8+9eBhaWfLVCJ2FTKTHYO4zcI 0RHA== X-Gm-Message-State: AOJu0YwQBnxVCNEZ5EjPbIEPB+KJgL4+EBMX6WqQNonZaegyriqZjfNf PcW36BPw/61aeRsJqzk6+rpfjA== X-Google-Smtp-Source: AGHT+IExPNjzRvpXubH5PAqjI6ugUZJhZu1aRDdRxEe/Wv8HDD5PVhfU4IwV6DA/cdJExnUd/EkMeQ== X-Received: by 2002:a81:6244:0:b0:595:59f:28d7 with SMTP id w65-20020a816244000000b00595059f28d7mr11992163ywb.48.1699289460803; Mon, 06 Nov 2023 08:51:00 -0800 (PST) Received: from ?IPV6:2804:1b3:a7c0:a715:e513:925e:1fa6:9bda? ([2804:1b3:a7c0:a715:e513:925e:1fa6:9bda]) by smtp.gmail.com with ESMTPSA id r125-20020a0de883000000b005a7fbac4ff0sm4530657ywe.110.2023.11.06.08.50.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 06 Nov 2023 08:51:00 -0800 (PST) Message-ID: <5e031d35-5d3e-49a7-b354-809bb4a1dc8f@linaro.org> Date: Mon, 6 Nov 2023 13:50:58 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 1/7] powerpc: Do not raise exception traps for fesetexcept/fesetexceptflag (BZ 30988) Content-Language: en-US To: Carlos O'Donell , libc-alpha@sourceware.org, Bruno Haible References: <20231106132713.953501-1-adhemerval.zanella@linaro.org> <20231106132713.953501-2-adhemerval.zanella@linaro.org> <6130f4c9-dab2-6f8e-5bc5-902b5a48e2dc@redhat.com> From: Adhemerval Zanella Netto Organization: Linaro In-Reply-To: <6130f4c9-dab2-6f8e-5bc5-902b5a48e2dc@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-11.5 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 List-Id: On 06/11/23 13:08, Carlos O'Donell wrote: > On 11/6/23 08:27, Adhemerval Zanella wrote: >> According to ISO C23 (7.6.4.4), fesetexcept is supposed to set >> floating-point exception flags without raising a trap (unlike >> feraiseexcept, which is supposed to raise a trap if feenableexcept was >> called with the appropriate argument). >> >> This is a side-effect of how we implement the GNU extension >> feenableexcept, where feenableexcept/fesetenv/fesetmode/feupdateenv >> might issue prctl (PR_SET_FPEXC, PR_FP_EXC_PRECISE) depending of the >> argument. And on PR_FP_EXC_PRECISE, setting a floating-point exception >> flag triggers a trap. >> >> To make the both functions follow the C23, fesetexcept and >> fesetexceptflag now fail if the argument may trigger a trap. > > OK. I reviewed ISO C 2x (n3096), and I agree this is permissible and preferable. > >> >> The math tests now check for an value different than 0, instead >> of bail out as unsupported for EXCEPTION_SET_FORCES_TRAP. >> >> Checked on powerpc64le-linux-gnu. > > Changes test from UNSUPPORTED to PASS when we should test more now that with > C2x we're saying the behaviour will result in a non-zero return... then we > should test for that. > >> --- >> math/test-fesetexcept-traps.c | 11 ++++------- >> math/test-fexcept-traps.c | 11 ++++------- >> sysdeps/powerpc/fpu/fesetexcept.c | 5 +++++ >> sysdeps/powerpc/fpu/fsetexcptflg.c | 9 ++++++++- >> 4 files changed, 21 insertions(+), 15 deletions(-) >> >> diff --git a/math/test-fesetexcept-traps.c b/math/test-fesetexcept-traps.c >> index 71b6e45b33..96f6c4752f 100644 >> --- a/math/test-fesetexcept-traps.c >> +++ b/math/test-fesetexcept-traps.c >> @@ -39,16 +39,13 @@ do_test (void) >> return result; >> } >> >> - if (EXCEPTION_SET_FORCES_TRAP) >> - { >> - puts ("setting exceptions traps, cannot test on this architecture"); >> - return 77; >> - } >> - /* Verify fesetexcept does not cause exception traps. */ >> + /* Verify fesetexcept does not cause exception traps. For architectures >> + where setting the exception might result in traps the function should >> + return a nonzero value. */ >> ret = fesetexcept (FE_ALL_EXCEPT); >> if (ret == 0) > > We can check for a non-zero return if EXCEPTION_SET_FORCES_TRAP? > > e.g. > > if (!EXCEPTION_SET_FORCES_TRAP) > { > if (ret == 0) > puts ("fesetexcept (FE_ALL_EXCEPT) succeeded"); > else > /* fail */ > } > else > { > if (ret == 0) > /* fail */ > else > /* pass */ > } The '!EXCEPTION_SET_FORCES_TRAP && ret == 0' or 'EXCEPTION_SET_FORCES_TRAP && ret == 1' checks are not really meaningful: either the function succeeds and return 0, or it fails for some reason. And for failure, EXCEPTION_SET_FORCES_TRAP really means an expected failure. So if the function succeeds and no trap is generated (which terminates the process as default on Linux) we are fine. Otherwise, it check if the failure is expected (EXCEPTION_SET_FORCES_TRAP).