Skip to content

Commit

Permalink
Select including thread impl file at config time
Browse files Browse the repository at this point in the history
  • Loading branch information
kateinoigakukun authored and mame committed Oct 30, 2021
1 parent ccda26e commit 8590d61
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
6 changes: 2 additions & 4 deletions thread.c
Expand Up @@ -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); \
Expand All @@ -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); \
Expand All @@ -368,8 +368,6 @@ ubf_sigwait(void *ignore)
fflush(stdout); \
pthread_mutex_unlock(&debug_mutex);

#else
#error "unsupported thread type"
#endif

/*
Expand Down
9 changes: 9 additions & 0 deletions tool/m4/ruby_thread.m4
Expand Up @@ -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
6 changes: 1 addition & 5 deletions vm_core.h
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions win32/Makefile.sub
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 8590d61

Please sign in to comment.