/*
* Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Thomas Roell not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Thomas Roell makes no representations
* about the suitability of this software for any purpose. It is provided
* "as is" without express or implied warranty.
*
* THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*
*/
/*
* Copyright (c) 1994-2003 by The XFree86 Project, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of the copyright holder(s)
* and author(s) shall not be used in advertising or otherwise to promote
* the sale, use or other dealings in this Software without prior written
* authorization from the copyright holder(s) and author(s).
*/
#ifndef _COMPILER_H
#define _COMPILER_H
#if defined(__SUNPRO_C)
#define DO_PROTOTYPES
#endif
/* Map Sun compiler platform defines to gcc-style used in the code */
#define __amd64__
#endif
#define __i386__
#endif
#define __sparc__
#endif
#if defined(__sparcv9) && !defined(__sparc64__)
#define __sparc64__
#endif
#ifndef _X_EXPORT
#include <X11/Xfuncproto.h>
#endif
#include <pixman.h> /* for uint*_t types */
#ifndef __inline__
#if defined(__GNUC__)
/* gcc has __inline__ */
#else
#endif
#endif /* __inline__ */
#ifndef __inline
#if defined(__GNUC__)
/* gcc has __inline */
#else
#endif
#endif /* __inline */
/* Support gcc's __FUNCTION__ for people using other compilers */
#if !defined(__GNUC__) && !defined(__FUNCTION__)
#endif
#if defined(DO_PROTOTYPES)
#if !defined(__arm__)
#else /* __sparc__, __arm32__, __alpha__, __nds32__ */
#ifdef __SUNPRO_C
extern _X_EXPORT unsigned char xf86ReadMmio8 (void *, unsigned long);
extern _X_EXPORT unsigned short xf86ReadMmio16Be (void *, unsigned long);
extern _X_EXPORT unsigned short xf86ReadMmio16Le (void *, unsigned long);
extern _X_EXPORT unsigned int xf86ReadMmio32Be (void *, unsigned long);
extern _X_EXPORT unsigned int xf86ReadMmio32Le (void *, unsigned long);
extern _X_EXPORT void xf86WriteMmio8 (void *, unsigned long, unsigned int);
extern _X_EXPORT void xf86WriteMmio16Be (void *, unsigned long, unsigned int);
extern _X_EXPORT void xf86WriteMmio16Le (void *, unsigned long, unsigned int);
extern _X_EXPORT void xf86WriteMmio32Be (void *, unsigned long, unsigned int);
extern _X_EXPORT void xf86WriteMmio32Le (void *, unsigned long, unsigned int);
#endif /* _SUNPRO_C */
#endif /* __sparc__, __arm32__, __alpha__, __nds32__ */
#endif /* __arm__ */
#endif /* NO_INLINE || DO_PROTOTYPES */
#ifdef __GNUC__
#ifdef __i386__
#ifdef __SSE__
#else
#endif
#ifdef __SSE2__
#else
#endif
#ifndef __INTEL_COMPILER
#else
#include "ia64intrin.h"
#endif
/* Note: sync instruction requires MIPS II instruction set */
#define mem_barrier() \
".set push\n\t" \
".set noreorder\n\t" \
".set mips2\n\t" \
"sync\n\t" \
".set pop" \
: /* no output */ \
: /* no input */ \
: "memory")
#elif defined __powerpc__
#ifndef eieio
#endif /* eieio */
#endif
#endif /* __GNUC__ */
#ifndef barrier
#define barrier()
#endif
#ifndef mem_barrier
#endif
#ifndef write_mem_barrier
#endif
#ifdef __GNUC__
#if 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 */
static __inline__ void
{
}
static __inline__ void
{
}
static __inline__ void
{
}
static __inline__ unsigned int
{
}
static __inline__ unsigned int
{
}
static __inline__ unsigned int
{
}
#endif /* linux */
#if (defined(__FreeBSD__) || defined(__OpenBSD__)) \
&& !defined(DO_PROTOTYPES)
/* for FreeBSD and OpenBSD on Alpha, we use the libio (resp. libalpha) */
/* note that the appropriate setup via "ioperm" needs to be done */
#endif /* (__FreeBSD__ || __OpenBSD__ ) && !DO_PROTOTYPES */
#if defined(__NetBSD__)
#endif /* __NetBSD__ */
#include <inttypes.h>
static __inline__ void
{
}
static __inline__ void
{
}
static __inline__ void
{
}
static __inline__ unsigned int
{
unsigned char ret;
return ret;
}
static __inline__ unsigned int
{
unsigned short ret;
return ret;
}
static __inline__ unsigned int
{
unsigned int ret;
return ret;
}
#ifndef ASI_PL
#endif
static __inline__ void
{
barrier();
}
static __inline__ void
{
barrier();
}
static __inline__ void
{
barrier();
}
static __inline__ unsigned int
{
unsigned int ret;
return ret;
}
static __inline__ unsigned int
{
unsigned int ret;
return ret;
}
static __inline__ unsigned int
{
unsigned int ret;
return ret;
}
static __inline__ unsigned char
{
unsigned char ret;
return ret;
}
static __inline__ unsigned short
{
unsigned short ret;
:"r"(addr));
return ret;
}
static __inline__ unsigned short
{
unsigned short ret;
return ret;
}
static __inline__ unsigned int
{
unsigned int ret;
:"r"(addr));
return ret;
}
static __inline__ unsigned int
{
unsigned int ret;
return ret;
}
static __inline__ void
const unsigned int val)
{
barrier();
}
static __inline__ void
const unsigned int val)
{
barrier();
}
static __inline__ void
const unsigned int val)
{
barrier();
}
static __inline__ void
const unsigned int val)
{
barrier();
}
static __inline__ void
const unsigned int val)
{
barrier();
}
#define PORT_SIZE long
#else
#define PORT_SIZE short
#endif
static __inline__ void
{
val;
}
static __inline__ void
{
val;
}
static __inline__ void
{
val;
}
static __inline__ unsigned int
{
}
static __inline__ unsigned int
{
}
static __inline__ unsigned int
{
}
#if defined(__mips__)
#ifdef linux /* don't mess with other OSs */
#if X_BYTE_ORDER == X_BIG_ENDIAN
static __inline__ unsigned int
{
unsigned int ret;
:"r"(addr));
return ret;
}
static __inline__ void
const unsigned int val)
{
}
#endif
#endif /* !linux */
#endif /* __mips__ */
#elif defined(__powerpc__)
#ifndef MAP_FAILED
#endif
static __inline__ unsigned char
{
register unsigned char val;
return val;
}
static __inline__ unsigned short
{
register unsigned short val;
return val;
}
static __inline__ unsigned short
{
register unsigned short val;
return val;
}
static __inline__ unsigned int
{
register unsigned int val;
return val;
}
static __inline__ unsigned int
{
register unsigned int val;
return val;
}
static __inline__ void
const unsigned char val)
{
eieio();
}
static __inline__ void
const unsigned short val)
{
eieio();
}
static __inline__ void
const unsigned short val)
{
eieio();
}
static __inline__ void
const unsigned int val)
{
eieio();
}
static __inline__ void
const unsigned int val)
{
eieio();
}
static __inline__ void
{
if (ioBase == MAP_FAILED)
return;
}
static __inline__ void
{
if (ioBase == MAP_FAILED)
return;
}
static __inline__ void
{
if (ioBase == MAP_FAILED)
return;
}
static __inline__ unsigned int
{
if (ioBase == MAP_FAILED)
return 0;
}
static __inline__ unsigned int
{
if (ioBase == MAP_FAILED)
return 0;
}
static __inline__ unsigned int
{
if (ioBase == MAP_FAILED)
return 0;
}
/* note that the appropriate setup via "ioperm" needs to be done */
static __inline__ void
{
}
static __inline__ void
{
}
static __inline__ void
{
}
/*
* Assume all port access are aligned. We need to revise this implementation
* if there is unaligned port access.
*/
#define PORT_SIZE long
static __inline__ unsigned char
{
}
static __inline__ void
const unsigned int val)
{
barrier();
}
static __inline__ unsigned short
{
unsigned short ret;
:"r"(addr));
return ret;
}
static __inline__ unsigned short
{
}
static __inline__ void
const unsigned int val)
{
barrier();
}
static __inline__ void
const unsigned int val)
{
barrier();
}
static __inline__ unsigned int
{
unsigned int ret;
:"r"(addr));
return ret;
}
static __inline__ unsigned int
{
}
static __inline__ void
const unsigned int val)
{
__asm__ __volatile__("wsbh %0, %0;\n\t" "rotri %0, %0, 16;\n\t" "swi %0, [%1];\n\t": /* No outputs */
barrier();
}
static __inline__ void
const unsigned int val)
{
barrier();
}
#if defined(NDS32_MMIO_SWAP)
static __inline__ void
{
}
static __inline__ void
{
}
static __inline__ void
{
}
static __inline__ unsigned int
{
}
static __inline__ unsigned int
{
}
static __inline__ unsigned int
{
}
#else /* !NDS32_MMIO_SWAP */
static __inline__ void
{
barrier();
}
static __inline__ void
{
barrier();
}
static __inline__ void
{
barrier();
}
static __inline__ unsigned int
{
}
static __inline__ unsigned int
{
}
static __inline__ unsigned int
{
}
#endif /* NDS32_MMIO_SWAP */
static __inline__ void
{
}
static __inline__ void
{
}
static __inline__ void
{
}
static __inline__ unsigned int
{
unsigned char ret;
return ret;
}
static __inline__ unsigned int
{
unsigned short ret;
return ret;
}
static __inline__ unsigned int
{
unsigned int ret;
return ret;
}
#endif /* arch madness */
#else /* !GNUC */
#ifndef asm
#define asm __asm
#endif
#endif
#if !defined(__SUNPRO_C)
#endif
#endif /* __GNUC__ */
#if !defined(MMIO_IS_BE) && \
(defined(SPARC_MMIO_IS_BE) || defined(PPC_MMIO_IS_BE))
#define MMIO_IS_BE
#endif
#ifdef __alpha__
/* entry points for Mmio memory access routines */
extern _X_EXPORT int (*xf86ReadMmio8) (void *, unsigned long);
extern _X_EXPORT int (*xf86ReadMmio16) (void *, unsigned long);
#ifndef STANDALONE_MMIO
extern _X_EXPORT int (*xf86ReadMmio32) (void *, unsigned long);
#else
/* Some DRI 3D drivers need MMIO_IN32. */
static __inline__ int
{
mem_barrier();
}
#endif
extern _X_EXPORT void (*xf86WriteMmio8) (int, void *, unsigned long);
extern _X_EXPORT void (*xf86WriteMmio16) (int, void *, unsigned long);
extern _X_EXPORT void (*xf86WriteMmio32) (int, void *, unsigned long);
extern _X_EXPORT void xf86SlowBCopyFromBus(unsigned char *, unsigned char *,
int);
extern _X_EXPORT void xf86SlowBCopyToBus(unsigned char *, unsigned char *, int);
/* Some macros to hide the system dependencies for MMIO accesses */
/* Changed to kill noise generated by gcc's -Wcast-align */
#ifndef STANDALONE_MMIO
#else
#endif
do { \
write_mem_barrier(); \
} while (0)
/*
* we provide byteswapping and no byteswapping functions here
* with byteswapping as default,
* drivers that don't need byteswapping should define MMIO_IS_BE
*/
#if defined(MMIO_IS_BE) /* No byteswapping */
#else /* byteswapping is the default */
#endif
/*
* we provide byteswapping and no byteswapping functions here
* with no byteswapping as default; when endianness of CPU core
* and I/O devices don't match, byte swapping is necessary
* drivers that need byteswapping should define NDS32_MMIO_SWAP
*/
#if defined(NDS32_MMIO_SWAP) /* byteswapping */
#else /* no byteswapping is the default */
#endif
#else /* !__alpha__ && !__powerpc__ && !__sparc__ */
#endif /* __alpha__ */
/*
* With Intel, the version in os-support/misc/SlowBcopy.s is used.
* This avoids port I/O during the copy (which causes problems with
* some hardware).
*/
#ifdef __alpha__
#else /* __alpha__ */
#endif /* __alpha__ */
#endif /* _COMPILER_H */