xserver: Branch 'master' - 6 commits

Matt Turner mattst88 at kemper.freedesktop.org
Mon Aug 31 13:13:07 PDT 2009


 hw/xfree86/common/compiler.h           |  535 +++++----------------------------
 hw/xfree86/os-support/misc/BUSmemcpy.c |  187 -----------
 hw/xfree86/os-support/misc/Delay.c     |   39 --
 hw/xfree86/os-support/misc/Makefile.am |    2 
 hw/xfree86/os-support/xf86_OSproc.h    |    3 
 5 files changed, 96 insertions(+), 670 deletions(-)

New commits:
commit 9522ab9a98e98bc394703038e34b1c12aa39a179
Author: Matt Turner <mattst88 at gmail.com>
Date:   Mon Aug 31 16:12:29 2009 -0400

    Remove unused Delay.c
    
    Signed-off-by: Matt Turner <mattst88 at gmail.com>

diff --git a/hw/xfree86/os-support/misc/Delay.c b/hw/xfree86/os-support/misc/Delay.c
deleted file mode 100644
index 35ced8c..0000000
--- a/hw/xfree86/os-support/misc/Delay.c
+++ /dev/null
@@ -1,39 +0,0 @@
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-
-#include <time.h>
-
-void
-xf86UDelay(long usec)
-{
-#if 0
-    struct timeval start, interrupt;
-#else
-    int sigio;
-
-    sigio = xf86BlockSIGIO();
-    usleep(usec);
-    xf86UnblockSIGIO(sigio);
-#endif
-
-#if 0
-    gettimeofday(&start,NULL);
-
-    do {
-	usleep(usec);
-	gettimeofday(&interrupt,NULL);
-	
-	if ((usec = usec - (interrupt.tv_sec - start.tv_sec) * 1000000
-	      - (interrupt.tv_usec - start.tv_usec)) < 0)
-	    break;
-	start = interrupt;
-    } while (1);
-#endif
-}
-
diff --git a/hw/xfree86/os-support/misc/Makefile.am b/hw/xfree86/os-support/misc/Makefile.am
index ce63583..4bd3fc3 100644
--- a/hw/xfree86/os-support/misc/Makefile.am
+++ b/hw/xfree86/os-support/misc/Makefile.am
@@ -1,7 +1,7 @@
 
 noinst_LTLIBRARIES = libmisc.la
 
-libmisc_la_SOURCES = Delay.c SlowBcopy.c
+libmisc_la_SOURCES = SlowBcopy.c
 
 #AM_LDFLAGS = -r
 
diff --git a/hw/xfree86/os-support/xf86_OSproc.h b/hw/xfree86/os-support/xf86_OSproc.h
index 7e07679..c1a1173 100644
--- a/hw/xfree86/os-support/xf86_OSproc.h
+++ b/hw/xfree86/os-support/xf86_OSproc.h
@@ -143,7 +143,6 @@ extern _X_EXPORT void xf86SetTVOut(int);
 extern _X_EXPORT void xf86SetRGBOut(void);
 #endif
 extern _X_EXPORT void xf86OSRingBell(int, int, int);
-extern _X_EXPORT void xf86UDelay(long usec);
 extern _X_EXPORT void xf86SetReallySlowBcopy(void);
 extern _X_EXPORT void xf86SlowBcopy(unsigned char *, unsigned char *, int);
 extern _X_EXPORT int xf86OpenSerial(pointer options);
commit 4fac13ff8848bc38654b5567170fbc0d7b2c96d6
Author: Matt Turner <mattst88 at gmail.com>
Date:   Mon Aug 31 16:11:59 2009 -0400

    Remove unused BUSmemcpy.c
    
    BUSmemcpy.c provides xf86BusToMem and xf86MemToBus, which are are memcpy
    wrappers written to avoid glibc's memcpy on Alpha. glibc'c memcpy on
    Alpha has improved much since this was written, so it's no longer
    needed. Neither function is used inside the xserver, and no module on
    my machine uses either as well.
    
    Signed-off-by: Matt Turner <mattst88 at gmail.com>

diff --git a/hw/xfree86/os-support/misc/BUSmemcpy.c b/hw/xfree86/os-support/misc/BUSmemcpy.c
deleted file mode 100644
index e6ffde9..0000000
--- a/hw/xfree86/os-support/misc/BUSmemcpy.c
+++ /dev/null
@@ -1,187 +0,0 @@
-
-/****************************************************************************
-
- For Alpha Linux, BusToMem() and MemToBus() can be simply memcpy(), BUT:
-  we need to prevent unaligned operations when accessing DENSE space on the BUS,
-  as the video memory is mmap'd that way. The below code does this.
-
-NOTE: we could simply use the "memcpy()" from LIBC here, but that, currently, is
-      not as fast.
-
-Thanks to Linus Torvalds for contributing this code.
-
-****************************************************************************/
-
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-
-#ifdef __alpha__
-
-#include "compiler.h"
-
-#define LWORD_CODING (0x60)
-#define SPARSE (7)
-
-static unsigned long __memcpy(unsigned long dest, unsigned long src, int n);
-
-void
-xf86BusToMem(unsigned char *dst, unsigned char *src, int len)
-{
-	__memcpy((unsigned long)dst, (unsigned long)src, len);
-}
-void
-xf86MemToBus(unsigned char *dst, unsigned char *src, int len)
-{
-  if (len == sizeof(int))
-    if (!(((long)src | (long)dst) & 3))
-      *((unsigned int*)dst) = *((unsigned int*)(src));
-    else {
-      int i;
-      if (((long)src) & 3)
-	i = ldl_u((unsigned int*)src);
-      else
-	i = *(unsigned int*)src;
-      if (((long)dst) & 3)
-	stl_u(i,(unsigned int*)dst);
-      else
-	*(unsigned int*)dst = i;
-    }
-  else
-    __memcpy((unsigned long)dst, (unsigned long)src, len);
-}
-
-/*
- *  linux/arch/alpha/lib/memcpy.c
- *
- *  Copyright (C) 1995  Linus Torvalds, used with his permission.
- */
-
-/*
- * This is a reasonably optimized memcpy() routine.
- */
-
-/*
- * Note that the C code is written to be optimized into good assembly. However,
- * at this point gcc is unable to sanely compile "if (n >= 0)", resulting in a
- * explicit compare against 0 (instead of just using the proper "blt reg, xx" or
- * "bge reg, xx"). I hope alpha-gcc will be fixed to notice this eventually..
- */
-
-/*
- * This should be done in one go with ldq_u*2/mask/stq_u. Do it
- * with a macro so that we can fix it up later..
- */
-#define ALIGN_DEST_TO8(d,s,n) \
-	while (d & 7) { \
-		if (n <= 0) return; \
-		n--; \
-		*(char *) d = *(char *) s; \
-		d++; s++; \
-	}
-
-/*
- * This should similarly be done with ldq_u*2/mask/stq. The destination
- * is aligned, but we don't fill in a full quad-word
- */
-#define DO_REST(d,s,n) \
-	while (n > 0) { \
-		n--; \
-		*(char *) d = *(char *) s; \
-		d++; s++; \
-	}
-
-/*
- * This should be done with ldq/mask/stq. The source and destination are
- * aligned, but we don't fill in a full quad-word
- */
-#define DO_REST_ALIGNED(d,s,n) DO_REST(d,s,n)
-
-/*
- * This does unaligned memory copies. We want to avoid storing to
- * an unaligned address, as that would do a read-modify-write cycle.
- * We also want to avoid double-reading the unaligned reads.
- *
- * Note the ordering to try to avoid load (and address generation) latencies.
- */
-static __inline__ void __memcpy_unaligned(unsigned long d, unsigned long s, long n)
-{
-	ALIGN_DEST_TO8(d,s,n);
-	n -= 8;			/* to avoid compare against 8 in the loop */
-	if (n >= 0) {
-		unsigned long low_word, high_word;
-		__asm__("ldq_u %0,%1":"=r" (low_word):"m" (*(unsigned long *) s));
-		do {
-			unsigned long tmp;
-			__asm__("ldq_u %0,%1":"=r" (high_word):"m" (*(unsigned long *)(s+8)));
-			n -= 8;
-			__asm__("extql %1,%2,%0"
-				:"=r" (low_word)
-				:"r" (low_word), "r" (s));
-			__asm__("extqh %1,%2,%0"
-				:"=r" (tmp)
-				:"r" (high_word), "r" (s));
-			s += 8;
-			*(unsigned long *) d = low_word | tmp;
-			d += 8;
-			low_word = high_word;
-		} while (n >= 0);
-	}
-	n += 8;
-	DO_REST(d,s,n);
-}
-
-/*
- * Hmm.. Strange. The __asm__ here is there to make gcc use a integer register
- * for the load-store. I don't know why, but it would seem that using a floating
- * point register for the move seems to slow things down (very small difference,
- * though).
- *
- * Note the ordering to try to avoid load (and address generation) latencies.
- */
-static __inline__ void __memcpy_aligned(unsigned long d, unsigned long s, long n)
-{
-	ALIGN_DEST_TO8(d,s,n);
-	n -= 8;
-	while (n >= 0) {
-		unsigned long tmp;
-		__asm__("ldq %0,%1":"=r" (tmp):"m" (*(unsigned long *) s));
-		n -= 8;
-		s += 8;
-		*(unsigned long *) d = tmp;
-		d += 8;
-	}
-	n += 8;
-	DO_REST_ALIGNED(d,s,n);
-}
-
-static unsigned long __memcpy(unsigned long dest, unsigned long src, int n)
-{
-	if (!((dest ^ src) & 7)) {
-		__memcpy_aligned(dest, src, n);
-		return dest;
-	}
-	__memcpy_unaligned(dest, src, n);
-	return dest;
-}
-
-#else /* __alpha__ */
-
-void
-xf86BusToMem(unsigned char *dst, unsigned char *src, int len)
-{
-	memcpy(dst, src, len);
-}
-void
-xf86MemToBus(unsigned char *dst, unsigned char *src, int len)
-{
-	memcpy(dst, src, len);
-}
-
-#endif /* __alpha__ */
diff --git a/hw/xfree86/os-support/misc/Makefile.am b/hw/xfree86/os-support/misc/Makefile.am
index 3d4b8ff..ce63583 100644
--- a/hw/xfree86/os-support/misc/Makefile.am
+++ b/hw/xfree86/os-support/misc/Makefile.am
@@ -1,7 +1,7 @@
 
 noinst_LTLIBRARIES = libmisc.la
 
-libmisc_la_SOURCES = Delay.c BUSmemcpy.c SlowBcopy.c
+libmisc_la_SOURCES = Delay.c SlowBcopy.c
 
 #AM_LDFLAGS = -r
 
diff --git a/hw/xfree86/os-support/xf86_OSproc.h b/hw/xfree86/os-support/xf86_OSproc.h
index 98d7932..7e07679 100644
--- a/hw/xfree86/os-support/xf86_OSproc.h
+++ b/hw/xfree86/os-support/xf86_OSproc.h
@@ -143,8 +143,6 @@ extern _X_EXPORT void xf86SetTVOut(int);
 extern _X_EXPORT void xf86SetRGBOut(void);
 #endif
 extern _X_EXPORT void xf86OSRingBell(int, int, int);
-extern _X_EXPORT void xf86BusToMem(unsigned char *, unsigned char *, int);
-extern _X_EXPORT void xf86MemToBus(unsigned char *, unsigned char *, int);
 extern _X_EXPORT void xf86UDelay(long usec);
 extern _X_EXPORT void xf86SetReallySlowBcopy(void);
 extern _X_EXPORT void xf86SlowBcopy(unsigned char *, unsigned char *, int);
commit b65146fc8418b53b7e43dd34cc20000369475671
Author: Matt Turner <mattst88 at gmail.com>
Date:   Mon Aug 31 16:11:10 2009 -0400

    Remove unused ia64_flush_cache function
    
    Signed-off-by: Matt Turner <mattst88 at gmail.com>

diff --git a/hw/xfree86/common/compiler.h b/hw/xfree86/common/compiler.h
index 14f43d4..b2301e7 100644
--- a/hw/xfree86/common/compiler.h
+++ b/hw/xfree86/common/compiler.h
@@ -386,27 +386,6 @@ extern _X_EXPORT unsigned int inl(unsigned int port);
 
 #    include <sys/io.h>
 
-/*
- * This is overkill, but for different reasons depending on where it is used.
- * This is thus general enough to be used everywhere cache flushes are needed.
- * It doesn't handle memory access serialisation by other processors, though.
- */
-#    ifndef __INTEL_COMPILER
-#       define ia64_flush_cache(Addr) \
-	__asm__ __volatile__ ( \
-		"fc.i %0;;;" \
-		"sync.i;;;" \
-		"mf;;;" \
-		"srlz.i;;;" \
-		:: "r"(Addr) : "memory")
-#    else
-#      define ia64_flush_cache(Addr) { \
-        __fc(Addr);\
-        __synci();\
-        __mf();\
-        __isrlz();\
-       }
-#    endif
 #    undef outb
 #    undef outw
 #    undef outl
commit f201705e29bdc3309dd611b461ec67740cb706ef
Author: Matt Turner <mattst88 at gmail.com>
Date:   Mon Aug 31 16:09:33 2009 -0400

    Simplify unaligned access code
    
    All architectures should be able to use the same unaligned access code,
    regardless of whether they need special unaligned access instructions.
    Let's let gcc do the heavy lifting.
    
    In the case that we're not using a gcc-compatible compiler, use memmove.
    
    The xserver already requires pixman, so include pixman.h for its uint*_t
    types.
    
    Signed-off-by: Matt Turner <mattst88 at gmail.com>

diff --git a/hw/xfree86/common/compiler.h b/hw/xfree86/common/compiler.h
index 4d3594c..14f43d4 100644
--- a/hw/xfree86/common/compiler.h
+++ b/hw/xfree86/common/compiler.h
@@ -59,6 +59,8 @@
 # include <X11/Xfuncproto.h>
 #endif
 
+# include <pixman.h> /* for uint*_t types */
+
 /* Allow drivers to use the GCC-supported __inline__ and/or __inline. */
 # ifndef __inline__
 #  if defined(__GNUC__)
@@ -213,320 +215,93 @@ extern unsigned short ldw_brx(volatile unsigned char *, int);
 
 # ifndef NO_INLINE
 #  ifdef __GNUC__
-#   ifdef __alpha__
-
-struct __una_u64 { unsigned long  x __attribute__((packed)); };
-struct __una_u32 { unsigned int   x __attribute__((packed)); };
-struct __una_u16 { unsigned short x __attribute__((packed)); };
-
-/* Elemental unaligned loads */
-
-static __inline__ unsigned long ldq_u(unsigned long * r11)
-{
-	const struct __una_u64 *ptr = (const struct __una_u64 *) r11;
-	return ptr->x;
-}
-
-static __inline__ unsigned long ldl_u(unsigned int * r11)
-{
-	const struct __una_u32 *ptr = (const struct __una_u32 *) r11;
-	return ptr->x;
-}
-
-static __inline__ unsigned long ldw_u(unsigned short * r11)
-{
-	const struct __una_u16 *ptr = (const struct __una_u16 *) r11;
-	return ptr->x;
-}
-
-/* Elemental unaligned stores */
-
-static __inline__ void stq_u(unsigned long r5, unsigned long * r11)
-{
-	struct __una_u64 *ptr = (struct __una_u64 *) r11;
-	ptr->x = r5;
-}
-
-static __inline__ void stl_u(unsigned long r5, unsigned int * r11)
-{
-	struct __una_u32 *ptr = (struct __una_u32 *) r11;
-	ptr->x = r5;
-}
-
-static __inline__ void stw_u(unsigned long r5, unsigned short * r11)
-{
-	struct __una_u16 *ptr = (struct __una_u16 *) r11;
-	ptr->x = r5;
-}
-
-#   elif defined __amd64__
 
-#    define ldq_u(p)	(*((unsigned long  *)(p)))
-#    define ldl_u(p)	(*((unsigned int   *)(p)))
-#    define ldw_u(p)	(*((unsigned short *)(p)))
-#    define stq_u(v,p)	(*(unsigned long  *)(p)) = (v)
-#    define stl_u(v,p)	(*(unsigned int   *)(p)) = (v)
-#    define stw_u(v,p)	(*(unsigned short *)(p)) = (v)
-
-#   elif defined __arm__
-
-#    define ldq_u(p)	(*((unsigned long  *)(p)))
-#    define ldl_u(p)	(*((unsigned int   *)(p)))
-#    define ldw_u(p)	(*((unsigned short *)(p)))
-#    define stq_u(v,p)	(*(unsigned long  *)(p)) = (v)
-#    define stl_u(v,p)	(*(unsigned int   *)(p)) = (v)
-#    define stw_u(v,p)	(*(unsigned short *)(p)) = (v)
-
-#   elif defined __arm32__
-
-#    define ldq_u(p)	(*((unsigned long  *)(p)))
-#    define ldl_u(p)	(*((unsigned int   *)(p)))
-#    define ldw_u(p)	(*((unsigned short *)(p)))
-#    define stq_u(v,p)	(*(unsigned long  *)(p)) = (v)
-#    define stl_u(v,p)	(*(unsigned int   *)(p)) = (v)
-#    define stw_u(v,p)	(*(unsigned short *)(p)) = (v)
-
-#   elif defined __ia64__
+/* Define some packed structures to use with unaligned accesses */
 
 struct __una_u64 { uint64_t x __attribute__((packed)); };
 struct __una_u32 { uint32_t x __attribute__((packed)); };
 struct __una_u16 { uint16_t x __attribute__((packed)); };
 
-static __inline__ unsigned long
-__uldq (const unsigned long * r11)
-{
-	const struct __una_u64 *ptr = (const struct __una_u64 *) r11;
-	return ptr->x;
-}
+/* Elemental unaligned loads */
 
-static __inline__ unsigned long
-__uldl (const unsigned int * r11)
+static __inline__ uint64_t ldq_u(uint64_t *p)
 {
-	const struct __una_u32 *ptr = (const struct __una_u32 *) r11;
+	const struct __una_u64 *ptr = (const struct __una_u64 *) p;
 	return ptr->x;
 }
 
-static __inline__ unsigned long
-__uldw (const unsigned short * r11)
+static __inline__ uint32_t ldl_u(uint32_t *p)
 {
-	const struct __una_u16 *ptr = (const struct __una_u16 *) r11;
+	const struct __una_u32 *ptr = (const struct __una_u32 *) p;
 	return ptr->x;
 }
 
-static __inline__ void
-__ustq (unsigned long r5, unsigned long * r11)
-{
-	struct __una_u64 *ptr = (struct __una_u64 *) r11;
-	ptr->x = r5;
-}
-
-static __inline__ void
-__ustl (unsigned long r5, unsigned int * r11)
-{
-	struct __una_u32 *ptr = (struct __una_u32 *) r11;
-	ptr->x = r5;
-}
-
-static __inline__ void
-__ustw (unsigned long r5, unsigned short * r11)
-{
-	struct __una_u16 *ptr = (struct __una_u16 *) r11;
-	ptr->x = r5;
-}
-
-#    define ldq_u(p)	__uldq(p)
-#    define ldl_u(p)	__uldl(p)
-#    define ldw_u(p)	__uldw(p) 
-#    define stq_u(v,p)	__ustq(v,p)
-#    define stl_u(v,p)	__ustl(v,p)
-#    define stw_u(v,p)	__ustw(v,p)
-
-#   elif defined __mips__
-
-static __inline__ unsigned long ldq_u(unsigned long * r11)
+static __inline__ uint16_t ldw_u(uint16_t *p)
 {
-	unsigned long r1;
-	__asm__("lwr %0,%2\n\t"
-		"lwl %0,%3\n\t"
-		:"=&r" (r1)
-		:"r" (r11),
-		 "m" (*r11),
-		 "m" (*(unsigned long *)(3+(char *) r11)));
-	return r1;
+	const struct __una_u16 *ptr = (const struct __una_u16 *) p;
+	return ptr->x;
 }
 
-static __inline__ unsigned long ldl_u(unsigned int * r11)
-{
-	unsigned long r1;
-	__asm__("lwr %0,%2\n\t"
-		"lwl %0,%3\n\t"
-		:"=&r" (r1)
-		:"r" (r11),
-		 "m" (*r11),
-		 "m" (*(unsigned long *)(3+(char *) r11)));
-	return r1;
-}
+/* Elemental unaligned stores */
 
-static __inline__ unsigned long ldw_u(unsigned short * r11)
+static __inline__ void stq_u(uint64_t val, uint64_t *p)
 {
-	unsigned long r1;
-	__asm__("lwr %0,%2\n\t"
-		"lwl %0,%3\n\t"
-		:"=&r" (r1)
-		:"r" (r11),
-		 "m" (*r11),
-		 "m" (*(unsigned long *)(1+(char *) r11)));
-	return r1;
+	struct __una_u64 *ptr = (struct __una_u64 *) p;
+	ptr->x = val;
 }
 
-#    ifdef linux
-struct __una_u32 { unsigned int   x __attribute__((packed)); };
-struct __una_u16 { unsigned short x __attribute__((packed)); };
-
-static __inline__ void stw_u(unsigned long val, unsigned short *p)
+static __inline__ void stl_u(uint32_t val, uint32_t *p)
 {
-	struct __una_u16 *ptr = (struct __una_u16 *) p;
+	struct __una_u32 *ptr = (struct __una_u32 *) p;
 	ptr->x = val;
 }
 
-static __inline__ void stl_u(unsigned long val, unsigned int *p)
+static __inline__ void stw_u(uint16_t val, uint16_t *p)
 {
-	struct __una_u32 *ptr = (struct __una_u32 *) p;
+	struct __una_u16 *ptr = (struct __una_u16 *) p;
 	ptr->x = val;
 }
-#    else  /* !linux */
-
-#     define stq_u(v,p)	stl_u(v,p)
-#     define stl_u(v,p)	(*(unsigned char *)(p)) = (v); \
-			(*(unsigned char *)(p)+1) = ((v) >> 8);  \
-			(*(unsigned char *)(p)+2) = ((v) >> 16); \
-			(*(unsigned char *)(p)+3) = ((v) >> 24)
-
-#     define stw_u(v,p)	(*(unsigned char *)(p)) = (v); \
-			(*(unsigned char *)(p)+1) = ((v) >> 8)
-#    endif /* linux */
+#  else /* !__GNUC__ */
 
-#   elif defined __powerpc__
-
-#    define ldq_u(p)	ldl_u(p)
-#    define ldl_u(p)	((*(unsigned char *)(p))	| \
-			(*((unsigned char *)(p)+1)<<8)	| \
-			(*((unsigned char *)(p)+2)<<16)	| \
-			(*((unsigned char *)(p)+3)<<24))
-#    define ldw_u(p)	((*(unsigned char *)(p)) | \
-			(*((unsigned char *)(p)+1)<<8))
-
-#    define stq_u(v,p)	stl_u(v,p)
-#    define stl_u(v,p)	(*(unsigned char *)(p)) = (v); \
-			(*((unsigned char *)(p)+1)) = ((v) >> 8);  \
-			(*((unsigned char *)(p)+2)) = ((v) >> 16); \
-			(*((unsigned char *)(p)+3)) = ((v) >> 24)
-#    define stw_u(v,p)	(*(unsigned char *)(p)) = (v); \
-			(*((unsigned char *)(p)+1)) = ((v) >> 8)
-
-#   elif defined __sparc__
-
-#    if defined(__arch64__) || defined(__sparcv9)
-struct __una_u64 { unsigned long  x __attribute__((packed)); };
-#    endif
-struct __una_u32 { unsigned int   x __attribute__((packed)); };
-struct __una_u16 { unsigned short x __attribute__((packed)); };
-
-static __inline__ unsigned long ldq_u(unsigned long *p)
+static __inline__ uint64_t ldq_u(uint64_t *p)
 {
-#    if defined(__GNUC__)
-#     if defined(__arch64__) || defined(__sparcv9)
-	const struct __una_u64 *ptr = (const struct __una_u64 *) p;
-#     else
-	const struct __una_u32 *ptr = (const struct __una_u32 *) p;
-#     endif
-	return ptr->x;
-#    else
-	unsigned long ret;
+	uint64_t ret;
 	memmove(&ret, p, sizeof(*p));
 	return ret;
-#    endif
 }
 
-static __inline__ unsigned long ldl_u(unsigned int *p)
+static __inline__ uint32_t ldl_u(uint32_t *p)
 {
-#    if defined(__GNUC__)
-	const struct __una_u32 *ptr = (const struct __una_u32 *) p;
-	return ptr->x;
-#    else
-	unsigned int ret;
+	uint32_t ret;
 	memmove(&ret, p, sizeof(*p));
 	return ret;
-#    endif
 }
 
-static __inline__ unsigned long ldw_u(unsigned short *p)
+static __inline__ uint16_t ldw_u(uint16_t *p)
 {
-#    if defined(__GNUC__)
-	const struct __una_u16 *ptr = (const struct __una_u16 *) p;
-	return ptr->x;
-#    else
-	unsigned short ret;
+	uint16_t ret;
 	memmove(&ret, p, sizeof(*p));
 	return ret;
-#    endif
 }
 
-static __inline__ void stq_u(unsigned long val, unsigned long *p)
+static __inline__ void stq_u(uint64_t val, uint64_t *p)
 {
-#    if defined(__GNUC__)
-#     if defined(__arch64__) || defined(__sparcv9)
-	struct __una_u64 *ptr = (struct __una_u64 *) p;
-#     else
-	struct __una_u32 *ptr = (struct __una_u32 *) p;
-#     endif
-	ptr->x = val;
-#    else
-	unsigned long tmp = val;
+	uint64_t tmp = val;
 	memmove(p, &tmp, sizeof(*p));
-#    endif
 }
 
-static __inline__ void stl_u(unsigned long val, unsigned int *p)
+static __inline__ void stl_u(uint32_t val, uint32_t *p)
 {
-#    if defined(__GNUC__)
-	struct __una_u32 *ptr = (struct __una_u32 *) p;
-	ptr->x = val;
-#    else
-	unsigned int tmp = val;
+	uint32_t tmp = val;
 	memmove(p, &tmp, sizeof(*p));
-#    endif
 }
 
-static __inline__ void stw_u(unsigned long val, unsigned short *p)
+static __inline__ void stw_u(uint16_t val, uint16_t *p)
 {
-#    if defined(__GNUC__)
-	struct __una_u16 *ptr = (struct __una_u16 *) p;
-	ptr->x = val;
-#    else
-	unsigned short tmp = val;
+	uint16_t tmp = val;
 	memmove(p, &tmp, sizeof(*p));
-#    endif
 }
 
-#   else
-
-#    define ldq_u(p)	(*((unsigned long  *)(p)))
-#    define ldl_u(p)	(*((unsigned int   *)(p)))
-#    define ldw_u(p)	(*((unsigned short *)(p)))
-#    define stq_u(v,p)	(*(unsigned long  *)(p)) = (v)
-#    define stl_u(v,p)	(*(unsigned int   *)(p)) = (v)
-#    define stw_u(v,p)	(*(unsigned short *)(p)) = (v)
-
-#   endif
-
-#   define ldq_u(p)	(*((unsigned long  *)(p)))
-#   define ldl_u(p)	(*((unsigned int   *)(p)))
-#   define ldw_u(p)	(*((unsigned short *)(p)))
-#   define stq_u(v,p)	(*(unsigned long  *)(p)) = (v)
-#   define stl_u(v,p)	(*(unsigned int   *)(p)) = (v)
-#   define stw_u(v,p)	(*(unsigned short *)(p)) = (v)
-
 #  endif /* __GNUC__ */
 # endif /* NO_INLINE */
 
commit 3718beb69cc5b4cdb79dd97242fce9231a26a39a
Author: Matt Turner <mattst88 at gmail.com>
Date:   Mon Aug 31 16:08:52 2009 -0400

    Clean up unaligned access functions on alpha
    
    Checks for __GNUC__ are superfluous since the only other compiler for
    the platform is Compaq C, and it doesn't support GCC style inline
    assembly.
    
    Signed-off-by: Matt Turner <mattst88 at gmail.com>

diff --git a/hw/xfree86/common/compiler.h b/hw/xfree86/common/compiler.h
index 251b4e5..4d3594c 100644
--- a/hw/xfree86/common/compiler.h
+++ b/hw/xfree86/common/compiler.h
@@ -215,159 +215,48 @@ extern unsigned short ldw_brx(volatile unsigned char *, int);
 #  ifdef __GNUC__
 #   ifdef __alpha__
 
-/*
- * inline functions to do unaligned accesses
- * from linux/include/asm-alpha/unaligned.h
- */
-
-/*
- * EGCS 1.1 knows about arbitrary unaligned loads.  Define some
- * packed structures to talk about such things with.
- */
-
 struct __una_u64 { unsigned long  x __attribute__((packed)); };
 struct __una_u32 { unsigned int   x __attribute__((packed)); };
 struct __una_u16 { unsigned short x __attribute__((packed)); };
 
-/*
- * Elemental unaligned loads 
- */
-/* let's try making these things static */
+/* Elemental unaligned loads */
 
 static __inline__ unsigned long ldq_u(unsigned long * r11)
 {
-#    if defined(__GNUC__)
 	const struct __una_u64 *ptr = (const struct __una_u64 *) r11;
 	return ptr->x;
-#    else
-	unsigned long r1,r2;
-	__asm__("ldq_u %0,%3\n\t"
-		"ldq_u %1,%4\n\t"
-		"extql %0,%2,%0\n\t"
-		"extqh %1,%2,%1"
-		:"=&r" (r1), "=&r" (r2)
-		:"r" (r11),
-		 "m" (*r11),
-		 "m" (*(const unsigned long *)(7+(char *) r11)));
-	return r1 | r2;
-#    endif
 }
 
 static __inline__ unsigned long ldl_u(unsigned int * r11)
 {
-#    if defined(__GNUC__)
 	const struct __una_u32 *ptr = (const struct __una_u32 *) r11;
 	return ptr->x;
-#    else
-	unsigned long r1,r2;
-	__asm__("ldq_u %0,%3\n\t"
-		"ldq_u %1,%4\n\t"
-		"extll %0,%2,%0\n\t"
-		"extlh %1,%2,%1"
-		:"=&r" (r1), "=&r" (r2)
-		:"r" (r11),
-		 "m" (*r11),
-		 "m" (*(const unsigned long *)(3+(char *) r11)));
-	return r1 | r2;
-#    endif
 }
 
 static __inline__ unsigned long ldw_u(unsigned short * r11)
 {
-#    if defined(__GNUC__)
 	const struct __una_u16 *ptr = (const struct __una_u16 *) r11;
 	return ptr->x;
-#    else
-	unsigned long r1,r2;
-	__asm__("ldq_u %0,%3\n\t"
-		"ldq_u %1,%4\n\t"
-		"extwl %0,%2,%0\n\t"
-		"extwh %1,%2,%1"
-		:"=&r" (r1), "=&r" (r2)
-		:"r" (r11),
-		 "m" (*r11),
-		 "m" (*(const unsigned long *)(1+(char *) r11)));
-	return r1 | r2;
-#    endif
 }
 
-/*
- * Elemental unaligned stores 
- */
+/* Elemental unaligned stores */
 
 static __inline__ void stq_u(unsigned long r5, unsigned long * r11)
 {
-#    if defined(__GNUC__)
 	struct __una_u64 *ptr = (struct __una_u64 *) r11;
 	ptr->x = r5;
-#    else
-	unsigned long r1,r2,r3,r4;
-
-	__asm__("ldq_u %3,%1\n\t"
-		"ldq_u %2,%0\n\t"
-		"insqh %6,%7,%5\n\t"
-		"insql %6,%7,%4\n\t"
-		"mskqh %3,%7,%3\n\t"
-		"mskql %2,%7,%2\n\t"
-		"bis %3,%5,%3\n\t"
-		"bis %2,%4,%2\n\t"
-		"stq_u %3,%1\n\t"
-		"stq_u %2,%0"
-		:"=m" (*r11),
-		 "=m" (*(unsigned long *)(7+(char *) r11)),
-		 "=&r" (r1), "=&r" (r2), "=&r" (r3), "=&r" (r4)
-		:"r" (r5), "r" (r11));
-#    endif
 }
 
 static __inline__ void stl_u(unsigned long r5, unsigned int * r11)
 {
-#    if defined(__GNUC__)
 	struct __una_u32 *ptr = (struct __una_u32 *) r11;
 	ptr->x = r5;
-#    else
-	unsigned long r1,r2,r3,r4;
-
-	__asm__("ldq_u %3,%1\n\t"
-		"ldq_u %2,%0\n\t"
-		"inslh %6,%7,%5\n\t"
-		"insll %6,%7,%4\n\t"
-		"msklh %3,%7,%3\n\t"
-		"mskll %2,%7,%2\n\t"
-		"bis %3,%5,%3\n\t"
-		"bis %2,%4,%2\n\t"
-		"stq_u %3,%1\n\t"
-		"stq_u %2,%0"
-		:"=m" (*r11),
-		 "=m" (*(unsigned long *)(3+(char *) r11)),
-		 "=&r" (r1), "=&r" (r2), "=&r" (r3), "=&r" (r4)
-		:"r" (r5), "r" (r11));
-#    endif
 }
 
 static __inline__ void stw_u(unsigned long r5, unsigned short * r11)
 {
-#    if defined(__GNUC__)
 	struct __una_u16 *ptr = (struct __una_u16 *) r11;
 	ptr->x = r5;
-#    else
-	unsigned long r1,r2,r3,r4;
-
-	__asm__("ldq_u %3,%1\n\t"
-		"ldq_u %2,%0\n\t"
-		"inswh %6,%7,%5\n\t"
-		"inswl %6,%7,%4\n\t"
-		"mskwh %3,%7,%3\n\t"
-		"mskwl %2,%7,%2\n\t"
-		"bis %3,%5,%3\n\t"
-		"bis %2,%4,%2\n\t"
-		"stq_u %3,%1\n\t"
-		"stq_u %2,%0"
-		:"=m" (*r11),
-		 "=m" (*(unsigned long *)(1+(char *) r11)),
-		 "=&r" (r1), "=&r" (r2), "=&r" (r3), "=&r" (r4)
-		:"r" (r5), "r" (r11));
-#    endif
 }
 
 #   elif defined __amd64__
commit e1fdd7671346ce374a2b77fe94b8c1a25c0520da
Author: Matt Turner <mattst88 at gmail.com>
Date:   Mon Aug 31 16:08:20 2009 -0400

    Move unaligned access functions to common section
    
    Signed-off-by: Matt Turner <mattst88 at gmail.com>

diff --git a/hw/xfree86/common/compiler.h b/hw/xfree86/common/compiler.h
index b94e2b2..251b4e5 100644
--- a/hw/xfree86/common/compiler.h
+++ b/hw/xfree86/common/compiler.h
@@ -210,80 +210,10 @@ extern unsigned short ldw_brx(volatile unsigned char *, int);
 #  define write_mem_barrier() /* NOP */
 # endif
 
+
 # ifndef NO_INLINE
 #  ifdef __GNUC__
-#   if (defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)) && (defined(__alpha__))
-
-#    ifdef linux
-/* for Linux on Alpha, we use the LIBC _inx/_outx routines */
-/* note that the appropriate setup via "ioperm" needs to be done */
-/*  *before* any inx/outx is done. */
-
-extern _X_EXPORT void (*_alpha_outb)(char val, unsigned long port);
-static __inline__ void
-outb(unsigned long port, unsigned char val)
-{
-    _alpha_outb(val, port);
-}
-
-extern _X_EXPORT void (*_alpha_outw)(short val, unsigned long port);
-static __inline__ void
-outw(unsigned long port, unsigned short val)
-{
-    _alpha_outw(val, port);
-}
-
-extern _X_EXPORT void (*_alpha_outl)(int val, unsigned long port);
-static __inline__ void
-outl(unsigned long port, unsigned int val)
-{
-    _alpha_outl(val, port);
-}
-
-extern _X_EXPORT unsigned int (*_alpha_inb)(unsigned long port);
-static __inline__ unsigned int
-inb(unsigned long port)
-{
-  return _alpha_inb(port);
-}
-
-extern _X_EXPORT unsigned int (*_alpha_inw)(unsigned long port);
-static __inline__ unsigned int
-inw(unsigned long port)
-{
-  return _alpha_inw(port);
-}
-
-extern _X_EXPORT unsigned int (*_alpha_inl)(unsigned long port);
-static __inline__ unsigned int
-inl(unsigned long port)
-{
-  return _alpha_inl(port);
-}
-
-#    endif /* linux */
-
-#    if (defined(__FreeBSD__) || defined(__OpenBSD__)) \
-      && !defined(DO_PROTOTYPES)
-
-/* for FreeBSD and OpenBSD on Alpha, we use the libio (resp. libalpha) */
-/*  inx/outx routines */
-/* note that the appropriate setup via "ioperm" needs to be done */
-/*  *before* any inx/outx is done. */
-
-extern _X_EXPORT void outb(unsigned int port, unsigned char val);
-extern _X_EXPORT void outw(unsigned int port, unsigned short val);
-extern _X_EXPORT void outl(unsigned int port, unsigned int val);
-extern _X_EXPORT unsigned char inb(unsigned int port);
-extern _X_EXPORT unsigned short inw(unsigned int port);
-extern _X_EXPORT unsigned int inl(unsigned int port);
-
-#    endif /* (__FreeBSD__ || __OpenBSD__ ) && !DO_PROTOTYPES */
-
-
-#if defined(__NetBSD__)
-#include <machine/pio.h>
-#endif /* __NetBSD__ */
+#   ifdef __alpha__
 
 /*
  * inline functions to do unaligned accesses
@@ -440,11 +370,34 @@ static __inline__ void stw_u(unsigned long r5, unsigned short * r11)
 #    endif
 }
 
-#   elif defined(linux) && defined(__ia64__) 
- 
-#    include <inttypes.h>
+#   elif defined __amd64__
 
-#    include <sys/io.h>
+#    define ldq_u(p)	(*((unsigned long  *)(p)))
+#    define ldl_u(p)	(*((unsigned int   *)(p)))
+#    define ldw_u(p)	(*((unsigned short *)(p)))
+#    define stq_u(v,p)	(*(unsigned long  *)(p)) = (v)
+#    define stl_u(v,p)	(*(unsigned int   *)(p)) = (v)
+#    define stw_u(v,p)	(*(unsigned short *)(p)) = (v)
+
+#   elif defined __arm__
+
+#    define ldq_u(p)	(*((unsigned long  *)(p)))
+#    define ldl_u(p)	(*((unsigned int   *)(p)))
+#    define ldw_u(p)	(*((unsigned short *)(p)))
+#    define stq_u(v,p)	(*(unsigned long  *)(p)) = (v)
+#    define stl_u(v,p)	(*(unsigned int   *)(p)) = (v)
+#    define stw_u(v,p)	(*(unsigned short *)(p)) = (v)
+
+#   elif defined __arm32__
+
+#    define ldq_u(p)	(*((unsigned long  *)(p)))
+#    define ldl_u(p)	(*((unsigned int   *)(p)))
+#    define ldw_u(p)	(*((unsigned short *)(p)))
+#    define stq_u(v,p)	(*(unsigned long  *)(p)) = (v)
+#    define stl_u(v,p)	(*(unsigned int   *)(p)) = (v)
+#    define stw_u(v,p)	(*(unsigned short *)(p)) = (v)
+
+#   elif defined __ia64__
 
 struct __una_u64 { uint64_t x __attribute__((packed)); };
 struct __una_u32 { uint32_t x __attribute__((packed)); };
@@ -499,6 +452,276 @@ __ustw (unsigned long r5, unsigned short * r11)
 #    define stl_u(v,p)	__ustl(v,p)
 #    define stw_u(v,p)	__ustw(v,p)
 
+#   elif defined __mips__
+
+static __inline__ unsigned long ldq_u(unsigned long * r11)
+{
+	unsigned long r1;
+	__asm__("lwr %0,%2\n\t"
+		"lwl %0,%3\n\t"
+		:"=&r" (r1)
+		:"r" (r11),
+		 "m" (*r11),
+		 "m" (*(unsigned long *)(3+(char *) r11)));
+	return r1;
+}
+
+static __inline__ unsigned long ldl_u(unsigned int * r11)
+{
+	unsigned long r1;
+	__asm__("lwr %0,%2\n\t"
+		"lwl %0,%3\n\t"
+		:"=&r" (r1)
+		:"r" (r11),
+		 "m" (*r11),
+		 "m" (*(unsigned long *)(3+(char *) r11)));
+	return r1;
+}
+
+static __inline__ unsigned long ldw_u(unsigned short * r11)
+{
+	unsigned long r1;
+	__asm__("lwr %0,%2\n\t"
+		"lwl %0,%3\n\t"
+		:"=&r" (r1)
+		:"r" (r11),
+		 "m" (*r11),
+		 "m" (*(unsigned long *)(1+(char *) r11)));
+	return r1;
+}
+
+#    ifdef linux
+struct __una_u32 { unsigned int   x __attribute__((packed)); };
+struct __una_u16 { unsigned short x __attribute__((packed)); };
+
+static __inline__ void stw_u(unsigned long val, unsigned short *p)
+{
+	struct __una_u16 *ptr = (struct __una_u16 *) p;
+	ptr->x = val;
+}
+
+static __inline__ void stl_u(unsigned long val, unsigned int *p)
+{
+	struct __una_u32 *ptr = (struct __una_u32 *) p;
+	ptr->x = val;
+}
+#    else  /* !linux */
+
+#     define stq_u(v,p)	stl_u(v,p)
+#     define stl_u(v,p)	(*(unsigned char *)(p)) = (v); \
+			(*(unsigned char *)(p)+1) = ((v) >> 8);  \
+			(*(unsigned char *)(p)+2) = ((v) >> 16); \
+			(*(unsigned char *)(p)+3) = ((v) >> 24)
+
+#     define stw_u(v,p)	(*(unsigned char *)(p)) = (v); \
+			(*(unsigned char *)(p)+1) = ((v) >> 8)
+#    endif /* linux */
+
+#   elif defined __powerpc__
+
+#    define ldq_u(p)	ldl_u(p)
+#    define ldl_u(p)	((*(unsigned char *)(p))	| \
+			(*((unsigned char *)(p)+1)<<8)	| \
+			(*((unsigned char *)(p)+2)<<16)	| \
+			(*((unsigned char *)(p)+3)<<24))
+#    define ldw_u(p)	((*(unsigned char *)(p)) | \
+			(*((unsigned char *)(p)+1)<<8))
+
+#    define stq_u(v,p)	stl_u(v,p)
+#    define stl_u(v,p)	(*(unsigned char *)(p)) = (v); \
+			(*((unsigned char *)(p)+1)) = ((v) >> 8);  \
+			(*((unsigned char *)(p)+2)) = ((v) >> 16); \
+			(*((unsigned char *)(p)+3)) = ((v) >> 24)
+#    define stw_u(v,p)	(*(unsigned char *)(p)) = (v); \
+			(*((unsigned char *)(p)+1)) = ((v) >> 8)
+
+#   elif defined __sparc__
+
+#    if defined(__arch64__) || defined(__sparcv9)
+struct __una_u64 { unsigned long  x __attribute__((packed)); };
+#    endif
+struct __una_u32 { unsigned int   x __attribute__((packed)); };
+struct __una_u16 { unsigned short x __attribute__((packed)); };
+
+static __inline__ unsigned long ldq_u(unsigned long *p)
+{
+#    if defined(__GNUC__)
+#     if defined(__arch64__) || defined(__sparcv9)
+	const struct __una_u64 *ptr = (const struct __una_u64 *) p;
+#     else
+	const struct __una_u32 *ptr = (const struct __una_u32 *) p;
+#     endif
+	return ptr->x;
+#    else
+	unsigned long ret;
+	memmove(&ret, p, sizeof(*p));
+	return ret;
+#    endif
+}
+
+static __inline__ unsigned long ldl_u(unsigned int *p)
+{
+#    if defined(__GNUC__)
+	const struct __una_u32 *ptr = (const struct __una_u32 *) p;
+	return ptr->x;
+#    else
+	unsigned int ret;
+	memmove(&ret, p, sizeof(*p));
+	return ret;
+#    endif
+}
+
+static __inline__ unsigned long ldw_u(unsigned short *p)
+{
+#    if defined(__GNUC__)
+	const struct __una_u16 *ptr = (const struct __una_u16 *) p;
+	return ptr->x;
+#    else
+	unsigned short ret;
+	memmove(&ret, p, sizeof(*p));
+	return ret;
+#    endif
+}
+
+static __inline__ void stq_u(unsigned long val, unsigned long *p)
+{
+#    if defined(__GNUC__)
+#     if defined(__arch64__) || defined(__sparcv9)
+	struct __una_u64 *ptr = (struct __una_u64 *) p;
+#     else
+	struct __una_u32 *ptr = (struct __una_u32 *) p;
+#     endif
+	ptr->x = val;
+#    else
+	unsigned long tmp = val;
+	memmove(p, &tmp, sizeof(*p));
+#    endif
+}
+
+static __inline__ void stl_u(unsigned long val, unsigned int *p)
+{
+#    if defined(__GNUC__)
+	struct __una_u32 *ptr = (struct __una_u32 *) p;
+	ptr->x = val;
+#    else
+	unsigned int tmp = val;
+	memmove(p, &tmp, sizeof(*p));
+#    endif
+}
+
+static __inline__ void stw_u(unsigned long val, unsigned short *p)
+{
+#    if defined(__GNUC__)
+	struct __una_u16 *ptr = (struct __una_u16 *) p;
+	ptr->x = val;
+#    else
+	unsigned short tmp = val;
+	memmove(p, &tmp, sizeof(*p));
+#    endif
+}
+
+#   else
+
+#    define ldq_u(p)	(*((unsigned long  *)(p)))
+#    define ldl_u(p)	(*((unsigned int   *)(p)))
+#    define ldw_u(p)	(*((unsigned short *)(p)))
+#    define stq_u(v,p)	(*(unsigned long  *)(p)) = (v)
+#    define stl_u(v,p)	(*(unsigned int   *)(p)) = (v)
+#    define stw_u(v,p)	(*(unsigned short *)(p)) = (v)
+
+#   endif
+
+#   define ldq_u(p)	(*((unsigned long  *)(p)))
+#   define ldl_u(p)	(*((unsigned int   *)(p)))
+#   define ldw_u(p)	(*((unsigned short *)(p)))
+#   define stq_u(v,p)	(*(unsigned long  *)(p)) = (v)
+#   define stl_u(v,p)	(*(unsigned int   *)(p)) = (v)
+#   define stw_u(v,p)	(*(unsigned short *)(p)) = (v)
+
+#  endif /* __GNUC__ */
+# endif /* NO_INLINE */
+
+# ifndef NO_INLINE
+#  ifdef __GNUC__
+#   if (defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)) && (defined(__alpha__))
+
+#    ifdef linux
+/* for Linux on Alpha, we use the LIBC _inx/_outx routines */
+/* note that the appropriate setup via "ioperm" needs to be done */
+/*  *before* any inx/outx is done. */
+
+extern _X_EXPORT void (*_alpha_outb)(char val, unsigned long port);
+static __inline__ void
+outb(unsigned long port, unsigned char val)
+{
+    _alpha_outb(val, port);
+}
+
+extern _X_EXPORT void (*_alpha_outw)(short val, unsigned long port);
+static __inline__ void
+outw(unsigned long port, unsigned short val)
+{
+    _alpha_outw(val, port);
+}
+
+extern _X_EXPORT void (*_alpha_outl)(int val, unsigned long port);
+static __inline__ void
+outl(unsigned long port, unsigned int val)
+{
+    _alpha_outl(val, port);
+}
+
+extern _X_EXPORT unsigned int (*_alpha_inb)(unsigned long port);
+static __inline__ unsigned int
+inb(unsigned long port)
+{
+  return _alpha_inb(port);
+}
+
+extern _X_EXPORT unsigned int (*_alpha_inw)(unsigned long port);
+static __inline__ unsigned int
+inw(unsigned long port)
+{
+  return _alpha_inw(port);
+}
+
+extern _X_EXPORT unsigned int (*_alpha_inl)(unsigned long port);
+static __inline__ unsigned int
+inl(unsigned long port)
+{
+  return _alpha_inl(port);
+}
+
+#    endif /* linux */
+
+#    if (defined(__FreeBSD__) || defined(__OpenBSD__)) \
+      && !defined(DO_PROTOTYPES)
+
+/* for FreeBSD and OpenBSD on Alpha, we use the libio (resp. libalpha) */
+/*  inx/outx routines */
+/* note that the appropriate setup via "ioperm" needs to be done */
+/*  *before* any inx/outx is done. */
+
+extern _X_EXPORT void outb(unsigned int port, unsigned char val);
+extern _X_EXPORT void outw(unsigned int port, unsigned short val);
+extern _X_EXPORT void outl(unsigned int port, unsigned int val);
+extern _X_EXPORT unsigned char inb(unsigned int port);
+extern _X_EXPORT unsigned short inw(unsigned int port);
+extern _X_EXPORT unsigned int inl(unsigned int port);
+
+#    endif /* (__FreeBSD__ || __OpenBSD__ ) && !DO_PROTOTYPES */
+
+
+#if defined(__NetBSD__)
+#include <machine/pio.h>
+#endif /* __NetBSD__ */
+
+#   elif defined(linux) && defined(__ia64__) 
+ 
+#    include <inttypes.h>
+
+#    include <sys/io.h>
+
 /*
  * This is overkill, but for different reasons depending on where it is used.
  * This is thus general enough to be used everywhere cache flushes are needed.
@@ -537,13 +760,6 @@ extern _X_EXPORT unsigned int inl(unsigned long port);
  
 #    include <inttypes.h>
 
-#    define ldq_u(p)	(*((unsigned long  *)(p)))
-#    define ldl_u(p)	(*((unsigned int   *)(p)))
-#    define ldw_u(p)	(*((unsigned short *)(p)))
-#    define stq_u(v,p)	(*(unsigned long  *)(p)) = (v)
-#    define stl_u(v,p)	(*(unsigned int   *)(p)) = (v)
-#    define stw_u(v,p)	(*(unsigned short *)(p)) = (v)
-  
 static __inline__ void
 outb(unsigned short port, unsigned char val)
 {
@@ -831,95 +1047,6 @@ xf86WriteMmio32LeNB(__volatile__ void *base, const unsigned long offset,
 			     : "r" (val), "r" (addr), "i" (ASI_PL));
 }
 
-
-/*
- * EGCS 1.1 knows about arbitrary unaligned loads.  Define some
- * packed structures to talk about such things with.
- */
-
-#    if defined(__arch64__) || defined(__sparcv9)
-struct __una_u64 { unsigned long  x __attribute__((packed)); };
-#    endif
-struct __una_u32 { unsigned int   x __attribute__((packed)); };
-struct __una_u16 { unsigned short x __attribute__((packed)); };
-
-static __inline__ unsigned long ldq_u(unsigned long *p)
-{
-#    if defined(__GNUC__)
-#     if defined(__arch64__) || defined(__sparcv9)
-	const struct __una_u64 *ptr = (const struct __una_u64 *) p;
-#     else
-	const struct __una_u32 *ptr = (const struct __una_u32 *) p;
-#     endif
-	return ptr->x;
-#    else
-	unsigned long ret;
-	memmove(&ret, p, sizeof(*p));
-	return ret;
-#    endif
-}
-
-static __inline__ unsigned long ldl_u(unsigned int *p)
-{
-#    if defined(__GNUC__)
-	const struct __una_u32 *ptr = (const struct __una_u32 *) p;
-	return ptr->x;
-#    else
-	unsigned int ret;
-	memmove(&ret, p, sizeof(*p));
-	return ret;
-#    endif
-}
-
-static __inline__ unsigned long ldw_u(unsigned short *p)
-{
-#    if defined(__GNUC__)
-	const struct __una_u16 *ptr = (const struct __una_u16 *) p;
-	return ptr->x;
-#    else
-	unsigned short ret;
-	memmove(&ret, p, sizeof(*p));
-	return ret;
-#    endif
-}
-
-static __inline__ void stq_u(unsigned long val, unsigned long *p)
-{
-#    if defined(__GNUC__)
-#     if defined(__arch64__) || defined(__sparcv9)
-	struct __una_u64 *ptr = (struct __una_u64 *) p;
-#     else
-	struct __una_u32 *ptr = (struct __una_u32 *) p;
-#     endif
-	ptr->x = val;
-#    else
-	unsigned long tmp = val;
-	memmove(p, &tmp, sizeof(*p));
-#    endif
-}
-
-static __inline__ void stl_u(unsigned long val, unsigned int *p)
-{
-#    if defined(__GNUC__)
-	struct __una_u32 *ptr = (struct __una_u32 *) p;
-	ptr->x = val;
-#    else
-	unsigned int tmp = val;
-	memmove(p, &tmp, sizeof(*p));
-#    endif
-}
-
-static __inline__ void stw_u(unsigned long val, unsigned short *p)
-{
-#    if defined(__GNUC__)
-	struct __una_u16 *ptr = (struct __una_u16 *) p;
-	ptr->x = val;
-#    else
-	unsigned short tmp = val;
-	memmove(p, &tmp, sizeof(*p));
-#    endif
-}
-
 #   elif defined(__mips__) || (defined(__arm32__) && !defined(__linux__))
 #    ifdef __arm32__
 #     define PORT_SIZE long
@@ -967,65 +1094,7 @@ inl(unsigned PORT_SIZE port)
 
 
 #    if defined(__mips__)
-static __inline__ unsigned long ldq_u(unsigned long * r11)
-{
-	unsigned long r1;
-	__asm__("lwr %0,%2\n\t"
-		"lwl %0,%3\n\t"
-		:"=&r" (r1)
-		:"r" (r11),
-		 "m" (*r11),
-		 "m" (*(unsigned long *)(3+(char *) r11)));
-	return r1;
-}
-
-static __inline__ unsigned long ldl_u(unsigned int * r11)
-{
-	unsigned long r1;
-	__asm__("lwr %0,%2\n\t"
-		"lwl %0,%3\n\t"
-		:"=&r" (r1)
-		:"r" (r11),
-		 "m" (*r11),
-		 "m" (*(unsigned long *)(3+(char *) r11)));
-	return r1;
-}
-
-static __inline__ unsigned long ldw_u(unsigned short * r11)
-{
-	unsigned long r1;
-	__asm__("lwr %0,%2\n\t"
-		"lwl %0,%3\n\t"
-		:"=&r" (r1)
-		:"r" (r11),
-		 "m" (*r11),
-		 "m" (*(unsigned long *)(1+(char *) r11)));
-	return r1;
-}
-
 #     ifdef linux	/* don't mess with other OSs */
-
-/*
- * EGCS 1.1 knows about arbitrary unaligned loads (and we don't support older
- * versions anyway. Define some packed structures to talk about such things
- * with.
- */
-
-struct __una_u32 { unsigned int   x __attribute__((packed)); };
-struct __una_u16 { unsigned short x __attribute__((packed)); };
-
-static __inline__ void stw_u(unsigned long val, unsigned short *p)
-{
-	struct __una_u16 *ptr = (struct __una_u16 *) p;
-	ptr->x = val;
-}
-
-static __inline__ void stl_u(unsigned long val, unsigned int *p)
-{
-	struct __una_u32 *ptr = (struct __una_u32 *) p;
-	ptr->x = val;
-}
-
 #       if X_BYTE_ORDER == X_BIG_ENDIAN
 static __inline__ unsigned int
 xf86ReadMmio32Be(__volatile__ void *base, const unsigned long offset)
@@ -1050,30 +1119,9 @@ xf86WriteMmio32Be(__volatile__ void *base, const unsigned long offset,
 			     : "r" (val), "r" (addr));
 }
 #      endif
-
-#     else  /* !linux */
-
-#      define stq_u(v,p)	stl_u(v,p)
-#      define stl_u(v,p)	(*(unsigned char *)(p)) = (v); \
-			(*(unsigned char *)(p)+1) = ((v) >> 8);  \
-			(*(unsigned char *)(p)+2) = ((v) >> 16); \
-			(*(unsigned char *)(p)+3) = ((v) >> 24)
-
-#      define stw_u(v,p)	(*(unsigned char *)(p)) = (v); \
-				(*(unsigned char *)(p)+1) = ((v) >> 8)
-
 #     endif /* !linux */
 #    endif /* __mips__ */
 
-#    if defined(__arm32__)
-#     define ldq_u(p)	(*((unsigned long  *)(p)))
-#     define ldl_u(p)	(*((unsigned int   *)(p)))
-#     define ldw_u(p)	(*((unsigned short *)(p)))
-#     define stq_u(v,p)	(*(unsigned long  *)(p)) = (v)
-#     define stl_u(v,p)	(*(unsigned int   *)(p)) = (v)
-#     define stw_u(v,p)	(*(unsigned short *)(p)) = (v)
-#    endif /* __arm32__ */
-
 #   elif (defined(linux) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__)) && defined(__powerpc__)
 
 #    ifndef MAP_FAILED
@@ -1280,31 +1328,8 @@ inl(unsigned short port)
         return xf86ReadMmio32Le((void *)ioBase, port);
 }
 
-#    define ldq_u(p)	ldl_u(p)
-#    define ldl_u(p)	((*(unsigned char *)(p))	| \
-			(*((unsigned char *)(p)+1)<<8)	| \
-			(*((unsigned char *)(p)+2)<<16)	| \
-			(*((unsigned char *)(p)+3)<<24))
-#    define ldw_u(p)	((*(unsigned char *)(p)) | \
-			(*((unsigned char *)(p)+1)<<8))
-
-#    define stq_u(v,p)	stl_u(v,p)
-#    define stl_u(v,p)	(*(unsigned char *)(p)) = (v); \
-				(*((unsigned char *)(p)+1)) = ((v) >> 8);  \
-				(*((unsigned char *)(p)+2)) = ((v) >> 16); \
-				(*((unsigned char *)(p)+3)) = ((v) >> 24)
-#    define stw_u(v,p)	(*(unsigned char *)(p)) = (v); \
-				(*((unsigned char *)(p)+1)) = ((v) >> 8)
-
 #elif defined(__arm__) && defined(__linux__)
 
-#define ldq_u(p)	(*((unsigned long  *)(p)))
-#define ldl_u(p)	(*((unsigned int   *)(p)))
-#define ldw_u(p)	(*((unsigned short *)(p)))
-#define stq_u(v,p)	(*(unsigned long  *)(p)) = (v)
-#define stl_u(v,p)	(*(unsigned int   *)(p)) = (v)
-#define stw_u(v,p)	(*(unsigned short *)(p)) = (v)
-
 /* for Linux on ARM, we use the LIBC inx/outx routines */
 /* note that the appropriate setup via "ioperm" needs to be done */
 /*  *before* any inx/outx is done. */
@@ -1335,13 +1360,6 @@ xf_outl(unsigned short port, unsigned int val)
 
 #   else /* ix86 */
 
-#    define ldq_u(p)	(*((unsigned long  *)(p)))
-#    define ldl_u(p)	(*((unsigned int   *)(p)))
-#    define ldw_u(p)	(*((unsigned short *)(p)))
-#    define stq_u(v,p)	(*(unsigned long  *)(p)) = (v)
-#    define stl_u(v,p)	(*(unsigned int   *)(p)) = (v)
-#    define stw_u(v,p)	(*(unsigned short *)(p)) = (v)
-
 #    if !defined(__SUNPRO_C)
 #    if !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__) && !defined(__s390__) && !defined(__m32r__)
 #     ifdef GCCUSESGAS
@@ -1523,12 +1541,6 @@ inl(unsigned short port)
 #     pragma asm partial_optimization inw
 #     pragma asm partial_optimization inb
 #    endif
-#   define ldq_u(p)	(*((unsigned long  *)(p)))
-#   define ldl_u(p)	(*((unsigned int   *)(p)))
-#   define ldw_u(p)	(*((unsigned short *)(p)))
-#   define stq_u(v,p)	(*(unsigned long  *)(p)) = (v)
-#   define stl_u(v,p)	(*(unsigned int   *)(p)) = (v)
-#   define stw_u(v,p)	(*(unsigned short *)(p)) = (v)
 #  endif /* __GNUC__ */
 
 # endif /* NO_INLINE */


More information about the xorg-commit mailing list