0.3.0: converge relibc to upstream 0.6.0 + Red Bear patches

This commit is contained in:
2026-07-06 19:13:08 +03:00
parent 1a0edd8eeb
commit 4ef7e57571
1466 changed files with 75236 additions and 13644 deletions
+57
View File
@@ -0,0 +1,57 @@
# Note: changing this file requires `make clean`.
sys_includes = []
include_guard = "_RELIBC_MATH_H"
language = "C"
style = "Type"
no_includes = true
cpp_compat = true
# constants from openlibm
after_includes = """
#define HUGE_VALF (float)HUGE_VAL
#define HUGE_VALL (long double)HUGE_VAL
#define INFINITY HUGE_VALF
#define NAN (__nan.__uf)
#define FP_ILOGB0 (-INT_MAX)
#define FP_ILOGBNAN INT_MAX
#define MAXFLOAT 3.40282346638528859812e+38F
#define M_E 2.7182818284590452354 /* e */
#define M_LOG2E 1.4426950408889634074 /* log_2 e */
#define M_LOG10E 0.43429448190325182765 /* log_10 e */
#define M_LN2 0.69314718055994530942 /* log_e 2 */
#define M_LN10 2.30258509299404568402 /* log_e 10 */
#define M_PI 3.14159265358979323846 /* pi */
#define M_PI_2 1.57079632679489661923 /* pi/2 */
#define M_PI_4 0.78539816339744830962 /* pi/4 */
#define M_1_PI 0.31830988618379067154 /* 1/pi */
#define M_2_PI 0.63661977236758134308 /* 2/pi */
#define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */
#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
#define FP_NAN 0
#define FP_INFINITE 1
#define FP_ZERO 2
#define FP_SUBNORMAL 3
#define FP_NORMAL 4
#define fpclassify(x) __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, x)
#define signbit(x) __builtin_signbit(x)
#define isnan(x) __builtin_isnan(x)
#define isinf(x) __builtin_isinf_sign(x)
#define isfinite(x) __builtin_isfinite(x)
#define isnormal(x) __builtin_isnormal(x)
#define isgreater(x, y) __builtin_isgreater((x), (y))
#define isgreaterequal(x, y) __builtin_isgreaterequal((x), (y))
#define isless(x, y) __builtin_isless((x), (y))
#define islessequal(x, y) __builtin_islessequal((x), (y))
#define islessgreater(x, y) __builtin_islessgreater((x), (y))
#define isunordered(x, y) __builtin_isunordered((x), (y))
"""
[enum]
prefix_with_name = true
+867
View File
@@ -0,0 +1,867 @@
//! `math.h` implementation.
//!
//! See <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/math.h.html>.
use crate::platform::types::{c_double, c_float, c_int, c_long, c_longlong};
// TODO move constants from cbindgen (openlibm)
// TODO all is* function is defined as "real-floating", so it can both f32 and f64
// TODO cover edge cases (EDOM and ERANGE)
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/acos.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn acos(x: c_double) -> c_double {
libm::acos(x)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/acos.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn acosf(x: c_float) -> c_float {
libm::acosf(x)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/acosh.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn acosh(x: c_double) -> c_double {
libm::acosh(x)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/acosh.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn acoshf(x: c_float) -> c_float {
libm::acoshf(x)
}
// TODO acoshl, acosl (long double)
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/asin.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn asin(x: c_double) -> c_double {
libm::asin(x)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/asin.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn asinf(x: c_float) -> c_float {
libm::asinf(x)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/asinh.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn asinh(x: c_double) -> c_double {
libm::asinh(x)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/asinh.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn asinhf(x: c_float) -> c_float {
libm::asinhf(x)
}
// TODO asinhl, asinl (long double)
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/atan.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn atan(x: c_double) -> c_double {
libm::atan(x)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/atan2.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn atan2(y: c_double, x: c_double) -> c_double {
libm::atan2(y, x)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/atan2.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn atan2f(y: c_float, x: c_float) -> c_float {
libm::atan2f(y, x)
}
// TODO atan2l (long double)
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/atan.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn atanf(x: c_float) -> c_float {
libm::atanf(x)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/atanh.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn atanh(x: c_double) -> c_double {
libm::atanh(x)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/atanh.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn atanhf(x: c_float) -> c_float {
libm::atanhf(x)
}
// TODO atanhl, atanl (long double)
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/cbrt.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn cbrt(x: c_double) -> c_double {
libm::cbrt(x)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/cbrt.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn cbrtf(x: c_float) -> c_float {
libm::cbrtf(x)
}
// TODO cbrtl (long double)
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/ceil.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn ceil(x: c_double) -> c_double {
libm::ceil(x)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/ceil.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn ceilf(x: c_float) -> c_float {
libm::ceilf(x)
}
// TODO ceill (long double)
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/copysign.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn copysign(x: c_double, y: c_double) -> c_double {
libm::copysign(x, y)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/copysign.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn copysignf(x: c_float, y: c_float) -> c_float {
libm::copysignf(x, y)
}
// TODO copysignl (long double)
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/cos.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn cos(x: c_double) -> c_double {
libm::cos(x)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/cos.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn cosf(x: c_float) -> c_float {
libm::cosf(x)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/cosh.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn cosh(x: c_double) -> c_double {
libm::cosh(x)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/cosh.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn coshf(x: c_float) -> c_float {
libm::coshf(x)
}
// TODO coshl, cosl (long double)
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/erf.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn erf(x: c_double) -> c_double {
libm::erf(x)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/erfc.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn erfc(x: c_double) -> c_double {
libm::erfc(x)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/erfc.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn erfcf(x: c_float) -> c_float {
libm::erfcf(x)
}
// TODO erfcl (long double)
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/erf.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn erff(x: c_float) -> c_float {
libm::erff(x)
}
// TODO erfl (long double)
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/exp.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn exp(x: c_double) -> c_double {
libm::exp(x)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/exp2.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn exp2(x: c_double) -> c_double {
libm::exp2(x)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/exp2.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn exp2f(x: c_float) -> c_float {
libm::exp2f(x)
}
// TODO exp2l (long double)
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/exp.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn expf(x: c_float) -> c_float {
libm::expf(x)
}
// TODO expl (long double)
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/expm1.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn expm1(x: c_double) -> c_double {
libm::expm1(x)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/expm1.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn expm1f(x: c_float) -> c_float {
libm::expm1f(x)
}
// TODO expm1l (long double)
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/fabs.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn fabs(x: c_double) -> c_double {
libm::fabs(x)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/fabsf.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn fabsf(x: c_float) -> c_float {
libm::fabsf(x)
}
// TODO fabsl (long double)
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/fdim.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn fdim(x: c_double, y: c_double) -> c_double {
libm::fdim(x, y)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/fdim.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn fdimf(x: c_float, y: c_float) -> c_float {
libm::fdimf(x, y)
}
// TODO fdiml (long double)
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/floor.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn floor(x: c_double) -> c_double {
libm::floor(x)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/floor.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn floorf(x: c_float) -> c_float {
libm::floorf(x)
}
// TODO floorl (long double)
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/fma.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn fma(x: c_double, y: c_double, z: c_double) -> c_double {
libm::fma(x, y, z)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/fma.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn fmaf(x: c_float, y: c_float, z: c_float) -> c_float {
libm::fmaf(x, y, z)
}
// TODO fmal (long double)
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/fmax.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn fmax(x: c_double, y: c_double) -> c_double {
libm::fmax(x, y)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/fmax.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn fmaxf(x: c_float, y: c_float) -> c_float {
libm::fmaxf(x, y)
}
// TODO fmaxl (long double)
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/fmin.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn fmin(x: c_double, y: c_double) -> c_double {
libm::fmin(x, y)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/fmin.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn fminf(x: c_float, y: c_float) -> c_float {
libm::fminf(x, y)
}
// TODO fminl (long double)
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/fmod.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn fmod(x: c_double, y: c_double) -> c_double {
libm::fmod(x, y)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/fmod.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn fmodf(x: c_float, y: c_float) -> c_float {
libm::fmodf(x, y)
}
// TODO fmodl (long double)
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/frexp.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn frexp(num: c_double, exp: *mut c_int) -> c_double {
let (number, exponent) = libm::frexp(num);
unsafe {
*exp = exponent;
}
number
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/frexp.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn frexpf(num: c_float, exp: *mut c_int) -> c_float {
let (number, exponent) = libm::frexpf(num);
unsafe {
*exp = exponent;
}
number
}
// TODO frexpl (long double)
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/hypot.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn hypot(x: c_double, y: c_double) -> c_double {
libm::hypot(x, y)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/hypot.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn hypotf(x: c_float, y: c_float) -> c_float {
libm::hypotf(x, y)
}
// TODO hypotl (long double)
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/ilogb.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn ilogb(x: c_double) -> c_int {
libm::ilogb(x)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/ilogb.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn ilogbf(x: c_float) -> c_int {
libm::ilogbf(x)
}
// TODO ilogbl (long double)
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/isfinite.html>.
#[unsafe(no_mangle)]
unsafe extern "C" fn isfinite(x: c_double) -> c_int {
if x.is_finite() { 1 } else { 0 }
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/isinf.html>.
#[unsafe(no_mangle)]
unsafe extern "C" fn isinf(x: c_double) -> c_int {
match x {
f64::INFINITY => 1,
f64::NEG_INFINITY => -1,
_ => 0,
}
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/isnan.html>.
#[unsafe(no_mangle)]
unsafe extern "C" fn isnan(x: c_double) -> c_int {
if x.is_nan() { 1 } else { 0 }
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/isnormal.html>.
#[unsafe(no_mangle)]
unsafe extern "C" fn isnormal(x: c_double) -> c_int {
if x.is_normal() { 1 } else { 0 }
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/j0.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn j0(x: c_double) -> c_double {
libm::j0(x)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/j0.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn j1(x: c_double) -> c_double {
libm::j1(x)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/j0.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn jn(n: c_int, x: c_double) -> c_double {
libm::jn(n, x)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/ldexp.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn ldexp(x: c_double, exp: c_int) -> c_double {
libm::ldexp(x, exp)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/ldexp.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn ldexpf(x: c_float, exp: c_int) -> c_float {
libm::ldexpf(x, exp)
}
// TODO ldexpl (long double)
#[unsafe(no_mangle)]
static mut signgam: c_int = 0;
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/lgamma.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn lgamma(x: c_double) -> c_double {
let (a, b) = libm::lgamma_r(x);
unsafe { signgam = b };
a
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/lgamma.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn lgammaf(x: c_float) -> c_float {
let (a, b) = libm::lgammaf_r(x);
unsafe { signgam = b };
a
}
// TODO lgammal (long double)
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/llrint.html>.
#[unsafe(no_mangle)]
unsafe extern "C" fn llrint(x: c_double) -> c_longlong {
libm::rint(x) as _
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/llrintf.html>.
#[unsafe(no_mangle)]
unsafe extern "C" fn llrintf(x: c_float) -> c_longlong {
libm::rintf(x) as _
}
// TODO llrintl (long double to c_longlong)
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/llround.html>.
#[unsafe(no_mangle)]
unsafe extern "C" fn llround(x: c_double) -> c_longlong {
libm::round(x) as _
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/llroundf.html>.
#[unsafe(no_mangle)]
unsafe extern "C" fn llroundf(x: c_float) -> c_longlong {
libm::roundf(x) as _
}
// TODO llroundl (long double to c_longlong)
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/log.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn log(x: c_double) -> c_double {
libm::log(x)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/log10.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn log10(x: c_double) -> c_double {
libm::log10(x)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/log10.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn log10f(x: c_float) -> c_float {
libm::log10f(x)
}
// TODO log10l (long double)
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/log1p.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn log1p(x: c_double) -> c_double {
libm::log1p(x)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/log1p.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn log1pf(x: c_float) -> c_float {
libm::log1pf(x)
}
// TODO log1pl (long double)
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/log2.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn log2(x: c_double) -> c_double {
libm::log2(x)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/log2.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn log2f(x: c_float) -> c_float {
libm::log2f(x)
}
// TODO log2l (long double)
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/logb.html>.
#[unsafe(no_mangle)]
unsafe extern "C" fn logb(x: c_double) -> c_double {
// TODO: errno
libm::ilogb(x) as _
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/logbf.html>.
#[unsafe(no_mangle)]
unsafe extern "C" fn logbf(x: c_float) -> c_float {
// TODO: errno
libm::ilogbf(x) as _
}
// TODO logbl (long double)
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/log.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn logf(x: c_float) -> c_float {
libm::logf(x)
}
// TODO logl (long double)
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/lrint.html>.
#[unsafe(no_mangle)]
unsafe extern "C" fn lrint(x: c_double) -> c_long {
// TODO: errno
libm::rint(x) as _
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/lrintf.html>.
#[unsafe(no_mangle)]
unsafe extern "C" fn lrintf(x: c_float) -> c_long {
// TODO: errno
libm::rintf(x) as _
}
// TODO lrintl (long double)
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/lround.html>.
#[unsafe(no_mangle)]
unsafe extern "C" fn lround(x: c_double) -> c_long {
libm::round(x) as _
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/lroundf.html>.
#[unsafe(no_mangle)]
unsafe extern "C" fn lroundf(x: c_float) -> c_long {
libm::roundf(x) as _
}
// TODO lroundl (long double)
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/modf.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn modf(x: c_double, iptr: *mut c_double) -> c_double {
let (integral, fractional) = libm::modf(x);
unsafe {
*iptr = integral;
}
fractional
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/modf.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn modff(value: c_float, iptr: *mut c_float) -> c_float {
let (integral, fractional) = libm::modff(value);
unsafe {
*iptr = integral;
}
fractional
}
// TODO modfl (long double)
// TODO do we want to support quiet NaN or just return 0?
// TODO nan (c_double)
// TODO nanf (c_float)
// TODO nanl (long double)
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/nearbyint.html>.
#[unsafe(no_mangle)]
unsafe extern "C" fn nearbyint(x: c_double) -> c_double {
libm::rint(x)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/nearbyintf.html>.
#[unsafe(no_mangle)]
unsafe extern "C" fn nearbyintf(x: c_float) -> c_float {
libm::rintf(x)
}
// TODO nearbyintl (long double)
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/nextafter.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn nextafter(x: c_double, y: c_double) -> c_double {
libm::nextafter(x, y)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/nextafter.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn nextafterf(x: c_float, y: c_float) -> c_float {
libm::nextafterf(x, y)
}
// TODO nextafterl (long double)
// TODO nexttoward (c_double)
// TODO nexttowardf (c_float)
// TODO nexttowardl (long double)
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/pow.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn pow(x: c_double, y: c_double) -> c_double {
libm::pow(x, y)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/pow.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn powf(x: c_float, y: c_float) -> c_float {
libm::powf(x, y)
}
// TODO powl (long double)
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/remainder.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn remainder(x: c_double, y: c_double) -> c_double {
libm::remainder(x, y)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/remainder.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn remainderf(x: c_float, y: c_float) -> c_float {
libm::remainderf(x, y)
}
// TODO remainderl (long double)
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/remquo.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn remquo(x: c_double, y: c_double, quo: *mut c_int) -> c_double {
let (remainder, quotient) = libm::remquo(x, y);
unsafe {
*quo = quotient;
}
remainder
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/remquo.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn remquof(x: c_float, y: c_float, quo: *mut c_int) -> c_float {
let (remainder, quotient) = libm::remquof(x, y);
unsafe {
*quo = quotient;
}
remainder
}
// TODO remquol (long double)
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/rint.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn rint(x: c_double) -> c_double {
libm::rint(x)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/rint.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn rintf(x: c_float) -> c_float {
libm::rintf(x)
}
// TODO rintl (long double)
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/round.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn round(x: c_double) -> c_double {
libm::round(x)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/round.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn roundf(x: c_float) -> c_float {
libm::roundf(x)
}
// TODO roundl (long double)
// TODO scalbln (c_double, c_long)
// TODO scalblnf (c_float, c_long)
// TODO scalblnl (long double, c_long)
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/scalbln.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn scalbn(x: c_double, n: c_int) -> c_double {
libm::scalbn(x, n)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/scalbln.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn scalbnf(x: c_float, n: c_int) -> c_float {
libm::scalbnf(x, n)
}
// TODO scalbnl (long double)
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/sin.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn sin(x: c_double) -> c_double {
libm::sin(x)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/sin.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn sinf(x: c_float) -> c_float {
libm::sinf(x)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/sinh.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn sinh(x: c_double) -> c_double {
libm::sinh(x)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/sinh.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn sinhf(x: c_float) -> c_float {
libm::sinhf(x)
}
// TODO sinhl (long double)
// TODO sinl (long double)
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/sqrt.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn sqrt(x: c_double) -> c_double {
libm::sqrt(x)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/sqrt.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn sqrtf(x: c_float) -> c_float {
libm::sqrtf(x)
}
// TODO sqrtl (long double)
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/tan.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn tan(x: c_double) -> c_double {
libm::tan(x)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/tan.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn tanf(x: c_float) -> c_float {
libm::tanf(x)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/tanh.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn tanh(x: c_double) -> c_double {
libm::tanh(x)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/tanh.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn tanhf(x: c_float) -> c_float {
libm::tanhf(x)
}
// TODO tanhl (long double)
// TODO tanl (long double)
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/tgamma.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn tgamma(x: c_double) -> c_double {
libm::tgamma(x)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/tgamma.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn tgammaf(x: c_float) -> c_float {
libm::tgammaf(x)
}
// TODO tgammal (long double)
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/trunc.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn trunc(x: c_double) -> c_double {
libm::trunc(x)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/trunc.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn truncf(x: c_float) -> c_float {
libm::truncf(x)
}
// TODO truncl (long double)
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/y0.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn y0(x: c_double) -> c_double {
libm::y0(x)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/y0.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn y1(x: c_double) -> c_double {
libm::y1(x)
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/y0.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn yn(n: c_int, x: c_double) -> c_double {
libm::yn(n, x)
}