minor fixes
[ia32rtools.git] / c_auto.h
CommitLineData
7ba45c34 1// note: include after system headers
2
3//#pragma GCC diagnostic ignored "-Wparentheses"
4
5#define u8 uint8_t
6#define u16 uint16_t
7#define u32 uint32_t
8#define u64 uint64_t
9#define s8 int8_t
10#define s16 int16_t
11#define s32 int32_t
12#define s64 int64_t
90307a99 13typedef struct {
14 u64 q;
15 u32 d[2];
16 u16 w[4];
17 u8 b[8];
18} mmxr;
19
7ba45c34 20#define bool int
04abc5d6 21#define _BYTE uint8_t
22#define _WORD uint16_t
23#define _DWORD uint32_t
2b43685d 24#define _UNKNOWN uint8_t
7ba45c34 25#undef LOBYTE
26#undef LOWORD
27#undef HIBYTE
28#undef HIWORD
04abc5d6 29#define LOBYTE(x) (*((u8*)&(x)))
30#define LOWORD(x) (*((u16*)&(x)))
31#define HIBYTE(x) (*((u8*)&(x)+1))
32#define HIWORD(x) (*((u16*)&(x)+1))
33#define BYTE0(x) (*((u8*)&(x)+0))
34#define BYTE1(x) (*((u8*)&(x)+1))
35#define BYTE2(x) (*((u8*)&(x)+2))
36#define BYTE3(x) (*((u8*)&(x)+3))
7ba45c34 37
1fe8d40e 38#ifndef __WINE__
39#define DECL_IMPORT __declspec(dllimport)
40#else
41#define DECL_IMPORT
42#endif
43
7ba45c34 44#define memcpy_0 memcpy
45
e56ab892 46#define noreturn __attribute__((noreturn))
7ba45c34 47
6bda240a 48static inline BOOL PtInRect_sa(LPCRECT r, int x, int y)
49{
50 POINT p = { x, y };
51 return PtInRect(r, p);
52}
11437ea1 53
2c31fb4c 54static inline int do_parity(unsigned int v)
55{
56 v ^= v >> 4;
57 v ^= v >> 2;
58 v ^= v >> 1;
59 return (v ^ 1) & 1;
60}
61
11437ea1 62#define do_skip_code_abort() \
63 printf("%s:%d: skip_code_abort\n", __FILE__, __LINE__); \
64 *(volatile int *)0 = 1
2c31fb4c 65
193c11bf 66#define barrier() \
67 asm volatile("" ::: "memory")
68
f124ee13 69/* gcc always emits vldr/vstr which requires alignment,
70 * so in some cases these unaligned helpers are needed */
71#ifdef __ARM_NEON__
72
73static inline float float_load(u32 ptr)
74{
75 register float v asm("s0");
76
77 asm ("vld1.32 {d0[0]}, [%1]"
78 : "=t"(v) : "r"(ptr));
79
80 return v;
81}
82
83static inline void float_store(float v, u32 ptr)
84{
85 register float v1 asm("s0") = v;
86
87 asm ("vst1.32 {d0[0]}, [%1]"
88 : : "t"(v1), "r"(ptr) : "memory");
89}
90
91#else
92
93static inline float float_load(u32 ptr)
94{
95 return *(const float *)ptr;
96}
97
98static inline void float_store(float v, u32 ptr)
99{
100 *(float *)ptr = v;
101}
102
103#endif
104
2c31fb4c 105// vim:ts=2:sw=2:expandtab