12 #include "internal/cmdlineopt.h"
13 #include "internal/parse.h"
14 #include "internal/gc.h"
23 #define EXIT_SUCCESS 0
27 # if RUBY_PATCHLEVEL == -1
28 # ifndef RUBY_BRANCH_NAME
29 # define RUBY_BRANCH_NAME "master"
31 # define RUBY_REVISION_STR " "RUBY_BRANCH_NAME" "RUBY_REVISION
33 # define RUBY_REVISION_STR " revision "RUBY_REVISION
36 # define RUBY_REVISION "HEAD"
37 # define RUBY_REVISION_STR ""
39 #if !defined RUBY_RELEASE_DATETIME || RUBY_PATCHLEVEL != -1
40 # undef RUBY_RELEASE_DATETIME
41 # define RUBY_RELEASE_DATETIME RUBY_RELEASE_DATE
44 #define PRINT(type) puts(ruby_##type)
45 #define MKSTR(type) rb_obj_freeze(rb_usascii_str_new_static(ruby_##type, sizeof(ruby_##type)-1))
46 #define MKINT(name) INT2FIX(ruby_##name)
53 #define RUBY_VERSION \
54 STRINGIZE(RUBY_VERSION_MAJOR) "." \
55 STRINGIZE(RUBY_VERSION_MINOR) "." \
56 STRINGIZE(RUBY_VERSION_TEENY) ""
57 #ifndef RUBY_FULL_REVISION
58 # define RUBY_FULL_REVISION RUBY_REVISION
61 #define YJIT_DESCRIPTION " +YJIT " STRINGIZE(YJIT_SUPPORT)
63 #define YJIT_DESCRIPTION " +YJIT"
66 #define GC_DESCRIPTION " +GC"
68 #define GC_DESCRIPTION ""
71 const char ruby_revision[] = RUBY_FULL_REVISION;
76 "ruby " RUBY_VERSION RUBY_PATCHLEVEL_STR
" "
77 "(" RUBY_RELEASE_DATETIME RUBY_REVISION_STR
") "
78 "[" RUBY_PLATFORM
"]";
79 static const int ruby_description_opt_point =
83 RUBY_BIRTH_YEAR_STR
"-" RUBY_RELEASE_YEAR_STR
" "
95 VALUE version = MKSTR(version);
96 VALUE ruby_engine_name = MKSTR(engine);
138 #define RJIT_OPTS_ON opt->rjit.on
140 #define RJIT_OPTS_ON 0
144 #define YJIT_OPTS_ON opt->yjit
146 #define YJIT_OPTS_ON 0
149 int ruby_mn_threads_enabled;
151 #ifndef RB_DEFAULT_PARSER
152 #define RB_DEFAULT_PARSER RB_DEFAULT_PARSER_PRISM
154 static ruby_default_parser_enum default_parser = RB_DEFAULT_PARSER;
156 ruby_default_parser_enum
157 rb_ruby_default_parser(
void)
159 return default_parser;
163 rb_ruby_default_parser_set(ruby_default_parser_enum parser)
165 default_parser = parser;
169 define_ruby_description(
const char *
const jit_opt)
181 + RB_GC_MAX_NAME_LEN + 3
186 int n = ruby_description_opt_point;
188 # define append(s) (n += (int)strlcpy(desc + n, s, sizeof(desc) - n))
189 if (*jit_opt) append(jit_opt);
191 if (ruby_mn_threads_enabled) append(
" +MN");
192 if (rb_ruby_prism_p()) append(
" +PRISM");
194 append(GC_DESCRIPTION);
195 if (rb_gc_modular_gc_loaded_p()) {
197 append(rb_gc_active_gc_name());
205 rb_dynamic_description = desc;
216 const char *
const jit_opt =
217 RJIT_OPTS_ON ?
" +RJIT" :
218 YJIT_OPTS_ON ? YJIT_DESCRIPTION :
220 define_ruby_description(jit_opt);
224 ruby_set_yjit_description(
void)
227 define_ruby_description(YJIT_DESCRIPTION);
233 puts(rb_dynamic_description);
235 #ifdef RUBY_LAST_COMMIT_TITLE
236 fputs(
"last_commit=" RUBY_LAST_COMMIT_TITLE, stdout);
238 #ifdef HAVE_MALLOC_CONF
239 if (malloc_conf) printf(
"malloc_conf=%s\n", malloc_conf);
#define RUBY_ASSERT(...)
Asserts that the given expression is truthy if and only if RUBY_DEBUG is truthy.
void ruby_set_script_name(VALUE name)
Identical to ruby_script(), except it takes the name as a Ruby String instance.
VALUE rb_obj_freeze(VALUE obj)
Just calls rb_obj_freeze_inline() inside.
void ruby_show_copyright(void)
Prints the copyright notice of the CRuby interpreter to stdout.
void ruby_show_version(void)
Prints the version information of the CRuby interpreter to stdout.
void rb_provide(const char *feature)
Declares that the given feature is already provided by someone else.
#define rb_strlen_lit(str)
Length of a string literal.
VALUE rb_usascii_str_new_static(const char *ptr, long len)
Identical to rb_str_new_static(), except it generates a string of "US ASCII" encoding instead of "bin...
VALUE rb_const_remove(VALUE space, ID name)
Identical to rb_mod_remove_const(), except it takes the name as ID instead of VALUE.
ID rb_intern(const char *name)
Finds or creates a symbol of the given name.
void rb_define_global_const(const char *name, VALUE val)
Identical to rb_define_const(), except it defines that of "global", i.e.
const int ruby_api_version[3]
API versions, in { major, minor, teeny } order.
const char ruby_engine[]
This is just "ruby" for us.
#define RUBY_API_VERSION_TEENY
Teeny version.
const char ruby_platform[]
Target platform identifier, in a C string.
const char ruby_version[]
Stringised version.
#define RUBY_API_VERSION_MAJOR
Major version.
#define RUBY_API_VERSION_MINOR
Minor version.
#define RUBY_AUTHOR
Author of this project.
const char ruby_copyright[]
Copyright notice.
const char ruby_release_date[]
Date of release, in a C string.
const int ruby_patchlevel
This is a monotonic increasing integer that describes specific "patch" level.
const char ruby_description[]
This is what ruby -v prints to the standard error.
uintptr_t VALUE
Type that represents a Ruby object.