summaryrefslogtreecommitdiffstats
path: root/src/common
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2019-04-12 02:42:40 +0200
committerLioncash <mathew1800@gmail.com>2019-04-12 02:42:44 +0200
commit66b73fd39957f9d40dc2d2b05468bbd4d2a1347e (patch)
treed1fcbe18e413a1ffe09ea1cf74420c1074a71df5 /src/common
parentcommon/swap: Simplify swap function ifdefs (diff)
downloadyuzu-66b73fd39957f9d40dc2d2b05468bbd4d2a1347e.tar
yuzu-66b73fd39957f9d40dc2d2b05468bbd4d2a1347e.tar.gz
yuzu-66b73fd39957f9d40dc2d2b05468bbd4d2a1347e.tar.bz2
yuzu-66b73fd39957f9d40dc2d2b05468bbd4d2a1347e.tar.lz
yuzu-66b73fd39957f9d40dc2d2b05468bbd4d2a1347e.tar.xz
yuzu-66b73fd39957f9d40dc2d2b05468bbd4d2a1347e.tar.zst
yuzu-66b73fd39957f9d40dc2d2b05468bbd4d2a1347e.zip
Diffstat (limited to 'src/common')
-rw-r--r--src/common/swap.h22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/common/swap.h b/src/common/swap.h
index fad0f35a7..086449028 100644
--- a/src/common/swap.h
+++ b/src/common/swap.h
@@ -57,13 +57,13 @@
namespace Common {
#ifdef _MSC_VER
-inline u16 swap16(u16 data) {
+[[nodiscard]] inline u16 swap16(u16 data) noexcept {
return _byteswap_ushort(data);
}
-inline u32 swap32(u32 data) {
+[[nodiscard]] inline u32 swap32(u32 data) noexcept {
return _byteswap_ulong(data);
}
-inline u64 swap64(u64 data) {
+[[nodiscard]] inline u64 swap64(u64 data) noexcept {
return _byteswap_uint64(data);
}
#elif defined(__clang__) || defined(__GNUC__)
@@ -73,29 +73,29 @@ inline u64 swap64(u64 data) {
#undef swap32
#undef swap64
#endif
-inline u16 swap16(u16 data) {
+[[nodiscard]] inline u16 swap16(u16 data) noexcept {
return __builtin_bswap16(data);
}
-inline u32 swap32(u32 data) {
+[[nodiscard]] inline u32 swap32(u32 data) noexcept {
return __builtin_bswap32(data);
}
-inline u64 swap64(u64 data) {
+[[nodiscard]] inline u64 swap64(u64 data) noexcept {
return __builtin_bswap64(data);
}
#else
// Slow generic implementation.
-inline u16 swap16(u16 data) {
+[[nodiscard]] inline u16 swap16(u16 data) noexcept {
return (data >> 8) | (data << 8);
}
-inline u32 swap32(u32 data) {
+[[nodiscard]] inline u32 swap32(u32 data) noexcept {
return (swap16(data) << 16) | swap16(data >> 16);
}
-inline u64 swap64(u64 data) {
+[[nodiscard]] inline u64 swap64(u64 data) noexcept {
return ((u64)swap32(data) << 32) | swap32(data >> 32);
}
#endif
-inline float swapf(float f) {
+[[nodiscard]] inline float swapf(float f) noexcept {
static_assert(sizeof(u32) == sizeof(float), "float must be the same size as uint32_t.");
u32 value;
@@ -107,7 +107,7 @@ inline float swapf(float f) {
return f;
}
-inline double swapd(double f) {
+[[nodiscard]] inline double swapd(double f) noexcept {
static_assert(sizeof(u64) == sizeof(double), "double must be the same size as uint64_t.");
u64 value;