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.

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