This is the mail archive of the libc-alpha@sourceware.org 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] Fix long double rounding functions


> +/* Handy utility functions to pack/unpack/cononicalize and find the nearbyint
> +   of long double implemented as double double.  */
> +static inline long double
> +__ldbl_pack (double a, double aa)

Don't use __ names for static things.  It's a private name space.
You can call it pack_long_double or whatever.  

Also, looking at math_ldbl.h makes me wonder why most of the contents of
those EXTRACT/INSERT macros aren't done in inlines instead.  That would be
cleaner, and you can check that the compiler produces the same code.

> +/* Convert a finite long double to canonical form.
> +   Does not handle +/-Inf properly.  */
> +static inline void
> +__ldbl_canonicalise (double *a, double *aa)

Sorry, we use American spelling in identifier names.

> +static inline int
> +___fegetround (void)

Only two __s please (__fe[gs]etround are appropriate names here because
each is an internal version of a public function by that name).

> +  asm ("mcrfs 7,7 ; mfcr %0" : "=r"(result) : : "cr7"); \

Please clean up the whitespace and remove spurious backslash, i.e.:

  asm ("mcrfs 7,7\n\t"
       "mfcr %0" : "=r" (result) : : "cr7");

> +#define fegetround ___fegetround

For such a case, use:

#define fegetround() __fegetround ()

It surely does not matter here, but it is the right way generally.

> +       asm volatile ("mtfsb0 30" : : );

AFAIK there is no point to : : here; it looks better without it.

> +#undef fesetround
>  int
>  fesetround (int round)
>  {

This should just call the __fesetround inline.


Thanks,
Roland


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