Commit graph

328 commits

Author SHA1 Message Date
Bernhard Seckinger
97abb91952 Fix Issue 10902 - some phobos unittests take an excessive amount of time 2019-11-12 20:21:03 +01:00
Mike
b3416948d9 Replace sizediff_t with ptrdiff_t in std.random.d 2019-08-30 17:38:39 +09:00
Martin Nowak
b42d6291ab Merge remote-tracking branch 'upstream/stable' into merge_stable 2019-06-13 01:06:21 +02:00
Nicholas Wilson
5e72cf5c1d
Merge pull request #7013 from n8sh/rndGenUnusedImports
Remove unused imports from std.random.rndGen
2019-05-18 13:48:34 +08:00
Nathan Sashihara
e4a38e8ea5 Remove unused imports from std.random.rndGen 2019-05-17 19:49:58 -04:00
Nathan Sashihara
8d49976514 Issue 19836 followup - also fix on 32 bit machines
Changed the private enhanced seeding method for `rndGen` to something
that is fast on both 64 bit and 32 bit machines so can be enabled
regardless of architecture. When compiled with LDC it is about 1.35x
the speed of public `Mt19937.seed(uint)`.
2019-05-06 05:13:56 -04:00
Nathan Sashihara
b7389926ee Fix Issue 19837 - std.random.isUniformRNG(Rng, ElementType) should not require Rng.front to be annotated @property 2019-04-29 10:03:45 -04:00
Nathan Sashihara
5d0f1d3471 Fix Issue 19836 - Excessive probability of UUID collisions in std.uuid.randomUUID
On 64-bit architectures use 64 bits of entropy to initialize
thread-local `rndGen`.

The motivation for this change is std.uuid defaults to using `rndGen`
to generate UUIDs. If every `rndGen` starts in one of 2^^32 states then
if 77000 independent programs each generate a single UUID there is a 50%
chance that at least two of them generate the same initial UUID (and all
subsequent UUIDs would be identical as well). Not just Phobos but also
C++ boost::uuids::random_generator defaults to generating UUIDs with a
Mersenne Twister initialized from a 32-bit seed, exacerbating the
collision problem further. If instead there are 2^^64 possible initial
states of `rndGen` there can be over 5 billion independent `rndGen`s
before there is a 50% chance of two having identical initial states.

This change is limited to 64-bit architectures to avoid a measurable
performance decrease, because many programs are not generating UUIDs.
2019-04-28 16:16:11 -04:00
Rainer Schuetze
2e13c10025 add workaround for https://issues.dlang.org/show_bug.cgi?id=2396 to reduce compile time of unittests 2019-03-29 12:12:53 +01:00
Nathan Sashihara
25300d32d1 Fix issue 15853 - std.random save methods must be const
Revival of dlang/phobos#4136
2019-02-08 16:52:20 -05:00
Nathan Sashihara
21120a4972 Fix Issue 19580 - [non-DMD] std.random seed bootstrap: don't count on reading an uninitialized variable being treated as an ordinary read 2019-01-14 02:05:04 -05:00
Walter Bright
233d7d617f std.random: make dip1000 compliant 2019-01-10 03:33:08 -08:00
Nathan Sashihara
dc1a3d3efa Fix Issue 18680 - std.random.LinearCongruentialEngine has opEquals but no toHash
The custom opEquals is unnecessary. Autogenerated struct equals is correct.
2018-11-21 15:05:48 -05:00
Nathan Sashihara
dcca23edca Fix Issue 19164 - malloc may be considered pure when failure results in program exit (no need to reset errno) 2018-11-17 17:00:16 -05:00
The Dlang Bot
ac2c7c627d
Merge pull request #6424 from n8sh/xorshift-18327
Fix Issue 18327 - std.random.XorshiftEngine is parameterized by UIntType but only works with uint
merged-on-behalf-of: Nicholas Wilson <thewilsonator@users.noreply.github.com>
2018-11-15 16:49:25 +01:00
Nathan Sashihara
c75d6f712a Fix Issue 18595 & Issue 18596: replace MindstdRand0 w/SplitMix & templatize unpredictableSeed!UIntType 2018-11-14 05:40:48 -05:00
ARaspiK
9bb605b8d1
Made unittest for rndGen also nothrow @nogc
As requested by @ZombineDev
2018-11-11 08:08:01 +01:00
ARaspiK
3d54b63c5d
Make rndgen nothrow
This passes all Phobos tests and would be really nice for no-exceptions situations, instead of appending `assumeWontThrow` to everything. Should be quick.
2018-11-10 21:47:25 +01:00
Nathan Sashihara
c99a1855f6 Fix Issue 18327 - std.random.XorshiftEngine is parameterized by UIntType but only works with uint
Also:
* Add ability to specify shift directions.
* Allow arbitrary XorshiftEngine sizes instead of predefined list only.
* Except when array is small, use index to make speed of `popFront`
  independent of array size.
2018-09-24 08:55:00 -04:00
Iain Buclaw
fd5facfe04 posix.mak: Enforce whitespace before opening parenthesis for version conditions 2018-09-22 16:57:24 +02:00
Sebastian Wilzbach
91c9973d72
Merge pull request #6657 from n8sh/std-random-14001-19156
Fix Issue 14001 & Issue 19156 - `@nogc` std.random.randomCover and std.random.randomShuffle
2018-08-14 13:54:44 +02:00
Martin Nowak
050464eda6 Merge remote-tracking branch 'upstream/stable' into merge_stable
# Conflicts:
#	std/conv.d
2018-08-12 16:36:44 +02:00
Nathan Sashihara
3a212c0c72 Fix Issue 14001 - Optionally @nogc std.random.randomCover
Fix Issue 19156 - `@nogc` std.random.randomShuffle

Solution is to use a private `_randomIndex` function that is guaranteed
to be called only with valid bounds.
2018-08-10 18:24:34 -04:00
Martin Kinkelin
4de15cec63 Remove superfluous core.stdc.* dependencies in std.{conv,random} 2018-08-06 21:40:38 +02:00
The Dlang Bot
c7b1cf1994
Merge pull request #6576 from BBasile/rnd-cov-nogc-buff
RandomCover use a `@nogc` buffer to store already chosen results
merged-on-behalf-of: Nathan Sashihara <n8sh@users.noreply.github.com>
2018-07-15 12:25:40 +02:00
Sebastian Wilzbach
84b98fc3f0 Remove invalid Markdown backticks in std.{container,path,random}.d 2018-06-19 22:04:01 +02:00
Basile Burg
a716ad69f1 address review: use memcpy and disable assignment 2018-06-14 07:03:23 +02:00
Basile Burg
d3a933b748 remove wrong ddoc and make disable default ctor 2018-06-13 14:13:34 +02:00
Basile Burg
4b3d0ed23c address review: make the custom array pure 2018-06-13 07:24:07 +02:00
Basile Burg
047f7272cb address review: use static OOME and remove useless null check 2018-06-13 06:28:49 +02:00
Basile Burg
76491474ef cover postblit when heap storage is used 2018-06-12 09:42:01 +02:00
Basile Burg
acb48117d0 fine tweaks 2018-06-11 07:12:25 +02:00
Basile Burg
87a909c147 make impossible to change length and use a var to test if a bit field is used 2018-06-11 06:04:31 +02:00
Basile Burg
395e5e91c4 use a bit packed vector (w/o heap alloc) for small lengths 2018-06-10 21:32:26 +02:00
Basile Burg
a8869e2666 RandomCover use a @nogc buffer to store already chosen results 2018-06-10 15:26:09 +02:00
Sebastian Wilzbach
c324714fde Remove a few cases of underscore escaping 2018-06-04 13:05:01 +02:00
Basile Burg
cac1be5408 Annotates std.random unittests with @nogc when already possible 2018-04-21 22:01:19 +02:00
Jack Stouffer
e14f89e170 Make references to input ranges a link to isInputRange 2018-04-08 16:19:57 -04:00
The Dlang Bot
c1fcea4fdf
Merge pull request #6414 from n8sh/remove-unpredictableseed-from-unittests
Issue 18715 - Non-documented unittests should not use unpredictableSeed or default Random alias
merged-on-behalf-of: Nathan Sashihara <n8sh@users.noreply.github.com>
2018-04-05 01:41:30 +02:00
Nathan Sashihara
c1d1c0e874 Issue 18715 - Non-documented unittests should not use unpredictableSeed or default Random alias 2018-04-04 18:08:00 -04:00
Sebastian Wilzbach
152647e985 Add public examples to std.random 2018-04-04 11:42:56 +02:00
Sebastian Wilzbach
42894784dd Markdownify Phobos
$(D word) -> `word`
2018-04-02 22:32:47 +02:00
Sebastian Wilzbach
72bfff5a74 std.random: add a module-level booktable 2018-03-31 04:33:02 +02:00
Nathan Sashihara
e9f56ba3b2 Fix Issue 18663 - std.random.isSeedable has false positives 2018-03-26 11:45:40 -04:00
The Dlang Bot
4b166f3088
Merge pull request #6331 from jmdavis/revert
Revert fix for 18631.
merged-on-behalf-of: Jack Stouffer <jack@jackstouffer.com>
2018-03-23 15:51:52 +01:00
The Dlang Bot
cc256d8dc9
Merge pull request #5746 from n8sh/xorshift-fix
Fix Issue 17862 - std.random.XorshiftEngine.min is wrong when bits == 32
merged-on-behalf-of: Andrei Alexandrescu <andralex@users.noreply.github.com>
2018-03-23 01:28:46 +01:00
Jonathan M Davis
5d6d784c9a Revert fix for 18631.
The fix for 18631 broke code. Ranges cannot be marked with const or
inout in generic code. The range API does not require that any functions
be const or inout. In this case, with the changes, choice requires that
length and opSlice be const, breaking any code that uses a range with
choice that does not have a const length or opSlice (which is going to
be a large percentage of ranges with those functions which aren't
arrays).
2018-03-22 18:23:30 -06:00
The Dlang Bot
b87d28f2c7
Merge pull request #6267 from n8sh/unpredictableSeedOf-arc4random
Partially Fix Issue 18596: use arc4random when available for unpredictableSeed
merged-on-behalf-of: unknown
2018-03-22 23:49:27 +01:00
Nathan Sashihara
f39686c771 Partially Fix Issue 18596: use arc4random when available for unpredictableSeed 2018-03-22 03:57:47 -04:00
Basile Burg
8f2ae51cb8 proper usage of inout 2018-03-19 21:25:07 +01:00