summaryrefslogtreecommitdiff
path: root/internal/bignum.h
diff options
context:
space:
mode:
authorKenta Murata <mrkn@users.noreply.github.com>2019-12-31 22:48:23 +0900
committerGitHub <noreply@github.com>2019-12-31 22:48:23 +0900
commite082f41611755b0fde967fccf3174c90ecb8469e (patch)
treeea496f496836091ff4a2046613b11a112af9fb99 /internal/bignum.h
parent4ce28b58cbf3f3b5ab0bcd3fa4479d4f6d427158 (diff)
downloadruby-e082f41611755b0fde967fccf3174c90ecb8469e.tar.gz
Introduce BIGNUM_EMBED_P to check BIGNUM_EMBED_FLAG (#2802)
* bignum.h: Add BIGNUM_EMBED_P * bignum.c: Use macros for handling BIGNUM_EMBED_FLAG
Diffstat (limited to 'internal/bignum.h')
-rw-r--r--internal/bignum.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/internal/bignum.h b/internal/bignum.h
index c35ba9eb47..508386452c 100644
--- a/internal/bignum.h
+++ b/internal/bignum.h
@@ -139,6 +139,7 @@ static inline void BIGNUM_NEGATE(VALUE b);
static inline size_t BIGNUM_LEN(VALUE b);
static inline BDIGIT *BIGNUM_DIGITS(VALUE b);
static inline int BIGNUM_LENINT(VALUE b);
+static inline bool BIGNUM_EMBED_P(VALUE b);
RUBY_SYMBOL_EXPORT_BEGIN
/* bignum.c (export) */
@@ -207,7 +208,7 @@ BIGNUM_NEGATE(VALUE b)
static inline size_t
BIGNUM_LEN(VALUE b)
{
- if (! FL_TEST_RAW(b, BIGNUM_EMBED_FLAG)) {
+ if (! BIGNUM_EMBED_P(b)) {
return RBIGNUM(b)->as.heap.len;
}
else {
@@ -228,11 +229,18 @@ BIGNUM_LENINT(VALUE b)
static inline BDIGIT *
BIGNUM_DIGITS(VALUE b)
{
- if (FL_TEST_RAW(b, BIGNUM_EMBED_FLAG)) {
+ if (BIGNUM_EMBED_P(b)) {
return RBIGNUM(b)->as.ary;
}
else {
return RBIGNUM(b)->as.heap.digits;
}
}
+
+static inline bool
+BIGNUM_EMBED_P(VALUE b)
+{
+ return FL_TEST_RAW(b, BIGNUM_EMBED_FLAG);
+}
+
#endif /* INTERNAL_BIGNUM_H */