| 1 |
/* do not edit automatically generated by mc from M2EXCEPTION. */ |
| 2 |
/* M2EXCEPTION.mod implement M2Exception and IsM2Exception. |
| 3 |
|
| 4 |
Copyright (C) 2001-2025 Free Software Foundation, Inc. |
| 5 |
Contributed by Gaius Mulley <[email protected]>. |
| 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_C |
| 39 |
|
| 40 |
#include "GM2EXCEPTION.h" |
| 41 |
# include "GSYSTEM.h" |
| 42 |
# include "GRTExceptions.h" |
| 43 |
|
| 44 |
extern "C" M2EXCEPTION_M2Exceptions M2EXCEPTION_M2Exception (void); |
| 45 |
extern "C" bool M2EXCEPTION_IsM2Exception (void); |
| 46 |
|
| 47 |
extern "C" M2EXCEPTION_M2Exceptions M2EXCEPTION_M2Exception (void) |
| 48 |
{ |
| 49 |
RTExceptions_EHBlock e; |
| 50 |
unsigned int n; |
| 51 |
|
| 52 |
/* If the program or coroutine is in the exception state then return the enumeration |
| 53 |
value representing the exception cause. If it is not in the exception state then |
| 54 |
raises and exception (exException). */ |
| 55 |
e = RTExceptions_GetExceptionBlock (); |
| 56 |
n = RTExceptions_GetNumber (e); |
| 57 |
if (n == (UINT_MAX)) |
| 58 |
{ |
| 59 |
RTExceptions_Raise ( ((unsigned int) (M2EXCEPTION_exException)), const_cast<void*> (static_cast<const void*>("../../gcc/m2/gm2-libs/M2EXCEPTION.mod")), 47, 6, const_cast<void*> (static_cast<const void*>("M2Exception")), const_cast<void*> (static_cast<const void*>("current coroutine is not in the exceptional execution state"))); |
| 60 |
} |
| 61 |
else |
| 62 |
{ |
| 63 |
return (M2EXCEPTION_M2Exceptions) (n); |
| 64 |
} |
| 65 |
ReturnException ("../../gcc/m2/gm2-libs/M2EXCEPTION.def", 25, 1); |
| 66 |
__builtin_unreachable (); |
| 67 |
} |
| 68 |
|
| 69 |
extern "C" bool M2EXCEPTION_IsM2Exception (void) |
| 70 |
{ |
| 71 |
RTExceptions_EHBlock e; |
| 72 |
|
| 73 |
/* Returns TRUE if the program or coroutine is in the exception state. |
| 74 |
Returns FALSE if the program or coroutine is not in the exception state. */ |
| 75 |
e = RTExceptions_GetExceptionBlock (); |
| 76 |
return (RTExceptions_GetNumber (e)) != (UINT_MAX); |
| 77 |
/* static analysis guarentees a RETURN statement will be used before here. */ |
| 78 |
__builtin_unreachable (); |
| 79 |
} |
| 80 |
|
| 81 |
extern "C" void _M2_M2EXCEPTION_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) |
| 82 |
{ |
| 83 |
RTExceptions_SetExceptionBlock (RTExceptions_InitExceptionBlock ()); |
| 84 |
} |
| 85 |
|
| 86 |
extern "C" void _M2_M2EXCEPTION_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) |
| 87 |
{ |
| 88 |
} |