DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 498GcDeG089257
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=aMefZZwD
X-Recipient: archive-cygwin@delorie.com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 00F9F385C6C7
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
	s=default; t=1728405493;
	bh=zEm8TBRDBqKeV/i/3Kxe1UqmXUrzbW7GrJAdk1oOIkw=;
	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=aMefZZwD0UcFx+MPu5aV/02cC5Q4N64K5/IEmkHsVuYMLK39uSqiqeGoVK6Axntf8
	 2w9H77RhlGAuF2BCLFpQJJTwbek40ZnpMLUUKE8kXToX1es8003Xc3l+LqNiMUDoC0
	 V4IQcEMDraoZa/LxySGI6ORZnQGAKX15FnebMvgw=
X-Original-To: cygwin@cygwin.com
Delivered-To: cygwin@cygwin.com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A0CAC385C6CC
ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A0CAC385C6CC
ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728405439; cv=none;
 b=uLL+/AX4fJ8h3gTjcLlknh4veBjbP+rdukq4dUd3MNqooRO+oVOCNUIO3R8S9h+R31Vu9mWnArS/0O40YAnbwyKMHMGLiXOUNfxlHpjO1dRlLpldugOWoD1gqJuJb0P22Whs/i6Xj2w+IusI6hgO6yXMrX3CvutNVcYt4p9GGP0=
ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key;
 t=1728405439; c=relaxed/simple;
 bh=GehJSEBFg2b6JL201QwKUWgfolssKLBcFSqQGHn+VDk=;
 h=Message-ID:Date:MIME-Version:From:Subject:To;
 b=t4mbveVE+oUC+W0y5fK0Xkje3HmtW8Hkj5gWdqBv5VYh5MbO+VofBI1ZTGWNsiehWhWrH6p+8mxRrfiPeXOLRMGd4Ch0xZFFnysdcVaKYkpdfy2foPzU9vRwFvRRBl9oXPeXGYUh7Yq1RNMiZ3OCDwcIXjzanP04484MmgBYDuc=
ARC-Authentication-Results: i=1; server2.sourceware.org
Message-ID: <99f51137-2889-4985-b4c6-a460e05befb8@SystematicSW.ab.ca>
Date: Tue, 8 Oct 2024 10:37:14 -0600
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: cygwin 3.5.4-1: signal handling destroys 'long double' values
Content-Language: en-CA
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>
Organization: Systematic Software
In-Reply-To: <79171662-eede-4b14-aaf4-ebd98e6d98de@SystematicSW.ab.ca>
X-Rspamd-Queue-Id: BF0AC2002C
X-Spam-Status: No, score=-0.6 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: rspamout01
X-Stat-Signature: utqfeggz9hgeozt8gyf41agn6b9xxjyr
X-Session-Marker: 427269616E2E496E676C69734053797374656D6174696353572E61622E6361
X-Session-ID: U2FsdGVkX1/dlldDZ5w3kOYObvcKDBks/Sv1rqL2vIk=
X-HE-Tag: 1728405435-468954
X-HE-Meta: U2FsdGVkX1+Sn4S9tBHqNYXXAJn3AYx0FIFgQCI3w56/HcNrvjuR7ZChYsW8yhNrTQKOLvZ1IWD2W6OaG/D3jOFz7SFR5t05d4HC2KzCoB8zwdAiH2kfDOuM8jDDOUsYebUuXJhx6ms0OU88gtTzVMh1KQI29S4SoJZ7WkZfdGebqg/tIW2IDAbkWp6hHB3w5OVtiAgmj7Vcn9kBNDqqgTXa+U/cSjNI+6cp6InrMG6HHOSfIHc/HjYxYWymDNUkHXeAT9dga6kg9jerJPZPveKHWtNTqcT2mRPCnYth4GPVa1ccGEvyFBXOYIbzFpj6jV+dtEkX43Ecc4cU0lBg5hB7iEGshOvXvWR2Wf+lOXP0wuF1tsHo6P7gl+bRyRiEEtKWsz6yugkY279z7w06r7a4fXx1SI3s0mVgUDR+jxPXWQscQzfiLhWnjJNGI1TZw4ZVCE832aUwgCikrTp5R7/EjxxEzh+ZO9LJ/W0abZs=
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 498GcDeG089257

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.

-- 
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

