1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-01-18 21:23:02 +00:00

Rearrange attributes to simplify macros

This commit is contained in:
Carles Fernandez 2020-02-24 11:39:15 +01:00
parent 5698c9c2ea
commit e0b54cf8fe

View File

@ -18,15 +18,15 @@
// //
// Cross-platform attribute macros not included in VOLK // Cross-platform attribute macros not included in VOLK
// //
#if defined __clang__ #if _MSC_VER
#define __VOLK_GNSSSDR_PREFETCH(addr) __builtin_prefetch(addr)
#define __VOLK_GNSSSDR_PREFETCH_LOCALITY(addr, rw, locality) __builtin_prefetch(addr, rw, locality)
#elif defined __GNUC__
#define __VOLK_GNSSSDR_PREFETCH(addr) __builtin_prefetch(addr)
#define __VOLK_GNSSSDR_PREFETCH_LOCALITY(addr, rw, locality) __builtin_prefetch(addr, rw, locality)
#elif _MSC_VER
#define __VOLK_GNSSSDR_PREFETCH(addr) #define __VOLK_GNSSSDR_PREFETCH(addr)
#define __VOLK_GNSSSDR_PREFETCH_LOCALITY(addr, rw, locality) #define __VOLK_GNSSSDR_PREFETCH_LOCALITY(addr, rw, locality)
#elif defined(__clang__)
#define __VOLK_GNSSSDR_PREFETCH(addr) __builtin_prefetch(addr)
#define __VOLK_GNSSSDR_PREFETCH_LOCALITY(addr, rw, locality) __builtin_prefetch(addr, rw, locality)
#elif defined(__GNUC__)
#define __VOLK_GNSSSDR_PREFETCH(addr) __builtin_prefetch(addr)
#define __VOLK_GNSSSDR_PREFETCH_LOCALITY(addr, rw, locality) __builtin_prefetch(addr, rw, locality)
#else #else
#define __VOLK_GNSSSDR_PREFETCH(addr) #define __VOLK_GNSSSDR_PREFETCH(addr)
#define __VOLK_GNSSSDR_PREFETCH_LOCALITY(addr, rw, locality) #define __VOLK_GNSSSDR_PREFETCH_LOCALITY(addr, rw, locality)
@ -38,7 +38,17 @@
// //
// Cross-platform attribute macros // Cross-platform attribute macros
// //
#if defined(__clang__) && (!defined(_MSC_VER)) #if _MSC_VER
#define __VOLK_ATTR_ALIGNED(x) __declspec(align(x))
#define __VOLK_ATTR_UNUSED
#define __VOLK_ATTR_INLINE __forceinline
#define __VOLK_ATTR_DEPRECATED __declspec(deprecated)
#define __VOLK_ATTR_EXPORT __declspec(dllexport)
#define __VOLK_ATTR_IMPORT __declspec(dllimport)
#define __VOLK_PREFETCH(addr)
#define __VOLK_ASM __asm
#define __VOLK_VOLATILE
#elif defined(__clang__)
// AppleClang also defines __GNUC__, so do this check first. These // AppleClang also defines __GNUC__, so do this check first. These
// will probably be the same as for __GNUC__, but let's keep them // will probably be the same as for __GNUC__, but let's keep them
// separate just to be safe. // separate just to be safe.
@ -51,7 +61,7 @@
#define __VOLK_ATTR_EXPORT __attribute__((visibility("default"))) #define __VOLK_ATTR_EXPORT __attribute__((visibility("default")))
#define __VOLK_ATTR_IMPORT __attribute__((visibility("default"))) #define __VOLK_ATTR_IMPORT __attribute__((visibility("default")))
#define __VOLK_PREFETCH(addr) __builtin_prefetch(addr) #define __VOLK_PREFETCH(addr) __builtin_prefetch(addr)
#elif defined __GNUC__ #elif defined(__GNUC__)
#define __VOLK_ATTR_ALIGNED(x) __attribute__((aligned(x))) #define __VOLK_ATTR_ALIGNED(x) __attribute__((aligned(x)))
#define __VOLK_ATTR_UNUSED __attribute__((unused)) #define __VOLK_ATTR_UNUSED __attribute__((unused))
#define __VOLK_ATTR_INLINE __attribute__((always_inline)) #define __VOLK_ATTR_INLINE __attribute__((always_inline))
@ -66,17 +76,8 @@
#define __VOLK_ATTR_IMPORT #define __VOLK_ATTR_IMPORT
#endif #endif
#define __VOLK_PREFETCH(addr) __builtin_prefetch(addr) #define __VOLK_PREFETCH(addr) __builtin_prefetch(addr)
#elif _MSC_VER
#define __VOLK_ATTR_ALIGNED(x) __declspec(align(x))
#define __VOLK_ATTR_UNUSED
#define __VOLK_ATTR_INLINE __forceinline
#define __VOLK_ATTR_DEPRECATED __declspec(deprecated)
#define __VOLK_ATTR_EXPORT __declspec(dllexport)
#define __VOLK_ATTR_IMPORT __declspec(dllimport)
#define __VOLK_PREFETCH(addr)
#define __VOLK_ASM __asm
#define __VOLK_VOLATILE
#else #else
#warning "Unknown compiler. Using default VOLK macros, which may or not work."
#define __VOLK_ATTR_ALIGNED(x) #define __VOLK_ATTR_ALIGNED(x)
#define __VOLK_ATTR_UNUSED #define __VOLK_ATTR_UNUSED
#define __VOLK_ATTR_INLINE #define __VOLK_ATTR_INLINE
@ -88,19 +89,19 @@
#define __VOLK_VOLATILE __volatile__ #define __VOLK_VOLATILE __volatile__
#endif #endif
// ////////////////////////////////////////////////////////////////////////
// Ignore annoying warnings in MSVC // Ignore annoying warnings in MSVC
// ////////////////////////////////////////////////////////////////////////
#if defined(_MSC_VER) #if defined(_MSC_VER)
#pragma warning(disable : 4244) // 'conversion' conversion from 'type1' to 'type2', possible loss of data #pragma warning(disable : 4244) //'conversion' conversion from 'type1' to 'type2', possible loss of data
#pragma warning(disable : 4305) // 'identifier' : truncation from 'type1' to 'type2' #pragma warning(disable : 4305) //'identifier' : truncation from 'type1' to 'type2'
#endif #endif
// ////////////////////////////////////////////////////////////////////////
// C-linkage declaration macros // C-linkage declaration macros
// FIXME: due to the usage of complex.h, require gcc for c-linkage // FIXME: due to the usage of complex.h, require gcc for c-linkage
// ////////////////////////////////////////////////////////////////////////
#if defined(__cplusplus) && (__GNUC__) #if defined(__cplusplus) && (defined(__GNUC__) || defined(__clang__))
#define __VOLK_DECL_BEGIN \ #define __VOLK_DECL_BEGIN \
extern "C" \ extern "C" \
{ {