This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: [PATCH] fegetenv/getcontext



> From: Andreas Schwab [mailto:schwab@suse.de] 
> 
> "Ed Connell" <Ed.Connell@sas.com> writes:
> 
> |> Hi
> |> 
> |> fegetenv and getcontext currently corrupt the floating point
> |> mask on x86.  I have included a patch and a testcase.  I 
> |> was only able to test this patch on 2.2.93 but looking at
> |> CVS, I see no reason the behavior should be different now.
> |> Someone involved with x86-64 should see if they need a
> |> similar patch.  The problem can be seen on RH 8 and RH 9.
> |> 
> |> Cheers
> |> Ed
> |> 
> |> 2003-05-19  Ed Connell  <ed.connell@sas.com>
> |> 
> |>       * sysdeps/unix/sysv/linux/i386/getcontext.S (getcontext): 
> |>         Retain floating point mask
> |>       * sysdeps/i386/fpu/fegetenv.c (fegetenv): Likewise.
> |> 
> |> --- glibc-2.3.2/sysdeps/i386/fpu/fegetenv.c     2001-07-07 
> 15:21:23.000000000 -0400
> |> +++ glibc-2.3.2/sysdeps/i386/fpu/fegetenv.c.edconn      
> 2003-05-19 16:27:16.000000000 -0400
> |> @@ -25,6 +25,7 @@
> |>  __fegetenv (fenv_t *envp)
> |>  {
> |>    __asm__ ("fnstenv %0" : "=m" (*envp));
> |> +  __asm__ ("fldenv %0" : "=m" (*envp));
>                              ^^^^
> 
> The constraint is wrong.  See fesetenv.c for correct usage.
> 
> Andreas.

Ok.  I fixed the constraint and got the correct behaviour
on 2.2.93.

2003-05-19  Ed Connell  <ed.connell@sas.com>

      * sysdeps/unix/sysv/linux/i386/getcontext.S (getcontext): 
        Retain floating point mask
      * sysdeps/i386/fpu/fegetenv.c (fegetenv): Likewise.

--- glibc-2.3.2/sysdeps/i386/fpu/fegetenv.c     2001-07-07 15:21:23.000000000 -0400
+++ glibc-2.3.2/sysdeps/i386/fpu/fegetenv.c.edconn      2003-05-19 16:27:16.000000000 -0400
@@ -25,6 +25,7 @@
 __fegetenv (fenv_t *envp)
 {
   __asm__ ("fnstenv %0" : "=m" (*envp));
+  __asm__ ("fldenv %0" : : "m" (*envp));
 
   /* Success.  */
   return 0;

--- glibc-2.3.2/sysdeps/unix/sysv/linux/i386/getcontext.S       2002-12-19 22:56:27.000000000 -0500
+++ glibc-2.3.2/sysdeps/unix/sysv/linux/i386/getcontext.S.edconn        2003-05-19 15:12:12.000000000 -0400
@@ -56,6 +56,7 @@
        movl    %ecx, oFPREGS(%eax)
        /* Save the floating-point context.  */
        fnstenv (%ecx)
+       fldenv  (%ecx)
 
        /* Save the current signal mask.  */
        pushl   %ebx  


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]