Another patch by Wincent Balin (from the FS #10416 series): get rid of some warnings. PDBox now builds without any error or warning.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21819 a1c6a512-1295-4272-9138-f99709370657
diff --git a/apps/plugins/pdbox/PDa/intern/rsqrt~.c b/apps/plugins/pdbox/PDa/intern/rsqrt~.c
index 7f5a481..3f82e11 100644
--- a/apps/plugins/pdbox/PDa/intern/rsqrt~.c
+++ b/apps/plugins/pdbox/PDa/intern/rsqrt~.c
@@ -18,10 +18,16 @@
int i;
for (i = 0; i < DUMTAB1SIZE; i++)
{
+#ifdef ROCKBOX
+ union f2i f2i;
+ f2i.i = (i ? (i == DUMTAB1SIZE-1 ? DUMTAB1SIZE-2 : i) : 1)<< 23;
+ rsqrt_exptab[i] = 1./sqrt(f2i.f);
+#else /* ROCKBOX */
float f;
long l = (i ? (i == DUMTAB1SIZE-1 ? DUMTAB1SIZE-2 : i) : 1)<< 23;
*(long *)(&f) = l;
rsqrt_exptab[i] = 1./sqrt(f);
+#endif /* ROCKBOX */
}
for (i = 0; i < DUMTAB2SIZE; i++)
{
@@ -34,18 +40,42 @@
float q8_rsqrt(float f)
{
+#ifdef ROCKBOX
+ union f2i f2i;
+ if(f < 0.0)
+ return 0.0;
+ else
+ {
+ f2i.f = f;
+ return (rsqrt_exptab[(f2i.i >> 23) & 0xff] *
+ rsqrt_mantissatab[(f2i.i >> 13) & 0x3ff]);
+ }
+#else /* ROCKBOX */
long l = *(long *)(&f);
if (f < 0) return (0);
else return (rsqrt_exptab[(l >> 23) & 0xff] *
rsqrt_mantissatab[(l >> 13) & 0x3ff]);
+#endif /* ROCKBOX */
}
float q8_sqrt(float f)
{
+#ifdef ROCKBOX
+ union f2i f2i;
+ if(f < 0.0)
+ return 0.0;
+ else
+ {
+ f2i.f = f;
+ return (f * rsqrt_exptab[(f2i.i >> 23) & 0xff] *
+ rsqrt_mantissatab[(f2i.i >> 13) & 0x3ff]);
+ }
+#else /* ROCKBOX */
long l = *(long *)(&f);
if (f < 0) return (0);
else return (f * rsqrt_exptab[(l >> 23) & 0xff] *
rsqrt_mantissatab[(l >> 13) & 0x3ff]);
+#endif /* ROCKBOX */
}
/* the old names are OK unless we're in IRIX N32 */
diff --git a/apps/plugins/pdbox/PDa/intern/sqrt~.c b/apps/plugins/pdbox/PDa/intern/sqrt~.c
index d78a6c6..42e526b 100644
--- a/apps/plugins/pdbox/PDa/intern/sqrt~.c
+++ b/apps/plugins/pdbox/PDa/intern/sqrt~.c
@@ -18,10 +18,16 @@
int i;
for (i = 0; i < DUMTAB1SIZE; i++)
{
+#ifdef ROCKBOX
+ union f2i f2i;
+ f2i.i = (i ? (i == DUMTAB1SIZE-1 ? DUMTAB1SIZE-2 : i) : 1)<< 23;
+ rsqrt_exptab[i] = 1./sqrt(f2i.f);
+#else /* ROCKBOX */
float f;
long l = (i ? (i == DUMTAB1SIZE-1 ? DUMTAB1SIZE-2 : i) : 1)<< 23;
*(long *)(&f) = l;
rsqrt_exptab[i] = 1./sqrt(f);
+#endif /* ROCKBOX */
}
for (i = 0; i < DUMTAB2SIZE; i++)
{
diff --git a/apps/plugins/pdbox/PDa/src/d_soundfile.c b/apps/plugins/pdbox/PDa/src/d_soundfile.c
index 34aa105..74c41a7 100644
--- a/apps/plugins/pdbox/PDa/src/d_soundfile.c
+++ b/apps/plugins/pdbox/PDa/src/d_soundfile.c
@@ -885,8 +885,14 @@
for (j = 0, sp2 = sp, fp=vecs[i] + onset;
j < nitems; j++, sp2 += bytesperframe, fp++)
{
+#ifdef ROCKBOX
+ union f2i f2i;
+ f2i.f = *fp * normalfactor;
+ xx = f2i.i;
+#else /* ROCKBOX */
float f2 = *fp * normalfactor;
xx = *(long *)&f2;
+#endif /* ROCKBOX */
sp2[0] = (xx >> 24); sp2[1] = (xx >> 16);
sp2[2] = (xx >> 8); sp2[3] = xx;
}
@@ -896,8 +902,14 @@
for (j = 0, sp2 = sp, fp=vecs[i] + onset;
j < nitems; j++, sp2 += bytesperframe, fp++)
{
+#ifdef ROCKBOX
+ union f2i f2i;
+ f2i.f = *fp * normalfactor;
+ xx = f2i.i;
+#else /* ROCKBOX */
float f2 = *fp * normalfactor;
xx = *(long *)&f2;
+#endif /* ROCKBOX */
sp2[3] = (xx >> 24); sp2[2] = (xx >> 16);
sp2[1] = (xx >> 8); sp2[0] = xx;
}
diff --git a/apps/plugins/pdbox/pdbox.h b/apps/plugins/pdbox/pdbox.h
index e758792..2ca5bc8 100644
--- a/apps/plugins/pdbox/pdbox.h
+++ b/apps/plugins/pdbox/pdbox.h
@@ -83,6 +83,11 @@
}
div_t;
div_t div(int x, int y);
+union f2i
+{
+ float f;
+ int32_t i;
+};
void sys_findlibdir(const char* filename);
int sys_startgui(const char *guidir);