Skip to content

Commit

Permalink
Don't use floating-point environment methods from openlibm.
Browse files Browse the repository at this point in the history
  • Loading branch information
maleadt committed Nov 18, 2020
1 parent c9a149b commit 21333bb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions base/rounding.jl
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ See [`RoundingMode`](@ref) for available modes.
"""
:rounding

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

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

Expand Down
13 changes: 13 additions & 0 deletions src/jlapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,19 @@ JL_DLLEXPORT void jl_get_fenv_consts(int *ret)
ret[8] = FE_TOWARDZERO;
}

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


#ifdef JL_ASAN_ENABLED
JL_DLLEXPORT const char* __asan_default_options()
Expand Down

0 comments on commit 21333bb

Please sign in to comment.