Tom Rini | b5351a4 | 2018-06-03 16:10:22 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Simon Glass | 30eef21 | 2018-05-16 09:42:22 -0600 | [diff] [blame] | 2 | /* |
| 3 | * (C) 2018 Google, Inc |
| 4 | * Written by Simon Glass <sjg@chromium.org> |
| 5 | */ |
| 6 | |
| 7 | #ifndef _SETJMP_H_ |
| 8 | #define _SETJMP_H_ |
| 9 | |
| 10 | struct jmp_buf_data { |
| 11 | /* |
| 12 | * We're not sure how long this should be: |
| 13 | * |
| 14 | * amd64: 200 bytes |
| 15 | * arm64: 392 bytes |
| 16 | * armhf: 392 bytes |
| 17 | * |
| 18 | * So allow space for all of those, plus some extra. |
| 19 | * We don't need to worry about 16-byte alignment, since this does not |
| 20 | * run on Windows. |
| 21 | */ |
| 22 | ulong data[128]; |
| 23 | }; |
| 24 | |
| 25 | typedef struct jmp_buf_data jmp_buf[1]; |
| 26 | |
Alexander Graf | 3fcb714 | 2018-06-22 14:44:12 +0200 | [diff] [blame] | 27 | /* |
| 28 | * We have to directly link with the system versions of |
| 29 | * setjmp/longjmp, because setjmp must not return as otherwise |
| 30 | * the stack may become invalid. |
| 31 | */ |
Simon Glass | 30eef21 | 2018-05-16 09:42:22 -0600 | [diff] [blame] | 32 | int setjmp(jmp_buf jmp); |
| 33 | __noreturn void longjmp(jmp_buf jmp, int ret); |
| 34 | |
| 35 | #endif /* _SETJMP_H_ */ |