[前][次][番号順一覧][スレッド一覧]

ruby-changes:65136

From: Kenta <ko1@a...>
Date: Thu, 4 Feb 2021 13:19:17 +0900 (JST)
Subject: [ruby-changes:65136] 868d66e0b5 (master): [ruby/bigdecimal] Stop using rmpd and RMPD prefixes and DBLE_FIG

https://git.ruby-lang.org/ruby.git/commit/?id=868d66e0b5

From 868d66e0b513ae038648fffbe826d9580099a6f4 Mon Sep 17 00:00:00 2001
From: Kenta Murata <mrkn@m...>
Date: Sat, 30 Jan 2021 12:05:15 +0900
Subject: [ruby/bigdecimal] Stop using rmpd and RMPD prefixes and DBLE_FIG

https://github.com/ruby/bigdecimal/commit/7479923fdb
---
 ext/bigdecimal/bigdecimal.c | 90 ++++++++++++++++++++++-----------------------
 ext/bigdecimal/bigdecimal.h | 55 +++++++++++----------------
 2 files changed, 64 insertions(+), 81 deletions(-)

diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index e0832b8..b9ba0ea 100644
--- a/ext/bigdecimal/bigdecimal.c
+++ b/ext/bigdecimal/bigdecimal.c
@@ -67,16 +67,12 @@ static ID id_half; https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L67
 #define SAVE(p)  PUSH((p)->obj)
 #define GUARD_OBJ(p,y) ((p)=(y), SAVE(p))
 
-#define BASE_FIG  RMPD_COMPONENT_FIGURES
-#define BASE      RMPD_BASE
+#define BASE_FIG  BIGDECIMAL_COMPONENT_FIGURES
+#define BASE      BIGDECIMAL_BASE
 
 #define HALF_BASE (BASE/2)
 #define BASE1 (BASE/10)
 
-#ifndef DBLE_FIG
-#define DBLE_FIG RMPD_DOUBLE_FIGURES  /* figure of double */
-#endif
-
 #define LOG10_2 0.3010299956639812
 
 #ifndef RRATIONAL_ZERO_P
@@ -2371,7 +2367,7 @@ is_even(VALUE x) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L2367
 }
 
 static VALUE
-rmpd_power_by_big_decimal(Real const* x, Real const* exp, ssize_t const n)
+bigdecimal_power_by_bigdecimal(Real const* x, Real const* exp, ssize_t const n)
 {
     VALUE log_x, multiplied, y;
     volatile VALUE obj = exp->obj;
@@ -2441,7 +2437,7 @@ BigDecimal_power(int argc, VALUE*argv, VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L2437
 	    goto retry;
 	}
         if (NIL_P(prec)) {
-            n += DBLE_FIG;
+            n += BIGDECIMAL_DOUBLE_FIGURES;
         }
         exp = GetVpValueWithPrec(vexp, 0, 1);
 	break;
@@ -2573,7 +2569,7 @@ BigDecimal_power(int argc, VALUE*argv, VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L2569
     }
 
     if (exp != NULL) {
-	return rmpd_power_by_big_decimal(x, exp, n);
+	return bigdecimal_power_by_bigdecimal(x, exp, n);
     }
     else if (RB_TYPE_P(vexp, T_BIGNUM)) {
 	VALUE abs_value = BigDecimal_abs(self);
@@ -2630,7 +2626,7 @@ BigDecimal_power(int argc, VALUE*argv, VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L2626
     else {
         GUARD_OBJ(y, VpCreateRbObject(1, "0", true));
     }
-    VpPower(y, x, int_exp);
+    VpPowerByInt(y, x, int_exp);
     if (!NIL_P(prec) && VpIsDef(y)) {
 	VpMidRound(y, VpGetRoundMode(), n);
     }
@@ -2849,22 +2845,22 @@ rb_float_convert_to_BigDecimal(VALUE val, size_t digs, int raise_exception) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L2845
                  "can't omit precision for a %"PRIsVALUE".",
                  CLASS_OF(val));
     }
-    else if (digs > DBLE_FIG) {
+    else if (digs > BIGDECIMAL_DOUBLE_FIGURES) {
         if (!raise_exception)
             return Qnil;
         rb_raise(rb_eArgError, "precision too large.");
     }
 
     /* Use the same logic in flo_to_s to convert a float to a decimal string */
-    char buf[DBLE_FIG + BASE_FIG + 2 + 1];  /* sizeof(buf) == 28 in the typical case */
+    char buf[BIGDECIMAL_DOUBLE_FIGURES + BASE_FIG + 2 + 1];  /* sizeof(buf) == 28 in the typical case */
     int decpt, negative_p;
     char *e;
     const int mode = digs == 0 ? 0 : 2;
     char *p = BigDecimal_dtoa(d, mode, (int)digs, &decpt, &negative_p, &e);
     int len10 = (int)(e - p);
-    if (len10 > DBLE_FIG) {
+    if (len10 > BIGDECIMAL_DOUBLE_FIGURES) {
         /* TODO: Presumably, rounding should be done here. */
-        len10 = DBLE_FIG;
+        len10 = BIGDECIMAL_DOUBLE_FIGURES;
     }
     memcpy(buf, p, len10);
     xfree(p);
@@ -3381,7 +3377,7 @@ BigMath_s_exp(VALUE klass, VALUE x, VALUE vprec) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L3377
     }
     x = vx->obj;
 
-    n = prec + rmpd_double_figures();
+    n = prec + BIGDECIMAL_DOUBLE_FIGURES;
     negative = BIGDECIMAL_NEGATIVE_P(vx);
     if (negative) {
         VALUE x_zero = INT2NUM(1);
@@ -3406,8 +3402,8 @@ BigMath_s_exp(VALUE klass, VALUE x, VALUE vprec) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L3402
 	if (m <= 0) {
 	    break;
 	}
-	else if ((size_t)m < rmpd_double_figures()) {
-	    m = rmpd_double_figures();
+	else if ((size_t)m < BIGDECIMAL_DOUBLE_FIGURES) {
+	    m = BIGDECIMAL_DOUBLE_FIGURES;
 	}
 
 	d = BigDecimal_mult(d, x);                             /* d <- d * x */
@@ -3543,7 +3539,7 @@ get_vp_value: https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L3539
     RB_GC_GUARD(one) = VpCheckGetValue(VpCreateRbObject(1, "1", true));
     RB_GC_GUARD(two) = VpCheckGetValue(VpCreateRbObject(1, "2", true));
 
-    n = prec + rmpd_double_figures();
+    n = prec + BIGDECIMAL_DOUBLE_FIGURES;
     RB_GC_GUARD(vn) = SSIZET2NUM(n);
     expo = VpExponent10(vx);
     if (expo < 0 || expo >= 3) {
@@ -3567,8 +3563,8 @@ get_vp_value: https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L3563
 	if (m <= 0) {
 	    break;
 	}
-	else if ((size_t)m < rmpd_double_figures()) {
-	    m = rmpd_double_figures();
+	else if ((size_t)m < BIGDECIMAL_DOUBLE_FIGURES) {
+	    m = BIGDECIMAL_DOUBLE_FIGURES;
 	}
 
 	x = BigDecimal_mult2(x2, x, vn);
@@ -4095,7 +4091,7 @@ VpFree(Real *pv) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L4091
  * EXCEPTION Handling.
  */
 
-#define rmpd_set_thread_local_exception_mode(mode) \
+#define bigdecimal_set_thread_local_exception_mode(mode) \
     rb_thread_local_aset( \
 	rb_thread_current(), \
 	id_BigDecimal_exception_mode, \
@@ -4111,8 +4107,8 @@ VpGetException (void) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L4107
     );
 
     if (NIL_P(vmode)) {
-	rmpd_set_thread_local_exception_mode(RMPD_EXCEPTION_MODE_DEFAULT);
-	return RMPD_EXCEPTION_MODE_DEFAULT;
+	bigdecimal_set_thread_local_exception_mode(BIGDECIMAL_EXCEPTION_MODE_DEFAULT);
+	return BIGDECIMAL_EXCEPTION_MODE_DEFAULT;
     }
 
     return NUM2USHORT(vmode);
@@ -4121,20 +4117,20 @@ VpGetException (void) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L4117
 static void
 VpSetException(unsigned short f)
 {
-    rmpd_set_thread_local_exception_mode(f);
+    bigdecimal_set_thread_local_exception_mode(f);
 }
 
 /*
  * Precision limit.
  */
 
-#define rmpd_set_thread_local_precision_limit(limit) \
+#define bigdecimal_set_thread_local_precision_limit(limit) \
     rb_thread_local_aset( \
 	rb_thread_current(), \
 	id_BigDecimal_precision_limit, \
 	SIZET2NUM(limit) \
     )
-#define RMPD_PRECISION_LIMIT_DEFAULT ((size_t)0)
+#define BIGDECIMAL_PRECISION_LIMIT_DEFAULT ((size_t)0)
 
 /* These 2 functions added at v1.1.7 */
 VP_EXPORT size_t
@@ -4146,8 +4142,8 @@ VpGetPrecLimit(void) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L4142
     );
 
     if (NIL_P(vlimit)) {
-	rmpd_set_thread_local_precision_limit(RMPD_PRECISION_LIMIT_DEFAULT);
-	return RMPD_PRECISION_LIMIT_DEFAULT;
+	bigdecimal_set_thread_local_precision_limit(BIGDECIMAL_PRECISION_LIMIT_DEFAULT);
+	return BIGDECIMAL_PRECISION_LIMIT_DEFAULT;
     }
 
     return NUM2SIZET(vlimit);
@@ -4157,7 +4153,7 @@ VP_EXPORT size_t https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L4153
 VpSetPrecLimit(size_t n)
 {
     size_t const s = VpGetPrecLimit();
-    rmpd_set_thread_local_precision_limit(n);
+    bigdecimal_set_thread_local_precision_limit(n);
     return s;
 }
 
@@ -4165,7 +4161,7 @@ VpSetPrecLimit(size_t n) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L4161
  * Rounding mode.
  */
 
-#define rmpd_set_thread_local_rounding_mode(mode) \
+#define bigdecimal_set_thread_local_rounding_mode(mode) \
     rb_thread_local_aset( \
 	rb_thread_current(), \
 	id_BigDecimal_rounding_mode, \
@@ -4181,8 +4177,8 @@ VpGetRoundMode(void) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L4177
     );
 
     if (NIL_P(vmode)) {
-	rmpd_set_thread_local_rounding_mode(RMPD_ROUNDING_MODE_DEFAULT);
-	return RMPD_ROUNDING_MODE_DEFAULT;
+	bigdecimal_set_thread_local_rounding_mode(BIGDECIMAL_ROUNDING_MODE_DEFAULT);
+	return BIGDECIMAL_ROUNDING_MODE_DEFAULT;
     }
 
     return NUM2USHORT(vmode);
@@ -4210,7 +4206,7 @@ VP_EXPORT unsigned short https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L4206
 VpSetRoundMode(unsigned short n)
 {
     if (VpIsRoundMode(n)) {
-	rmpd_set_thread_local_rounding_mode(n);
+	bigdecimal_set_thread_local_rounding_mode(n);
 	return n;
     }
 
@@ -4450,7 +4446,7 @@ VpNumOfChars(Real *vp,const char *pszFmt) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L4446
  *   by one DECDIG word in the computer used.
  *
  * [Returns]
- *   DBLE_FIG   ... OK
+ *   BIGDECIMAL_DOUBLE_FIGURES  ... OK
  */
 VP_EXPORT size_t
 VpInit(DECDIG BaseVal)
@@ -4468,16 +4464,16 @@ VpInit(DECDIG BaseVal) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L4464
 
 #ifdef BIGDECIMAL_DEBUG
     if (gfDebug) {
-        printf("VpInit: BaseVal   = %"PRIuDECDIG"\n", BaseVal);
+        printf("VpInit: BaseVal = %"PRIuDECDIG"\n", BaseVal);
         printf("\tBASE      = %"PRIuDECDIG"\n", BASE);
         printf("\tHALF_BASE = %"PRIuDECDIG"\n", HALF_BASE);
         printf("\tBASE1     = %"PRIuDECDIG"\n", BASE1);
         printf("\tBASE_FIG  = %u\n", BASE_FIG);
-        printf("\tDBLE_FIG  = %d\n", DBLE_FIG);
+        printf("\tBIGDECIMAL_DOUBLE_FIGURES = %d\n", BIGDECIMAL_DOUBLE_FIGURES);
     }
 #endif /* BIGDECIMAL_DEBUG */
 
-    return rmpd_double_figures();
+    return BIGDECIMAL_DOUBLE_FIGURES;
 }
 
 VP_EXPORT Real *
@@ -4525,7 +4521,7 @@ overflow: https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L4521
 }
 
 Real *
-rmpd_parse_special_string(const char *str)
+bigdecimal_parse_special_string(const char *s (... truncated)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]