diff options
Diffstat (limited to 'lib/libm/arch/hppa/s_floor.c')
-rw-r--r-- | lib/libm/arch/hppa/s_floor.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/libm/arch/hppa/s_floor.c b/lib/libm/arch/hppa/s_floor.c new file mode 100644 index 00000000000..8064793c2bf --- /dev/null +++ b/lib/libm/arch/hppa/s_floor.c @@ -0,0 +1,26 @@ +/* + * Written by Michael Shalayeff. Public Domain + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$OpenBSD: s_floor.c,v 1.1 2002/05/22 21:34:56 mickey Exp $"; +#endif + +#include <sys/types.h> +#include <machine/ieeefp.h> +#include "math.h" + +double +__ieee754_floor(double x) +{ + u_int32_t ofpsr, fpsr; + + __asm__ __volatile__("fstw %%fr0,0(%1)" : "=m" (ofpsr) : "r" (&ofpsr)); + fpsr = (ofpsr & ~0x600) | (FP_RN << 9); + __asm__ __volatile__("fldw 0(%0), %%fr0" :: "r" (&fpsr)); + + __asm__ __volatile__("frnd,dbl %0,%0" : "+f" (x)); + + __asm__ __volatile__("fldw 0(%0), %%fr0" :: "r" (&ofpsr)); + return (x); +} |