From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vk1-xa35.google.com (mail-vk1-xa35.google.com [IPv6:2607:f8b0:4864:20::a35]) by sourceware.org (Postfix) with ESMTPS id BD6513858D20 for ; Mon, 6 Nov 2023 17:11:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BD6513858D20 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 BD6513858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::a35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699290686; cv=none; b=nD8yWcZI1K4+lW9WYt0LsdrpHTf71SrheScpW3gh3i89FAbUaaEzGRlO9IbwX6JVNFyn6ev5SJJiYH/dB/4vJ555gtXnmshFD04CX6/CSho0hWUUcUDjkrjZW2FZC8axohuUoM+op8gb0bgQYrZt8YO8lFZ1EzB3EtTs4iNozME= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699290686; c=relaxed/simple; bh=AM6hEE0W3yKHIblPC/4rCtsmUApORzfRwbYArpJjghY=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=pgZUWtn5WOyo7/xFRP7sT2FKb7rm3wsvLE2FoLXsSwZAzTrmZ29LuYIacE2og+y8K1syxK+F+9vjGAMM3hAW5H3V80jFCJ2cj4WGQgZzA+zgYOVOUNWUuKSkOjRK6Au5xFxQyxtJT5EbcqzPjudLAw1dwSOnZQrCQH9XvU79P3A= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-vk1-xa35.google.com with SMTP id 71dfb90a1353d-4abf8ba3e4fso1243370e0c.1 for ; Mon, 06 Nov 2023 09:11:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699290684; x=1699895484; 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=CclX2y9iykUVNbUPK77ySY31RZEQGfl3FmSrsLRgarA=; b=Sj1qO70YmorjcdHC4yseEA6VWGHMzcYscJjYZM7q3ndTlNUqzq65nUlVxTfx1Mf0Zz ic7Yx1rQdnpq451P623zcCyJL+RPrZXDMEuic1Wu+1lpSGuiVoHNZCtZf/0Y5/gWj+lx wunHe+GO3ABJdqRZtY754O6o84gPnggB6QdZLx09j3e2Nku7Nj0mwi/Elb3HYDYdOmbg bAwmVy/1ybjsrAwNo19Ewf0//YHZVWcCs+qhlLy85atbCcJQLVY81yujpFBQdpHzQBYV L0ppdOJlkxkSEFoShgIxZN7ryfZ0LuNoA7OfKbOoPG4owRDQI7DV7LCv8fhCVoCaMgpm 5wqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699290684; x=1699895484; 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=CclX2y9iykUVNbUPK77ySY31RZEQGfl3FmSrsLRgarA=; b=Pnpug7eWf1zQLJWRtpxb9CLpZ53OEUGIYU+UOqEXjXpRab0lTmqo28AEZcFoqLg8FJ x0VgNdLWjW3f6t4kjVxAFCkI9rFY274M83v55NhcQyY3abRM2Ma3b9POZTUWX2osmieh e8hnqdpp4y7wL/vWyblXZXCP7z9UBXgwsnHgkoG3cUaQiH6lTpqHJKZOpKoDBjtzm4dh C4oe51z2hdzXnwvh19IiYBZ0k+KJ6IZSJOAAzYpllkJTdpB3L9GksiCjy7Fb0dhKCeoW tdJ60eyXjAUgsXsOMDeprJhdo3dlPFyw9X/3wHfyhzYQOoebu+kwPXM+SoffF4UY+Wtv iNbQ== X-Gm-Message-State: AOJu0YyagCh9wxBwRaZXiO5ZFAHva0Z5DsvY7EIFHeDdfTcTv8ATUjSq xb1c0kxvpjaFEdgkZ8yqKBzRV0qc6/54HbqkC2f5jA== X-Google-Smtp-Source: AGHT+IGd65VT0w0n6DLXH/cocaKsgZIU3DHxJqku8Wk8t1Lxb40lbl/JgsDwLNDS55UPKytOs1BleA== X-Received: by 2002:a1f:1dc8:0:b0:4a8:4218:804b with SMTP id d191-20020a1f1dc8000000b004a84218804bmr25400405vkd.12.1699290683942; Mon, 06 Nov 2023 09:11:23 -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 ct9-20020a056214178900b00674bdf8bfa9sm3585012qvb.29.2023.11.06.09.11.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 06 Nov 2023 09:11:22 -0800 (PST) Message-ID: <8aaf2565-5310-44aa-a331-6d12b26d2274@linaro.org> Date: Mon, 6 Nov 2023 14:11:20 -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> <5e031d35-5d3e-49a7-b354-809bb4a1dc8f@linaro.org> <6e4ff3c5-8504-79a4-8865-0239b0cd7185@redhat.com> From: Adhemerval Zanella Netto Organization: Linaro In-Reply-To: <6e4ff3c5-8504-79a4-8865-0239b0cd7185@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-11.6 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 14:02, Carlos O'Donell wrote: > On 11/6/23 11:50, Adhemerval Zanella Netto wrote: >> >> >> 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. > > Sure. > >> 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). >> > > So we go from UNSUPPORTED to... ? > I though about that, but the test also checks fegetexceptflag (a better option would to split the test in two, so only the fesetexceptflag is unsupported on ppc32).