aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorlizzie <lizzie@eden-emu.dev>2025-10-22 02:56:28 +0200
committercrueter <crueter@eden-emu.dev>2025-10-22 02:56:28 +0200
commit992bae4e2a14ca2547c09637b7dc6fc5f73b353a (patch)
tree4b7df7f2cf95255551ccfad40ea33ed354b1f8ec /src/common
parent6ff043c4fbd5dae5e0b1ec73a3bb4003e8cef20b (diff)
[common] replace Common::BitCast with libc++ provided one (#2774)
Signed-off-by: lizzie <lizzie@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/2774 Reviewed-by: MaranBr <maranbr@eden-emu.dev> Reviewed-by: crueter <crueter@eden-emu.dev> Co-authored-by: lizzie <lizzie@eden-emu.dev> Co-committed-by: lizzie <lizzie@eden-emu.dev>
Diffstat (limited to 'src/common')
-rw-r--r--src/common/CMakeLists.txt1
-rw-r--r--src/common/bit_cast.h23
-rw-r--r--src/common/overflow.h11
3 files changed, 5 insertions, 30 deletions
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt
index 2bd74503f4..21f2ab4ed4 100644
--- a/src/common/CMakeLists.txt
+++ b/src/common/CMakeLists.txt
@@ -30,7 +30,6 @@ add_library(
assert.h
atomic_helpers.h
atomic_ops.h
- bit_cast.h
bit_field.h
bit_util.h
bounded_threadsafe_queue.h
diff --git a/src/common/bit_cast.h b/src/common/bit_cast.h
deleted file mode 100644
index c6110c5426..0000000000
--- a/src/common/bit_cast.h
+++ /dev/null
@@ -1,23 +0,0 @@
-// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
-// SPDX-License-Identifier: GPL-2.0-or-later
-
-#pragma once
-
-#include <version>
-
-#ifdef __cpp_lib_bit_cast
-#include <bit>
-#endif
-
-namespace Common {
-
-template <typename To, typename From>
-constexpr inline To BitCast(const From& from) {
-#ifdef __cpp_lib_bit_cast
- return std::bit_cast<To>(from);
-#else
- return __builtin_bit_cast(To, from);
-#endif
-}
-
-} // namespace Common
diff --git a/src/common/overflow.h b/src/common/overflow.h
index 5f048de7e6..e82747795b 100644
--- a/src/common/overflow.h
+++ b/src/common/overflow.h
@@ -8,7 +8,8 @@
#include <algorithm>
#include <type_traits>
-#include "bit_cast.h"
+#include <numeric>
+#include <bit>
namespace Common {
@@ -16,11 +17,9 @@ template <typename T>
requires(std::is_integral_v<T> && std::is_signed_v<T>)
inline T WrappingAdd(T lhs, T rhs) {
using U = std::make_unsigned_t<T>;
-
- U lhs_u = BitCast<U>(lhs);
- U rhs_u = BitCast<U>(rhs);
-
- return BitCast<T>(lhs_u + rhs_u);
+ U lhs_u = std::bit_cast<U>(lhs);
+ U rhs_u = std::bit_cast<U>(rhs);
+ return std::bit_cast<T>(lhs_u + rhs_u);
}
template <typename T>