Ticket #125: convert_to_a_macro-only_solution.patch

File convert_to_a_macro-only_solution.patch, 2.0 KB (added by Infinoid, 6 years ago)

updated patch with an extra set of parens, to solve an operator precedence issue (it built fine, but wasn't catching failures properly).

  • include/parrot/exceptions.h

    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  
    267267 
    268268#define PANIC(interp, message) do_panic((interp), (message), __FILE__, __LINE__) 
    269269 
     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 */ 
    270277#ifdef NDEBUG 
    271278#  define PARROT_ASSERT(x) ((void)0) 
     279#  define PARROT_ASSERT_ARG(x) (0) 
    272280#else 
    273281#  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)) 
    274283#endif 
    275284 
    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__) 
    292285#define ASSERT_ARGS(a) ASSERT_ARGS_ ## a 
    293286 
    294287