28#ifndef KJK_INTRIN_PPC_H_
29#define KJK_INTRIN_PPC_H_
32#define PPC_QUAL extern __inline__
35#error Unsupported compiler
39#define _ReturnAddress() (__builtin_return_address(0))
40#define _AddressOfReturnAddress() (&(((void **)(__builtin_frame_address(0)))[1]))
48#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) > 40100
49#define _ReadWriteBarrier() __sync_synchronize()
54#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) > 40100
58 return __sync_val_compare_and_swap(
Destination, Comperand, Exchange);
63 return __sync_val_compare_and_swap(
Destination, Comperand, Exchange);
68 return __sync_val_compare_and_swap(
Destination, Comperand, Exchange);
73 return __sync_val_compare_and_swap(
Destination, Comperand, Exchange);
78 return __sync_val_compare_and_swap(
Destination, Comperand, Exchange);
102 return __sync_fetch_and_and(
value,
mask);
107 return __sync_fetch_and_and(
value,
mask);
112 return __sync_fetch_and_and(
value,
mask);
132 return __sync_fetch_and_xor(
value,
mask);
137 return __sync_fetch_and_xor(
value,
mask);
142 return __sync_fetch_and_xor(
value,
mask);
149 volatile long retval
__asm__(
"r8") = 0;
161 :
"r" (
Destination),
"r" (Comperand),
"r" (Exchange),
"r" (retval));
167 volatile long retval
__asm__(
"r8") = 0;
179 :
"r" (
Destination),
"r" (Comperand),
"r" (Exchange),
"r" (retval));
185 volatile long retval
__asm__(
"r8") = 0;
197 :
"r" (
Destination),
"r" (Comperand),
"r" (Exchange),
"r" (retval));
203 long long capture = *
Target;
211 ((
long *)
Destination, (
long) Exchange, (
long) Comperand);
234#define PPC_MakeInterlockedFunction(type,name,op,proto) \
235PPC_QUAL type name proto \
241 y = _InterlockedCompareExchange(value, addend op modify, addend); \
243 while(y != addend); \
261 return (
y & ~
mask) != 0;
288 return (
y & ~
mask) != 0;
429 if(
Mask == 0)
return 0;
434 ((
mask & 0xffff0000) ? 16 : 0) +
435 ((
mask & 0xff00ff00) ? 8 : 0) +
436 ((
mask & 0xf0f0f0f0) ? 4 : 0) +
437 ((
mask & 0xcccccccc) ? 2 : 0) +
438 ((
mask & 0xaaaaaaaa) ? 1 : 0);
446 unsigned long check = 16, checkmask;
447 if(
Mask == 0)
return 0;
453 if(
mask & checkmask ) {
466 return ((*
a) & (1<<
b)) != 0;
471 unsigned char ret = ((*a) & (1<<
b)) != 0;
478 unsigned char ret = ((*a) & (1<<
b)) != 0;
485 unsigned char ret = ((*a) & (1<<
b)) != 0;
544 "andi. 6,5,0xffef\n\t"
549 "mtmsr 5\n\t" :
"=r" (
ret) :
"b" (
Port)
559 "andi. 6,5,0xffef\n\t"
564 "mtmsr 5\n\t" :
"=r" (
ret) :
"b" (
Port)
574 "andi. 6,5,0xffef\n\t"
579 "mtmsr 5\n\t" :
"=r" (
ret) :
"b" (
Port)
609 "andi. 6,5,0xffef\n\t"
617 "eieio\n\t" : :
"b" (
Port),
"r" (
Data)
625 "andi. 6,5,0xffef\n\t"
633 "eieio\n\t" : :
"b" (
Port),
"b" (
Data)
641 "andi. 6,5,0xffef\n\t"
649 "eieio\n\t" : :
"b" (
Port),
"b" (
Data)
685 __asm__(
"mfpvr" :
"=b" (lo32));
691 __asm__(
"mfdec %0" :
"=b" (lo32));
708#ifndef _ENABLE_DISABLE_DEFINED
709#define _ENABLE_DISABLE_DEFINED
712 __asm__ __volatile__(
"mfmsr 0\n\t" \
720 __asm__ __volatile__(
"mfmsr 8\n\t" \
721 "ori 8,8,0x8000\n\t" \
773 "lock; add %[Value], %[Lo32];"
775 "lock; adc $0, %[Hi32];"
777 [Lo32]
"=m" (*((
volatile long *)(
Addend) + 0)), [Hi32]
"=m" (*((
volatile long *)(
Addend) + 1)) :
786#define __noop(...) ((void)0)
788#define __assume(x) if (!(x)) __builtin_unreachable()
#define check(expected, result)
GLint GLint GLint GLint GLint x
GLint GLint GLint GLint GLint GLint y
GLuint GLuint GLsizei count
GLboolean GLboolean GLboolean b
GLenum const GLvoid * addr
GLboolean GLboolean GLboolean GLboolean a
long __cdecl _InterlockedExchangeAdd(_Interlocked_operand_ long volatile *_Addend, long _Value)
char _InterlockedOr8(_Interlocked_operand_ char volatile *_Value, char _Mask)
long _InterlockedOr(_Interlocked_operand_ long volatile *_Value, long _Mask)
short _InterlockedXor16(_Interlocked_operand_ short volatile *_Value, short _Mask)
short _InterlockedAnd16(_Interlocked_operand_ short volatile *_Value, short _Mask)
PPC_QUAL unsigned char _bittestandset(long *const a, const long b)
PPC_QUAL unsigned char __readfsbyte(const unsigned long Offset)
PPC_QUAL unsigned long long __ull_rshift(const unsigned long long Mask, int Bit)
PPC_QUAL void __stosb(unsigned char *Dest, const unsigned char Data, unsigned long Count)
PPC_QUAL void __writemsr(const unsigned long Value)
PPC_QUAL long _InterlockedDecrement(volatile long *const lpAddend)
PPC_QUAL unsigned long long __emulu(const unsigned int a, const unsigned int b)
volatile char *const const char modify volatile long *const const long modify volatile short *const const short modify volatile char *const const char modify volatile long *const const long modify PPC_QUAL unsigned char _interlockedbittestandset(volatile long *const a, const long b)
PPC_QUAL void __writefsword(const unsigned long Offset, const unsigned short Data)
PPC_QUAL void __incfsword(const unsigned long Offset)
PPC_QUAL void __incfsdword(const unsigned long Offset)
PPC_QUAL long _InterlockedExchange(volatile long *const Target, const long Value)
PPC_QUAL void __movsd(unsigned long *Destination, const unsigned long *Source, unsigned long Count)
PPC_QUAL unsigned long long __ll_lshift(const unsigned long long Mask, int Bit)
PPC_QUAL void _enable(void)
PPC_QUAL long long __emul(const int a, const int b)
PPC_QUAL void __cpuid(int CPUInfo[], const int InfoType)
PPC_QUAL unsigned char _rotl8(const unsigned char value, const unsigned char shift)
PPC_QUAL void __incfsbyte(const unsigned long Offset)
PPC_QUAL unsigned long long __readmsr()
PPC_QUAL void __outbytestring(unsigned long const Port, const unsigned char *const Buffer, const unsigned long Count)
PPC_QUAL long _InterlockedIncrement(volatile long *const lpAddend)
PPC_QUAL void __addfsword(const unsigned long Offset, const unsigned short Data)
PPC_QUAL long long _InterlockedCompareExchange64(volatile long long *const Target, const long long Exchange, const long long Comperand)
PPC_QUAL void __outdword(unsigned long const Port, const unsigned long Data)
#define PPC_MakeInterlockedFunction(type, name, op, proto)
volatile char *const value
PPC_QUAL unsigned short __readfsword(const unsigned long Offset)
PPC_QUAL void __movsw(unsigned short *Destination, const unsigned short *Source, unsigned long Count)
PPC_QUAL void __wbinvd(void)
PPC_QUAL void __outwordstring(unsigned long const Port, const unsigned short *const Buffer, const unsigned long Count)
PPC_QUAL void * _InterlockedCompareExchangePointer(void *volatile *const Destination, void *const Exchange, void *const Comperand)
PPC_QUAL void _disable(void)
PPC_QUAL unsigned short _rotr16(const unsigned short value, const unsigned char shift)
PPC_QUAL void __addfsbyte(const unsigned long Offset, const unsigned char Data)
PPC_QUAL void __int2c(void)
PPC_QUAL unsigned long __readsdr1(void)
PPC_QUAL unsigned char __inbyte(const unsigned long Port)
PPC_QUAL short _InterlockedCompareExchange16(volatile short *const Destination, const short Exchange, const short Comperand)
PPC_QUAL void __writesdr1(const unsigned long long Data)
PPC_QUAL unsigned char _BitScanReverse(unsigned long *const Index, const unsigned long Mask)
PPC_QUAL long _InterlockedCompareExchange(volatile long *const Destination, const long Exchange, const long Comperand)
PPC_QUAL char _InterlockedCompareExchange8(volatile char *const Destination, const char Exchange, const char Comperand)
PPC_QUAL unsigned short __inword(const unsigned long Port)
PPC_QUAL void __inwordstring(unsigned long Port, unsigned short *Buffer, unsigned long Count)
PPC_QUAL unsigned char _bittestandreset(long *const a, const long b)
PPC_QUAL void __debugbreak(void)
PPC_QUAL unsigned char _rotr8(const unsigned char value, const unsigned char shift)
PPC_QUAL unsigned char _bittest(const long *const a, const long b)
PPC_QUAL void __outbyte(unsigned long const Port, const unsigned char Data)
volatile char *const const char modify volatile long *const const long modify _InterlockedOr16
PPC_QUAL void __writefsdword(const unsigned long Offset, const unsigned long Data)
PPC_QUAL long _InterlockedAddLargeStatistic(volatile long long *const Addend, const long Value)
PPC_QUAL unsigned char _BitScanForward(unsigned long *const Index, const unsigned long Mask)
PPC_QUAL void __inbytestring(unsigned long Port, unsigned char *Buffer, unsigned long Count)
PPC_QUAL void __outdwordstring(unsigned long const Port, const unsigned long *const Buffer, const unsigned long Count)
PPC_QUAL long long __ll_rshift(const long long Mask, const int Bit)
PPC_QUAL void __movsb(unsigned char *Destination, const unsigned char *Source, unsigned long Count)
PPC_QUAL unsigned long __indword(const unsigned long Port)
PPC_QUAL unsigned long __readfsdword(const unsigned long Offset)
PPC_QUAL void * _InterlockedExchangePointer(void *volatile *const Target, void *const Value)
PPC_QUAL void __indwordstring(unsigned long Port, unsigned long *Buffer, unsigned long Count)
PPC_QUAL unsigned char _interlockedbittestandreset(volatile long *const a, const long b)
PPC_QUAL void __writefsbyte(const unsigned long Offset, const unsigned char Data)
PPC_QUAL void __outword(unsigned long const Port, const unsigned short Data)
PPC_QUAL unsigned char _bittestandcomplement(long *const a, const long b)
volatile char *const const char modify volatile long *const const long modify volatile short *const const short modify volatile char *const const char modify _InterlockedXor
volatile char *const const char modify _InterlockedAnd
PPC_QUAL void __stosw(unsigned short *Dest, const unsigned short Data, unsigned long Count)
volatile char *const const char modify volatile long *const const long modify volatile short *const const short modify _InterlockedXor8
PPC_QUAL void __addfsdword(const unsigned long Offset, const unsigned int Data)
PPC_QUAL void __stosd(unsigned long *Dest, const unsigned long Data, unsigned long Count)
PPC_QUAL unsigned long long __rdtsc(void)
PPC_QUAL unsigned short _rotl16(const unsigned short value, const unsigned char shift)
#define memcpy(s1, s2, n)
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
_In_ ULONG _In_ ULONG Offset
__asm__(".p2align 4, 0x90\n" ".seh_proc __seh2_global_filter_func\n" "__seh2_global_filter_func:\n" "\tsub %rbp, %rax\n" "\tpush %rbp\n" "\t.seh_pushreg %rbp\n" "\tsub $32, %rsp\n" "\t.seh_stackalloc 32\n" "\t.seh_endprologue\n" "\tsub %rax, %rdx\n" "\tmov %rdx, %rbp\n" "\tjmp *%r8\n" "__seh2_global_filter_func_exit:\n" "\t.p2align 4\n" "\tadd $32, %rsp\n" "\tpop %rbp\n" "\tret\n" "\t.seh_endproc")
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value