This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: __HAVE_BUILTIN_SETJMP__: why?


Zack Weinberg writes:

> cpplib unconditionally defines __HAVE_BUILTIN_SETJMP__ to 1.  This was
> added back in 1996:
> 
> Sat Jan 27 07:59:25 1996  Richard Kenner  (kenner@vlsi1.ultra.nyu.edu)
> 
>         * tree.h (enum built_in_function): Add BUILT_IN_{SET,LONG}JMP.
>         * expr.c: Include hard-reg-set.h.
>         (arg_pointer_save_area): New declaration.
>         (expand_builtin, case BUILT_IN_{SET,LONG}JMP): New cases.
>         * Makefile.in (expr.o): Includes hard-reg-set.h.
>         * c-decl.c (init_decl_processing): Add definitions for
>         __builtin_setjmp and __builtin_longjmp.
>         * cccp.c (initialize_builtins): Add def of __HAVE_BUILTIN_SETJMP__.
> 
> I can find no references to this macro anywhere.  What was it for?

Presumably it was so people who wanted to use __builtin_setjmp() could write

	#ifdef __HAVE_BUILTIN_SETJMP__
	  /* the fast version -- use GCC's __builtin_setjmp() */
	  #define my_setjmp __builtin_setjmp
	  #define my_longjmp __builtin_longjmp
	  typedef void *my_jmpbuf[5];
	#else
	  /* the portable version -- use the standard ANSI/ISO C setjmp() */
	  #include <setjmp.h>
	  #define my_setjmp setjmp
	  #define my_longjmp longjmp
	  typedef jmpbuf_t my_jmpbuf;
	#endif

You could use something like

	#if (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))

instead of
	
	#ifdef __HAVE_BUILTIN_SETJMP__

so it is not strictly necessary, but the definition of __HAVE_BUILTIN_SETJMP__
is pretty harmless, so personally I would leave it in to avoid breaking any
existing code which relies on it.

-- 
Fergus Henderson <fjh@cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]