ruby-changes:20374
From: kosaki <ko1@a...>
Date: Wed, 6 Jul 2011 21:32:51 +0900 (JST)
Subject: [ruby-changes:20374] kosaki:r32422 (trunk): * cont.c (fiber_machine_stack_alloc): cleanup pointer arithmetic.
kosaki 2011-07-06 21:31:53 +0900 (Wed, 06 Jul 2011) New Revision: 32422 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=32422 Log: * cont.c (fiber_machine_stack_alloc): cleanup pointer arithmetic. "size/sizeof(VALUE)" is ugly and easy confusing. * cont.c (fiber_initialize_machine_stack_context): ditto. Modified files: trunk/ChangeLog trunk/cont.c Index: ChangeLog =================================================================== --- ChangeLog (revision 32421) +++ ChangeLog (revision 32422) @@ -1,3 +1,9 @@ +Wed Jul 6 21:29:33 2011 KOSAKI Motohiro <kosaki.motohiro@g...> + + * cont.c (fiber_machine_stack_alloc): cleanup pointer arithmetic. + "size/sizeof(VALUE)" is ugly and easy confusing. + * cont.c (fiber_initialize_machine_stack_context): ditto. + Wed Jul 6 21:24:53 2011 KOSAKI Motohiro <kosaki.motohiro@g...> * cont.c (fiber_machine_stack_alloc): fix mprotect misuse. A stack Index: cont.c =================================================================== --- cont.c (revision 32421) +++ cont.c (revision 32422) @@ -523,10 +523,10 @@ #define FIBER_STACK_FLAGS (MAP_PRIVATE | MAP_ANON) #endif -static VALUE* +static char* fiber_machine_stack_alloc(size_t size) { - VALUE *ptr; + char *ptr; if (machine_stack_cache_index > 0) { if (machine_stack_cache[machine_stack_cache_index - 1].size == (size / sizeof(VALUE))) { @@ -550,7 +550,7 @@ } /* guard page setup */ - page = ptr + STACK_DIR_UPPER((size - RB_PAGE_SIZE) / sizeof(VALUE), 0); + page = ptr + STACK_DIR_UPPER(size - RB_PAGE_SIZE, 0); if (mprotect(page, RB_PAGE_SIZE, PROT_NONE) < 0) { rb_raise(rb_eFiberError, "mprotect failed"); } @@ -578,16 +578,16 @@ sth->machine_stack_maxsize = size; #else /* not WIN32 */ ucontext_t *context = &fib->context; - VALUE *ptr; + char *ptr; STACK_GROW_DIR_DETECTION; getcontext(context); ptr = fiber_machine_stack_alloc(size); context->uc_link = NULL; - context->uc_stack.ss_sp = (char *)ptr; + context->uc_stack.ss_sp = ptr; context->uc_stack.ss_size = size; makecontext(context, rb_fiber_start, 0); - sth->machine_stack_start = ptr + STACK_DIR_UPPER(0, size / sizeof(VALUE)); + sth->machine_stack_start = (VALUE*)(ptr + STACK_DIR_UPPER(0, size)); sth->machine_stack_maxsize = size - RB_PAGE_SIZE; #endif #ifdef __ia64 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/