9 #define SPARCV9_TICK_PRIVILEGED (1<<0)
10 #define SPARCV9_PREFER_FPU (1<<1)
11 #define SPARCV9_VIS1 (1<<2)
12 #define SPARCV9_VIS2 (1<<3)
13 #define SPARCV9_FMADD (1<<4)
17 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)
19 int bn_mul_mont_fpu(BN_ULONG *rp,
const BN_ULONG *ap,
const BN_ULONG *bp,
const BN_ULONG *np,
const BN_ULONG *n0,
int num);
20 int bn_mul_mont_int(BN_ULONG *rp,
const BN_ULONG *ap,
const BN_ULONG *bp,
const BN_ULONG *np,
const BN_ULONG *n0,
int num);
22 if (num>=8 && !(num&1) &&
25 return bn_mul_mont_fpu(rp,ap,bp,np,n0,num);
27 return bn_mul_mont_int(rp,ap,bp,np,n0,num);
39 #if defined(__sun) && defined(__SVR4)
48 #if 0 && defined(__sun) && defined(__SVR4)
54 #include <libdevinfo.h>
55 #include <sys/systeminfo.h>
57 typedef di_node_t (*di_init_t)(
const char *,uint_t);
58 typedef void (*di_fini_t)(di_node_t);
59 typedef char * (*di_node_name_t)(di_node_t);
60 typedef int (*di_walk_node_t)(di_node_t,uint_t,di_node_name_t,int (*)(di_node_t,di_node_name_t));
62 #define DLLINK(h,name) (name=(name##_t)dlsym((h),#name))
64 static int walk_nodename(di_node_t node, di_node_name_t di_node_name)
66 char *name = (*di_node_name)(node);
69 if (!strcmp (name,
"SUNW,UltraSPARC") ||
70 !strncmp(name,
"SUNW,UltraSPARC-I",17))
75 if (name[14]!=
'\0' && name[17]!=
'\0' && name[18]!=
'\0')
78 return DI_WALK_TERMINATE;
81 else if (!strncmp(name,
"SUNW,UltraSPARC",15))
85 return DI_WALK_TERMINATE;
88 return DI_WALK_CONTINUE;
100 if ((e=getenv(
"OPENSSL_sparcv9cap")))
102 OPENSSL_sparcv9cap_P=strtoul(e,NULL,0);
106 if (sysinfo(SI_MACHINE,si,
sizeof(si))>0)
108 if (strcmp(si,
"sun4v"))
113 if (sysinfo(SI_ISALIST,si,
sizeof(si))>0)
115 if (strstr(si,
"+vis"))
117 if (strstr(si,
"+vis2"))
132 if ((h = dlopen(NULL,RTLD_LAZY)))
134 union {
void *
p; int (*
f)(int,int); } sym;
135 if ((sym.p = dlsym(h,
"mallopt"))) (*sym.f)(M_KEEP,0);
139 if ((h = dlopen(
"libdevinfo.so.1",RTLD_LAZY)))
do
143 di_walk_node_t di_walk_node;
144 di_node_name_t di_node_name;
147 if (!DLLINK(h,di_init))
break;
148 if (!DLLINK(h,di_fini))
break;
149 if (!DLLINK(h,di_walk_node))
break;
150 if (!DLLINK(h,di_node_name))
break;
152 if ((root_node = (*di_init)(
"/",DINFOSUBTREE))!=DI_NODE_NIL)
154 (*di_walk_node)(root_node,DI_WALK_SIBFIRST,
155 di_node_name,walk_nodename);
156 (*di_fini)(root_node);
165 static sigjmp_buf common_jmp;
166 static void common_handler(
int sig) { siglongjmp(common_jmp,sig); }
171 struct sigaction common_act,ill_oact,bus_oact;
172 sigset_t all_masked,oset;
173 static int trigger=0;
178 if ((e=getenv(
"OPENSSL_sparcv9cap")))
180 OPENSSL_sparcv9cap_P=strtoul(e,NULL,0);
187 sigfillset(&all_masked);
188 sigdelset(&all_masked,SIGILL);
189 sigdelset(&all_masked,SIGTRAP);
191 sigdelset(&all_masked,SIGEMT);
193 sigdelset(&all_masked,SIGFPE);
194 sigdelset(&all_masked,SIGBUS);
195 sigdelset(&all_masked,SIGSEGV);
196 sigprocmask(SIG_SETMASK,&all_masked,&oset);
198 memset(&common_act,0,
sizeof(common_act));
199 common_act.sa_handler = common_handler;
200 common_act.sa_mask = all_masked;
202 sigaction(SIGILL,&common_act,&ill_oact);
203 sigaction(SIGBUS,&common_act,&bus_oact);
205 if (sigsetjmp(common_jmp,1) == 0)
211 if (sigsetjmp(common_jmp,1) == 0)
225 if (sigsetjmp(common_jmp,1) == 0)
231 sigaction(SIGBUS,&bus_oact,NULL);
232 sigaction(SIGILL,&ill_oact,NULL);
234 sigprocmask(SIG_SETMASK,&oset,NULL);