summaryrefslogtreecommitdiff
path: root/lib/libcrypto/ppccap.c
blob: ce01edf6ecf51a60dde97e2902aa6eeaf6bf91f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/* $OpenBSD: ppccap.c,v 1.6 2014/07/17 23:48:24 deraadt Exp $ */

#include <sys/types.h>
#include <sys/sysctl.h>
#include <machine/cpu.h>
#include <unistd.h>

#include <crypto.h>
#include <openssl/bn.h>

#ifdef unused
#define PPC_FPU64	(1<<0)
#define PPC_ALTIVEC	(1<<1)

static int OPENSSL_ppccap_P = 0;
#endif

#ifdef OPENSSL_BN_ASM_MONT
extern int bn_mul_mont_int(BN_ULONG *, const BN_ULONG *, const BN_ULONG *,
	    const BN_ULONG *, const BN_ULONG *, int);
int
bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,
    const BN_ULONG *np, const BN_ULONG *n0, int num)
{
	return bn_mul_mont_int(rp, ap, bp, np, n0, num);
}
#endif

#ifdef unused
void OPENSSL_cpuid_setup(void) __attribute__((constructor));

void
OPENSSL_cpuid_setup(void)
{
	static const int mib[2] = { CTL_MACHDEP, CPU_ALTIVEC };
	static int trigger = 0;
	int altivec = 0;
	size_t size;

	if (trigger)
		return;
	trigger = 1;

	size = sizeof altivec;
	if (sysctl(mib, 2, &altivec, &size, NULL, 0) != -1) {
		if (altivec != 0)
			OPENSSL_ppccap_P |= PPC_ALTIVEC;
	}
}
#endif