test: make clang use __attribute__((constructor)) to register leak checker

This commit is contained in:
Bert Belder 2018-05-17 00:42:12 -07:00
parent 4e21e8411e
commit bcc72f8ec5
No known key found for this signature in database
GPG Key ID: 7A77887B2E2ED461

View File

@ -3,16 +3,16 @@
#include "test-util.h" #include "test-util.h"
#if defined(_MSC_VER) /* msvc */ #if defined(__clang__) || defined(__GNUC__)
#define constructor(fn) \
static void fn(void) __attribute__((constructor)); \
static void fn(void)
#else /* msvc */
#pragma section(".CRT$XCU", read) #pragma section(".CRT$XCU", read)
#define constructor(fn) \ #define constructor(fn) \
static void __cdecl fn(void); \ static void __cdecl fn(void); \
__declspec(allocate(".CRT$XCU")) void(__cdecl * fn##_)(void) = fn; \ __declspec(allocate(".CRT$XCU")) void(__cdecl * fn##_)(void) = fn; \
static void __cdecl fn(void) static void __cdecl fn(void)
#else /* gcc/clang */
#define constructor(fn) \
static void fn(void) __attribute__((constructor)); \
static void fn(void)
#endif #endif
static void __cdecl leak_check_finalize(void); static void __cdecl leak_check_finalize(void);