]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/m2/mc-boot/GM2EXCEPTION.c
Update copyright years.
[thirdparty/gcc.git] / gcc / m2 / mc-boot / GM2EXCEPTION.c
1 /* do not edit automatically generated by mc from M2EXCEPTION. */
2 /* M2EXCEPTION.mod implement M2Exception and IsM2Exception.
3
4 Copyright (C) 2001-2023 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 # if !defined (PROC_D)
31 # define PROC_D
32 typedef void (*PROC_t) (void);
33 typedef struct { PROC_t proc; } PROC;
34 # endif
35
36 # include "Gmcrts.h"
37 #define _M2EXCEPTION_H
38 #define _M2EXCEPTION_C
39
40 # include "GSYSTEM.h"
41 # include "GRTExceptions.h"
42
43 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;
44
45 extern "C" M2EXCEPTION_M2Exceptions M2EXCEPTION_M2Exception (void);
46 extern "C" unsigned int M2EXCEPTION_IsM2Exception (void);
47
48 extern "C" M2EXCEPTION_M2Exceptions M2EXCEPTION_M2Exception (void)
49 {
50 RTExceptions_EHBlock e;
51 unsigned int n;
52
53 /* If the program or coroutine is in the exception state then return the enumeration
54 value representing the exception cause. If it is not in the exception state then
55 raises and exception (exException). */
56 e = RTExceptions_GetExceptionBlock ();
57 n = RTExceptions_GetNumber (e);
58 if (n == (UINT_MAX))
59 {
60 RTExceptions_Raise ( ((unsigned int) (M2EXCEPTION_exException)), const_cast<void*> (reinterpret_cast<const void*>("../../gcc-git-devel-modula2/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")));
61 }
62 else
63 {
64 return (M2EXCEPTION_M2Exceptions) (n);
65 }
66 ReturnException ("../../gcc-git-devel-modula2/gcc/m2/gm2-libs/M2EXCEPTION.def", 25, 1);
67 __builtin_unreachable ();
68 }
69
70 extern "C" unsigned int M2EXCEPTION_IsM2Exception (void)
71 {
72 RTExceptions_EHBlock e;
73
74 /* Returns TRUE if the program or coroutine is in the exception state.
75 Returns FALSE if the program or coroutine is not in the exception state. */
76 e = RTExceptions_GetExceptionBlock ();
77 return (RTExceptions_GetNumber (e)) != (UINT_MAX);
78 /* static analysis guarentees a RETURN statement will be used before here. */
79 __builtin_unreachable ();
80 }
81
82 extern "C" void _M2_M2EXCEPTION_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
83 {
84 RTExceptions_SetExceptionBlock (RTExceptions_InitExceptionBlock ());
85 }
86
87 extern "C" void _M2_M2EXCEPTION_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
88 {
89 }