public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
* [PATCH xf86-video-intel] configure: check for cpuid.h
@ 2014-08-31  8:48 Jonathan Gray
  2014-08-31 10:53 ` Chris Wilson
  0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Gray @ 2014-08-31  8:48 UTC (permalink / raw)
  To: intel-gfx

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(-)

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
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH xf86-video-intel] configure: check for cpuid.h
  2014-08-31  8:48 [PATCH xf86-video-intel] configure: check for cpuid.h Jonathan Gray
@ 2014-08-31 10:53 ` Chris Wilson
  2014-08-31 12:27   ` Jonathan Gray
  0 siblings, 1 reply; 3+ messages in thread
From: Chris Wilson @ 2014-08-31 10:53 UTC (permalink / raw)
  To: Jonathan Gray; +Cc: intel-gfx

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

-- 
Chris Wilson, Intel Open Source Technology Centre

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH xf86-video-intel] configure: check for cpuid.h
  2014-08-31 10:53 ` Chris Wilson
@ 2014-08-31 12:27   ` Jonathan Gray
  0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Gray @ 2014-08-31 12:27 UTC (permalink / raw)
  To: Chris Wilson, intel-gfx

On Sun, Aug 31, 2014 at 11:53:06AM +0100, Chris Wilson wrote:
> 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

Thanks, the particular case I have in mind is adding the clang
cpuid.h to gcc 4.2.1 for OpenBSD as cpuid.h is needed for
Mesa and a few other things as well.

http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/cpuid.h?revision=197399&view=co

The clang cpuid.h has all of the functions used it just needs some
small changes for bit values along the lines of the following patch.

These aren't needed for xf86-video-intel and Mesa as bit values
are defined in each project.

--- cpuid.h.orig	Sun Aug 31 22:15:36 2014
+++ cpuid.h	Sun Aug 31 22:15:46 2014
@@ -44,7 +44,9 @@
 #define bit_PCID        0x00020000
 #define bit_DCA         0x00040000
 #define bit_SSE41       0x00080000
+#define bit_SSE4_1      bit_SSE41   /* for gcc compat */
 #define bit_SSE42       0x00100000
+#define bit_SSE4_2      bit_SSE42   /* for gcc compat */
 #define bit_x2APIC      0x00200000
 #define bit_MOVBE       0x00400000
 #define bit_POPCNT      0x00800000
@@ -89,6 +91,7 @@
 
 /* Features in %ebx for level 7 sub-leaf 0 */
 #define bit_FSGSBASE    0x00000001
+#define bit_AVX2        0x00000020
 #define bit_SMEP        0x00000080
 #define bit_ENH_MOVSB   0x00000200

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-08-31 12:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-31  8:48 [PATCH xf86-video-intel] configure: check for cpuid.h Jonathan Gray
2014-08-31 10:53 ` Chris Wilson
2014-08-31 12:27   ` Jonathan Gray

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox