OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-6.8/] [sim/] [common/] [sim-assert.h] - Blame information for rev 300

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 24 jeremybenn
/*  This file is part of the program GDB.
2
 
3
    Copyright (C) 1997, 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
#define SIM_FILTER_PATH(FILE, PATH) \
25
do \
26
  { \
27
    /* strip leading path */ \
28
    const char *p = (PATH); \
29
    (FILE) = p; \
30
    while (*p != '\0' && *p != ':') \
31
      { \
32
        if (*p == '/') \
33
          (FILE) = p + 1; \
34
        p++; \
35
      } \
36
  } \
37
while (0)
38
 
39
/* The subtle difference between SIM_ASSERT and ASSERT is that
40
   SIM_ASSERT passes `sd' to sim_io_error for the SIM_DESC,
41
   ASSERT passes NULL.  */
42
 
43
#if !defined (SIM_ASSERT)
44
#if defined (WITH_ASSERT)
45
#define SIM_ASSERT(EXPRESSION) \
46
do \
47
  { \
48
    if (WITH_ASSERT) \
49
      { \
50
        if (!(EXPRESSION)) \
51
          { \
52
            /* report the failure */ \
53
            const char *file; \
54
            SIM_FILTER_PATH(file, __FILE__); \
55
            sim_io_error (sd, "%s:%d: assertion failed - %s", \
56
                          file, __LINE__, #EXPRESSION); \
57
          } \
58
      } \
59
  } \
60
while (0)
61
#else
62
#define SIM_ASSERT(EXPRESSION) do { /*nothing*/; } while (0)
63
#endif
64
#endif
65
 
66
#if !defined (ASSERT)
67
#if defined (WITH_ASSERT)
68
#define ASSERT(EXPRESSION) \
69
do \
70
  { \
71
    if (WITH_ASSERT) \
72
      { \
73
        if (!(EXPRESSION)) \
74
          { \
75
            /* report the failure */ \
76
            const char *file; \
77
            SIM_FILTER_PATH(file, __FILE__); \
78
            sim_io_error (NULL, "%s:%d: assertion failed - %s", \
79
                          file, __LINE__, #EXPRESSION); \
80
          } \
81
      } \
82
  } \
83
while (0)
84
#else
85
#define ASSERT(EXPRESSION) do { /*nothing*/; } while (0)
86
#endif
87
#endif
88
 
89
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.