Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
716 | lvd | 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 unsigned char u8; |
||
19 | |||
20 | #ifdef _MSC_VER |
||
21 | #define ATTR_ALIGN(x) __declspec(align(x)) |
||
22 | #define strtoull _strtoui64 |
||
23 | #endif |
||
24 | |||
25 | #ifdef __ICL |
||
26 | #pragma warning(disable : 2259) |
||
27 | #endif |
||
28 | |||
29 | #if __ICL >= 1000 || defined(__GNUC__) |
||
30 | static inline u8 rol8(u8 val, u8 shift) |
||
31 | { |
||
32 | __asm__ volatile ("rolb %1,%0" : "=r"(val) : "cI"(shift), "0"(val)); |
||
33 | return val; |
||
34 | } |
||
35 | |||
36 | static inline u8 ror8(u8 val, u8 shift) |
||
37 | { |
||
38 | __asm__ volatile ("rorb %1,%0" : "=r"(val) : "cI"(shift), "0"(val)); |
||
39 | return val; |
||
40 | } |
||
41 | static inline void asm_pause() { __asm__("pause"); } |
||
42 | #else |
||
43 | extern "C" unsigned char __cdecl _rotr8(unsigned char value, unsigned char shift); |
||
44 | extern "C" unsigned char __cdecl _rotl8(unsigned char value, unsigned char shift); |
||
45 | #pragma intrinsic(_rotr8) |
||
46 | #pragma intrinsic(_rotl8) |
||
47 | static inline u8 rol8(u8 val, u8 shift) { return _rotl8(val, shift); } |
||
48 | static inline u8 ror8(u8 val, u8 shift) { return _rotr8(val, shift); } |
||
49 | extern "C" void __cdecl _mm_pause(); |
||
50 | #pragma intrinsic(_mm_pause) |
||
51 | static inline void asm_pause() { _mm_pause();/* __asm {rep nop}*/ } |
||
52 | #endif |
||
53 | |||
54 | #if defined(_MSC_VER) && _MSC_VER < 1300 |
||
55 | static inline u16 _byteswap_ushort(u16 i){return (i>>8)|(i<<8);} |
||
56 | static inline u32 _byteswap_ulong(u32 i){return _byteswap_ushort((u16)(i>>16))|(_byteswap_ushort((u16)i)<<16);}; |
||
57 | #endif |
||
58 | |||
59 | #ifdef __GNUC__ |
||
60 | #include <stdint.h> |
||
61 | #define HANDLE_PRAGMA_PACK_PUSH_POP |
||
62 | |||
63 | #define ATTR_ALIGN(x) __attribute__((aligned(x))) |
||
64 | |||
65 | #ifndef __clang__ |
||
66 | #ifndef __forceinline |
||
67 | #define __forceinline __attribute__((always_inline)) |
||
68 | #endif // __forceinline |
||
69 | #undef forceinline |
||
70 | #define forceinline __forceinline |
||
71 | #define _byteswap_ulong(x) _bswap(x) |
||
72 | #endif // __clang__ |
||
73 | |||
74 | static __inline__ void __debugbreak__(void) |
||
75 | { |
||
76 | __asm__ __volatile__ ("int $3"); |
||
77 | } |
||
78 | |||
79 | #define __debugbreak __debugbreak__ |
||
80 | #ifndef _countof |
||
81 | #define _countof(x) (sizeof(x)/sizeof((x)[0])) |
||
82 | #endif |
||
83 | |||
84 | #define __assume(x) |
||
85 | |||
719 | lvd | 86 | |
87 | |||
88 | #ifndef min |
||
89 | #define min(a,b) (((a)<(b))?(a):(b)) |
||
90 | #endif |
||
91 | #ifndef max |
||
92 | #define max(a,b) (((a)>(b))?(a):(b)) |
||
93 | #endif |
||
94 | |||
716 | lvd | 95 | #endif // __GNUC__ |
96 | |||
97 | #endif // __SYSDEFS_H_INCLUDED |