summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Wu <XrXr@users.noreply.github.com>2020-11-04 11:24:38 -0500
committerAaron Patterson <aaron.patterson@gmail.com>2020-11-06 09:55:26 -0800
commitf234f2740dc060ab565899f726101ebf79f5c71e (patch)
treebbfdd888bf61560279a8e67df002931de9b7ee89
parent037803e092e3a8deb07ebd44840ef5ce12843985 (diff)
Add docs for some C extension GC APIs
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3733
-rw-r--r--include/ruby/internal/gc.h32
1 files changed, 28 insertions, 4 deletions
diff --git a/include/ruby/internal/gc.h b/include/ruby/internal/gc.h
index 7f335ca8f7..69ff6193d8 100644
--- a/include/ruby/internal/gc.h
+++ b/include/ruby/internal/gc.h
@@ -25,10 +25,34 @@
RBIMPL_SYMBOL_EXPORT_BEGIN()
-void rb_global_variable(VALUE*);
-void rb_gc_register_mark_object(VALUE);
-void rb_gc_register_address(VALUE*);
-void rb_gc_unregister_address(VALUE*);
+/**
+ * Inform the garbage collector that `valptr` points to a live Ruby object that
+ * should not be moved. Note that extensions should use this API on global
+ * constants instead of assuming constants defined in Ruby are always alive.
+ * Ruby code can remove global constants.
+ */
+void rb_gc_register_address(VALUE *valptr);
+
+/**
+ * An alias for `rb_gc_register_address()`.
+ */
+void rb_global_variable(VALUE *);
+
+/**
+ * Inform the garbage collector that a pointer previously passed to
+ * `rb_gc_register_address()` no longer points to a live Ruby object.
+ */
+void rb_gc_unregister_address(VALUE *valptr);
+
+/**
+ * Inform the garbage collector that `object` is a live Ruby object. Note that
+ * the garbage collector is free to move `object` and so it is not correct to
+ * save `object` into a C global constant and assume that it will always refer
+ * to the same Ruby object.
+ *
+ * See also: rb_gc_register_address()
+ */
+void rb_gc_register_mark_object(VALUE object);
RBIMPL_SYMBOL_EXPORT_END()