diff -upN sysbench-0.4.8/sysbench/sysbench.h build.timc-patch.amd64/sysbench/sysbench.h --- sysbench-0.4.8/sysbench/sysbench.h 2006-05-05 13:15:45.000000000 +0000 +++ build.timc-patch.amd64/sysbench/sysbench.h 2008-12-05 01:17:18.000000000 +0000 @@ -51,8 +51,23 @@ #define SB_THREAD_MUTEX_LOCK() pthread_mutex_lock(&sb_globals.exec_mutex) #define SB_THREAD_MUTEX_UNLOCK() pthread_mutex_unlock(&sb_globals.exec_mutex) +/* Are we running on Solaris? */ +#if defined(sun) || defined(__sun) +#if defined(__SVR4) || defined(__svr4__) +#define SOLARIS +/* random(3C) identifies random() as unsafe in MT applications */ +#define RANDOM_THR_UNSAFE +#endif +#endif + #define SB_MAX_RND 0x3fffffffu -#define sb_rnd() (random() % SB_MAX_RND) +#ifdef RANDOM_THR_UNSAFE +#define sb_srnd(seed) (srand48(seed)) +#define sb_rnd() (lrand48() % SB_MAX_RND) +#else +#define sb_srnd(seed) (srandom((unsigned int)seed)) +#define sb_rnd() (random() % SB_MAX_RND) +#endif /* Sysbench commands */ diff -upN sysbench-0.4.8/sysbench/sysbench.c build.timc-patch.amd64/sysbench/sysbench.c --- sysbench-0.4.8/sysbench/sysbench.c 2006-01-31 11:15:53.000000000 +0000 +++ build.timc-patch.amd64/sysbench/sysbench.c 2008-12-04 21:00:37.000000000 +0000 @@ -310,7 +310,7 @@ void print_run_mode(sb_test_t *test) if (init_rng) { log_text(LOG_NOTICE, "Initializing random number generator from timer.\n"); - srandom(time(NULL)); + sb_srnd(time(NULL)); } log_text(LOG_NOTICE, ""); diff -upN sysbench-0.4.8/sysbench/tests/fileio/sb_fileio.c build.timc-patch.amd64/sysbench/tests/fileio/sb_fileio.c --- sysbench-0.4.8/sysbench/tests/fileio/sb_fileio.c 2006-01-31 11:15:49.000000000 +0000 +++ build.timc-patch.amd64/sysbench/tests/fileio/sb_fileio.c 2008-12-09 08:36:16.471606000 +0000 @@ -1612,7 +1612,7 @@ void file_fill_buffer(char *buf, unsigne unsigned int i; for (i = 0; i < len - (FILE_CHECKSUM_LENGTH + FILE_OFFSET_LENGTH); i++) - buf[i] = random() & 0xFF; + buf[i] = sb_rnd() & 0xFF; /* Store the checksum */ *(int *)(buf + i) = (int)crc32(0, buf, len -