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

ruby-changes:51148

From: nobu <ko1@a...>
Date: Tue, 8 May 2018 09:01:21 +0900 (JST)
Subject: [ruby-changes:51148] nobu:r63355 (trunk): cont.c: host out context setup

nobu	2018-05-08 09:01:16 +0900 (Tue, 08 May 2018)

  New Revision: 63355

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

  Log:
    cont.c: host out context setup

  Modified files:
    trunk/cont.c
Index: cont.c
===================================================================
--- cont.c	(revision 63354)
+++ cont.c	(revision 63355)
@@ -142,6 +142,18 @@ enum fiber_status { https://github.com/ruby/ruby/blob/trunk/cont.c#L142
 #define FIBER_RUNNABLE_P(fib)   (FIBER_CREATED_P(fib) || FIBER_SUSPENDED_P(fib))
 
 #if FIBER_USE_NATIVE && !defined(_WIN32)
+static inline void
+fiber_context_create(ucontext_t *context, void (*func)(void *), void *arg, void *ptr, size_t size)
+{
+    getcontext(context);
+    context->uc_link = NULL;
+    context->uc_stack.ss_sp = ptr;
+    context->uc_stack.ss_size = size;
+    makecontext(context, func, 0);
+}
+#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 {
@@ -838,18 +850,13 @@ fiber_initialize_machine_stack_context(r https://github.com/ruby/ruby/blob/trunk/cont.c#L850
     }
     sec->machine.stack_maxsize = size;
 #else /* not WIN32 */
-    ucontext_t *context = &fib->context;
     char *ptr;
     STACK_GROW_DIR_DETECTION;
 
-    getcontext(context);
     ptr = fiber_machine_stack_alloc(size);
-    context->uc_link = NULL;
-    context->uc_stack.ss_sp = ptr;
-    context->uc_stack.ss_size = size;
     fib->ss_sp = ptr;
     fib->ss_size = size;
-    makecontext(context, fiber_entry, 0);
+    fiber_context_create(&fib->context, fiber_entry, NULL, fib->ss_sp, fib->ss_size);
     sec->machine.stack_start = (VALUE*)(ptr + STACK_DIR_UPPER(0, size));
     sec->machine.stack_maxsize = size - RB_PAGE_SIZE;
 #endif

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

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