Update and add last (?) set of GOST OIDs.
[openssl.git] / crypto / sparcv9cap.c
index 7012f78604b294fd8dcc202b86058d312282e5d8..3ec2340241af11a1d668d70f5ea7ea304438587b 100644 (file)
@@ -16,7 +16,7 @@ int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_U
        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
@@ -25,7 +25,7 @@ int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_U
 
 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)
@@ -34,7 +34,7 @@ unsigned long OPENSSL_rdtsc(void)
                return 0;
 #endif
        else
-               return OPENSSL_rdtick();
+               return _sparcv9_rdtick();
        }
 
 #if defined(__sun) && defined(__SVR4)
@@ -55,21 +55,22 @@ static int walk_nodename(di_node_t node, di_node_name_t di_node_name)
 
        /* 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;
@@ -79,14 +80,18 @@ void OPENSSL_cpuid_setup(void)
        {
        void *h;
        char *e;
+       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 ((h = dlopen("libdevinfo.so.1",RTLD_LAZY))) do
                {
                di_init_t       di_init;
                di_fini_t       di_fini;
@@ -110,24 +115,20 @@ void OPENSSL_cpuid_setup(void)
        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);
                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