Split the initialization of the pragma.h's libdivide tables into its own function.

git-svn-id: https://svn.eduke32.com/eduke32@5362 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2015-09-27 21:18:12 +00:00
parent ed734ccd98
commit ff416551ce
3 changed files with 16 additions and 9 deletions

View file

@ -43,6 +43,7 @@ extern int32_t reciptable[2048], fpuasm;
extern libdivide_s64pad_t divtable64[DIVTABLESIZE];
extern libdivide_s32pad_t divtable32[DIVTABLESIZE];
extern void initdivtables(void);
#if defined(__arm__) || defined(LIBDIVIDE_ALWAYS)
static inline uint32_t divideu32(uint32_t n, uint32_t d)

View file

@ -8178,18 +8178,10 @@ static int32_t loadtables(void)
if (tablesloaded == 0)
{
int32_t i;
libdivide_s64_t d;
libdivide_s32_t d32;
initksqrt();
for (i=1; i<DIVTABLESIZE; i++)
{
d = libdivide_s64_gen(i);
divtable64[i].magic = d.magic, divtable64[i].more = d.more;
d32 = libdivide_s32_gen(i);
divtable32[i].magic = d32.magic, divtable32[i].more = d32.more;
}
initdivtables();
for (i=0; i<2048; i++)
reciptable[i] = divscale30(2048, i+2048);

View file

@ -13,6 +13,20 @@
libdivide_s64pad_t divtable64[DIVTABLESIZE];
libdivide_s32pad_t divtable32[DIVTABLESIZE];
void initdivtables(void)
{
libdivide_s64_t d;
libdivide_s32_t d32;
for (int i=1; i<DIVTABLESIZE; i++)
{
d = libdivide_s64_gen(i);
divtable64[i].magic = d.magic, divtable64[i].more = d.more;
d32 = libdivide_s32_gen(i);
divtable32[i].magic = d32.magic, divtable32[i].more = d32.more;
}
}
uint32_t divideu32_noinline(uint32_t n, uint32_t d) { return divideu32(n, d); }
int32_t tabledivide32_noinline(int32_t n, int32_t d) { return tabledivide32(n, d); }
int32_t tabledivide64_noinline(int64_t n, int32_t d) { return tabledivide64(n, d); }