[ruby/win32ole] Undefine allocator of WIN32OLE_VARIABLE to get rid of warning
[ruby-80x24.org.git] / version.c
blob7d4478eeb6c77e89fcbf5f593c77f563e04b5b38
1 /**********************************************************************
3 version.c -
5 $Author$
6 created at: Thu Sep 30 20:08:01 JST 1993
8 Copyright (C) 1993-2007 Yukihiro Matsumoto
10 **********************************************************************/
12 #include "ruby/ruby.h"
13 #include "version.h"
14 #include "vm_core.h"
15 #include "mjit.h"
16 #include "yjit.h"
17 #include <stdio.h>
19 #ifndef EXIT_SUCCESS
20 #define EXIT_SUCCESS 0
21 #endif
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
38 #endif
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 */
51 void
52 Init_version(void)
54 enum {ruby_patchlevel = RUBY_PATCHLEVEL};
55 VALUE version;
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");
95 #if USE_MJIT
96 #define MJIT_OPTS_ON mjit_opts.on
97 #else
98 #define MJIT_OPTS_ON 0
99 #endif
101 void
102 Init_ruby_description(void)
104 VALUE description;
106 if (MJIT_OPTS_ON) {
107 description = MKSTR(description_with_mjit);
109 else if (rb_yjit_enabled_p()) {
110 description = MKSTR(description_with_yjit);
112 else {
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);
122 void
123 ruby_show_version(void)
125 if (MJIT_OPTS_ON) {
126 PRINT(description_with_mjit);
128 else if (rb_yjit_enabled_p()) {
129 PRINT(description_with_yjit);
131 else {
132 PRINT(description);
135 #ifdef RUBY_LAST_COMMIT_TITLE
136 fputs("last_commit=" RUBY_LAST_COMMIT_TITLE, stdout);
137 #endif
138 #ifdef HAVE_MALLOC_CONF
139 if (malloc_conf) printf("malloc_conf=%s\n", malloc_conf);
140 #endif
141 fflush(stdout);
144 void
145 ruby_show_copyright(void)
147 PRINT(copyright);
148 fflush(stdout);