⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 compiler.h

📁 远程桌面连接工具
💻 H
📖 第 1 页 / 共 3 页
字号:
/* $XFree86: xc/programs/Xserver/hw/xfree86/common/compiler.h,v 3.24.2.2 1998/02/07 00:44:37 dawes Exp $ *//* * 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. * *//* $XConsortium: compiler.h /main/16 1996/10/25 15:38:34 kaleb $ */#ifndef _COMPILER_H#define _COMPILER_H#ifndef __STDC__# ifdef signed#  undef signed# endif# ifdef volatile#  undef volatile# endif# ifdef const#  undef const# endif# define signed /**/# ifdef __GNUC__#  define volatile __volatile__#  define const __const__#  ifdef PC98#   undef NO_INLINE#  endif# else#  define const /**/#  ifdef PC98#   define __inline__ /**/#  endif# endif /* __GNUC__ */#endif /* !__STDC__ */#if defined(IODEBUG) && defined(__GNUC__)#define outb RealOutb#define outw RealOutw#define outl RealOutl#define inb RealInb#define inw RealInw#define inl RealInl#endif#ifdef NO_INLINEextern void outb();extern void outw();extern void outl();extern unsigned int inb();extern unsigned int inw();extern unsigned int inl();#if NeedFunctionPrototypesextern unsigned char rdinx(unsigned short int, unsigned char);extern void wrinx(unsigned short int, unsigned char, unsigned char);extern void modinx(unsigned short int, unsigned char, unsigned char, unsigned char);extern int testrg(unsigned short int, unsigned char);extern int testinx2(unsigned short int, unsigned char, unsigned char);extern int testinx(unsigned short int, unsigned char);#else /* NeedFunctionProtoypes */extern unsigned char rdinx();extern void wrinx();extern void modinx();extern int testrg();extern int testinx2();extern int testinx();#endif /* NeedFunctionProtoypes */#else /* NO_INLINE */#ifdef __GNUC__#if defined(linux) && defined(__alpha__)/* 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. */static __inline__ voidoutb(port, val)     unsigned short port;     char val;{    extern void _outb(char val, unsigned short port);    _outb(val, port);}static __inline__ voidoutw(port, val)     unsigned short port;     short val;{    extern void _outw(short val, unsigned short port);    _outw(val, port);}static __inline__ voidoutl(port, val)     unsigned short port;     int val;{    extern void _outl(int val, unsigned short port);    _outl(val, port);}static __inline__ unsigned intinb(port)     unsigned short port;{  extern unsigned int _inb(unsigned short port);  return _inb(port);}static __inline__ unsigned intinw(port)     unsigned short port;{  extern unsigned int _inw(unsigned short port);  return _inw(port);}static __inline__ unsigned intinl(port)     unsigned short port;{  extern unsigned int _inl(unsigned short port);  return _inl(port);}/* * inline functions to do unaligned accesses * from linux/include/asm-alpha/unaligned.h */static __inline__ unsigned long ldq_u(unsigned long * r11){	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\n\t"		"bis %1,%0,%0"		:"=&r" (r1), "=&r" (r2)		:"r" (r11),		 "m" (*r11),		 "m" (*(unsigned long *)(7+(char *) r11)));	return r1;}static __inline__ unsigned long ldl_u(unsigned int * r11){	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\n\t"		"bis %1,%0,%0"		:"=&r" (r1), "=&r" (r2)		:"r" (r11),		 "m" (*r11),		 "m" (*(unsigned long *)(3+(char *) r11)));	return r1;}static __inline__ unsigned long ldw_u(unsigned short * r11){	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\n\t"		"bis %1,%0,%0"		:"=&r" (r1), "=&r" (r2)		:"r" (r11),		 "m" (*r11),		 "m" (*(unsigned long *)(1+(char *) r11)));	return r1;}static __inline__ void stq_u(unsigned long r5, unsigned long * r11){	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));}static __inline__ void stl_u(unsigned long r5, unsigned int * r11){	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));}static __inline__ void stw_u(unsigned long r5, unsigned short * r11){	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));}#define mem_barrier()        __asm__ __volatile__("mb"  : : : "memory")#ifdef __ELF__#define write_mem_barrier()  __asm__ __volatile__("wmb" : : : "memory")#else  /*  ECOFF gas 2.6 doesn't know "wmb" :-(  */#define write_mem_barrier()  mem_barrier()#endif#else /* defined(linux) && defined(__alpha__) */#if defined(__mips__)unsigned int IOPortBase;  /* Memory mapped I/O port area */static __inline__ voidoutb(port, val)     short port;     char val;{	*(volatile unsigned char*)(((unsigned short)(port))+IOPortBase) = val;}static __inline__ voidoutw(port, val)     short port;     short val;{	*(volatile unsigned short*)(((unsigned short)(port))+IOPortBase) = val;}static __inline__ voidoutl(port, val)     short port;     int val;{	*(volatile unsigned long*)(((unsigned short)(port))+IOPortBase) = val;}static __inline__ unsigned intinb(port)     short port;{	return(*(volatile unsigned char*)(((unsigned short)(port))+IOPortBase));}static __inline__ unsigned intinw(port)     short port;{	return(*(volatile unsigned short*)(((unsigned short)(port))+IOPortBase));}static __inline__ unsigned intinl(port)     short port;{	return(*(volatile unsigned long*)(((unsigned short)(port))+IOPortBase));}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;}#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)#define mem_barrier()   /* NOP */#else /* defined(mips) */#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)#define mem_barrier()   /* NOP */#define write_mem_barrier()   /* NOP */#if !defined(FAKEIT) && !defined(__mc68000__)#ifdef GCCUSESGAS/* * If gcc uses gas rather than the native assembler, the syntax of these * inlines has to be different.		DHD */#ifndef PC98static __inline__ void#if NeedFunctionPrototypesoutb(unsigned short int port,unsigned char val)#elseoutb(port, val)unsigned short int port;unsigned char val;#endif /* NeedFunctionPrototypes */{   __asm__ __volatile__("outb %0,%1" : :"a" (val), "d" (port));}static __inline__ void#if NeedFunctionPrototypesoutw(unsigned short int port,unsigned short int val)#elseoutw(port, val)unsigned short int port;unsigned short int val;#endif /* NeedFunctionPrototypes */{   __asm__ __volatile__("outw %0,%1" : :"a" (val), "d" (port));}static __inline__ void#if NeedFunctionPrototypesoutl(unsigned short int port,unsigned int val)#elseoutl(port, val)unsigned short int port;unsigned int val;#endif /* NeedFunctionPrototypes */{   __asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port));}static __inline__ unsigned int#if NeedFunctionPrototypesinb(unsigned short int port)#elseinb(port)unsigned short int port;#endif /* NeedFunctionPrototypes */{   unsigned char ret;   __asm__ __volatile__("inb %1,%0" :       "=a" (ret) :       "d" (port));   return ret;}static __inline__ unsigned int#if NeedFunctionPrototypesinw(unsigned short int port)#elseinw(port)unsigned short int port;#endif /* NeedFunctionPrototypes */{   unsigned short int ret;   __asm__ __volatile__("inw %1,%0" :       "=a" (ret) :       "d" (port));   return ret;}static __inline__ unsigned int#if NeedFunctionPrototypesinl(unsigned short int port)#elseinl(port)unsigned short int port;#endif /* NeedFunctionPrototypes */{   unsigned int ret;   __asm__ __volatile__("inl %1,%0" :       "=a" (ret) :       "d" (port));   return ret;}#else /* PC98 */static __inline__ void#if NeedFunctionPrototypes_outb(unsigned short int port,unsigned char val)#else_outb(port, val)unsigned short int port;unsigned char val;#endif /* NeedFunctionPrototypes */{     __asm__ __volatile__("outb %0,%1" ::"a" (val), "d" (port));

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -