diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 2002-05-22 21:34:57 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 2002-05-22 21:34:57 +0000 |
commit | 3f07829b93ace0640205e778f058729bcf9408b0 (patch) | |
tree | 06ccd5cad1e461f301cef520c9b08b06fee26986 /lib/libm/arch/hppa | |
parent | 9edcf43eec38251e9ff35a8f9831f9ba3ad7a042 (diff) |
add reminder and roundings
Diffstat (limited to 'lib/libm/arch/hppa')
-rw-r--r-- | lib/libm/arch/hppa/e_remainder.c | 17 | ||||
-rw-r--r-- | lib/libm/arch/hppa/e_remainderf.c | 17 | ||||
-rw-r--r-- | lib/libm/arch/hppa/s_ceil.c | 26 | ||||
-rw-r--r-- | lib/libm/arch/hppa/s_ceilf.c | 26 | ||||
-rw-r--r-- | lib/libm/arch/hppa/s_floor.c | 26 | ||||
-rw-r--r-- | lib/libm/arch/hppa/s_floorf.c | 26 | ||||
-rw-r--r-- | lib/libm/arch/hppa/s_rint.c | 17 | ||||
-rw-r--r-- | lib/libm/arch/hppa/s_rintf.c | 17 |
8 files changed, 172 insertions, 0 deletions
diff --git a/lib/libm/arch/hppa/e_remainder.c b/lib/libm/arch/hppa/e_remainder.c new file mode 100644 index 00000000000..15db821d42c --- /dev/null +++ b/lib/libm/arch/hppa/e_remainder.c @@ -0,0 +1,17 @@ +/* + * Written by Michael Shalayeff. Public Domain + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$OpenBSD: e_remainder.c,v 1.1 2002/05/22 21:34:56 mickey Exp $"; +#endif + +#include "math.h" + +double +__ieee754_remainder(double x, double p) +{ + __asm__ __volatile__("frem,dbl %0,%1,%0" : "+f" (x) : "f" (p)); + + return (x); +} diff --git a/lib/libm/arch/hppa/e_remainderf.c b/lib/libm/arch/hppa/e_remainderf.c new file mode 100644 index 00000000000..366be878631 --- /dev/null +++ b/lib/libm/arch/hppa/e_remainderf.c @@ -0,0 +1,17 @@ +/* + * Written by Michael Shalayeff. Public Domain + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$OpenBSD: e_remainderf.c,v 1.1 2002/05/22 21:34:56 mickey Exp $"; +#endif + +#include "math.h" + +float +__ieee754_remainder(float x, float p) +{ + __asm__ __volatile__("frem,sgl %0,%1,%0" : "+f" (x) : "f" (p)); + + return (x); +} diff --git a/lib/libm/arch/hppa/s_ceil.c b/lib/libm/arch/hppa/s_ceil.c new file mode 100644 index 00000000000..c85f3533492 --- /dev/null +++ b/lib/libm/arch/hppa/s_ceil.c @@ -0,0 +1,26 @@ +/* + * Written by Michael Shalayeff. Public Domain + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$OpenBSD: s_ceil.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_ceil(double x) +{ + u_int32_t ofpsr, fpsr; + + __asm__ __volatile__("fstw %%fr0,0(%1)" : "=m" (ofpsr) : "r" (&ofpsr)); + fpsr = (ofpsr & ~0x600) | (FP_RP << 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); +} diff --git a/lib/libm/arch/hppa/s_ceilf.c b/lib/libm/arch/hppa/s_ceilf.c new file mode 100644 index 00000000000..9c363ae1ce4 --- /dev/null +++ b/lib/libm/arch/hppa/s_ceilf.c @@ -0,0 +1,26 @@ +/* + * Written by Michael Shalayeff. Public Domain + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$OpenBSD: s_ceilf.c,v 1.1 2002/05/22 21:34:56 mickey Exp $"; +#endif + +#include <sys/types.h> +#include <machine/ieeefp.h> +#include "math.h" + +float +__ieee754_ceil(float x) +{ + u_int32_t ofpsr, fpsr; + + __asm__ __volatile__("fstw %%fr0,0(%1)" : "=m" (ofpsr) : "r" (&ofpsr)); + fpsr = (ofpsr & ~0x600) | (FP_RP << 9); + __asm__ __volatile__("fldw 0(%0), %%fr0" :: "r" (&fpsr)); + + __asm__ __volatile__("frnd,sgl %0,%0" : "+f" (x)); + + __asm__ __volatile__("fldw 0(%0), %%fr0" :: "r" (&ofpsr)); + return (x); +} 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); +} diff --git a/lib/libm/arch/hppa/s_floorf.c b/lib/libm/arch/hppa/s_floorf.c new file mode 100644 index 00000000000..feff01f6fbf --- /dev/null +++ b/lib/libm/arch/hppa/s_floorf.c @@ -0,0 +1,26 @@ +/* + * Written by Michael Shalayeff. Public Domain + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$OpenBSD: s_floorf.c,v 1.1 2002/05/22 21:34:56 mickey Exp $"; +#endif + +#include <sys/types.h> +#include <machine/ieeefp.h> +#include "math.h" + +float +__ieee754_floorf(float 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,sgl %0,%0" : "+f" (x)); + + __asm__ __volatile__("fldw 0(%0), %%fr0" :: "r" (&ofpsr)); + return (x); +} diff --git a/lib/libm/arch/hppa/s_rint.c b/lib/libm/arch/hppa/s_rint.c new file mode 100644 index 00000000000..101b62c9db0 --- /dev/null +++ b/lib/libm/arch/hppa/s_rint.c @@ -0,0 +1,17 @@ +/* + * Written by Michael Shalayeff. Public Domain + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$OpenBSD: s_rint.c,v 1.1 2002/05/22 21:34:56 mickey Exp $"; +#endif + +#include "math.h" + +double +__ieee754_rint(double x) +{ + __asm__ __volatile__("frnd,dbl %0,%0" : "+f" (x)); + + return (x); +} diff --git a/lib/libm/arch/hppa/s_rintf.c b/lib/libm/arch/hppa/s_rintf.c new file mode 100644 index 00000000000..f3d0a60235c --- /dev/null +++ b/lib/libm/arch/hppa/s_rintf.c @@ -0,0 +1,17 @@ +/* + * Written by Michael Shalayeff. Public Domain + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$OpenBSD: s_rintf.c,v 1.1 2002/05/22 21:34:56 mickey Exp $"; +#endif + +#include "math.h" + +float +__ieee754_rint(float x) +{ + __asm__ __volatile__("frnd,dbl %0,%0" : "+f" (x)); + + return (x); +} |