From: Michael Tokarev <mjt@tls.msk.ru>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: QEMU Developers <qemu-devel@nongnu.org>,
SeokYeon Hwang <syeon.hwang@samsung.com>
Subject: Re: [Qemu-devel] [PATCH] translate-all: wrapped map_exec() in #ifdef
Date: Mon, 03 Nov 2014 17:27:54 +0300 [thread overview]
Message-ID: <545790EA.1080506@msgid.tls.msk.ru> (raw)
In-Reply-To: <CAFEAcA8Z2W+x4dswF1y_=K988CUUKkQzaCF92fbyj4eLOz6Fzg@mail.gmail.com>
03.11.2014 15:25, Peter Maydell wrote:
> On 3 November 2014 09:16, Michael Tokarev <mjt@tls.msk.ru> wrote:
>> 03.11.2014 11:18, SeokYeon Hwang wrote:
>>>> --- a/translate-all.c
>>>> +++ b/translate-all.c
>>>> @@ -270,14 +270,14 @@ bool cpu_restore_state(CPUState *cpu, uintptr_t
>>>> retaddr) }
>>>>
>>>> #ifdef _WIN32
>>>> -static inline void map_exec(void *addr, long size)
>>>> +static __attribute__((unused)) void map_exec(void *addr, long size)
>>>> {
>>>> DWORD old_protect;
>>>> VirtualProtect(addr, size,
>>>> PAGE_EXECUTE_READWRITE, &old_protect); }
>>
>> In which case this function isn't used on windows? I mean, is it really
>> necessary to mark it as unused for win32 case?
>
> It's not necessary, but it means we're consistent between
> windows and not-windows. It avoids unnecessary coupling between
> how the calling function happens to be implemented and
> what defines we put around this utility function.
I usually reluctant to add these unused attributes and shut up other
warnings by force, because with time this cruft does not help, and
more and more code becomes "forgotten". If it is not needed for
windows, why add it?
>>>> #else
>>>> -static inline void map_exec(void *addr, long size)
>>>> +static __attribute__((unused)) void map_exec(void *addr, long size)
>>>> {
>>>> unsigned long start, end, page_size;
>>
>> How about this instead:
>>
>> --- a/translate-all.c
>> +++ b/translate-all.c
>> @@ -276,7 +276,7 @@ static inline void map_exec(void *addr, long size)
>> VirtualProtect(addr, size,
>> PAGE_EXECUTE_READWRITE, &old_protect);
>> }
>> -#else
>> +#elif !defined(USE_MMAP)
>> static inline void map_exec(void *addr, long size)
>> {
>> unsigned long start, end, page_size;
>>
>> ? (Untested, but just to show an idea)... ;)
>
> This breaks for linux-user, where we will define both
> USE_STATIC_CODE_GEN_BUFFER and USE_MMAP, and your change won't
> define map_exec() but the later ifdef ladder will pick a version
> of alloc_code_gen_buffer() that calls it.
Hence the "untested" warning by me... So the test can be rewritten
like this:
#elif defined(USE_STATIC_CODE_GEN_BUFFER) || !defined(USE_MMAP)
(untested again! ;) and everything should be well without adding
extra attributes... Which one is better is, well, a matter of
personal taste really.. :)
(Not that all this is hugely important, we already spent too much
time discussing various trivial/unimportant things and had much
less time to do the real work, but... ;)
Thanks,
/mjt
next prev parent reply other threads:[~2014-11-03 14:28 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-31 4:59 [Qemu-devel] [PATCH] translate-all: wrapped map_exec() in #ifdef SeokYeon Hwang
2014-10-31 18:30 ` Peter Maydell
2014-11-03 8:18 ` SeokYeon Hwang
2014-11-03 9:16 ` Michael Tokarev
2014-11-03 12:25 ` Peter Maydell
2014-11-03 14:27 ` Michael Tokarev [this message]
2014-11-03 15:05 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=545790EA.1080506@msgid.tls.msk.ru \
--to=mjt@tls.msk.ru \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=syeon.hwang@samsung.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.