Skip to content

Commit b00ef11

Browse files
committed
give up on Crand for now :(
1 parent b9c5efe commit b00ef11

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

base/sysimg.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,14 +458,19 @@ include("docs/Docs.jl")
458458
using .Docs, .Markdown
459459
isdefined(Core, :Inference) && Docs.loaddocs(Core.Inference.CoreDocs.DOCS)
460460

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

466471
function __init__()
467472
# for the few uses of Crand in Base:
468-
ccall(:srand, Void, (Cuint,), floor(time()))
473+
# ccall(:srand, Void, (Cuint,), floor(time()))
469474
# Base library init
470475
reinit_stdio()
471476
global_logger(SimpleLogger(STDERR))

stdlib/Random/src/Random.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ abstract type AbstractRNG end
3232

3333
defaultRNG() = GLOBAL_RNG
3434

35+
### Crand from Base
36+
37+
Base.Crand(::Type{UInt32}) = rand(UInt32)
38+
Base.Crand(::Type{Float64}) = rand(Float64)
39+
3540
### integers
3641

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

0 commit comments

Comments
 (0)