What is the setjump call

moss at BRL-VLD.ARPA moss at BRL-VLD.ARPA
Mon Oct 1 23:45:26 AEST 1984


From:      "Gary S. Moss (AMXBR-VLD-V)" <moss at BRL-VLD.ARPA>

Do not use char buf[8] as the storage area for setjmp().  The portable
way is to use the typedef jmp_buf from <setjmp.h>.  This is defined in
Doug Gwyn's System V emulation as follows;

/*	@(#)setjmp.h	1.3	*/
#ifndef _JBLEN

#if vax || u3b5
#define _JBLEN	10
#endif

#if pdp11
#define _JBLEN	4	/* DAG -- one larger for overlays */
#endif

#if u370
#define _JBLEN	4
#endif

#if u3b
#define _JBLEN	11
#endif

typedef int jmp_buf[_JBLEN];

extern int setjmp();
extern void longjmp();

#endif

The size of the buffer differs with machine and version of UNIX and the
whim of whoever modifies the compiler, so USE THE TYPEDEF BY INCLUDING
SETJMP.H!!!

I got bit by this one because I defined it as int buf[3] rather than
including <setjmp.h>.  Since my buffer was one integer short, I stomped
on an integer variable when I called setjmp(), and Boy was that a tough
bug to track down.

-- Moss.
PS, I know this was not your question.



More information about the Comp.lang.c mailing list