home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / source / xdme_1.84_src.lha / XDME / Lib / include / Definitions.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-05  |  8.1 KB  |  287 lines

  1. /******************************************************************************
  2.  
  3.     MODULE
  4.     Definitions.h
  5.  
  6.     DESCRIPTION
  7.     The most important definitions to make a module work
  8.     in the XDME complex
  9.  
  10.     HISTORY
  11.     20-11-94 b_noll created
  12.  
  13. ******************************************************************************/
  14.  
  15. #ifndef DEFINITIONS_H
  16. #define DEFINITIONS_H 1
  17.  
  18. /**************************************
  19.         Macros
  20. **************************************/
  21.  
  22.  
  23. /* ---- std way to declare prototypes, introduced by DICE */
  24. #undef    Prototype
  25. #define Prototype extern
  26.  
  27. #undef    Local
  28. #define Local      static
  29.  
  30. /* ---- Some protos might be interesting only to a certain module */
  31. /*    while others might be usable for all other modules; so we */
  32. /*    should introduce something to distinguish these cases      */
  33.  
  34.  
  35. /* ---- alternative entry for an external visible function */
  36. #undef    DEFPROTO
  37. #define DEFPROTO(ret,func,param)                        ret func param
  38.  
  39.  
  40. /* ---- entry for XDME v1.xx macro language commands */
  41. #undef    DEFUSERCMD
  42. #define DEFUSERCMD(str,nargs,flags,ret,func,param,ext)  ret func param ext
  43.  
  44.  
  45. /* ---- entries for generic flags - first create gen_flags.h 2 compile */
  46. #undef    DEFFLAG
  47. #include "gen_flags.h"
  48. #undef    DEFFLAG
  49. #define DEFFLAG(date,name,initval)  /* expand to nothing */
  50.  
  51.  
  52. /* ---- entries for localizable strings - create gen_messages.h 2 compile */
  53. #undef    DEFMESSAGE
  54. #define DEFMESSAGE(name,txt) extern const char *name;
  55. #include "gen_messages.h"
  56. #undef    DEFMESSAGE
  57. #define DEFMESSAGE(name,txt)        /* expand to nothing */
  58.  
  59.  
  60. /* ---- entry for a XDME v1.xx group of variables  */
  61. #undef    DEFVARTREE
  62. #define DEFVARTREE(prio,prefix,id,prelen,precut,flags,replace,ud,set,get) \
  63.                     /* expand to nothing */
  64.  
  65.  
  66. /* ---- entry for a XDME signal bit handler in main loop */
  67. #undef    DEFSIGHANDLER
  68. #define DEFSIGHANDLER(sig,func)     /* expand to nothing */
  69.  
  70.  
  71. /* ---- entry for a define, that is only active, if a certain module is used */
  72. #include "gen_definitions.h"
  73. #undef    DEFDEFINITION
  74. #define DEFDEFINITION(x)            /* expand to nothing */
  75.  
  76.  
  77. /* ---- entries for autoinit and autoexit functions (compiler dependent) */
  78.  
  79. #if   defined(__SASC)
  80.  
  81. #   undef  DEFAUTOINIT
  82. #   define DEFAUTOINIT(name)                \
  83.     void _STI__ ## name (void)
  84.  
  85.     /* ---- the somehow funny defexit is caused by the fact, that some */
  86.     /*        other functions are trying to call the exitfunc by name    */
  87. #   undef  DEFAUTOEXIT
  88. #   define DEFAUTOEXIT(name)                \
  89.     void name (void);                       \
  90.     void _STD__ ## name (void) { name(); }  \
  91.     void name (void)
  92.  
  93. #elif defined(_DCC)
  94.  
  95. #   undef  DEFAUTOINIT
  96. #   define DEFAUTOINIT(name) __autoinit void name (void)
  97.  
  98. #   undef  DEFAUTOEXIT
  99. #   define DEFAUTOEXIT(name) __autoexit void name (void)
  100.  
  101. #else
  102.  
  103. #   error "Unknown compiler! Please add proper defines in Definitions.h"
  104.  
  105. #endif
  106.  
  107.  
  108. /* ---- some other compiler specific stuff used for special OS       */
  109. /*    related functionality like e.g. Libs, callbacks, BOOPSI    */
  110. /*                                   */
  111. /*    **** this stuff is currently not used inside XDME ****       */
  112. /*                                   */
  113. /*    PRE_A4 qualifier for a function to restore the A4 register */
  114. /*    POST_A4 function to restore the A4 register           */
  115. /*        either PRE_A4 or POST_A4 is normally empty           */
  116. /*    PRE_REG qualifier to indicate, a function uses explicitely */
  117. /*        defined registerized arguments               */
  118. /*    REG() definition for a registerized parameter              */
  119. /*    __A[012]/__D[01] the mostly used registerized parameters   */
  120.  
  121. #if   defined(__SASC)
  122.  
  123. #   define  PRE_A4  __saveds
  124. #   define  PRE_REG __asm
  125. #   define POST_A4
  126.  
  127. #   define REG(r,x) register __ ## r x
  128.  
  129. #   define __A0(x)  register __a0 x
  130. #   define __A1(x)  register __a1 x
  131. #   define __A2(x)  register __a2 x
  132. #   define __D0(x)  register __d0 x
  133. #   define __D1(x)  register __d1 x
  134.  
  135. #elif defined(_DCC)
  136.  
  137. #   define  PRE_A4  __geta4
  138. #   define  PRE_REG
  139. #   define POST_A4
  140.  
  141. #   define REG(r,x) __ ## r x
  142.  
  143. #   define __A0(x)  __A0 x
  144. #   define __A1(x)  __A1 x
  145. #   define __A2(x)  __A2 x
  146. #   define __D0(x)  __D0 x
  147. #   define __D1(x)  __D1 x
  148.  
  149. #else
  150.  
  151. #   error "Unknown compiler! Please add proper defines in Definitions.h"
  152.  
  153. #endif
  154.  
  155.  
  156.  
  157. #if 0
  158.  
  159. /* ---- support for (not yet supported) ARexx commands  */
  160. /*    Other than ARexxBox we do not calloc/free    */
  161. /*    the arg structs in additional calls to the    */
  162. /*    according function but immediately in the main    */
  163. /*    command dispatcher                */
  164. /*                            */
  165. /* *** this stuff is currently not used inside XDME *** */
  166.  
  167. //////////////////////////////////////////////////
  168. //    Read the C-fied Definitions
  169. //////////////////////////////////////////////////
  170. #include "gen_rx_commands.h"
  171.  
  172. //////////////////////////////////////////////////
  173. //        Make Arg Structs
  174. //////////////////////////////////////////////////
  175. #undef    ARG_SEP
  176. #define ARG_SEP ";"
  177. #undef    DEFRXCMD
  178. #define DEFRXCMD(name,param,results)            \
  179.     struct name ## _ARG {            \
  180.     A_ARGS_ ## name             \
  181.     };
  182. #include "rx_commands.h"
  183.  
  184. //////////////////////////////////////////////////
  185. //        Make Prototypes
  186. //////////////////////////////////////////////////
  187. #undef    ARG_SEP
  188. #define ARG_SEP ","
  189. #undef    DEFRXCMD
  190. #define DEFRXCMD(name,param,results)            \
  191.     RX_TYPE name ( APTR, A_ARGS_ ## name APTR); \
  192.     RX_TYPE name ## A ( APTR, struct name ## _ARG *arg, APTR);
  193. #include "rx_commands.h"
  194.  
  195. //////////////////////////////////////////////////
  196. //        Header for each RX Command
  197. //    we create a stackargs function
  198. //    and a varargs function
  199. //////////////////////////////////////////////////
  200. #undef    ARG_SEP
  201. #define ARG_SEP ","
  202. #undef    DEFRXCMD
  203. #define DEFRXCMD(name,param,results)                    \
  204.     RX_TYPE name ( APTR lock, A_ARGS_ ## name APTR ud) {\
  205.     va_list arg;                    \
  206.     va_start (va, lock);                            \
  207.     return VCALL (name);                            \
  208.     va_end (arg);                                   \
  209.     }                            \
  210.     RX_TYPE name ## A ( APTR lock, struct name ## _ARG *arg, APTR ud )
  211.  
  212. //////////////////////////////////////////////////
  213. //  Call another command with the same Arguments
  214. //////////////////////////////////////////////////
  215. #define VCALL(name) name ## A (lock, (struct name ## _ARG *) arg, ud)
  216.  
  217. //////////////////////////////////////////////////
  218. // Make sure only One of the Args is used
  219. //////////////////////////////////////////////////
  220. #define ONLY_ONE() do{                                      \
  221.     int    num = 0;                     \
  222.     ULONG *ptr = (ULONG *)((ULONG)arg) + sizeof (arg*); \
  223.     do {                            \
  224.         if (*(--ptr)) ++ num;                           \
  225.     } while (ptr != (ULONG *)arg);                      \
  226.     if (num != 1)                                       \
  227.         return RX_ERROR;                    \
  228.     }while(0)
  229.  
  230. #endif
  231.  
  232.  
  233. #if 0
  234.  
  235. /* ---- support for (not yet supported) ARexx commands          */
  236. /*    this time we use the same mechanism like ARexxBox    */
  237. /*    ahhhh that's imho a waste of code                       */
  238. /*    the main differences to our code are that here a **parg */
  239. /*    is used and we are using a 3-parted function        */
  240. /*                                */
  241. /*    please note, that the same overhead is neccessary is in */
  242. /*    the previous way; i have omitted it here, since its not */
  243. /*    much more than codecopying                */
  244. /*                                */
  245. /*    **** this stuff is currently not used inside XDME ****    */
  246.  
  247.  
  248. #undef    DEFARBCMD
  249. #define DEFARBCMD(name,param,results)       \
  250.     void name ## A ( APTR lock, struct name ## _ARG **parg, ULONG action )
  251.  
  252. #define ARBINIT(name,block)                 \
  253.     {                        \
  254.     struct name ## _ARG *arg = *parg;   \
  255.     switch (action) {                   \
  256.     case INIT:                \
  257.         *parg = calloc(sizeof (*arg));  \
  258.         if (*parg) {                    \
  259.         arg = *parg;            \
  260.         block                \
  261.         }                    \
  262.         break;                \
  263.     case ACTION:
  264.  
  265. #define ARBEXIT(name,block)                 \
  266.         break;                \
  267.     case FREE:                \
  268.         block;                \
  269.         free (arg);                     \
  270.         break;                \
  271.     }                    \
  272.     }
  273.  
  274. #endif
  275.  
  276.  
  277. /* ---- we use SPC_VAR to shade out parts of the file that are only of */
  278. /*    interest to the VariableParser, and which would confuse the C  */
  279. /*    compiler ...                               */
  280. #undef SPC_VAR
  281.  
  282. #endif /* !DEFINITIONS_H */
  283.  
  284. /******************************************************************************
  285. *****  END Definitions.h
  286. ******************************************************************************/
  287.