OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-6.8/] [sim/] [common/] [sim-assert.h] - Diff between revs 816 and 827

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 816 Rev 827
/*  This file is part of the program GDB.
/*  This file is part of the program GDB.
 
 
    Copyright (C) 1997, Free Software Foundation, Inc.
    Copyright (C) 1997, Free Software Foundation, Inc.
 
 
    This program is free software; you can redistribute it and/or modify
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
    (at your option) any later version.
 
 
    This program is distributed in the hope that it will be useful,
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    GNU General Public License for more details.
 
 
    You should have received a copy of the GNU General Public License
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
    */
    */
 
 
 
 
#ifndef _SIM_ASSERT_H_
#ifndef _SIM_ASSERT_H_
#define _SIM_ASSERT_H_
#define _SIM_ASSERT_H_
 
 
#define SIM_FILTER_PATH(FILE, PATH) \
#define SIM_FILTER_PATH(FILE, PATH) \
do \
do \
  { \
  { \
    /* strip leading path */ \
    /* strip leading path */ \
    const char *p = (PATH); \
    const char *p = (PATH); \
    (FILE) = p; \
    (FILE) = p; \
    while (*p != '\0' && *p != ':') \
    while (*p != '\0' && *p != ':') \
      { \
      { \
        if (*p == '/') \
        if (*p == '/') \
          (FILE) = p + 1; \
          (FILE) = p + 1; \
        p++; \
        p++; \
      } \
      } \
  } \
  } \
while (0)
while (0)
 
 
/* The subtle difference between SIM_ASSERT and ASSERT is that
/* The subtle difference between SIM_ASSERT and ASSERT is that
   SIM_ASSERT passes `sd' to sim_io_error for the SIM_DESC,
   SIM_ASSERT passes `sd' to sim_io_error for the SIM_DESC,
   ASSERT passes NULL.  */
   ASSERT passes NULL.  */
 
 
#if !defined (SIM_ASSERT)
#if !defined (SIM_ASSERT)
#if defined (WITH_ASSERT)
#if defined (WITH_ASSERT)
#define SIM_ASSERT(EXPRESSION) \
#define SIM_ASSERT(EXPRESSION) \
do \
do \
  { \
  { \
    if (WITH_ASSERT) \
    if (WITH_ASSERT) \
      { \
      { \
        if (!(EXPRESSION)) \
        if (!(EXPRESSION)) \
          { \
          { \
            /* report the failure */ \
            /* report the failure */ \
            const char *file; \
            const char *file; \
            SIM_FILTER_PATH(file, __FILE__); \
            SIM_FILTER_PATH(file, __FILE__); \
            sim_io_error (sd, "%s:%d: assertion failed - %s", \
            sim_io_error (sd, "%s:%d: assertion failed - %s", \
                          file, __LINE__, #EXPRESSION); \
                          file, __LINE__, #EXPRESSION); \
          } \
          } \
      } \
      } \
  } \
  } \
while (0)
while (0)
#else
#else
#define SIM_ASSERT(EXPRESSION) do { /*nothing*/; } while (0)
#define SIM_ASSERT(EXPRESSION) do { /*nothing*/; } while (0)
#endif
#endif
#endif
#endif
 
 
#if !defined (ASSERT)
#if !defined (ASSERT)
#if defined (WITH_ASSERT)
#if defined (WITH_ASSERT)
#define ASSERT(EXPRESSION) \
#define ASSERT(EXPRESSION) \
do \
do \
  { \
  { \
    if (WITH_ASSERT) \
    if (WITH_ASSERT) \
      { \
      { \
        if (!(EXPRESSION)) \
        if (!(EXPRESSION)) \
          { \
          { \
            /* report the failure */ \
            /* report the failure */ \
            const char *file; \
            const char *file; \
            SIM_FILTER_PATH(file, __FILE__); \
            SIM_FILTER_PATH(file, __FILE__); \
            sim_io_error (NULL, "%s:%d: assertion failed - %s", \
            sim_io_error (NULL, "%s:%d: assertion failed - %s", \
                          file, __LINE__, #EXPRESSION); \
                          file, __LINE__, #EXPRESSION); \
          } \
          } \
      } \
      } \
  } \
  } \
while (0)
while (0)
#else
#else
#define ASSERT(EXPRESSION) do { /*nothing*/; } while (0)
#define ASSERT(EXPRESSION) do { /*nothing*/; } while (0)
#endif
#endif
#endif
#endif
 
 
#endif
#endif
 
 

powered by: WebSVN 2.1.0

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