home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / server / ddx / x386 / compiler.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-06-26  |  2.3 KB  |  98 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 __GNUC__
  30.  
  31.  
  32. static __inline__ void
  33. outb(port, val)
  34.      short port;
  35.      char val;
  36. {
  37.   __asm__ volatile("out%B0 (%1)" : :"a" (val), "d" (port));
  38. }
  39.  
  40. static __inline__ void
  41. outw(port, val)
  42.      short port;
  43.      short val;
  44. {
  45.   __asm__ volatile("out%W0 (%1)" : :"a" (val), "d" (port));
  46. }
  47.  
  48. static __inline__ unsigned int
  49. inb(port)
  50.      short port;
  51. {
  52.   unsigned int ret;
  53.   __asm__ volatile("in%B0 (%1)" :
  54.            "=a" (ret) :
  55.            "d" (port));
  56.   return ret;
  57. }
  58.  
  59. static __inline__ unsigned int
  60. inw(port)
  61.      short port;
  62. {
  63.   unsigned int ret;
  64.   __asm__ volatile("in%W0 (%1)" :
  65.            "=a" (ret) :
  66.            "d" (port));
  67.   return ret;
  68. }
  69.  
  70. static __inline__ void
  71. intr_disable()
  72. {
  73.   __asm__ volatile("cli");
  74. }
  75.  
  76. static __inline__ void
  77. intr_enable()
  78. {
  79.   __asm__ volatile("sti");
  80. }
  81.  
  82.  
  83. #else /* __GNUC__ */
  84. # if defined(__STDC__) && (__STDC__ == 1)
  85. #  define asm __asm
  86. # endif
  87. #include <sys/inline.h>
  88. #define intr_disable() asm("cli")
  89. #define intr_enable()  asm("sti")
  90. #endif
  91.  
  92. #ifndef __STDC__
  93. #define signed /**/
  94. #define const /**/
  95. #endif
  96.  
  97. #endif /* _COMPILER_H */
  98.