boot2

Playing with the boostrap
git clone https://git.ryansepassi.com/git/boot2.git
Log | Files | Refs | README

setjmp.h (1883B)


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