ruby-changes:44437
From: nobu <ko1@a...>
Date: Fri, 28 Oct 2016 15:58:25 +0900 (JST)
Subject: [ruby-changes:44437] nobu:r56510 (trunk): internal.h: RB_OBJ_BUILTIN_TYPE
nobu 2016-10-28 15:58:19 +0900 (Fri, 28 Oct 2016) New Revision: 56510 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=56510 Log: internal.h: RB_OBJ_BUILTIN_TYPE * internal.h (RB_OBJ_BUILTIN_TYPE): special-const safe BUILTIN_TYPE. Modified files: trunk/ChangeLog trunk/ext/objspace/objspace.c trunk/file.c trunk/internal.h Index: internal.h =================================================================== --- internal.h (revision 56509) +++ internal.h (revision 56510) @@ -1682,6 +1682,24 @@ do { \ https://github.com/ruby/ruby/blob/trunk/internal.h#L1682 } \ } 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 */ Index: ext/objspace/objspace.c =================================================================== --- ext/objspace/objspace.c (revision 56509) +++ ext/objspace/objspace.c (revision 56510) @@ -922,7 +922,7 @@ objspace_internal_super_of(VALUE self, V https://github.com/ruby/ruby/blob/trunk/ext/objspace/objspace.c#L922 obj = (VALUE)DATA_PTR(obj); } - switch (TYPE(obj)) { + switch (OBJ_BUILTIN_TYPE(obj)) { case T_MODULE: case T_CLASS: case T_ICLASS: Index: ChangeLog =================================================================== --- ChangeLog (revision 56509) +++ ChangeLog (revision 56510) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Fri Oct 28 15:58:16 2016 Nobuyoshi Nakada <nobu@r...> + + * internal.h (RB_OBJ_BUILTIN_TYPE): special-const safe + BUILTIN_TYPE. + Fri Oct 28 15:20:18 2016 Nobuyoshi Nakada <nobu@r...> * complex.c (id_finite_p, id_infinite_p, id_rationalize, id_PI): Index: file.c =================================================================== --- file.c (revision 56509) +++ file.c (revision 56510) @@ -4346,7 +4346,7 @@ rb_file_join(VALUE ary, VALUE sep) https://github.com/ruby/ruby/blob/trunk/file.c#L4346 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); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/