summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2020-11-17 22:47:25 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2020-11-17 22:47:25 +0900
commit7c80edb577722a140b805f55f9c51a23f78da992 (patch)
treef9e972870e16efb7154902185b25eb5880855ed5 /include
parent5abb283dd7323e63b12ea14cc98b35f77ba771e7 (diff)
downloadmruby-7c80edb577722a140b805f55f9c51a23f78da992.tar.gz
mruby-7c80edb577722a140b805f55f9c51a23f78da992.zip
Revert half of 9fbf0ef8.
I misunderstand the meaning of #4483. Sorry.
Diffstat (limited to 'include')
-rw-r--r--include/mruby/array.h6
-rw-r--r--include/mruby/string.h6
-rw-r--r--include/mruby/value.h8
3 files changed, 14 insertions, 6 deletions
diff --git a/include/mruby/array.h b/include/mruby/array.h
index 61e3ab8d5..5164efa69 100644
--- a/include/mruby/array.h
+++ b/include/mruby/array.h
@@ -17,7 +17,7 @@ MRB_BEGIN_DECL
typedef struct mrb_shared_array {
int refcnt;
- mrb_int len;
+ mrb_ssize len;
mrb_value *ptr;
} mrb_shared_array;
@@ -33,9 +33,9 @@ struct RArray {
MRB_OBJECT_HEADER;
union {
struct {
- mrb_int len;
+ mrb_ssize len;
union {
- mrb_int capa;
+ mrb_ssize capa;
mrb_shared_array *shared;
} aux;
mrb_value *ptr;
diff --git a/include/mruby/string.h b/include/mruby/string.h
index a847a1804..8384128c7 100644
--- a/include/mruby/string.h
+++ b/include/mruby/string.h
@@ -23,9 +23,9 @@ struct RString {
MRB_OBJECT_HEADER;
union {
struct {
- mrb_int len;
+ mrb_ssize len;
union {
- mrb_int capa;
+ mrb_ssize capa;
struct mrb_shared_string *shared;
struct RString *fshared;
} aux;
@@ -54,7 +54,7 @@ struct RStringEmbed {
RSTR_SET_EMBED_LEN((s),(n));\
}\
else {\
- (s)->as.heap.len = (mrb_int)(n);\
+ (s)->as.heap.len = (mrb_ssize)(n);\
}\
} while (0)
#define RSTR_EMBED_PTR(s) (((struct RStringEmbed*)(s))->ary)
diff --git a/include/mruby/value.h b/include/mruby/value.h
index a0d299422..4c8befc44 100644
--- a/include/mruby/value.h
+++ b/include/mruby/value.h
@@ -168,6 +168,14 @@ struct RCptr {
#define MRB_SYMBOL_BIT (sizeof(mrb_sym) * CHAR_BIT - MRB_SYMBOL_SHIFT)
+#if INTPTR_MAX < MRB_INT_MAX
+ typedef intptr_t mrb_ssize;
+# define MRB_SSIZE_MAX (INTPTR_MAX>>MRB_FIXNUM_SHIFT)
+#else
+ typedef mrb_int mrb_ssize;
+# define MRB_SSIZE_MAX MRB_INT_MAX
+#endif
+
#ifndef mrb_immediate_p
#define mrb_immediate_p(o) (mrb_type(o) < MRB_TT_FREE)
#endif