]> source.dussan.org Git - rspamd.git/commitdiff
Use __get_cpuid if available.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 14 Mar 2015 19:56:22 +0000 (19:56 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 14 Mar 2015 19:56:22 +0000 (19:56 +0000)
CMakeLists.txt
config.h.in
src/libcryptobox/cryptobox.c

index a330a5a20ac6e62017467f188b2f210a74052148..25df1a57469d00da501085d63b64156d712031f6 100644 (file)
@@ -712,6 +712,7 @@ CHECK_INCLUDE_FILES(sys/eventfd.h HAVE_SYS_EVENTFD_H)
 CHECK_INCLUDE_FILES(aio.h HAVE_AIO_H)
 CHECK_INCLUDE_FILES(libaio.h HAVE_LIBAIO_H)
 CHECK_INCLUDE_FILES(unistd.h HAVE_UNISTD_H)
+CHECK_INCLUDE_FILES(cpuid.h HAVE_CPUID_H)
 
 # Some dependencies
 IF(HAVE_SYS_WAIT_H)
@@ -830,6 +831,7 @@ CHECK_SYMBOL_EXISTS(_SC_NPROCESSORS_ONLN unistd.h HAVE_SC_NPROCESSORS_ONLN)
 CHECK_SYMBOL_EXISTS(setbit sys/param.h PARAM_H_HAS_BITSET)
 CHECK_SYMBOL_EXISTS(getaddrinfo "sys/types.h;sys/socket.h;netdb.h" HAVE_GETADDRINFO)
 CHECK_SYMBOL_EXISTS(sched_yield "sched.h" HAVE_SCHED_YIELD)
+CHECK_SYMBOL_EXISTS(__get_cpuid "cpuid.h" HAVE_GET_CPUID)
 CHECK_SYMBOL_EXISTS(PCRE_CONFIG_JIT "pcre.h" HAVE_PCRE_JIT)
 
 FILE(WRITE ${CMAKE_BINARY_DIR}/pthread_setpshared.c "
index 3bed214dae9bd845edd1e9f76bee44dc732ff6af..5e262235a234e38419d7b1d908e1dfcb4c29753e 100644 (file)
 #cmakedefine HAVE_EXPLICIT_BZERO 1
 #cmakedefine HAVE_WEAK_SYMBOLS   1
 #cmakedefine HAVE_PCRE_JIT       1
+#cmakedefine HAVE_GET_CPUID      1
+#cmakedefine HAVE_CPUID_H        1
 
 /* Configure allocator */
 #define uthash_malloc(sz) g_slice_alloc(sz)
index d115f79c6025a2149ce63b94e94f76995e385988..8674867d6ec113e92f012b18cf88441378aee06c 100644 (file)
@@ -27,6 +27,9 @@
 #include "poly1305/poly1305.h"
 #include "curve25519/curve25519.h"
 #include "ottery.h"
+#ifdef HAVE_CPUID_H
+#include <cpuid.h>
+#endif
 
 unsigned long cpu_config = 0;
 
@@ -66,6 +69,9 @@ static void
 rspamd_cryptobox_cpuid (gint cpu[4], gint info)
 {
 #if defined(__GNUC__) && (defined(__x86_64__) || defined(__i386__))
+# if defined(HAVE_GET_CPUID)
+       __get_cpuid (info, &cpu[0], &cpu[1], &cpu[2], &cpu[3]);
+# else
        __asm__ __volatile__ (
                        "cpuid":
                        "=a" (cpu[0]),
@@ -74,6 +80,7 @@ rspamd_cryptobox_cpuid (gint cpu[4], gint info)
                        "=d" (cpu[3]) :
                        "a" (info), "c" (0)
        );
+# endif
 #else
        memset (cpu, 0, sizeof (cpu));
 #endif