Skip to content

Commit

Permalink
Look for fesetround in libm rather than the executable
Browse files Browse the repository at this point in the history
We usually get lucky because GCC's runtime library includes this functions.
However, their proper place is in the math library and Clang's runtime
library does not include these functions on windows, so without this change
the function is not found.
  • Loading branch information
Keno authored and tkelman committed May 19, 2016
1 parent 68a38d2 commit 187ea1a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
6 changes: 4 additions & 2 deletions base/rounding.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export
rounding, setrounding,
get_zero_subnormals, set_zero_subnormals

const libm = Base.libm_name

## rounding modes ##
immutable RoundingMode{T} end

Expand Down Expand Up @@ -41,8 +43,8 @@ function from_fenv(r::Integer)
end
end

setrounding_raw{T<:Union{Float32,Float64}}(::Type{T},i::Integer) = ccall(:fesetround, Int32, (Int32,), i)
rounding_raw{T<:Union{Float32,Float64}}(::Type{T}) = ccall(:fegetround, Int32, ())
setrounding_raw{T<:Union{Float32,Float64}}(::Type{T},i::Integer) = ccall((:fesetround, libm), Int32, (Int32,), i)
rounding_raw{T<:Union{Float32,Float64}}(::Type{T}) = ccall((:fegetround, libm), Int32, ())

setrounding{T<:Union{Float32,Float64}}(::Type{T},r::RoundingMode) = setrounding_raw(T,to_fenv(r))
rounding{T<:Union{Float32,Float64}}(::Type{T}) = from_fenv(rounding_raw(T))
Expand Down
12 changes: 6 additions & 6 deletions base/sysimg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ Array{T}(::Type{T}, m::Integer) = Array{T,1}(Int(m))
Array{T}(::Type{T}, m::Integer,n::Integer) = Array{T,2}(Int(m),Int(n))
Array{T}(::Type{T}, m::Integer,n::Integer,o::Integer) = Array{T,3}(Int(m),Int(n),Int(o))

# For OS specific stuff
include(String(vcat(length(Core.ARGS)>=2?Core.ARGS[2].data:"".data, "build_h.jl".data))) # include($BUILDROOT/base/build_h.jl)
include(String(vcat(length(Core.ARGS)>=2?Core.ARGS[2].data:"".data, "version_git.jl".data))) # include($BUILDROOT/base/version_git.jl)
include("osutils.jl")
include("c.jl")

# numeric operations
include("hashing.jl")
include("rounding.jl")
Expand Down Expand Up @@ -112,12 +118,6 @@ typealias StridedVector{T,A<:Union{DenseArray,StridedReshapedArray},I<:Tuple{Var
typealias StridedMatrix{T,A<:Union{DenseArray,StridedReshapedArray},I<:Tuple{Vararg{Union{RangeIndex, NoSlice, AbstractCartesianIndex}}}} Union{DenseArray{T,2}, SubArray{T,2,A,I}, StridedReshapedArray{T,2}}
typealias StridedVecOrMat{T} Union{StridedVector{T}, StridedMatrix{T}}

# For OS specific stuff
include(String(vcat(length(Core.ARGS)>=2?Core.ARGS[2].data:"".data, "build_h.jl".data))) # include($BUILDROOT/base/build_h.jl)
include(String(vcat(length(Core.ARGS)>=2?Core.ARGS[2].data:"".data, "version_git.jl".data))) # include($BUILDROOT/base/version_git.jl)
include("osutils.jl")
include("c.jl")

# Core I/O
include("io.jl")
include("iostream.jl")
Expand Down

0 comments on commit 187ea1a

Please sign in to comment.