qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] tcg: Reload local variables after return from l


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH] tcg: Reload local variables after return from longjmp
Date: Thu, 11 Aug 2011 15:13:41 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:5.0) Gecko/20110707 Thunderbird/5.0

On 08/11/2011 02:40 PM, Peter Maydell wrote:
"All accessible objects have values [...] as of the time the longjmp
function was called, except that the values of objects of automatic
storage duration that are local to the function containing the
invocation of the corresponding setjmp macro that do not have
volatile-qualified type and have been changed between the setjmp
invocation and longjmp call are indeterminate."
  -- C99 section 7.13.2.1 para 3.

So variables may only be destroyed if they are all of:
  * local to the function calling setjmp
  * not volatile
  * changed between setjmp and longjmp

I didn't remember this third part.  Thanks for bringing up facts. :)

We don't change env between the setjmp and longjmp so the compiler
should not trash it. (Indeed according to Jan in
http://lists.gnu.org/archive/html/qemu-devel/2011-07/msg00144.html
-Wclobbered doesn't complain about this code.)

Then it's a compiler bug, not smartness. Making env volatile (or making a volatile copy if there is a performance impact) should still be enough to work around it.

Paolo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]