home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 40 / IOPROG_40.ISO / SOFT / NETFrameworkSDK.exe / comsdk.cab / samples1.exe / smc / smc.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-23  |  4.8 KB  |  193 lines

  1. /*****************************************************************************/
  2. #ifndef _SMC_H_
  3. #define _SMC_H_
  4. /*****************************************************************************/
  5.  
  6. /*****************************************************************************/
  7. #include "macros.h"
  8. /*****************************************************************************/
  9.  
  10. #if     FAST
  11. #ifndef __SMC__
  12. #define COUNT_CYCLES    1
  13. #endif
  14. #endif
  15.  
  16. #if     COUNT_CYCLES
  17. extern  unsigned        cycleExtra;
  18. extern  void            cycleCounterInit  ();
  19. extern  void            cycleCounterBeg   ();
  20. extern  void            cycleCounterPause ();
  21. extern  void            cycleCounterResume();
  22. extern  void            cycleCounterEnd   ();
  23. extern  __int64         GetCycleCount64   ();
  24. extern  unsigned        GetCycleCount32   ();
  25. #else
  26. inline  void            cycleCounterInit  (){}
  27. inline  void            cycleCounterBeg   (){}
  28. inline  void            cycleCounterPause (){}
  29. inline  void            cycleCounterResume(){}
  30. inline  void            cycleCounterEnd   (){}
  31. #endif
  32.  
  33. /*****************************************************************************/
  34. #ifndef __SMC__
  35. #define UNION(tag)  union
  36. #define CASE(tval)
  37. #define DEFCASE
  38. #endif
  39. /*****************************************************************************/
  40. #ifdef  __SMC__
  41. unmanaged   class   IMetaDataDispenser      {}
  42. unmanaged   class   IMetaDataImport         {}
  43. unmanaged   class   IMetaDataEmit           {}
  44. unmanaged   class   IMetaDataAssemblyImport {}
  45. unmanaged   class   IMetaDataAssemblyEmit   {}
  46. unmanaged   class   IMetaDataDebugEmit      {}
  47. #endif
  48. /*****************************************************************************/
  49.  
  50. #ifndef _HOST_H_
  51. #include "host.h"
  52. #endif
  53.  
  54. /*****************************************************************************/
  55.  
  56. inline
  57. size_t              roundUp(size_t size, size_t mult = sizeof(int))
  58. {
  59.     // UNDONE: Check that 'mult' is a power of 2
  60.  
  61.     return  (size + (mult - 1)) & ~(mult - 1);
  62. }
  63.  
  64. /*****************************************************************************/
  65.  
  66. #ifndef _TYPEDEFS_H_
  67. #include "typedefs.h"
  68. #endif
  69.  
  70. #ifndef _VARTYPE_H_
  71. #include "vartype.h"
  72. #endif
  73.  
  74. /*****************************************************************************/
  75.  
  76. #ifndef _HASH_H_
  77. #include "hash.h"
  78. #endif
  79.  
  80. #ifndef _ERRROR_H_
  81. #include "error.h"
  82. #endif
  83.  
  84. #ifndef _CONFIG_H_
  85. #include "config.h"
  86. #endif
  87.  
  88. #ifndef _PARSER_H_
  89. #include "parser.h"
  90. #endif
  91.  
  92. #ifndef _SYMBOL_H_
  93. #include "symbol.h"
  94. #endif
  95.  
  96. /*****************************************************************************
  97.  *
  98.  *  Data structures and helpers used to manipulate memory buffers and such.
  99.  */
  100.  
  101. /*****************************************************************************/
  102. #if MGDDATA
  103. /*****************************************************************************/
  104.  
  105. inline
  106. genericBuff         makeGenBuff(const void *addr, size_t size)
  107. {
  108.     UNIMPL(!"");
  109.     return  null;
  110. }
  111.  
  112. inline
  113. stringBuff          makeStrBuff(const char *str)
  114. {
  115.     UNIMPL(!"");
  116.     return  null;
  117. }
  118.  
  119. /*****************************************************************************/
  120.  
  121. inline
  122. memBuffPtr          memBuffMkNull()
  123. {
  124.     memBuffPtr n; n.buffBase = NULL; return n;
  125. }
  126.  
  127. inline
  128. bool                memBuffIsNull(memBuffPtr buff)
  129. {
  130.     return (buff.buffBase == NULL);
  131. }
  132.  
  133. inline
  134. void                memBuffCopy(INOUT memBuffPtr REF buff, genericBuff  dptr,
  135.                                                            size_t       dlen)
  136. {
  137.     UNIMPL(!"copy array data");
  138. }
  139.  
  140. inline
  141. void                memBuffMove(INOUT memBuffPtr REF buff, size_t       dlen)
  142. {
  143.     buff.buffOffs += dlen;
  144. }
  145.  
  146. /*****************************************************************************/
  147. #else //MGDDATA
  148. /*****************************************************************************/
  149.  
  150. inline
  151. genericBuff         makeGenBuff(const void *addr, size_t size)
  152. {
  153.     return (BYTE*)addr;
  154. }
  155.  
  156. inline
  157. stringBuff          makeStrBuff(const char *str)
  158. {
  159.     return  (stringBuff)str;
  160. }
  161.  
  162. inline
  163. memBuffPtr          memBuffMkNull()
  164. {
  165.     return NULL;
  166. }
  167.  
  168. inline
  169. bool                memBuffIsNull(memBuffPtr buff)
  170. {
  171.     return !buff;
  172. }
  173.  
  174. inline
  175. void                memBuffCopy(INOUT memBuffPtr REF buff, genericBuff  dptr,
  176.                                                            size_t       dlen)
  177. {
  178.     memcpy(buff, dptr, dlen);
  179.            buff   +=   dlen;
  180. }
  181.  
  182. inline
  183. void                memBuffMove(INOUT memBuffPtr REF buff, size_t       dlen)
  184. {
  185.     buff += dlen;
  186. }
  187.  
  188. /*****************************************************************************/
  189. #endif//MGDDATA
  190. /*****************************************************************************/
  191. #endif
  192. /*****************************************************************************/
  193.