From 2c997a097449f129b6e36107ec3ce1979c6c117e Mon Sep 17 00:00:00 2001 From: Charlie Savage Date: Sat, 6 Jan 2024 21:51:14 -0800 Subject: [PATCH] Define rb_class_attached_object for older versions of Ruby. --- ext/ruby_prof/rp_method.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ext/ruby_prof/rp_method.c b/ext/ruby_prof/rp_method.c index 7464c764..261d59d9 100644 --- a/ext/ruby_prof/rp_method.c +++ b/ext/ruby_prof/rp_method.c @@ -6,6 +6,16 @@ #include "rp_method.h" #include "rp_profile.h" +#include + +// Needed for Ruby 3.0.* and 3.1.* +#if RUBY_API_VERSION_MAJOR == 3 && RUBY_API_VERSION_MINOR < 2 + VALUE rb_class_attached_object(VALUE klass) + { + return rb_iv_get(klass, "__attached__"); + } +#endif + VALUE cRpMethodInfo; /* ================ Helper Functions =================*/