Skip to content

ARM Thumb targets need fmax*/fmin* intrinsics #354

Closed
@saleemrashid

Description

@saleemrashid

core::f32 and core::f64 expose max and min, but these use the fmax*/fmin* intrinsics, which aren't exposed for the Thumb targets

// only for the thumb*-none-eabi* targets
#[cfg(all(target_arch = "arm", target_os = "none"))]
no_mangle! {
// `f64 % f64`
fn fmod(x: f64, y: f64) -> f64;
// `f32 % f32`
fn fmodf(x: f32, y: f32) -> f32;
}

https://rust.godbolt.org/z/B4tB6w

#![no_std]

pub fn maxf(a: f32, b: f32) -> f32 {
    a.max(b)
}

pub fn minf(a: f32, b: f32) -> f32 {
    a.min(b)
}

pub fn max(a: f64, b: f64) -> f64 {
    a.max(b)
}

pub fn min(a: f64, b: f64) -> f64 {
    a.min(b)
}
example::maxf:
        b       fmaxf

example::minf:
        b       fminf

example::max:
        b       fmax

example::min:
        b       fmin

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions