Changes in uspace/lib/c/generic/setjmp.c [a35a3d8:e0a4686] in mainline
- File:
-
- 1 edited
-
uspace/lib/c/generic/setjmp.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/setjmp.c
ra35a3d8 re0a4686 1 1 /* 2 2 * Copyright (c) 2013 Vojtech Horky 3 * Copyright (c) 2018 CZ.NIC, z.s.p.o.4 3 * All rights reserved. 5 4 * … … 31 30 * @{ 32 31 */ 32 /** @file Long jump implementation. 33 * 34 * Implementation inspired by Jiri Zarevucky's code from 35 * http://bazaar.launchpad.net/~zarevucky-jiri/helenos/stdc/revision/1544/uspace/lib/posix/setjmp.h 36 */ 33 37 34 38 #include <setjmp.h> 35 39 #include <context.h> 36 40 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); 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); 42 58 } 43 59
Note:
See TracChangeset
for help on using the changeset viewer.
