1/*  This file is part of the program GDB.
2
3    Copyright (C) 1997-2023 Free Software Foundation, Inc.
4
5    This program is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 3 of the License, or
8    (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18    */
19
20
21#ifndef SIM_ASSERT_H
22#define SIM_ASSERT_H
23
24#include "libiberty.h"
25
26/* The subtle difference between SIM_ASSERT and ASSERT is that
27   SIM_ASSERT passes `sd' to sim_io_error for the SIM_DESC,
28   ASSERT passes NULL.  */
29
30#if !defined (SIM_ASSERT)
31#if defined (WITH_ASSERT)
32#include "sim-io.h"
33#define SIM_ASSERT(EXPRESSION) \
34do \
35  { \
36    if (WITH_ASSERT) \
37      { \
38        if (!(EXPRESSION)) \
39          { \
40            /* report the failure */ \
41            sim_io_error (sd, "%s:%d: assertion failed - %s", \
42                          lbasename (__FILE__), __LINE__, #EXPRESSION); \
43          } \
44      } \
45  } \
46while (0)
47#else
48#define SIM_ASSERT(EXPRESSION) do { /*nothing*/; } while (0)
49#endif
50#endif
51
52#if !defined (ASSERT)
53#if defined (WITH_ASSERT)
54#include "sim-io.h"
55#define ASSERT(EXPRESSION) \
56do \
57  { \
58    if (WITH_ASSERT) \
59      { \
60        if (!(EXPRESSION)) \
61          { \
62            /* report the failure */ \
63            sim_io_error (NULL, "%s:%d: assertion failed - %s", \
64                          lbasename (__FILE__), __LINE__, #EXPRESSION); \
65          } \
66      } \
67  } \
68while (0)
69#else
70#define ASSERT(EXPRESSION) do { /*nothing*/; } while (0)
71#endif
72#endif
73
74#endif
75