[前][次][番号順一覧][スレッド一覧]

ruby-changes:53672

From: samuel <ko1@a...>
Date: Wed, 21 Nov 2018 02:27:43 +0900 (JST)
Subject: [ruby-changes:53672] samuel:r65875 (trunk): Expose stack functions to coroutine and non-windows implementations.

samuel	2018-11-20 19:18:12 +0900 (Tue, 20 Nov 2018)

  New Revision: 65875

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=65875

  Log:
    Expose stack functions to coroutine and non-windows implementations.

  Modified files:
    trunk/cont.c
Index: cont.c
===================================================================
--- cont.c	(revision 65874)
+++ cont.c	(revision 65875)
@@ -179,17 +179,6 @@ fiber_context_create(ucontext_t *context https://github.com/ruby/ruby/blob/trunk/cont.c#L179
 }
 #endif
 
-#if FIBER_USE_NATIVE && !defined(_WIN32)
-#define MAX_MACHINE_STACK_CACHE  10
-static int machine_stack_cache_index = 0;
-typedef struct machine_stack_cache_struct {
-    void *ptr;
-    size_t size;
-} machine_stack_cache_t;
-static machine_stack_cache_t machine_stack_cache[MAX_MACHINE_STACK_CACHE];
-static machine_stack_cache_t terminated_machine_stack;
-#endif
-
 struct rb_fiber_struct {
     rb_context_t cont;
     VALUE first_proc;
@@ -203,12 +192,14 @@ struct rb_fiber_struct { https://github.com/ruby/ruby/blob/trunk/cont.c#L192
 
 #if FIBER_USE_NATIVE
 #if defined(FIBER_USE_COROUTINE)
+#define FIBER_ALLOCATE_STACK
     coroutine_context context;
     void *ss_sp;
     size_t ss_size;
 #elif defined(_WIN32)
     void *fib_handle;
 #else
+#define FIBER_ALLOCATE_STACK
     ucontext_t context;
     /* Because context.uc_stack.ss_sp and context.uc_stack.ss_size
      * are not necessarily valid after makecontext() or swapcontext(),
@@ -220,6 +211,17 @@ struct rb_fiber_struct { https://github.com/ruby/ruby/blob/trunk/cont.c#L211
 #endif
 };
 
+#ifdef FIBER_ALLOCATE_STACK
+#define MAX_MACHINE_STACK_CACHE  10
+static int machine_stack_cache_index = 0;
+typedef struct machine_stack_cache_struct {
+    void *ptr;
+    size_t size;
+} machine_stack_cache_t;
+static machine_stack_cache_t machine_stack_cache[MAX_MACHINE_STACK_CACHE];
+static machine_stack_cache_t terminated_machine_stack;
+#endif
+
 static const char *
 fiber_status_name(enum fiber_status s)
 {
@@ -847,7 +849,9 @@ fiber_entry(void *arg) https://github.com/ruby/ruby/blob/trunk/cont.c#L849
     rb_fiber_start();
 }
 #endif
+#endif
 
+#ifdef FIBER_ALLOCATE_STACK
 /*
  * FreeBSD require a first (i.e. addr) argument of mmap(2) is not NULL
  * if MAP_STACK is passed.
@@ -992,7 +996,7 @@ fiber_setcontext(rb_fiber_t *newfib, rb_ https://github.com/ruby/ruby/blob/trunk/cont.c#L996
     swapcontext(&oldfib->context, &newfib->context);
 #endif
 }
-#endif /* FIBER_USE_NATIVE */
+#endif /* FIBER_ALLOCATE_STACK */
 
 NOINLINE(NORETURN(static void cont_restore_1(rb_context_t *)));
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]