oslib-posix.c (186c0ab9b98d90642f37a629b1ff520cbfd06394) | oslib-posix.c (038adc2f5850e32019bda06c559d0301be436eae) |
---|---|
1/* 2 * os-posix-lib.c 3 * 4 * Copyright (c) 2003-2008 Fabrice Bellard 5 * Copyright (c) 2010 Red Hat, Inc. 6 * 7 * QEMU library functions on POSIX which are shared between QEMU and 8 * the QEMU tools. --- 603 unchanged lines hidden (view full) --- 612 613void *qemu_alloc_stack(size_t *sz) 614{ 615 void *ptr, *guardpage; 616 int flags; 617#ifdef CONFIG_DEBUG_STACK_USAGE 618 void *ptr2; 619#endif | 1/* 2 * os-posix-lib.c 3 * 4 * Copyright (c) 2003-2008 Fabrice Bellard 5 * Copyright (c) 2010 Red Hat, Inc. 6 * 7 * QEMU library functions on POSIX which are shared between QEMU and 8 * the QEMU tools. --- 603 unchanged lines hidden (view full) --- 612 613void *qemu_alloc_stack(size_t *sz) 614{ 615 void *ptr, *guardpage; 616 int flags; 617#ifdef CONFIG_DEBUG_STACK_USAGE 618 void *ptr2; 619#endif |
620 size_t pagesz = getpagesize(); | 620 size_t pagesz = qemu_real_host_page_size; |
621#ifdef _SC_THREAD_STACK_MIN 622 /* avoid stacks smaller than _SC_THREAD_STACK_MIN */ 623 long min_stack_sz = sysconf(_SC_THREAD_STACK_MIN); 624 *sz = MAX(MAX(min_stack_sz, 0), *sz); 625#endif 626 /* adjust stack size to a multiple of the page size */ 627 *sz = ROUND_UP(*sz, pagesz); 628 /* allocate one extra page for the guard page */ --- 45 unchanged lines hidden (view full) --- 674#endif 675 676void qemu_free_stack(void *stack, size_t sz) 677{ 678#ifdef CONFIG_DEBUG_STACK_USAGE 679 unsigned int usage; 680 void *ptr; 681 | 621#ifdef _SC_THREAD_STACK_MIN 622 /* avoid stacks smaller than _SC_THREAD_STACK_MIN */ 623 long min_stack_sz = sysconf(_SC_THREAD_STACK_MIN); 624 *sz = MAX(MAX(min_stack_sz, 0), *sz); 625#endif 626 /* adjust stack size to a multiple of the page size */ 627 *sz = ROUND_UP(*sz, pagesz); 628 /* allocate one extra page for the guard page */ --- 45 unchanged lines hidden (view full) --- 674#endif 675 676void qemu_free_stack(void *stack, size_t sz) 677{ 678#ifdef CONFIG_DEBUG_STACK_USAGE 679 unsigned int usage; 680 void *ptr; 681 |
682 for (ptr = stack + getpagesize(); ptr < stack + sz; | 682 for (ptr = stack + qemu_real_host_page_size; ptr < stack + sz; |
683 ptr += sizeof(uint32_t)) { 684 if (*(uint32_t *)ptr != 0xdeadbeaf) { 685 break; 686 } 687 } 688 usage = sz - (uintptr_t) (ptr - stack); 689 if (usage > max_stack_usage) { 690 error_report("thread %d max stack usage increased from %u to %u", --- 38 unchanged lines hidden --- | 683 ptr += sizeof(uint32_t)) { 684 if (*(uint32_t *)ptr != 0xdeadbeaf) { 685 break; 686 } 687 } 688 usage = sz - (uintptr_t) (ptr - stack); 689 if (usage > max_stack_usage) { 690 error_report("thread %d max stack usage increased from %u to %u", --- 38 unchanged lines hidden --- |