From 0321c3f544d70e2d789f2b2fa985d0f57e6f0c4f Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Thu, 13 Mar 2025 00:08:57 +0200 Subject: [PATCH] Revert "math.bits: port changes from e66e996, so that `-cstrict -cc gcc-11` passes for `markdown` as well" This reverts commit 41a846a534dd582f061183463d2812cce29530e1. --- vlib/math/bits/unsafe_bits.v | 50 ++++++------------------------------ 1 file changed, 8 insertions(+), 42 deletions(-) diff --git a/vlib/math/bits/unsafe_bits.v b/vlib/math/bits/unsafe_bits.v index 764be748d..81332db75 100644 --- a/vlib/math/bits/unsafe_bits.v +++ b/vlib/math/bits/unsafe_bits.v @@ -3,29 +3,13 @@ // that can be found in the LICENSE file. module bits -union U32_F32 { - u u32 - f f32 -} - -union U64_F64 { - u u64 - f f64 -} - // f32_bits returns the IEEE 754 binary representation of f, // with the sign bit of f and the result in the same bit position. // f32_bits(f32_from_bits(x)) == x. @[inline] pub fn f32_bits(f f32) u32 { - $if tinyc { - return *unsafe { &u32(&f) } // this is faster for tcc, but causes `error: dereferencing type-punned pointer will break strict-aliasing rules` on gcc, with -cstrict - } - return unsafe { - U32_F32{ - f: f - }.u - } + p := *unsafe { &u32(&f) } + return p } // f32_from_bits returns the floating-point number corresponding @@ -34,14 +18,8 @@ pub fn f32_bits(f f32) u32 { // f32_from_bits(f32_bits(x)) == x. @[inline] pub fn f32_from_bits(b u32) f32 { - $if tinyc { - return *unsafe { &f32(&b) } - } - return unsafe { - U32_F32{ - u: b - }.f - } + p := *unsafe { &f32(&b) } + return p } // f64_bits returns the IEEE 754 binary representation of f, @@ -49,14 +27,8 @@ pub fn f32_from_bits(b u32) f32 { // and f64_bits(f64_from_bits(x)) == x. @[inline] pub fn f64_bits(f f64) u64 { - $if tinyc { - return *unsafe { &u64(&f) } - } - return unsafe { - U64_F64{ - f: f - }.u - } + p := *unsafe { &u64(&f) } + return p } // f64_from_bits returns the floating-point number corresponding @@ -65,12 +37,6 @@ pub fn f64_bits(f f64) u64 { // f64_from_bits(f64_bits(x)) == x. @[inline] pub fn f64_from_bits(b u64) f64 { - $if tinyc { - return *unsafe { &f64(&b) } - } - return unsafe { - U64_F64{ - u: b - }.f - } + p := *unsafe { &f64(&b) } + return p } -- 2.39.5