Co-authored-by: Gleb Popov <arrowd@FreeBSD.org>
Reviewed-by: Andrew Dinh <andrewd@openssl.org>
Reviewed-by: Igor Ustinov <igus@openssl.foundation>
MergeDate: Fri Jul 31 16:49:41 2026
(Merged from https://github.com/openssl/openssl/pull/31269)
return &const_one;
}
+#ifndef __e2k__
int BN_num_bits_word(BN_ULONG l)
{
BN_ULONG x, mask;
return bits;
}
+#else /* __e2k__ */
+#include <x86gprintrin.h>
+int BN_num_bits_word(BN_ULONG l)
+{
+ /* clz(0) is well-defined on e2k, hence no if (l == 0) return 0;
+ * is required here.
+ */
+#if BN_BITS2 > 32
+ return 64 - __builtin_clzll(l);
+#else
+ return 32 - __builtin_clz(l);
+#endif
+}
+#endif /* __e2k__ */
/*
* This function still leaks `a->dmax`: it's caller's responsibility to