diff --git a/src/add_debug_flags.c b/src/add_debug_flags.c index 21c0481..407b9c6 100644 --- a/src/add_debug_flags.c +++ b/src/add_debug_flags.c @@ -1,9 +1,9 @@ -#include "swift_net.h" #include "internal/internal.h" +#include "swift_net.h" -void swiftnet_add_debug_flags(const uint32_t flags) { - debugger.flags |= flags; +void swiftnet_add_debug_flags(const enum SwiftNetDebugFlags flags) { + debugger.flags |= flags; } -void swiftnet_remove_debug_flags(const uint32_t flags) { - debugger.flags &= ~flags; +void swiftnet_remove_debug_flags(const enum SwiftNetDebugFlags flags) { + debugger.flags &= ~flags; } diff --git a/src/internal/internal.h b/src/internal/internal.h index 37d4154..9787591 100644 --- a/src/internal/internal.h +++ b/src/internal/internal.h @@ -153,7 +153,7 @@ extern void* check_existing_listener(const char* interface_name, void* const con #ifdef SWIFT_NET_DEBUG extern struct SwiftNetDebugger debugger; - static inline bool check_debug_flag(enum SwiftNetDebugFlags flag) { + static inline bool check_debug_flag(const enum SwiftNetDebugFlags flag) { return (debugger.flags & flag) != 0; } diff --git a/src/swift_net.h b/src/swift_net.h index 5f99b68..d650cf6 100644 --- a/src/swift_net.h +++ b/src/swift_net.h @@ -54,14 +54,17 @@ extern uint32_t maximum_transmission_unit; #ifdef SWIFT_NET_DEBUG enum SwiftNetDebugFlags { - PACKETS_SENDING = 1u << 0, - PACKETS_RECEIVING = 1u << 1, - INITIALIZATION = 1u << 2, - LOST_PACKETS = 1u << 3 + PACKETS_SENDING = 1u << 1, + PACKETS_RECEIVING = 1u << 2, + INITIALIZATION = 1u << 3, + LOST_PACKETS = 1u << 4 }; +#define SWIFTNET_DEBUG_FLAGS(num) \ + ((enum SwiftNetDebugFlags)(num)) + struct SwiftNetDebugger { - uint32_t flags; + int flags; }; #endif @@ -396,9 +399,9 @@ extern void swiftnet_server_make_response( #ifdef SWIFT_NET_DEBUG // Adds one or more debug flags to the global debugger state. - extern void swiftnet_add_debug_flags(const uint32_t flags); + extern void swiftnet_add_debug_flags(const enum SwiftNetDebugFlags flags); // Removes one or more debug flags from the global debugger state. - extern void swiftnet_remove_debug_flags(const uint32_t flags); + extern void swiftnet_remove_debug_flags(const enum SwiftNetDebugFlags flags); #endif diff --git a/tests/integration_tests/output/run_tests b/tests/integration_tests/output/run_tests index 3347134..9980735 100755 Binary files a/tests/integration_tests/output/run_tests and b/tests/integration_tests/output/run_tests differ diff --git a/tests/integration_tests/src/run_tests.c b/tests/integration_tests/src/run_tests.c index 243129d..9915945 100644 --- a/tests/integration_tests/src/run_tests.c +++ b/tests/integration_tests/src/run_tests.c @@ -217,7 +217,7 @@ int main() { swiftnet_initialize(); - swiftnet_add_debug_flags(INITIALIZATION | LOST_PACKETS | PACKETS_RECEIVING | PACKETS_SENDING); + swiftnet_add_debug_flags(SWIFTNET_DEBUG_FLAGS(PACKETS_SENDING | PACKETS_RECEIVING | INITIALIZATION | LOST_PACKETS)); for (uint16_t i = 0; i < sizeof(tests) / sizeof(struct Test); i++) { const struct Test* current_test = &tests[i]; diff --git a/tests/performance_tests/output/run_tests b/tests/performance_tests/output/run_tests index 25c4ad5..ecb06ac 100755 Binary files a/tests/performance_tests/output/run_tests and b/tests/performance_tests/output/run_tests differ diff --git a/tests/performance_tests/src/main.c b/tests/performance_tests/src/main.c index fe99fb7..236dc4a 100644 --- a/tests/performance_tests/src/main.c +++ b/tests/performance_tests/src/main.c @@ -86,7 +86,7 @@ void send_large_packets(const bool loopback) { int main() { swiftnet_initialize(); - swiftnet_add_debug_flags(PACKETS_SENDING | PACKETS_RECEIVING | INITIALIZATION | LOST_PACKETS); + swiftnet_add_debug_flags(SWIFTNET_DEBUG_FLAGS(PACKETS_SENDING | PACKETS_RECEIVING | INITIALIZATION | LOST_PACKETS)); send_large_packets(false);