]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/m2/mc-boot/GM2EXCEPTION.cc
Update copyright years.
[thirdparty/gcc.git] / gcc / m2 / mc-boot / GM2EXCEPTION.cc
1 /* do not edit automatically generated by mc from M2EXCEPTION. */
2 /* M2EXCEPTION.mod implement M2Exception and IsM2Exception.
3
4 Copyright (C) 2001-2024 Free Software Foundation, Inc.
5 Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
6
7 This file is part of GNU Modula-2.
8
9 GNU Modula-2 is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3, or (at your option)
12 any later version.
13
14 GNU Modula-2 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 GNU
17 General Public License for more details.
18
19 Under Section 7 of GPL version 3, you are granted additional
20 permissions described in the GCC Runtime Library Exception, version
21 3.1, as published by the Free Software Foundation.
22
23 You should have received a copy of the GNU General Public License and
24 a copy of the GCC Runtime Library Exception along with this program;
25 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
26 <http://www.gnu.org/licenses/>. */
27
28 #include "config.h"
29 #include "system.h"
30 #include <stdbool.h>
31 # if !defined (PROC_D)
32 # define PROC_D
33 typedef void (*PROC_t) (void);
34 typedef struct { PROC_t proc; } PROC;
35 # endif
36
37 # include "Gmcrts.h"
38 #define _M2EXCEPTION_H
39 #define _M2EXCEPTION_C
40
41 # include "GSYSTEM.h"
42 # include "GRTExceptions.h"
43
44 typedef enum {M2EXCEPTION_indexException, M2EXCEPTION_rangeException, M2EXCEPTION_caseSelectException, M2EXCEPTION_invalidLocation, M2EXCEPTION_functionException, M2EXCEPTION_wholeValueException, M2EXCEPTION_wholeDivException, M2EXCEPTION_realValueException, M2EXCEPTION_realDivException, M2EXCEPTION_complexValueException, M2EXCEPTION_complexDivException, M2EXCEPTION_protException, M2EXCEPTION_sysException, M2EXCEPTION_coException, M2EXCEPTION_exException} M2EXCEPTION_M2Exceptions;
45
46 extern "C" M2EXCEPTION_M2Exceptions M2EXCEPTION_M2Exception (void);
47 extern "C" bool M2EXCEPTION_IsM2Exception (void);
48
49 extern "C" M2EXCEPTION_M2Exceptions M2EXCEPTION_M2Exception (void)
50 {
51 RTExceptions_EHBlock e;
52 unsigned int n;
53
54 /* If the program or coroutine is in the exception state then return the enumeration
55 value representing the exception cause. If it is not in the exception state then
56 raises and exception (exException). */
57 e = RTExceptions_GetExceptionBlock ();
58 n = RTExceptions_GetNumber (e);
59 if (n == (UINT_MAX))
60 {
61 RTExceptions_Raise ( ((unsigned int) (M2EXCEPTION_exException)), const_cast<void*> (reinterpret_cast<const void*>("../../gcc-read-write/gcc/m2/gm2-libs/M2EXCEPTION.mod")), 47, 6, const_cast<void*> (reinterpret_cast<const void*>("M2Exception")), const_cast<void*> (reinterpret_cast<const void*>("current coroutine is not in the exceptional execution state")));
62 }
63 else
64 {
65 return (M2EXCEPTION_M2Exceptions) (n);
66 }
67 ReturnException ("../../gcc-read-write/gcc/m2/gm2-libs/M2EXCEPTION.def", 25, 1);
68 __builtin_unreachable ();
69 }
70
71 extern "C" bool M2EXCEPTION_IsM2Exception (void)
72 {
73 RTExceptions_EHBlock e;
74
75 /* Returns TRUE if the program or coroutine is in the exception state.
76 Returns FALSE if the program or coroutine is not in the exception state. */
77 e = RTExceptions_GetExceptionBlock ();
78 return (RTExceptions_GetNumber (e)) != (UINT_MAX);
79 /* static analysis guarentees a RETURN statement will be used before here. */
80 __builtin_unreachable ();
81 }
82
83 extern "C" void _M2_M2EXCEPTION_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
84 {
85 RTExceptions_SetExceptionBlock (RTExceptions_InitExceptionBlock ());
86 }
87
88 extern "C" void _M2_M2EXCEPTION_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
89 {
90 }