8 /*** Stack frame juggling ***/
9 void * _ReturnAddress(void);
10 void * _AddressOfReturnAddress(void);
11 unsigned int __getcallerseflags(void);
13 /*** Atomic operations ***/
14 void _ReadWriteBarrier(void);
15 void _ReadBarrier(void);
16 void _WriteBarrier(void);
18 char _InterlockedCompareExchange8(volatile char * const Destination
, const char Exchange
, const char Comperand
);
19 short _InterlockedCompareExchange16(volatile short * const Destination
, const short Exchange
, const short Comperand
);
20 long _InterlockedCompareExchange(volatile long * const Destination
, const long Exchange
, const long Comperand
);
21 void * _InterlockedCompareExchangePointer(void * volatile * const Destination
, void * const Exchange
, void * const Comperand
);
22 long _InterlockedExchange(volatile long * const Target
, const long Value
);
23 void * _InterlockedExchangePointer(void * volatile * const Target
, void * const Value
);
24 long _InterlockedExchangeAdd16(volatile short * const Addend
, const short Value
);
25 long _InterlockedExchangeAdd(volatile long * const Addend
, const long Value
);
26 char _InterlockedAnd8(volatile char * const value
, const char mask
);
27 short _InterlockedAnd16(volatile short * const value
, const short mask
);
28 long _InterlockedAnd(volatile long * const value
, const long mask
);
29 char _InterlockedOr8(volatile char * const value
, const char mask
);
30 short _InterlockedOr16(volatile short * const value
, const short mask
);
31 long _InterlockedOr(volatile long * const value
, const long mask
);
32 char _InterlockedXor8(volatile char * const value
, const char mask
);
33 short _InterlockedXor16(volatile short * const value
, const short mask
);
34 long _InterlockedXor(volatile long * const value
, const long mask
);
35 long _InterlockedAddLargeStatistic(volatile __int64
* const Addend
, const long Value
);
36 long _InterlockedDecrement(volatile long * const lpAddend
);
37 long _InterlockedIncrement(volatile long * const lpAddend
);
38 short _InterlockedDecrement16(volatile short * const lpAddend
);
39 short _InterlockedIncrement16(volatile short * const lpAddend
);
40 unsigned char _interlockedbittestandreset(volatile long * a
, const long b
);
41 unsigned char _interlockedbittestandset(volatile long * a
, const long b
);
44 __int64
_InterlockedExchange64(volatile __int64
* const Target
, const __int64 Value
);
45 __int64
_InterlockedExchangeAdd64(volatile __int64
* const Addend
, const __int64 Value
);
46 long _InterlockedAnd64(volatile __int64
* const value
, const __int64 mask
);
47 long _InterlockedOr64(volatile __int64
* const value
, const __int64 mask
);
48 __int64
_InterlockedCompareExchange64(volatile __int64
* const Destination
, const __int64 Exchange
, const __int64 Comperand
);
49 __int64
_InterlockedDecrement64(volatile __int64
* const lpAddend
);
50 __int64
_InterlockedIncrement64(volatile __int64
* const lpAddend
);
51 unsigned char _interlockedbittestandreset64(volatile __int64
* a
, const __int64 b
);
52 unsigned char _interlockedbittestandset64(volatile __int64
* a
, const __int64 b
);
55 /*** String operations ***/
56 void __stosb(unsigned char * Dest
, const unsigned char Data
, size_t Count
);
57 void __stosw(unsigned short * Dest
, const unsigned short Data
, size_t Count
);
58 void __stosd(unsigned long * Dest
, const unsigned long Data
, size_t Count
);
59 void __movsb(unsigned char * Destination
, const unsigned char * Source
, size_t Count
);
60 void __movsw(unsigned short * Destination
, const unsigned short * Source
, size_t Count
);
61 void __movsd(unsigned long * Destination
, const unsigned long * Source
, size_t Count
);
64 /*** GS segment addressing ***/
65 void __writegsbyte(const unsigned long Offset
, const unsigned char Data
);
66 void __writegsword(const unsigned long Offset
, const unsigned short Data
);
67 void __writegsdword(const unsigned long Offset
, const unsigned long Data
);
68 void __writegsqword(const unsigned long Offset
, const unsigned __int64 Data
);
69 unsigned char __readgsbyte(const unsigned long Offset
);
70 unsigned short __readgsword(const unsigned long Offset
);
71 unsigned long __readgsdword(const unsigned long Offset
);
72 unsigned __int64
__readgsqword(const unsigned long Offset
);
73 void __incgsbyte(const unsigned long Offset
);
74 void __incgsword(const unsigned long Offset
);
75 void __incgsdword(const unsigned long Offset
);
76 void __addgsbyte(const unsigned long Offset
, const unsigned char Data
);
77 void __addgsword(const unsigned long Offset
, const unsigned short Data
);
78 void __addgsdword(const unsigned long Offset
, const unsigned int Data
);
79 void __addgsqword(const unsigned long Offset
, const unsigned __int64 Data
);
83 /*** FS segment addressing ***/
84 void __writefsbyte(const unsigned long Offset
, const unsigned char Data
);
85 void __writefsword(const unsigned long Offset
, const unsigned short Data
);
86 void __writefsdword(const unsigned long Offset
, const unsigned long Data
);
87 unsigned char __readfsbyte(const unsigned long Offset
);
88 unsigned short __readfsword(const unsigned long Offset
);
89 unsigned long __readfsdword(const unsigned long Offset
);
90 void __incfsbyte(const unsigned long Offset
);
91 void __incfsword(const unsigned long Offset
);
92 void __incfsdword(const unsigned long Offset
);
93 void __addfsbyte(const unsigned long Offset
, const unsigned char Data
);
94 void __addfsword(const unsigned long Offset
, const unsigned short Data
);
95 void __addfsdword(const unsigned long Offset
, const unsigned int Data
);
99 /*** Bit manipulation ***/
100 unsigned char _BitScanForward(unsigned long * const Index
, const unsigned long Mask
);
101 unsigned char _BitScanReverse(unsigned long * const Index
, const unsigned long Mask
);
102 unsigned char _bittest(const long * const a
, const long b
);
103 unsigned char _bittestandcomplement(long * const a
, const long b
);
104 unsigned char _bittestandreset(long * const a
, const long b
);
105 unsigned char _bittestandset(long * const a
, const long b
);
106 unsigned char _rotl8(unsigned char value
, unsigned char shift
);
107 unsigned short _rotl16(unsigned short value
, unsigned char shift
);
108 unsigned int _rotl(unsigned int value
, int shift
);
109 unsigned int _rotr(unsigned int value
, int shift
);
110 unsigned char _rotr8(unsigned char value
, unsigned char shift
);
111 unsigned short _rotr16(unsigned short value
, unsigned char shift
);
112 unsigned __int64
__ll_lshift(const unsigned __int64 Mask
, const int Bit
);
113 __int64
__ll_rshift(const __int64 Mask
, const int Bit
);
114 unsigned __int64
__ull_rshift(const unsigned __int64 Mask
, int Bit
);
115 unsigned short _byteswap_ushort(unsigned short value
);
116 unsigned long _byteswap_ulong(unsigned long value
);
117 unsigned __int64
_byteswap_uint64(unsigned __int64 value
);
119 /*** 64-bit math ***/
120 __int64
__emul(const int a
, const int b
);
121 unsigned __int64
__emulu(const unsigned int a
, const unsigned int b
);
124 unsigned char __inbyte(const unsigned short Port
);
125 unsigned short __inword(const unsigned short Port
);
126 unsigned long __indword(const unsigned short Port
);
127 void __inbytestring(unsigned short Port
, unsigned char * Buffer
, unsigned long Count
);
128 void __inwordstring(unsigned short Port
, unsigned short * Buffer
, unsigned long Count
);
129 void __indwordstring(unsigned short Port
, unsigned long * Buffer
, unsigned long Count
);
130 void __outbyte(unsigned short const Port
, const unsigned char Data
);
131 void __outword(unsigned short const Port
, const unsigned short Data
);
132 void __outdword(unsigned short const Port
, const unsigned long Data
);
133 void __outbytestring(unsigned short const Port
, const unsigned char * const Buffer
, const unsigned long Count
);
134 void __outwordstring(unsigned short const Port
, const unsigned short * const Buffer
, const unsigned long Count
);
135 void __outdwordstring(unsigned short const Port
, const unsigned long * const Buffer
, const unsigned long Count
);
137 /*** System information ***/
138 void __cpuid(int CPUInfo
[], const int InfoType
);
139 unsigned __int64
__rdtsc(void);
140 void __writeeflags(uintptr_t Value
);
141 uintptr_t __readeflags(void);
144 void __debugbreak(void);
150 /*** Protected memory management ***/
151 void __writecr0(const unsigned __int64 Data
);
152 void __writecr3(const unsigned __int64 Data
);
153 void __writecr4(const unsigned __int64 Data
);
156 void __writecr8(const unsigned __int64 Data
);
157 unsigned __int64
__readcr0(void);
158 unsigned __int64
__readcr2(void);
159 unsigned __int64
__readcr3(void);
160 unsigned __int64
__readcr4(void);
161 unsigned __int64
__readcr8(void);
162 unsigned __int64
__readdr(unsigned int reg
);
163 void __writedr(unsigned reg
, unsigned __int64 value
);
165 unsigned long __readcr0(void);
166 unsigned long __readcr2(void);
167 unsigned long __readcr3(void);
168 unsigned long __readcr4(void);
169 unsigned int __readdr(unsigned int reg
);
170 void __writedr(unsigned reg
, unsigned int value
);
173 void __invlpg(void * const Address
);
175 /*** System operations ***/
176 unsigned __int64
__readmsr(const int reg
);
177 void __writemsr(const unsigned long Register
, const unsigned __int64 Value
);
178 unsigned __int64
__readpmc(const int counter
);
179 unsigned long __segmentlimit(const unsigned long a
);
181 void __lidt(void *Source
);
182 void __sidt(void *Destination
);
183 void _mm_pause(void);
189 #endif /* KJK_INTRIN_H_ */