This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Fix long double rounding functions
- From: Roland McGrath <roland at redhat dot com>
- To: Steven Munroe <munroesj at us dot ibm dot com>
- Cc: libc-alpha at sources dot redhat dot com, Alan Modra <amodra at bigpond dot net dot au>, Dwayne McConnell <decimal at us dot ibm dot com>
- Date: Thu, 2 Mar 2006 19:07:41 -0800 (PST)
- Subject: 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