Ruby 2.7.7p221 (2022-11-24 revision 168ec2b1e5ad0e4688e963d9de019557c78feed9)
version.c
Go to the documentation of this file.
1/**********************************************************************
2
3 version.c -
4
5 $Author$
6 created at: Thu Sep 30 20:08:01 JST 1993
7
8 Copyright (C) 1993-2007 Yukihiro Matsumoto
9
10**********************************************************************/
11
12#include "ruby/ruby.h"
13#include "version.h"
14#include "vm_core.h"
15#include "mjit.h"
16#include <stdio.h>
17
18#ifndef EXIT_SUCCESS
19#define EXIT_SUCCESS 0
20#endif
21
22#define PRINT(type) puts(ruby_##type)
23#define MKSTR(type) rb_obj_freeze(rb_usascii_str_new_static(ruby_##type, sizeof(ruby_##type)-1))
24#define MKINT(name) INT2FIX(ruby_##name)
25
26const int ruby_api_version[] = {
30};
31#define RUBY_VERSION \
32 STRINGIZE(RUBY_VERSION_MAJOR) "." \
33 STRINGIZE(RUBY_VERSION_MINOR) "." \
34 STRINGIZE(RUBY_VERSION_TEENY) ""
35#ifndef RUBY_FULL_REVISION
36# define RUBY_FULL_REVISION RUBY_REVISION
37#endif
44static const char ruby_description_with_jit[] = RUBY_DESCRIPTION_WITH(" +JIT");
46const char ruby_engine[] = "ruby";
47
49void
51{
53 VALUE version;
54 VALUE ruby_engine_name;
55 /*
56 * The running version of ruby
57 */
58 rb_define_global_const("RUBY_VERSION", (version = MKSTR(version)));
59 /*
60 * The date this ruby was released
61 */
62 rb_define_global_const("RUBY_RELEASE_DATE", MKSTR(release_date));
63 /*
64 * The platform for this ruby
65 */
66 rb_define_global_const("RUBY_PLATFORM", MKSTR(platform));
67 /*
68 * The patchlevel for this ruby. If this is a development build of ruby
69 * the patchlevel will be -1
70 */
71 rb_define_global_const("RUBY_PATCHLEVEL", MKINT(patchlevel));
72 /*
73 * The GIT commit hash for this ruby.
74 */
75 rb_define_global_const("RUBY_REVISION", MKSTR(revision));
76 /*
77 * The copyright string for ruby
78 */
79 rb_define_global_const("RUBY_COPYRIGHT", MKSTR(copyright));
80 /*
81 * The engine or interpreter this ruby uses.
82 */
83 rb_define_global_const("RUBY_ENGINE", ruby_engine_name = MKSTR(engine));
84 ruby_set_script_name(ruby_engine_name);
85 /*
86 * The version of the engine or interpreter this ruby uses.
87 */
88 rb_define_global_const("RUBY_ENGINE_VERSION", (1 ? version : MKSTR(version)));
89
90 rb_provide("ruby2_keywords.rb");
91}
92
93#if USE_MJIT
94#define MJIT_OPTS_ON mjit_opts.on
95#else
96#define MJIT_OPTS_ON 0
97#endif
98
99void
101{
102 VALUE description;
103
104 if (MJIT_OPTS_ON) {
105 description = MKSTR(description_with_jit);
106 }
107 else {
108 description = MKSTR(description);
109 }
110
111 /*
112 * The full ruby version string, like <tt>ruby -v</tt> prints
113 */
114 rb_define_global_const("RUBY_DESCRIPTION", /* MKSTR(description) */ description);
115}
116
118void
120{
121 if (MJIT_OPTS_ON) {
122 PRINT(description_with_jit);
123 }
124 else {
125 PRINT(description);
126 }
127#ifdef RUBY_LAST_COMMIT_TITLE
128 fputs("last_commit=" RUBY_LAST_COMMIT_TITLE, stdout);
129#endif
130#ifdef HAVE_MALLOC_CONF
131 if (malloc_conf) printf("malloc_conf=%s\n", malloc_conf);
132#endif
133 fflush(stdout);
134}
135
137void
139{
140 PRINT(copyright);
141 fflush(stdout);
142}
const char ruby_description[]
Definition: version.c:43
void ruby_show_copyright(void)
Prints the copyright notice of the CRuby interpreter to stdout.
Definition: version.c:138
void ruby_show_version(void)
Prints the version information of the CRuby interpreter to stdout.
Definition: version.c:119
#define RUBY_API_VERSION_TEENY
Definition: version.h:35
#define RUBY_API_VERSION_MAJOR
Definition: version.h:33
#define RUBY_API_VERSION_MINOR
Definition: version.h:34
void rb_provide(const char *)
Definition: load.c:607
#define stdout
int int int printf(const char *__restrict__,...) __attribute__((__format__(__printf__
void rb_define_global_const(const char *, VALUE)
Definition: variable.c:2903
unsigned long VALUE
#define RUBY_PLATFORM
void ruby_set_script_name(VALUE name)
Sets the current script name to this value.
Definition: ruby.c:2315
int fputs(const char *__restrict__, FILE *__restrict__)
int fflush(FILE *)
const char ruby_engine[]
Definition: version.c:46
const int ruby_api_version[]
Definition: version.c:26
const char ruby_platform[]
Definition: version.c:41
const char ruby_version[]
Definition: version.c:38
void Init_version(void)
Defines platform-depended Ruby-level constants.
Definition: version.c:50
#define RUBY_FULL_REVISION
Definition: version.c:36
#define MJIT_OPTS_ON
Definition: version.c:96
void Init_ruby_description(void)
Definition: version.c:100
#define PRINT(type)
Definition: version.c:22
const char ruby_revision[]
Definition: version.c:39
#define RUBY_VERSION
Definition: version.c:31
#define MKSTR(type)
Definition: version.c:23
#define MKINT(name)
Definition: version.c:24
const char ruby_copyright[]
Definition: version.c:45
const char ruby_release_date[]
Definition: version.c:40
const int ruby_patchlevel
Definition: version.c:42
#define RUBY_PATCHLEVEL
Definition: version.h:5
#define RUBY_DESCRIPTION_WITH(opt)
Definition: version.h:67
#define RUBY_COPYRIGHT
Definition: version.h:73
#define RUBY_RELEASE_DATE
Definition: version.h:4