Leaked source code of windows server 2003
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.

113 lines
2.6 KiB

  1. /***************************************************************************
  2. *
  3. * Copyright (C) 2000-2000 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: runtime.h
  6. * Content: New versions of C runtime functions.
  7. * History:
  8. * Date By Reason
  9. * ==== == ======
  10. * 05/16/2000 jstokes Created
  11. *
  12. ***************************************************************************/
  13. #ifndef __RUNTIME_H__
  14. #define __RUNTIME_H__
  15. // We have BYTE, WORD and DWORD, but no QWORD?
  16. typedef unsigned __int64 QWORD, *LPQWORD;
  17. // Bounderies of numeric types
  18. #define MAX_CHAR ((CHAR)0x7F)
  19. #define MIN_CHAR ((CHAR)-0x7F)
  20. #define MAX_UCHAR ((UCHAR)0xFF)
  21. #define MIN_UCHAR ((UCHAR)0)
  22. #define MAX_SHORT ((SHORT)0x7FFF)
  23. #define MIN_SHORT ((SHORT)-0x7FFF)
  24. #define MAX_USHORT ((USHORT)0xFFFF)
  25. #define MIN_USHORT ((USHORT)0)
  26. #define MAX_INT ((INT)0x7FFFFFFF)
  27. #define MIN_INT ((INT)-0x7FFFFFFF)
  28. #define MAX_UINT ((UINT)0xFFFFFFFF)
  29. #define MIN_UINT ((UINT)0)
  30. #define MAX_LONG MAX_INT
  31. #define MIN_LONG MIN_INT
  32. #define MAX_ULONG MAX_UINT
  33. #define MIN_ULONG MIN_UINT
  34. #define MAX_INT64 ((INT64)0x7FFFFFFFFFFFFFFF)
  35. #define MIN_INT64 ((INT64)-0x7FFFFFFFFFFFFFFF)
  36. #define MAX_UINT64 ((UINT64)0xFFFFFFFFFFFFFFFF)
  37. #define MIN_UINT64 ((UINT64)0)
  38. #define MAX_LONGLONG MAX_INT64
  39. #define MIN_LONGLONG MIN_INT64
  40. #define MAX_ULONGLONG MAX_UINT64
  41. #define MIN_ULONGLONG MIN_UINT64
  42. #define MAX_BYTE MAX_UCHAR
  43. #define MIN_BYTE MIN_UCHAR
  44. #define MAX_WORD MAX_USHORT
  45. #define MIN_WORD MIN_USHORT
  46. #define MAX_DWORD MAX_ULONG
  47. #define MIN_DWORD MIN_ULONG
  48. #define MAX_QWORD MAX_UINT64
  49. #define MIN_QWORD MIN_UINT64
  50. #define NUMERIC_CAST(val, type) \
  51. ((type)min(MAX_##type, max(MIN_##type, val)))
  52. // Sundown
  53. #ifdef WIN64
  54. #pragma warning(disable:4311) // type cast truncation
  55. #ifndef __midl
  56. __inline unsigned long PtrDiffToUlong(__int64 n64)
  57. {
  58. return((unsigned long)n64);
  59. }
  60. __inline long PtrDiffToLong(__int64 n64)
  61. {
  62. return((long)n64);
  63. }
  64. __inline int PtrDiffToInt(__int64 n64)
  65. {
  66. return((int)n64);
  67. }
  68. #endif // __midl
  69. #pragma warning(3:4311) // type cast truncation
  70. #else // WIN64
  71. #define PtrDiffToUlong(n64) \
  72. ((unsigned long)(n64))
  73. #define PtrDiffToLong(n64) \
  74. ((long)(n64))
  75. #define PtrDiffToInt(n64) \
  76. ((int)(n64))
  77. #endif // WIN64
  78. #endif // __RUNTIME_H__