mirror of https://github.com/openssl/openssl.git
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:
parent
e740864976
commit
340827c819
|
@ -502,7 +502,7 @@ int OPENSSL_init_crypto(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings)
|
||||||
int aloaddone = 0;
|
int aloaddone = 0;
|
||||||
|
|
||||||
/* Applications depend on 0 being returned when cleanup was already done */
|
/* Applications depend on 0 being returned when cleanup was already done */
|
||||||
if (stopped) {
|
if (ossl_unlikely(stopped)) {
|
||||||
if (!(opts & OPENSSL_INIT_BASE_ONLY))
|
if (!(opts & OPENSSL_INIT_BASE_ONLY))
|
||||||
ERR_raise(ERR_LIB_CRYPTO, ERR_R_INIT_FAIL);
|
ERR_raise(ERR_LIB_CRYPTO, ERR_R_INIT_FAIL);
|
||||||
return 0;
|
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
|
* unnecessarily - but all the critical code is contained in RUN_ONCE
|
||||||
* functions anyway so we are safe.
|
* 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)
|
if ((tmp & opts) == opts)
|
||||||
return 1;
|
return 1;
|
||||||
aloaddone = 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
|
* 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.
|
* 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;
|
return 0;
|
||||||
|
|
||||||
if (opts & OPENSSL_INIT_BASE_ONLY)
|
if (opts & OPENSSL_INIT_BASE_ONLY)
|
||||||
|
|
Loading…
Reference in New Issue