diff options
author | Richard Levitte <levitte@openssl.org> | 2022-10-03 07:10:34 +0200 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2022-10-06 08:01:09 +0200 |
commit | 82d28c6b3cbd8074faaa34cc2ce57dacc580792f (patch) | |
tree | ee3ec2399066e8e508512d4e4c7eb6342f44c3a9 /include | |
parent | a8572674f12ceb39f7e66ccbaa8918b922c76739 (diff) |
Rename ossl_sleep() to OSSL_sleep() and make it public
ossl_sleep() was implemented as a static inline function in internal/e_os.h,
using usleep() on Unix and Sleep() on Windows. So far well and good.
However, it also has a fallback implementation for systems that do not have
usleep() or Sleep(), and that implementation happens to use ossl_time_now(),
which is a normal function, private to libcrypto, and is judged to be too
complex to sanely make into a static inline function.
This fallback creates a problem, because we do use ossl_sleep() in apps/ and
a few test programs in test/, and when they are linked with libcrypto in
shared library form, ossl_time_now() can't be found, since it's not publicly
exposed.
Something needs to give, and the easiest, and hopefully sanest answer is to
make ossl_sleep() a publicly exposed function, which requires a slight name
change.
Documentation and 'make update' result included.
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/19330)
Diffstat (limited to 'include')
-rw-r--r-- | include/internal/e_os.h | 44 | ||||
-rw-r--r-- | include/openssl/crypto.h.in | 2 |
2 files changed, 2 insertions, 44 deletions
diff --git a/include/internal/e_os.h b/include/internal/e_os.h index 059fae4040..6fc1c74c97 100644 --- a/include/internal/e_os.h +++ b/include/internal/e_os.h @@ -286,50 +286,6 @@ struct servent *getservbyname(const char *name, const char *proto); # endif /* end vxworks */ -/* system-specific variants defining ossl_sleep() */ -#if defined(OPENSSL_SYS_UNIX) || defined(__DJGPP__) -# include <unistd.h> -static ossl_inline void ossl_sleep(unsigned long millis) -{ -# ifdef OPENSSL_SYS_VXWORKS - struct timespec ts; - ts.tv_sec = (long int) (millis / 1000); - ts.tv_nsec = (long int) (millis % 1000) * 1000000ul; - nanosleep(&ts, NULL); -# elif defined(__TANDEM) -# if !defined(_REENTRANT) -# include <cextdecs.h(PROCESS_DELAY_)> - /* HPNS does not support usleep for non threaded apps */ - PROCESS_DELAY_(millis * 1000); -# elif defined(_SPT_MODEL_) -# include <spthread.h> -# include <spt_extensions.h> - usleep(millis * 1000); -# else - usleep(millis * 1000); -# endif -# else - usleep(millis * 1000); -# endif -} -#elif defined(_WIN32) -# include <windows.h> -static ossl_inline void ossl_sleep(unsigned long millis) -{ - Sleep(millis); -} -#else -/* Fallback to a busy wait */ -# include "internal/time.h" -static ossl_inline void ossl_sleep(unsigned long millis) -{ - const OSSL_TIME finish = ossl_time_add(ossl_time_now(), ossl_ms2time(millis)); - - while (ossl_time_compare(ossl_time_now(), finish) < 0) - /* busy wait */ ; -} -#endif /* defined OPENSSL_SYS_UNIX */ - /* ----------------------------- HP NonStop -------------------------------- */ /* Required to support platform variant without getpid() and pid_t. */ # if defined(__TANDEM) && defined(_GUARDIAN_TARGET) diff --git a/include/openssl/crypto.h.in b/include/openssl/crypto.h.in index fb0c7cbb87..963bc635fb 100644 --- a/include/openssl/crypto.h.in +++ b/include/openssl/crypto.h.in @@ -529,6 +529,8 @@ void OSSL_LIB_CTX_free(OSSL_LIB_CTX *); OSSL_LIB_CTX *OSSL_LIB_CTX_get0_global_default(void); OSSL_LIB_CTX *OSSL_LIB_CTX_set0_default(OSSL_LIB_CTX *libctx); +void OSSL_sleep(uint64_t millis); + # ifdef __cplusplus } # endif |