setjmp,longjmp, sigsetjmp implementation

T

Tim Rentsch

Nobody said:
7.13.2.1p3:

All accessible objects have values as of the time longjmp 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.

gcc will warn about such cases with e.g.:

warning: variable 'foo' might be clobbered by 'longjmp' or 'vfork'

A herring was never redder. :)
Typically, only the "essential" registers (program counter, stack pointer,
frame pointer) are preserved. Registers holding local variables or
intermediate results aren't required to be preserved (and usually aren't).
[snip unrelated]

This is nonsense. Any register holding a live value at the time
of the call to setjmp must be preserved, and restored by longjmp.
Most commonly that will be most or all the registers.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top