Skip to content

Commit

Permalink
give up on Crand for now :(
Browse files Browse the repository at this point in the history
  • Loading branch information
rfourquet committed Dec 16, 2017
1 parent b9c5efe commit b00ef11
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 6 additions & 1 deletion base/sysimg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -458,14 +458,19 @@ include("docs/Docs.jl")
using .Docs, .Markdown
isdefined(Core, :Inference) && Docs.loaddocs(Core.Inference.CoreDocs.DOCS)

#= The following Crand function is not statistically good enough to meet the
requirements in test/error.jl, so we still have to depend on Random
# RAND_MAX at least 2^15-1 in theory, but we assume 2^16-1 (in practice, it's 2^31-1)
Crand() = ccall(:rand, Cuint, ())
Crand(::Type{UInt32}) = ((Crand() % UInt32) << 16) ⊻ (Crand() % UInt32)
Crand(::Type{Float64}) = Crand(UInt32) / 2^32
=#

function Crand end

function __init__()
# for the few uses of Crand in Base:
ccall(:srand, Void, (Cuint,), floor(time()))
# ccall(:srand, Void, (Cuint,), floor(time()))
# Base library init
reinit_stdio()
global_logger(SimpleLogger(STDERR))
Expand Down
5 changes: 5 additions & 0 deletions stdlib/Random/src/Random.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ abstract type AbstractRNG end

defaultRNG() = GLOBAL_RNG

### Crand from Base

Base.Crand(::Type{UInt32}) = rand(UInt32)
Base.Crand(::Type{Float64}) = rand(Float64)

### integers

# we define types which encode the generation of a specific number of bits
Expand Down

0 comments on commit b00ef11

Please sign in to comment.