summaryrefslogtreecommitdiff
path: root/version.c
diff options
context:
space:
mode:
authorMatt Valentine-House <[email protected]>2024-10-08 21:30:06 +0100
committerMatt Valentine-House <[email protected]>2024-11-14 10:46:36 +0000
commitee290c94a3dd0327f3407edb02272d37470edc95 (patch)
tree941b26392942b9c927876079826f7c4a7ea0e776 /version.c
parentfa10441981c89deec914ba243360b40c5aede6ed (diff)
Include the currently active GC in RUBY_DESCRIPTION
This will add +MOD_GC to the version string and Ruby description when Ruby is compiled with shared gc support. When shared GC support is compiled in and a GC module has been loaded using RUBY_GC_LIBRARY, the version string will include the name of the currently active GC as reported by the rb_gc_active_gc_name function in the form +MOD_GC[gc_name] [Feature #20794]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/11872
Diffstat (limited to 'version.c')
-rw-r--r--version.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/version.c b/version.c
index 416688644a..ddc093ebb0 100644
--- a/version.c
+++ b/version.c
@@ -11,6 +11,7 @@
#include "internal/cmdlineopt.h"
#include "internal/parse.h"
+#include "internal/gc.h"
#include "ruby/ruby.h"
#include "version.h"
#include "vm_core.h"
@@ -61,6 +62,11 @@ const int ruby_api_version[] = {
#else
#define YJIT_DESCRIPTION " +YJIT"
#endif
+#if USE_SHARED_GC
+#define GC_DESCRIPTION " +GC"
+#else
+#define GC_DESCRIPTION ""
+#endif
const char ruby_version[] = RUBY_VERSION;
const char ruby_revision[] = RUBY_FULL_REVISION;
const char ruby_release_date[] = RUBY_RELEASE_DATE;
@@ -167,6 +173,14 @@ define_ruby_description(const char *const jit_opt)
+ rb_strlen_lit(YJIT_DESCRIPTION)
+ rb_strlen_lit(" +MN")
+ rb_strlen_lit(" +PRISM")
+#if USE_SHARED_GC
+ + rb_strlen_lit(GC_DESCRIPTION)
+ // Assume the active GC name can not be longer than 20 chars
+ // so that we don't have to use strlen and remove the static
+ // qualifier from desc.
+ + RB_GC_MAX_NAME_LEN + 3
+#endif
+
];
int n = ruby_description_opt_point;
@@ -176,6 +190,14 @@ define_ruby_description(const char *const jit_opt)
RUBY_ASSERT(n <= ruby_description_opt_point + (int)rb_strlen_lit(YJIT_DESCRIPTION));
if (ruby_mn_threads_enabled) append(" +MN");
if (rb_ruby_prism_p()) append(" +PRISM");
+#if USE_SHARED_GC
+ append(GC_DESCRIPTION);
+ if (rb_gc_external_gc_loaded_p()) {
+ append("[");
+ append(rb_gc_active_gc_name());
+ append("]");
+ }
+#endif
append(ruby_description + ruby_description_opt_point);
# undef append