aboutsummaryrefslogtreecommitdiff
path: root/sim/common/sim-assert.h
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>1997-03-21 03:56:07 +0000
committerAndrew Cagney <cagney@redhat.com>1997-03-21 03:56:07 +0000
commitfa21d299e666c3b9862e2e96cf1c4bacc3675c6b (patch)
tree3b474411e2f92be90709dd93c37f33e698333398 /sim/common/sim-assert.h
parent011fa6712432575d1ea1f9b70c9d2eb3f981476f (diff)
downloadgdb-fa21d299e666c3b9862e2e96cf1c4bacc3675c6b.zip
gdb-fa21d299e666c3b9862e2e96cf1c4bacc3675c6b.tar.gz
gdb-fa21d299e666c3b9862e2e96cf1c4bacc3675c6b.tar.bz2
Pass GCC -W...
Diffstat (limited to 'sim/common/sim-assert.h')
-rw-r--r--sim/common/sim-assert.h77
1 files changed, 46 insertions, 31 deletions
diff --git a/sim/common/sim-assert.h b/sim/common/sim-assert.h
index 2d6a3d7..40d0883 100644
--- a/sim/common/sim-assert.h
+++ b/sim/common/sim-assert.h
@@ -22,48 +22,63 @@
#ifndef _SIM_ASSERT_H_
#define _SIM_ASSERT_H_
-# if defined (WITH_ASSERT)
+#define SIM_FILTER_PATH(FILE, PATH) \
+do \
+ { \
+ /* strip leading path */ \
+ const char *p = (PATH); \
+ (FILE) = p; \
+ while (*p != '\0' && *p != ':') \
+ { \
+ if (*p == '/') \
+ (FILE) = p; \
+ p++; \
+ } \
+ } \
+while (0)
+
+/* The subtle difference between SIM_ASSERT and ASSERT is that
+ SIM_ASSERT passes `sd' to sim_io_error for the SIM_DESC,
+ ASSERT passes NULL. */
+
+#if defined (WITH_ASSERT)
#define SIM_ASSERT(EXPRESSION) \
-do { \
- if (WITH_ASSERT) { \
- if (!(EXPRESSION)) { \
- /* strip leading path */ \
- const char *file = __FILE__; \
- const char *p = file; \
- while (*p != '\0' && *p != ':') { \
- if (*p == '/') \
- file = p; \
- p++; \
+do \
+ { \
+ if (WITH_ASSERT) \
+ { \
+ if (!(EXPRESSION)) \
+ { \
+ /* report the failure */ \
+ const char *file; \
+ SIM_FILTER_PATH(file, __FILE__); \
+ sim_io_error (sd, "%s:%d: assertion failed - %s", \
+ file, __LINE__, #EXPRESSION); \
+ } \
} \
- /* report the failure */ \
- sim_io_error (sd, "%s:%d: assertion failed - %s", \
- file, __LINE__, #EXPRESSION); \
- } \
} \
-} while (0)
+while (0)
#else
#define SIM_ASSERT(EXPRESSION) do { /*nothing*/; } while (0)
#endif
#if defined (WITH_ASSERT)
#define ASSERT(EXPRESSION) \
-do { \
- if (WITH_ASSERT) { \
- if (!(EXPRESSION)) { \
- /* strip leading path */ \
- const char *file = __FILE__; \
- const char *p = file; \
- while (*p != '\0' && *p != ':') { \
- if (*p == '/') \
- file = p; \
- p++; \
+do \
+ { \
+ if (WITH_ASSERT) \
+ { \
+ if (!(EXPRESSION)) \
+ { \
+ /* report the failure */ \
+ const char *file; \
+ SIM_FILTER_PATH(file, __FILE__); \
+ sim_io_error (NULL, "%s:%d: assertion failed - %s", \
+ file, __LINE__, #EXPRESSION); \
+ } \
} \
- /* report the failure */ \
- sim_io_error (NULL, "%s:%d: assertion failed - %s", \
- file, __LINE__, #EXPRESSION); \
- } \
} \
-} while (0)
+while (0)
#else
#define ASSERT(EXPRESSION) do { /*nothing*/; } while (0)
#endif