summaryrefslogtreecommitdiff
path: root/gc.c
diff options
context:
space:
mode:
authorPeter Zhu <[email protected]>2024-12-03 13:26:10 -0500
committerPeter Zhu <[email protected]>2024-12-03 16:16:13 -0500
commit3a90663776f94e4a617a4069d1d073cc1eca0526 (patch)
tree9dc4530a7e5ed239546fcda3422af166eec7a432 /gc.c
parent6adc69c41c6edb409c5306573511cd6d8b436fbe (diff)
Move external_gc_loaded_p to gc_functions
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/12242
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/gc.c b/gc.c
index 40b17cacfc..5342628b0d 100644
--- a/gc.c
+++ b/gc.c
@@ -617,8 +617,6 @@ rb_gc_guarded_ptr_val(volatile VALUE *ptr, VALUE val)
static const char *obj_type_name(VALUE obj);
#define RB_AMALGAMATED_DEFAULT_GC
#include "gc/default/default.c"
-static int external_gc_loaded = FALSE;
-
#if USE_SHARED_GC && !defined(HAVE_DLOPEN)
# error "Shared GC requires dlopen"
@@ -704,6 +702,8 @@ typedef struct gc_function_map {
void (*copy_attributes)(void *objspace_ptr, VALUE dest, VALUE obj);
// GC Identification
const char *(*active_gc_name)(void);
+
+ bool external_gc_loaded_p;
} rb_gc_function_map_t;
static rb_gc_function_map_t rb_gc_functions;
@@ -718,6 +718,8 @@ ruby_external_gc_init(void)
char *gc_so_file = getenv(RUBY_GC_LIBRARY);
+ rb_gc_function_map_t gc_functions = { 0 };
+
char *gc_so_path = NULL;
void *handle = NULL;
if (gc_so_file) {
@@ -756,10 +758,9 @@ ruby_external_gc_init(void)
fprintf(stderr, "ruby_external_gc_init: Shared library %s cannot be opened: %s\n", gc_so_path, dlerror());
exit(1);
}
- external_gc_loaded = TRUE;
- }
- rb_gc_function_map_t gc_functions;
+ gc_functions.external_gc_loaded_p = true;
+ }
# define load_external_gc_func(name) do { \
if (handle) { \
@@ -2872,7 +2873,11 @@ rb_gc_copy_attributes(VALUE dest, VALUE obj)
int
rb_gc_external_gc_loaded_p(void)
{
- return external_gc_loaded;
+#if USE_SHARED_GC
+ return rb_gc_functions.external_gc_loaded_p;
+#else
+ return false;
+#endif
}
const char *