[parisc-linux] glibc-2.3.3: a warning with gcc-3.3 become an error with gcc-3.5

Joel Soete soete.joel at tiscali.be
Sun Mar 14 09:21:37 MST 2004


Carlos,

Carlos O'Donell wrote:
> On Sat, Mar 06, 2004 at 10:14:12PM +0000, Joel Soete wrote:
> 
>>Taken into account of your relevant remarks here is my new proposal:
>>=========><=========
>>--- sysdeps/hppa/fpu/feupdateenv.c.orig 2004-03-06 21:18:40.789605000 +0100
>>+++ sysdeps/hppa/fpu/feupdateenv.c      2004-03-06 21:22:21.839605000 +0100
>>@@ -23,15 +23,16 @@
>> int
>> feupdateenv (const fenv_t *envp)
>> {
>>-  unsigned int sw[2];
>>+  struct fenv_t saved_env, new_env;
>>
>>   /* Get the current exception status. */
>>-  __asm__ ("fstd %%fr0,0(%1)" : "=m" (*sw) : "r" (sw));
>>-  sw[0] &= FE_ALL_EXCEPT;
>>-  envp->__status_word = envp->__status_word | sw[0];
> 
> 
> Yeah, this is bad, because 'envp' is const, and we shouldn't be changing
> its value.
> 
> 
>>+  fegetenv(&saved_env);
>>+  saved_env.__status_word &= FE_ALL_EXCEPT;
>>+  new_env.__status_word = envp->__status_word | saved_env.__status_word;
>>+  for (i = 0; i < 7; i++) new_env.__exception[i] = envp->__exception[i];
> 
> 
> Why do you use "new_env" at all? Just use saved_env. Then you don't have
> to have a silly loop to copy the exceptions, they'll already be there.
> Then you can call fesetenv(&saved_env);
>  
> 
>>   /* Install new environment.  */
>>-  fesetenv (envp);
>>+  fesetenv (&new_env);
>>
>>   /* Success.  */
>>   return 0;
>>=========><=========
> 
Taken into account of your remarks here is the final patch:
--- glibc-2.3.3-20040314/sysdeps/hppa/fpu/feupdateenv.c.orig    2003-12-18 04:57:50.000000000 +0100
+++ glibc-2.3.3-20040314/sysdeps/hppa/fpu/feupdateenv.c 2004-03-14 12:06:13.286349000 +0100
@@ -23,15 +23,15 @@
  int
  feupdateenv (const fenv_t *envp)
  {
-  unsigned int sw[2];
+  fenv_t tmp_env;

    /* Get the current exception status. */
-  __asm__ ("fstd %%fr0,0(%1)" : "=m" (*sw) : "r" (sw));
-  sw[0] &= FE_ALL_EXCEPT;
-  envp->__status_word = envp->__status_word | sw[0];
+  fegetenv(&tmp_env);
+  tmp_env.__status_word &= FE_ALL_EXCEPT;
+  tmp_env.__status_word |= envp->__status_word;

    /* Install new environment.  */
-  fesetenv (envp);
+  fesetenv (&tmp_env);

    /* Success.  */
    return 0;
=========><=========

it compiles well with gcc-3.3.

I hope it will not break anything :)

Joel


More information about the parisc-linux mailing list