basetsd.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /**
  2. * This file has no copyright assigned and is placed in the Public Domain.
  3. * This file is part of the w64 mingw-runtime package.
  4. * No warranty is given; refer to the file DISCLAIMER within this package.
  5. */
  6. #ifndef _BASETSD_H_
  7. #define _BASETSD_H_
  8. #if (defined(__x86_64) || defined(__ia64__)) && !defined(RC_INVOKED)
  9. typedef unsigned __int64 POINTER_64_INT;
  10. #else
  11. typedef unsigned long POINTER_64_INT;
  12. #endif
  13. #define POINTER_32
  14. #define POINTER_64
  15. #define FIRMWARE_PTR
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19. typedef signed char INT8,*PINT8;
  20. typedef signed short INT16,*PINT16;
  21. typedef signed int INT32,*PINT32;
  22. typedef signed __int64 INT64,*PINT64;
  23. typedef unsigned char UINT8,*PUINT8;
  24. typedef unsigned short UINT16,*PUINT16;
  25. typedef unsigned int UINT32,*PUINT32;
  26. typedef unsigned __int64 UINT64,*PUINT64;
  27. typedef signed int LONG32,*PLONG32;
  28. typedef unsigned int ULONG32,*PULONG32;
  29. typedef unsigned int DWORD32,*PDWORD32;
  30. #ifndef _W64
  31. #define _W64
  32. #endif
  33. #ifdef _WIN64
  34. typedef __int64 INT_PTR,*PINT_PTR;
  35. typedef unsigned __int64 UINT_PTR,*PUINT_PTR;
  36. typedef __int64 LONG_PTR,*PLONG_PTR;
  37. typedef unsigned __int64 ULONG_PTR,*PULONG_PTR;
  38. #define __int3264 __int64
  39. #else
  40. typedef int INT_PTR,*PINT_PTR;
  41. typedef unsigned int UINT_PTR,*PUINT_PTR;
  42. typedef long LONG_PTR,*PLONG_PTR;
  43. typedef unsigned long ULONG_PTR,*PULONG_PTR;
  44. #define __int3264 __int32
  45. #endif
  46. #ifdef _WIN64
  47. #define ADDRESS_TAG_BIT 0x40000000000ULL
  48. typedef __int64 SHANDLE_PTR;
  49. typedef unsigned __int64 HANDLE_PTR;
  50. typedef unsigned int UHALF_PTR,*PUHALF_PTR;
  51. typedef int HALF_PTR,*PHALF_PTR;
  52. static __inline unsigned long HandleToULong(const void *h) { return((unsigned long) (ULONG_PTR) h); }
  53. static __inline long HandleToLong(const void *h) { return((long) (LONG_PTR) h); }
  54. static __inline void *ULongToHandle(const unsigned long h) { return((void *) (UINT_PTR) h); }
  55. static __inline void *LongToHandle(const long h) { return((void *) (INT_PTR) h); }
  56. static __inline unsigned long PtrToUlong(const void *p) { return((unsigned long) (ULONG_PTR) p); }
  57. static __inline unsigned int PtrToUint(const void *p) { return((unsigned int) (UINT_PTR) p); }
  58. static __inline unsigned short PtrToUshort(const void *p) { return((unsigned short) (unsigned long) (ULONG_PTR) p); }
  59. static __inline long PtrToLong(const void *p) { return((long) (LONG_PTR) p); }
  60. static __inline int PtrToInt(const void *p) { return((int) (INT_PTR) p); }
  61. static __inline short PtrToShort(const void *p) { return((short) (long) (LONG_PTR) p); }
  62. static __inline void *IntToPtr(const int i) { return((void *)(INT_PTR)i); }
  63. static __inline void *UIntToPtr(const unsigned int ui) { return((void *)(UINT_PTR)ui); }
  64. static __inline void *LongToPtr(const long l) { return((void *)(LONG_PTR)l); }
  65. static __inline void *ULongToPtr(const unsigned long ul) { return((void *)(ULONG_PTR)ul); }
  66. #define PtrToPtr64(p) ((void *) p)
  67. #define Ptr64ToPtr(p) ((void *) p)
  68. #define HandleToHandle64(h) (PtrToPtr64(h))
  69. #define Handle64ToHandle(h) (Ptr64ToPtr(h))
  70. static __inline void *Ptr32ToPtr(const void *p) { return (void *)p; }
  71. static __inline void *Handle32ToHandle(const void *h) { return((void *) h); }
  72. static __inline void *PtrToPtr32(const void *p) { return((void *) (ULONG_PTR) p); }
  73. #define HandleToHandle32(h) (PtrToPtr32(h))
  74. #else
  75. #define ADDRESS_TAG_BIT 0x80000000UL
  76. typedef unsigned short UHALF_PTR,*PUHALF_PTR;
  77. typedef short HALF_PTR,*PHALF_PTR;
  78. typedef long SHANDLE_PTR;
  79. typedef unsigned long HANDLE_PTR;
  80. #define HandleToULong(h) ((ULONG)(ULONG_PTR)(h))
  81. #define HandleToLong(h) ((LONG)(LONG_PTR) (h))
  82. #define ULongToHandle(ul) ((HANDLE)(ULONG_PTR) (ul))
  83. #define LongToHandle(h) ((HANDLE)(LONG_PTR) (h))
  84. #define PtrToUlong(p) ((ULONG)(ULONG_PTR) (p))
  85. #define PtrToLong(p) ((LONG)(LONG_PTR) (p))
  86. #define PtrToUint(p) ((UINT)(UINT_PTR) (p))
  87. #define PtrToInt(p) ((INT)(INT_PTR) (p))
  88. #define PtrToUshort(p) ((unsigned short)(ULONG_PTR)(p))
  89. #define PtrToShort(p) ((short)(LONG_PTR)(p))
  90. #define IntToPtr(i) ((VOID *)(INT_PTR)((int)i))
  91. #define UIntToPtr(ui) ((VOID *)(UINT_PTR)((unsigned int)ui))
  92. #define LongToPtr(l) ((VOID *)(LONG_PTR)((long)l))
  93. #define ULongToPtr(ul) ((VOID *)(ULONG_PTR)((unsigned long)ul))
  94. static __inline void *PtrToPtr64(const void *p) { return((void *) (ULONG_PTR)p); }
  95. static __inline void *Ptr64ToPtr(const void *p) { return((void *) (ULONG_PTR) p); }
  96. static __inline void *HandleToHandle64(const void *h) { return((void *) h); }
  97. static __inline void *Handle64ToHandle(const void *h) { return((void *) (ULONG_PTR) h); }
  98. #define Ptr32ToPtr(p) ((void *) p)
  99. #define Handle32ToHandle(h) (Ptr32ToPtr(h))
  100. #define PtrToPtr32(p) ((void *) p)
  101. #define HandleToHandle32(h) (PtrToPtr32(h))
  102. #endif
  103. #define HandleToUlong(h) HandleToULong(h)
  104. #define UlongToHandle(ul) ULongToHandle(ul)
  105. #define UlongToPtr(ul) ULongToPtr(ul)
  106. #define UintToPtr(ui) UIntToPtr(ui)
  107. #define MAXUINT_PTR (~((UINT_PTR)0))
  108. #define MAXINT_PTR ((INT_PTR)(MAXUINT_PTR >> 1))
  109. #define MININT_PTR (~MAXINT_PTR)
  110. #define MAXULONG_PTR (~((ULONG_PTR)0))
  111. #define MAXLONG_PTR ((LONG_PTR)(MAXULONG_PTR >> 1))
  112. #define MINLONG_PTR (~MAXLONG_PTR)
  113. #define MAXUHALF_PTR ((UHALF_PTR)~0)
  114. #define MAXHALF_PTR ((HALF_PTR)(MAXUHALF_PTR >> 1))
  115. #define MINHALF_PTR (~MAXHALF_PTR)
  116. typedef ULONG_PTR SIZE_T,*PSIZE_T;
  117. typedef LONG_PTR SSIZE_T,*PSSIZE_T;
  118. typedef ULONG_PTR DWORD_PTR,*PDWORD_PTR;
  119. typedef __int64 LONG64,*PLONG64;
  120. typedef unsigned __int64 ULONG64,*PULONG64;
  121. typedef unsigned __int64 DWORD64,*PDWORD64;
  122. typedef ULONG_PTR KAFFINITY;
  123. typedef KAFFINITY *PKAFFINITY;
  124. #ifdef __cplusplus
  125. }
  126. #endif
  127. #endif