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

ruby-changes:50150

From: nobu <ko1@a...>
Date: Wed, 7 Feb 2018 08:40:25 +0900 (JST)
Subject: [ruby-changes:50150] nobu:r62268 (trunk): share ruby_null_device

nobu	2018-02-07 08:40:19 +0900 (Wed, 07 Feb 2018)

  New Revision: 62268

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

  Log:
    share ruby_null_device

  Modified files:
    trunk/file.c
    trunk/mjit.c
Index: file.c
===================================================================
--- file.c	(revision 62267)
+++ file.c	(revision 62268)
@@ -6126,7 +6126,7 @@ define_filetest_function(const char *nam https://github.com/ruby/ruby/blob/trunk/file.c#L6126
     rb_define_singleton_method(rb_cFile, name, func, argc);
 }
 
-static const char null_device[] =
+const char ruby_null_device[] =
 #if defined DOSISH
     "NUL"
 #elif defined AMIGA || defined __amigaos__
@@ -6368,7 +6368,7 @@ Init_File(void) https://github.com/ruby/ruby/blob/trunk/file.c#L6368
     rb_define_const(rb_mFConst, "LOCK_NB", INT2FIX(LOCK_NB));
 
     /* Name of the null device */
-    rb_define_const(rb_mFConst, "NULL", rb_fstring_cstr(null_device));
+    rb_define_const(rb_mFConst, "NULL", rb_fstring_cstr(ruby_null_device));
 
     rb_define_method(rb_cFile, "path",  rb_file_path, 0);
     rb_define_method(rb_cFile, "to_path",  rb_file_path, 0);
Index: mjit.c
===================================================================
--- mjit.c	(revision 62267)
+++ mjit.c	(revision 62268)
@@ -198,13 +198,13 @@ static char *header_file; https://github.com/ruby/ruby/blob/trunk/mjit.c#L198
 static char *pch_file;
 /* Path of "/tmp", which can be changed to $TMP in MinGW. */
 static char *tmp_dir;
-/* Portable /dev/null, fetched from file.c */
-static char *null_device;
 /* Hash like { 1 => true, 2 => true, ... } whose keys are valid `class_serial`s.
    This is used to invalidate obsoleted CALL_CACHE. */
 static VALUE valid_class_serials;
 /* Ruby level interface module.  */
 VALUE rb_mMJIT;
+/* Portable /dev/null, defined in file.c */
+extern const char *ruby_null_device;
 
 #ifdef _WIN32
 /* Linker option to enable libruby in the build directory. */
@@ -323,7 +323,7 @@ start_process(const char *path, char *co https://github.com/ruby/ruby/blob/trunk/mjit.c#L323
 #else
     {
         /* Not calling IO functions between fork and exec for safety */
-        FILE *f = fopen(null_device, "w");
+        FILE *f = fopen(ruby_null_device, "w");
         int dev_null = fileno(f);
         fclose(f);
 
@@ -1228,10 +1228,6 @@ mjit_init(struct mjit_options *opts) https://github.com/ruby/ruby/blob/trunk/mjit.c#L1228
     else {
         tmp_dir = get_string("/tmp");
     }
-    {
-        VALUE file_null = rb_const_get(rb_cFile, rb_intern("NULL"));
-        null_device = get_string(StringValuePtr(file_null));
-    }
 
     init_header_filename();
     pch_file = get_uniq_filename(0, MJIT_TMP_PREFIX "h", ".h.gch");
@@ -1316,7 +1312,6 @@ mjit_finish(void) https://github.com/ruby/ruby/blob/trunk/mjit.c#L1312
         remove(pch_file);
 
     xfree(tmp_dir); tmp_dir = NULL;
-    xfree(null_device); null_device = NULL;
     xfree(pch_file); pch_file = NULL;
     xfree(header_file); header_file = NULL;
 

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

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