diff options
author | jsing <> | 2023-07-09 10:37:32 +0000 |
---|---|---|
committer | jsing <> | 2023-07-09 10:37:32 +0000 |
commit | 6503fbfd862518a9088d61b700240ef33e4e3996 (patch) | |
tree | cd154512bd9a8e4d80cb5fb18b29e0743638561d /src | |
parent | 631ee3952685367c55618f2f750b769eadd4f32f (diff) | |
download | openbsd-6503fbfd862518a9088d61b700240ef33e4e3996.tar.gz openbsd-6503fbfd862518a9088d61b700240ef33e4e3996.tar.bz2 openbsd-6503fbfd862518a9088d61b700240ef33e4e3996.zip |
Provide optimised bn_subw() for riscv64.
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/bn/arch/riscv64/bn_arch.h | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/lib/libcrypto/bn/arch/riscv64/bn_arch.h b/src/lib/libcrypto/bn/arch/riscv64/bn_arch.h index a8c50eb06d..e67de835cf 100644 --- a/src/lib/libcrypto/bn/arch/riscv64/bn_arch.h +++ b/src/lib/libcrypto/bn/arch/riscv64/bn_arch.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bn_arch.h,v 1.6 2023/07/09 10:36:53 jsing Exp $ */ | 1 | /* $OpenBSD: bn_arch.h,v 1.7 2023/07/09 10:37:32 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2023 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2023 Joel Sing <jsing@openbsd.org> |
4 | * | 4 | * |
@@ -63,6 +63,23 @@ bn_mulw(BN_ULONG a, BN_ULONG b, BN_ULONG *out_r1, BN_ULONG *out_r0) | |||
63 | *out_r0 = r0; | 63 | *out_r0 = r0; |
64 | } | 64 | } |
65 | 65 | ||
66 | #define HAVE_BN_SUBW | ||
67 | |||
68 | static inline void | ||
69 | bn_subw(BN_ULONG a, BN_ULONG b, BN_ULONG *out_borrow, BN_ULONG *out_r0) | ||
70 | { | ||
71 | BN_ULONG borrow, r0; | ||
72 | |||
73 | __asm__ ( | ||
74 | "sub %[r0], %[a], %[b] \n" | ||
75 | "sltu %[borrow], %[a], %[r0] \n" | ||
76 | : [borrow]"=r"(borrow), [r0]"=&r"(r0) | ||
77 | : [a]"r"(a), [b]"r"(b)); | ||
78 | |||
79 | *out_borrow = borrow; | ||
80 | *out_r0 = r0; | ||
81 | } | ||
82 | |||
66 | #endif /* __GNUC__ */ | 83 | #endif /* __GNUC__ */ |
67 | 84 | ||
68 | #endif | 85 | #endif |