diff --git a/base/.gitignore b/base/.gitignore index 3121265e546a4..463d2f01f7bdf 100644 --- a/base/.gitignore +++ b/base/.gitignore @@ -1,7 +1,6 @@ /pcre_h.jl /errno_h.jl /build_h.jl -/fenv_constants.jl /file_constants.jl /uv_constants.jl /version_git.jl diff --git a/base/Makefile b/base/Makefile index 9fd1d56cc1db1..9edca7ec8f417 100644 --- a/base/Makefile +++ b/base/Makefile @@ -12,7 +12,7 @@ else CPP_STDOUT := $(CPP) -E endif -all: $(addprefix $(BUILDDIR)/,pcre_h.jl errno_h.jl build_h.jl.phony fenv_constants.jl file_constants.jl uv_constants.jl version_git.jl.phony) +all: $(addprefix $(BUILDDIR)/,pcre_h.jl errno_h.jl build_h.jl.phony file_constants.jl uv_constants.jl version_git.jl.phony) PCRE_CONST := 0x[0-9a-fA-F]+|[0-9]+ ifeq ($(USE_SYSTEM_PCRE), 1) @@ -27,9 +27,6 @@ $(BUILDDIR)/pcre_h.jl: $(PCRE_INCL_PATH) $(BUILDDIR)/errno_h.jl: @$(call PRINT_PERL, echo '#include ' | $(CPP) -dM - | perl -nle 'print "const $$1 = Int32($$2)" if /^#define\s+(E\w+)\s+(\d+)\s*$$/' | LC_ALL=C sort > $@) -$(BUILDDIR)/fenv_constants.jl: $(SRCDIR)/../src/fenv_constants.h - @$(PRINT_PERL) $(CPP_STDOUT) -DJULIA $< | tail -n 8 | perl -ple 's/\sFE_UN\w+/ 0x10/g; s/\sFE_O\w+/ 0x08/g; s/\sFE_DI\w+/ 0x04/g; s/\sFE_INV\w+/ 0x01/g; s/\sFE_TON\w+/ 0x00/g; s/\sFE_UP\w+/ 0x800/g; s/\sFE_DO\w+/ 0x400/g; s/\sFE_TOW\w+/ 0xc00/g' > $@ - $(BUILDDIR)/file_constants.jl: $(SRCDIR)/../src/file_constants.h @$(call PRINT_PERL, $(CPP_STDOUT) -DJULIA $< | perl -nle 'print "$$1 0o$$2" if /^(\s*const\s+[A-z_]+\s+=)\s+(0[0-9]*)\s*$$/; print "$$1" if /^\s*(const\s+[A-z_]+\s+=\s+([1-9]|0x)[0-9A-z]*)\s*$$/' > $@) @@ -106,7 +103,7 @@ clean: rm -f $(BUILDDIR)/errno_h.jl rm -f $(BUILDDIR)/build_h.jl rm -f $(BUILDDIR)/build_h.jl.phony - rm -f $(BUILDDIR)/fenv_constants.jl + rm -f $(BUILDDIR)/fenv_constants.jl # To be removed rm -f $(BUILDDIR)/uv_constants.jl rm -f $(BUILDDIR)/file_constants.jl rm -f $(BUILDDIR)/version_git.jl diff --git a/base/rounding.jl b/base/rounding.jl index cbb740af82889..5ba4f6d6476d2 100644 --- a/base/rounding.jl +++ b/base/rounding.jl @@ -1,7 +1,20 @@ # This file is a part of Julia. License is MIT: http://julialang.org/license module Rounding -include(String(vcat(length(Core.ARGS)>=2?Core.ARGS[2].data:"".data, "fenv_constants.jl".data))) # include($BUILDROOT/base/fenv_constants.jl) + +let fenv_consts = Vector{Cint}(9) + ccall(:jl_get_fenv_consts, Void, (Ptr{Cint},), fenv_consts) + global const JL_FE_INEXACT = fenv_consts[1] + global const JL_FE_UNDERFLOW = fenv_consts[2] + global const JL_FE_OVERFLOW = fenv_consts[3] + global const JL_FE_DIVBYZERO = fenv_consts[4] + global const JL_FE_INVALID = fenv_consts[5] + + global const JL_FE_TONEAREST = fenv_consts[6] + global const JL_FE_UPWARD = fenv_consts[7] + global const JL_FE_DOWNWARD = fenv_consts[8] + global const JL_FE_TOWARDZERO = fenv_consts[9] +end export RoundingMode, RoundNearest, RoundToZero, RoundUp, RoundDown, RoundFromZero, diff --git a/src/fenv_constants.h b/src/fenv_constants.h deleted file mode 100644 index 5b3778e21987a..0000000000000 --- a/src/fenv_constants.h +++ /dev/null @@ -1,12 +0,0 @@ -// This file is a part of Julia. License is MIT: http://julialang.org/license - -#include -const JL_FE_INEXACT = FE_INEXACT -const JL_FE_UNDERFLOW = FE_UNDERFLOW -const JL_FE_OVERFLOW = FE_OVERFLOW -const JL_FE_DIVBYZERO = FE_DIVBYZERO -const JL_FE_INVALID = FE_INVALID -const JL_FE_TONEAREST = FE_TONEAREST -const JL_FE_UPWARD = FE_UPWARD -const JL_FE_DOWNWARD = FE_DOWNWARD -const JL_FE_TOWARDZERO = FE_TOWARDZERO diff --git a/src/jlapi.c b/src/jlapi.c index f4fbd12e5461a..7d11fc663143d 100644 --- a/src/jlapi.c +++ b/src/jlapi.c @@ -15,6 +15,9 @@ #ifdef __cplusplus extern "C" { +#include +#else +#include #endif #if defined(_OS_WINDOWS_) && !defined(_COMPILER_MINGW_) @@ -367,6 +370,19 @@ JL_DLLEXPORT void (jl_cpu_wake)(void) jl_cpu_wake(); } +JL_DLLEXPORT void jl_get_fenv_consts(int *ret) +{ + ret[0] = FE_INEXACT; + ret[1] = FE_UNDERFLOW; + ret[2] = FE_OVERFLOW; + ret[3] = FE_DIVBYZERO; + ret[4] = FE_INVALID; + ret[5] = FE_TONEAREST; + ret[6] = FE_UPWARD; + ret[7] = FE_DOWNWARD; + ret[8] = FE_TOWARDZERO; +} + #ifdef __cplusplus } #endif