| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
1) Unifdef USE_WEAK_SEEDING since it is too obsolete to support and makes
reading hard.
2) Instead of doing range transformation in each and every function here,
do it single time directly in do_rand(). One "mod" operation overhead is not
a big deal, but the code looks nicer and possible future functions additions
or PRNG change do not miss range transformations neither have unneeded ones.
3) Use POSIX argument types for visible functions (cosmetic).
Notes:
svn path=/stable/10/; revision=301445
|
| |
|
|
|
|
|
|
| |
can't be merged without conflicts and require merging of other versions
too and I don't want to go deep in that unmerged commits chain.
Notes:
svn path=/stable/10/; revision=301444
|
| |
|
|
| |
Notes:
svn path=/head/; revision=252698
|
| |
|
|
|
|
|
|
| |
srand() must be the same as srand(1); rand();
(yet one increment)
Notes:
svn path=/head/; revision=252668
|
| |
|
|
|
|
|
|
|
|
| |
to compensate back at the end incremented at the start internal
state.
MFC after: 2 weeks
Notes:
svn path=/head/; revision=252648
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
but ACM formula we use have internal state (and return value) in the
[1, 0x7ffffffe] range, so our RAND_MAX (0x7fffffff) is never reached
because it is off by one, zero is not reached too.
Correct both RAND_MAX and rand(3) return value, shifting last one
to the 0 by 1 subtracted, resulting POSIXed [0, 0x7ffffffd(=new RAND_MAX)]
range.
2) Add a checks for not overflowing on too big seeds. It may happens on
the machines, where sizeof(unsigned int) > 32 bits.
Reviewed by: bde [1]
MFC after: 2 weeks
Notes:
svn path=/head/; revision=252608
|
| |
|
|
|
|
|
|
| |
NetBSD, OpenBSD, and Android's Bionic number the clauses 1 through 3,
so follow suit to make comparison easier.
Notes:
svn path=/head/; revision=251672
|
| |
|
|
|
|
|
|
|
|
|
| |
source sysctl(KERN_ARND) and remove the fallback code.
Obtained from: OpenBSD
Reviewed by: secteam
MFC after: 1 month
Notes:
svn path=/head/; revision=249035
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
srandomdev(). This doesn't actually work
with any modern C compiler:
In particular, both clang and modern gcc
verisons silently elide any xor operation
with 'junk'.
Approved by: secteam
MFC after: 3 days
Notes:
svn path=/head/; revision=241373
|
| |
|
|
|
|
|
|
|
|
|
|
| |
This fixes a race condition where another thread may fork() before CLOEXEC
is set, unintentionally passing the descriptor to the child process.
This commit only adds O_CLOEXEC flags to open() or openat() calls where no
fcntl(fd, F_SETFD, FD_CLOEXEC) follows. The separate fcntl() call still
leaves a race window so it should be fixed later.
Notes:
svn path=/head/; revision=241046
|
| |
|
|
| |
Notes:
svn path=/head/; revision=174541
|
| |
|
|
|
|
|
|
|
| |
clause.
# If I've done so improperly on a file, please let me know.
Notes:
svn path=/head/; revision=165903
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
seed->first value correlation. It breaks rand_r()... Other possible methods
like shuffling inside aray will breaks rand_r() too, because it assumes
only one word state, i.e. nothing extra can be added after seed assignment
in srand().
BTW, for old formulae seed->first value correlation is not so monotonically
increased as with other Linear Congruential Generators of this type only
becase arithmetic overflow happens. But overflow affects distribution
and lower bits very badly, as many articles says, such type of overflow
not improves PRNG.
So, monotonically increased seed->first value correlation problem remains...
Notes:
svn path=/head/; revision=111026
|
| |
|
|
|
|
|
| |
after srand(1)
Notes:
svn path=/head/; revision=110421
|
| |
|
|
|
|
|
|
|
|
| |
to remove part of seed -> 1st value correlation. Correlation still remains
because of algorithm limits. Note that old algorithm have even stronger
correlation, especially in the lower bits area, but not eye-visible, as
current one.
Notes:
svn path=/head/; revision=110321
|
| |
|
|
|
|
|
|
|
|
| |
at 0 as designed. Its BSD adaptation tries to fight it by mapping 0 to
2147483647 after calculation, but this method not works since 2147483647
seed returns to 0 again on the next interation. Instead of after calculation
mapping, map 0 to another value _before_ calculation, so it never stucks.
Notes:
svn path=/head/; revision=110280
|
| |
|
|
|
|
|
| |
may store less amount bits for seed, than available. Fix it.
Notes:
svn path=/head/; revision=110236
|
| |
|
|
| |
Notes:
svn path=/head/; revision=108625
|
| |
|
|
|
|
|
| |
I believe have made all of libc .c's as consistent as possible.
Notes:
svn path=/head/; revision=92986
|
| |
|
|
|
|
|
|
| |
by asking some things that need unpredictable numbers to read
/dev/random instead.
Notes:
svn path=/head/; revision=85752
|
| |
|
|
|
|
|
|
|
|
| |
PR: 27858
Submitted by: Yoshihiro Koya <Yoshihiro.Koya@math.yokohama-cu.ac.jp>
Reviewed by: md5(1)
Approved by: markm
Notes:
svn path=/head/; revision=77851
|
| |
|
|
| |
Notes:
svn path=/head/; revision=75863
|
| |
|
|
|
|
|
| |
change of high word part too to produce more interesting seed distribution.
Notes:
svn path=/head/; revision=75862
|
| |
|
|
| |
Notes:
svn path=/head/; revision=75845
|
| |
|
|
|
|
|
|
|
| |
Even better formula from random() could not be intetgrated because rand_r()
supposed to store its state in the single variable (but table needed for
random() algorithm integration).
Notes:
svn path=/head/; revision=73156
|
| |
|
|
| |
Notes:
svn path=/head/; revision=47474
|
|
|
Notes:
svn path=/cvs2svn/branches/unlabeled-1.1.1/; revision=1573
|