]>
Commit | Line | Data |
---|---|---|
2aa62f2b | 1 | /** @file\r |
a430bdb1 | 2 | This file defines the macro setjmp, and declares the function longjmp\r |
3 | and the type jmp_buf, for bypassing the normal function call and return discipline.\r | |
2aa62f2b | 4 | \r |
a430bdb1 | 5 | Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>\r |
6 | This program and the accompanying materials are licensed and made available under\r | |
7 | the terms and conditions of the BSD License that accompanies this distribution.\r | |
8 | The full text of the license may be found at\r | |
9 | http://opensource.org/licenses/bsd-license.\r | |
2aa62f2b | 10 | \r |
a430bdb1 | 11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
2aa62f2b | 13 | **/\r |
14 | #ifndef _SETJMP_H\r | |
15 | #define _SETJMP_H\r | |
16 | #include <Library/BaseLib.h>\r | |
17 | #include <sys/EfiCdefs.h>\r | |
18 | \r | |
19 | /** jmp_buf is an array type suitable for holding the information needed to\r | |
20 | restore a calling environment. The environment of a call to the setjmp\r | |
21 | macro consists of information sufficient for a call to the longjmp function\r | |
22 | to return execution to the correct block and invocation of that block, were\r | |
23 | it called recursively. It does not include the state of the floating-point\r | |
24 | status flags, of open files, or of any other component of the abstract\r | |
25 | machine.\r | |
26 | **/\r | |
27 | typedef BASE_LIBRARY_JUMP_BUFFER jmp_buf[1];\r | |
28 | \r | |
29 | /** The setjmp macro saves its calling environment in its jmp_buf argument for\r | |
30 | later use by the longjmp function.\r | |
31 | \r | |
32 | The Standard does not specify whether setjmp is a macro or an identifier\r | |
33 | declared with external linkage. If a macro definition is suppressed in\r | |
34 | order to access an actual function, or a program defines an external\r | |
35 | identifier with the name setjmp, the behavior is undefined by the Standard.\r | |
36 | \r | |
37 | @param[in,out] env A jmp_buf type object into which\r | |
38 | the current environment is stored.\r | |
39 | \r | |
40 | @return If the return is from a direct invocation, the setjmp macro\r | |
41 | returns the value zero. If the return is from a call to the longjmp\r | |
a430bdb1 | 42 | function, the setjmp macro returns a nonzero value based upon the value\r |
43 | of the second argument to the longjmp function.\r | |
2aa62f2b | 44 | **/\r |
45 | #define setjmp(env) (INTN)SetJump((env))\r | |
46 | \r | |
47 | /** The longjmp function restores the environment saved by the most recent\r | |
48 | invocation of the setjmp macro in the same invocation of the program with\r | |
49 | the corresponding jmp_buf argument. If there has been no such invocation,\r | |
50 | or if the function containing the invocation of the setjmp macro has\r | |
51 | terminated execution in the interim, or if the invocation of the setjmp\r | |
52 | macro was within the scope of an identifier with variably modified type and\r | |
53 | execution has left that scope in the interim, the behavior is undefined.\r | |
54 | \r | |
a430bdb1 | 55 | @param[in] env The jump buffer containing the environment to be returned to.\r |
56 | @param[in] val A non-zero value to be returned from setjmp.\r | |
57 | \r | |
58 | @return After longjmp is completed, program execution continues as if the\r | |
2aa62f2b | 59 | corresponding invocation of the setjmp macro had just returned the value\r |
60 | specified by val. The longjmp function cannot cause the setjmp macro to\r | |
61 | return the value 0; if val is 0, the setjmp macro returns the value 1.\r | |
62 | **/\r | |
63 | extern void longjmp(jmp_buf env, int val);\r | |
64 | \r | |
65 | #endif /* _SETJMP_H */\r |