1 /**********************************************************************
6 created at: Thu Sep 30 20:08:01 JST 1993
8 Copyright (C) 1993-2007 Yukihiro Matsumoto
10 **********************************************************************/
12 #include "ruby/ruby.h"
20 #define EXIT_SUCCESS 0
23 #define PRINT(type) puts(ruby_##type)
24 #define MKSTR(type) rb_obj_freeze(rb_usascii_str_new_static(ruby_##type, sizeof(ruby_##type)-1))
25 #define MKINT(name) INT2FIX(ruby_##name)
27 const int ruby_api_version
[] = {
28 RUBY_API_VERSION_MAJOR
,
29 RUBY_API_VERSION_MINOR
,
30 RUBY_API_VERSION_TEENY
,
32 #define RUBY_VERSION \
33 STRINGIZE(RUBY_VERSION_MAJOR) "." \
34 STRINGIZE(RUBY_VERSION_MINOR) "." \
35 STRINGIZE(RUBY_VERSION_TEENY) ""
36 #ifndef RUBY_FULL_REVISION
37 # define RUBY_FULL_REVISION RUBY_REVISION
39 const char ruby_version
[] = RUBY_VERSION
;
40 const char ruby_revision
[] = RUBY_FULL_REVISION
;
41 const char ruby_release_date
[] = RUBY_RELEASE_DATE
;
42 const char ruby_platform
[] = RUBY_PLATFORM
;
43 const int ruby_patchlevel
= RUBY_PATCHLEVEL
;
44 const char ruby_description
[] = RUBY_DESCRIPTION_WITH("");
45 static const char ruby_description_with_mjit
[] = RUBY_DESCRIPTION_WITH(" +MJIT");
46 static const char ruby_description_with_yjit
[] = RUBY_DESCRIPTION_WITH(" +YJIT");
47 const char ruby_copyright
[] = RUBY_COPYRIGHT
;
48 const char ruby_engine
[] = "ruby";
50 /*! Defines platform-depended Ruby-level constants */
54 enum {ruby_patchlevel
= RUBY_PATCHLEVEL
};
56 VALUE ruby_engine_name
;
58 * The running version of ruby
60 rb_define_global_const("RUBY_VERSION", (version
= MKSTR(version
)));
62 * The date this ruby was released
64 rb_define_global_const("RUBY_RELEASE_DATE", MKSTR(release_date
));
66 * The platform for this ruby
68 rb_define_global_const("RUBY_PLATFORM", MKSTR(platform
));
70 * The patchlevel for this ruby. If this is a development build of ruby
71 * the patchlevel will be -1
73 rb_define_global_const("RUBY_PATCHLEVEL", MKINT(patchlevel
));
75 * The GIT commit hash for this ruby.
77 rb_define_global_const("RUBY_REVISION", MKSTR(revision
));
79 * The copyright string for ruby
81 rb_define_global_const("RUBY_COPYRIGHT", MKSTR(copyright
));
83 * The engine or interpreter this ruby uses.
85 rb_define_global_const("RUBY_ENGINE", ruby_engine_name
= MKSTR(engine
));
86 ruby_set_script_name(ruby_engine_name
);
88 * The version of the engine or interpreter this ruby uses.
90 rb_define_global_const("RUBY_ENGINE_VERSION", (1 ? version
: MKSTR(version
)));
92 rb_provide("ruby2_keywords.rb");
96 #define MJIT_OPTS_ON mjit_opts.on
98 #define MJIT_OPTS_ON 0
102 Init_ruby_description(void)
107 description
= MKSTR(description_with_mjit
);
109 else if (rb_yjit_enabled_p()) {
110 description
= MKSTR(description_with_yjit
);
113 description
= MKSTR(description
);
117 * The full ruby version string, like <tt>ruby -v</tt> prints
119 rb_define_global_const("RUBY_DESCRIPTION", /* MKSTR(description) */ description
);
123 ruby_show_version(void)
126 PRINT(description_with_mjit
);
128 else if (rb_yjit_enabled_p()) {
129 PRINT(description_with_yjit
);
135 #ifdef RUBY_LAST_COMMIT_TITLE
136 fputs("last_commit=" RUBY_LAST_COMMIT_TITLE
, stdout
);
138 #ifdef HAVE_MALLOC_CONF
139 if (malloc_conf
) printf("malloc_conf=%s\n", malloc_conf
);
145 ruby_show_copyright(void)