mirror of
https://github.com/openvswitch/ovs
synced 2025-10-29 15:28:56 +00:00
compiler: Add OVS_CONSTRUCTOR to mark functions as init functions
Functions marked with OVS_CONSTRUCTOR are called unconditionally before main. Tested with GCC. Untested with MSVC. Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
This commit is contained in:
@@ -179,4 +179,17 @@
|
||||
#define OVS_PACKED(DECL) __pragma(pack(push, 1)) DECL __pragma(pack(pop))
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define CCALL __cdecl
|
||||
#pragma section(".CRT$XCU",read)
|
||||
#define OVS_CONSTRUCTOR(f) \
|
||||
static void __cdecl f(void); \
|
||||
__declspec(allocate(".CRT$XCU")) void (__cdecl*f##_)(void) = f; \
|
||||
static void __cdecl f(void)
|
||||
#else
|
||||
#define OVS_CONSTRUCTOR(f) \
|
||||
static void f(void) __attribute__((constructor)); \
|
||||
static void f(void)
|
||||
#endif
|
||||
|
||||
#endif /* compiler.h */
|
||||
|
||||
Reference in New Issue
Block a user