From 79f2a52a391dab35132a2aa998757abea7f32533 Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Tue, 14 Apr 2020 22:29:37 -0500 Subject: avoid exporting a sleep() symbol from libcrypto Since it seems only MSVC lacks sleep(), and it's only used by apps, lets special-case that and make it available as a static inline function instead. --- crypto/CMakeLists.txt | 1 - crypto/compat/posix_win.c | 6 ------ include/compat/unistd.h | 8 +++++++- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/crypto/CMakeLists.txt b/crypto/CMakeLists.txt index e6cfc65..01effbf 100644 --- a/crypto/CMakeLists.txt +++ b/crypto/CMakeLists.txt @@ -808,7 +808,6 @@ if(WIN32) set(EXTRA_EXPORT ${EXTRA_EXPORT} posix_write) set(EXTRA_EXPORT ${EXTRA_EXPORT} posix_getsockopt) set(EXTRA_EXPORT ${EXTRA_EXPORT} posix_setsockopt) - set(EXTRA_EXPORT ${EXTRA_EXPORT} sleep) endif() if(NOT HAVE_ASPRINTF) diff --git a/crypto/compat/posix_win.c b/crypto/compat/posix_win.c index 4b4b5f5..30c93cd 100644 --- a/crypto/compat/posix_win.c +++ b/crypto/compat/posix_win.c @@ -242,10 +242,4 @@ int gettimeofday(struct timeval * tp, struct timezone * tzp) return 0; } -unsigned int sleep(unsigned int seconds) -{ - Sleep(seconds * 1000); - return seconds; -} - #endif diff --git a/include/compat/unistd.h b/include/compat/unistd.h index f521b94..4c4df10 100644 --- a/include/compat/unistd.h +++ b/include/compat/unistd.h @@ -37,7 +37,13 @@ ssize_t pwrite(int d, const void *buf, size_t nbytes, off_t offset); #define access _access -unsigned int sleep(unsigned int seconds); +#ifdef _MSC_VER +static inline unsigned int sleep(unsigned int seconds) +{ + Sleep(seconds * 1000); + return seconds; +} +#endif int ftruncate(int fd, off_t length); uid_t getuid(void); -- cgit v1.2.3-55-g6feb