diff options
author | Christopher Faylor <me@cgf.cx> | 2000-02-17 19:39:52 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2000-02-17 19:39:52 +0000 |
commit | 8a0efa53e44919bcf5ccb1d3353618a82afdf8bc (patch) | |
tree | 68c3dbf3f2c6fd5d49777def9914d77b5cd4589d /newlib/libc/sys/sparc64/ieee.c | |
parent | 1fd5e000ace55b323124c7e556a7a864b972a5c4 (diff) | |
download | cygnal-8a0efa53e44919bcf5ccb1d3353618a82afdf8bc.tar.gz cygnal-8a0efa53e44919bcf5ccb1d3353618a82afdf8bc.tar.bz2 cygnal-8a0efa53e44919bcf5ccb1d3353618a82afdf8bc.zip |
import newlib-2000-02-17 snapshot
Diffstat (limited to 'newlib/libc/sys/sparc64/ieee.c')
-rw-r--r-- | newlib/libc/sys/sparc64/ieee.c | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/newlib/libc/sys/sparc64/ieee.c b/newlib/libc/sys/sparc64/ieee.c new file mode 100644 index 000000000..28289761d --- /dev/null +++ b/newlib/libc/sys/sparc64/ieee.c @@ -0,0 +1,115 @@ + +#include <ieeefp.h> + + +fp_rnd +_DEFUN_VOID(fpgetround) +{ + char *out; + ieee_flags("get", "direction","", &out); + if (strcmp(out,"nearest") == 0) return FP_RN; + if (strcmp(out,"negative") == 0) return FP_RM; + if (strcmp(out,"positive") == 0) return FP_RP; + if (strcmp(out,"tozero") == 0) return FP_RZ; + abort(); + +} + +fp_rnd +_DEFUN(fpsetround,(new), + fp_rnd new) +{ + fp_rnd old = fpgetround(); + char *dummy; + + switch (new) + { + case FP_RN: + ieee_flags("set", "direction", "nearest", &dummy); + break; + case FP_RM: + ieee_flags("set", "direction", "negative", &dummy); + break; + case FP_RP: + ieee_flags("set", "direction", "positive", &dummy); + break; + case FP_RZ: + ieee_flags("set", "direction", "tozero", &dummy); + break; + default: + break; + } + return old; +} + + +fp_except +_DEFUN_VOID(fpgetmask) +{ + char *out; + int r = 0; + + int i = ieee_flags("get","exception","",&out); + if (i & 1) r |= FP_X_IMP; + if (i & 2) r |= FP_X_DX; + if (i & 4) r |= FP_X_UFL; + if (i & 8) r |= FP_X_OFL; + if (i & 16) r |= FP_X_INV; + return r; + +} + +fp_except +_DEFUN(fpsetmask,(mask), + fp_except mask) +{ + fp_except old = fpgetmask(); + + char *out; + ieee_flags("clear","exception", "all", &out); + + + if (mask & FP_X_IMP) + ieee_flags("set","exception","inexact", &out); + if (mask & FP_X_DX) + ieee_flags("set","exception","division", &out); + if (mask & FP_X_UFL) + ieee_flags("set","exception","underflow", &out); + if (mask & FP_X_OFL) + ieee_flags("set","exception","overflow", &out); + if (mask & FP_X_INV) + ieee_flags("set","exception","invalid", &out); + + return old; + +} + +fp_except +_DEFUN(fpsetsticky,(mask), + fp_except mask) +{ + return fpsetmask(mask); +} + +fp_except +_DEFUN_VOID(fpgetsticky) +{ + return fpgetmask(); +} + +int +_DEFUN(fpsetroundtoi,(rdi_mode), + fp_rdi rdi_mode) +{ + + return 0; + +} + +int +_DEFUN_VOID(fpgetroundtoi) +{ + + return 0; + +} |