File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -138,6 +138,17 @@ static const secp256k1_callback default_error_callback = {
138138#define EXPECT (x ,c ) (x)
139139#endif
140140
141+ /* Fallback for function name in pre-C99 */
142+ #if defined(__cplusplus ) && !defined(FUNC_NAME )
143+ #define FUNC_NAME __FUNCTION__
144+ #elif !defined(FUNC_NAME )
145+ #ifdef __func__
146+ #define FUNC_NAME __func__
147+ #else
148+ #define FUNC_NAME "(unknown function)"
149+ #endif
150+ #endif
151+
141152#ifdef DETERMINISTIC
142153#define CHECK (cond ) do { \
143154 if (EXPECT(!(cond), 0)) { \
@@ -147,7 +158,11 @@ static const secp256k1_callback default_error_callback = {
147158#else
148159#define CHECK (cond ) do { \
149160 if (EXPECT(!(cond), 0)) { \
150- TEST_FAILURE("test condition failed: " #cond); \
161+ char err_buf[256]; \
162+ int buf_pos = sprintf(err_buf, "test condition failed: %s in ", #cond); \
163+ strncpy(err_buf + buf_pos, FUNC_NAME, sizeof(err_buf) - buf_pos - 1); \
164+ err_buf[sizeof(err_buf) - 1] = '\0'; \
165+ TEST_FAILURE(err_buf); \
151166 } \
152167} while(0)
153168#endif
You can’t perform that action at this time.
0 commit comments