summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-07-06 12:31:53 +0000
committerkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-07-06 12:31:53 +0000
commit0242fe816ca736a927d551f64e9ba5d2263fed32 (patch)
tree8580b5fa34904a7675da6f35e377fa1a2586d591
parent032e56fbd66d3dd1aa144a86f4a90b667dcff649 (diff)
* 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
-rw-r--r--ChangeLog6
-rw-r--r--cont.c12
2 files changed, 12 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 2370e92..c646488 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/cont.c b/cont.c
index beaa5c8..adf975b 100644
--- a/cont.c
+++ b/cont.c
@@ -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