Changeset 615e83d in mainline for uspace/lib/c/generic/setjmp.c
- Timestamp:
- 2018-03-08T18:25:31Z (7 years ago)
- Children:
- 55f068c
- Parents:
- e0a4686
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-08 17:43:06)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-08 18:25:31)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/setjmp.c
re0a4686 r615e83d 1 1 /* 2 2 * Copyright (c) 2013 Vojtech Horky 3 * Copyright (c) 2018 CZ.NIC, z.s.p.o. 3 4 * All rights reserved. 4 5 * … … 30 31 * @{ 31 32 */ 32 /** @file Long jump implementation.33 *34 * Implementation inspired by Jiri Zarevucky's code from35 * http://bazaar.launchpad.net/~zarevucky-jiri/helenos/stdc/revision/1544/uspace/lib/posix/setjmp.h36 */37 33 38 34 #include <setjmp.h> 39 35 #include <context.h> 40 36 41 // TODO: setjmp/longjmp are basically a stronger version of 42 // context_save/context_restore. It would be preferable to turn 43 // those two into setjmp/longjmp (all it would need is preserving the 44 // return value). 45 46 /** 47 * Restore environment previously stored by setjmp. 48 * 49 * This function never returns. 50 * 51 * @param env Variable with the environment previously stored by call 52 * to setjmp. 53 * @param val Value to fake when returning from setjmp (0 is transformed to 1). 54 */ 55 void longjmp(jmp_buf env, int val) { 56 env[0].return_value = (val == 0) ? 1 : val; 57 context_restore(&env[0].context); 37 /** Standard function implementation. */ 38 void longjmp(jmp_buf env, int val) 39 { 40 /* __longjmp defined in assembly doesn't "correct" the value. */ 41 __longjmp(env, val == 0 ? 1 : val); 58 42 } 59 43
Note:
See TracChangeset
for help on using the changeset viewer.