ruby-changes:64767
From: Kenta <ko1@a...>
Date: Wed, 6 Jan 2021 13:54:35 +0900 (JST)
Subject: [ruby-changes:64767] fa8295ccb9 (master): [ruby/bigdecimal] Rename BDIGIT to DECDIG
https://git.ruby-lang.org/ruby.git/commit/?id=fa8295ccb9 From fa8295ccb91e931e7ede2c02a5820cbba9787234 Mon Sep 17 00:00:00 2001 From: Kenta Murata <mrkn@m...> Date: Wed, 6 Jan 2021 11:54:17 +0900 Subject: [ruby/bigdecimal] Rename BDIGIT to DECDIG https://github.com/ruby/bigdecimal/commit/686487d942 diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c index 7f671f1..63de77c 100644 --- a/ext/bigdecimal/bigdecimal.c +++ b/ext/bigdecimal/bigdecimal.c @@ -115,7 +115,7 @@ static ID id_half; https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L115 */ static unsigned short VpGetException(void); static void VpSetException(unsigned short f); -static void VpInternalRound(Real *c, size_t ixDigit, BDIGIT vPrev, BDIGIT v); +static void VpInternalRound(Real *c, size_t ixDigit, DECDIG vPrev, DECDIG v); static int VpLimitRound(Real *c, size_t ixDigit); static Real *VpCopy(Real *pv, Real const* const x); @@ -137,7 +137,7 @@ static size_t https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L137 BigDecimal_memsize(const void *ptr) { const Real *pv = ptr; - return (sizeof(*pv) + pv->MaxPrec * sizeof(BDIGIT)); + return (sizeof(*pv) + pv->MaxPrec * sizeof(DECDIG)); } #ifndef HAVE_RB_EXT_RACTOR_SAFE @@ -381,7 +381,7 @@ BigDecimal_precision(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L381 ex = 0; } else if (p->Prec > 0) { - BDIGIT x = p->frac[0]; + DECDIG x = p->frac[0]; for (precision = 0; x > 0; x /= 10) { ++precision; } @@ -397,7 +397,7 @@ BigDecimal_precision(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L397 precision += n * BASE_FIG; if (ex < (ssize_t)p->Prec) { - BDIGIT x = p->frac[n]; + DECDIG x = p->frac[n]; for (; x > 0 && x % 10 == 0; x /= 10) { --precision; } @@ -423,7 +423,7 @@ BigDecimal_n_significant_digits(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L423 int nlz, ntz; - BDIGIT x = p->frac[0]; + DECDIG x = p->frac[0]; for (nlz = BASE_FIG; x > 0; x /= 10) --nlz; x = p->frac[n-1]; @@ -452,8 +452,8 @@ BigDecimal_hash(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L452 hash = (st_index_t)p->sign; /* hash!=2: the case for 0(1),NaN(0) or +-Infinity(3) is sign itself */ if(hash == 2 || hash == (st_index_t)-2) { - hash ^= rb_memhash(p->frac, sizeof(BDIGIT)*p->Prec); - hash += p->exponent; + hash ^= rb_memhash(p->frac, sizeof(DECDIG)*p->Prec); + hash += p->exponent; } return ST2FIX(hash); } @@ -760,8 +760,8 @@ VpCreateRbObject(size_t mx, const char *str, bool raise_exception) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L760 return VpNewRbClass(mx, str, rb_cBigDecimal, true, raise_exception); } -#define VpAllocReal(prec) (Real *)VpMemAlloc(offsetof(Real, frac) + (prec) * sizeof(BDIGIT)) -#define VpReallocReal(ptr, prec) (Real *)VpMemRealloc((ptr), offsetof(Real, frac) + (prec) * sizeof(BDIGIT)) +#define VpAllocReal(prec) (Real *)VpMemAlloc(offsetof(Real, frac) + (prec) * sizeof(DECDIG)) +#define VpReallocReal(ptr, prec) (Real *)VpMemRealloc((ptr), offsetof(Real, frac) + (prec) * sizeof(DECDIG)) static Real * VpCopy(Real *pv, Real const* const x) @@ -774,7 +774,7 @@ VpCopy(Real *pv, Real const* const x) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L774 pv->exponent = x->exponent; pv->sign = x->sign; pv->flag = x->flag; - MEMCPY(pv->frac, x->frac, BDIGIT, pv->MaxPrec); + MEMCPY(pv->frac, x->frac, DECDIG, pv->MaxPrec); return pv; } @@ -836,7 +836,7 @@ BigDecimal_to_i(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L836 if (e <= 0) return INT2FIX(0); nf = VpBaseFig(); if (e <= nf) { - return LONG2NUM((long)(VpGetSign(p) * (BDIGIT_DBL_SIGNED)p->frac[0])); + return LONG2NUM((long)(VpGetSign(p) * (DECDIG_DBL_SIGNED)p->frac[0])); } else { VALUE a = BigDecimal_split(self); @@ -1424,7 +1424,7 @@ BigDecimal_div(VALUE self, VALUE r) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L1424 */ /* Round */ if (VpHasVal(div)) { /* frac[0] must be zero for NaN,INF,Zero */ - VpInternalRound(c, 0, c->frac[c->Prec-1], (BDIGIT)(VpBaseVal() * (BDIGIT_DBL)res->frac[0] / div->frac[0])); + VpInternalRound(c, 0, c->frac[c->Prec-1], (DECDIG)(VpBaseVal() * (DECDIG_DBL)res->frac[0] / div->frac[0])); } return VpCheckGetValue(c); } @@ -2724,7 +2724,7 @@ rb_uint64_convert_to_BigDecimal(uint64_t uval, RB_UNUSED_VAR(size_t digs), int r https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L2724 vp->Prec = 1; vp->exponent = 1; VpSetSign(vp, 1); - vp->frac[0] = (BDIGIT)uval; + vp->frac[0] = (DECDIG)uval; } else { const size_t len10 = ceil(LOG10_2 * bit_length(uval)); @@ -2738,7 +2738,7 @@ rb_uint64_convert_to_BigDecimal(uint64_t uval, RB_UNUSED_VAR(size_t digs), int r https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L2738 size_t i; for (i = 0; i < len; ++i) { - BDIGIT r = uval % BASE; + DECDIG r = uval % BASE; vp->frac[len - i - 1] = r; uval /= BASE; } @@ -3809,9 +3809,9 @@ enum op_sw { https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L3809 static int VpIsDefOP(Real *c, Real *a, Real *b, enum op_sw sw); static int AddExponent(Real *a, SIGNED_VALUE n); -static BDIGIT VpAddAbs(Real *a,Real *b,Real *c); -static BDIGIT VpSubAbs(Real *a,Real *b,Real *c); -static size_t VpSetPTR(Real *a, Real *b, Real *c, size_t *a_pos, size_t *b_pos, size_t *c_pos, BDIGIT *av, BDIGIT *bv); +static DECDIG VpAddAbs(Real *a,Real *b,Real *c); +static DECDIG VpSubAbs(Real *a,Real *b,Real *c); +static size_t VpSetPTR(Real *a, Real *b, Real *c, size_t *a_pos, size_t *b_pos, size_t *c_pos, DECDIG *av, DECDIG *bv); static int VpNmlz(Real *a); static void VpFormatSt(char *psz, size_t fFmt); static int VpRdup(Real *m, size_t ind_m); @@ -4215,13 +4215,13 @@ VpNumOfChars(Real *vp,const char *pszFmt) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L4215 * that BASE is as large as possible satisfying the * relation MaxVal <= BASE*(BASE+1). Where the value * MaxVal is the largest value which can be represented - * by one BDIGIT word in the computer used. + * by one DECDIG word in the computer used. * * [Returns] * DBLE_FIG ... OK */ VP_EXPORT size_t -VpInit(BDIGIT BaseVal) +VpInit(DECDIG BaseVal) { /* Setup +/- Inf NaN -0 */ VpGetDoubleNegZero(); @@ -4236,12 +4236,12 @@ VpInit(BDIGIT BaseVal) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L4236 #ifdef BIGDECIMAL_DEBUG if (gfDebug) { - printf("VpInit: BaseVal = %"PRIuBDIGIT"\n", BaseVal); - printf("\tBASE = %"PRIuBDIGIT"\n", BASE); - printf("\tHALF_BASE = %"PRIuBDIGIT"\n", HALF_BASE); - printf("\tBASE1 = %"PRIuBDIGIT"\n", BASE1); - printf("\tBASE_FIG = %u\n", BASE_FIG); - printf("\tDBLE_FIG = %d\n", DBLE_FIG); + 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); } #endif /* BIGDECIMAL_DEBUG */ @@ -4601,7 +4601,7 @@ VpAsgn(Real *c, Real *a, int isw) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L4601 VpSetSign(c, isw * VpGetSign(a)); /* set sign */ n = (a->Prec < c->MaxPrec) ? (a->Prec) : (c->MaxPrec); c->Prec = n; - memcpy(c->frac, a->frac, n * sizeof(BDIGIT)); + memcpy(c->frac, a->frac, n * sizeof(DECDIG)); /* Needs round ? */ if (isw != 10) { /* Not in ActiveRound */ @@ -4632,7 +4632,7 @@ VpAddSub(Real *c, Real *a, Real *b, int operation) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L4632 short sw, isw; Real *a_ptr, *b_ptr; size_t n, na, nb, i; - BDIGIT mrv; + DECDIG mrv; #ifdef BIGDECIMAL_DEBUG if (gfDebug) { @@ -4760,7 +4760,7 @@ end_if: https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L4760 * a and b assuming abs(a)>abs(b). * c = abs(a) + abs(b) ; where |a|>=|b| */ -static BDIGIT +static DECDIG VpAddAbs(Real *a, Real *b, Real *c) { size_t word_shift; @@ -4770,7 +4770,7 @@ VpAddAbs(Real *a, Real *b, Real *c) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L4770 size_t a_pos; size_t b_pos, b_pos_with_word_shift; size_t c_pos; - BDIGIT av, bv, carry, mrv; + DECDIG av, bv, carry, mrv; #ifdef BIGDECIMAL_DEBUG if (gfDebug) { @@ -4855,7 +4855,7 @@ Exit: https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L4855 /* * c = abs(a) - abs(b) */ -static BDIGIT +static DECDIG VpSubAbs(Real *a, Real *b, Real *c) { size_t word_shift; @@ -4865,7 +4865,7 @@ VpSubAbs(Real *a, Real *b, Real *c) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L4865 size_t a_pos; size_t b_pos, b_pos_with_word_shift; size_t c_pos; - BDIGIT av, bv, borrow, mrv; + DECDIG av, bv, borrow, mrv; #ifdef BIGDECIMAL_DEBUG if (gfDebug) { @@ -4972,7 +4972,7 @@ Exit: https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L4972 * c_pos = | */ static size_t -VpSetPTR(Real *a, Real *b, Real *c, size_t *a_pos, size_t *b_pos, size_t *c_pos, BDIGIT *av, BDIGIT *bv) +VpSetPTR(Real *a, Real *b, Real *c, size_t *a_pos, size_t *b_pos, size_t *c_pos, DECDIG *av, DECDIG *bv) { size_t left_word, right_word, word_shift; @@ -5087,8 +5087,8 @@ VpMult(Real *c (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/