File 0001-Adding-OPENSSL_cpuid_setup.patch of Package openssl.1634

diff --git a/crypto/fips/fips_standalone_hmac.c b/crypto/fips/fips_standalone_hmac.c
index 5340665..a457fa3 100644
--- a/crypto/fips/fips_standalone_hmac.c
+++ b/crypto/fips/fips_standalone_hmac.c
@@ -69,6 +69,51 @@ int bn_mul_mont_int(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const
 	defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || defined(_M_X64)
 
 unsigned int  OPENSSL_ia32cap_P[2];
+
+#if defined(OPENSSL_CPUID_OBJ) && !defined(OPENSSL_NO_ASM) && !defined(I386_ONLY)
+#define OPENSSL_CPUID_SETUP
+#if defined(_WIN32)
+typedef unsigned __int64 IA32CAP;
+#else
+typedef unsigned long long IA32CAP;
+#endif
+void OPENSSL_cpuid_setup(void)
+{ static int trigger=0;
+  IA32CAP OPENSSL_ia32_cpuid(void);
+  IA32CAP vec;
+  char *env;
+
+    if (trigger)        return;
+
+    trigger=1;
+    if ((env=getenv("OPENSSL_ia32cap"))) {
+        int off = (env[0]=='~')?1:0;
+#if defined(_WIN32)
+        if (!sscanf(env+off,"%I64i",&vec)) vec = strtoul(env+off,NULL,0);
+#else
+        if (!sscanf(env+off,"%lli",(long long *)&vec)) vec = strtoul(env+off,NULL,0);
+#endif
+        if (off) vec = OPENSSL_ia32_cpuid()&~vec;
+    }
+    else
+        vec = OPENSSL_ia32_cpuid();
+
+    /*
+     * |(1<<10) sets a reserved bit to signal that variable
+     * was initialized already... This is to avoid interference
+     * with cpuid snippets in ELF .init segment.
+     */
+    OPENSSL_ia32cap_P[0] = (unsigned int)vec|(1<<10);
+    OPENSSL_ia32cap_P[1] = (unsigned int)(vec>>32);
+}
+#endif
+
+#else
+unsigned long *OPENSSL_ia32cap_loc(void) { return NULL; }
+#endif
+int OPENSSL_NONPIC_relocated = 0;
+#if !defined(OPENSSL_CPUID_SETUP) && !defined(OPENSSL_CPUID_OBJ)
+void OPENSSL_cpuid_setup(void) {}
 #endif
 
 #ifdef OPENSSL_FIPS
openSUSE Build Service is sponsored by