home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / include / basetsd.h < prev    next >
C/C++ Source or Header  |  1998-05-05  |  3KB  |  174 lines

  1. /*++
  2.  
  3. Copyright (c) 1997-1998  Microsoft Corporation
  4.  
  5. Module Name:
  6.  
  7.     basetsd.h
  8.  
  9. Abstract:
  10.  
  11.     Type definitions for the basic sized types.
  12.  
  13. Author:
  14.  
  15.     Jeff Havens (jhavens)   23-Oct-1997
  16.  
  17. Revision History:
  18.  
  19. --*/
  20.  
  21. #ifndef _BASETSD_H_
  22. #define _BASETSD_H_
  23.  
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27.  
  28. //
  29. // The following types are guaranteed to be signed and 32 bits wide.
  30. //
  31.  
  32. typedef int LONG32, *PLONG32;
  33. typedef int INT32, *PINT32;
  34.  
  35. //
  36. // The following types are guaranteed to be unsigned and 32 bits wide.
  37. //
  38.  
  39. typedef unsigned int ULONG32, *PULONG32;
  40. typedef unsigned int DWORD32, *PDWORD32;
  41. typedef unsigned int UINT32, *PUINT32;
  42.  
  43. //
  44. // The INT_PTR is guaranteed to be the same size as a pointer.  Its
  45. // size with change with pointer size (32/64).  It should be used
  46. // anywhere that a pointer is cast to an integer type. UINT_PTR is
  47. // the unsigned variation.
  48. //
  49. // HALF_PTR is half the size of a pointer it intended for use with
  50. // within strcuture which contain a pointer and two small fields.
  51. // UHALF_PTR is the unsigned variation.
  52. //
  53.  
  54. #ifdef _WIN64
  55.  
  56. typedef __int64 INT_PTR, *PINT_PTR;
  57. typedef unsigned __int64 UINT_PTR, *PUINT_PTR;
  58.  
  59. #define MAXINT_PTR (0x7fffffffffffffffI64)
  60. #define MININT_PTR (0x8000000000000000I64)
  61. #define MAXUINT_PTR (0xffffffffffffffffUI64)
  62.  
  63. typedef unsigned int UHALF_PTR, *PUHALF_PTR;
  64. typedef int HALF_PTR, *PHALF_PTR;
  65.  
  66. #define MAXUHALF_PTR (0xffffffffUL)
  67. #define MAXHALF_PTR (0x7fffffffL)
  68. #define MINHALF_PTR (0x80000000L)
  69.  
  70. #pragma warning(disable:4311)   // type cast truncation
  71.  
  72. #if !defined(__midl)
  73. __inline
  74. unsigned long
  75. HandleToUlong(
  76.     void *h
  77.     )
  78. {
  79.     return((unsigned long) h );
  80. }
  81.  
  82. __inline
  83. unsigned long
  84. PtrToUlong(
  85.     void  *p
  86.     )
  87. {
  88.     return((unsigned long) p );
  89. }
  90.  
  91. __inline
  92. unsigned short
  93. PtrToUshort(
  94.     void  *p
  95.     )
  96. {
  97.     return((unsigned short) p );
  98. }
  99.  
  100. __inline
  101. long
  102. PtrToLong(
  103.     void  *p
  104.     )
  105. {
  106.     return((long) p );
  107. }
  108.  
  109. __inline
  110. short
  111. PtrToShort(
  112.     void  *p
  113.     )
  114. {
  115.     return((short) p );
  116. }
  117. #endif
  118. #pragma warning(3:4311)   // type cast truncation
  119.  
  120. #else
  121.  
  122.  
  123. typedef long INT_PTR, *PINT_PTR;
  124. typedef unsigned long UINT_PTR, *PUINT_PTR;
  125.  
  126. #define MAXINT_PTR (0x7fffffffL)
  127. #define MININT_PTR (0x80000000L)
  128. #define MAXUINT_PTR (0xffffffffUL)
  129.  
  130. typedef unsigned short UHALF_PTR, *PUHALF_PTR;
  131. typedef short HALF_PTR, *PHALF_PTR;
  132.  
  133. #define MAXUHALF_PTR 0xffff
  134. #define MAXHALF_PTR 0x7fff
  135. #define MINHALF_PTR 0x8000
  136.  
  137. #define HandleToUlong( h ) ((ULONG) (h) )
  138. #define PtrToUlong( p ) ((ULONG) (p) )
  139. #define PtrToLong( p ) ((LONG) (p) )
  140. #define PtrToUshort( p ) ((unsigned short) (p) )
  141. #define PtrToShort( p ) ((short) (p) )
  142.  
  143. #endif
  144.  
  145. //
  146. // SIZE_T used for counts or ranges which need to span the range of
  147. // of a pointer.  SSIZE_T is the signed variation.
  148. //
  149.  
  150. typedef UINT_PTR SIZE_T, *PSIZE_T;
  151. typedef INT_PTR SSIZE_T, *PSSIZE_T;
  152.  
  153. //
  154. // The following types are guaranteed to be signed and 64 bits wide.
  155. //
  156.  
  157. typedef __int64 LONG64, *PLONG64;
  158. typedef __int64 INT64, *PINT64;
  159.  
  160.  
  161. //
  162. // The following types are guaranteed to be unsigned and 64 bits wide.
  163. //
  164.  
  165. typedef unsigned __int64 ULONG64, *PULONG64;
  166. typedef unsigned __int64 DWORD64, *PDWORD64;
  167. typedef unsigned __int64 UINT64, *PUINT64;
  168.  
  169. #ifdef __cplusplus
  170. }
  171. #endif
  172.  
  173. #endif // _BASETSD_H_
  174.