diff options
-rw-r--r-- | common.mk | 3 | ||||
-rw-r--r-- | configure.ac | 58 | ||||
-rw-r--r-- | cont.c | 7 | ||||
-rw-r--r-- | template/Makefile.in | 3 | ||||
-rw-r--r-- | win32/Makefile.sub | 26 |
5 files changed, 50 insertions, 47 deletions
@@ -924,9 +924,8 @@ strlcpy.$(OBJEXT): {$(VPATH)}strlcpy.c strstr.$(OBJEXT): {$(VPATH)}strstr.c nt.$(OBJEXT): {$(VPATH)}nt.c -COROUTINE_SRC = $(COROUTINE_H:.h=).$(ASMEXT) .coroutine_obj $(COROUTINE_OBJ): \ - {$(VPATH)}$(COROUTINE_SRC:/ucontext/Context.S=/ucontext/Context.c) \ + {$(VPATH)}$(COROUTINE_SRC) \ $(COROUTINE_H:/Context.h=/.time) $(COROUTINE_H:/Context.h=/.time): $(Q) $(MAKEDIRS) $(@D) diff --git a/configure.ac b/configure.ac index bc678cdc2d..9703591af7 100644 --- a/configure.ac +++ b/configure.ac @@ -964,7 +964,7 @@ main() AS_IF([test "$target_cpu" = x64], [ ac_cv_func___builtin_setjmp=yes ac_cv_func_round=no - rb_cv_fiber_coroutine=yes + rb_cv_coroutine=yes ]) ac_cv_func_tgamma=no rb_cv_negative_time_t=yes @@ -2251,60 +2251,67 @@ AS_IF([test "${universal_binary-no}" = yes ], [ AC_DEFINE_UNQUOTED(STACK_GROW_DIRECTION, $dir) ]) -AC_ARG_ENABLE(fiber-coroutine, - AS_HELP_STRING([--disable-fiber-coroutine], [disable native coroutine implementation for fiber]), - [rb_cv_fiber_coroutine=$enableval]) -AS_CASE(["$rb_cv_fiber_coroutine"], [yes|''], [ +AC_ARG_WITH(coroutine, + AS_HELP_STRING([--with-coroutine=IMPLEMENTATION], [specify the coroutine implementation to use]), + [rb_cv_coroutine=$withval]) +AS_CASE([$rb_cv_coroutine], [yes|''], [ AC_MSG_CHECKING(native coroutine implementation for ${target_cpu}-${target_os}) AS_CASE(["$target_cpu-$target_os"], [x*64-darwin*], [ - rb_cv_fiber_coroutine=amd64 + rb_cv_coroutine=amd64 ], [x*64-linux], [ AS_CASE(["$ac_cv_sizeof_voidp"], - [8], [ rb_cv_fiber_coroutine=amd64 ], - [4], [ rb_cv_fiber_coroutine=x86 ], - [*], [ rb_cv_fiber_coroutine= ] + [8], [ rb_cv_coroutine=amd64 ], + [4], [ rb_cv_coroutine=x86 ], + [*], [ rb_cv_coroutine= ] ) ], [*86-linux], [ - rb_cv_fiber_coroutine=x86 + rb_cv_coroutine=x86 ], [x64-mingw32], [ - rb_cv_fiber_coroutine=win64 + rb_cv_coroutine=win64 ], [*86-mingw32], [ - rb_cv_fiber_coroutine=win32 + rb_cv_coroutine=win32 ], [armv7*-linux-*], [ - rb_cv_fiber_coroutine=ucontext + rb_cv_coroutine=ucontext ], [aarch64-linux], [ - rb_cv_fiber_coroutine=arm64 + rb_cv_coroutine=arm64 ], [powerpc64le-linux], [ - rb_cv_fiber_coroutine=ppc64le + rb_cv_coroutine=ppc64le ], [x86_64-openbsd*], [ - rb_cv_fiber_coroutine=amd64 + rb_cv_coroutine=amd64 ], [i386-openbsd*], [ - rb_cv_fiber_coroutine=x86 + rb_cv_coroutine=x86 ], [*-openbsd*], [ - rb_cv_fiber_coroutine= + rb_cv_coroutine=copy ], [*], [ - rb_cv_fiber_coroutine=ucontext + rb_cv_coroutine=ucontext ] ) - AC_MSG_RESULT(${rb_cv_fiber_coroutine:-no}) -]) -AS_IF([test "${rb_cv_fiber_coroutine:-no}" != no], [ - COROUTINE_H=coroutine/$rb_cv_fiber_coroutine/Context.h - AC_DEFINE_UNQUOTED(FIBER_USE_COROUTINE, ["$COROUTINE_H"]) - AC_SUBST(X_FIBER_COROUTINE_H, [$COROUTINE_H]) + AC_MSG_RESULT(${rb_cv_coroutine}) ]) +COROUTINE_H=coroutine/$rb_cv_coroutine/Context.h +AS_CASE([$rb_cv_coroutine], + [copy|ucontext], [ + COROUTINE_SRC=coroutine/$rb_cv_coroutine/Context.c + ], + [*], [ + COROUTINE_SRC=coroutine/$rb_cv_coroutine/Context.'$(ASMEXT)' + ], +) +AC_DEFINE_UNQUOTED(COROUTINE_H, ["$COROUTINE_H"]) +AC_SUBST(X_COROUTINE_H, [$COROUTINE_H]) +AC_SUBST(X_COROUTINE_SRC, [$COROUTINE_SRC]) AS_IF([test x"$enable_pthread" = xyes], [ for pthread_lib in thr pthread pthreads c c_r root; do @@ -4009,6 +4016,7 @@ config_summary "vendor path" "$vendordir" config_summary "target OS" "$target_os" config_summary "compiler" "$CC" config_summary "with pthread" "$enable_pthread" +config_summary "with coroutine" "$rb_cv_coroutine" config_summary "enable shared libs" "$ENABLE_SHARED" config_summary "dynamic library ext" "$DLEXT" config_summary "CFLAGS" "$cflags" @@ -15,12 +15,7 @@ #include "eval_intern.h" #include "mjit.h" -#ifdef FIBER_USE_COROUTINE -#include FIBER_USE_COROUTINE -#else -// Stack copying implementation, should work everywhere: -#include "coroutine/copy/Context.h" -#endif +#include COROUTINE_H #ifndef _WIN32 #include <unistd.h> diff --git a/template/Makefile.in b/template/Makefile.in index 110071de6a..eae67a5d05 100644 --- a/template/Makefile.in +++ b/template/Makefile.in @@ -152,8 +152,9 @@ XRUBY_RUBYLIBDIR = @XRUBY_RUBYLIBDIR@ XRUBY_RUBYHDRDIR = @XRUBY_RUBYHDRDIR@ BOOTSTRAPRUBY = @BOOTSTRAPRUBY@ -COROUTINE_H = @X_FIBER_COROUTINE_H@ +COROUTINE_H = @X_COROUTINE_H@ COROUTINE_OBJ = $(COROUTINE_H:.h=.@OBJEXT@) +COROUTINE_SRC = @X_COROUTINE_SRC@ #### End of system configuration section. #### diff --git a/win32/Makefile.sub b/win32/Makefile.sub index d79a16bddb..a990a557ea 100644 --- a/win32/Makefile.sub +++ b/win32/Makefile.sub @@ -290,19 +290,18 @@ MISSING = $(MISSING) acosh.obj cbrt.obj erf.obj nan.obj tgamma.obj MISSING = $(MISSING) explicit_bzero.obj !endif DLNOBJ = dln.obj + !if "$(ARCH)" == "x64" -COROUTINE_OBJ = coroutine/Win64/Context.obj +COROUTINE_OBJ = coroutine/win64/Context.obj +COROUTINE_SRC = $(COROUTINE_OBJ:.obj=.asm) !elseif "$(ARCH)" == "i386" -COROUTINE_OBJ = coroutine/Win32/Context.obj +COROUTINE_OBJ = coroutine/win32/Context.obj +COROUTINE_SRC = $(COROUTINE_OBJ:.obj=.asm) !else -COROUTINE_OBJ = +COROUTINE_OBJ = coroutine/copy/Context.obj +COROUTINE_SRC = $(COROUTINE_OBJ:.obj=.c) !endif -!if "$(COROUTINE_OBJ)" == "" -# get rid of empty value not to leave VPATH only in dependencies -COROUTINE_H = coroutine/Win32/Context.h -!else COROUTINE_H = $(COROUTINE_OBJ:.obj=.h) -!endif ARFLAGS = -machine:$(MACHINE) -out: LD = $(CC) @@ -871,9 +870,7 @@ $(CONFIG_H): $(MKFILES) $(srcdir)/win32/Makefile.sub $(win_srcdir)/Makefile.sub !if "$(MACHINE)" == "x86" || "$(ARCH)" == "x64" #define STACK_GROW_DIRECTION -1 !endif -!if "$(COROUTINE_OBJ)" != "" -#define FIBER_USE_COROUTINE "$(COROUTINE_H)" -!endif +#define COROUTINE_H "$(COROUTINE_H)" #define DEFAULT_KCODE KCODE_NONE #define LOAD_RELATIVE 1 #define DLEXT ".so" @@ -1235,12 +1232,15 @@ $(ruby_pc): $(RBCONFIG) -output=$@ -mode=$(INSTALL_DATA_MODE) -config=rbconfig.rb \ $(srcdir)/template/ruby.pc.in -{$(srcdir)/coroutine/Win32}.asm{coroutine/Win32}.obj: +{$(srcdir)/coroutine/win32}.asm{coroutine/win32}.obj: $(ECHO) assembling $(<:\=/) $(Q) $(AS) $(ASFLAGS) $(XCFLAGS) $(CPPFLAGS) $(COUTFLAG)$@ -c $(<:\=/) -{$(srcdir)/coroutine/Win64}.asm{coroutine/Win64}.obj: +{$(srcdir)/coroutine/win64}.asm{coroutine/win64}.obj: $(ECHO) assembling $(<:\=/) $(Q) $(AS) $(ASFLAGS) $(XCFLAGS) $(CPPFLAGS) $(COUTFLAG)$@ -c $(<:\=/) +{$(srcdir)/coroutine/copy}.c{coroutine/copy}.obj: + $(ECHO) compiling $(<:\=/) + $(Q) $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$(<:\=/) {$(srcdir)/enc/trans}.c.obj: $(ECHO) compiling $(<:\=/) |