DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 49D9uItN2852489 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=YN2uFzfy X-Recipient: archive-cygwin AT delorie DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9C36F3857000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; s=default; t=1728813375; bh=zdUK4UwiMJMGAPf6Cq1IiDrVz86PLjgHwEPhHfrTwm4=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=YN2uFzfyAVlcLoOPYZwMdgXq6BOYCIuo0ve9V+z7nPIlfybE/lsm31rStSvzIjSC8 Q8WeoFPix71AQ5WLtZClFtNJIo4k96khARDaBvuGjGk+XXIb22HxcmhiD8e/OoKYU+ mH4YoptENje8AbVavGa6R4/3KhtzT0aC+DSna6f4= X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6BD0F385840F ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6BD0F385840F ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728813354; cv=none; b=lW1f2LksR0WHxe5WbjOmCVOOvEbOxYpyAljjGDq/ObSCjzwpUmT/KFfHSTmNrLMgBtSij5Qn79qjBsehpoN0WzCZskVTmMc+K/s80+VOsL1DTtc9hvBx8qpnlSXsq1KeY1haiP2iumqAmFRGW12SeRdB6Nd32jyWZWfMO7B/s74= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728813354; c=relaxed/simple; bh=7XqHP6/1PgZ1l7G0WgudpdMHIZ+XET2Z/uiH/FSTwfE=; h=Subject:To:From:Message-ID:Date:MIME-Version; b=RH8NrfdKeCmfj3JsRbbaE4FEqKNmzhftgTmC+8NUISb+7ydl2QuvMhkIxQaobkFABNRvJgODs1pr2UXQvxCi4y5xiDxIEj+Gd6X0Ki6ZXoKZXBJC7Zl/hIQW9cCriXiofREl+W79kluqpcLUV+z+y3uaET1d6St705DGLX3p5hM= ARC-Authentication-Results: i=1; server2.sourceware.org Subject: Re: cygwin 3.5.4-1: signal handling destroys 'long double' values To: cygwin AT cygwin DOT com References: <922a6d7e-3ee1-9bb7-dfd7-b94c53a7b9d4 AT t-online DOT de> <20241008202057 DOT abd3dc5bb4df172c530e7655 AT nifty DOT ne DOT jp> <79171662-eede-4b14-aaf4-ebd98e6d98de AT SystematicSW DOT ab DOT ca> <99f51137-2889-4985-b4c6-a460e05befb8 AT SystematicSW DOT ab DOT ca> <20241013081407 DOT f07402abe9f721924f461dcc AT nifty DOT ne DOT jp> Message-ID: <0784c8f3-ab93-670c-835e-ef7344d38701@t-online.de> Date: Sun, 13 Oct 2024 11:55:46 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 SeaMonkey/2.53.18.2 MIME-Version: 1.0 In-Reply-To: <20241013081407.f07402abe9f721924f461dcc@nifty.ne.jp> X-TOI-EXPURGATEID: 150726::1728813347-DB7FC45E-E837C1DC/0/0 CLEAN NORMAL X-TOI-MSGID: a5a36358-d850-4d55-a942-260bdc0c243f X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00, BODY_8BITS, FREEMAIL_FROM, KAM_DMARC_STATUS, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP 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: cygwin AT cygwin DOT com X-Mailman-Version: 2.1.30 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Christian Franke via Cygwin Reply-To: cygwin AT cygwin DOT com Cc: Christian Franke Content-Type: text/plain; charset="utf-8"; Format="flowed" Errors-To: cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com Sender: "Cygwin" Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 49D9uItN2852489 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 AT cygwin DOT com mailing list. > https://cygwin.com/pipermail/cygwin-patches/2024q4/012804.html The patch fixes the testcases from my original post on a CPU with XSAFE support and also if usage of FXSAVE if forced by this hack:         movl    \$1,%eax         cpuid -       andl    \$0x04000000,%ecx # xsave available? +       andl    \$0x00000000,%ecx # xsave available?         jnz     1f -- Regards, Christian -- 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