Re: [AD] C99 isms in test.c |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
On Sunday 09 October 2005 23:30, Evert Glebbeek wrote:
> See near the bottom of this thread for details:
> http://www.allegro.cc/forums/view_thread.php?_id=534779
>
> The last patch to test.c added some calls to sinf(), atanf(), cosf() and
> others. These are C99 functions and therefor no-no.
> The fix is simple, just remove the f prefix. I can (hopefully) submit a
> patch tomorrow.
Ok, so my bike broke down on monday and I've been working through the past
couple of evenings, so I didn't get round to it before now.
Anyway, patch attached. It fixes the C99isms, corrects a small mistake and
tries to fool clever compilers that might optimise out the unused result
of the calculation.
Evert
Index: tests/test.c
===================================================================
RCS file: /cvsroot/alleg/allegro/tests/test.c,v
retrieving revision 1.39
diff -u -r1.39 test.c
--- tests/test.c 18 Sep 2005 10:52:29 -0000 1.39
+++ tests/test.c 13 Oct 2005 20:07:18 -0000
@@ -1432,7 +1432,7 @@
ct = 0;
do {
- z = fixmul(x,y);
+ z += fixmul(x,y);
x += 1317;
y += 7143;
ct++;
@@ -1448,7 +1448,7 @@
ct = 0;
do {
- fz = fx * fy;
+ fz += fx * fy;
fx += 1317;
fy += 7143;
ct++;
@@ -1464,7 +1464,7 @@
ct = 0;
do {
- z = fixdiv(x,y);
+ z += fixdiv(x,y);
x += 1317;
y += 7143;
if (y==0)
@@ -1482,7 +1482,7 @@
ct = 0;
do {
- fz = fx / fy;
+ fz += fx / fy;
fx += 1317;
fy += 7143;
if (fy==0)
@@ -1500,7 +1500,7 @@
ct = 0;
do {
- y = fixsqrt(x);
+ y += fixsqrt(x);
x += 7361;
ct++;
if (next())
@@ -1515,7 +1515,7 @@
ct = 0;
do {
- fy = fixsqrt(fx);
+ fy += sqrt(fx);
fx += 7361;
ct++;
if (next())
@@ -1530,7 +1530,7 @@
ct = 0;
do {
- y = fixsin(x);
+ y += fixsin(x);
x += 4283;
ct++;
if (next())
@@ -1545,14 +1545,14 @@
ct = 0;
do {
- fy = sinf(fx);
+ fy += sin(fx);
fx += 4283;
ct++;
if (next())
return;
} while (tm < TIME_SPEED);
- sprintf(buf, "libc sinf(): %ld per second", ct / TIME_SPEED);
+ sprintf(buf, "libc sin(): %ld per second", ct / TIME_SPEED);
textout_ex(screen, font, buf, xoff+16, yoff+95, palette_color[15], palette_color[0]);
x = 1;
@@ -1560,7 +1560,7 @@
ct = 0;
do {
- y = fixcos(x);
+ y += fixcos(x);
x += 4283;
ct++;
if (next())
@@ -1575,7 +1575,7 @@
ct = 0;
do {
- y = fixtan(x);
+ y += fixtan(x);
x += 8372;
ct++;
if (next())
@@ -1590,14 +1590,14 @@
ct = 0;
do {
- fy = tanf(fx);
+ fy += tan(fx);
fx += 8372;
ct++;
if (next())
return;
} while (tm < TIME_SPEED);
- sprintf(buf, "libc tanf(): %ld per second", ct / TIME_SPEED);
+ sprintf(buf, "libc tan(): %ld per second", ct / TIME_SPEED);
textout_ex(screen, font, buf, xoff+16, yoff+125, palette_color[15], palette_color[0]);
x = 1;
@@ -1605,7 +1605,7 @@
ct = 0;
do {
- y = fixasin(x);
+ y += fixasin(x);
x += 5621;
x &= 0xffff;
ct++;
@@ -1621,7 +1621,7 @@
ct = 0;
do {
- y = fixacos(x);
+ y += fixacos(x);
x += 5621;
x &= 0xffff;
ct++;
@@ -1637,7 +1637,7 @@
ct = 0;
do {
- y = fixatan(x);
+ y += fixatan(x);
x += 7358;
ct++;
if (next())
@@ -1652,14 +1652,14 @@
ct = 0;
do {
- fy = atanf(fx);
+ fy += atan(fx);
fx += 7358;
ct++;
if (next())
return;
} while (tm < TIME_SPEED);
- sprintf(buf, "libc atanf(): %ld per second", ct / TIME_SPEED);
+ sprintf(buf, "libc atan(): %ld per second", ct / TIME_SPEED);
textout_ex(screen, font, buf, xoff+16, yoff+165, palette_color[15], palette_color[0]);
x = 1, y = 2;
@@ -1667,7 +1667,7 @@
ct = 0;
do {
- z = fixatan2(x, y);
+ z += fixatan2(x, y);
x += 5621;
y += 7335;
ct++;