1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32422 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
kosaki 2011-07-06 12:31:53 +00:00
parent 032e56fbd6
commit 0242fe816c
2 changed files with 12 additions and 6 deletions

View file

@ -1,3 +1,9 @@
Wed Jul 6 21:29:33 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
* 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@gmail.com>
* cont.c (fiber_machine_stack_alloc): fix mprotect misuse. A stack

12
cont.c
View file

@ -523,10 +523,10 @@ fiber_entry(void *arg)
#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 @@ fiber_machine_stack_alloc(size_t size)
}
/* 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 @@ fiber_initialize_machine_stack_context(rb_fiber_t *fib, size_t size)
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