home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / system / misc / mouse_ta.z / mouse_ta / mouse / compiler.h next >
Encoding:
C/C++ Source or Header  |  1992-05-09  |  3.1 KB  |  132 lines

  1. /*
  2.  * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
  3.  *
  4.  * Permission to use, copy, modify, distribute, and sell this software and its
  5.  * documentation for any purpose is hereby granted without fee, provided that
  6.  * the above copyright notice appear in all copies and that both that
  7.  * copyright notice and this permission notice appear in supporting
  8.  * documentation, and that the name of Thomas Roell not be used in
  9.  * advertising or publicity pertaining to distribution of the software without
  10.  * specific, written prior permission.  Thomas Roell makes no representations
  11.  * about the suitability of this software for any purpose.  It is provided
  12.  * "as is" without express or implied warranty.
  13.  *
  14.  * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  15.  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  16.  * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  17.  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  18.  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  19.  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  20.  * PERFORMANCE OF THIS SOFTWARE.
  21.  *
  22.  * $Header: /proj/X11/mit/server/ddx/x386/RCS/compiler.h,v 1.2 1991/06/27 00:01:11 root Exp $
  23.  */
  24.  
  25.  
  26. #ifndef _COMPILER_H
  27. #define _COMPILER_H
  28.  
  29. #ifdef linux
  30. static void inline outb(unsigned short port, char value)
  31. {
  32. __asm__ volatile ("outb %0,%1"
  33.     ::"a" ((char) value),"d" ((unsigned short) port));
  34. }
  35. static void inline outw(unsigned short port, short value)
  36. {
  37. __asm__ volatile ("outw %0,%1"
  38.     ::"a" ((short) value),"d" ((unsigned short) port));
  39. }
  40.  
  41. static unsigned char inline inb(unsigned short port)
  42. {
  43.     unsigned char _v;
  44.     __asm__ volatile ("inb %1,%0"
  45.         :"=a" (_v):"d" ((unsigned short) port));
  46.     return _v;
  47. }
  48. static unsigned short inline inw(unsigned short port)
  49. {
  50.     unsigned short _v;
  51.     __asm__ volatile ("inw %1,%0"
  52.         :"=a" (_v):"d" ((unsigned short) port));
  53.     return _v;
  54. }
  55.  
  56. #define intr_disable() /* should we do this?: asm("cli") */
  57. #define intr_enable()  /* should we do this?: asm("sti") */
  58.  
  59. #else /* !linux */
  60.  
  61. #define usleep(usec) syscall(3112, usec / 1000)
  62.  
  63. #ifdef __GNUC__
  64.  
  65. static __inline__ void
  66. outb(port, val)
  67.      short port;
  68.      char val;
  69. {
  70.   __asm__ volatile("out%B0 (%1)" : :"a" (val), "d" (port));
  71. }
  72.  
  73. static __inline__ void
  74. outw(port, val)
  75.      short port;
  76.      short val;
  77. {
  78.   __asm__ volatile("out%W0 (%1)" : :"a" (val), "d" (port));
  79. }
  80.  
  81. static __inline__ unsigned int
  82. inb(port)
  83.      short port;
  84. {
  85.   unsigned int ret;
  86.   __asm__ volatile("in%B0 (%1)" :
  87.            "=a" (ret) :
  88.            "d" (port));
  89.   return ret;
  90. }
  91.  
  92. static __inline__ unsigned int
  93. inw(port)
  94.      short port;
  95. {
  96.   unsigned int ret;
  97.   __asm__ volatile("in%W0 (%1)" :
  98.            "=a" (ret) :
  99.            "d" (port));
  100.   return ret;
  101. }
  102.  
  103. static __inline__ void
  104. intr_disable()
  105. {
  106.   __asm__ volatile("cli");
  107. }
  108.  
  109. static __inline__ void
  110. intr_enable()
  111. {
  112.   __asm__ volatile("sti");
  113. }
  114.  
  115. #else /* __GNUC__ */
  116. # if defined(__STDC__) && (__STDC__ == 1)
  117. #  define asm __asm
  118. # endif
  119. #include <sys/inline.h>
  120. #define intr_disable() asm("cli")
  121. #define intr_enable()  asm("sti")
  122. #endif
  123.  
  124. #endif /* linux */
  125.  
  126. #ifndef __STDC__
  127. #define signed /**/
  128. #define const /**/
  129. #endif
  130.  
  131. #endif /* _COMPILER_H */
  132.