Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reimplement RData on top of RTypedData #558

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
rb_objspace_call_finalizer_i
  • Loading branch information
byroot committed Jun 21, 2024
commit 7a2ce88fe6f2cb49745a8cd9128d782057132b13
6 changes: 3 additions & 3 deletions gc.c
Original file line number Diff line number Diff line change
@@ -3071,7 +3071,7 @@ memsize_deprecated_rdata_object(const void *ptr)

#define DEPRECATED_DATA_FREE RBIMPL_DATA_FUNC(-3)

const rb_data_type_t deprecated_rdata_type = {
const rb_data_type_t ruby_deprecated_rdata_type = {
.wrap_struct_name = "RDATA(deprecated)",
.function = {
.dmark = mark_deprecated_rdata_object,
@@ -3086,7 +3086,7 @@ rb_data_object_wrap(VALUE klass, void *datap, RUBY_DATA_FUNC dmark, RUBY_DATA_FU
RUBY_ASSERT_ALWAYS(dfree != (RUBY_DATA_FUNC)1);
if (klass) rb_data_object_check(klass);

VALUE obj = rb_data_typed_object_zalloc(klass, sizeof(struct RData), &deprecated_rdata_type);
VALUE obj = rb_data_typed_object_zalloc(klass, sizeof(struct RData), &ruby_deprecated_rdata_type);

struct RData *rdata = (struct RData *)obj;
rdata->dmark = dmark;
@@ -4363,7 +4363,7 @@ rb_objspace_call_finalizer_i(VALUE obj, void *data)

switch (BUILTIN_TYPE(obj)) {
case T_DATA:
if (!rb_free_at_exit && (!DATA_PTR(obj) || !RDATA(obj)->dfree)) break;
if (!rb_free_at_exit && (!RTYPEDDATA_GET_DATA(obj) || !RANY(obj)->as.typeddata.type->function.dfree)) break;
if (rb_obj_is_thread(obj)) break;
if (rb_obj_is_mutex(obj)) break;
if (rb_obj_is_fiber(obj)) break;
4 changes: 2 additions & 2 deletions include/ruby/internal/core/rtypeddata.h
Original file line number Diff line number Diff line change
@@ -523,7 +523,6 @@ RBIMPL_SYMBOL_EXPORT_END()
#define TypedData_Get_Struct(obj,type,data_type,sval) \
((sval) = RBIMPL_CAST((type *)rb_check_typeddata((obj), (data_type))))

extern const rb_data_type_t deprecated_rdata_type;

RBIMPL_ATTR_PURE()
RBIMPL_ATTR_ARTIFICIAL()
@@ -541,7 +540,8 @@ RBIMPL_ATTR_ARTIFICIAL()
static inline bool
rbimpl_rtypeddata_p(VALUE obj)
{
return RTYPEDDATA(obj)->type != &deprecated_rdata_type;
extern const rb_data_type_t ruby_deprecated_rdata_type;
return RTYPEDDATA(obj)->type != &ruby_deprecated_rdata_type;
}

RBIMPL_ATTR_PURE_UNLESS_DEBUG()
Loading
Oops, something went wrong.