1 /*	$OpenBSD: bn_arch.h,v 1.4 2023/02/16 10:41:03 jsing Exp $ */
2 /*
3  * Copyright (c) 2023 Joel Sing <jsing@openbsd.org>
4  *
5  * Permission to use, copy, modify, and distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17 
18 #ifndef HEADER_BN_ARCH_H
19 #define HEADER_BN_ARCH_H
20 
21 #ifndef OPENSSL_NO_ASM
22 
23 #if 0 /* Needs testing and enabling. */
24 #if defined(__GNUC__)
25 #define HAVE_BN_MULW
26 
27 static inline void
28 bn_mulw(BN_ULONG a, BN_ULONG b, BN_ULONG *out_r1, BN_ULONG *out_r0)
29 {
30 	BN_ULONG r1, r0;
31 
32 	/* Unsigned multiplication using a mulhdu/mul pair. */
33 	__asm__ ("mulhdu %0, %2, %3; mul %1, %2, %3"
34 	    : "=&r"(r1), "=r"(r0)
35 	    : "r"(a), "r"(b));
36 
37 	*out_r1 = r1;
38 	*out_r0 = r0;
39 }
40 #endif /* __GNUC__ */
41 #endif
42 
43 #endif
44 #endif
45