rartypes.hpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #ifndef _RAR_TYPES_
  2. #define _RAR_TYPES_
  3. typedef unsigned char byte; // unsigned 8 bits
  4. typedef unsigned short ushort; // preferably 16 bits, but can be more
  5. typedef unsigned int uint; // 32 bits or more
  6. #define PRESENT_INT32 // undefine if signed 32 bits is not available
  7. typedef unsigned int uint32; // 32 bits exactly
  8. typedef signed int int32; // signed 32 bits exactly
  9. // If compiler does not support 64 bit variables, we can define
  10. // uint64 and int64 as 32 bit, but it will limit the maximum processed
  11. // file size to 2 GB.
  12. #if defined(__BORLANDC__) || defined(_MSC_VER)
  13. typedef unsigned __int64 uint64; // unsigned 64 bits
  14. typedef signed __int64 int64; // signed 64 bits
  15. #else
  16. typedef unsigned long long uint64; // unsigned 64 bits
  17. typedef signed long long int64; // signed 64 bits
  18. #endif
  19. #if defined(_WIN_ALL) || defined(__GNUC__) || defined(__sgi) || defined(_AIX) || defined(__sun) || defined(__hpux) || defined(_OSF_SOURCE)
  20. typedef wchar_t wchar;
  21. #else
  22. typedef ushort wchar;
  23. #endif
  24. // Get lowest 16 bits.
  25. #define SHORT16(x) (sizeof(ushort)==2 ? (ushort)(x):((x)&0xffff))
  26. // Get lowest 32 bits.
  27. #define UINT32(x) (sizeof(uint32)==4 ? (uint32)(x):((x)&0xffffffff))
  28. // Make 64 bit integer from two 32 bit.
  29. #define INT32TO64(high,low) ((((uint64)(high))<<32)+((uint64)low))
  30. // Special int64 value, large enough to never be found in real life.
  31. // We use it in situations, when we need to indicate that parameter
  32. // is not defined and probably should be calculated inside of function.
  33. // Lower part is intentionally 0x7fffffff, not 0xffffffff, to make it
  34. // compatible with 32 bit int64.
  35. #define INT64NDF INT32TO64(0x7fffffff,0x7fffffff)
  36. #endif