Subversion Repositories pentevo

Rev

Rev 796 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1.  
  2. #ifndef __SYSDEFS_H_INCLUDED
  3. #define __SYSDEFS_H_INCLUDED
  4.  
  5. #define inline __inline
  6. #define forceinline __forceinline
  7. #define fastcall __fastcall             // parameters in registers
  8.  
  9. typedef unsigned long long uint64_t;
  10.  
  11. typedef uint64_t QWORD;
  12.  
  13. typedef unsigned long long u64;
  14. typedef long long i64;
  15. typedef unsigned long u32;
  16. typedef unsigned short u16;
  17. typedef signed  short i16;
  18. typedef signed char i8;
  19. typedef unsigned char u8;
  20.  
  21. #ifdef _MSC_VER
  22. #define ATTR_ALIGN(x) __declspec(align(x))
  23. #define strtoull _strtoui64
  24. #endif
  25.  
  26. #ifdef __ICL
  27. #pragma warning(disable : 2259)
  28. #endif
  29.  
  30. #if __ICL >= 1000 || defined(__GNUC__)
  31. static inline u8 rol8(u8 val, u8 shift)
  32. {
  33.     __asm__ volatile ("rolb %1,%0" : "=r"(val) : "cI"(shift), "0"(val));
  34.     return val;
  35. }
  36.  
  37. static inline u8 ror8(u8 val, u8 shift)
  38. {
  39.     __asm__ volatile ("rorb %1,%0" : "=r"(val) : "cI"(shift), "0"(val));
  40.     return val;
  41. }
  42. static inline void asm_pause() { __asm__("pause"); }
  43. #else
  44. extern "C" unsigned char __cdecl _rotr8(unsigned char value, unsigned char shift);
  45. extern "C" unsigned char __cdecl _rotl8(unsigned char value, unsigned char shift);
  46. #pragma intrinsic(_rotr8)
  47. #pragma intrinsic(_rotl8)
  48. static inline u8 rol8(u8 val, u8 shift) { return _rotl8(val, shift); }
  49. static inline u8 ror8(u8 val, u8 shift) { return _rotr8(val, shift); }
  50. extern "C" void __cdecl _mm_pause();
  51. #pragma intrinsic(_mm_pause)
  52. static inline void asm_pause() { _mm_pause();/* __asm {rep nop}*/ }
  53. #endif
  54.  
  55. #if defined(_MSC_VER) && _MSC_VER < 1300
  56. static inline u16 _byteswap_ushort(u16 i){return (i>>8)|(i<<8);}
  57. static inline u32 _byteswap_ulong(u32 i){return _byteswap_ushort((u16)(i>>16))|(_byteswap_ushort((u16)i)<<16);};
  58. #endif
  59.  
  60. #ifdef __GNUC__
  61. #include <stdint.h>
  62. #define HANDLE_PRAGMA_PACK_PUSH_POP
  63.  
  64. #define ATTR_ALIGN(x) __attribute__((aligned(x)))
  65.  
  66. #ifndef __clang__
  67.     #ifndef __forceinline
  68.     #define __forceinline __attribute__((always_inline))
  69.     #endif // __forceinline
  70.     #undef forceinline
  71.     #define forceinline __forceinline
  72.     #define _byteswap_ulong(x) _bswap(x)
  73. #endif // __clang__
  74.  
  75. static __inline__ void __debugbreak__(void)
  76. {
  77.   __asm__ __volatile__ ("int $3");
  78. }
  79.  
  80. #define __debugbreak __debugbreak__
  81. #ifndef _countof
  82. #define _countof(x) (sizeof(x)/sizeof((x)[0]))
  83. #endif
  84.  
  85. #define __assume(x)
  86.  
  87. #endif // __GNUC__
  88.  
  89. #endif // __SYSDEFS_H_INCLUDED
  90.