|
From: | Peter Lieven |
Subject: | Re: [Qemu-devel] [PATCH V6 1/6] oslib-posix: add helpers for stack alloc and free |
Date: | Tue, 23 Aug 2016 09:16:04 +0200 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 |
Am 22.08.2016 um 17:19 schrieb Richard Henderson:
On 08/22/2016 06:04 AM, Peter Lieven wrote:+static size_t adjust_stack_size(size_t sz) +{ +#ifdef _SC_THREAD_STACK_MIN + /* avoid stacks smaller than _SC_THREAD_STACK_MIN */ + sz = MAX(MAX(sysconf(_SC_THREAD_STACK_MIN), 0), sz); +#endifYou need to place the sysconf result into a local variable. What you have now expands to 4 invocations of the function.
okay, I thought it would only be 2 calls and its not critical. but I can change that.
You might also consider passing in the pagesize, since you've already called getpagesize in one of the two users of this function.
I can change this as well, but isn't getpagesize just a macro on most systems? If the call of getpagesize is critical we should cache it somewhere as there are more critical sections that call it repeatly. Peter
[Prev in Thread] | Current Thread | [Next in Thread] |