Volatile is Necessary
gordon at sneaky.UUCP
gordon at sneaky.UUCP
Sun Apr 3 05:33:00 AEST 1988
> The |setjmp| macro shall be implemented as a macro, not as an
> actual function. If the macro definition is suppressed in order
> to access an actual function, the behavior is undefined.
> No reason is given here for this requirement (which, incidentally,
> makes it technically illegal NOT to |#define setjmp| as something, even
> if it is just as |_setjmp|), but it would make sense if it were
> intended as a constraint on the *programmer* so that |<setjmp.h>| could
> say, e.g.,
> #define setjmp(env) _builtin_setjmp(env)
I interpret the requirement that setjmp be implemented as a macro as
requiring that you cannot (portably) take the address of setjmp, and
put it in a function pointer. Therefore, the compiler may assume that
all calls through function pointers are NOT calls to setjmp. Further, you
can make the compiler recognize all calls to setjmp, by doing things
like:
# define setjmp(env) (_builtin_setjmp(env) + 0)
where the +0 ensures that &setjmp draws an error message, and the name
_builtin_setjmp is recognized by the compiler and makes it flush out
common subexpressions, etc.
Gordon Burditt
...!ihnp4!sys1!sneaky!gordon
More information about the Comp.lang.c
mailing list