| 1 |
/* do not edit automatically generated by mc from Assertion. */ |
| 2 |
/* Assertion.mod provides an assert procedure. |
| 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 |
#define _Assertion_C |
| 38 |
|
| 39 |
#include "GAssertion.h" |
| 40 |
# include "GStrIO.h" |
| 41 |
# include "GM2RTS.h" |
| 42 |
|
| 43 |
|
| 44 |
/* |
| 45 |
Assert - tests the boolean Condition, if it fails then HALT is called. |
| 46 |
*/ |
| 47 |
|
| 48 |
extern "C" void Assertion_Assert (bool Condition); |
| 49 |
|
| 50 |
|
| 51 |
/* |
| 52 |
Assert - tests the boolean Condition, if it fails then HALT is called. |
| 53 |
*/ |
| 54 |
|
| 55 |
extern "C" void Assertion_Assert (bool Condition) |
| 56 |
{ |
| 57 |
if (! Condition) |
| 58 |
{ |
| 59 |
StrIO_WriteString ((const char *) "assert failed - halting system", 30); |
| 60 |
StrIO_WriteLn (); |
| 61 |
M2RTS_HALT (-1); |
| 62 |
__builtin_unreachable (); |
| 63 |
} |
| 64 |
} |
| 65 |
|
| 66 |
extern "C" void _M2_Assertion_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) |
| 67 |
{ |
| 68 |
} |
| 69 |
|
| 70 |
extern "C" void _M2_Assertion_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) |
| 71 |
{ |
| 72 |
} |