From cb269b46d63d680b936c55e965dc0bb4e4f13677 Mon Sep 17 00:00:00 2001 From: dragonmux Date: Wed, 3 Jan 2024 15:07:53 +0000 Subject: [PATCH] rust: Made the wrap helper `inline` and fixed an accidental copy error --- rust/rust.cc | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/rust/rust.cc b/rust/rust.cc index 279884d0..cb486233 100644 --- a/rust/rust.cc +++ b/rust/rust.cc @@ -24,17 +24,12 @@ namespace { USING_NEXTPNR_NAMESPACE; - // `memcpy` is used here to avoid strict-aliasing problems, but GCC dislikes it. -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wclass-memaccess" - template - uint64_t wrap(T thing) { + template static inline uint64_t wrap(const T &thing) noexcept { static_assert(sizeof(T) <= 8, "T is too big for FFI"); uint64_t b = 0; memcpy(&b, &thing, sizeof(T)); return b; } -#pragma GCC diagnostic pop template static inline T unwrap(const std::array &value) noexcept { static_assert(sizeof(T) <= 8, "T is too big for FFI");