diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | ext/objspace/objspace.c | 2 | ||||
-rw-r--r-- | file.c | 2 | ||||
-rw-r--r-- | internal.h | 18 |
4 files changed, 25 insertions, 2 deletions
@@ -1,3 +1,8 @@ +Fri Oct 28 15:58:16 2016 Nobuyoshi Nakada <[email protected]> + + * internal.h (RB_OBJ_BUILTIN_TYPE): special-const safe + BUILTIN_TYPE. + Fri Oct 28 15:20:18 2016 Nobuyoshi Nakada <[email protected]> * complex.c (id_finite_p, id_infinite_p, id_rationalize, id_PI): diff --git a/ext/objspace/objspace.c b/ext/objspace/objspace.c index eff9d0c7f8..958ef71db2 100644 --- a/ext/objspace/objspace.c +++ b/ext/objspace/objspace.c @@ -922,7 +922,7 @@ objspace_internal_super_of(VALUE self, VALUE obj) obj = (VALUE)DATA_PTR(obj); } - switch (TYPE(obj)) { + switch (OBJ_BUILTIN_TYPE(obj)) { case T_MODULE: case T_CLASS: case T_ICLASS: @@ -4346,7 +4346,7 @@ rb_file_join(VALUE ary, VALUE sep) OBJ_INFECT(result, ary); for (i=0; i<RARRAY_LEN(ary); i++) { tmp = RARRAY_AREF(ary, i); - switch (TYPE(tmp)) { + switch (OBJ_BUILTIN_TYPE(tmp)) { case T_STRING: if (!checked) check_path_encoding(tmp); StringValueCStr(tmp); diff --git a/internal.h b/internal.h index 116654ef91..c7e80aa978 100644 --- a/internal.h +++ b/internal.h @@ -1682,6 +1682,24 @@ do { \ } \ } while (0) +#define RB_OBJ_BUILTIN_TYPE(obj) rb_obj_builtin_type(obj) +#define OBJ_BUILTIN_TYPE(obj) RB_OBJ_BUILTIN_TYPE(obj) +#ifdef __GNUC__ +#define rb_obj_builtin_type(obj) \ +__extension__({ \ + VALUE arg_obj = (obj); \ + RB_SPECIAL_CONST_P(arg_obj) ? -1 : \ + RB_BUILTIN_TYPE(arg_obj); \ + }) +#else +static inline int +rb_obj_builtin_type(VALUE obj) +{ + return RB_SPECIAL_CONST_P(obj) ? -1 : + RB_BUILTIN_TYPE(obj); +} +#endif + #if defined(__cplusplus) #if 0 { /* satisfy cc-mode */ |