Skip to content

Commit 21333bb

Browse files
committed
Don't use floating-point environment methods from openlibm.
1 parent c9a149b commit 21333bb

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

base/rounding.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ See [`RoundingMode`](@ref) for available modes.
151151
"""
152152
:rounding
153153

154-
setrounding_raw(::Type{<:Union{Float32,Float64}}, i::Integer) = ccall((:fesetround, Base.libm_name), Int32, (Int32,), i)
155-
rounding_raw(::Type{<:Union{Float32,Float64}}) = ccall((:fegetround, Base.libm_name), Int32, ())
154+
setrounding_raw(::Type{<:Union{Float32,Float64}}, i::Integer) = ccall(:jl_set_fenv_rounding, Int32, (Int32,), i)
155+
rounding_raw(::Type{<:Union{Float32,Float64}}) = ccall(:jl_get_fenv_rounding, Int32, ())
156156

157157
rounding(::Type{T}) where {T<:Union{Float32,Float64}} = from_fenv(rounding_raw(T))
158158

src/jlapi.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,19 @@ JL_DLLEXPORT void jl_get_fenv_consts(int *ret)
475475
ret[8] = FE_TOWARDZERO;
476476
}
477477

478+
// TODO: Windows binaries currently load msvcrt which doesn't have these C99 functions.
479+
// the mingw compiler ships additional definitions, but only for use in C code.
480+
// remove this when we switch to ucrt, make the version in openlibm portable,
481+
// or figure out how to reexport the defs from libmingwex (see JuliaLang/julia#38466).
482+
JL_DLLEXPORT int jl_get_fenv_rounding(void)
483+
{
484+
return fegetround();
485+
}
486+
JL_DLLEXPORT int jl_set_fenv_rounding(int i)
487+
{
488+
return fesetround(i);
489+
}
490+
478491

479492
#ifdef JL_ASAN_ENABLED
480493
JL_DLLEXPORT const char* __asan_default_options()

0 commit comments

Comments
 (0)