Chapter Contents |
Previous |
Next |
onjmpout |
Portability: | SAS/C extension |
SYNOPSIS | |
DESCRIPTION | |
RETURN VALUE | |
CAUTION | |
IMPLEMENTATION | |
EXAMPLE | |
RELATED FUNCTIONS | |
SEE ALSO |
SYNOPSIS |
#include <lcjmp.h> void onjmpout(jmp_buf env, int code, target);
DESCRIPTION |
onjmpout
requests interception of calls to
longjmp
that could terminate the calling function. If a call to
longjmp
is later intercepted, control is passed to the
target
label. The
env
and
code
variables are modified to indicate the target
and code specified by the intercepted
longjmp
so that it can be reissued by the intercepting routine.
onjmpout
sets the
code
variable to 0 on completion. Because interception
of a jump assigns the
code
variable a value
other than 0, it can be tested elsewhere to determine whether interception
has taken place.
After a call to
longjmp
is intercepted,
onjmpout
must be
reissued if you want continued interception.
Because
exit
is implemented
as a
longjmp
to the caller of
main
, you use
onjmpout
to intercept
program exit.
RETURN VALUE |
onjmpout
has no return value.
CAUTION |
Variables of storage class
auto
and
register
, whose values
are changed between the
onjmpout
and
longjmp
calls, have indeterminate values after
the branch to
target
unless declared
volatile
.
onjmpout
is implemented
as a macro and should not be used in any position where a value is required.
IMPLEMENTATION |
onjmpout
is implemented as
#define onjmpout(e, c, t) if (c = blkjmp(e)) goto t
EXAMPLE |
The following code fragment illustrates
the use of
onjmpout
:
#include <lcjmp.h> jmp_buf env; int jmpcode; /* Intercept abnormal exits. */ onjmpout(env, jmpcode, cleanup); . . . cleanup: /* Clean up after attempted exit. */ . . . longjmp(env, jmpcode); /* And then reissue the jump. */
RELATED FUNCTIONS |
SEE ALSO |
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.