[SunHELP] About setjmp and longjmp

Greg sunhelp at sunhelp.org
Thu Sep 13 17:20:52 CDT 2001


Nicholas Dronen wrote:

>>Hi, setjmp and longjmp are MT-safe? How can I jump from one function to
>>another function in MT-program?
> 
> The man page for setjmp and longjmp should indicate whether
> they are MT-safe.  They *should* be MT-safe, because they
> are system calls;


setjmp and longjmp are not system calls, they are very short
assembly routines.  As long as the jmpbuf is thread-specific
I don't see why MT is an issue for this.  The code using
setjmp/longjmp has to be written knowing it could happen
else you could leave locks held, etc.

For the interested reader:

	dis -F setjmp /usr/lib/libc.so
	dis -F longjmp /usr/lib/libc.so

-greg









More information about the SunHELP mailing list