summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-09-23 10:47:24 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2014-09-23 10:47:24 +0200
commit389c6d35f2908018e8b6ae3f8294c02c6b5073a0 (patch)
tree5d52965eaf12dab1e81900688268c3a877338231
parent88c5996dc16b6356ec03f9c4d0562203c6d0cb54 (diff)
eo: call stack can grow/shrink when not using mmap
- if HAVE_MMAP call stack do not shrink and abort() when should grow - otherwise it's a growing/shrinking stack using realloc
-rw-r--r--src/lib/eo/eo.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c
index b27b221..319eb09 100644
--- a/src/lib/eo/eo.c
+++ b/src/lib/eo/eo.c
@@ -314,20 +314,27 @@ _eo_call_stack_mem_alloc(size_t size)
314static void 314static void
315_eo_call_stack_mem_resize(void **ptr EINA_UNUSED, size_t newsize, size_t size) 315_eo_call_stack_mem_resize(void **ptr EINA_UNUSED, size_t newsize, size_t size)
316{ 316{
317 // resize call stack down - currently won't ever be called 317 // FIXME we don't grow
318 if (newsize > size) 318 if (newsize > size)
319 { 319 {
320 CRI("eo call stack overflow, abort."); 320 CRI("eo call stack overflow, abort.");
321 abort(); 321 abort();
322 } 322 }
323 // FIXME resize call stack down
324 return;
323 size_t addr = MEM_PAGE_SIZE * ((newsize + MEM_PAGE_SIZE - 1) / 325 size_t addr = MEM_PAGE_SIZE * ((newsize + MEM_PAGE_SIZE - 1) /
324 MEM_PAGE_SIZE); 326 MEM_PAGE_SIZE);
325 madvise(((unsigned char *)*ptr) + addr, size - addr, MADV_DONTNEED); 327 madvise(((unsigned char *)*ptr) + addr, size - addr, MADV_DONTNEED);
326#else 328#else
327static void 329static void
328_eo_call_stack_mem_resize(void **ptr EINA_UNUSED, size_t newsize EINA_UNUSED, size_t size EINA_UNUSED) 330_eo_call_stack_mem_resize(void **ptr, size_t newsize, size_t size EINA_UNUSED)
329{ 331{
330 // just grow in regular cases 332 *ptr = realloc(*ptr, newsize);
333 if (!*ptr)
334 {
335 CRI("eo call stack resize failed, abort.");
336 abort();
337 }
331#endif 338#endif
332} 339}
333 340
@@ -427,10 +434,9 @@ _eo_call_stack_resize(Eo_Call_Stack *stack, Eina_Bool grow)
427 frame_offset = stack->frame_ptr - stack->frames; 434 frame_offset = stack->frame_ptr - stack->frames;
428 435
429 DBG("resize from %lu to %lu", (long unsigned int)sz, (long unsigned int)next_sz); 436 DBG("resize from %lu to %lu", (long unsigned int)sz, (long unsigned int)next_sz);
430 if (!grow) 437 _eo_call_stack_mem_resize((void **)&(stack->frames),
431 _eo_call_stack_mem_resize((void **)&(stack->frames), 438 next_sz * sizeof(Eo_Stack_Frame),
432 next_sz * sizeof(Eo_Stack_Frame), 439 sz * sizeof(Eo_Stack_Frame));
433 sz * sizeof(Eo_Stack_Frame));
434 if (!stack->frames) 440 if (!stack->frames)
435 { 441 {
436 CRI("unable to resize call stack, abort."); 442 CRI("unable to resize call stack, abort.");