diff mbox

[xf86-video-intel] configure: check for cpuid.h

Message ID 1409474936-1867-1-git-send-email-jsg@jsg.id.au (mailing list archive)
State New, archived
Headers show

Commit Message

Jonathan Gray Aug. 31, 2014, 8:48 a.m. UTC
Instead of checking for a particular version of GCC check for
a cpuid.h with __cpuid_count.  This allows cpuid.h to be
provided for older/different compilers.

Signed-off-by: Jonathan Gray <jsg@jsg.id.au>
---
 configure.ac        | 18 ++++++++++++++++++
 src/sna/sna_cpuid.h |  4 ++--
 2 files changed, 20 insertions(+), 2 deletions(-)

Comments

Chris Wilson Aug. 31, 2014, 10:53 a.m. UTC | #1
On Sun, Aug 31, 2014 at 06:48:56PM +1000, Jonathan Gray wrote:
> Instead of checking for a particular version of GCC check for
> a cpuid.h with __cpuid_count.  This allows cpuid.h to be
> provided for older/different compilers.
> 
> Signed-off-by: Jonathan Gray <jsg@jsg.id.au>

I didn't have much luck last time I tried with clang, but this seems to
still work for me, so pushed.

To ssh://git.freedesktop.org/git/xorg/driver/xf86-video-intel
2086965..2c564c0  master -> master
-Chris
diff mbox

Patch

diff --git a/configure.ac b/configure.ac
index 4f1cff7..c24b369 100644
--- a/configure.ac
+++ b/configure.ac
@@ -208,6 +208,24 @@  fi
 PKG_CHECK_MODULES(X11, [x11 xrender xrandr xext xfixes cairo cairo-xlib-xrender pixman-1 libpng], [x11="yes"], [x11="no"])
 AM_CONDITIONAL(HAVE_X11, test "x$x11" = "xyes")
 
+cpuid="yes"
+AC_TRY_LINK([
+	#include <cpuid.h>
+	#include <stddef.h>
+	],
+	[
+	int eax, ebx, ecx, edx;
+	if (__get_cpuid_max(0, NULL) < 4)
+		return 0;
+	__cpuid_count(4, 0, eax, ebx, ecx, edx);
+	],
+	[cpuid="yes"],
+	[cpuid="no"]
+)
+if test "x$cpuid" = "xyes"; then
+	AC_DEFINE(HAVE_CPUID_H,1,[Found a useable cpuid.h])
+fi
+
 shm=yes
 AC_CHECK_HEADERS([sys/ipc.h sys/ipc.h], [], [shm="no"])
 AC_CHECK_HEADERS([X11/extensions/XShm.h], [], [shm="no"], [
diff --git a/src/sna/sna_cpuid.h b/src/sna/sna_cpuid.h
index ed28a0a..14af62b 100644
--- a/src/sna/sna_cpuid.h
+++ b/src/sna/sna_cpuid.h
@@ -30,9 +30,9 @@ 
 #ifndef SNA_CPUID_H
 #define SNA_CPUID_H
 
-#include "compiler.h"
+#include "config.h"
 
-#if HAS_GCC(4, 4) /* for __cpuid_count() */
+#ifdef HAVE_CPUID_H
 #include <cpuid.h>
 #else
 #define __get_cpuid_max(x, y) 0