From b0edbf3f98eba4b1effd31584dae0af06eb2deff Mon Sep 17 00:00:00 2001 From: jsing <> Date: Wed, 21 Jun 2023 07:48:41 +0000 Subject: Provide and use bn_clzw() in place of bn_word_clz(). On some architectures, we can provide an optimised (often single instruction) count-leading-zero implementation. In order to do this effectively, provide bn_clzw() as a static inline that can be replaced by an architecture specific version. The default implementation defers to the bn_word_clz() function (which may also be architecture specific). ok tb@ --- src/lib/libcrypto/bn/bn_internal.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/lib/libcrypto/bn/bn_internal.h') diff --git a/src/lib/libcrypto/bn/bn_internal.h b/src/lib/libcrypto/bn/bn_internal.h index f5c69c5d77..b712b736f6 100644 --- a/src/lib/libcrypto/bn/bn_internal.h +++ b/src/lib/libcrypto/bn/bn_internal.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_internal.h,v 1.13 2023/06/21 07:41:55 jsing Exp $ */ +/* $OpenBSD: bn_internal.h,v 1.14 2023/06/21 07:48:41 jsing Exp $ */ /* * Copyright (c) 2023 Joel Sing * @@ -58,6 +58,14 @@ bn_ct_eq_zero_mask(BN_ULONG w) } #endif +#ifndef HAVE_BN_CLZW +static inline int +bn_clzw(BN_ULONG w) +{ + return bn_word_clz(w); +} +#endif + /* * Big number primitives are named as the operation followed by a suffix * that indicates the number of words that it operates on, where 'w' means -- cgit v1.2.3-55-g6feb