X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=ia32rtools.git;a=blobdiff_plain;f=c_auto.h;h=84eb4e3347dc1ad58ad5b5a12717c2d76b4e1b48;hp=9b34f885d13c52cec9c57a58866ad0372ed9e0a4;hb=HEAD;hpb=2c31fb4cf1427f5a24c4eed0a08dbd3f3a2dacce diff --git a/c_auto.h b/c_auto.h index 9b34f88..84eb4e3 100644 --- a/c_auto.h +++ b/c_auto.h @@ -35,6 +35,12 @@ typedef struct { #define BYTE2(x) (*((u8*)&(x)+2)) #define BYTE3(x) (*((u8*)&(x)+3)) +#ifndef __WINE__ +#define DECL_IMPORT __declspec(dllimport) +#else +#define DECL_IMPORT +#endif + #define memcpy_0 memcpy #define noreturn __attribute__((noreturn)) @@ -57,4 +63,43 @@ static inline int do_parity(unsigned int v) printf("%s:%d: skip_code_abort\n", __FILE__, __LINE__); \ *(volatile int *)0 = 1 +#define barrier() \ + asm volatile("" ::: "memory") + +/* gcc always emits vldr/vstr which requires alignment, + * so in some cases these unaligned helpers are needed */ +#ifdef __ARM_NEON__ + +static inline float float_load(u32 ptr) +{ + register float v asm("s0"); + + asm ("vld1.32 {d0[0]}, [%1]" + : "=t"(v) : "r"(ptr)); + + return v; +} + +static inline void float_store(float v, u32 ptr) +{ + register float v1 asm("s0") = v; + + asm ("vst1.32 {d0[0]}, [%1]" + : : "t"(v1), "r"(ptr) : "memory"); +} + +#else + +static inline float float_load(u32 ptr) +{ + return *(const float *)ptr; +} + +static inline void float_store(float v, u32 ptr) +{ + *(float *)ptr = v; +} + +#endif + // vim:ts=2:sw=2:expandtab