aboutsummaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
authorMichael Dickens <michael.dickens@ettus.com>2022-03-16 16:08:11 -0400
committerAaron Rossetto <aaron.rossetto@ni.com>2022-04-01 12:13:12 -0700
commit8dd3ace5c35d0054835671a0fe839960b1e2db3a (patch)
tree8bf31fec9518c289077d25a622e5a152e7e14a78 /host
parent00e18de91c1e22b0b452869aaa87f7bcf10efe09 (diff)
downloaduhd-8dd3ace5c35d0054835671a0fe839960b1e2db3a.tar.gz
uhd-8dd3ace5c35d0054835671a0fe839960b1e2db3a.tar.bz2
uhd-8dd3ace5c35d0054835671a0fe839960b1e2db3a.zip
uhd: fix compiler macro ordering
Clang provides the same macros as GCC, so if we're differentiating between these compilers then we need to get the compiler checking macros in the correct order
Diffstat (limited to 'host')
-rw-r--r--host/include/uhd/config.h4
-rw-r--r--host/include/uhd/config.hpp12
-rw-r--r--host/include/uhd/utils/byteswap.ipp18
3 files changed, 17 insertions, 17 deletions
diff --git a/host/include/uhd/config.h b/host/include/uhd/config.h
index a6c05f0c4..4aaff659b 100644
--- a/host/include/uhd/config.h
+++ b/host/include/uhd/config.h
@@ -39,7 +39,7 @@ typedef SSIZE_T ssize_t;
#define UHD_DEPRECATED __declspec(deprecated)
#define UHD_ALIGNED(x) __declspec(align(x))
#define UHD_UNUSED(x) x __attribute__((unused))
-#elif defined(__GNUC__) && __GNUC__ >= 4
+#elif defined(__clang__)
#define UHD_EXPORT __attribute__((visibility("default")))
#define UHD_IMPORT __attribute__((visibility("default")))
#define UHD_EXPORT_HEADER __attribute__((visibility("default")))
@@ -48,7 +48,7 @@ typedef SSIZE_T ssize_t;
#define UHD_DEPRECATED __attribute__((deprecated))
#define UHD_ALIGNED(x) __attribute__((aligned(x)))
#define UHD_UNUSED(x) x __attribute__((unused))
-#elif defined(__clang__)
+#elif defined(__GNUC__) && (__GNUC__ >= 4)
#define UHD_EXPORT __attribute__((visibility("default")))
#define UHD_IMPORT __attribute__((visibility("default")))
#define UHD_EXPORT_HEADER __attribute__((visibility("default")))
diff --git a/host/include/uhd/config.hpp b/host/include/uhd/config.hpp
index 3fae77085..a0289ca1a 100644
--- a/host/include/uhd/config.hpp
+++ b/host/include/uhd/config.hpp
@@ -73,7 +73,7 @@ typedef SSIZE_T ssize_t;
# define UHD_FALLTHROUGH
# define UHD_FUNCTION __func__
# define UHD_PRETTY_FUNCTION __PRETTY_FUNCTION__
-#elif defined(__GNUG__) && __GNUG__ >= 4
+#elif defined(__clang__)
# define UHD_EXPORT __attribute__((visibility("default")))
# define UHD_IMPORT __attribute__((visibility("default")))
# define UHD_EXPORT_HEADER __attribute__((visibility("default")))
@@ -83,14 +83,14 @@ typedef SSIZE_T ssize_t;
# define UHD_DEPRECATED __attribute__((deprecated))
# define UHD_ALIGNED(x) __attribute__((aligned(x)))
# define UHD_UNUSED(x) x __attribute__((unused))
-# if __GNUG__ >= 7
-# define UHD_FALLTHROUGH __attribute__((fallthrough));
+# if __clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 8)
+# define UHD_FALLTHROUGH [[clang:fallthrough]];
# else
# define UHD_FALLTHROUGH
# endif
# define UHD_FUNCTION __func__
# define UHD_PRETTY_FUNCTION __PRETTY_FUNCTION__
-#elif defined(__clang__)
+#elif defined(__GNUG__) && __GNUG__ >= 4
# define UHD_EXPORT __attribute__((visibility("default")))
# define UHD_IMPORT __attribute__((visibility("default")))
# define UHD_EXPORT_HEADER __attribute__((visibility("default")))
@@ -100,8 +100,8 @@ typedef SSIZE_T ssize_t;
# define UHD_DEPRECATED __attribute__((deprecated))
# define UHD_ALIGNED(x) __attribute__((aligned(x)))
# define UHD_UNUSED(x) x __attribute__((unused))
-# if __clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 8)
-# define UHD_FALLTHROUGH [[clang:fallthrough]];
+# if __GNUG__ >= 7
+# define UHD_FALLTHROUGH __attribute__((fallthrough));
# else
# define UHD_FALLTHROUGH
# endif
diff --git a/host/include/uhd/utils/byteswap.ipp b/host/include/uhd/utils/byteswap.ipp
index 85c11b8f4..25f688693 100644
--- a/host/include/uhd/utils/byteswap.ipp
+++ b/host/include/uhd/utils/byteswap.ipp
@@ -29,39 +29,39 @@ UHD_INLINE uint64_t uhd::byteswap(uint64_t x)
return _byteswap_uint64(x);
}
-#elif defined(__GNUC__) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 3
+#elif defined(UHD_PLATFORM_MACOS)
+# include <libkern/OSByteOrder.h>
UHD_INLINE uint16_t uhd::byteswap(uint16_t x)
{
- return (x >> 8) | (x << 8); // DNE return __builtin_bswap16(x);
+ return OSSwapInt16(x);
}
UHD_INLINE uint32_t uhd::byteswap(uint32_t x)
{
- return __builtin_bswap32(x);
+ return OSSwapInt32(x);
}
UHD_INLINE uint64_t uhd::byteswap(uint64_t x)
{
- return __builtin_bswap64(x);
+ return OSSwapInt64(x);
}
-#elif defined(UHD_PLATFORM_MACOS)
-# include <libkern/OSByteOrder.h>
+#elif defined(__GNUC__) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 3
UHD_INLINE uint16_t uhd::byteswap(uint16_t x)
{
- return OSSwapInt16(x);
+ return (x >> 8) | (x << 8); // DNE return __builtin_bswap16(x);
}
UHD_INLINE uint32_t uhd::byteswap(uint32_t x)
{
- return OSSwapInt32(x);
+ return __builtin_bswap32(x);
}
UHD_INLINE uint64_t uhd::byteswap(uint64_t x)
{
- return OSSwapInt64(x);
+ return __builtin_bswap64(x);
}
#elif defined(UHD_PLATFORM_LINUX)