History log of /fuchsia/zircon/kernel/lib/libc/rand.c
Revision Date Author Comments
# 1843d346 23-Jul-2018 Nick Maniscalco <maniscalco@google.com>

[kernel] Change rand() to return only non-negative values

This particular rand() is used only in tests and the kernel heap.

Typical rand() implementations return a value between 0 and RAND_MAX.
Prior to this change, rand() could return negative values.

Rewrite kernel's rand() to behave like musl's.

Remove unused rand_add_entropy function.

Add atomic_cmpxchg_u64_relaxed and atomic_store_u64_relaxed, which are
used to implement rand().

Tested: Ran "k ut all" and "k thread_tests".

ZX-2400 #comment non-negative rand()

Change-Id: I8a2d3e006c308f1465e6b85b5f1aa8dca9d776a0


# f06cd6de 22-Jan-2018 George Kulakowski <kulakowski@google.com>

[kernel][rand] Make rand() and friends threadsafe

They are used across threads with no serialization, so update the
random state atomically.

Change-Id: I46c8aff553eef8fc828933df9c37deb9da79b261


# 53b9e1c8 15-Jun-2016 The Fuchsia Authors <authors@fuchsia.local>

[magenta] Initial commit