From 3736a011cd396b9ff745b79a15f25ec820498afd Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Mon, 17 Sep 2018 02:54:58 -0700 Subject: [PATCH] Wrap assertion strings, for configuration by host. --- ldid.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/ldid.cpp b/ldid.cpp index 5f4c473..f569dc0 100644 --- a/ldid.cpp +++ b/ldid.cpp @@ -94,23 +94,27 @@ #define _assert__(line) \ _assert___(line) +#ifndef $ +#define $(value) value +#endif + #ifdef __EXCEPTIONS #define _assert_(expr, format, ...) \ do if (!(expr)) { \ - fprintf(stderr, "%s(%u): _assert(): " format "\n", __FILE__, __LINE__, ## __VA_ARGS__); \ - throw __FILE__ "(" _assert__(__LINE__) "): _assert(" #expr ")"; \ + fprintf(stderr, $("%s(%u): _assert(): " format "\n"), __FILE__, __LINE__, ## __VA_ARGS__); \ + throw $(__FILE__ "(" _assert__(__LINE__) "): _assert(" #expr ")"); \ } while (false) #else // XXX: this is not acceptable #define _assert_(expr, format, ...) \ do if (!(expr)) { \ - fprintf(stderr, "%s(%u): _assert(): " format "\n", __FILE__, __LINE__, ## __VA_ARGS__); \ + fprintf(stderr, $("%s(%u): _assert(): " format "\n"), __FILE__, __LINE__, ## __VA_ARGS__); \ exit(-1); \ } while (false) #endif #define _assert(expr) \ - _assert_(expr, "%s", #expr) + _assert_(expr, "%s", $(#expr)) #define _syscall(expr, ...) [&] { for (;;) { \ auto _value(expr); \ @@ -127,7 +131,7 @@ } }() #define _trace() \ - fprintf(stderr, "_trace(%s:%u): %s\n", __FILE__, __LINE__, __FUNCTION__) + fprintf(stderr, $("_trace(%s:%u): %s\n"), __FILE__, __LINE__, $(__FUNCTION__)) #define _not(type) \ ((type) ~ (type) 0) -- 2.45.2