diff options
author | hjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-09-27 17:47:23 +0000 |
---|---|---|
committer | hjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-09-27 17:47:23 +0000 |
commit | 84d1fc49c54eda6906a643de78b72df65c2ce9fb (patch) | |
tree | 373fa862a43e43bb30e4f569c9c95e43119764f8 /libgcc/config/libbid/bid_flag_operations.c | |
parent | 72c59a18cc11b00528f439ea717715b9baddad9d (diff) | |
download | gcc-84d1fc49c54eda6906a643de78b72df65c2ce9fb.tar.gz |
libgcc/
2007-09-27 H.J. Lu <hongjiu.lu@intel.com>
* Makefile.in (dfp-filenames): Replace decimal_globals,
decimal_data, binarydecimal and convert_data with
bid_decimal_globals, bid_decimal_data, bid_binarydecimal
and bid_convert_data, respectively.
libgcc/config/libbid/
2007-09-27 H.J. Lu <hongjiu.lu@intel.com>
* bid128_fromstring.c: Removed.
* bid_dpd.c: New from libbid 2007-09-26.
* bid128_to_int16.c: Likewise.
* bid128_to_int8.c: Likewise.
* bid128_to_uint8.c: Likewise.
* bid128_to_uint16.c: Likewise.
* bid64_to_int16.c: Likewise.
* bid64_to_int8.c: Likewise.
* bid64_to_uint16.c: Likewise.
* bid64_to_uint8.c: Likewise.
* bid128_2_str.h: Updated from libbid 2007-09-26.
* bid128_2_str_macros.h: Likewise.
* bid128_2_str_tables.c: Likewise.
* bid128_add.c: Likewise.
* bid128.c: Likewise.
* bid128_compare.c: Likewise.
* bid128_div.c: Likewise.
* bid128_fma.c: Likewise.
* bid128_logb.c: Likewise.
* bid128_minmax.c: Likewise.
* bid128_mul.c: Likewise.
* bid128_next.c: Likewise.
* bid128_noncomp.c: Likewise.
* bid128_quantize.c: Likewise.
* bid128_rem.c: Likewise.
* bid128_round_integral.c: Likewise.
* bid128_scalb.c: Likewise.
* bid128_sqrt.c: Likewise.
* bid128_string.c: Likewise.
* bid128_to_int32.c: Likewise.
* bid128_to_int64.c: Likewise.
* bid128_to_uint32.c: Likewise.
* bid128_to_uint64.c: Likewise.
* bid32_to_bid128.c: Likewise.
* bid32_to_bid64.c: Likewise.
* bid64_add.c: Likewise.
* bid64_compare.c: Likewise.
* bid64_div.c: Likewise.
* bid64_fma.c: Likewise.
* bid64_logb.c: Likewise.
* bid64_minmax.c: Likewise.
* bid64_mul.c: Likewise.
* bid64_next.c: Likewise.
* bid64_noncomp.c: Likewise.
* bid64_quantize.c: Likewise.
* bid64_rem.c: Likewise.
* bid64_round_integral.c: Likewise.
* bid64_scalb.c: Likewise.
* bid64_sqrt.c: Likewise.
* bid64_string.c: Likewise.
* bid64_to_bid128.c: Likewise.
* bid64_to_int32.c: Likewise.
* bid64_to_int64.c: Likewise.
* bid64_to_uint32.c: Likewise.
* bid64_to_uint64.c: Likewise.
* bid_b2d.h: Likewise.
* bid_binarydecimal.c: Likewise.
* bid_conf.h: Likewise.
* bid_convert_data.c: Likewise.
* bid_decimal_data.c: Likewise.
* bid_decimal_globals.c: Likewise.
* bid_div_macros.h: Likewise.
* bid_flag_operations.c: Likewise.
* bid_from_int.c: Likewise.
* bid_functions.h: Likewise.
* bid_gcc_intrinsics.h: Likewise.
* bid_inline_add.h: Likewise.
* bid_internal.h: Likewise.
* bid_round.c: Likewise.
* bid_sqrt_macros.h: Likewise.
* _addsub_dd.c: Likewise.
* _addsub_sd.c: Likewise.
* _addsub_td.c: Likewise.
* _dd_to_df.c: Likewise.
* _dd_to_di.c: Likewise.
* _dd_to_sd.c: Likewise.
* _dd_to_sf.c: Likewise.
* _dd_to_si.c: Likewise.
* _dd_to_td.c: Likewise.
* _dd_to_tf.c: Likewise.
* _dd_to_udi.c: Likewise.
* _dd_to_usi.c: Likewise.
* _dd_to_xf.c: Likewise.
* _df_to_dd.c: Likewise.
* _df_to_sd.c: Likewise.
* _df_to_td.c: Likewise.
* _di_to_dd.c: Likewise.
* _di_to_sd.c: Likewise.
* _di_to_td.c: Likewise.
* _div_dd.c: Likewise.
* _div_sd.c: Likewise.
* _div_td.c: Likewise.
* _eq_dd.c: Likewise.
* _eq_sd.c: Likewise.
* _eq_td.c: Likewise.
* _ge_dd.c: Likewise.
* _ge_sd.c: Likewise.
* _ge_td.c: Likewise.
* _gt_dd.c: Likewise.
* _gt_sd.c: Likewise.
* _gt_td.c: Likewise.
* _isinfd128.c: Likewise.
* _isinfd32.c: Likewise.
* _isinfd64.c: Likewise.
* _le_dd.c: Likewise.
* _le_sd.c: Likewise.
* _le_td.c: Likewise.
* _lt_dd.c: Likewise.
* _lt_sd.c: Likewise.
* _lt_td.c: Likewise.
* _mul_dd.c: Likewise.
* _mul_sd.c: Likewise.
* _mul_td.c: Likewise.
* _ne_dd.c: Likewise.
* _ne_sd.c: Likewise.
* _ne_td.c: Likewise.
* _sd_to_dd.c: Likewise.
* _sd_to_df.c: Likewise.
* _sd_to_di.c: Likewise.
* _sd_to_sf.c: Likewise.
* _sd_to_si.c: Likewise.
* _sd_to_td.c: Likewise.
* _sd_to_tf.c: Likewise.
* _sd_to_udi.c: Likewise.
* _sd_to_usi.c: Likewise.
* _sd_to_xf.c: Likewise.
* _sf_to_dd.c: Likewise.
* _sf_to_sd.c: Likewise.
* _sf_to_td.c: Likewise.
* _si_to_dd.c: Likewise.
* _si_to_sd.c: Likewise.
* _si_to_td.c: Likewise.
* _td_to_dd.c: Likewise.
* _td_to_df.c: Likewise.
* _td_to_di.c: Likewise.
* _td_to_sd.c: Likewise.
* _td_to_sf.c: Likewise.
* _td_to_si.c: Likewise.
* _td_to_tf.c: Likewise.
* _td_to_udi.c: Likewise.
* _td_to_usi.c: Likewise.
* _td_to_xf.c: Likewise.
* _tf_to_dd.c: Likewise.
* _tf_to_sd.c: Likewise.
* _tf_to_td.c: Likewise.
* _udi_to_dd.c: Likewise.
* _udi_to_sd.c: Likewise.
* _udi_to_td.c: Likewise.
* _unord_dd.c: Likewise.
* _unord_sd.c: Likewise.
* _unord_td.c: Likewise.
* _usi_to_dd.c: Likewise.
* _usi_to_sd.c: Likewise.
* _usi_to_td.c: Likewise.
* _xf_to_dd.c: Likewise.
* _xf_to_sd.c: Likewise.
* _xf_to_td.c: Likewise.
2007-09-27 H.J. Lu <hongjiu.lu@intel.com>
* b2d.h: Renamed to ...
* bid_b2d.h: This.
* bid128_to_string.c: Renamed to ...
* bid128_string.c: This.
* bid_intrinsics.h: Renamed to ...
* bid_gcc_intrinsics.h: This.
* bid_string.c: Renamed to ...
* bid64_string.c: This.
* binarydecimal.c: Renamed to ...
* bid_decimal_globals.c: This.
* convert_data.c: Renamed to ...
* bid_convert_data.c: This.
* decimal_data.c: Renamed to ...
* bid_decimal_data.c: This.
* decimal_globals.c: Renamed to ...
* bid_decimal_globals.c: This.
* div_macros.h: Renamed to ...
* bid_div_macros.h: This.
* inline_bid_add.h: Renamed to ...
* bid_inline_add.h: This.
* sqrt_macros.h: Renamed to ...
* bid_sqrt_macros.h: This.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@128841 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgcc/config/libbid/bid_flag_operations.c')
-rw-r--r-- | libgcc/config/libbid/bid_flag_operations.c | 155 |
1 files changed, 101 insertions, 54 deletions
diff --git a/libgcc/config/libbid/bid_flag_operations.c b/libgcc/config/libbid/bid_flag_operations.c index 3198f968bf7..d025e635f88 100644 --- a/libgcc/config/libbid/bid_flag_operations.c +++ b/libgcc/config/libbid/bid_flag_operations.c @@ -30,13 +30,11 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA * Non-computational Operations on Flags: ****************************************************************************/ -#include "bid_conf.h" -#include "bid_functions.h" #include "bid_internal.h" // Note the following definitions from bid_conf.h: if the status flags are // global, they have a fixed name recognized by the library functions: -// __bid_IDEC_glbflags; pfpsf, defined as &__bid_IDEC_glbflags, can be used instead; no +// _IDEC_glbflags; pfpsf, defined as &_IDEC_glbflags, can be used instead; no // argument is passed for the status flags to the library functions; if the // status flags are local then they are passed as an arument, always by // reference, to the library functions @@ -44,59 +42,79 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA // #if !DECIMAL_GLOBAL_EXCEPTION_FLAGS // #define _EXC_FLAGS_PARAM , _IDEC_flags *pfpsf // #else -// extern _IDEC_flags __bid_IDEC_glbflags; +// extern _IDEC_flags _IDEC_glbflags; // #define _EXC_FLAGS_PARAM -// #define pfpsf &__bid_IDEC_glbflags +// #define pfpsf &_IDEC_glbflags // #endif #if DECIMAL_CALL_BY_REFERENCE void -__bid_lowerFlags (_IDEC_flags * pflagsmask _EXC_FLAGS_PARAM) { +signalException (_IDEC_flags * pflagsmask _EXC_FLAGS_PARAM) { + // *pflagsmask is the logical OR of the flags to be set, e.g. + // *pflagsmask =INVALID_EXCEPTION | ZERO_DIVIDE_EXCEPTION | OVERFLOW_EXCEPTION + // UNDERFLOW_EXCEPTION | INEXACT_EXCEPTION to set all five IEEE 754R + // exception flags + *pfpsf = *pfpsf | (*pflagsmask & BID_IEEE_FLAGS); +} +#else +void +signalException (_IDEC_flags flagsmask _EXC_FLAGS_PARAM) { + // flagsmask is the logical OR of the flags to be set, e.g. + // flagsmask = INVALID_EXCEPTION | ZERO_DIVIDE_EXCEPTION | OVERFLOW_EXCEPTION + // UNDERFLOW_EXCEPTION | INEXACT_EXCEPTION to set all five IEEE 754R + // exception flags + *pfpsf = *pfpsf | (flagsmask & BID_IEEE_FLAGS); +} +#endif + +#if DECIMAL_CALL_BY_REFERENCE +void +lowerFlags (_IDEC_flags * pflagsmask _EXC_FLAGS_PARAM) { // *pflagsmask is the logical OR of the flags to be cleared, e.g. // *pflagsmask =INVALID_EXCEPTION | ZERO_DIVIDE_EXCEPTION | OVERFLOW_EXCEPTION // UNDERFLOW_EXCEPTION | INEXACT_EXCEPTION to clear all five IEEE 754R // exception flags - *pfpsf = *pfpsf & ~(*pflagsmask); + *pfpsf = *pfpsf & ~(*pflagsmask & BID_IEEE_FLAGS); } #else void -__bid_lowerFlags (_IDEC_flags flagsmask _EXC_FLAGS_PARAM) { +lowerFlags (_IDEC_flags flagsmask _EXC_FLAGS_PARAM) { // flagsmask is the logical OR of the flags to be cleared, e.g. // flagsmask = INVALID_EXCEPTION | ZERO_DIVIDE_EXCEPTION | OVERFLOW_EXCEPTION // UNDERFLOW_EXCEPTION | INEXACT_EXCEPTION to clear all five IEEE 754R // exception flags - *pfpsf = *pfpsf & ~(flagsmask); + *pfpsf = *pfpsf & ~(flagsmask & BID_IEEE_FLAGS); } #endif #if DECIMAL_CALL_BY_REFERENCE void -__bid_testFlags (_IDEC_flags * praised, +testFlags (_IDEC_flags * praised, _IDEC_flags * pflagsmask _EXC_FLAGS_PARAM) { // *praised is a pointer to the result, i.e. the logical OR of the flags // selected by *pflagsmask that are set; e.g. if // *pflagsmask = INVALID_EXCEPTION | UNDERFLOW_EXCEPTION | INEXACT_EXCEPTION // and only the invalid and inexact flags are raised (set) then upon return // *praised = INVALID_EXCEPTION | INEXACT_EXCEPTION - *praised = *pfpsf & *pflagsmask; + *praised = *pfpsf & (*pflagsmask & BID_IEEE_FLAGS); } #else _IDEC_flags -__bid_testFlags (_IDEC_flags flagsmask _EXC_FLAGS_PARAM) { +testFlags (_IDEC_flags flagsmask _EXC_FLAGS_PARAM) { _IDEC_flags raised; // the raturn value raised is the logical OR of the flags // selected by flagsmask, that are set; e.g. if // flagsmask = INVALID_EXCEPTION | UNDERFLOW_EXCEPTION | INEXACT_EXCEPTION and // only the invalid and inexact flags are raised (set) then the return value // is raised = INVALID_EXCEPTION | INEXACT_EXCEPTION - raised = *pfpsf & flagsmask; + raised = *pfpsf & (flagsmask & BID_IEEE_FLAGS); return (raised); } #endif #if DECIMAL_CALL_BY_REFERENCE void -__bid_testSavedFlags (_IDEC_flags * praised, _IDEC_flags * psavedflags, +testSavedFlags (_IDEC_flags * praised, _IDEC_flags * psavedflags, _IDEC_flags * pflagsmask) { // *praised is a pointer to the result, i.e. the logical OR of the flags // selected by *pflagsmask that are set in *psavedflags; e.g. if @@ -105,11 +123,11 @@ __bid_testSavedFlags (_IDEC_flags * praised, _IDEC_flags * psavedflags, // then upon return *praised = INVALID_EXCEPTION | INEXACT_EXCEPTION // Note that the flags could be saved in a global variable, but this function // would still expect that value as an argument passed by reference - *praised = *psavedflags & *pflagsmask; + *praised = *psavedflags & (*pflagsmask & BID_IEEE_FLAGS); } #else _IDEC_flags -__bid_testSavedFlags (_IDEC_flags savedflags, _IDEC_flags flagsmask) { +testSavedFlags (_IDEC_flags savedflags, _IDEC_flags flagsmask) { _IDEC_flags raised; // the raturn value raised is the logical OR of the flags // selected by flagsmask, that are set in savedflags; e.g. if @@ -118,14 +136,14 @@ __bid_testSavedFlags (_IDEC_flags savedflags, _IDEC_flags flagsmask) { // then the return value is raised = INVALID_EXCEPTION | INEXACT_EXCEPTION // Note that the flags could be saved in a global variable, but this function // would still expect that value as an argument passed by value - raised = savedflags & flagsmask; + raised = savedflags & (flagsmask & BID_IEEE_FLAGS); return (raised); } #endif #if DECIMAL_CALL_BY_REFERENCE void -__bid_restoreFlags (_IDEC_flags * pflagsvalues, +restoreFlags (_IDEC_flags * pflagsvalues, _IDEC_flags * pflagsmask _EXC_FLAGS_PARAM) { // restore the status flags selected by *pflagsmask to the values speciafied // (as a logical OR) in *pflagsvalues; e.g. if @@ -133,12 +151,14 @@ __bid_restoreFlags (_IDEC_flags * pflagsvalues, // and only the invalid and inexact flags are raised (set) in *pflagsvalues // then upon return the invalid status flag will be set, the underflow status // flag will be clear, and the inexact status flag will be set - *pfpsf = *pfpsf & ~(*pflagsmask); // clear flags that have to be restored - *pfpsf = *pfpsf | (*pflagsvalues & *pflagsmask); // restore flags + *pfpsf = *pfpsf & ~(*pflagsmask & BID_IEEE_FLAGS); + // clear flags that have to be restored + *pfpsf = *pfpsf | (*pflagsvalues & (*pflagsmask & BID_IEEE_FLAGS)); + // restore flags } #else void -__bid_restoreFlags (_IDEC_flags flagsvalues, +restoreFlags (_IDEC_flags flagsvalues, _IDEC_flags flagsmask _EXC_FLAGS_PARAM) { // restore the status flags selected by flagsmask to the values speciafied // (as a logical OR) in flagsvalues; e.g. if @@ -146,14 +166,16 @@ __bid_restoreFlags (_IDEC_flags flagsvalues, // and only the invalid and inexact flags are raised (set) in flagsvalues // then upon return the invalid status flag will be set, the underflow status // flag will be clear, and the inexact status flag will be set - *pfpsf = *pfpsf & ~flagsmask; // clear flags that have to be restored - *pfpsf = *pfpsf | (flagsvalues & flagsmask); // restore flags + *pfpsf = *pfpsf & ~(flagsmask & BID_IEEE_FLAGS); + // clear flags that have to be restored + *pfpsf = *pfpsf | (flagsvalues & (flagsmask & BID_IEEE_FLAGS)); + // restore flags } #endif #if DECIMAL_CALL_BY_REFERENCE void -__bid_saveFlags (_IDEC_flags * pflagsvalues, +saveFlags (_IDEC_flags * pflagsvalues, _IDEC_flags * pflagsmask _EXC_FLAGS_PARAM) { // return in *pflagsvalues the status flags specified (as a logical OR) in // *pflagsmask; e.g. if @@ -161,25 +183,25 @@ __bid_saveFlags (_IDEC_flags * pflagsvalues, // and only the invalid and inexact flags are raised (set) in the status word, // then upon return the value in *pflagsvalues will have the invalid status // flag set, the underflow status flag clear, and the inexact status flag set - *pflagsvalues = *pfpsf & *pflagsmask; + *pflagsvalues = *pfpsf & (*pflagsmask & BID_IEEE_FLAGS); } #else _IDEC_flags -__bid_saveFlags (_IDEC_flags flagsmask _EXC_FLAGS_PARAM) { +saveFlags (_IDEC_flags flagsmask _EXC_FLAGS_PARAM) { _IDEC_flags flagsvalues; // return the status flags specified (as a logical OR) in flagsmask; e.g. if // flagsmask = INVALID_EXCEPTION | UNDERFLOW_EXCEPTION | INEXACT_EXCEPTION // and only the invalid and inexact flags are raised (set) in the status word, // then the return value will have the invalid status flag set, the // underflow status flag clear, and the inexact status flag set - flagsvalues = *pfpsf & flagsmask; + flagsvalues = *pfpsf & (flagsmask & BID_IEEE_FLAGS); return (flagsvalues); } #endif // Note the following definitions from bid_conf.h (rearranged): if the rounding // mode is global, it has a fixed name recognized by the library functions: -// __bid_IDEC_glbround; rnd_mode, defined as &__bid_IDEC_glbround, can be used instead; no +// _IDEC_glbround; rnd_mode, defined as &_IDEC_glbround, can be used instead; no // argument is passed for the rounding mode to the library functions; if the // rounding mode is local then it is passed as an arument, by reference or by // value, to the library functions @@ -189,14 +211,14 @@ __bid_saveFlags (_IDEC_flags flagsmask _EXC_FLAGS_PARAM) { // #define _RND_MODE_PARAM , _IDEC_round *prnd_mode // #else // #define _RND_MODE_PARAM -// #define rnd_mode __bid_IDEC_glbround +// #define rnd_mode _IDEC_glbround // #endif // #else // #if !DECIMAL_GLOBAL_ROUNDING // #define _RND_MODE_PARAM , _IDEC_round rnd_mode // #else // #define _RND_MODE_PARAM -// #define rnd_mode __bid_IDEC_glbround +// #define rnd_mode _IDEC_glbround // #endif // #endif @@ -204,16 +226,16 @@ __bid_saveFlags (_IDEC_flags flagsmask _EXC_FLAGS_PARAM) { #if !DECIMAL_GLOBAL_ROUNDING // #define _RND_MODE_PARAM , _IDEC_round *prnd_mode void -__bid_getDecimalRoundingDirection (_IDEC_round * rounding_mode +getDecimalRoundingDirection (_IDEC_round * rounding_mode _RND_MODE_PARAM) { // returns the current rounding mode *rounding_mode = *prnd_mode; } #else // #define _RND_MODE_PARAM - // #define rnd_mode __bid_IDEC_glbround + // #define rnd_mode _IDEC_glbround void -__bid_getDecimalRoundingDirection (_IDEC_round * rounding_mode +getDecimalRoundingDirection (_IDEC_round * rounding_mode _RND_MODE_PARAM) { // returns the current rounding mode *rounding_mode = rnd_mode; @@ -223,15 +245,15 @@ __bid_getDecimalRoundingDirection (_IDEC_round * rounding_mode #if !DECIMAL_GLOBAL_ROUNDING // #define _RND_MODE_PARAM , _IDEC_round rnd_mode _IDEC_round -__bid_getDecimalRoundingDirection (_IDEC_round rnd_mode) { +getDecimalRoundingDirection (_IDEC_round rnd_mode) { // returns the current rounding mode return (rnd_mode); } #else // #define _RND_MODE_PARAM - // #define rnd_mode __bid_IDEC_glbround + // #define rnd_mode _IDEC_glbround _IDEC_round -__bid_getDecimalRoundingDirection (void) { +getDecimalRoundingDirection (void) { // returns the current rounding mode return (rnd_mode); } @@ -242,62 +264,87 @@ __bid_getDecimalRoundingDirection (void) { #if !DECIMAL_GLOBAL_ROUNDING // #define _RND_MODE_PARAM , _IDEC_round *prnd_mode void -__bid_setDecimalRoundingDirection (_IDEC_round * rounding_mode +setDecimalRoundingDirection (_IDEC_round * rounding_mode _RND_MODE_PARAM) { - // sets the current rounding mode to the value in *rounding_mode - *prnd_mode = *rounding_mode; + // sets the current rounding mode to the value in *rounding_mode, if valid + if (*rounding_mode == ROUNDING_TO_NEAREST || + *rounding_mode == ROUNDING_DOWN || + *rounding_mode == ROUNDING_UP || + *rounding_mode == ROUNDING_TO_ZERO || + *rounding_mode == ROUNDING_TIES_AWAY) { + *prnd_mode = *rounding_mode; + } } #else // #define _RND_MODE_PARAM - // #define rnd_mode __bid_IDEC_glbround + // #define rnd_mode _IDEC_glbround void -__bid_setDecimalRoundingDirection (_IDEC_round * rounding_mode - _RND_MODE_PARAM) { - // sets the global rounding mode to the value in *rounding_mode - rnd_mode = *rounding_mode; +setDecimalRoundingDirection (_IDEC_round * rounding_mode + ) { + // sets the global rounding mode to the value in *rounding_mode, if valid + if (*rounding_mode == ROUNDING_TO_NEAREST || + *rounding_mode == ROUNDING_DOWN || + *rounding_mode == ROUNDING_UP || + *rounding_mode == ROUNDING_TO_ZERO || + *rounding_mode == ROUNDING_TIES_AWAY) { + rnd_mode = *rounding_mode; + } } #endif #else #if !DECIMAL_GLOBAL_ROUNDING // #define _RND_MODE_PARAM , _IDEC_round rnd_mode _IDEC_round -__bid_setDecimalRoundingDirection (_IDEC_round rounding_mode) { +setDecimalRoundingDirection (_IDEC_round rounding_mode _RND_MODE_PARAM) { // sets the current rounding mode to the value in rounding_mode; // however, when arguments are passed by value and the rounding mode // is a local variable, this is not of any use - return (rounding_mode); + if (rounding_mode == ROUNDING_TO_NEAREST || + rounding_mode == ROUNDING_DOWN || + rounding_mode == ROUNDING_UP || + rounding_mode == ROUNDING_TO_ZERO || + rounding_mode == ROUNDING_TIES_AWAY) { + return (rounding_mode); + } + return (rnd_mode); } #else // #define _RND_MODE_PARAM - // #define rnd_mode __bid_IDEC_glbround + // #define rnd_mode _IDEC_glbround void -__bid_setDecimalRoundingDirection (_IDEC_round rounding_mode) { - // sets the current rounding mode to the value in rounding_mode; - rnd_mode = rounding_mode; +setDecimalRoundingDirection (_IDEC_round rounding_mode) { + // sets the current rounding mode to the value in rounding_mode, if valid; + if (rounding_mode == ROUNDING_TO_NEAREST || + rounding_mode == ROUNDING_DOWN || + rounding_mode == ROUNDING_UP || + rounding_mode == ROUNDING_TO_ZERO || + rounding_mode == ROUNDING_TIES_AWAY) { + rnd_mode = rounding_mode; + } } #endif #endif #if DECIMAL_CALL_BY_REFERENCE void -__bid_is754 (int *retval) { +is754 (int *retval) { *retval = 0; } #else int -__bid_is754 (void) { +is754 (void) { return 0; } #endif #if DECIMAL_CALL_BY_REFERENCE void -__bid_is754R (int *retval) { +is754R (int *retval) { *retval = 1; } #else int -__bid_is754R (void) { +is754R (void) { return 1; } #endif |