@@ -226,10 +226,42 @@ if OF_UNLIKELY (extra != NULL) *extra = (char*)instance + instanceSize + extraAlignment; return instance; } + +uint32_t +of_random() +{ +#if defined(OF_HAVE_ARC4RANDOM) + return arc4random(); +#elif defined(OF_HAVE_RANDOM) + static BOOL initialized = NO; + + if (!initialized) { + struct timeval t; + + gettimeofday(&t, NULL); + srandom(t.tv_sec ^ t.tv_usec); + initialized = YES; + } + + return (random() << 16) | (random() & 0xFFFF); +#else + static BOOL initialized = NO; + + if (!initialized) { + struct timeval t; + + gettimeofday(&t, NULL); + srand(t.tv_sec ^ t.tv_usec); + initialized = YES; + } + + return (random() << 16) | (random() & 0xFFFF); +#endif +} const char* _NSPrintForDebugger(id object) { return [[object description] @@ -277,23 +309,11 @@ if ((of_num_cpus = sysconf(_SC_NPROCESSORS_CONF)) < 1) # endif of_num_cpus = 1; #endif -#if defined(OF_HAVE_ARC4RANDOM) - of_hash_seed = arc4random(); -#elif defined(OF_HAVE_RANDOM) - struct timeval t; - gettimeofday(&t, NULL); - srandom(t.tv_usec); - of_hash_seed = random(); -#else - struct timeval t; - gettimeofday(&t, NULL); - srand(t.tv_usec); - of_hash_seed = rand(); -#endif + of_hash_seed = of_random(); } + (void)initialize { }