Changeset 91e22dc in mainline
- Timestamp:
- 2013-11-15T08:39:36Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6a5b999
- Parents:
- 8797bae
- Location:
- uspace/lib/c
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/setjmp.c
r8797bae r91e22dc 40 40 #include <fibril.h> 41 41 42 struct jmp_buf_interal {43 context_t context;44 int return_value;45 };46 47 /**48 * Save current environment (registers).49 *50 * This function may return twice.51 *52 * @param env Variable where to save the environment.53 * @return Whether the call returned after longjmp.54 * @retval 0 Environment was saved, normal execution.55 * @retval other longjmp was executed and returned here.56 */57 int setjmp(jmp_buf env) {58 env->return_value = 0;59 context_save(&env[0].context);60 return env->return_value;61 }62 63 42 /** 64 43 * Restore environment previously stored by setjmp. -
uspace/lib/c/include/setjmp.h
r8797bae r91e22dc 31 31 * @{ 32 32 */ 33 /** @file 33 /** @file Long jump implementation. 34 * 35 * Implementation inspired by Jiri Zarevucky's code from 36 * http://bazaar.launchpad.net/~zarevucky-jiri/helenos/stdc/revision/1544/uspace/lib/posix/setjmp.h 34 37 */ 35 38 … … 37 40 #define LIBC_SETJMP_H_ 38 41 42 #include <libarch/fibril.h> 43 44 struct jmp_buf_interal { 45 context_t context; 46 int return_value; 47 }; 48 typedef struct jmp_buf_interal jmp_buf[1]; 49 39 50 /* 40 * We hide the structure to allow smooth inclusion from libposix41 * as no other types are necessary (and thus no includes are needed).51 * Specified as extern to minimize number of included headers 52 * because this file is used as is in libposix too. 42 53 */ 43 struct jmp_buf_interal; 44 typedef struct jmp_buf_interal *jmp_buf; 54 extern int context_save(context_t *ctx) __attribute__((returns_twice)); 45 55 46 extern int setjmp(jmp_buf env); 56 /** 57 * Save current environment (registers). 58 * 59 * This function may return twice. 60 * 61 * @param env Variable where to save the environment (of type jmp_buf). 62 * @return Whether the call returned after longjmp. 63 * @retval 0 Environment was saved, normal execution. 64 * @retval other longjmp was executed and returned here. 65 */ 66 #define setjmp(env) \ 67 ((env)[0].return_value = 0, \ 68 context_save(&(env)[0].context), \ 69 (env)[0].return_value) 70 47 71 extern void longjmp(jmp_buf env, int val) __attribute__((noreturn)); 48 72
Note:
See TracChangeset
for help on using the changeset viewer.