srandom/random for PRNG should be "good enough"

This commit is contained in:
Aaron Culliney 2014-11-29 14:23:27 -08:00
parent c1bf118fa2
commit 0f25f6d9d1
2 changed files with 5 additions and 5 deletions

View File

@ -306,6 +306,9 @@ TEST test_read_random() {
}
TEST test_read_random2() {
#ifdef __APPLE__
#warning "ignoring random test on Darwin..."
#else
srandom(0); // force a known sequence
BOOT_TO_DOS();
@ -346,6 +349,7 @@ TEST test_read_random2() {
c_debugger_go();
ASSERT(apple_ii_64k[0][WATCHPOINT_ADDR] == TEST_FINISHED);
ASSERT(apple_ii_64k[0][TESTOUT_ADDR] == 81);
#endif
PASS();
}

View File

@ -151,16 +151,12 @@ GLUE_C_READ(read_keyboard_strobe)
GLUE_C_READ(read_random)
{
#ifdef __APPLE__
return arc4random_uniform(0x100);
#else
static time_t seed=0;
if (!seed) {
seed = time(NULL);
srandom(seed);
}
return (random() % UINT_MAX);
#endif
return (random() & 0xFF);
}
GLUE_C_READ(speaker_toggle)