On Thu, Oct 13, 2005 at 11:10:18PM -0400, Daniel Jacobowitz wrote: > On Wed, Sep 21, 2005 at 12:46:48PM -0400, Carlos O'Donell wrote: > > int > > fesetround (int round) > > { > > struct { unsigned int sw[2]; } s; > > > > /* Get the current status word. */ > > __asm__ ("fstd %%fr0,0(%1)" : "=m" (s) : "r" (&s) : "%r0"); > > s.sw[0] &= ~FE_DOWNWARD; > > s.sw[0] |= round & FE_DOWNWARD; > > __asm__ ("fldd 0(%0),%%fr0" : : "r" (&s), "m" (s) : "%r0"); > > > > return 0; > > } > > --- > > > > Comments: > > - Please do not return 1 if the rounding mode is invalid. > > Try as hard as possible to set something reasonable. > > - Use a struct where possible for two integers since GCC > > will generally have an easier time following the memory. > > - These are double word stores, so you need sw[2]. > > Er... how can comment #1 possibly be correct? The documentation's > clear: fesetround should return 1 if it could not set the requested > rounding mode.
info glibc? AFAIU the return was undefined if the input is not one of the rounding macros. I meant only to make the function more robust, but in retrospect you are right, it should be more conformant. To be clear the section 7.6.3.2 fesetround of the ISO C spec says that zero should only be returned when the round value matches one of the rounding macros. And this function does not do that. I should not go around recommending people break spec :} c. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]