commit 8fd03dde7bde0ce39b4113390a96c0fbbcf6a03c
Author: Mark Glines <mark@glines.org>
Date: Sat Jan 3 09:20:07 2009 -0800
Convert PARROT_ASSERT_ARG() to a macro-only solution, inline functions
are not C89. Hopefully this will fix darwin and msvc.
diff --git a/include/parrot/exceptions.h b/include/parrot/exceptions.h
index 0b6763b..3f70952 100644
|
a
|
b
|
|
| 267 | 267 | |
| 268 | 268 | #define PANIC(interp, message) do_panic((interp), (message), __FILE__, __LINE__) |
| 269 | 269 | |
| | 270 | /* having a modified version of PARROT_ASSERT which resolves as an integer |
| | 271 | * rvalue lets us put ASSERT_ARGS() at the top of the list of local variables. |
| | 272 | * Thus, we can catch bad pointers before any of the local initialization |
| | 273 | * logic is run. And it always returns 0, so headerizer can chain them in |
| | 274 | * ASSERT_ARGS_* macros like: |
| | 275 | * int _ASSERT_ARGS = PARROT_ASSERT_ARG(a) || PARROT_ASSERT_ARG(b) || ... |
| | 276 | */ |
| 270 | 277 | #ifdef NDEBUG |
| 271 | 278 | # define PARROT_ASSERT(x) ((void)0) |
| | 279 | # define PARROT_ASSERT_ARG(x) (0) |
| 272 | 280 | #else |
| 273 | 281 | # define PARROT_ASSERT(x) (x) ? ((void)0) : Parrot_confess(#x, __FILE__, __LINE__) |
| | 282 | # define PARROT_ASSERT_ARG(x) ((x) ? (0) : (Parrot_confess(#x, __FILE__, __LINE__), 0)) |
| 274 | 283 | #endif |
| 275 | 284 | |
| 276 | | /* having a function version of this lets us put ASSERT_ARGS() at the top |
| 277 | | * of the list of local variables. Thus, we can catch bad pointers before |
| 278 | | * any of the local initialization logic is run. And it always returns 0, |
| 279 | | * so headerizer can define the ASSERT_ARGS_* macros like: |
| 280 | | * int _ASSERT_ARGS = PARROT_ASSERT_ARG(a) || PARROT_ASSERT_ARG(b) || ... |
| 281 | | */ |
| 282 | | static inline int |
| 283 | | _PARROT_ASSERT_ARG(const volatile void *x, const char *name, |
| 284 | | const char *file, unsigned int line) /* HEADERIZER SKIP */ |
| 285 | | { |
| 286 | | #ifndef NDEBUG |
| 287 | | if (!x) Parrot_confess(name, file, line); |
| 288 | | #endif |
| 289 | | return 0; |
| 290 | | } |
| 291 | | #define PARROT_ASSERT_ARG(x) _PARROT_ASSERT_ARG((x), (#x), __FILE__, __LINE__) |
| 292 | 285 | #define ASSERT_ARGS(a) ASSERT_ARGS_ ## a |
| 293 | 286 | |
| 294 | 287 | |