12 #include "internal/cmdlineopt.h"
13 #include "internal/parse.h"
22 #define EXIT_SUCCESS 0
26 # if RUBY_PATCHLEVEL == -1
27 # ifndef RUBY_BRANCH_NAME
28 # define RUBY_BRANCH_NAME "master"
30 # define RUBY_REVISION_STR " "RUBY_BRANCH_NAME" "RUBY_REVISION
32 # define RUBY_REVISION_STR " revision "RUBY_REVISION
35 # define RUBY_REVISION "HEAD"
36 # define RUBY_REVISION_STR ""
38 #if !defined RUBY_RELEASE_DATETIME || RUBY_PATCHLEVEL != -1
39 # undef RUBY_RELEASE_DATETIME
40 # define RUBY_RELEASE_DATETIME RUBY_RELEASE_DATE
43 #define PRINT(type) puts(ruby_##type)
44 #define MKSTR(type) rb_obj_freeze(rb_usascii_str_new_static(ruby_##type, sizeof(ruby_##type)-1))
45 #define MKINT(name) INT2FIX(ruby_##name)
52 #define RUBY_VERSION \
53 STRINGIZE(RUBY_VERSION_MAJOR) "." \
54 STRINGIZE(RUBY_VERSION_MINOR) "." \
55 STRINGIZE(RUBY_VERSION_TEENY) ""
56 #ifndef RUBY_FULL_REVISION
57 # define RUBY_FULL_REVISION RUBY_REVISION
60 #define YJIT_DESCRIPTION " +YJIT " STRINGIZE(YJIT_SUPPORT)
62 #define YJIT_DESCRIPTION " +YJIT"
65 const char ruby_revision[] = RUBY_FULL_REVISION;
70 "ruby " RUBY_VERSION RUBY_PATCHLEVEL_STR
" "
71 "(" RUBY_RELEASE_DATETIME RUBY_REVISION_STR
") "
72 "[" RUBY_PLATFORM
"]";
73 static const int ruby_description_opt_point =
77 RUBY_BIRTH_YEAR_STR
"-" RUBY_RELEASE_YEAR_STR
" "
89 VALUE version = MKSTR(version);
90 VALUE ruby_engine_name = MKSTR(engine);
132 #define RJIT_OPTS_ON opt->rjit.on
134 #define RJIT_OPTS_ON 0
138 #define YJIT_OPTS_ON opt->yjit
140 #define YJIT_OPTS_ON 0
143 int ruby_mn_threads_enabled;
145 #ifndef RB_DEFAULT_PARSER
146 #define RB_DEFAULT_PARSER RB_DEFAULT_PARSER_PRISM
148 static ruby_default_parser_enum default_parser = RB_DEFAULT_PARSER;
150 ruby_default_parser_enum
151 rb_ruby_default_parser(
void)
153 return default_parser;
157 rb_ruby_default_parser_set(ruby_default_parser_enum parser)
159 default_parser = parser;
163 define_ruby_description(
const char *
const jit_opt)
172 int n = ruby_description_opt_point;
174 # define append(s) (n += (int)strlcpy(desc + n, s, sizeof(desc) - n))
175 if (*jit_opt) append(jit_opt);
177 if (ruby_mn_threads_enabled) append(
" +MN");
178 if (rb_ruby_prism_p()) append(
" +PRISM");
183 rb_dynamic_description = desc;
194 const char *
const jit_opt =
195 RJIT_OPTS_ON ?
" +RJIT" :
196 YJIT_OPTS_ON ? YJIT_DESCRIPTION :
198 define_ruby_description(jit_opt);
202 ruby_set_yjit_description(
void)
205 define_ruby_description(YJIT_DESCRIPTION);
211 puts(rb_dynamic_description);
213 #ifdef RUBY_LAST_COMMIT_TITLE
214 fputs(
"last_commit=" RUBY_LAST_COMMIT_TITLE, stdout);
216 #ifdef HAVE_MALLOC_CONF
217 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.