Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

322 lines
9.6 KiB

  1. /*************************************************************************
  2. * *
  3. * MVOPSYS.H *
  4. * *
  5. * Copyright (C) Microsoft Corporation 1990-1994 *
  6. * All Rights reserved. *
  7. * *
  8. **************************************************************************
  9. * *
  10. * Module Intent *
  11. * Include platform dependent include files *
  12. * *
  13. **************************************************************************
  14. * *
  15. * Current Owner: BinhN *
  16. * *
  17. *************************************************************************/
  18. #ifndef __MVOPSYS_H_
  19. #define __MVOPSYS_H_
  20. /* There is C and C++ code, use these defines for interfaces between the 2 */
  21. #if defined( __cplusplus ) // {
  22. #define EXTC extern "C"
  23. #define EXTCSTART EXTC {
  24. #define EXTCEND }
  25. #else // } {
  26. #define EXTC
  27. #define EXTCSTART
  28. #define EXTCEND
  29. #endif // }
  30. #include <windows.h>
  31. #include <windowsx.h>
  32. #include <string.h>
  33. #if defined(DBG) && !defined(_DEBUG)
  34. #define _DEBUG
  35. #endif
  36. #if defined(_WIN32) && !defined(_32BIT)
  37. #define _32BIT
  38. #endif
  39. #ifdef _32BIT // {
  40. #include <wincon.h>
  41. /*****************************************************
  42. * 32-BIT SPECIFIC DEFINITIONS
  43. *
  44. * All 32-bit platforms related definitions should be
  45. * placed here, eg. _MAC, _NT, etc
  46. *****************************************************/
  47. /* Some _32BIT specific bits & pieces */
  48. #define _loadds
  49. #define __loadds
  50. #define far
  51. #define _far
  52. #define huge
  53. #define _huge
  54. #define _export
  55. #define __export
  56. #define EXPORT_API
  57. #define PRIVATE
  58. // These old macros are still used in some places.
  59. #define WRITE OF_WRITE
  60. #define READ OF_READ
  61. // Define PAGE_SIZE (this is processor dependent)
  62. #if defined(ALPHA) || defined(IA64)
  63. #define PAGE_SIZE 8192
  64. #else
  65. #define PAGE_SIZE 4096
  66. #endif
  67. /**************************************************
  68. * FUNCTIONS SPECIFIC TO 32-BIT ONLY
  69. **************************************************/
  70. #ifdef _MAC
  71. #define LOCKSEMAPHORE(pl) ((*(pl)==0) ? (*(pl)=1,0) : 1)
  72. #define UNLOCKSEMAPHORE(pl) (*(pl)=0)
  73. #else
  74. #define LOCKSEMAPHORE(pl) InterlockedExchange((pl),1)
  75. #define UNLOCKSEMAPHORE(pl) InterlockedExchange((pl),0)
  76. #endif
  77. /* GetProfileString */
  78. #define GETPROFILESTRING(a,b,c,d,e)
  79. /* MakeProcInstance is not needed for Win32 */
  80. #define MAKEPROCINSTANCE(a,b) a
  81. #define FREEPROCINSTANCE(a)
  82. /* DLL currently not supported */
  83. #define FREELIBRARY(a)
  84. /* Function calls changes between 16 and 32 bit */
  85. #define SETVIEWPORTORG(a,b,c) SetViewportOrgEx(a,b,c,NULL)
  86. #define SETVIEWPORTEXT(a,b,c) SetViewportExtEx(a,b,c,NULL)
  87. #define SETWINDOWEXT(a,b,c) SetWindowExtEx(a,b,c,NULL)
  88. #define SETWINDOWORG(a,b,c) SetWindowOrgEx(a,b,c,NULL)
  89. #define MOVETO(a,b,c) MoveToEx(a,b,c,NULL)
  90. #define SETBRUSHORG(a,b,c) SetBrushOrgEx(a,b,c,NULL)
  91. #define ENUMFONTFAMILIES(a,b,c,d) EnumFontFamilies(a,b,c,(LPARAM)d)
  92. #define GETCWD( addr, len ) (GetCurrentDirectory( len, addr ) ? addr : NULL)
  93. #define MAKEPOINT(l) { (LONG)(WORD)(l) , (LONG)(WORD)(l >> 16)}
  94. // Can't have NULL as path... must be a string
  95. #define GETTEMPFILENAME GetTempFileNameEx
  96. WORD EXPORT_API PASCAL FAR GetTempFileNameEx(
  97. LPCSTR lpszPath, /* address of name of dir. where temp. file is created */
  98. LPCSTR lpszPrefix, /* address of prefix of temp. filename */
  99. WORD uUnique, /* number used to create temp. filename */
  100. LPSTR lpszTempFile) ; /* address buffer that will receive temp. filename */
  101. #define MEMCPY memmove
  102. #define MEMSET memset
  103. #define MEMCMP memcmp
  104. #define FREE free
  105. #define MALLOC malloc
  106. #define REALLOC realloc
  107. #define MEMMOVE memmove
  108. #define QVCOPY memmove
  109. #define VSNPRINTF _vsnprintf
  110. #define SPRINTF wsprintf
  111. #define ITOA _itoa
  112. #define ATOI atoi
  113. #define ATOL atol
  114. #define ISDIGIT isdigit
  115. #define ISXDIGIT isxdigit
  116. #define QvCopy memmove
  117. #define STRLEN strlen
  118. #define STRCPY lstrcpy
  119. #define STRDUP _strdup
  120. #define STRCHR strchr
  121. #define STRCAT lstrcat
  122. #define STRTOK strtok
  123. #define STRUPR _strupr
  124. #define STRCMP lstrcmp
  125. #define STRICMP lstrcmpi
  126. #define STRNICMP _strnicmp
  127. #define STRNCPY lstrcpyn
  128. #define STRNCAT strncat
  129. // Define some new macros
  130. // I'm afraid of just defining the ones
  131. // above to the appropriate UNICODE versions
  132. // since the B-tree code (for example) is not
  133. // yet UNICODE
  134. #define WSTRLEN wcslen
  135. #define WSTRCPY wcscpy
  136. #define WSTRDUP _wcsdup
  137. #define WSTRCHR wcschr
  138. #define WSTRCAT wcscat
  139. #define WSTRTOK wcstok
  140. #define WSTRUPR _wcsupr
  141. #define WSTRCMP wcscmp
  142. #define WSTRICMP _it_wcsicmp
  143. #define WSTRNICMP _wcsnicmp
  144. #define WSTRNCPY wcsncpy
  145. #define WSTRNCAT wcsncat
  146. #define WTOI _wtoi
  147. #define WTOL _wtol
  148. #define GETINSTANCE(h) ((HINSTANCE)GetWindowLong(h,GWL_HINSTANCE))
  149. /***********************************************
  150. * MAC SPECIFIC DEFINITIONS & DECLARATIONS
  151. ***********************************************/
  152. #ifdef _MAC // {
  153. /* Currently, Pascal convention is inefficient on the MAC, becuase:
  154. * - Returned value are passed back on the stack instead of using register
  155. * - For earlier CPU (<68910), the return code is less efficient
  156. * movel (a7)+, a0
  157. * adda.w #cbParams, a7
  158. * jmp (a0)
  159. */
  160. //#undef PASCAL
  161. //#define PASCAL
  162. #endif // }
  163. #ifdef _BIG_E // BigEndian {
  164. /* The below defines are needed to handle difference in architectures between
  165. * Motorola's 68K and Intel's x86 memory mappings
  166. */
  167. #ifdef __cplusplus
  168. extern "C"
  169. {
  170. WORD PASCAL FAR SwapWord (WORD);
  171. DWORD PASCAL FAR SwapLong (DWORD);
  172. WORD PASCAL FAR GetMacWord (BYTE FAR *);
  173. VOID PASCAL FAR SetMacWord (BYTE FAR *, WORD);
  174. DWORD PASCAL FAR GetMacLong (BYTE FAR *);
  175. VOID PASCAL FAR SetMacLong (BYTE FAR *, DWORD);
  176. };
  177. #endif
  178. #define GETWORD(p) GetMacWord((BYTE FAR *)(p))
  179. #define SETWORD(p,w) SetMacWord((BYTE FAR *)(p),(w))
  180. #define SWAPWORD(p) SwapWord((p))
  181. #define GETLONG(p) GetMacLong((BYTE FAR *)(p))
  182. #define SETLONG(p,l) SetMacLong((BYTE FAR *)(p),(l))
  183. #define SWAPLONG(p) SwapLong((p))
  184. #define GETVA(p) GetMacVA((p))
  185. #define SWAPVA(p) GetMacVA((p))
  186. #define GETMBHD(p,q) GetMacMBHD((p),(q))
  187. #define GETMFCP(p,q) GetMacMFCP((p),(q))
  188. #define HI_BYTE 1
  189. #define LO_BYTE 0
  190. #else // regular 32 bit }{
  191. #define GETWORD(p) (*((USHORT UNALIGNED FAR *)(p)))
  192. #define SETWORD(a, b) (*((USHORT UNALIGNED FAR *)(a))=(b))
  193. #define GETLONG(p) (*((DWORD UNALIGNED FAR *)(p)))
  194. #define SETLONG(p,l) ((*((DWORD UNALIGNED FAR *)(p))) = (l))
  195. #define SWAPWORD(p) ((p))
  196. #define SWAPLONG(p) ((p))
  197. #define GETVA(p) ((p))
  198. #define SWAPVA(p) ((p))
  199. #define GETMBHD(p,q) QvCopy((p),(q), sizeof(MBHD))
  200. #define GETMFCP(p,q) QvCopy((p),(q), sizeof(MFCP))
  201. #define HI_BYTE 0
  202. #define LO_BYTE 1
  203. #endif // _BIG_E}
  204. /*********************************************************************
  205. * Typecast to get rid of the unalignment problems on the RISC
  206. *********************************************************************/
  207. typedef USHORT UNALIGNED FAR * LPUW;
  208. typedef DWORD UNALIGNED FAR * LPUL;
  209. #else
  210. /***************************************************
  211. * 16-BITS DEFINITIONS & DECLARATIONS
  212. ***************************************************/
  213. #define EXPORT_API _export
  214. #define UNALIGNED
  215. #define GETWORD(p) (*((USHORT FAR UNALIGNED *)(p)))
  216. #define SWAPWORD(p) (p)
  217. #define GETLONG(p) (*((DWORD FAR UNALIGNED *)(p)))
  218. #define SETLONG(p,l) ((*((DWORD FAR UNALIGNED *)(p))) = l)
  219. #define SWAPLONG(p) (p)
  220. #define GETVA(p) (p)
  221. #define SWAPVA(p) (p)
  222. #define GETMBHD(p,q) QvCopy((p),(q), sizeof(MBHD))
  223. #define GETMFCP(p,q) QvCopy((p),(q), sizeof(MFCP))
  224. #define HI_BYTE 0
  225. #define LO_BYTE 1
  226. #define LOCKSEMAPHORE(pl) ((*(pl)==0) ? (*(pl)=1,0) : 1)
  227. #define UNLOCKSEMAPHORE(pl) (*(pl)=0)
  228. /* GetProfileString */
  229. #define GETPROFILESTRING(a,b,c,d,e) GetProfileString(a,b,c,d,e)
  230. /* DLL currently not supported */
  231. #define FREELIBRARY(a) FreeLibrary(a)
  232. /* Viewport calls */
  233. #define SETVIEWPORTORG(a,b,c) SetViewportOrg(a,b,c)
  234. #define SETVIEWPORTEXT(a,b,c) SetViewportExt(a,b,c)
  235. #define SETWINDOWEXT(a,b,c) SetWindowExt(a,b,c)
  236. #define SETWINDOWORG(a,b,c) SetWindowOrg(a,b,c)
  237. #define MOVETO(a,b,c) MoveTo(a,b,c)
  238. #define SETBRUSHORG(a,b,c) SetBrushOrg(a,b,c)
  239. #define ENUMFONTFAMILIES(a,b,c,d) EnumFontFamilies(a,b,c,(LPSTR)d)
  240. #define GETCWD( addr, len ) getcwd( addr, len )
  241. #define MEMCPY _fmemmove
  242. #define MEMSET _fmemset
  243. #define MEMCMP _fmemcmp
  244. #define STRLEN _fstrlen
  245. #define STRCPY _fstrcpy
  246. #define STRDUP _fstrdup
  247. #define STRCHR _fstrchr
  248. #define STRCAT _fstrcat
  249. #define STRTOK _fstrtok
  250. #define STRUPR _fstrupr
  251. #define STRCMP _fstrcmp
  252. #define STRICMP _fstricmp
  253. #define STRNICMP _fstrnicmp
  254. #define FREE _ffree
  255. #define MALLOC _fmalloc
  256. #define REALLOC _frealloc
  257. #define STRNCPY _fstrncpy
  258. #define MEMMOVE _fmemmove
  259. #define QVCOPY _fmemmove
  260. #define VSNPRINTF _vsnprintf
  261. #define STRNCAT _fstrncat
  262. #define SPRINTF wsprintf
  263. #define ITOA itoa
  264. #define MAKEPROCINSTANCE(a,b) MakeProcInstance(a,b)
  265. #define FREEPROCINSTANCE(a) FreeProcInstance(a)
  266. #define GETTEMPFILENAME GetTempFileName
  267. #define GETINSTANCE(h) ((HINSTANCE)GetWindowWord(h,GWW_HINSTANCE))
  268. #endif // } _32BIT
  269. #endif // __MVOPSYS_H_