[前][次][番号順一覧][スレッド一覧]

ruby-changes:50200

From: nobu <ko1@a...>
Date: Fri, 9 Feb 2018 00:09:29 +0900 (JST)
Subject: [ruby-changes:50200] nobu:r62318 (trunk): mjit.c: ruby_version from version.c

nobu	2018-02-09 00:00:28 +0900 (Fri, 09 Feb 2018)

  New Revision: 62318

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=62318

  Log:
    mjit.c: ruby_version from version.c
    
    * mjit.c (init_header_filename): get version name from the
      particular global variable, not from the macro in version.h.
      to get rid of re-compilation for each revision.

  Modified files:
    trunk/common.mk
    trunk/mjit.c
Index: common.mk
===================================================================
--- common.mk	(revision 62317)
+++ common.mk	(revision 62318)
@@ -2030,12 +2030,11 @@ iseq.$(OBJEXT): {$(VPATH)}util.h https://github.com/ruby/ruby/blob/trunk/common.mk#L2030
 iseq.$(OBJEXT): {$(VPATH)}vm_core.h
 iseq.$(OBJEXT): {$(VPATH)}vm_debug.h
 iseq.$(OBJEXT): {$(VPATH)}vm_opts.h
-mjit.$(OBJEXT): $(top_srcdir)/revision.h
+mjit.$(OBJEXT): $(hdrdir)/ruby/version.h
 mjit.$(OBJEXT): {$(VPATH)}mjit.c
 mjit.$(OBJEXT): {$(VPATH)}mjit.h
 mjit.$(OBJEXT): {$(VPATH)}ruby_assert.h
 mjit.$(OBJEXT): {$(VPATH)}util.h
-mjit.$(OBJEXT): {$(VPATH)}version.h
 mjit.$(OBJEXT): {$(VPATH)}vm_core.h
 mjit_compile.$(OBJEXT): {$(VPATH)}insns.inc
 mjit_compile.$(OBJEXT): {$(VPATH)}insns_info.inc
Index: mjit.c
===================================================================
--- mjit.c	(revision 62317)
+++ mjit.c	(revision 62318)
@@ -76,12 +76,12 @@ https://github.com/ruby/ruby/blob/trunk/mjit.c#L76
 #include "internal.h"
 #include "vm_core.h"
 #include "mjit.h"
-#include "version.h"
 #include "gc.h"
 #include "constant.h"
 #include "id_table.h"
 #include "ruby_assert.h"
 #include "ruby/util.h"
+#include "ruby/version.h"
 
 #ifdef _WIN32
 #include <winsock2.h>
@@ -1113,7 +1113,7 @@ mjit_get_iseq_func(const struct rb_iseq_ https://github.com/ruby/ruby/blob/trunk/mjit.c#L1113
 }
 
 /* A name of the header file included in any C file generated by MJIT for iseqs.  */
-#define RUBY_MJIT_HEADER_FILE "rb_mjit_min_header-" RUBY_VERSION ".h"
+#define RUBY_MJIT_HEADER_NAME "rb_mjit_min_header-"
 /* GCC and CLANG executable paths.  TODO: The paths should absolute
    ones to prevent changing C compiler for security reasons.  */
 #define GCC_PATH "gcc"
@@ -1130,8 +1130,9 @@ init_header_filename(void) https://github.com/ruby/ruby/blob/trunk/mjit.c#L1130
     VALUE basedir_val;
     char *basedir;
     size_t baselen;
+    size_t verlen;
     static const char header_name[] =
-        "/" MJIT_HEADER_INSTALL_DIR "/" RUBY_MJIT_HEADER_FILE;
+        "/" MJIT_HEADER_INSTALL_DIR "/" RUBY_MJIT_HEADER_NAME;
     char *p;
 #ifdef _WIN32
     static const char libpathflag[] =
@@ -1146,12 +1147,15 @@ init_header_filename(void) https://github.com/ruby/ruby/blob/trunk/mjit.c#L1147
     basedir_val = rb_const_get(rb_cObject, rb_intern_const("TMP_RUBY_PREFIX"));
     basedir = StringValuePtr(basedir_val);
     baselen = RSTRING_LEN(basedir_val);
+    verlen = strlen(ruby_version);
 
-    header_file = xmalloc(baselen + sizeof(header_name));
+    header_file = xmalloc(baselen + sizeof(header_name) + verlen + 2);
     if (header_file == NULL)
         return;
     p = append_str2(header_file, basedir, baselen);
-    p = append_str2(p, header_name, sizeof(header_name));
+    p = append_str2(p, header_name, sizeof(header_name)-1);
+    p = append_str2(p, ruby_version, verlen);
+    p = append_str2(p, ".h", 3);
     if ((fd = rb_cloexec_open(header_file, O_RDONLY, 0)) < 0) {
         xfree(header_file);
         header_file = NULL;

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]