From 5d4f0faaaf5ce8b78f26f1cb9a1c0753ba303953 Mon Sep 17 00:00:00 2001 From: Vicente Eduardo Ferrer Garcia Date: Thu, 5 Oct 2023 16:55:29 +0200 Subject: [PATCH] Change macro newline alignement. --- .clang-format | 2 +- source/adt/include/adt/adt_string.h | 11 +- source/adt/include/adt/adt_vector.h | 40 +++---- .../source/cli_core_plugin.cpp | 2 +- .../dynlink/include/dynlink/dynlink_flags.h | 12 +- .../dynlink/dynlink_impl_symbol_beos.h | 4 +- .../dynlink/dynlink_impl_symbol_macos.h | 4 +- .../dynlink/dynlink_impl_symbol_unix.h | 4 +- .../dynlink/dynlink_impl_symbol_win32.h | 6 +- .../environment/environment_variable_path.h | 8 +- .../source/environment_variable_path.c | 8 +- source/format/include/format/format_print.h | 6 +- .../format/include/format/format_specifier.h | 48 ++++---- source/loader/source/loader_impl.c | 2 +- .../file_loader/source/file_loader_impl.c | 12 +- .../node_loader/source/node_loader_impl.cpp | 6 +- .../node_loader/source/node_loader_port.cpp | 31 +++--- .../source/node_loader_trampoline.cpp | 4 +- .../loaders/rb_loader/source/rb_loader_impl.c | 36 +++--- source/log/include/log/log_preprocessor.h | 8 +- source/log/source/log_policy_format_text.c | 6 +- source/log/source/log_policy_stream_syslog.c | 10 +- .../metacall/include/metacall/metacall_fork.h | 6 +- source/metacall/source/metacall_fork.c | 12 +- .../portability/portability_executable_path.h | 4 +- .../include/portability/portability_path.h | 14 +-- .../source/portability_executable_path.c | 2 +- .../source/portability_library_path.c | 4 +- source/portability/source/portability_path.c | 6 +- .../reflect/reflect_class_visibility.h | 4 +- .../include/reflect/reflect_memory_tracker.h | 80 +++++++------- .../reflect/source/reflect_class_visibility.c | 4 +- .../source/metacall_fork_test.cpp | 2 +- .../source/node_extension_test.c | 4 +- .../source/metacall_sandbox_plugin_test.cpp | 4 +- .../metacall_test/source/metacall_test.cpp | 12 +- .../threading/threading_atomic_win32.h | 104 +++++++++--------- .../include/threading/threading_mutex.h | 8 +- 38 files changed, 265 insertions(+), 275 deletions(-) diff --git a/.clang-format b/.clang-format index a3ebb75c1..bffce04a3 100644 --- a/.clang-format +++ b/.clang-format @@ -5,7 +5,7 @@ AlignAfterOpenBracket: DontAlign AlignConsecutiveBitFields: true # AlignConsecutiveDeclarations: false AlignConsecutiveMacros: true -# AlignEscapedNewlines: Right +AlignEscapedNewlines: DontAlign # AlignOperands: true AlignTrailingComments: true AllowAllParametersOfDeclarationOnNextLine: false diff --git a/source/adt/include/adt/adt_string.h b/source/adt/include/adt/adt_string.h index 903acbbd1..ebb634422 100644 --- a/source/adt/include/adt/adt_string.h +++ b/source/adt/include/adt/adt_string.h @@ -35,13 +35,12 @@ extern "C" { /* -- Macros -- */ /* This is a temporary solution for safe strings, it can be improved in the future */ -#define string_copy(dest, src, dest_size) \ - do \ - { \ +#define string_copy(dest, src, dest_size) \ + do \ + { \ size_t __string_copy_length = strnlen(src, dest_size - 1); \ - memcpy(dest, src, __string_copy_length); \ - dest[__string_copy_length] = '\0'; \ - \ + memcpy(dest, src, __string_copy_length); \ + dest[__string_copy_length] = '\0'; \ } while (0) #ifdef __cplusplus diff --git a/source/adt/include/adt/adt_vector.h b/source/adt/include/adt/adt_vector.h index d839b2b8d..3399b1f60 100644 --- a/source/adt/include/adt/adt_vector.h +++ b/source/adt/include/adt/adt_vector.h @@ -205,13 +205,11 @@ typedef struct vector_type *vector; * @param[in] type_name * Type of element to be modified */ -#define vector_set_const(v, position, constant, type_name) \ - do \ - { \ - type_name macro_vector_type_const_to_var = constant; \ - \ +#define vector_set_const(v, position, constant, type_name) \ + do \ + { \ + type_name macro_vector_type_const_to_var = constant; \ vector_set(v, position, ¯o_vector_type_const_to_var); \ - \ } while (0) /** @@ -228,13 +226,11 @@ typedef struct vector_type *vector; * @param[in] type_name * Type of element to be inserted */ -#define vector_push_back_const(v, constant, type_name) \ - do \ - { \ - type_name macro_vector_type_const_to_var = constant; \ - \ +#define vector_push_back_const(v, constant, type_name) \ + do \ + { \ + type_name macro_vector_type_const_to_var = constant; \ vector_push_back(v, ¯o_vector_type_const_to_var); \ - \ } while (0) /** @@ -251,13 +247,11 @@ typedef struct vector_type *vector; * @param[in] type_name * Type of element to be inserted */ -#define vector_push_front_const(v, constant, type_name) \ - do \ - { \ - type_name macro_vector_type_const_to_var = constant; \ - \ +#define vector_push_front_const(v, constant, type_name) \ + do \ + { \ + type_name macro_vector_type_const_to_var = constant; \ vector_push_front(v, ¯o_vector_type_const_to_var); \ - \ } while (0) /** @@ -279,13 +273,11 @@ typedef struct vector_type *vector; * @param[in] type_name * Type of element to be inserted */ -#define vector_insert_const(v, position, constant, type_name) \ - do \ - { \ - type_name macro_vector_type_const_to_var = constant; \ - \ +#define vector_insert_const(v, position, constant, type_name) \ + do \ + { \ + type_name macro_vector_type_const_to_var = constant; \ vector_insert(v, position, ¯o_vector_type_const_to_var); \ - \ } while (0) /* -- Methods -- */ diff --git a/source/cli/plugins/cli_core_plugin/source/cli_core_plugin.cpp b/source/cli/plugins/cli_core_plugin/source/cli_core_plugin.cpp index a308fce68..ecc7d5757 100644 --- a/source/cli/plugins/cli_core_plugin/source/cli_core_plugin.cpp +++ b/source/cli/plugins/cli_core_plugin/source/cli_core_plugin.cpp @@ -20,7 +20,7 @@ #include -#include +#include #include diff --git a/source/dynlink/include/dynlink/dynlink_flags.h b/source/dynlink/include/dynlink/dynlink_flags.h index 77060053a..3c94c4026 100644 --- a/source/dynlink/include/dynlink/dynlink_flags.h +++ b/source/dynlink/include/dynlink/dynlink_flags.h @@ -58,9 +58,9 @@ extern "C" { * */ #define DYNLINK_FLAGS_SET(flags, flag) \ - do \ - { \ - flags = (flag); \ + do \ + { \ + flags = (flag); \ } while (0) /** @@ -83,9 +83,9 @@ extern "C" { * */ #define DYNLINK_FLAGS_ADD(flags, flag) \ - do \ - { \ - flags |= (flag); \ + do \ + { \ + flags |= (flag); \ } while (0) /** diff --git a/source/dynlink/include/dynlink/dynlink_impl_symbol_beos.h b/source/dynlink/include/dynlink/dynlink_impl_symbol_beos.h index 1c50340e9..33fcbac2b 100644 --- a/source/dynlink/include/dynlink/dynlink_impl_symbol_beos.h +++ b/source/dynlink/include/dynlink/dynlink_impl_symbol_beos.h @@ -36,9 +36,9 @@ extern "C" { /* -- Macros -- */ -#define DYNLINK_SYMBOL_EXPORT(name) \ +#define DYNLINK_SYMBOL_EXPORT(name) \ DYNLINK_API struct dynlink_symbol_addr_beos_type DYNLINK_SYMBOL_NAME(name) = { \ - (dynlink_symbol_addr_beos_impl)&name \ + (dynlink_symbol_addr_beos_impl)&name \ } #define DYNLINK_SYMBOL_GET(name) \ diff --git a/source/dynlink/include/dynlink/dynlink_impl_symbol_macos.h b/source/dynlink/include/dynlink/dynlink_impl_symbol_macos.h index a1198b08b..e06fa5f93 100644 --- a/source/dynlink/include/dynlink/dynlink_impl_symbol_macos.h +++ b/source/dynlink/include/dynlink/dynlink_impl_symbol_macos.h @@ -36,9 +36,9 @@ extern "C" { /* -- Macros -- */ -#define DYNLINK_SYMBOL_EXPORT(name) \ +#define DYNLINK_SYMBOL_EXPORT(name) \ DYNLINK_API struct dynlink_symbol_addr_macos_type DYNLINK_SYMBOL_NAME(name) = { \ - (dynlink_symbol_addr_macos_impl)&name \ + (dynlink_symbol_addr_macos_impl)&name \ } #define DYNLINK_SYMBOL_GET(name) \ diff --git a/source/dynlink/include/dynlink/dynlink_impl_symbol_unix.h b/source/dynlink/include/dynlink/dynlink_impl_symbol_unix.h index 9d4f38d40..7d4119eee 100644 --- a/source/dynlink/include/dynlink/dynlink_impl_symbol_unix.h +++ b/source/dynlink/include/dynlink/dynlink_impl_symbol_unix.h @@ -36,9 +36,9 @@ extern "C" { /* -- Macros -- */ -#define DYNLINK_SYMBOL_EXPORT(name) \ +#define DYNLINK_SYMBOL_EXPORT(name) \ DYNLINK_API struct dynlink_symbol_addr_unix_type DYNLINK_SYMBOL_NAME(name) = { \ - (dynlink_symbol_addr_unix_impl)&name \ + (dynlink_symbol_addr_unix_impl)&name \ } #define DYNLINK_SYMBOL_GET(name) \ diff --git a/source/dynlink/include/dynlink/dynlink_impl_symbol_win32.h b/source/dynlink/include/dynlink/dynlink_impl_symbol_win32.h index 769ada398..b1314824c 100644 --- a/source/dynlink/include/dynlink/dynlink_impl_symbol_win32.h +++ b/source/dynlink/include/dynlink/dynlink_impl_symbol_win32.h @@ -38,9 +38,9 @@ extern "C" { /* -- Macros -- */ #define DYNLINK_SYMBOL_EXPORT(name) \ - DYNLINK_NO_EXPORT struct \ - { \ - char name; \ + DYNLINK_NO_EXPORT struct \ + { \ + char name; \ } PREPROCESSOR_CONCAT(dynlink_no_export_, name) #define DYNLINK_SYMBOL_GET(name) name diff --git a/source/environment/include/environment/environment_variable_path.h b/source/environment/include/environment/environment_variable_path.h index 42e19ca58..402a2eeb0 100644 --- a/source/environment/include/environment/environment_variable_path.h +++ b/source/environment/include/environment/environment_variable_path.h @@ -35,15 +35,15 @@ extern "C" { /* -- Definitions -- */ -#if defined(WIN32) || defined(_WIN32) || \ +#if defined(WIN32) || defined(_WIN32) || \ defined(__CYGWIN__) || defined(__CYGWIN32__) || \ defined(__MINGW32__) || defined(__MINGW64__) #define ENVIRONMENT_VARIABLE_PATH_SEPARATOR_C '\\' #define ENVIRONMENT_VARIABLE_PATH_SEPARATOR_STR "\\" -#elif defined(unix) || defined(__unix__) || defined(__unix) || \ +#elif defined(unix) || defined(__unix__) || defined(__unix) || \ defined(linux) || defined(__linux__) || defined(__linux) || defined(__gnu_linux) || \ - defined(__CYGWIN__) || defined(__CYGWIN32__) || \ - (defined(__APPLE__) && defined(__MACH__)) || defined(__MACOSX__) || \ + defined(__CYGWIN__) || defined(__CYGWIN32__) || \ + (defined(__APPLE__) && defined(__MACH__)) || defined(__MACOSX__) || \ defined(__HAIKU__) || defined(__BEOS__) #define ENVIRONMENT_VARIABLE_PATH_SEPARATOR_C '/' #define ENVIRONMENT_VARIABLE_PATH_SEPARATOR_STR "/" diff --git a/source/environment/source/environment_variable_path.c b/source/environment/source/environment_variable_path.c index 1a7891dee..351db6994 100644 --- a/source/environment/source/environment_variable_path.c +++ b/source/environment/source/environment_variable_path.c @@ -27,14 +27,14 @@ /* -- Definitions -- */ -#if defined(WIN32) || defined(_WIN32) || \ +#if defined(WIN32) || defined(_WIN32) || \ defined(__CYGWIN__) || defined(__CYGWIN32__) || \ defined(__MINGW32__) || defined(__MINGW64__) #define ENVIRONMENT_VARIABLE_PATH_SEPARATOR(chr) (chr == '/' || chr == '\\') -#elif defined(unix) || defined(__unix__) || defined(__unix) || \ +#elif defined(unix) || defined(__unix__) || defined(__unix) || \ defined(linux) || defined(__linux__) || defined(__linux) || defined(__gnu_linux) || \ - defined(__CYGWIN__) || defined(__CYGWIN32__) || \ - (defined(__APPLE__) && defined(__MACH__)) || defined(__MACOSX__) || \ + defined(__CYGWIN__) || defined(__CYGWIN32__) || \ + (defined(__APPLE__) && defined(__MACH__)) || defined(__MACOSX__) || \ defined(__HAIKU__) || defined(__BEOS__) #define ENVIRONMENT_VARIABLE_PATH_SEPARATOR(chr) (chr == '/') #else diff --git a/source/format/include/format/format_print.h b/source/format/include/format/format_print.h index 31a4c777c..5bc3ec7e1 100644 --- a/source/format/include/format/format_print.h +++ b/source/format/include/format/format_print.h @@ -45,10 +45,10 @@ extern "C" { #ifndef vsnprintf #define vsnprintf _vsnprintf #endif -#elif (defined(_WIN32) && defined(_MSC_VER) && (_MSC_VER >= 1900)) || \ - defined(_BSD_SOURCE) || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 500) || \ +#elif (defined(_WIN32) && defined(_MSC_VER) && (_MSC_VER >= 1900)) || \ + defined(_BSD_SOURCE) || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 500) || \ defined(_ISOC99_SOURCE) || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L) || \ - defined(__HAIKU__) || defined(__BEOS__) || \ + defined(__HAIKU__) || defined(__BEOS__) || \ (defined(__APPLE__) && defined(__MACH__)) || defined(__MACOSX__) /* Supported */ diff --git a/source/format/include/format/format_specifier.h b/source/format/include/format/format_specifier.h index 8a83081c9..2d51d9c3c 100644 --- a/source/format/include/format/format_specifier.h +++ b/source/format/include/format/format_specifier.h @@ -34,10 +34,10 @@ extern "C" { #include #include -#if !defined(_WIN32) && \ - (defined(unix) || defined(__unix__) || defined(__unix) || \ +#if !defined(_WIN32) && \ + (defined(unix) || defined(__unix__) || defined(__unix) || \ defined(linux) || defined(__linux__) || defined(__linux) || defined(__gnu_linux) || \ - defined(__CYGWIN__) || defined(__CYGWIN32__) || \ + defined(__CYGWIN__) || defined(__CYGWIN32__) || \ (defined(__APPLE__) && defined(__MACH__)) || defined(__MACOSX__)) #include @@ -59,31 +59,31 @@ extern "C" { /* -- Definitions -- */ -#if defined(__LP64__) || defined(_LP64) || \ - defined(_WIN64) || \ +#if defined(__LP64__) || defined(_LP64) || \ + defined(_WIN64) || \ defined(alpha) || defined(__ALPHA) || defined(__alpha) || defined(__alpha__) || defined(_M_ALPHA) || \ - defined(_IA64) || defined(__IA64__) || defined(__ia64__) || defined(__ia64) || defined(_M_IA64) || \ - defined(__x86_64__) || defined(_M_X64) || defined(_M_AMD64) || defined(__amd64) || \ - defined(__mips64) || \ - defined(__powerpc64__) || defined(__ppc64__) || defined(_ARCH_PPC64) || \ - defined(__arch64__) || defined(__sparcv9) || defined(__sparc_v9__) || defined(__sparc64__) || \ + defined(_IA64) || defined(__IA64__) || defined(__ia64__) || defined(__ia64) || defined(_M_IA64) || \ + defined(__x86_64__) || defined(_M_X64) || defined(_M_AMD64) || defined(__amd64) || \ + defined(__mips64) || \ + defined(__powerpc64__) || defined(__ppc64__) || defined(_ARCH_PPC64) || \ + defined(__arch64__) || defined(__sparcv9) || defined(__sparc_v9__) || defined(__sparc64__) || \ defined(__s390__) || defined(__s390x__) #define FORMAT_64BIT 1 /* 64-bit */ -#elif defined(_ILP32) || defined(__ILP32__) || \ - defined(_WIN32) || \ - defined(__386__) || defined(i386) || defined(__i386) || defined(__i386__) || defined(__X86) || defined(_M_IX86) || \ - defined(__mips__) || defined(__mips) || defined(__MIPS__) || defined(_M_MRX000) || \ - defined(__hppa) || defined(__hppa__) || \ - ((defined(__PPC) || defined(__POWERPC__) || defined(__powerpc) || defined(__powerpc64__) || defined(__PPC__) || \ - defined(__powerpc__) || defined(__ppc__) || defined(__ppc) || defined(_ARCH_PPC) || defined(_M_PPC)) && \ - !defined(__powerpc64__)) || \ - (defined(_ARCH_COM) && defined(_ARCH_PPC)) || \ +#elif defined(_ILP32) || defined(__ILP32__) || \ + defined(_WIN32) || \ + defined(__386__) || defined(i386) || defined(__i386) || defined(__i386__) || defined(__X86) || defined(_M_IX86) || \ + defined(__mips__) || defined(__mips) || defined(__MIPS__) || defined(_M_MRX000) || \ + defined(__hppa) || defined(__hppa__) || \ + ((defined(__PPC) || defined(__POWERPC__) || defined(__powerpc) || defined(__powerpc64__) || defined(__PPC__) || \ + defined(__powerpc__) || defined(__ppc__) || defined(__ppc) || defined(_ARCH_PPC) || defined(_M_PPC)) && \ + !defined(__powerpc64__)) || \ + (defined(_ARCH_COM) && defined(_ARCH_PPC)) || \ ((defined(__sparc__) || defined(__sparc) || defined(sparc)) && !(defined(__arch64__) || defined(__sparcv9) || defined(__sparc_v9__) || defined(__sparc64__))) || \ - defined(__arm__) || defined(__arm) || defined(ARM) || defined(_ARM) || defined(_ARM_) || defined(__ARM__) || defined(_M_ARM) || \ - defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \ - defined(__sh__) || defined(__sh) || defined(SHx) || defined(_SHX_) || \ + defined(__arm__) || defined(__arm) || defined(ARM) || defined(_ARM) || defined(_ARM_) || defined(__ARM__) || defined(_M_ARM) || \ + defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \ + defined(__sh__) || defined(__sh) || defined(SHx) || defined(_SHX_) || \ defined(nios2) || defined(__nios2) || defined(__nios2__) #define FORMAT_32BIT 1 /* 32-bit */ @@ -94,8 +94,8 @@ extern "C" { #if defined(_WIN32) && defined(_MSC_VER) && (_MSC_VER < 1900) #define FORMAT_PREFIX "I" -#elif defined(FORMAT_32BIT) || \ - (defined(_WIN32) && defined(_MSC_VER) && (_MSC_VER >= 1900)) || \ +#elif defined(FORMAT_32BIT) || \ + (defined(_WIN32) && defined(_MSC_VER) && (_MSC_VER >= 1900)) || \ defined(_BSD_SOURCE) || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 500) || \ defined(_ISOC99_SOURCE) || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L) #define FORMAT_PREFIX "z" diff --git a/source/loader/source/loader_impl.c b/source/loader/source/loader_impl.c index f35f0714b..bb99f66cc 100644 --- a/source/loader/source/loader_impl.c +++ b/source/loader/source/loader_impl.c @@ -49,7 +49,7 @@ #define LOADER_IMPL_FUNCTION_INIT "__metacall_initialize__" #define LOADER_IMPL_FUNCTION_FINI "__metacall_finalize__" -#if defined(WIN32) || defined(_WIN32) || \ +#if defined(WIN32) || defined(_WIN32) || \ defined(__CYGWIN__) || defined(__CYGWIN32__) || \ defined(__MINGW32__) || defined(__MINGW64__) diff --git a/source/loaders/file_loader/source/file_loader_impl.c b/source/loaders/file_loader/source/file_loader_impl.c index 4ef87e5ed..a3a73289b 100644 --- a/source/loaders/file_loader/source/file_loader_impl.c +++ b/source/loaders/file_loader/source/file_loader_impl.c @@ -53,10 +53,10 @@ typedef struct _stat file_stat_type; #define file_stat _stat -#elif defined(unix) || defined(__unix__) || defined(__unix) || \ +#elif defined(unix) || defined(__unix__) || defined(__unix) || \ defined(linux) || defined(__linux__) || defined(__linux) || defined(__gnu_linux) || \ - defined(__CYGWIN__) || defined(__CYGWIN32__) || \ - defined(__MINGW32__) || defined(__MINGW64__) || \ + defined(__CYGWIN__) || defined(__CYGWIN32__) || \ + defined(__MINGW32__) || defined(__MINGW64__) || \ (defined(__APPLE__) && defined(__MACH__)) || defined(__MACOSX__) #include @@ -68,10 +68,10 @@ typedef struct stat file_stat_type; #endif /* Support for glob, only in POSIX for now (TODO: Implement Windows support) */ -#if !defined(_WIN32) && \ - (defined(unix) || defined(__unix__) || defined(__unix) || \ +#if !defined(_WIN32) && \ + (defined(unix) || defined(__unix__) || defined(__unix) || \ defined(linux) || defined(__linux__) || defined(__linux) || defined(__gnu_linux) || \ - defined(__CYGWIN__) || defined(__CYGWIN32__) || \ + defined(__CYGWIN__) || defined(__CYGWIN32__) || \ (defined(__APPLE__) && defined(__MACH__)) || defined(__MACOSX__)) #include diff --git a/source/loaders/node_loader/source/node_loader_impl.cpp b/source/loaders/node_loader/source/node_loader_impl.cpp index b0d021665..1b0660c20 100644 --- a/source/loaders/node_loader/source/node_loader_impl.cpp +++ b/source/loaders/node_loader/source/node_loader_impl.cpp @@ -149,9 +149,9 @@ namespace node extern bool linux_at_secure; } -#define NODE_GET_EVENT_LOOP \ - (NAPI_VERSION >= 2) && \ - ((NODE_MAJOR_VERSION == 8 && NODE_MINOR_VERSION >= 10) || \ +#define NODE_GET_EVENT_LOOP \ + (NAPI_VERSION >= 2) && \ + ((NODE_MAJOR_VERSION == 8 && NODE_MINOR_VERSION >= 10) || \ (NODE_MAJOR_VERSION == 9 && NODE_MINOR_VERSION >= 3) || \ (NODE_MAJOR_VERSION >= 10)) diff --git a/source/loaders/node_loader/source/node_loader_port.cpp b/source/loaders/node_loader/source/node_loader_port.cpp index 168038a43..82cdc899e 100644 --- a/source/loaders/node_loader/source/node_loader_port.cpp +++ b/source/loaders/node_loader/source/node_loader_port.cpp @@ -796,26 +796,25 @@ napi_value node_loader_port_metacall_logs(napi_env env, napi_callback_info) // This functions sets the necessary js functions that could be called in NodeJs void node_loader_port_exports(napi_env env, napi_value exports) { -#define NODE_LOADER_PORT_DECL_FUNC(name) \ - do \ - { \ - const char PREPROCESSOR_CONCAT(function_str_, name)[] = PREPROCESSOR_STRINGIFY(name); \ - napi_value PREPROCESSOR_CONCAT(function_, name); \ +#define NODE_LOADER_PORT_DECL_FUNC(name) \ + do \ + { \ + const char PREPROCESSOR_CONCAT(function_str_, name)[] = PREPROCESSOR_STRINGIFY(name); \ + napi_value PREPROCESSOR_CONCAT(function_, name); \ napi_create_function(env, PREPROCESSOR_CONCAT(function_str_, name), sizeof(PREPROCESSOR_CONCAT(function_str_, name)) - 1, PREPROCESSOR_CONCAT(node_loader_port_, name), NULL, &PREPROCESSOR_CONCAT(function_, name)); \ - napi_set_named_property(env, exports, PREPROCESSOR_CONCAT(function_str_, name), PREPROCESSOR_CONCAT(function_, name)); \ - \ + napi_set_named_property(env, exports, PREPROCESSOR_CONCAT(function_str_, name), PREPROCESSOR_CONCAT(function_, name)); \ } while (0) -#define NODE_LOADER_PORT_DECL_X_MACRO(x) \ - x(metacall); \ - x(metacall_await); \ - x(metacall_load_from_file); \ - x(metacall_load_from_file_export); \ - x(metacall_load_from_memory); \ - x(metacall_load_from_memory_export); \ - x(metacall_load_from_configuration); \ +#define NODE_LOADER_PORT_DECL_X_MACRO(x) \ + x(metacall); \ + x(metacall_await); \ + x(metacall_load_from_file); \ + x(metacall_load_from_file_export); \ + x(metacall_load_from_memory); \ + x(metacall_load_from_memory_export); \ + x(metacall_load_from_configuration); \ x(metacall_load_from_configuration_export); \ - x(metacall_inspect); \ + x(metacall_inspect); \ x(metacall_logs); /* Declare all the functions */ diff --git a/source/loaders/node_loader/source/node_loader_trampoline.cpp b/source/loaders/node_loader/source/node_loader_trampoline.cpp index ceeae0606..15380ef50 100644 --- a/source/loaders/node_loader/source/node_loader_trampoline.cpp +++ b/source/loaders/node_loader/source/node_loader_trampoline.cpp @@ -12,8 +12,8 @@ #include /* TODO: Improve this trick */ #define NODE_LOADER_TRAMPOLINE_DECLARE_NAPI_METHOD(name, func) \ - { \ - name, 0, func, 0, 0, 0, napi_default, 0 \ + { \ + name, 0, func, 0, 0, 0, napi_default, 0 \ } typedef void *(*future_resolve_callback)(void *, void *); diff --git a/source/loaders/rb_loader/source/rb_loader_impl.c b/source/loaders/rb_loader/source/rb_loader_impl.c index 4e7ee73f0..0bd8fb194 100644 --- a/source/loaders/rb_loader/source/rb_loader_impl.c +++ b/source/loaders/rb_loader/source/rb_loader_impl.c @@ -67,14 +67,14 @@ #define rb_fiber_resume_kw(o, c, v, kw) rb_fiber_resume(o, c, v) #define rb_fiber_yield_kw(c, v, kw) rb_fiber_yield(c, v) #define rb_enumeratorize_with_size_kw(o, m, c, v, f, kw) rb_enumeratorize_with_size(o, m, c, v, f) - #define SIZED_ENUMERATOR_KW(obj, argc, argv, size_fn, kw_splat) \ + #define SIZED_ENUMERATOR_KW(obj, argc, argv, size_fn, kw_splat) \ rb_enumeratorize_with_size((obj), ID2SYM(rb_frame_this_func()), \ (argc), (argv), (size_fn)) #define RETURN_SIZED_ENUMERATOR_KW(obj, argc, argv, size_fn, kw_splat) \ - do \ - { \ - if (!rb_block_given_p()) \ - return SIZED_ENUMERATOR(obj, argc, argv, size_fn); \ + do \ + { \ + if (!rb_block_given_p()) \ + return SIZED_ENUMERATOR(obj, argc, argv, size_fn); \ } while (0) #define RETURN_ENUMERATOR_KW(obj, argc, argv, kw_splat) RETURN_SIZED_ENUMERATOR(obj, argc, argv, 0) #define rb_check_funcall_kw(o, m, c, v, kw) rb_check_funcall(o, m, c, v) @@ -378,20 +378,20 @@ static VALUE rb_loader_impl_funcallv_kw_protect(VALUE args) } /* TODO: Convert this into a return exception */ -#define rb_loader_impl_print_last_exception() \ - do \ - { \ - VALUE e = rb_errinfo(); \ - if (e != Qnil) \ - { \ - VALUE error; \ - VALUE bt = rb_funcall(e, rb_intern("backtrace"), 0); \ - VALUE msg = rb_funcall(e, rb_intern("message"), 0); \ - bt = rb_ary_entry(bt, 0); \ - error = rb_sprintf("%" PRIsVALUE ": %" PRIsVALUE " (%s)\n", bt, msg, rb_obj_classname(e)); \ +#define rb_loader_impl_print_last_exception() \ + do \ + { \ + VALUE e = rb_errinfo(); \ + if (e != Qnil) \ + { \ + VALUE error; \ + VALUE bt = rb_funcall(e, rb_intern("backtrace"), 0); \ + VALUE msg = rb_funcall(e, rb_intern("message"), 0); \ + bt = rb_ary_entry(bt, 0); \ + error = rb_sprintf("%" PRIsVALUE ": %" PRIsVALUE " (%s)\n", bt, msg, rb_obj_classname(e)); \ log_write("metacall", LOG_LEVEL_ERROR, "Exception raised in Ruby '%s'", RSTRING_PTR(error)); \ - rb_backtrace(); \ - } \ + rb_backtrace(); \ + } \ } while (0) function_return function_rb_interface_invoke(function func, function_impl impl, function_args args, size_t size) diff --git a/source/log/include/log/log_preprocessor.h b/source/log/include/log/log_preprocessor.h index cbdbe5cb8..621a2f2b5 100644 --- a/source/log/include/log/log_preprocessor.h +++ b/source/log/include/log/log_preprocessor.h @@ -43,13 +43,13 @@ extern "C" { #if (defined(__cplusplus) && (__cplusplus >= 201103L)) || \ (defined(__STDC__) && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) - #define log_write(name, level, ...) \ - PREPROCESSOR_IF(PREPROCESSOR_ARGS_EMPTY(__VA_ARGS__), \ + #define log_write(name, level, ...) \ + PREPROCESSOR_IF(PREPROCESSOR_ARGS_EMPTY(__VA_ARGS__), \ log_write_impl(name, LOG_PREPROCESSOR_LINE, log_record_function(), __FILE__, level, __VA_ARGS__), \ log_write_impl_va(name, LOG_PREPROCESSOR_LINE, log_record_function(), __FILE__, level, __VA_ARGS__)) #else - #define log_write(name, level, message, ...) \ - PREPROCESSOR_IF(PREPROCESSOR_ARGS_EMPTY(__VA_ARGS__), \ + #define log_write(name, level, message, ...) \ + PREPROCESSOR_IF(PREPROCESSOR_ARGS_EMPTY(__VA_ARGS__), \ log_write_impl(name, LOG_PREPROCESSOR_LINE, log_record_function(), __FILE__, level, message), \ log_write_impl_va(name, LOG_PREPROCESSOR_LINE, log_record_function(), __FILE__, level, message, __VA_ARGS__)) #endif diff --git a/source/log/source/log_policy_format_text.c b/source/log/source/log_policy_format_text.c index addbf6c6b..1a4648fe5 100644 --- a/source/log/source/log_policy_format_text.c +++ b/source/log/source/log_policy_format_text.c @@ -32,10 +32,10 @@ #define va_copy(dest, src) __va_copy((dest), (src)) #elif defined(__builtin_va_copy) #define va_copy(dest, src) __builtin_va_copy((dest), (src)) - #elif defined(_WIN32) || defined(_WIN64) || \ - defined(_ARCH_PPC) || defined(_POWER) || defined(powerpc) || defined(__powerpc) || \ + #elif defined(_WIN32) || defined(_WIN64) || \ + defined(_ARCH_PPC) || defined(_POWER) || defined(powerpc) || defined(__powerpc) || \ defined(__powerpc__) || defined(__PowerPC__) || defined(__POWERPC__) || defined(PPC) || \ - defined(__ppc__) || defined(__PPC) || defined(__PPC__) || \ + defined(__ppc__) || defined(__PPC) || defined(__PPC__) || \ defined(_ARCH_PPC64) || defined(__powerpc64__) || defined(__ppc64) || defined(__ppc64__) || defined(__PPC64__) /* Works for Microsoft x86, x64 and PowerPC-based platforms */ #define va_copy(dest, src) ((void)memcpy(&(dest), &(src), sizeof(va_list))) diff --git a/source/log/source/log_policy_stream_syslog.c b/source/log/source/log_policy_stream_syslog.c index 17fb6dade..f07edb6e0 100644 --- a/source/log/source/log_policy_stream_syslog.c +++ b/source/log/source/log_policy_stream_syslog.c @@ -26,7 +26,7 @@ #include #endif #elif defined(linux) || defined(__linux__) || defined(__linux) || defined(__gnu_linux) || \ - defined(__FreeBSD__) || \ + defined(__FreeBSD__) || \ (defined(__APPLE__) && defined(__MACH__)) || defined(__MACOSX__) #include #endif @@ -55,7 +55,7 @@ struct log_policy_stream_syslog_data_type #if defined(_WIN32) HANDLE handle; #elif defined(linux) || defined(__linux__) || defined(__linux) || defined(__gnu_linux) || \ - defined(__FreeBSD__) || \ + defined(__FreeBSD__) || \ (defined(__APPLE__) && defined(__MACH__)) || defined(__MACOSX__) /* ... */ #endif @@ -105,7 +105,7 @@ static int log_policy_stream_syslog_create(log_policy policy, const log_policy_c #if defined(_WIN32) syslog_data->handle = RegisterEventSource(NULL, syslog_data->name); #elif defined(linux) || defined(__linux__) || defined(__linux) || defined(__gnu_linux) || \ - defined(__FreeBSD__) || \ + defined(__FreeBSD__) || \ (defined(__APPLE__) && defined(__MACH__)) || defined(__MACOSX__) openlog(syslog_data->name, LOG_CONS | LOG_PID | LOG_NDELAY, LOG_USER); #endif @@ -133,7 +133,7 @@ static int log_policy_stream_syslog_write(log_policy policy, const void *buffer, LOG_POLICY_STREAM_SYSLOG_WIN_MSG, NULL, 1, 0, (LPTSTR *)lpt_str, NULL); #elif defined(linux) || defined(__linux__) || defined(__linux) || defined(__gnu_linux) || \ - defined(__FreeBSD__) || \ + defined(__FreeBSD__) || \ (defined(__APPLE__) && defined(__MACH__)) || defined(__MACOSX__) (void)syslog_data; @@ -162,7 +162,7 @@ static int log_policy_stream_syslog_destroy(log_policy policy) DeregisterEventSource(syslog_data->handle); } #elif defined(linux) || defined(__linux__) || defined(__linux) || defined(__gnu_linux) || \ - defined(__FreeBSD__) || \ + defined(__FreeBSD__) || \ (defined(__APPLE__) && defined(__MACH__)) || defined(__MACOSX__) closelog(); #endif diff --git a/source/metacall/include/metacall/metacall_fork.h b/source/metacall/include/metacall/metacall_fork.h index 9e9b7f0cc..d3a78eccc 100644 --- a/source/metacall/include/metacall/metacall_fork.h +++ b/source/metacall/include/metacall/metacall_fork.h @@ -29,7 +29,7 @@ extern "C" { #endif -#if defined(WIN32) || defined(_WIN32) || \ +#if defined(WIN32) || defined(_WIN32) || \ defined(__CYGWIN__) || defined(__CYGWIN32__) || \ defined(__MINGW32__) || defined(__MINGW64__) @@ -41,9 +41,9 @@ extern "C" { typedef int metacall_pid; -#elif defined(unix) || defined(__unix__) || defined(__unix) || \ +#elif defined(unix) || defined(__unix__) || defined(__unix) || \ defined(linux) || defined(__linux__) || defined(__linux) || defined(__gnu_linux) || \ - defined(__CYGWIN__) || defined(__CYGWIN32__) || \ + defined(__CYGWIN__) || defined(__CYGWIN32__) || \ (defined(__APPLE__) && defined(__MACH__)) || defined(__MACOSX__) /* -- Headers -- */ diff --git a/source/metacall/source/metacall_fork.c b/source/metacall/source/metacall_fork.c index 0e5eb60f4..2bfa05e6c 100644 --- a/source/metacall/source/metacall_fork.c +++ b/source/metacall/source/metacall_fork.c @@ -17,7 +17,7 @@ #include -#if defined(WIN32) || defined(_WIN32) || \ +#if defined(WIN32) || defined(_WIN32) || \ defined(__CYGWIN__) || defined(__CYGWIN32__) || \ defined(__MINGW32__) || defined(__MINGW64__) @@ -85,9 +85,9 @@ NTSTATUS NTAPI metacall_fork_hook(ULONG ProcessFlags, HANDLE DebugPort, PRTL_USER_PROCESS_INFORMATION ProcessInformation); -#elif defined(unix) || defined(__unix__) || defined(__unix) || \ +#elif defined(unix) || defined(__unix__) || defined(__unix) || \ defined(linux) || defined(__linux__) || defined(__linux) || defined(__gnu_linux) || \ - defined(__CYGWIN__) || defined(__CYGWIN32__) || \ + defined(__CYGWIN__) || defined(__CYGWIN32__) || \ (defined(__APPLE__) && defined(__MACH__)) || defined(__MACOSX__) /* -- Methods -- */ @@ -115,7 +115,7 @@ static int metacall_fork_flag = 1; /* -- Methods -- */ -#if defined(WIN32) || defined(_WIN32) || \ +#if defined(WIN32) || defined(_WIN32) || \ defined(__CYGWIN__) || defined(__CYGWIN32__) || \ defined(__MINGW32__) || defined(__MINGW64__) @@ -205,9 +205,9 @@ NTSTATUS NTAPI metacall_fork_hook(ULONG ProcessFlags, return result; } -#elif defined(unix) || defined(__unix__) || defined(__unix) || \ +#elif defined(unix) || defined(__unix__) || defined(__unix) || \ defined(linux) || defined(__linux__) || defined(__linux) || defined(__gnu_linux) || \ - defined(__CYGWIN__) || defined(__CYGWIN32__) || \ + defined(__CYGWIN__) || defined(__CYGWIN32__) || \ (defined(__APPLE__) && defined(__MACH__)) || defined(__MACOSX__) void (*metacall_fork_func(void))(void) diff --git a/source/portability/include/portability/portability_executable_path.h b/source/portability/include/portability/portability_executable_path.h index a1d5be8b8..0f1908d59 100644 --- a/source/portability/include/portability/portability_executable_path.h +++ b/source/portability/include/portability/portability_executable_path.h @@ -31,11 +31,11 @@ typedef char portability_executable_path_str[PORTABILITY_PATH_SIZE]; -#if defined(WIN32) || defined(_WIN32) || \ +#if defined(WIN32) || defined(_WIN32) || \ defined(__CYGWIN__) || defined(__CYGWIN32__) || \ defined(__MINGW32__) || defined(__MINGW64__) typedef DWORD portability_executable_path_length; -#elif defined(unix) || defined(__unix__) || defined(__unix) || \ +#elif defined(unix) || defined(__unix__) || defined(__unix) || \ defined(linux) || defined(__linux__) || defined(__linux) || defined(__gnu_linux) || \ defined(__NetBSD__) || defined(__DragonFly__) diff --git a/source/portability/include/portability/portability_path.h b/source/portability/include/portability/portability_path.h index 2421092ea..f8124edca 100644 --- a/source/portability/include/portability/portability_path.h +++ b/source/portability/include/portability/portability_path.h @@ -28,7 +28,7 @@ /* -- Definitions -- */ /* Path limits */ -#if defined(WIN32) || defined(_WIN32) || \ +#if defined(WIN32) || defined(_WIN32) || \ defined(__CYGWIN__) || defined(__CYGWIN32__) || \ defined(__MINGW32__) || defined(__MINGW64__) @@ -42,7 +42,7 @@ #include #define PORTABILITY_PATH_SIZE MAX_PATH -#elif defined(unix) || defined(__unix__) || defined(__unix) || \ +#elif defined(unix) || defined(__unix__) || defined(__unix) || \ defined(linux) || defined(__linux__) || defined(__linux) || defined(__gnu_linux) || \ defined(__NetBSD__) || defined(__DragonFly__) @@ -73,17 +73,17 @@ #endif /* Path separator */ -#if defined(WIN32) || defined(_WIN32) || \ +#if defined(WIN32) || defined(_WIN32) || \ defined(__CYGWIN__) || defined(__CYGWIN32__) || \ defined(__MINGW32__) || defined(__MINGW64__) #define PORTABILITY_PATH_SEPARATOR(chr) (chr == '\\' || chr == '/') #define PORTABILITY_PATH_SEPARATOR_C '/' -#elif defined(unix) || defined(__unix__) || defined(__unix) || \ +#elif defined(unix) || defined(__unix__) || defined(__unix) || \ defined(linux) || defined(__linux__) || defined(__linux) || defined(__gnu_linux) || \ - defined(__CYGWIN__) || defined(__CYGWIN32__) || \ - (defined(__APPLE__) && defined(__MACH__)) || defined(__MACOSX__) || \ + defined(__CYGWIN__) || defined(__CYGWIN32__) || \ + (defined(__APPLE__) && defined(__MACH__)) || defined(__MACOSX__) || \ defined(__HAIKU__) || defined(__BEOS__) #define PORTABILITY_PATH_SEPARATOR(chr) (chr == '/') #define PORTABILITY_PATH_SEPARATOR_C '/' @@ -93,7 +93,7 @@ #endif /* Path delimiter */ -#if defined(WIN32) || defined(_WIN32) || \ +#if defined(WIN32) || defined(_WIN32) || \ defined(__CYGWIN__) || defined(__CYGWIN32__) || \ defined(__MINGW32__) || defined(__MINGW64__) diff --git a/source/portability/source/portability_executable_path.c b/source/portability/source/portability_executable_path.c index ac07d1151..75cc306c8 100644 --- a/source/portability/source/portability_executable_path.c +++ b/source/portability/source/portability_executable_path.c @@ -35,7 +35,7 @@ int portability_executable_path(portability_executable_path_str path, portabilit /* Reset the path */ memset(path, 0, path_max_length); -#if defined(WIN32) || defined(_WIN32) || \ +#if defined(WIN32) || defined(_WIN32) || \ defined(__CYGWIN__) || defined(__CYGWIN32__) || \ defined(__MINGW32__) || defined(__MINGW64__) *length = GetModuleFileName(NULL, path, (DWORD)path_max_length); diff --git a/source/portability/source/portability_library_path.c b/source/portability/source/portability_library_path.c index 2f6f7c996..baaaa5bb1 100644 --- a/source/portability/source/portability_library_path.c +++ b/source/portability/source/portability_library_path.c @@ -68,7 +68,7 @@ static int portability_library_path_phdr_callback(struct dl_phdr_info *info, siz return 0; } -#elif defined(WIN32) || defined(_WIN32) || \ +#elif defined(WIN32) || defined(_WIN32) || \ defined(__CYGWIN__) || defined(__CYGWIN32__) || \ defined(__MINGW32__) || defined(__MINGW64__) @@ -118,7 +118,7 @@ int portability_library_path(const char name[], portability_library_path_str pat return 0; -#elif defined(WIN32) || defined(_WIN32) || \ +#elif defined(WIN32) || defined(_WIN32) || \ defined(__CYGWIN__) || defined(__CYGWIN32__) || \ defined(__MINGW32__) || defined(__MINGW64__) diff --git a/source/portability/source/portability_path.c b/source/portability/source/portability_path.c index 31ed52060..87bedb53e 100644 --- a/source/portability/source/portability_path.c +++ b/source/portability/source/portability_path.c @@ -250,10 +250,10 @@ int portability_path_is_absolute(const char *path, size_t size) return !((path[0] != '\0' && (path[0] >= 'A' && path[0] <= 'Z')) && (path[1] != '\0' && path[1] == ':') && (path[2] != '\0' && PORTABILITY_PATH_SEPARATOR(path[2]))); -#elif defined(unix) || defined(__unix__) || defined(__unix) || \ +#elif defined(unix) || defined(__unix__) || defined(__unix) || \ defined(linux) || defined(__linux__) || defined(__linux) || defined(__gnu_linux) || \ - defined(__CYGWIN__) || defined(__CYGWIN32__) || \ - (defined(__APPLE__) && defined(__MACH__)) || defined(__MACOSX__) || \ + defined(__CYGWIN__) || defined(__CYGWIN32__) || \ + (defined(__APPLE__) && defined(__MACH__)) || defined(__MACOSX__) || \ defined(__HAIKU__) || defined(__BEOS__) if (size < 1) diff --git a/source/reflect/include/reflect/reflect_class_visibility.h b/source/reflect/include/reflect/reflect_class_visibility.h index 5df5e0bdb..3f81c8dcb 100644 --- a/source/reflect/include/reflect/reflect_class_visibility.h +++ b/source/reflect/include/reflect/reflect_class_visibility.h @@ -31,8 +31,8 @@ extern "C" { #endif -#define CLASS_VISIBILITY_X(X) \ - X(PUBLIC, "public", 0), \ +#define CLASS_VISIBILITY_X(X) \ + X(PUBLIC, "public", 0), \ X(PROTECTED, "protected", 1), \ X(PRIVATE, "private", 2) diff --git a/source/reflect/include/reflect/reflect_memory_tracker.h b/source/reflect/include/reflect/reflect_memory_tracker.h index 166f5a72c..28e85c6d3 100644 --- a/source/reflect/include/reflect/reflect_memory_tracker.h +++ b/source/reflect/include/reflect/reflect_memory_tracker.h @@ -35,13 +35,13 @@ extern "C" { #include - #define reflect_memory_tracker(name) \ - static struct \ - { \ - atomic_uintmax_t allocations; \ + #define reflect_memory_tracker(name) \ + static struct \ + { \ + atomic_uintmax_t allocations; \ atomic_uintmax_t deallocations; \ - atomic_uintmax_t increments; \ - atomic_uintmax_t decrements; \ + atomic_uintmax_t increments; \ + atomic_uintmax_t decrements; \ } name = { 0, 0, 0, 0 } #define reflect_memory_tracker_allocation(name) \ @@ -57,34 +57,34 @@ extern "C" { atomic_fetch_add_explicit(&name.decrements, 1, memory_order_relaxed) #if !defined(NDEBUG) || defined(DEBUG) || defined(_DEBUG) || defined(__DEBUG) || defined(__DEBUG__) - #define reflect_memory_tracker_print(name, title) \ - do \ - { \ - printf("----------------- " title " -----------------\n"); \ - printf("Allocations: %" PRIuMAX "\n", atomic_load_explicit(&name.allocations, memory_order_relaxed)); \ + #define reflect_memory_tracker_print(name, title) \ + do \ + { \ + printf("----------------- " title " -----------------\n"); \ + printf("Allocations: %" PRIuMAX "\n", atomic_load_explicit(&name.allocations, memory_order_relaxed)); \ printf("Deallocations: %" PRIuMAX "\n", atomic_load_explicit(&name.deallocations, memory_order_relaxed)); \ - printf("Increments: %" PRIuMAX "\n", atomic_load_explicit(&name.increments, memory_order_relaxed)); \ - printf("Decrements: %" PRIuMAX "\n", atomic_load_explicit(&name.decrements, memory_order_relaxed)); \ - fflush(stdout); \ + printf("Increments: %" PRIuMAX "\n", atomic_load_explicit(&name.increments, memory_order_relaxed)); \ + printf("Decrements: %" PRIuMAX "\n", atomic_load_explicit(&name.decrements, memory_order_relaxed)); \ + fflush(stdout); \ } while (0) #else - #define reflect_memory_tracker_print(name, title) \ - do \ - { \ - uintmax_t allocations = atomic_load_explicit(&name.allocations, memory_order_relaxed); \ - uintmax_t deallocations = atomic_load_explicit(&name.deallocations, memory_order_relaxed); \ - uintmax_t increments = atomic_load_explicit(&name.increments, memory_order_relaxed); \ - uintmax_t decrements = atomic_load_explicit(&name.decrements, memory_order_relaxed); \ + #define reflect_memory_tracker_print(name, title) \ + do \ + { \ + uintmax_t allocations = atomic_load_explicit(&name.allocations, memory_order_relaxed); \ + uintmax_t deallocations = atomic_load_explicit(&name.deallocations, memory_order_relaxed); \ + uintmax_t increments = atomic_load_explicit(&name.increments, memory_order_relaxed); \ + uintmax_t decrements = atomic_load_explicit(&name.decrements, memory_order_relaxed); \ /* This comparison is safe to be done like this because it is done once execution has finalized */ \ - if (allocations != deallocations || increments != decrements) \ - { \ - printf("----------------- " title " -----------------\n"); \ - printf("Allocations: %" PRIuMAX "\n", allocations); \ - printf("Deallocations: %" PRIuMAX "\n", deallocations); \ - printf("Increments: %" PRIuMAX "\n", increments); \ - printf("Decrements: %" PRIuMAX "\n", decrements); \ - fflush(stdout); \ - } \ + if (allocations != deallocations || increments != decrements) \ + { \ + printf("----------------- " title " -----------------\n"); \ + printf("Allocations: %" PRIuMAX "\n", allocations); \ + printf("Deallocations: %" PRIuMAX "\n", deallocations); \ + printf("Increments: %" PRIuMAX "\n", increments); \ + printf("Decrements: %" PRIuMAX "\n", decrements); \ + fflush(stdout); \ + } \ } while (0) #endif #else @@ -92,28 +92,28 @@ extern "C" { typedef char reflect_memory_tracker_disabled #define reflect_memory_tracker_allocation(name) \ - do \ - { \ + do \ + { \ } while (0) #define reflect_memory_tracker_deallocation(name) \ - do \ - { \ + do \ + { \ } while (0) #define reflect_memory_tracker_increment(name) \ - do \ - { \ + do \ + { \ } while (0) #define reflect_memory_tracker_decrement(name) \ - do \ - { \ + do \ + { \ } while (0) #define reflect_memory_tracker_print(name, title) \ - do \ - { \ + do \ + { \ } while (0) #endif diff --git a/source/reflect/source/reflect_class_visibility.c b/source/reflect/source/reflect_class_visibility.c index 1515cc0a1..142a85a72 100644 --- a/source/reflect/source/reflect_class_visibility.c +++ b/source/reflect/source/reflect_class_visibility.c @@ -29,8 +29,8 @@ struct visibility_string_length_type }; #define CLASS_VISIBILITY_STRUCT(name, str, id) \ - { \ - str, sizeof(str) - 1 \ + { \ + str, sizeof(str) - 1 \ } static struct visibility_string_length_type visibility_array[] = { diff --git a/source/tests/metacall_fork_test/source/metacall_fork_test.cpp b/source/tests/metacall_fork_test/source/metacall_fork_test.cpp index 63a02f88f..0e25266a2 100644 --- a/source/tests/metacall_fork_test/source/metacall_fork_test.cpp +++ b/source/tests/metacall_fork_test/source/metacall_fork_test.cpp @@ -20,7 +20,7 @@ class metacall_fork_test : public testing::Test static int pre_callback_fired = 0; static int post_callback_fired = 0; -#if defined(WIN32) || defined(_WIN32) || \ +#if defined(WIN32) || defined(_WIN32) || \ defined(__CYGWIN__) || defined(__CYGWIN32__) || \ defined(__MINGW32__) || defined(__MINGW64__) diff --git a/source/tests/metacall_node_extension_test/node_extension_test/source/node_extension_test.c b/source/tests/metacall_node_extension_test/node_extension_test/source/node_extension_test.c index 24b135680..d5a9087f2 100644 --- a/source/tests/metacall_node_extension_test/node_extension_test/source/node_extension_test.c +++ b/source/tests/metacall_node_extension_test/node_extension_test/source/node_extension_test.c @@ -33,8 +33,8 @@ static napi_value Method(napi_env env, napi_callback_info info) return world; } -#define DECLARE_NAPI_METHOD(name, func) \ - { \ +#define DECLARE_NAPI_METHOD(name, func) \ + { \ name, 0, func, 0, 0, 0, napi_default, 0 \ } diff --git a/source/tests/metacall_sandbox_plugin_test/source/metacall_sandbox_plugin_test.cpp b/source/tests/metacall_sandbox_plugin_test/source/metacall_sandbox_plugin_test.cpp index e9beb938f..9e075cd3b 100644 --- a/source/tests/metacall_sandbox_plugin_test/source/metacall_sandbox_plugin_test.cpp +++ b/source/tests/metacall_sandbox_plugin_test/source/metacall_sandbox_plugin_test.cpp @@ -45,7 +45,7 @@ TEST_F(metacall_sandbox_plugin_test, DefaultConstructor) /* Initialize sandboxing */ { - void *args[1] = { metacall_value_create_bool(0L) }; + void *args[1] = { metacall_value_create_bool(1L) /* Allow */ }; sandbox_ctx = metacallhv_s(handle, "sandbox_initialize", args, 1); @@ -57,7 +57,7 @@ TEST_F(metacall_sandbox_plugin_test, DefaultConstructor) /* Disable uname syscall */ { - void *args[2] = { sandbox_ctx, metacall_value_create_bool(0L) }; + void *args[2] = { sandbox_ctx, metacall_value_create_bool(0L) /* Kill */ }; void *ret = metacallhv_s(handle, "sandbox_uname", args, 2); diff --git a/source/tests/metacall_test/source/metacall_test.cpp b/source/tests/metacall_test/source/metacall_test.cpp index 36a225395..831cb2926 100644 --- a/source/tests/metacall_test/source/metacall_test.cpp +++ b/source/tests/metacall_test/source/metacall_test.cpp @@ -36,10 +36,10 @@ #endif #include -#elif defined(unix) || defined(__unix__) || defined(__unix) || \ +#elif defined(unix) || defined(__unix__) || defined(__unix) || \ defined(linux) || defined(__linux__) || defined(__linux) || defined(__gnu_linux) || \ - defined(__CYGWIN__) || defined(__CYGWIN32__) || \ - defined(__MINGW32__) || defined(__MINGW64__) || \ + defined(__CYGWIN__) || defined(__CYGWIN32__) || \ + defined(__MINGW32__) || defined(__MINGW64__) || \ (defined(__APPLE__) && defined(__MACH__)) || defined(__MACOSX__) #include #endif @@ -79,10 +79,10 @@ TEST_F(metacall_test, DefaultConstructor) ASSERT_NE((DWORD)0, (DWORD)GetCurrentDirectory(length, cwd)); - #elif defined(unix) || defined(__unix__) || defined(__unix) || \ + #elif defined(unix) || defined(__unix__) || defined(__unix) || \ defined(linux) || defined(__linux__) || defined(__linux) || defined(__gnu_linux) || \ - defined(__CYGWIN__) || defined(__CYGWIN32__) || \ - defined(__MINGW32__) || defined(__MINGW64__) || \ + defined(__CYGWIN__) || defined(__CYGWIN32__) || \ + defined(__MINGW32__) || defined(__MINGW64__) || \ (defined(__APPLE__) && defined(__MACH__)) || defined(__MACOSX__) char cwd[PATH_MAX]; diff --git a/source/threading/include/threading/threading_atomic_win32.h b/source/threading/include/threading/threading_atomic_win32.h index 4676b69fd..895838e72 100644 --- a/source/threading/include/threading/threading_atomic_win32.h +++ b/source/threading/include/threading/threading_atomic_win32.h @@ -183,29 +183,29 @@ static inline void atomic_store_explicit64(LONG64 volatile *obj, LONG64 desired, #define atomic_store(obj, desired) \ atomic_store_explicit(obj, desired, memory_order_seq_cst) -#define atomic_store_explicit(obj, desired, order) \ - do \ - { \ - if (sizeof *(obj) == 1) \ - { \ - atomic_store_explicit8((CHAR volatile *)(obj), (CHAR)(desired), order); \ - } \ - else if (sizeof *(obj) == 2) \ - { \ - atomic_store_explicit16((SHORT volatile *)(obj), (SHORT)(desired), order); \ - } \ - else if (sizeof *(obj) == 4) \ - { \ - atomic_store_explicit32((LONG volatile *)(obj), (LONG)(desired), order); \ - } \ - else if (sizeof *(obj) == 8) \ - { \ +#define atomic_store_explicit(obj, desired, order) \ + do \ + { \ + if (sizeof *(obj) == 1) \ + { \ + atomic_store_explicit8((CHAR volatile *)(obj), (CHAR)(desired), order); \ + } \ + else if (sizeof *(obj) == 2) \ + { \ + atomic_store_explicit16((SHORT volatile *)(obj), (SHORT)(desired), order); \ + } \ + else if (sizeof *(obj) == 4) \ + { \ + atomic_store_explicit32((LONG volatile *)(obj), (LONG)(desired), order); \ + } \ + else if (sizeof *(obj) == 8) \ + { \ atomic_store_explicit64((LONG64 volatile *)(obj), (LONG64)(desired), order); \ - } \ - else \ - { \ - abort(); \ - } \ + } \ + else \ + { \ + abort(); \ + } \ } while (0) #define atomic_load(obj) \ @@ -217,10 +217,10 @@ static inline void atomic_store_explicit64(LONG64 volatile *obj, LONG64 desired, #define atomic_exchange(obj, desired) \ atomic_exchange_explicit(obj, desired, memory_order_seq_cst) -#define atomic_exchange_explicit(obj, desired, order) \ - ((sizeof *(obj) == 1) ? _InterlockedExchange8((CHAR volatile *)obj, (CHAR)desired) : \ - (sizeof *(obj) == 2) ? _InterlockedExchange16((SHORT volatile *)obj, (SHORT)desired) : \ - (sizeof *(obj) == 4) ? _InterlockedExchange((LONG volatile *)obj, (LONG)desired) : \ +#define atomic_exchange_explicit(obj, desired, order) \ + ((sizeof *(obj) == 1) ? _InterlockedExchange8((CHAR volatile *)obj, (CHAR)desired) : \ + (sizeof *(obj) == 2) ? _InterlockedExchange16((SHORT volatile *)obj, (SHORT)desired) : \ + (sizeof *(obj) == 4) ? _InterlockedExchange((LONG volatile *)obj, (LONG)desired) : \ (sizeof *(obj) == 8) ? _InterlockedExchange64((LONG64 volatile *)obj, (LONG64)desired) : \ (abort(), 0)) @@ -276,10 +276,10 @@ static inline bool atomic_compare_exchange64(LONG64 volatile *obj, LONG64 *expec return result; } -#define atomic_compare_exchange_strong_explicit(obj, expected, desired, succ, fail) \ - ((sizeof *(obj) == 1) ? atomic_compare_exchange8((CHAR volatile *)(obj), (CHAR *)(expected), (CHAR)(desired)) : \ - (sizeof *(obj) == 2) ? atomic_compare_exchange16((SHORT volatile *)(obj), (SHORT *)(expected), (SHORT)(desired)) : \ - (sizeof *(obj) == 4) ? atomic_compare_exchange32((LONG volatile *)(obj), (LONG *)(expected), (LONG)(desired)) : \ +#define atomic_compare_exchange_strong_explicit(obj, expected, desired, succ, fail) \ + ((sizeof *(obj) == 1) ? atomic_compare_exchange8((CHAR volatile *)(obj), (CHAR *)(expected), (CHAR)(desired)) : \ + (sizeof *(obj) == 2) ? atomic_compare_exchange16((SHORT volatile *)(obj), (SHORT *)(expected), (SHORT)(desired)) : \ + (sizeof *(obj) == 4) ? atomic_compare_exchange32((LONG volatile *)(obj), (LONG *)(expected), (LONG)(desired)) : \ (sizeof *(obj) == 8) ? atomic_compare_exchange64((LONG64 volatile *)(obj), (LONG64 *)(expected), (LONG64)(desired)) : \ (abort(), false)) @@ -294,10 +294,10 @@ static inline bool atomic_compare_exchange64(LONG64 volatile *obj, LONG64 *expec #define atomic_fetch_add(obj, arg) \ atomic_fetch_add_explicit(obj, arg, memory_order_seq_cst) -#define atomic_fetch_add_explicit(obj, arg, order) \ - ((sizeof *(obj) == 1) ? _InterlockedExchangeAdd8((char volatile *)obj, (char)(arg)) : \ - (sizeof *(obj) == 2) ? _InterlockedExchangeAdd16((SHORT volatile *)obj, (SHORT)(arg)) : \ - (sizeof *(obj) == 4) ? _InterlockedExchangeAdd((LONG volatile *)obj, (LONG)(arg)) : \ +#define atomic_fetch_add_explicit(obj, arg, order) \ + ((sizeof *(obj) == 1) ? _InterlockedExchangeAdd8((char volatile *)obj, (char)(arg)) : \ + (sizeof *(obj) == 2) ? _InterlockedExchangeAdd16((SHORT volatile *)obj, (SHORT)(arg)) : \ + (sizeof *(obj) == 4) ? _InterlockedExchangeAdd((LONG volatile *)obj, (LONG)(arg)) : \ (sizeof *(obj) == 8) ? _InterlockedExchangeAdd64((LONG64 volatile *)obj, (LONG64)(arg)) : \ (abort(), 0)) @@ -310,40 +310,40 @@ static inline bool atomic_compare_exchange64(LONG64 volatile *obj, LONG64 *expec #define atomic_fetch_or(obj, arg) \ atomic_fetch_or_explicit(obj, arg, memory_order_seq_cst) -#define atomic_fetch_or_explicit(obj, arg, order) \ - ((sizeof *(obj) == 1) ? _InterlockedOr8((char volatile *)obj, (char)(arg)) : \ - (sizeof *(obj) == 2) ? _InterlockedOr16((SHORT volatile *)obj, (SHORT)(arg)) : \ - (sizeof *(obj) == 4) ? _InterlockedOr((LONG volatile *)obj, (LONG)(arg)) : \ +#define atomic_fetch_or_explicit(obj, arg, order) \ + ((sizeof *(obj) == 1) ? _InterlockedOr8((char volatile *)obj, (char)(arg)) : \ + (sizeof *(obj) == 2) ? _InterlockedOr16((SHORT volatile *)obj, (SHORT)(arg)) : \ + (sizeof *(obj) == 4) ? _InterlockedOr((LONG volatile *)obj, (LONG)(arg)) : \ (sizeof *(obj) == 8) ? _InterlockedOr64((LONG64 volatile *)obj, (LONG64)(arg)) : \ (abort(), 0)) #define atomic_fetch_xor(obj, arg) \ atomic_fetch_xor_explicit(obj, arg, memory_order_seq_cst) -#define atomic_fetch_xor_explicit(obj, arg, order) \ - ((sizeof *(obj) == 1) ? _InterlockedXor8((char volatile *)obj, (char)(arg)) : \ - (sizeof *(obj) == 2) ? _InterlockedXor16((SHORT volatile *)obj, (SHORT)(arg)) : \ - (sizeof *(obj) == 4) ? _InterlockedXor((LONG volatile *)obj, (LONG)(arg)) : \ +#define atomic_fetch_xor_explicit(obj, arg, order) \ + ((sizeof *(obj) == 1) ? _InterlockedXor8((char volatile *)obj, (char)(arg)) : \ + (sizeof *(obj) == 2) ? _InterlockedXor16((SHORT volatile *)obj, (SHORT)(arg)) : \ + (sizeof *(obj) == 4) ? _InterlockedXor((LONG volatile *)obj, (LONG)(arg)) : \ (sizeof *(obj) == 8) ? _InterlockedXor64((LONG64 volatile *)obj, (LONG64)(arg)) : \ (abort(), 0)) #define atomic_fetch_and(obj, arg) \ atomic_fetch_and_explicit(obj, arg, memory_order_seq_cst) -#define atomic_fetch_and_explicit(obj, arg, order) \ - ((sizeof *(obj) == 1) ? _InterlockedAnd8((char volatile *)obj, (char)(arg)) : \ - (sizeof *(obj) == 2) ? _InterlockedAnd16((SHORT volatile *)obj, (SHORT)(arg)) : \ - (sizeof *(obj) == 4) ? _InterlockedAnd((LONG volatile *)obj, (LONG)(arg)) : \ +#define atomic_fetch_and_explicit(obj, arg, order) \ + ((sizeof *(obj) == 1) ? _InterlockedAnd8((char volatile *)obj, (char)(arg)) : \ + (sizeof *(obj) == 2) ? _InterlockedAnd16((SHORT volatile *)obj, (SHORT)(arg)) : \ + (sizeof *(obj) == 4) ? _InterlockedAnd((LONG volatile *)obj, (LONG)(arg)) : \ (sizeof *(obj) == 8) ? _InterlockedAnd64((LONG64 volatile *)obj, (LONG64)(arg)) : \ (abort(), 0)) -#define __atomic_compiler_barrier(order) \ - do \ - { \ +#define __atomic_compiler_barrier(order) \ + do \ + { \ if (order > memory_order_consume) \ - { \ - _ReadWriteBarrier(); \ - } \ + { \ + _ReadWriteBarrier(); \ + } \ } while (0) static inline void atomic_thread_fence(memory_order order) diff --git a/source/threading/include/threading/threading_mutex.h b/source/threading/include/threading/threading_mutex.h index e0048eacf..29f5163de 100644 --- a/source/threading/include/threading/threading_mutex.h +++ b/source/threading/include/threading/threading_mutex.h @@ -35,10 +35,10 @@ extern "C" { #include typedef CRITICAL_SECTION threading_mutex_impl_type; #elif (defined(linux) || defined(__linux) || defined(__linux__) || defined(__gnu_linux) || defined(__gnu_linux__) || defined(__TOS_LINUX__)) || \ - defined(__FreeBSD__) || \ - defined(__NetBSD__) || \ - defined(__OpenBSD__) || \ - (defined(bsdi) || defined(__bsdi__)) || \ + defined(__FreeBSD__) || \ + defined(__NetBSD__) || \ + defined(__OpenBSD__) || \ + (defined(bsdi) || defined(__bsdi__)) || \ defined(__DragonFly__) #include typedef pthread_mutex_t threading_mutex_impl_type;