On Aug 31 09:37, Brian Inglis wrote: > On 2020-08-31 01:35, Corinna Vinschen wrote: > > On Aug 30 14:39, Brian Inglis wrote: > >> On 2020-08-30 07:00, Corinna Vinschen wrote: > >>> On Aug 29 08:52, airplanemath via Cygwin wrote: > >>>> I have two reports. A brief description of the system: > >>>> $ uname -a | sed "s/${HOSTNAME}/\${HOSTNAME}/g" > >>>> CYGWIN_NT-10.0 ${HOSTNAME} 3.1.7(0.340/5/3) 2020-08-22 17:48 x86_64 > >>>> Cygwin > >> ... > >>>> $ cat test.c > >>>> #include <math.h> > >>>> #include <stdio.h> > >>>> #include <stdlib.h> > >>>> > >>>> int main(int argc, char *argv[]) { > >>>> long double a, b, c; > >>>> char *num_end = NULL; > >>>> a = b = c = 0.0L; > >>>> if (argc != 2) { > >>>> fprintf(stderr, "Usage: %s NUMBER\n", argv[0]); > >>>> exit(1); > >>>> } > >>>> a = strtold(argv[1], &num_end); > >>>> b = modfl(a, &c); > >>>> printf("%Lf %Lf %Lf\n", a, b, c); > >>>> return 0; > >>>> } > >>> > >>> This is a bug in the assembler code taken from Mingw-w64. The bug has > >>> been fixed upstream, so I just pulled in the upstream fixes. > >> > >> The 64 bit fix doesn't pop eax but *now* flags eax as clobbered, whereas > >> the 32 > >> bit fix both pops and *now* flags eax as clobbered, which it really > >> doesn't need > >> to do. Is this inconsistent treatment correct? > > > > You may be right that this is not necessary on i686, but it doesn't > > hurt either and I'd like to stick to the upstream code if possible. > > The upstream patch changed only amd64/x86_64 code sequences for multiple > modules > including modfl, and left i386/x86 untouched for those modules.
$ git remote -v origin https://git.code.sourceforge.net/p/mingw-w64/mingw-w64 (fetch) origin https://git.code.sourceforge.net/p/mingw-w64/mingw-w64 (push) $ git st On branch master Your branch is up to date with 'origin/master'. nothing to commit, working tree clean $ $ git log --oneline -2 -- mingw-w64-crt/math/modfl.c fac3a8a6e4ca crt: Add "volatile" to all inline assembly snippets under math 9a2479858b3b mingw-w64-crt/math/modf{,f,l}.c: Fix segment faults in modf(), modff() and modfl(). $ git show 9a2479858b3b [...] diff --git a/mingw-w64-crt/math/modfl.c b/mingw-w64-crt/math/modfl.c index af75a8b8cf60..ef1ab16ce256 100644 --- a/mingw-w64-crt/math/modfl.c +++ b/mingw-w64-crt/math/modfl.c @@ -21,7 +21,7 @@ modfl (long double value, long double* iptr) "fldcw (%%rsp)\n" "frndint\n" "fldcw 4(%%rsp)\n" - "addq $8, %%rsp\n" : "=t" (int_part) : "0" (value)); /* round */ + "addq $8, %%rsp\n" : "=t" (int_part) : "0" (value) : "eax"); /* round */ #elif defined(_X86_) || defined(__i386__) asm ("push %%eax\n\tsubl $8, %%esp\n" "fnstcw 4(%%esp)\n" @@ -31,7 +31,7 @@ modfl (long double value, long double* iptr) "fldcw (%%esp)\n" "frndint\n" "fldcw 4(%%esp)\n" - "addl $8, %%esp\n\tpop %%eax\n" : "=t" (int_part) : "0" (value)); /* round */ + "addl $8, %%esp\n\tpop %%eax\n" : "=t" (int_part) : "0" (value) : "eax"); /* round */ #else int_part = truncl(value); #endif Corinna -- Corinna Vinschen Cygwin Maintainer -- 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