summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuta Saito <kateinoigakukun@gmail.com>2021-10-28 15:51:40 +0900
committerYusuke Endoh <mame@ruby-lang.org>2021-10-30 10:18:33 +0900
commit8590d61ea9b6b91c89a14a8d0f6829c8a3a8c6c8 (patch)
tree52b07a13002406e41bc9f22c11614387650b952d
parentccda26efe7c6acf7edd1262dd2826b8c7008ff75 (diff)
Select including thread impl file at config time
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/5043
-rw-r--r--thread.c6
-rw-r--r--tool/m4/ruby_thread.m49
-rw-r--r--vm_core.h6
-rw-r--r--win32/Makefile.sub4
4 files changed, 16 insertions, 9 deletions
diff --git a/thread.c b/thread.c
index 1209de948a..0e3b53ae0b 100644
--- a/thread.c
+++ b/thread.c
@@ -349,8 +349,9 @@ ubf_sigwait(void *ignore)
rb_thread_wakeup_timer_thread(0);
}
+#include THREAD_IMPL_SRC
+
#if defined(_WIN32)
-#include "thread_win32.c"
#define DEBUG_OUT() \
WaitForSingleObject(&debug_mutex, INFINITE); \
@@ -359,7 +360,6 @@ ubf_sigwait(void *ignore)
ReleaseMutex(&debug_mutex);
#elif defined(HAVE_PTHREAD_H)
-#include "thread_pthread.c"
#define DEBUG_OUT() \
pthread_mutex_lock(&debug_mutex); \
@@ -368,8 +368,6 @@ ubf_sigwait(void *ignore)
fflush(stdout); \
pthread_mutex_unlock(&debug_mutex);
-#else
-#error "unsupported thread type"
#endif
/*
diff --git a/tool/m4/ruby_thread.m4 b/tool/m4/ruby_thread.m4
index 92d80421f1..6f1e3960b1 100644
--- a/tool/m4/ruby_thread.m4
+++ b/tool/m4/ruby_thread.m4
@@ -16,4 +16,13 @@ AS_CASE(["$THREAD_MODEL"],
[win32], [],
[""], [AC_MSG_ERROR(thread model is missing)],
[AC_MSG_ERROR(unknown thread model $THREAD_MODEL)])
+
+THREAD_IMPL_H=thread_$THREAD_MODEL.h
+AS_IF([test ! -f "$srcdir/$THREAD_IMPL_H"],
+ [AC_MSG_ERROR('$srcdir/$THREAD_IMPL_H' must exist)])
+THREAD_IMPL_SRC=thread_$THREAD_MODEL.c
+AS_IF([test ! -f "$srcdir/$THREAD_IMPL_SRC"],
+ [AC_MSG_ERROR('$srcdir/$THREAD_IMPL_SRC' must exist)])
+AC_DEFINE_UNQUOTED(THREAD_IMPL_H, ["$THREAD_IMPL_H"])
+AC_DEFINE_UNQUOTED(THREAD_IMPL_SRC, ["$THREAD_IMPL_SRC"])
])dnl
diff --git a/vm_core.h b/vm_core.h
index 96437ff559..2e022a6dd0 100644
--- a/vm_core.h
+++ b/vm_core.h
@@ -80,11 +80,7 @@
#include "darray.h"
#include "ruby/thread_native.h"
-#if defined(_WIN32)
-#include "thread_win32.h"
-#elif defined(HAVE_PTHREAD_H)
-#include "thread_pthread.h"
-#endif
+#include THREAD_IMPL_H
#define RUBY_VM_THREAD_MODEL 2
diff --git a/win32/Makefile.sub b/win32/Makefile.sub
index 2aef63985b..ce8cafe807 100644
--- a/win32/Makefile.sub
+++ b/win32/Makefile.sub
@@ -414,6 +414,8 @@ LIBRUBYARG_SHARED = $(LIBRUBY)
LIBRUBY_RELATIVE = yes
THREAD_MODEL = win32
+THREAD_IMPL_H = thread_$(THREAD_MODEL).h
+THREAD_IMPL_SRC = thread_$(THREAD_MODEL).c
!if "$(CROSS_COMPILING)" == "yes"
PREP = $(arch)-fake.rb
@@ -873,6 +875,8 @@ $(CONFIG_H): $(MKFILES) $(srcdir)/win32/Makefile.sub $(win_srcdir)/Makefile.sub
#define STACK_GROW_DIRECTION -1
!endif
#define COROUTINE_H "$(COROUTINE_H)"
+#define THREAD_IMPL_H "$(THREAD_IMPL_H)"
+#define THREAD_IMPL_SRC "$(THREAD_IMPL_SRC)"
#define LOAD_RELATIVE 1
#define DLEXT ".so"
!if "$(libdir_basename)" != "lib"