pgbackrest.git / summary / log / commit / refs

commit    e18b70bf555de24ba38d7c51f9d0ffbe8a02a355
Author:   David Steele <david@pgmasters.net>
Date:     Thu Apr 21 11:45:59 2022 +0000

    Allow *RETURN*() macros to accept struct initializers.
    
    Struct initializers look like multiple parameters in a macro so use __VA_ARGS__ to reconstruct them.


src/common/debug.h | 40 ++++++++++++++++++++-------------------- test/src/common/harnessDebug.h | 8 ++++---- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/common/debug.h b/src/common/debug.h index 9f2d81afd..61a70d89c 100644 --- a/src/common/debug.h +++ b/src/common/debug.h @@ -215,10 +215,10 @@ size_t typeToLog(const char *typeName, char *buffer, size_t bufferSize); /*********************************************************************************************************************************** Macros to return function results (or void) ***********************************************************************************************************************************/ -#define FUNCTION_LOG_RETURN_BASE(typePre, typeMacroPrefix, typePost, result) \ +#define FUNCTION_LOG_RETURN_BASE(typePre, typeMacroPrefix, typePost, ...) \ do \ { \ - typePre FUNCTION_LOG_##typeMacroPrefix##_TYPE typePost FUNCTION_LOG_RETURN_result = result; \ + typePre FUNCTION_LOG_##typeMacroPrefix##_TYPE typePost FUNCTION_LOG_RETURN_result = __VA_ARGS__; \ \ STACK_TRACE_POP(false); \ \ @@ -234,25 +234,25 @@ Macros to return function results (or void) } \ while (0) -#define FUNCTION_LOG_RETURN(typeMacroPrefix, result) \ - FUNCTION_LOG_RETURN_BASE(, typeMacroPrefix, , result) +#define FUNCTION_LOG_RETURN(typeMacroPrefix, ...) \ + FUNCTION_LOG_RETURN_BASE(, typeMacroPrefix, , __VA_ARGS__) -#define FUNCTION_LOG_RETURN_P(typeMacroPrefix, result) \ - FUNCTION_LOG_RETURN_BASE(, typeMacroPrefix, *, result) +#define FUNCTION_LOG_RETURN_P(typeMacroPrefix, ...) \ + FUNCTION_LOG_RETURN_BASE(, typeMacroPrefix, *, __VA_ARGS__) -#define FUNCTION_LOG_RETURN_PP(typeMacroPrefix, result) \ - FUNCTION_LOG_RETURN_BASE(, typeMacroPrefix, **, result) +#define FUNCTION_LOG_RETURN_PP(typeMacroPrefix, ...) \ + FUNCTION_LOG_RETURN_BASE(, typeMacroPrefix, **, __VA_ARGS__) -#define FUNCTION_LOG_RETURN_CONST(typeMacroPrefix, result) \ - FUNCTION_LOG_RETURN_BASE(const, typeMacroPrefix, , result) +#define FUNCTION_LOG_RETURN_CONST(typeMacroPrefix, ...) \ + FUNCTION_LOG_RETURN_BASE(const, typeMacroPrefix, , __VA_ARGS__) -#define FUNCTION_LOG_RETURN_CONST_P(typeMacroPrefix, result) \ - FUNCTION_LOG_RETURN_BASE(const, typeMacroPrefix, *, result) +#define FUNCTION_LOG_RETURN_CONST_P(typeMacroPrefix, ...) \ + FUNCTION_LOG_RETURN_BASE(const, typeMacroPrefix, *, __VA_ARGS__) -#define FUNCTION_LOG_RETURN_CONST_PP(typeMacroPrefix, result) \ - FUNCTION_LOG_RETURN_BASE(const, typeMacroPrefix, **, result) +#define FUNCTION_LOG_RETURN_CONST_PP(typeMacroPrefix, ...) \ + FUNCTION_LOG_RETURN_BASE(const, typeMacroPrefix, **, __VA_ARGS__) -#define FUNCTION_LOG_RETURN_STRUCT(result) \ +#define FUNCTION_LOG_RETURN_STRUCT(...) \ do \ { \ STACK_TRACE_POP(false); \ @@ -260,7 +260,7 @@ Macros to return function results (or void) IF_LOG_ANY(FUNCTION_LOG_LEVEL()) \ LOG_FMT(FUNCTION_LOG_LEVEL(), 0, "=> struct"); \ \ - return result; \ + return __VA_ARGS__; \ } \ while (0) @@ -327,14 +327,14 @@ Ignore DEBUG_TEST_TRACE_MACRO if DEBUG is not defined because the underlying fun FUNCTION_TEST_BEGIN(); \ FUNCTION_TEST_END(); - #define FUNCTION_TEST_RETURN(result) \ + #define FUNCTION_TEST_RETURN(...) \ do \ { \ /* CHECK for presense of FUNCTION_TEST_BEGIN*() */ \ (void)FUNCTION_TEST_BEGIN_exists; \ \ STACK_TRACE_POP(true); \ - return result; \ + return __VA_ARGS__; \ } \ while (0) @@ -355,8 +355,8 @@ Ignore DEBUG_TEST_TRACE_MACRO if DEBUG is not defined because the underlying fun #define FUNCTION_TEST_PARAM_PP(typeMacroPrefix, param) #define FUNCTION_TEST_END() #define FUNCTION_TEST_VOID() - #define FUNCTION_TEST_RETURN(result) \ - return result + #define FUNCTION_TEST_RETURN(...) \ + return __VA_ARGS__ #define FUNCTION_TEST_RETURN_VOID() \ return #endif // DEBUG_TEST_TRACE_MACRO diff --git a/test/src/common/harnessDebug.h b/test/src/common/harnessDebug.h index 2b80b30a6..1ace19610 100644 --- a/test/src/common/harnessDebug.h +++ b/test/src/common/harnessDebug.h @@ -50,11 +50,11 @@ C Debug Harness } \ while (0) - #define FUNCTION_HARNESS_RETURN(typeMacroPrefix, result) \ + #define FUNCTION_HARNESS_RETURN(typeMacroPrefix, ...) \ do \ { \ STACK_TRACE_POP(false); \ - return result; \ + return __VA_ARGS__; \ } \ while (0) @@ -71,8 +71,8 @@ C Debug Harness #define FUNCTION_HARNESS_VOID() #define FUNCTION_HARNESS_ASSERT(condition) - #define FUNCTION_HARNESS_RETURN(typeMacroPrefix, result) \ - return result + #define FUNCTION_HARNESS_RETURN(typeMacroPrefix, ...) \ + return __VA_ARGS__ #define FUNCTION_HARNESS_RETURN_VOID(); #endif [parent: ea4d73f37555]