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:
parent
032e56fbd6
commit
0242fe816c
2 changed files with 12 additions and 6 deletions
|
@ -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>
|
Wed Jul 6 21:24:53 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
||||||
|
|
||||||
* cont.c (fiber_machine_stack_alloc): fix mprotect misuse. A stack
|
* cont.c (fiber_machine_stack_alloc): fix mprotect misuse. A stack
|
||||||
|
|
12
cont.c
12
cont.c
|
@ -523,10 +523,10 @@ fiber_entry(void *arg)
|
||||||
#define FIBER_STACK_FLAGS (MAP_PRIVATE | MAP_ANON)
|
#define FIBER_STACK_FLAGS (MAP_PRIVATE | MAP_ANON)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static VALUE*
|
static char*
|
||||||
fiber_machine_stack_alloc(size_t size)
|
fiber_machine_stack_alloc(size_t size)
|
||||||
{
|
{
|
||||||
VALUE *ptr;
|
char *ptr;
|
||||||
|
|
||||||
if (machine_stack_cache_index > 0) {
|
if (machine_stack_cache_index > 0) {
|
||||||
if (machine_stack_cache[machine_stack_cache_index - 1].size == (size / sizeof(VALUE))) {
|
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 */
|
/* 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) {
|
if (mprotect(page, RB_PAGE_SIZE, PROT_NONE) < 0) {
|
||||||
rb_raise(rb_eFiberError, "mprotect failed");
|
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;
|
sth->machine_stack_maxsize = size;
|
||||||
#else /* not WIN32 */
|
#else /* not WIN32 */
|
||||||
ucontext_t *context = &fib->context;
|
ucontext_t *context = &fib->context;
|
||||||
VALUE *ptr;
|
char *ptr;
|
||||||
STACK_GROW_DIR_DETECTION;
|
STACK_GROW_DIR_DETECTION;
|
||||||
|
|
||||||
getcontext(context);
|
getcontext(context);
|
||||||
ptr = fiber_machine_stack_alloc(size);
|
ptr = fiber_machine_stack_alloc(size);
|
||||||
context->uc_link = NULL;
|
context->uc_link = NULL;
|
||||||
context->uc_stack.ss_sp = (char *)ptr;
|
context->uc_stack.ss_sp = ptr;
|
||||||
context->uc_stack.ss_size = size;
|
context->uc_stack.ss_size = size;
|
||||||
makecontext(context, rb_fiber_start, 0);
|
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;
|
sth->machine_stack_maxsize = size - RB_PAGE_SIZE;
|
||||||
#endif
|
#endif
|
||||||
#ifdef __ia64
|
#ifdef __ia64
|
||||||
|
|
Loading…
Reference in a new issue