setjmp.h 773 B

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