diff --git a/newlib/ChangeLog b/newlib/ChangeLog index 34986d349..20db001e8 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,9 @@ +2005-03-18 Corinna Vinschen + + * libc/include/machine/setjmp.h (sigsetjmp): Use GCC extension to + evaluate first parameter only once. + (siglongjmp): Ditto. + 2005-03-17 Jeff Johnston * configure.in: Add new check to see if compiler supports diff --git a/newlib/libc/include/machine/setjmp.h b/newlib/libc/include/machine/setjmp.h index 7a61fcfea..fe05ee1ee 100644 --- a/newlib/libc/include/machine/setjmp.h +++ b/newlib/libc/include/machine/setjmp.h @@ -236,6 +236,27 @@ typedef int sigjmp_buf[_JBLEN+2]; # define _CYGWIN_WORKING_SIGSETJMP #endif +#if defined(__GNUC__) + +#define sigsetjmp(env, savemask) \ + ({ \ + sigjmp_buf *_sjbuf = &(env); \ + ((*_sjbuf)[_SAVEMASK] = savemask,\ + sigprocmask (SIG_SETMASK, 0, (sigset_t *)((*_sjbuf) + _SIGMASK)),\ + setjmp (*_sjbuf)); \ + }) + +#define siglongjmp(env, val) \ + ({ \ + sigjmp_buf *_sjbuf = &(env); \ + ((((*_sjbuf)[_SAVEMASK]) ? \ + sigprocmask (SIG_SETMASK, (sigset_t *)((*_sjbuf) + _SIGMASK), 0)\ + : 0), \ + longjmp (*_sjbuf, val)); \ + }) + +#else /* !__GNUC__ */ + #define sigsetjmp(env, savemask) ((env)[_SAVEMASK] = savemask,\ sigprocmask (SIG_SETMASK, 0, (sigset_t *) ((env) + _SIGMASK)),\ setjmp (env)) @@ -244,6 +265,8 @@ typedef int sigjmp_buf[_JBLEN+2]; sigprocmask (SIG_SETMASK, (sigset_t *) ((env) + _SIGMASK), 0):0),\ longjmp (env, val)) +#endif + #ifdef __cplusplus } #endif