Hello!
I have pushed a branch with a new implementation and API for obtaining random numbers in CHICKEN 5 to the git repository. The API design resulted mostly by ideas from Kooda and me, together with a lot of bikeshedding on #chicken. The implementation in the "randomness" branch is by me, including all errors and shortcomings. There are two methods of obtaining randomness, one strong one using whatever the OS provides, that is, /dev/urandom on Linux, or getrandom(2), if available. For quick pseudo random numbers, an implementation of the WELL512 PRNG is provided, which is relatively fast, compact and uses 64 bytes of state. The latter is initially seeded using rand(3). Interface: (pseudo-random-integer RANGE) returns a random integer between 0 and RANGE generated by the PRNG. RANGE may be a bignum. (set-pseudo-random-seed! BUFFER [SIZE]) seeds the PRNG with SIZE bytes of BUFFER, the buffer is treated as a cicrcular one, if it's size (or SIZE) is less than the size of the PRNG state. (random-bytes [BUFFER [SIZE]] fills BUFFER, which may be a string or a blob with SIZE random bytes. SIZE defaults to the size of the buffer, at most 256 bytes are read. By using differently named procedures, surprises using the old API can hopefully be reduced. This is all preliminary, and just a proposal. The scaling in C_random_fixnum is likely to be wrong or suboptimal. The code has not been tested yet on Windows, newer Linuxen that have getrandom(2) or OpenBSD. On OpenBSD arc4random_buf is used, on Windows RtlGenRandom. felix _______________________________________________ Chicken-hackers mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/chicken-hackers
