From 3dc6edf793c33483c9d7365b865152d57fa994fb Mon Sep 17 00:00:00 2001 From: mrkn Date: Thu, 26 Aug 2010 00:14:18 +0000 Subject: * ext/bigdecimal/bigdecimal.c (Init_bigdecimal, rmpd_set_thread_local_exception_mode, VpGetException, VpSetException): thread-local exception mode. * ext/bigdecimal/bigdecimal.c (Init_bigdecimal, rmpd_set_thread_local_precision_limit, VpGetPrecLimit, VpSetPrecLimit): thread-local precision limit. * ext/bigdecimal/bigdecimal.c (Init_bigdecimal, rmpd_set_thread_local_rounding_mode, VpGetRoundMode, VpSetRoundMode, VpException, VpInternalRound): thread-local rounding mode. * ext/bigdecimal/bigdecimal.c (BigDecimal_mode, BigDecimal_round, VpIsRoundMode, VpGetRoundMode, VpSetRoundMode, VpActiveRound, VpMidRound, VpLeftRound), ext/bigdecimal/bigdecimal.h: use unsigned short for rounding mode. * test/bigdecimal/test_bigdecimal.rb (test_mode): add test for setting rounding mode. * test/bigdecimal/test_bigdecimal.rb (test_thread_local_mode): add test for setting mode thread-locally. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29099 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/bigdecimal/bigdecimal.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'ext/bigdecimal/bigdecimal.h') diff --git a/ext/bigdecimal/bigdecimal.h b/ext/bigdecimal/bigdecimal.h index 06b9a85c3a..afc6703c0c 100644 --- a/ext/bigdecimal/bigdecimal.h +++ b/ext/bigdecimal/bigdecimal.h @@ -98,6 +98,8 @@ extern VALUE rb_cBigDecimal; #define VP_EXCEPTION_OP ((unsigned short)0x0020) #define VP_EXCEPTION_MEMORY ((unsigned short)0x0040) +#define RMPD_EXCEPTION_MODE_DEFAULT 0U + /* Computation mode */ #define VP_ROUND_MODE ((unsigned short)0x0100) #define VP_ROUND_UP 1 @@ -108,6 +110,8 @@ extern VALUE rb_cBigDecimal; #define VP_ROUND_FLOOR 6 #define VP_ROUND_HALF_EVEN 7 +#define RMPD_ROUNDING_MODE_DEFAULT VP_ROUND_HALF_UP + #define VP_SIGN_NaN 0 /* NaN */ #define VP_SIGN_POSITIVE_ZERO 1 /* Positive zero */ #define VP_SIGN_NEGATIVE_ZERO -1 /* Negative zero */ @@ -176,9 +180,9 @@ VP_EXPORT size_t VpGetPrecLimit(void); VP_EXPORT size_t VpSetPrecLimit(size_t n); /* Round mode */ -VP_EXPORT int VpIsRoundMode(unsigned long n); -VP_EXPORT unsigned long VpGetRoundMode(void); -VP_EXPORT unsigned long VpSetRoundMode(unsigned long n); +VP_EXPORT int VpIsRoundMode(unsigned short n); +VP_EXPORT unsigned short VpGetRoundMode(void); +VP_EXPORT unsigned short VpSetRoundMode(unsigned short n); VP_EXPORT int VpException(unsigned short f,const char *str,int always); #if 0 /* unused */ @@ -206,9 +210,9 @@ VP_EXPORT void VpDtoV(Real *m,double d); VP_EXPORT void VpItoV(Real *m,S_INT ival); #endif VP_EXPORT int VpSqrt(Real *y,Real *x); -VP_EXPORT int VpActiveRound(Real *y, Real *x, int f, ssize_t il); -VP_EXPORT int VpMidRound(Real *y, int f, ssize_t nf); -VP_EXPORT int VpLeftRound(Real *y, int f, ssize_t nf); +VP_EXPORT int VpActiveRound(Real *y, Real *x, unsigned short f, ssize_t il); +VP_EXPORT int VpMidRound(Real *y, unsigned short f, ssize_t nf); +VP_EXPORT int VpLeftRound(Real *y, unsigned short f, ssize_t nf); VP_EXPORT void VpFrac(Real *y, Real *x); VP_EXPORT int VpPower(Real *y, Real *x, SIGNED_VALUE n); -- cgit v1.2.3