diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/setjmp/_longjmp.c | 21 | ||||
| -rw-r--r-- | src/setjmp/_setjmp.c | 19 | ||||
| -rw-r--r-- | src/setjmp/sigjmp_buf.c | 8 | ||||
| -rw-r--r-- | src/setjmp/siglongjmp.c | 28 | ||||
| -rw-r--r-- | src/setjmp/sigsetjmp.c | 26 |
5 files changed, 98 insertions, 4 deletions
diff --git a/src/setjmp/_longjmp.c b/src/setjmp/_longjmp.c index 6a7d0b5c..f8c46b32 100644 --- a/src/setjmp/_longjmp.c +++ b/src/setjmp/_longjmp.c @@ -1,10 +1,31 @@ #include <setjmp.h> +/** restore calling environment **/ + void _longjmp(jmp_buf env, int val) { return longjmp(env, val); } +/*** +restores the environment, without manipulation the signal mask, of a previous +call to FUNCTION(_setjmp) and continues execution at the location of the call +to FUNCTION(_setjmp). + +All objects previously accessible at the time of the call to FUNCTION(_setjmp) +have the same values. Non-TYPE(volatile) objects of automatic storage duration +that have changed since the call to FUNCTION(_setjmp) have intederminate values. + +When execution resumes at the point of the original call to FUNCTION(_setjmp), +the value specified by ARGUMENT(val) is returned. If 0 is specified, then the +return value is 1. +***/ + /* +UNDEFINED(There was no previous call to FUNCTION(_setjmp)) +UNDEFINED(The function containing the previous call to FUNCTION(_setjmp) is no longer executing) +UNDEFINED(THIS() is called from a nested signal handler) + XOPEN(400) +XOBSOLETE(700, FUNCTION(siglongjmp)) */ diff --git a/src/setjmp/_setjmp.c b/src/setjmp/_setjmp.c index 922a36dc..a2537915 100644 --- a/src/setjmp/_setjmp.c +++ b/src/setjmp/_setjmp.c @@ -1,9 +1,28 @@ #include <setjmp.h> +/** save program state **/ + int _setjmp(jmp_buf env) { return setjmp(env); } + +/*** +saves the current state, without the signal mask, of the calling environment +in the TYPEDEF(jmp_buf) ARGUMENT(env). +***/ + /* +CONSTRAINT: entire controlling expression of a selection or iteration statement +CONSTRAINT: one operand of a relational or equality operator which is the entire controlling expression of a selction or iteration statement +CONSTRAINT: the operand of a unary ! as the entire controlling expression of a selection or iteration statement +CONSTRAINT: an entire expression statement + +UNSPECIFIED(Whether THIS() is a macro or identifier with external linkage) + +UNDEFINED(A macro definition of THIS() is suppressed in order to access an actual function) +UNDEFINED(A program defines an external identifier named LITERAL(setjmp)) + XOPEN(400) +XOBSOLETE(700, FUNCTION(siglongjmp)) */ diff --git a/src/setjmp/sigjmp_buf.c b/src/setjmp/sigjmp_buf.c index 09829e88..945448cd 100644 --- a/src/setjmp/sigjmp_buf.c +++ b/src/setjmp/sigjmp_buf.c @@ -1,7 +1,15 @@ #include <setjmp.h> +/** program environment with signal mask **/ + typedef jmp_buf sigjmp_buf; +/*** +is used to hold all the information needed to restore a a calling +environment, including the signal mask. +***/ + /* +TYPEDEF(an array type) POSIX(1) */ diff --git a/src/setjmp/siglongjmp.c b/src/setjmp/siglongjmp.c index 44b6d6ed..06edc641 100644 --- a/src/setjmp/siglongjmp.c +++ b/src/setjmp/siglongjmp.c @@ -1,10 +1,34 @@ #include <setjmp.h> +#include "signal.h" + +/** restore calling environment with signal mask **/ void siglongjmp(sigjmp_buf env, int val) { - (void)env; (void)val; - /* TODO */ + /* restor signal mask */ + + return longjmp(env, val); } + +/*** +restores the environment, including the saved signal mask (if any), of a +previous call to FUNCTION(sigsetjmp) and continues execution at the location of +the call to FUNCTION(sigsetjmp). + +All objects previously accessible at the time of the call to FUNCTION(sigsetjmp) +have the same values. Non-TYPE(volatile) objects of automatic storage duration +that have changed since the call to FUNCTION(sigsetjmp) have intederminate +values. + +When execution resumes at the point of the original call to FUNCTION(sigsetjmp), +the value specified by ARGUMENT(val) is returned. If 0 is specified, then the +return value is 1. +***/ + /* +UNDEFINED(There was no previous call to FUNCTION(setjmp)) +UNDEFINED(The function containing the previous call to FUNCTION(setjmp) is no longer executing) +UNDEFINED(THIS() is called from a nested signal handler) + POSIX(1) */ diff --git a/src/setjmp/sigsetjmp.c b/src/setjmp/sigsetjmp.c index 37c9727f..46eebeba 100644 --- a/src/setjmp/sigsetjmp.c +++ b/src/setjmp/sigsetjmp.c @@ -1,10 +1,32 @@ #include <setjmp.h> +#include "signal.h" + +/** save program state with signal mask **/ int sigsetjmp(sigjmp_buf env, int savemask) { - (void)env; (void)savemask; - return 0; + if (savemask) { + /* save mask to env */ + } + return setjmp(env); } + +/*** +saves the current state of the calling environment in the +TYPEDEF(sigjmp_buf) ARGUMENT(env). If ARGUMENT(savemask) is nonzero, the saved +environment includes the signal mask of the current thread. +***/ + /* +CONSTRAINT: entire controlling expression of a selection or iteration statement +CONSTRAINT: one operand of a relational or equality operator which is the entire controlling expression of a selction or iteration statement +CONSTRAINT: the operand of a unary ! as the entire controlling expression of a selection or iteration statement +CONSTRAINT: an entire expression statement + +UNSPECIFIED(Whether THIS() is a macro or identifier with external linkage) + +UNDEFINED(A macro definition of THIS() is suppressed in order to access an actual function) +UNDEFINED(A program defines an external identifier named LITERAL(setjmp)) + POSIX(1) */ |
