fi
-AM_CONDITIONAL(TRY_X86_OPTIMIZATIONS, test x"$hw_accel" = x"x86" || test x"$hw_accel" = x"x86-64")
AM_CONDITIONAL(ASM_X86_64, test x"$hw_accel" = x"x86-64")
+AM_CONDITIONAL(ASM_X86_32, test x"$hw_accel" = x"x86")
AM_CONDITIONAL(HAVE_GCC_GNU89_INLINE_OPTION, test "$gnu89_inline" = "yes"])
AM_CONDITIONAL(HAVE_GCC, test "$GCC" = "yes")
libaccelerated_la_SOURCES = accelerated.c cryptodev.c
libaccelerated_la_LIBADD =
-if TRY_X86_OPTIMIZATIONS
+if ASM_X86_64
SUBDIRS += intel
-AM_CFLAGS += -DTRY_X86_OPTIMIZATIONS
+AM_CFLAGS += -DASM_X86_64
+libaccelerated_la_LIBADD += intel/libintel.la
+endif
+
+if ASM_X86_32
+SUBDIRS += intel
+AM_CFLAGS += -DASM_X86_32
libaccelerated_la_LIBADD += intel/libintel.la
endif
*/
#include <accelerated.h>
-#ifdef TRY_X86_OPTIMIZATIONS
+#if defined(ASM_X86_32) || defined(ASM_X86_64)
# include <intel/aes-x86.h>
+# include <x86.h>
#endif
void _gnutls_register_accel_crypto(void)
{
-#ifdef TRY_X86_OPTIMIZATIONS
- register_x86_crypto ();
- register_padlock_crypto ();
+#if defined(ASM_X86_32) || defined(ASM_X86_64)
+ if (have_cpuid() != 0)
+ {
+ register_x86_crypto ();
+ register_padlock_crypto ();
+ }
#endif
return;
#include <config.h>
-#ifdef HAVE_CPUID_H
-# include <cpuid.h>
-# define cpuid __cpuid
+#ifdef ASM_X86_64
-#else
-
-# ifdef ASM_X86_64
+# ifdef HAVE_CPUID_H
+# include <cpuid.h>
+# define cpuid __cpuid
+# else
-# define cpuid(func,ax,bx,cx,dx)\
+#define cpuid(func,ax,bx,cx,dx)\
__asm__ __volatile__ ("cpuid":\
"=a" (ax), "=b" (bx), "=c" (cx), "=d" (dx) : "a" (func));
-# else
+# endif
+
+# define have_cpuid() 1
+
+#endif /* ASM_X86_64 */
+
+
+#ifdef ASM_X86_32
/* some GCC versions complain on the version above */
# define cpuid(func, a, b, c, d) g_cpuid(func, &a, &b, &c, &d)
:"a"(func)
:"cc");
}
-# endif
-#endif
+inline static unsigned int have_cpuid(void)
+{
+ unsigned int have_id;
+ asm volatile(
+ "pushfl\t\n"
+ "pop %0\t\n"
+ "orl $0x200000, %0\t\n"
+ "push %0\t\n"
+ "popfl\t\n"
+ "pushfl\t\n"
+ "pop %0\t\n"
+ "andl $0x200000, %0\t\n"
+ :"=r" (have_id)
+ ::
+ );
+
+ return have_id;
+}
+#endif /* ASM_X86_32 */