X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fcompiler.h;h=e867d72f202a102526c3881b5e7a6b9569a460de;hb=5de43a606c949dbb74272d5b09627ddd5f64b06b;hp=519b83291a00c51da12544d53347953ea0da9ca7;hpb=47b52c71232c01837e5c5e374af8033fbf711f0f;p=sliver-openvswitch.git diff --git a/lib/compiler.h b/lib/compiler.h index 519b83291..e867d72f2 100644 --- a/lib/compiler.h +++ b/lib/compiler.h @@ -20,11 +20,15 @@ #ifndef __has_feature #define __has_feature(x) 0 #endif +#ifndef __has_extension + #define __has_extension(x) 0 +#endif #if __GNUC__ && !__CHECKER__ #define NO_RETURN __attribute__((__noreturn__)) #define OVS_UNUSED __attribute__((__unused__)) #define PRINTF_FORMAT(FMT, ARG1) __attribute__((__format__(printf, FMT, ARG1))) +#define SCANF_FORMAT(FMT, ARG1) __attribute__((__format__(scanf, FMT, ARG1))) #define STRFTIME_FORMAT(FMT) __attribute__((__format__(__strftime__, FMT, 0))) #define MALLOC_LIKE __attribute__((__malloc__)) #define ALWAYS_INLINE __attribute__((always_inline)) @@ -36,6 +40,7 @@ #define NO_RETURN #define OVS_UNUSED #define PRINTF_FORMAT(FMT, ARG1) +#define SCANF_FORMAT(FMT, ARG1) #define STRFTIME_FORMAT(FMT) #define MALLOC_LIKE #define ALWAYS_INLINE @@ -91,8 +96,8 @@ * - OVS_REQUIRES(MUTEX) indicate that the function may only be called with * MUTEX held and that the function does not release MUTEX. * - * - OVS_LOCKS_EXCLUDED(MUTEX) indicates that the function may only be - * called when MUTEX is not held. + * - OVS_EXCLUDED(MUTEX) indicates that the function may only be called when + * MUTEX is not held. * * * The following variants, with the same syntax, apply to reader-writer locks: @@ -103,7 +108,7 @@ * OVS_RELEASES OVS_RELEASES OVS_RELEASES * OVS_TRY_LOCK OVS_TRY_RDLOCK OVS_TRY_WRLOCK * OVS_REQUIRES OVS_REQ_RDLOCK OVS_REQ_WRLOCK - * OVS_LOCKS_EXCLUDED OVS_LOCKS_EXCLUDED OVS_LOCKS_EXCLUDED + * OVS_EXCLUDED OVS_EXCLUDED OVS_EXCLUDED */ #define OVS_LOCKABLE __attribute__((lockable)) #define OVS_REQ_RDLOCK(...) __attribute__((shared_locks_required(__VA_ARGS__))) @@ -128,6 +133,8 @@ #define OVS_EXCLUDED(...) __attribute__((locks_excluded(__VA_ARGS__))) #define OVS_ACQ_BEFORE(...) __attribute__((acquired_before(__VA_ARGS__))) #define OVS_ACQ_AFTER(...) __attribute__((acquired_after(__VA_ARGS__))) +#define OVS_NO_THREAD_SAFETY_ANALYSIS \ + __attribute__((no_thread_safety_analysis)) #else /* not Clang */ #define OVS_LOCKABLE #define OVS_REQ_RDLOCK(...) @@ -145,6 +152,7 @@ #define OVS_RELEASES(...) #define OVS_ACQ_BEFORE(...) #define OVS_ACQ_AFTER(...) +#define OVS_NO_THREAD_SAFETY_ANALYSIS #endif /* ISO C says that a C implementation may choose any integer type for an enum @@ -171,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 */