mirror of
https://github.com/DrBeef/Raze.git
synced 2025-01-31 05:00:41 +00:00
Pragma tweaks
git-svn-id: https://svn.eduke32.com/eduke32@5784 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
74b01416d0
commit
42ece182e4
2 changed files with 20 additions and 26 deletions
|
@ -54,8 +54,7 @@ static inline uint32_t divideu32(uint32_t n, uint32_t d)
|
|||
if (d == lastd)
|
||||
goto skip;
|
||||
|
||||
lastd = d;
|
||||
udiv = libdivide_u32_gen(d);
|
||||
udiv = libdivide_u32_gen((lastd = d));
|
||||
skip:
|
||||
return libdivide_u32_do(n, &udiv);
|
||||
}
|
||||
|
@ -69,8 +68,7 @@ static inline int32_t tabledivide64(int64_t n, int32_t d)
|
|||
if (d == lastd || dptr != &sdiv)
|
||||
goto skip;
|
||||
|
||||
lastd = d;
|
||||
sdiv = libdivide_s64_gen(d);
|
||||
sdiv = libdivide_s64_gen((lastd = d));
|
||||
skip:
|
||||
return libdivide_s64_do(n, dptr);
|
||||
}
|
||||
|
@ -84,8 +82,7 @@ static inline int32_t tabledivide32(int32_t n, int32_t d)
|
|||
if (d == lastd || dptr != &sdiv)
|
||||
goto skip;
|
||||
|
||||
lastd = d;
|
||||
sdiv = libdivide_s32_gen(d);
|
||||
sdiv = libdivide_s32_gen((lastd = d));
|
||||
skip:
|
||||
return libdivide_s32_do(n, dptr);
|
||||
}
|
||||
|
@ -165,14 +162,12 @@ FORCE_INLINE int32_t sqr(int32_t a) { return a * a; }
|
|||
//
|
||||
|
||||
#define EDUKE32_SCALER_PRAGMA(a) \
|
||||
FORCE_INLINE int32_t mulscale##a(int32_t eax, int32_t edx) { return dw((qw(eax) * qw(edx)) >> by(a)); } \
|
||||
\
|
||||
FORCE_INLINE int32_t dmulscale##a(int32_t eax, int32_t edx, int32_t esi, int32_t edi) \
|
||||
FORCE_INLINE int32_t mulscale##a(int32_t eax, int32_t edx) { return dw((qw(eax) * qw(edx)) >> by(a)); } \
|
||||
FORCE_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
|
||||
|
|
|
@ -6,9 +6,8 @@
|
|||
#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 dmulscale##a(int32_t eax, int32_t edx, int32_t esi, int32_t edi) \
|
||||
FORCE_INLINE int32_t mulscale##a(int32_t eax, int32_t edx) { return dw((qw(eax) * edx) >> by(a)); } \
|
||||
FORCE_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)); \
|
||||
}
|
||||
|
@ -17,60 +16,60 @@ EDUKE32_GENERATE_PRAGMAS EDUKE32_SCALER_PRAGMA(32)
|
|||
|
||||
#undef EDUKE32_SCALER_PRAGMA
|
||||
|
||||
static inline void swapchar(void *a, void *b)
|
||||
FORCE_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)
|
||||
FORCE_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)
|
||||
FORCE_INLINE void swapshort(void *a, void *b)
|
||||
{
|
||||
int16_t const t = *((int16_t *)b);
|
||||
*((int16_t *)b) = *((int16_t *)a);
|
||||
*((int16_t *)a) = t;
|
||||
}
|
||||
static inline void swaplong(void *a, void *b)
|
||||
FORCE_INLINE void swaplong(void *a, void *b)
|
||||
{
|
||||
int32_t const t = *((int32_t *)b);
|
||||
*((int32_t *)b) = *((int32_t *)a);
|
||||
*((int32_t *)a) = t;
|
||||
}
|
||||
static inline void swapfloat(void *a, void *b)
|
||||
FORCE_INLINE void swapfloat(void *a, void *b)
|
||||
{
|
||||
float const t = *((float *)b);
|
||||
*((float *)b) = *((float *)a);
|
||||
*((float *)a) = t;
|
||||
}
|
||||
static inline void swapdouble(void *a, void *b)
|
||||
FORCE_INLINE void swapdouble(void *a, void *b)
|
||||
{
|
||||
double const t = *((double *) b);
|
||||
*((double *) b) = *((double *) a);
|
||||
*((double *) a) = t;
|
||||
}
|
||||
static inline void swap64bit(void *a, void *b)
|
||||
FORCE_INLINE void swap64bit(void *a, void *b)
|
||||
{
|
||||
uint64_t const t = *((uint64_t *)b);
|
||||
*((uint64_t *)b) = *((uint64_t *)a);
|
||||
*((uint64_t *)a) = t;
|
||||
}
|
||||
|
||||
static inline char readpixel(void *s) { return (*((char *)(s))); }
|
||||
static inline void drawpixel(void *s, char a) { *((char *)(s)) = a; }
|
||||
FORCE_INLINE char readpixel(void *s) { return (*((char *)(s))); }
|
||||
FORCE_INLINE void drawpixel(void *s, char a) { *((char *)(s)) = a; }
|
||||
|
||||
static inline int32_t klabs(int32_t a)
|
||||
FORCE_INLINE int32_t klabs(int32_t a)
|
||||
{
|
||||
const uint32_t m = a >> (sizeof(uint32_t) * CHAR_BIT - 1);
|
||||
return (a ^ m) - m;
|
||||
}
|
||||
static inline int32_t ksgn(int32_t a) { return (a > 0) - (a < 0); }
|
||||
FORCE_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)
|
||||
FORCE_INLINE int32_t mulscale(int32_t eax, int32_t edx, int32_t ecx) { return dw((qw(eax) * qw(edx)) >> by(ecx)); }
|
||||
FORCE_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));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue