setjmp.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /* -*-comment-start: "//";comment-end:""-*-
  2. * GNU Mes --- Maxwell Equations of Software
  3. * Copyright © 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
  4. * Copyright © 2020 Danny Milosavljevic <dannym@scratchpost.org>
  5. *
  6. * This file is part of GNU Mes.
  7. *
  8. * GNU Mes is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 3 of the License, or (at
  11. * your option) any later version.
  12. *
  13. * GNU Mes is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. #ifndef __MES_SETJMP_H
  22. #define __MES_SETJMP_H 1
  23. #if SYSTEM_LIBC
  24. #undef __MES_SETJMP_H
  25. #include_next <setjmp.h>
  26. #else // ! SYSTEM_LIBC
  27. #if __arm__
  28. #if __GNUC__ || __TINYC__
  29. #warning "It is not supported to use mes' setjmp implementation together with GCC. Continuing with best-effort implementation."
  30. typedef struct
  31. {
  32. long __sp;
  33. long __lr;
  34. long __registers[8]; /* Note: Keep in sync with lib/arm-mes-gcc/setjmp.c */
  35. } __jmp_buf;
  36. #else
  37. typedef struct
  38. {
  39. long __fp;
  40. long __lr;
  41. long __sp;
  42. } __jmp_buf;
  43. #endif
  44. #else
  45. typedef struct
  46. {
  47. long __bp;
  48. long __pc;
  49. long __sp;
  50. } __jmp_buf;
  51. #endif
  52. typedef __jmp_buf jmp_buf[1];
  53. void longjmp (jmp_buf env, int val);
  54. int setjmp (jmp_buf env);
  55. #endif // ! SYSTEM_LIBC
  56. #endif // __MES_SETJMP_H