ext/internal/thread/thread.c in ruby-internal-0.8.4 vs ext/internal/thread/thread.c in ruby-internal-0.8.5

- old
+ new

@@ -6,10 +6,26 @@ #include "internal/vm/control_frame/control_frame.h" #endif #ifdef RUBY_VM +#ifdef HAVE_TYPE_STRUCT_RTYPEDDATA + +# undef GetThreadPtr +# define GetThreadPtr(obj, ptr) \ + TypedData_Get_Struct((obj), rb_thread_t, p_ruby_threadptr_data_type, (ptr)) + + static rb_data_type_t const * p_ruby_threadptr_data_type; + + static void init_ruby_threadptr_data_type() + { + VALUE thread = rb_thread_current(); + p_ruby_threadptr_data_type = RTYPEDDATA_TYPE(thread); + } + +#endif + static VALUE rb_cVmControlFrame; /* TODO: also defined in control_frame.c */ void mark_ruby_internal_control_frame( struct RubyInternalControlFrame * cfp) @@ -106,8 +122,12 @@ rb_cRubyVM = rb_define_class("RubyVM", rb_cObject); rb_cVmControlFrame = rb_const_get(rb_cRubyVM, rb_intern("ControlFrame")); rb_define_method(rb_cThread, "cfp", thread_cfp, 0); +#endif + +#ifdef HAVE_TYPE_STRUCT_RTYPEDDATA + init_ruby_threadptr_data_type(); #endif }