[openssl/openssl] 9c8539: bn_nist: replace pointer bit-fiddling with ternary
Alois Klink
noreply at github.com
Mon Apr 17 22:08:01 UTC 2023
Branch: refs/heads/openssl-3.0
Home: https://github.com/openssl/openssl
Commit: 9c85390e345199032c84628c95fc0e7659a3855e
https://github.com/openssl/openssl/commit/9c85390e345199032c84628c95fc0e7659a3855e
Author: Alois Klink <alois at aloisklink.com>
Date: 2023-04-18 (Tue, 18 Apr 2023)
Changed paths:
M crypto/bn/bn_nist.c
Log Message:
-----------
bn_nist: replace pointer bit-fiddling with ternary
Bit-fiddling pointers is technically implementation defined behavior
in the C specification so the following code is not supported in all
platforms:
PTR_SIZE_INT mask;
void * a, b, c;
int boolean_flag;
mask = 0 - boolean_flag;
/* Not guaranteed to be a valid ptr to a or b on all platforms */
a = (void *)
((((PTR_SIZE_INT) b & ~mask) | (((PTR_SIZE_INT)) c & mask)));
Using a ternary conditional operator is supported on all platforms
(i.e. `a = boolean_flag ? b : c;`).
On most modern compilers/CPUs, this will be faster, since it will
get converted to a CMOV instruction.
Reviewed-by: Richard Levitte <levitte at openssl.org>
Reviewed-by: Paul Dale <pauli at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20748)
(cherry picked from commit 326af4ad171b849ba1e76fd425d8f337718c4108)
Commit: a79d2fe9c4cb88c4cd5f49148fbdd42b14e9e31e
https://github.com/openssl/openssl/commit/a79d2fe9c4cb88c4cd5f49148fbdd42b14e9e31e
Author: Alois Klink <alois at aloisklink.com>
Date: 2023-04-18 (Tue, 18 Apr 2023)
Changed paths:
M crypto/bn/bn_nist.c
Log Message:
-----------
bn_nist: remove unused type-punning union `u`
We no longer need to cast function pointers to PTR_SIZE_INT.
Reviewed-by: Richard Levitte <levitte at openssl.org>
Reviewed-by: Paul Dale <pauli at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20748)
(cherry picked from commit f659f7a1c70709caa1727bb0b7f836d170d35bb5)
Commit: ca723d10b20160d587850858d96576739870a134
https://github.com/openssl/openssl/commit/ca723d10b20160d587850858d96576739870a134
Author: Alois Klink <alois at aloisklink.com>
Date: 2023-04-18 (Tue, 18 Apr 2023)
Changed paths:
M crypto/bn/bn_local.h
Log Message:
-----------
bn_local: remove unused `PTR_SIZE_INT` definition
Reviewed-by: Richard Levitte <levitte at openssl.org>
Reviewed-by: Paul Dale <pauli at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20748)
(cherry picked from commit dcfeb617477dd957f69e713cbc61fd4dca0f2db4)
Compare: https://github.com/openssl/openssl/compare/98c1660e67fc...ca723d10b201
More information about the openssl-commits
mailing list