[uClibc]setjmp() & setsigjmp()

Michael Shmulevich michaels at jungo.com
Sun May 6 08:51:37 UTC 2001


Well, since Erik entered a confession mode, I think I must say several 
words on it:

Erik Andersen wrote:

> On Fri May 04, 2001 at 05:01:39AM -0400, Tom Walsh wrote:
> 
>> If I am reading this correctly..  A call to setjmp() will save the
>> processor state within a struct sigjmp_buff (everything, including the
>> stack and except the status register)?  Then when setlongjmp() is
>> called, this will restore the processor state back to what it had been
>> saved into the sigjmp_buff structure?

Well, setjmp() and sigsetjmp() are similar, except for sigsetjmp() also

saves set of blocked signals when such parameter is given. Besides that they are synonyms.
There are longjmp() and siglongjmp() which are the function that use 
buffers saved by *setjmp().


>> I need to implement the m68k version of sigsetjmp() and, by looking at
>> the other processor implementations of this, it appears that a setjmp()
>> will *always* save into "slot"(?) zero, and with sigsetjmp() it is
>> possible to specify which "slot" within the sigjmp_buff to place the
>> processor state?

My advice will not be new to you already: look at glibc's implementation 
of this stuff. Besides that the "slot" has no sence in this context: 
there is only one "slot" which is *jmp_buff itself. You can use several 
variables for several junps, but for every buf there is only one slot.


> <confession mode>
> To be honest, this is one area which I have managed thus far
> by swiping code from glibc....  I understand what these functions
> do, but I've never actually sat down and figured out how they do it
> </confession mode>

Erik, you could've at least read the manual and tell, just like I did :-)


NOTES
        POSIX does not specify whether setjmp will save the signal
        context. (In SYSV it will not.  In  BSD4.3  it  will,  and
        there  is  a function _setjmp that will not.)  If you want
        to save signal masks, use sigsetjmp.

  >>>> I love this one: <<<<<<
        setjmp() and sigsetjmp make programs  hard  to  understand
        and  maintain.  If possible an alternative should be used.

Erik, i have had crashes in busybox's cp_mv ever since I tried to port 
uLibc to MIPS, all due to this... :-)

-- 
Sincerely yours,
Michael Shmulevich
______________________________________
Software Developer
Jungo - R&D
email: michaels at jungo.com
web: http://www.jungo.com
Phone: 1-877-514-0537(USA)  +972-9-8859365(Worldwide) ext. 233
Fax:   1-877-514-0538(USA)  +972-9-8859366(Worldwide)






More information about the uClibc mailing list