DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 49DGgws52974087
Authentication-Results: delorie.com;
	dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=eHHCAxXg
X-Recipient: archive-cygwin@delorie.com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 75481385AE7D
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
	s=default; t=1728837776;
	bh=UrwNl5scP6u9YwTpdwkAlziH4hokj/50JSua9JBCFYQ=;
	h=Date:Subject:To:References:In-Reply-To:List-Id:List-Unsubscribe:
	 List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:
	 From;
	b=eHHCAxXgxpfoE4Wb/y5FDyhJt8Qn76hkgbfhtu8gxYlwNodFIfANN0M05ze1eSKNS
	 VLO6d33Sc7OY+Q3WdPXXQrdPaw2tKpThWcqYUsOhxMQLWomgwgHQ+P3v4EijiJGSaP
	 NYV1K1CKW/c5zk47mX1yabaU3udCmW2g0q7w0Fjk=
X-Original-To: cygwin@cygwin.com
Delivered-To: cygwin@cygwin.com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A6BCB385AE47
ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A6BCB385AE47
ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728837723; cv=none;
 b=Yi+z4MW7B6bjQwsvVezGS5AcskxV9mXDvHP5KmH7uCMYwdMn2meY155xMmQY+QFYBFact5qNykMBUFo+hPbJW4PhluDB3JY9lzirFfCpIRovftRIeFliOIlDF73vK1/DdnR6GdYbIirK1CYOcol3NpbV9KfWmow8wqJXIdr2tY4=
ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key;
 t=1728837723; c=relaxed/simple;
 bh=5bmETrJes4cu9u8pUaI6T9O3xgDYxDmG/MX8a649Bv8=;
 h=Message-ID:Date:MIME-Version:From:Subject:To;
 b=j0oDUkp4809/Tjb+cvBxExYlbSUgxB8is9gvFkNlsARkrhCKdqgYoHjyb+rsPFeRsoJbjvJyLhmgs/dczE52xF18qreBdsG5E8XrusYy9c9kuxnqvno7ZuXwYgnOtuKnY5Aeu+guAydg9EGDmQWuH9V+b0gnsZ0rwGeLIlzE5i0=
ARC-Authentication-Results: i=1; server2.sourceware.org
Message-ID: <51e4e5dd-57ef-4cbc-aff4-572eebb863e2@SystematicSW.ab.ca>
Date: Sun, 13 Oct 2024 10:41:58 -0600
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: cygwin 3.5.4-1: signal handling destroys 'long double' values
To: cygwin@cygwin.com
References: <922a6d7e-3ee1-9bb7-dfd7-b94c53a7b9d4@t-online.de>
 <20241008202057.abd3dc5bb4df172c530e7655@nifty.ne.jp>
 <79171662-eede-4b14-aaf4-ebd98e6d98de@SystematicSW.ab.ca>
 <99f51137-2889-4985-b4c6-a460e05befb8@SystematicSW.ab.ca>
 <20241013081407.f07402abe9f721924f461dcc@nifty.ne.jp>
Content-Language: en-CA
Organization: Systematic Software
In-Reply-To: <20241013081407.f07402abe9f721924f461dcc@nifty.ne.jp>
X-Rspamd-Queue-Id: D188920025
X-Spam-Status: No, score=-0.7 required=5.0 tests=BAYES_00, BODY_8BITS,
 KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,
 SPF_PASS, TXREP,
 UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6
X-Rspamd-Server: rspamout03
X-Stat-Signature: einxzqhzg9exgmt688oebc5pm4aukhpz
X-Session-Marker: 427269616E2E496E676C69734053797374656D6174696353572E61622E6361
X-Session-ID: U2FsdGVkX1/WNyi8iV1HWinlUB80dwvQ31W7ZeuL8lg=
X-HE-Tag: 1728837717-740018
X-HE-Meta: U2FsdGVkX19iV/cIuxdsUYmNNn/9l7rnyTx7TYk2s8p1FpVObXMVTF+8iyHv71LASU1ou8wv7JO/b38D3rY1Vm0artUQyqv313RiwOjb/tvdG4LuJGL3DiSIMWJUQpMCpuY5omvOqofbTeSTOptWaj5oUb1Ios7xuiT+IEjVaDbLxYm8ldLLnYsjM8dK9XGvEaOzJgFpTzVpONltWAdabwPKHL8El45B4EbpawiltuuhApnXV0Wb5TYRNYkhZDUMVdTYiCVT4lPXpGSJIzAUcLuXZ9tvnxS2MgEiE/XSkNTavON3hEwi69Yr7y9/wajgWy/FplodekYum8WdCMYYdlcHBvIjcNjAC6pxCNk9R9QmH+bB6lZDmO8julvvLYTUBWu0QS0OPi5zTkfOjg0Xbhj6gXM47d7+xlj0H6JPtm8SgbqSKajY1B0Bo3pJTDLNMCfcAXd6XeC/b3t6k8IXbWIl12Zjsqz0AoMDc6id8v7/P6jqXn7m0eddVFNx3ImnlzZqQyHTVguuoE7rgws+Cung3hORlxnikDsxVGVTTuDERUaD3eYgjSPFVY6x0cUJ
X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on
 server2.sourceware.org
X-BeenThere: cygwin@cygwin.com
X-Mailman-Version: 2.1.30
Precedence: list
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-request@cygwin.com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=subscribe>
From: Brian Inglis via Cygwin <cygwin@cygwin.com>
Reply-To: cygwin@cygwin.com
Cc: Brian Inglis <Brian.Inglis@SystematicSW.ab.ca>
Content-Type: text/plain; charset="utf-8"; Format="flowed"
Errors-To: cygwin-bounces~archive-cygwin=delorie.com@cygwin.com
Sender: "Cygwin" <cygwin-bounces~archive-cygwin=delorie.com@cygwin.com>
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 49DGgws52974087

On 2024-10-12 17:14, Takashi Yano via Cygwin wrote:
> Hi Brian,
> 
> On Tue, 8 Oct 2024 10:37:14 -0600
> Brian Inglis wrote:
>> On 2024-10-08 10:14, Brian Inglis via Cygwin wrote:
>>> On 2024-10-08 05:20, Takashi Yano via Cygwin wrote:
>>>> On Mon, 7 Oct 2024 15:11:52 +0200
>>>> Christian Franke wrote:
>>>>> $ gcc -o sigtest -O2 sigtest.c
>>>>>
>>>>> $ ./sigtest > out.txt
>>>>> (press ^C 42x :-)
>>>>>
>>>>> $ sort out.txt | uniq -c
>>>>>          3 x = 0x1.23456789p+0, y = -nan, d = -nan
>>>>>          6 x = 0x1.23456789p+0, y = 0x1.23456789p+0, d = -nan
>>>>>         33 x = 0x1.23456789p+0, y = 0x1.23456789p+0, d = 0x0p+0
>>>>>
>>>>> The problem also occurs if compiled without -O2, but less often. No
>>>>> problem occurs if compiled with -DWORKS which suggests that only 'long
>>>>> double' is affected.
>>>>
>>>> Thanks for the report. I looked into this problem and might find the
>>>> cause. It seems due to a bug of scripts/gendef. It generates signal
>>>> handler caller (sigfe.s) which stores/restores the registers.
>>>>
>>>> In sigdelayed, control word is stored/restored by fnstcw/fldcw instruction,
>>>> however, fninit instruction destroys some status registers in FPU (x87).
>>>>
>>>> I think we shold use fnstenv/fldenv rather than fnstcw/fldcw and fninit.
>>>> However, I'm not familiar with x87 instructions, so I may overlook
>>>> something.
>>>>
>>>> Could anyone expert of x87 instructions and sigfe stuff give some
>>>> comments?
>>>
>>> AIUI x87 FP handling is outdated and mainly unused on current systems, as
>>> current systems do more and use more than the legacy x87 instructions and stack.
>>>
>>> See https://en.cppreference.com/w/c/numeric/fenv and related docs for more
>>> modern approaches.
>>>
>>> You would have to look into the AMD/Intel/IEEE docs for lower level details.
>>
>> This is basically what ISTR:
>>
>> https://beta.boost.org/doc/libs/1_82_0/libs/context/doc/html/context/rationale/x86_and_floating_point_env.html
>>
>> where legacy x87 and MMX registers are not used or preserved on x86_64/amd64, as
>> SSE... instructions and XMM registers are used.
> 
> Thanks for the advice. I read throuh the web pages and related documents
> and made a patch which uses fxsave/fxrstor and xsave/xrstror to
> cygwin-patches@cygwin.com mailing list.
> https://cygwin.com/pipermail/cygwin-patches/2024q4/012804.html
> 
> Is this as you intended?

That seems to be the preferred approach now, as long as you can correctly 
determine adequate space for fxsave and xsave, given the varying feature sets, 
register counts, and register sizes of recent processors: 
sse/2/3/4.1/4.2/4a/5/ssse3 avx2/512 128/256/512 bits X/Y/ZMM registers.

-- 
Take care. Thanks, Brian Inglis              Calgary, Alberta, Canada

La perfection est atteinte                   Perfection is achieved
non pas lorsqu'il n'y a plus rien à ajouter  not when there is no more to add
mais lorsqu'il n'y a plus rien à retirer     but when there is no more to cut
                                 -- Antoine de Saint-Exupéry


-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

