Skip to content

Commit 1906db9

Browse files
committed
Implement version string for ZJIT
1 parent 6bc9e8e commit 1906db9

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

version.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,16 @@ const int ruby_api_version[] = {
6161
#else
6262
#define YJIT_DESCRIPTION " +YJIT"
6363
#endif
64+
#ifdef ZJIT_SUPPORT
65+
#define ZJIT_DESCRIPTION " +ZJIT " STRINGIZE(ZJIT_SUPPORT)
66+
#else
67+
#define ZJIT_DESCRIPTION " +ZJIT"
68+
#endif
69+
#if USE_ZJIT
70+
#define JIT_DESCRIPTION ZJIT_DESCRIPTION
71+
#else
72+
#define JIT_DESCRIPTION YJIT_DESCRIPTION
73+
#endif
6474
#if USE_MODULAR_GC
6575
#define GC_DESCRIPTION " +GC"
6676
#else
@@ -162,6 +172,12 @@ Init_version(void)
162172
#define YJIT_OPTS_ON 0
163173
#endif
164174

175+
#if USE_ZJIT
176+
#define ZJIT_OPTS_ON opt->zjit
177+
#else
178+
#define ZJIT_OPTS_ON 0
179+
#endif
180+
165181
int ruby_mn_threads_enabled;
166182

167183
#ifndef RB_DEFAULT_PARSER
@@ -186,7 +202,7 @@ define_ruby_description(const char *const jit_opt)
186202
{
187203
static char desc[
188204
sizeof(ruby_description)
189-
+ rb_strlen_lit(YJIT_DESCRIPTION)
205+
+ rb_strlen_lit(JIT_DESCRIPTION)
190206
+ rb_strlen_lit(" +MN")
191207
+ rb_strlen_lit(" +PRISM")
192208
#if USE_MODULAR_GC
@@ -203,7 +219,7 @@ define_ruby_description(const char *const jit_opt)
203219
memcpy(desc, ruby_description, n);
204220
# define append(s) (n += (int)strlcpy(desc + n, s, sizeof(desc) - n))
205221
if (*jit_opt) append(jit_opt);
206-
RUBY_ASSERT(n <= ruby_description_opt_point + (int)rb_strlen_lit(YJIT_DESCRIPTION));
222+
RUBY_ASSERT(n <= ruby_description_opt_point + (int)rb_strlen_lit(JIT_DESCRIPTION));
207223
if (ruby_mn_threads_enabled) append(" +MN");
208224
if (rb_ruby_prism_p()) append(" +PRISM");
209225
#if USE_MODULAR_GC
@@ -232,6 +248,7 @@ Init_ruby_description(ruby_cmdline_options_t *opt)
232248
{
233249
const char *const jit_opt =
234250
YJIT_OPTS_ON ? YJIT_DESCRIPTION :
251+
ZJIT_OPTS_ON ? ZJIT_DESCRIPTION :
235252
"";
236253
define_ruby_description(jit_opt);
237254
}

0 commit comments

Comments
 (0)