Branch data Line data Source code
1 : : /* do not edit automatically generated by mc from M2Debug. */
2 : : /* M2Debug.mod simple debugging facilities in the Modula-2 compiler.
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 : : You should have received a copy of the GNU General Public License
20 : : along with GNU Modula-2; see the file COPYING3. If not see
21 : : <http://www.gnu.org/licenses/>. */
22 : :
23 : : #include "config.h"
24 : : #include "system.h"
25 : : #include <stdbool.h>
26 : : # if !defined (PROC_D)
27 : : # define PROC_D
28 : : typedef void (*PROC_t) (void);
29 : : typedef struct { PROC_t proc; } PROC;
30 : : # endif
31 : :
32 : : #define _M2Debug_H
33 : : #define _M2Debug_C
34 : :
35 : : # include "GStrIO.h"
36 : : # include "GM2Error.h"
37 : : # include "GM2Options.h"
38 : :
39 : :
40 : : /*
41 : : Assert - tests the boolean, q. If false then an error is reported
42 : : and the execution is HALTed.
43 : : */
44 : :
45 : : extern "C" void M2Debug_Assert (bool q);
46 : :
47 : : /*
48 : : WriteDebug - only writes a string if the debugging mode is on.
49 : : */
50 : :
51 : : extern "C" void M2Debug_WriteDebug (const char *a_, unsigned int _a_high);
52 : :
53 : :
54 : : /*
55 : : Assert - tests the boolean, q. If false then an error is reported
56 : : and the execution is HALTed.
57 : : */
58 : :
59 : 1300871139 : extern "C" void M2Debug_Assert (bool q)
60 : : {
61 : 1300871139 : if (! q)
62 : : {
63 : 30 : M2Error_InternalError ((const char *) "assert failed", 13);
64 : : }
65 : 1300871109 : }
66 : :
67 : :
68 : : /*
69 : : WriteDebug - only writes a string if the debugging mode is on.
70 : : */
71 : :
72 : 0 : extern "C" void M2Debug_WriteDebug (const char *a_, unsigned int _a_high)
73 : : {
74 : 0 : char a[_a_high+1];
75 : :
76 : : /* make a local copy of each unbounded array. */
77 : 0 : memcpy (a, a_, _a_high+1);
78 : :
79 : 0 : if (M2Options_CompilerDebugging)
80 : : {
81 : 0 : StrIO_WriteString ((const char *) a, _a_high);
82 : 0 : StrIO_WriteLn ();
83 : : }
84 : 0 : }
85 : :
86 : 12963 : extern "C" void _M2_M2Debug_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
87 : : {
88 : 12963 : }
89 : :
90 : 0 : extern "C" void _M2_M2Debug_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
91 : : {
92 : 0 : }
|