ruby-changes:50148
From: k0kubun <ko1@a...>
Date: Wed, 7 Feb 2018 01:57:52 +0900 (JST)
Subject: [ruby-changes:50148] k0kubun:r62266 (trunk): mjit.c: make null device portable
k0kubun 2018-02-07 01:57:46 +0900 (Wed, 07 Feb 2018) New Revision: 62266 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=62266 Log: mjit.c: make null device portable for future mswin support Modified files: trunk/mjit.c Index: mjit.c =================================================================== --- mjit.c (revision 62265) +++ mjit.c (revision 62266) @@ -198,6 +198,8 @@ 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; @@ -321,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("/dev/null", "w"); + FILE *f = fopen(null_device, "w"); int dev_null = fileno(f); fclose(f); @@ -1171,6 +1173,10 @@ mjit_init(struct mjit_options *opts) https://github.com/ruby/ruby/blob/trunk/mjit.c#L1173 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"); @@ -1255,6 +1261,7 @@ mjit_finish(void) https://github.com/ruby/ruby/blob/trunk/mjit.c#L1261 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/