diff --git a/CMakeLists.txt b/CMakeLists.txt index 133dcad9a..cd27fd05f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -117,6 +117,7 @@ check_function_exists(getprogname HAVE_GETPROGNAME) check_symbol_exists(localtime_r time.h HAVE_LOCALTIME_R) check_symbol_exists(localtime_s time.h HAVE_LOCALTIME_S) check_function_exists(memcpy_s HAVE_MEMCPY_S) +check_function_exists(random HAVE_RANDOM) check_function_exists(setmode HAVE_SETMODE) check_symbol_exists(snprintf stdio.h HAVE_SNPRINTF) check_symbol_exists(snprintf_s stdio.h HAVE_SNPRINTF_S) diff --git a/lib/zip_random_unix.c b/lib/zip_random_unix.c index fd9a67d29..e8ed5bf70 100644 --- a/lib/zip_random_unix.c +++ b/lib/zip_random_unix.c @@ -93,12 +93,21 @@ zip_random_uint32(void) { return value; } +#ifdef HAVE_RANDOM if (!seeded) { srandom((unsigned int)time(NULL)); seeded = true; } return (zip_uint32_t)random(); +#else + if (!seeded) { + srand((unsigned int)time(NULL)); + seeded = true; + } + + return (zip_uint32_t)rand(); +#endif } #endif