clang-format a couple of pragma headers. DONT_BUILD.

git-svn-id: https://svn.eduke32.com/eduke32@4715 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2014-11-02 05:35:22 +00:00
parent e677923165
commit 2badda6ec4
2 changed files with 156 additions and 82 deletions

View file

@ -11,7 +11,8 @@ extern "C" {
#include <limits.h>
#define EDUKE32_GENERATE_PRAGMAS EDUKE32_SCALER_PRAGMA(1) EDUKE32_SCALER_PRAGMA(2) EDUKE32_SCALER_PRAGMA(3) EDUKE32_SCALER_PRAGMA(4)\
#define EDUKE32_GENERATE_PRAGMAS \
EDUKE32_SCALER_PRAGMA(1) EDUKE32_SCALER_PRAGMA(2) EDUKE32_SCALER_PRAGMA(3) EDUKE32_SCALER_PRAGMA(4) \
EDUKE32_SCALER_PRAGMA(5) EDUKE32_SCALER_PRAGMA(6) EDUKE32_SCALER_PRAGMA(7) EDUKE32_SCALER_PRAGMA(8) \
EDUKE32_SCALER_PRAGMA(9) EDUKE32_SCALER_PRAGMA(10) EDUKE32_SCALER_PRAGMA(11) EDUKE32_SCALER_PRAGMA(12) \
EDUKE32_SCALER_PRAGMA(13) EDUKE32_SCALER_PRAGMA(14) EDUKE32_SCALER_PRAGMA(15) EDUKE32_SCALER_PRAGMA(16) \
@ -90,11 +91,15 @@ skip:
#else
static inline uint32_t divideu32(uint32_t n, uint32_t d) { return n / d; }
static inline int32_t tabledivide64(int64_t n, int32_t d) { return ((unsigned) d < DIVTABLESIZE) ?
libdivide_s64_do(n, (libdivide_s64_t *) &divtable64[d]) : n / d; }
static inline int32_t tabledivide64(int64_t n, int32_t d)
{
return ((unsigned)d < DIVTABLESIZE) ? libdivide_s64_do(n, (libdivide_s64_t *)&divtable64[d]) : n / d;
}
static inline int32_t tabledivide32(int32_t n, int32_t d) { return ((unsigned) d < DIVTABLESIZE) ?
libdivide_s32_do(n, (libdivide_s32_t *) &divtable32[d]) : n / d; }
static inline int32_t tabledivide32(int32_t n, int32_t d)
{
return ((unsigned)d < DIVTABLESIZE) ? libdivide_s32_do(n, (libdivide_s32_t *)&divtable32[d]) : n / d;
}
#endif
extern uint32_t divideu32_noinline(uint32_t n, uint32_t d);
@ -103,10 +108,7 @@ extern int32_t tabledivide64_noinline(int64_t n, int32_t d);
#ifdef GEKKO
#include <math.h>
static inline int32_t divscale(int32_t eax, int32_t ebx, int32_t ecx)
{
return tabledivide64(ldexp(eax, ecx), ebx);
}
static inline int32_t divscale(int32_t eax, int32_t ebx, int32_t ecx) { return tabledivide64(ldexp(eax, ecx), ebx); }
#else
static inline int32_t divscale(int32_t eax, int32_t ebx, int32_t ecx)
{
@ -115,7 +117,8 @@ static inline int32_t divscale(int32_t eax, int32_t ebx, int32_t ecx)
}
#endif
# define EDUKE32_SCALER_PRAGMA(a) static inline int32_t divscale##a(int32_t eax, int32_t ebx) { return divscale(eax, ebx, a); }
#define EDUKE32_SCALER_PRAGMA(a) \
static inline int32_t divscale##a(int32_t eax, int32_t ebx) { return divscale(eax, ebx, a); }
EDUKE32_GENERATE_PRAGMAS EDUKE32_SCALER_PRAGMA(32)
#undef EDUKE32_SCALER_PRAGMA
@ -152,36 +155,69 @@ static inline int32_t scale(int32_t eax, int32_t edx, int32_t ecx)
//
#define EDUKE32_SCALER_PRAGMA(a) \
static inline int32_t mulscale##a(int32_t eax, int32_t edx) \
{ \
return dw((qw(eax) * qw(edx)) >> by(a)); \
} \
static inline int32_t mulscale##a(int32_t eax, int32_t edx) { return dw((qw(eax) * qw(edx)) >> by(a)); } \
\
static inline int32_t dmulscale##a(int32_t eax, int32_t edx, int32_t esi, int32_t edi) \
{ \
return dw(((qw(eax) * qw(edx)) + (qw(esi) * qw(edi))) >> by(a)); \
} \
\
}
EDUKE32_GENERATE_PRAGMAS EDUKE32_SCALER_PRAGMA(32)
#undef EDUKE32_SCALER_PRAGMA
static inline void swapchar(void* a, void* b) { char t = *((char*)b); *((char*)b) = *((char*)a); *((char*)a) = t; }
static inline void swapchar2(void* a, void* b, int32_t s) { swapchar(a,b); swapchar((char*)a+1,(char*)b+s); }
static inline void swapshort(void* a, void* b) { int16_t t = *((int16_t*)b); *((int16_t*)b) = *((int16_t*)a); *((int16_t*)a) = t; }
static inline void swaplong(void* a, void* b) { int32_t t = *((int32_t*)b); *((int32_t*)b) = *((int32_t*)a); *((int32_t*)a) = t; }
static inline void swapfloat(void* a, void* b) { float t = *((float*)b); *((float*)b) = *((float*)a); *((float*)a) = t; }
static inline void swap64bit(void* a, void* b) { int64_t t = *((int64_t*)b); *((int64_t*)b) = *((int64_t*)a); *((int64_t*)a) = t; }
static inline void swapchar(void *a, void *b)
{
char t = *((char *)b);
*((char *)b) = *((char *)a);
*((char *)a) = t;
}
static inline void swapchar2(void *a, void *b, int32_t s)
{
swapchar(a, b);
swapchar((char *)a + 1, (char *)b + s);
}
static inline void swapshort(void *a, void *b)
{
int16_t t = *((int16_t *)b);
*((int16_t *)b) = *((int16_t *)a);
*((int16_t *)a) = t;
}
static inline void swaplong(void *a, void *b)
{
int32_t t = *((int32_t *)b);
*((int32_t *)b) = *((int32_t *)a);
*((int32_t *)a) = t;
}
static inline void swapfloat(void *a, void *b)
{
float t = *((float *)b);
*((float *)b) = *((float *)a);
*((float *)a) = t;
}
static inline void swap64bit(void *a, void *b)
{
int64_t t = *((int64_t *)b);
*((int64_t *)b) = *((int64_t *)a);
*((int64_t *)a) = t;
}
static inline char readpixel(void *s) { return (*((char *)(s))); }
static inline void drawpixel(void *s, char a) { *((char *)(s)) = a; }
static inline int32_t klabs(int32_t a) { const uint32_t m = a >> (sizeof(int) * CHAR_BIT - 1); return (a ^ m) - m; }
static inline int32_t klabs(int32_t a)
{
const uint32_t m = a >> (sizeof(int) * CHAR_BIT - 1);
return (a ^ m) - m;
}
static inline int32_t ksgn(int32_t a) { return (a > 0) - (a < 0); }
static inline int32_t mulscale(int32_t eax, int32_t edx, int32_t ecx) { return dw((qw(eax) * edx) >> by(ecx)); }
static inline int32_t dmulscale(int32_t eax, int32_t edx, int32_t esi, int32_t edi, int32_t ecx) { return dw(((qw(eax) * edx) + (qw(esi) * edi)) >> by(ecx)); }
static inline int32_t dmulscale(int32_t eax, int32_t edx, int32_t esi, int32_t edi, int32_t ecx)
{
return dw(((qw(eax) * edx) + (qw(esi) * edi)) >> by(ecx));
}
void qinterpolatedown16(intptr_t bufptr, int32_t num, int32_t val, int32_t add);
void qinterpolatedown16short(intptr_t bufptr, int32_t num, int32_t val, int32_t add);
@ -197,7 +233,8 @@ void copybufreverse(const void *S, void *D, int32_t c);
static inline int32_t krecipasm(int32_t i)
{
// Ken did this
float f = (float) i; i = *(int32_t *) &f;
float f = (float)i;
i = *(int32_t *)&f;
return ((reciptable[(i >> 12) & 2047] >> (((i - 0x3f800000) >> 23) & 31)) ^ (i >> 31));
}
@ -227,4 +264,3 @@ static inline void swapbufreverse(void *s, void *d, int32_t c)
#endif
#endif // __pragmas_h__

View file

@ -6,31 +6,68 @@
#define __pragmas_arm_h__
#define EDUKE32_SCALER_PRAGMA(a) \
static inline int32_t mulscale##a(int32_t eax, int32_t edx) \
{ return dw((qw(eax) * edx) >> by(a)); } \
static inline int32_t mulscale##a(int32_t eax, int32_t edx) { return dw((qw(eax) * edx) >> by(a)); } \
\
static inline int32_t dmulscale##a(int32_t eax, int32_t edx, int32_t esi, int32_t edi) \
{ return dw(((qw(eax) * edx) + (qw(esi) * edi)) >> by(a)); } \
{ \
return dw(((qw(eax) * edx) + (qw(esi) * edi)) >> by(a)); \
}
EDUKE32_GENERATE_PRAGMAS EDUKE32_SCALER_PRAGMA(32)
#undef EDUKE32_SCALER_PRAGMA
static inline void swapchar(void* a, void* b) { char t = *((char*) b); *((char*) b) = *((char*) a); *((char*) a) = t; }
static inline void swapchar2(void* a, void* b, int32_t s) { swapchar(a, b); swapchar((char*) a+1, (char*) b+s); }
static inline void swapshort(void* a, void* b) { int16_t t = *((int16_t*) b); *((int16_t*) b) = *((int16_t*) a); *((int16_t*) a) = t; }
static inline void swaplong(void* a, void* b) { int32_t t = *((int32_t*) b); *((int32_t*) b) = *((int32_t*) a); *((int32_t*) a) = t; }
static inline void swapfloat(void* a, void* b) { float t = *((float*) b); *((float*) b) = *((float*) a); *((float*) a) = t; }
static inline void swap64bit(void* a, void* b) { int64_t t = *((int64_t*) b); *((int64_t*) b) = *((int64_t*) a); *((int64_t*) a) = t; }
static inline void swapchar(void *a, void *b)
{
char t = *((char *)b);
*((char *)b) = *((char *)a);
*((char *)a) = t;
}
static inline void swapchar2(void *a, void *b, int32_t s)
{
swapchar(a, b);
swapchar((char *)a + 1, (char *)b + s);
}
static inline void swapshort(void *a, void *b)
{
int16_t t = *((int16_t *)b);
*((int16_t *)b) = *((int16_t *)a);
*((int16_t *)a) = t;
}
static inline void swaplong(void *a, void *b)
{
int32_t t = *((int32_t *)b);
*((int32_t *)b) = *((int32_t *)a);
*((int32_t *)a) = t;
}
static inline void swapfloat(void *a, void *b)
{
float t = *((float *)b);
*((float *)b) = *((float *)a);
*((float *)a) = t;
}
static inline void swap64bit(void *a, void *b)
{
int64_t t = *((int64_t *)b);
*((int64_t *)b) = *((int64_t *)a);
*((int64_t *)a) = t;
}
static inline char readpixel(void *s) { return (*((char *)(s))); }
static inline void drawpixel(void *s, char a) { *((char *)(s)) = a; }
static inline int32_t klabs(int32_t a) { const uint32_t m = a >> (sizeof(int) * CHAR_BIT - 1); return (a ^ m) - m; }
static inline int32_t klabs(int32_t a)
{
const uint32_t m = a >> (sizeof(int32_t) * CHAR_BIT - 1);
return (a ^ m) - m;
}
static inline int32_t ksgn(int32_t a) { return (a > 0) - (a < 0); }
static inline int32_t mulscale(int32_t eax, int32_t edx, int32_t ecx) { return dw((qw(eax) * qw(edx)) >> by(ecx)); }
static inline int32_t dmulscale(int32_t eax, int32_t edx, int32_t esi, int32_t edi, int32_t ecx) { return dw(((qw(eax) * qw(edx)) + (qw(esi) * qw(edi))) >> by(ecx)); }
static inline int32_t dmulscale(int32_t eax, int32_t edx, int32_t esi, int32_t edi, int32_t ecx)
{
return dw(((qw(eax) * qw(edx)) + (qw(esi) * qw(edi))) >> by(ecx));
}
void qinterpolatedown16(intptr_t bufptr, int32_t num, int32_t val, int32_t add);
void qinterpolatedown16short(intptr_t bufptr, int32_t num, int32_t val, int32_t add);
@ -46,7 +83,8 @@ void copybufreverse(const void *S, void *D, int32_t c);
static inline int32_t krecipasm(int32_t i)
{
// Ken did this
float f = (float) i; i = *(int32_t *) &f;
float f = (float)i;
i = *(int32_t *)&f;
return ((reciptable[(i >> 12) & 2047] >> (((i - 0x3f800000) >> 23) & 31)) ^ (i >> 31));
}
#endif