crypto/init.c optimize ossl_(un)likely

Signed-off-by: Norbert Pocs <norbertp@openssl.org>

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27961)
This commit is contained in:
Norbert Pocs 2025-07-03 16:16:34 +02:00 committed by Neil Horman
parent e740864976
commit 340827c819
1 changed files with 3 additions and 3 deletions

View File

@ -502,7 +502,7 @@ int OPENSSL_init_crypto(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings)
int aloaddone = 0;
/* Applications depend on 0 being returned when cleanup was already done */
if (stopped) {
if (ossl_unlikely(stopped)) {
if (!(opts & OPENSSL_INIT_BASE_ONLY))
ERR_raise(ERR_LIB_CRYPTO, ERR_R_INIT_FAIL);
return 0;
@ -521,7 +521,7 @@ int OPENSSL_init_crypto(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings)
* unnecessarily - but all the critical code is contained in RUN_ONCE
* functions anyway so we are safe.
*/
if (CRYPTO_atomic_load(&optsdone, &tmp, NULL)) {
if (ossl_likely(CRYPTO_atomic_load(&optsdone, &tmp, NULL))) {
if ((tmp & opts) == opts)
return 1;
aloaddone = 1;
@ -541,7 +541,7 @@ int OPENSSL_init_crypto(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings)
* If we remain the only caller of err_shelve_state() the recursion should
* perhaps be removed, but if in doubt, it can be left in place.
*/
if (!RUN_ONCE(&base, ossl_init_base))
if (ossl_unlikely(!RUN_ONCE(&base, ossl_init_base)))
return 0;
if (opts & OPENSSL_INIT_BASE_ONLY)