summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/armcap.c
diff options
context:
space:
mode:
authorjsing <>2014-04-15 13:42:55 +0000
committerjsing <>2014-04-15 13:42:55 +0000
commit179b5aba8054138fe6ae76eb86d0ba485fa99f67 (patch)
treef085d85cb06e6b6e1a1b1d52cced54d9f7d7e5f2 /src/lib/libcrypto/armcap.c
parent91b7379546c278344ff2e20e9eb6ecec326f20cd (diff)
downloadopenbsd-179b5aba8054138fe6ae76eb86d0ba485fa99f67.tar.gz
openbsd-179b5aba8054138fe6ae76eb86d0ba485fa99f67.tar.bz2
openbsd-179b5aba8054138fe6ae76eb86d0ba485fa99f67.zip
First pass at applying KNF to the OpenSSL code, which almost makes it
readable. This pass is whitespace only and can readily be verified using tr and md5.
Diffstat (limited to 'src/lib/libcrypto/armcap.c')
-rw-r--r--src/lib/libcrypto/armcap.c70
1 files changed, 36 insertions, 34 deletions
diff --git a/src/lib/libcrypto/armcap.c b/src/lib/libcrypto/armcap.c
index 9abaf396e5..0625587bdd 100644
--- a/src/lib/libcrypto/armcap.c
+++ b/src/lib/libcrypto/armcap.c
@@ -12,7 +12,8 @@ unsigned int OPENSSL_armcap_P;
12static sigset_t all_masked; 12static sigset_t all_masked;
13 13
14static sigjmp_buf ill_jmp; 14static sigjmp_buf ill_jmp;
15static void ill_handler (int sig) { siglongjmp(ill_jmp,sig); } 15 static void ill_handler (int sig) { siglongjmp(ill_jmp, sig);
16}
16 17
17/* 18/*
18 * Following subroutines could have been inlined, but it's not all 19 * Following subroutines could have been inlined, but it's not all
@@ -21,60 +22,61 @@ static void ill_handler (int sig) { siglongjmp(ill_jmp,sig); }
21void _armv7_neon_probe(void); 22void _armv7_neon_probe(void);
22unsigned int _armv7_tick(void); 23unsigned int _armv7_tick(void);
23 24
24unsigned int OPENSSL_rdtsc(void) 25unsigned int
25 { 26OPENSSL_rdtsc(void)
27{
26 if (OPENSSL_armcap_P & ARMV7_TICK) 28 if (OPENSSL_armcap_P & ARMV7_TICK)
27 return _armv7_tick(); 29 return _armv7_tick();
28 else 30 else
29 return 0; 31 return 0;
30 } 32}
31 33
32#if defined(__GNUC__) && __GNUC__>=2 34#if defined(__GNUC__) && __GNUC__>=2
33void OPENSSL_cpuid_setup(void) __attribute__((constructor)); 35void OPENSSL_cpuid_setup(void) __attribute__((constructor));
34#endif 36#endif
35void OPENSSL_cpuid_setup(void) 37
36 { 38void
39OPENSSL_cpuid_setup(void)
40{
37 char *e; 41 char *e;
38 struct sigaction ill_oact,ill_act; 42 struct sigaction ill_oact, ill_act;
39 sigset_t oset; 43 sigset_t oset;
40 static int trigger=0; 44 static int trigger = 0;
41 45
42 if (trigger) return; 46 if (trigger)
43 trigger=1;
44
45 if ((e=getenv("OPENSSL_armcap")))
46 {
47 OPENSSL_armcap_P=strtoul(e,NULL,0);
48 return; 47 return;
49 } 48 trigger = 1;
49
50 if ((e = getenv("OPENSSL_armcap"))) {
51 OPENSSL_armcap_P = strtoul(e, NULL, 0);
52 return;
53 }
50 54
51 sigfillset(&all_masked); 55 sigfillset(&all_masked);
52 sigdelset(&all_masked,SIGILL); 56 sigdelset(&all_masked, SIGILL);
53 sigdelset(&all_masked,SIGTRAP); 57 sigdelset(&all_masked, SIGTRAP);
54 sigdelset(&all_masked,SIGFPE); 58 sigdelset(&all_masked, SIGFPE);
55 sigdelset(&all_masked,SIGBUS); 59 sigdelset(&all_masked, SIGBUS);
56 sigdelset(&all_masked,SIGSEGV); 60 sigdelset(&all_masked, SIGSEGV);
57 61
58 OPENSSL_armcap_P = 0; 62 OPENSSL_armcap_P = 0;
59 63
60 memset(&ill_act,0,sizeof(ill_act)); 64 memset(&ill_act, 0, sizeof(ill_act));
61 ill_act.sa_handler = ill_handler; 65 ill_act.sa_handler = ill_handler;
62 ill_act.sa_mask = all_masked; 66 ill_act.sa_mask = all_masked;
63 67
64 sigprocmask(SIG_SETMASK,&ill_act.sa_mask,&oset); 68 sigprocmask(SIG_SETMASK, &ill_act.sa_mask, &oset);
65 sigaction(SIGILL,&ill_act,&ill_oact); 69 sigaction(SIGILL, &ill_act, &ill_oact);
66 70
67 if (sigsetjmp(ill_jmp,1) == 0) 71 if (sigsetjmp(ill_jmp, 1) == 0) {
68 {
69 _armv7_neon_probe(); 72 _armv7_neon_probe();
70 OPENSSL_armcap_P |= ARMV7_NEON; 73 OPENSSL_armcap_P |= ARMV7_NEON;
71 } 74 }
72 if (sigsetjmp(ill_jmp,1) == 0) 75 if (sigsetjmp(ill_jmp, 1) == 0) {
73 {
74 _armv7_tick(); 76 _armv7_tick();
75 OPENSSL_armcap_P |= ARMV7_TICK; 77 OPENSSL_armcap_P |= ARMV7_TICK;
76 }
77
78 sigaction (SIGILL,&ill_oact,NULL);
79 sigprocmask(SIG_SETMASK,&oset,NULL);
80 } 78 }
79
80 sigaction (SIGILL, &ill_oact, NULL);
81 sigprocmask(SIG_SETMASK, &oset, NULL);
82}