home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 109 / EnigmaAmiga109CD.iso / software / varie / jstatus / source / compiler.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-03-18  |  5.0 KB  |  199 lines

  1. /*
  2. **      $VER: compiler.h 37.30 (7.3.98)
  3. **
  4. **      Compiler independent register (and SAS/C extensions) handling
  5. **
  6. **      (C) Copyright 1997-98 Andreas R. Kleinert
  7. **      All Rights Reserved.
  8. */
  9.  
  10. #ifndef COMPILER_H
  11. #define COMPILER_H
  12.  
  13.  /* There have been problems how to define the seglist pointer
  14.     under AROS, AmigaOS or elsewhere. It may make sense to
  15.     use a new, global type definition for it. This is done here. */
  16.  
  17. #ifndef _AROS
  18. #include <dos/dos.h>
  19. #define SEGLISTPTR BPTR
  20. #else
  21. typedef struct SegList * SEGLISTPTR;
  22. #endif /* AROS */
  23.  
  24.  
  25. /* Basically, Amiga C compilers must reach the goal to be
  26.    as SAS/C compatible as possible. But on the other hand,
  27.    when porting AmigaOS to other platforms, one perhaps
  28.    can't expect GCC becoming fully SAS/C compatible...
  29.  
  30.    There are two ways to make your sources portable:
  31.  
  32.     - using non ANSI SAS/C statements and making these
  33.       "available" to the other compilers (re- or undefining)
  34.     - using replacements for SAS/C statements and smartly
  35.       redefining these for any compiler
  36.  
  37.    The last mentioned is the most elegant, but may require to
  38.    rewrite your source codes, so this compiler include file
  39.    basically does offer both.
  40.  
  41.    For some compilers, this may have been done fromout project or
  42.    makefiles for the first method (e.g. StormC) to ensure compileablity.
  43.  
  44.    Basically, you should include this header file BEFORE any other stuff.
  45. */
  46.  
  47. /* ********************************************************************* */
  48. /* Method 1: redefining SAS/C keywords                                   */
  49. /*                                                                       */
  50. /* Sorry, this method does not work with register definitions for the current
  51. gcc version (V2.7.2.1), as it expects register attributes after the parameter
  52. description. (This is announced to be fixed with gcc V2.8.0).
  53. Moreover the __asm keyword has another meaning with GCC.
  54. Therefore ASM must be used. */
  55.  
  56. #ifdef __MAXON__  // ignore this switches of SAS/Storm
  57. #define __aligned
  58. #define __asm
  59. #define __regargs
  60. #define __saveds
  61. #define __stdargs
  62. #endif
  63.  
  64. #ifdef __GNUC__  // ignore this switches of SAS/Storm
  65. #define __d0
  66. #define __d1
  67. #define __d2
  68. #define __d3
  69. #define __d4
  70. #define __d5
  71. #define __d6
  72. #define __d7
  73. #define __a0
  74. #define __a1
  75. #define __a2
  76. #define __a3
  77. #define __a4
  78. #define __a5
  79. #define __a6
  80. #define __a7
  81. #endif
  82.  
  83. #ifdef VBCC
  84. #define __d0 __reg("d0")
  85. #define __d1 __reg("d1")
  86. #define __d2 __reg("d2")
  87. #define __d3 __reg("d3")
  88. #define __d4 __reg("d4")
  89. #define __d5 __reg("d5")
  90. #define __d6 __reg("d6")
  91. #define __d7 __reg("d7")
  92. #define __a0 __reg("a0")
  93. #define __a1 __reg("a1")
  94. #define __a2 __reg("a2")
  95. #define __a3 __reg("a3")
  96. #define __a4 __reg("a4")
  97. #define __a5 __reg("a5")
  98. #define __a6 __reg("a6")
  99. #define __a7 __reg("a7")
  100. #endif
  101.  
  102.  /* for SAS/C we don't need this, for StormC this is done in the
  103.     makefile or projectfile */
  104.  
  105. /*                                                                       */
  106. /* ********************************************************************* */
  107.  
  108.  
  109. /* ********************************************************************* */
  110. /* Method 2: defining our own keywords                                   */
  111. /*                                                                       */
  112. #ifdef __SASC
  113.  
  114. #  define REG(r)     register __ ## r
  115. #  define GNUCREG(r)
  116. #  define SAVEDS     __saveds
  117. #  define ASM        __asm
  118. #  define REGARGS    __regargs
  119. #  define STDARGS    __stdargs
  120. #  define ALIGNED    __aligned
  121.  
  122. #else
  123. # ifdef __MAXON__
  124.  
  125. #  define REG(r)    register __ ## r
  126. #  define GNUCREG(r)
  127. #  define SAVEDS
  128. #  define ASM
  129. #  define REGARGS
  130. #  define STDARGS
  131. #  define ALIGNED
  132.  
  133. # else
  134. #  ifdef __STORM__
  135.  
  136. #   define REG(r)  register __ ## r
  137. #   define GNUCREG(r)
  138. #   define SAVEDS  __saveds
  139. #   define ASM
  140. #   define REGARGS
  141. #   define STDARGS
  142. #   define ALIGNED
  143.  
  144. #  else
  145. #   ifdef __GNUC__
  146.  
  147. #    define REG(r)
  148. #    define GNUCREG(r)  __asm( #r )
  149. #    define SAVEDS  __saveds
  150. #    define ASM
  151. #    define REGARGS __regargs
  152. #    define STDARGS __stdargs
  153. #    define ALIGNED __aligned
  154.  
  155. #   else
  156. #    ifdef VBCC
  157. /* VBCC ignore this switch */
  158. #     define __aligned
  159. #     define __asm
  160. #     define __regargs
  161. #     define __saveds
  162. #     define __stdargs
  163. #     define __register
  164. #     define GNUCREG(r)
  165. #     define REG(r)
  166. #     define SAVEDS
  167. #     define ASM
  168. #     define REGARGS
  169. #     define STDARGS
  170. #     define ALIGNED
  171.  
  172. #    else
  173. #     ifdef _DCC
  174. #      define __aligned
  175. #      define __stdargs
  176. #      define GNUCREG(r)
  177. #      define ASM
  178.  
  179. #     else  /* any other compiler, to be added here */
  180.  
  181. #      define REG(r)
  182. #      define GNUCREG(r)
  183. #      define SAVEDS
  184. #      define ASM
  185. #      define REGARGS
  186. #      define STDARGS
  187. #      define ALIGNED
  188.  
  189. #     endif /*   _DCC      */
  190. #    endif /*   VBCC      */
  191. #   endif /*  __GNUC__   */
  192. #  endif /*  __STORM__  */
  193. # endif /*  __MAXON__  */
  194. #endif /*  __SASC     */
  195. /*                                                                       */
  196. /* ********************************************************************* */
  197.  
  198. #endif /* COMPILER_H */
  199.