chiark / gitweb /
volume_id: provide libvolume_id.a file
[elogind.git] / klibc / include / setjmp.h
1 /*
2  * setjmp.h
3  */
4
5 #ifndef _SETJMP_H
6 #define _SETJMP_H
7
8 #include <klibc/extern.h>
9 #include <klibc/compiler.h>
10 #include <stddef.h>
11 #include <signal.h>
12
13 #include <klibc/archsetjmp.h>
14
15 __extern int setjmp(jmp_buf);
16 __extern __noreturn longjmp(jmp_buf, int);
17
18 /*
19   Whose bright idea was it to add unrelated functionality to just about
20   the only function in the standard C library (setjmp) which cannot be
21   wrapped by an ordinary function wrapper?  Anyway, the damage is done,
22   and therefore, this wrapper *must* be inline.  However, gcc will
23   complain if this is an inline function for unknown reason, and
24   therefore sigsetjmp() needs to be a macro.
25 */
26
27 struct __sigjmp_buf {
28   jmp_buf __jmpbuf;
29   sigset_t __sigs;
30 };
31
32 typedef struct __sigjmp_buf sigjmp_buf[1];
33
34 #define sigsetjmp(__env, __save) \
35 ({ \
36   struct __sigjmp_buf *__e = (__env); \
37   sigprocmask(0, NULL, &__e->__sigs); \
38   setjmp(__e->__jmpbuf); \
39 })
40
41 __extern __noreturn siglongjmp(sigjmp_buf, int);
42
43 #endif /* _SETJMP_H */