summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authork0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-08-05 04:48:18 +0000
committerk0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-08-05 04:48:18 +0000
commitd3e90363d36ec74ff97d2b17abbe1bf626c8deaf (patch)
treec65c5dcb05444f9c247bf8598a7d8718a2f8014d
parentd7786b1e7814a776b7c0307e64fbbf13324131a9 (diff)
mjit.c: reorder functions to reduce #ifdef branches
Just moved make_pch into `#else` of `#ifdef _MSC_VER`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64191 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--mjit.c90
1 files changed, 43 insertions, 47 deletions
diff --git a/mjit.c b/mjit.c
index 3f9a7c4..31d83d0 100644
--- a/mjit.c
+++ b/mjit.c
@@ -720,7 +720,49 @@ static const char *const CC_LIBS[] = {
shared by the workers and the pch thread. */
static enum {PCH_NOT_READY, PCH_FAILED, PCH_SUCCESS} pch_status;
-#ifndef _MSC_VER
+#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))
+
+#define MJIT_TMP_PREFIX "_ruby_mjit_"
+
+#ifdef _MSC_VER
+/* Compile C file to so. It returns 1 if it succeeds. (mswin) */
+static int
+compile_c_to_so(const char *c_file, const char *so_file)
+{
+ int exit_code;
+ const char *files[] = { NULL, NULL, NULL, "-link", libruby_pathflag, NULL };
+ char **args;
+ char *p;
+
+ /* files[0] = "-Fe*.dll" */
+ files[0] = p = (char *)alloca(sizeof(char) * (rb_strlen_lit("-Fe") + strlen(so_file) + 1));
+ p = append_lit(p, "-Fe");
+ p = append_str2(p, so_file, strlen(so_file));
+ *p = '\0';
+
+ /* files[1] = "-Yu*.pch" */
+ files[1] = p = (char *)alloca(sizeof(char) * (rb_strlen_lit("-Yu") + strlen(pch_file) + 1));
+ p = append_lit(p, "-Yu");
+ p = append_str2(p, pch_file, strlen(pch_file));
+ *p = '\0';
+
+ files[2] = c_file;
+ args = form_args(5, CC_LDSHARED_ARGS, CC_CODEFLAG_ARGS,
+ files, CC_LIBS, CC_DLDFLAGS_ARGS);
+ if (args == NULL)
+ return FALSE;
+
+ exit_code = exec_process(cc_path, args);
+ free(args);
+
+ if (exit_code != 0)
+ verbose(2, "compile_c_to_so: compile error: %d", exit_code);
+ return exit_code == 0;
+}
+#else /* _MSC_VER */
+
/* The function producing the pre-compiled header. */
static void
make_pch(void)
@@ -764,52 +806,6 @@ make_pch(void)
rb_native_cond_broadcast(&mjit_pch_wakeup);
CRITICAL_SECTION_FINISH(3, "in make_pch");
}
-#endif /* _MSC_VER */
-
-#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))
-
-#define MJIT_TMP_PREFIX "_ruby_mjit_"
-
-#ifdef _MSC_VER
-
-/* Compile C file to so. It returns 1 if it succeeds. (mswin) */
-static int
-compile_c_to_so(const char *c_file, const char *so_file)
-{
- int exit_code;
- const char *files[] = { NULL, NULL, NULL, "-link", libruby_pathflag, NULL };
- char **args;
- char *p;
-
- /* files[0] = "-Fe*.dll" */
- files[0] = p = (char *)alloca(sizeof(char) * (rb_strlen_lit("-Fe") + strlen(so_file) + 1));
- p = append_lit(p, "-Fe");
- p = append_str2(p, so_file, strlen(so_file));
- *p = '\0';
-
- /* files[1] = "-Yu*.pch" */
- files[1] = p = (char *)alloca(sizeof(char) * (rb_strlen_lit("-Yu") + strlen(pch_file) + 1));
- p = append_lit(p, "-Yu");
- p = append_str2(p, pch_file, strlen(pch_file));
- *p = '\0';
-
- files[2] = c_file;
- args = form_args(5, CC_LDSHARED_ARGS, CC_CODEFLAG_ARGS,
- files, CC_LIBS, CC_DLDFLAGS_ARGS);
- if (args == NULL)
- return FALSE;
-
- exit_code = exec_process(cc_path, args);
- free(args);
-
- if (exit_code != 0)
- verbose(2, "compile_c_to_so: compile error: %d", exit_code);
- return exit_code == 0;
-}
-
-#else /* _MSC_VER */
/* Compile .c file to .o file. It returns 1 if it succeeds. (non-mswin) */
static int