summaryrefslogtreecommitdiff
path: root/mjit_worker.c
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2020-05-01 01:56:04 -0700
committerTakashi Kokubun <takashikkbn@gmail.com>2020-05-01 01:58:19 -0700
commit72aa4dd183921aaf7405d8611af4ca5613bfaf4d (patch)
tree8c396e1bb1ca23d09c04bef5ece023c14022f81b /mjit_worker.c
parent818d6d33368a396d9cd3d1a34a84015a9e76c5c8 (diff)
c_file_access_mode should be defined for Windows
as well. And also unit->c_file doesn't exist in mswin. https://github.com/ruby/ruby/runs/635915704
Diffstat (limited to 'mjit_worker.c')
-rw-r--r--mjit_worker.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/mjit_worker.c b/mjit_worker.c
index b64c769..5a108c7 100644
--- a/mjit_worker.c
+++ b/mjit_worker.c
@@ -725,6 +725,12 @@ sprint_funcname(char *funcname, const struct rb_mjit_unit *unit)
}
}
+static const int c_file_access_mode =
+#ifdef O_BINARY
+ O_BINARY|
+#endif
+ O_WRONLY|O_EXCL|O_CREAT;
+
#define append_str2(p, str, len) ((char *)memcpy((p), str, (len))+(len))
#define append_str(p, str) append_str2(p, str, sizeof(str)-1)
#define append_lit(p, str) append_str2(p, str, rb_strlen_lit(str))
@@ -874,12 +880,6 @@ compile_c_to_so(const char *c_file, const char *so_file)
static void compile_prelude(FILE *f);
-static const int c_file_access_mode =
-#ifdef O_BINARY
- O_BINARY|
-#endif
- O_WRONLY|O_EXCL|O_CREAT;
-
static bool
compile_compact_jit_code(char* c_file)
{
@@ -1145,7 +1145,10 @@ convert_unit_to_func(struct rb_mjit_unit *unit)
start_time = real_ms_time();
success = compile_c_to_so(c_file, so_file);
-#ifndef _MSC_VER
+#ifdef _MSC_VER
+ if (!mjit_opts.save_temps)
+ remove_file(c_file);
+#else
if (success) {
// Always set c_file for compaction. The value is also used for lazy deletion.
unit->c_file = strdup(c_file);
@@ -1153,9 +1156,9 @@ convert_unit_to_func(struct rb_mjit_unit *unit)
mjit_warning("failed to allocate memory to remember '%s' (%s), removing it...", c_file, strerror(errno));
}
}
-#endif
if (!mjit_opts.save_temps && unit->c_file == NULL)
remove_file(c_file);
+#endif
end_time = real_ms_time();
if (!success) {