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);
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);
- if (OPENSSL_sparcv9cap_P&(SPARCV9_PREFER_FPU|SPARCV9_VIS1) ==
+ if ((OPENSSL_sparcv9cap_P&(SPARCV9_PREFER_FPU|SPARCV9_VIS1)) ==
(SPARCV9_PREFER_FPU|SPARCV9_VIS1))
return bn_mul_mont_fpu(rp,ap,bp,np,n0,num);
else
unsigned long OPENSSL_rdtsc(void)
{
- unsigned long OPENSSL_rdtick(void);
+ unsigned long _sparcv9_rdtick(void);
if (OPENSSL_sparcv9cap_P&SPARCV9_TICK_PRIVILEGED)
#if defined(__sun) && defined(__SVR4)
return 0;
#endif
else
- return OPENSSL_rdtick();
+ return _sparcv9_rdtick();
}
#if defined(__sun) && defined(__SVR4)
#include <dlfcn.h>
#include <libdevinfo.h>
+#include <sys/systeminfo.h>
typedef di_node_t (*di_init_t)(const char *,uint_t);
typedef void (*di_fini_t)(di_node_t);
/* This is expected to catch all UltraSPARC flavors prior T1 */
if (!strcmp (name,"SUNW,UltraSPARC") ||
- !strncmp(name,"SUNW,UltraSPARC-I",17))
+ !strncmp(name,"SUNW,UltraSPARC-I",17)) /* covers II,III,IV */
{
OPENSSL_sparcv9cap_P |= SPARCV9_PREFER_FPU|SPARCV9_VIS1;
- /* %tick is privileged only on UltraSPARC-I/II */
+ /* %tick is privileged only on UltraSPARC-I/II, but not IIe */
if (name[14]!='\0' && name[17]!='\0' && name[18]!='\0')
OPENSSL_sparcv9cap_P &= ~SPARCV9_TICK_PRIVILEGED;
return DI_WALK_TERMINATE;
}
- /* This is expected to catch remaining UltraSPARC T1 */
+ /* This is expected to catch remaining UltraSPARCs, such as T1 */
else if (!strncmp(name,"SUNW,UltraSPARC",15))
{
- OPENSSL_sparcv9cap_P |= SPARCV9_VIS1;
OPENSSL_sparcv9cap_P &= ~SPARCV9_TICK_PRIVILEGED;
+
+ return DI_WALK_TERMINATE;
}
return DI_WALK_CONTINUE;
void OPENSSL_cpuid_setup(void)
{
void *h;
- char *e;
+ char *e,si[256];
+ static int trigger=0;
- if (e=getenv("OPENSSL_sparcv9cap"))
+ if (trigger) return;
+ trigger=1;
+
+ if ((e=getenv("OPENSSL_sparcv9cap")))
{
OPENSSL_sparcv9cap_P=strtoul(e,NULL,0);
return;
}
- if (h = dlopen("libdevinfo.so.1",RTLD_LAZY)) do
+ if (sysinfo(SI_MACHINE,si,sizeof(si))>0)
+ {
+ if (strcmp(si,"sun4v"))
+ /* FPU is preferred for all CPUs, but US-T1/2 */
+ OPENSSL_sparcv9cap_P |= SPARCV9_PREFER_FPU;
+ }
+
+ if (sysinfo(SI_ISALIST,si,sizeof(si))>0)
+ {
+ if (strstr(si,"+vis"))
+ OPENSSL_sparcv9cap_P |= SPARCV9_VIS1;
+ if (strstr(si,"+vis2"))
+ {
+ OPENSSL_sparcv9cap_P |= SPARCV9_VIS2;
+ OPENSSL_sparcv9cap_P &= ~SPARCV9_TICK_PRIVILEGED;
+ return;
+ }
+ }
+
+ if ((h = dlopen("libdevinfo.so.1",RTLD_LAZY))) do
{
di_init_t di_init;
di_fini_t di_fini;
if (h) dlclose(h);
}
-#elif defined(__linux)
+#else
void OPENSSL_cpuid_setup(void)
{
char *e;
- if (e=getenv("OPENSSL_sparcv9cap"))
+ if ((e=getenv("OPENSSL_sparcv9cap")))
{
- OPENSSL_sparcv9cap_P=strtoul(env,NULL,0);
+ OPENSSL_sparcv9cap_P=strtoul(e,NULL,0);
return;
}
- /* Linux apparently supports UltraSPARC-I/II/III only */
+ /* For now we assume that the rest supports UltraSPARC-I* only */
OPENSSL_sparcv9cap_P |= SPARCV9_PREFER_FPU|SPARCV9_VIS1;
}
-#else
-
-void OPENSSL_cpuid_setup(void) {}
-
#endif