diff options
author | Liu-ErMeng <liuermeng2@huawei.com> | 2023-07-11 16:22:53 +0800 |
---|---|---|
committer | Pauli <pauli@openssl.org> | 2023-07-13 22:54:14 +1000 |
commit | ed6dfd1e3694b3438249f3d0117bc314afa6b240 (patch) | |
tree | f19dcfa72065dd6d7d2dc19ff42a7586f93ea8a8 /include | |
parent | 5be8233d2be306a2906d3da16e59aa15a4559dd2 (diff) |
use '__builtin_expect' to improve EVP_EncryptUpdate performance for gcc/clang.
Signed-off-by: Liu-ErMeng <liuermeng2@huawei.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21425)
Diffstat (limited to 'include')
-rw-r--r-- | include/internal/common.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/include/internal/common.h b/include/internal/common.h index f941eddbe1..204e7c3eec 100644 --- a/include/internal/common.h +++ b/include/internal/common.h @@ -18,6 +18,14 @@ # include "internal/e_os.h" /* ossl_inline in many files */ # include "internal/nelem.h" +#if defined(__GNUC__) || defined(__clang__) + #define likely(x) __builtin_expect(!!(x), 1) + #define unlikely(x) __builtin_expect(!!(x), 0) +#else + #define likely(x) x + #define unlikely(x) x +#endif + #ifdef NDEBUG # define ossl_assert(x) ((x) != 0) #else |