File tree Expand file tree Collapse file tree 4 files changed +21
-7
lines changed Expand file tree Collapse file tree 4 files changed +21
-7
lines changed Original file line number Diff line number Diff line change @@ -209,6 +209,13 @@ cargo bench
209209open target/criterion/report/index.html
210210` ` `
211211
212+ To automatically detect the Minimum Supported Rust Version (MSRV):
213+
214+ ` ` ` sh
215+ cargo +stable install cargo-msrv
216+ cargo msrv find --ignore-lockfile
217+ ` ` `
218+
212219# # JavaScript
213220
214221# ## NodeJS
Original file line number Diff line number Diff line change @@ -16,15 +16,16 @@ categories = [
1616 " wasm" ,
1717 " external-ffi-bindings" ,
1818]
19- include = [" /rust/**" , " /c/**" , " /include/**" , " /build.rs" ]
19+ rust-version = " 1.64" # Introduced Core C FFI in stable Rust
20+ include = [" rust/**" , " c/**" , " include/**" , " build.rs" ]
2021
2122
2223[lib ]
2324name = " simsimd"
2425path = " rust/lib.rs"
2526
2627[build-dependencies ]
27- cc = " 1.0.83 "
28+ cc = " 1.2.36 "
2829
2930
3031[[bench ]]
@@ -48,6 +49,6 @@ default = []
4849std = []
4950
5051[dev-dependencies ]
51- criterion = { version = " 0.6 .0" }
52+ criterion = { version = " 0.7 .0" }
5253rand = { version = " 0.9.1" }
5354half = { version = " 2.6.0" }
Original file line number Diff line number Diff line change @@ -2,14 +2,14 @@ fn main() -> Result<(), cc::Error> {
22 let mut build = cc:: Build :: new ( ) ;
33
44 build
5+ // Prefer portable flags to support MSVC and older toolchains
6+ . std ( "c99" ) // Enforce C99 standard when supported
57 . file ( "c/lib.c" )
68 . include ( "include" )
79 . define ( "SIMSIMD_NATIVE_F16" , "0" )
810 . define ( "SIMSIMD_NATIVE_BF16" , "0" )
911 . define ( "SIMSIMD_DYNAMIC_DISPATCH" , "1" )
1012 . opt_level ( 3 )
11- // Prefer portable flags to support MSVC and older toolchains
12- . flag_if_supported ( "-std=c99" ) // Enforce C99 standard when supported
1313 . flag_if_supported ( "-pedantic" ) // Strict compliance when supported
1414 . warnings ( false ) ;
1515
Original file line number Diff line number Diff line change 7777pub type Distance = f64 ;
7878pub type ComplexProduct = ( f64 , f64 ) ;
7979
80+ /// Compatibility function for pre 1.85 Rust versions lacking `f32::abs`.
81+ #[ inline( always) ]
82+ fn f32_abs_compat ( x : f32 ) -> f32 {
83+ f32:: from_bits ( x. to_bits ( ) & 0x7FFF_FFFF )
84+ }
85+
8086#[ link( name = "simsimd" ) ]
8187extern "C" {
8288
@@ -251,7 +257,7 @@ impl f16 {
251257 /// Returns the absolute value of self.
252258 #[ inline( always) ]
253259 pub fn abs ( self ) -> Self {
254- Self :: from_f32 ( self . to_f32 ( ) . abs ( ) )
260+ Self :: from_f32 ( f32_abs_compat ( self . to_f32 ( ) ) )
255261 }
256262
257263 /// Returns the largest integer less than or equal to a number.
@@ -425,7 +431,7 @@ impl bf16 {
425431 /// Returns the absolute value of self.
426432 #[ inline( always) ]
427433 pub fn abs ( self ) -> Self {
428- Self :: from_f32 ( self . to_f32 ( ) . abs ( ) )
434+ Self :: from_f32 ( f32_abs_compat ( self . to_f32 ( ) ) )
429435 }
430436
431437 /// Returns the largest integer less than or equal to a number.
You can’t perform that action at this time.
0 commit comments