[ECOS] issue with floor()

David Brennan ecos@brennanhome.com
Wed Nov 10 04:06:00 GMT 2010


I am using a relatively recent CVS of eCos on an x86 VME target. I am
trying to get an existing application working, and I stumbled across
an unusual result.

The code called floor() with a value of 0.048000000000000001. the
correct return value should have been 0.0.

Single stepping through the "bit twiddling" looked like it was
pursuing the correct code path, but at this point, somthing went
wrong.

97	                if(huge+x>0.0) {/* return 0*sign(x) if |x|<1 */
(gdb) s
98	                    if(i0>=0) {i0=i1=0;}
(gdb) p i0
$4 = 8
(gdb) s
131	}
(gdb) info locals
i0 = 8
j0 = -5
i = 1067989024
x = 0.048000000000000001
(gdb) li
126	            }
127	        }
128	        CYG_LIBM_HI(x) = i0;
129	        CYG_LIBM_LO(x) = i1;
130	        return x;
131	}
132	
133	#endif // ifdef CYGPKG_LIBM
134	
135	// EOF s_floor.c

It appears that the code did not run line 98 correctly. So I took a
step back. And ran the floor tests:

(gdb) c
Continuing.
INFO:<Starting tests from testcase
/opt/ecos-old/eCosIRL/OS/ecos/packages/language/c/libm/current/tests/vectors/floor.c
for Math library floor() function>
INFO:<Still crunching, please wait...>
Vector #1
FAIL:<Result out of tolerance> Line: 477, File:
/opt/ecos-old/eCosIRL/OS/ecos/packages/language/c/libm/current/tests/vectors/vector_support.h
Vector #2
FAIL:<Result out of tolerance> Line: 477, File:
/opt/ecos-old/eCosIRL/OS/ecos/packages/language/c/libm/current/tests/vectors/vector_support.h
Vector #5
FAIL:<Result out of tolerance> Line: 477, File:
/opt/ecos-old/eCosIRL/OS/ecos/packages/language/c/libm/current/tests/vectors/vector_support.h
Vector #7
FAIL:<Result out of tolerance> Line: 477, File:
/opt/ecos-old/eCosIRL/OS/ecos/packages/language/c/libm/current/tests/vectors/vector_support.h
Vector #8
FAIL:<Result out of tolerance> Line: 477, File:
/opt/ecos-old/eCosIRL/OS/ecos/packages/language/c/libm/current/tests/vectors/vector_support.h
Vector #9
FAIL:<Result out of tolerance> Line: 477, File:
/opt/ecos-old/eCosIRL/OS/ecos/packages/language/c/libm/current/tests/vectors/vector_support.h
Vector #10
FAIL:<Result out of tolerance> Line: 477, File:
/opt/ecos-old/eCosIRL/OS/ecos/packages/language/c/libm/current/tests/vectors/vector_support.h
Vector #11
FAIL:<Result out of tolerance> Line: 477, File:
/opt/ecos-old/eCosIRL/OS/ecos/packages/language/c/libm/current/tests/vectors/vector_support.h
Vector #14
FAIL:<Result out of tolerance> Line: 477, File:
/opt/ecos-old/eCosIRL/OS/ecos/packages/language/c/libm/current/tests/vectors/vector_support.h
Vector #17
FAIL:<Result out of tolerance> Line: 477, File:
/opt/ecos-old/eCosIRL/OS/ecos/packages/language/c/libm/current/tests/vectors/vector_support.h
FAIL:<floor() failed tests> Line: 92, File:
/opt/ecos-old/eCosIRL/OS/ecos/packages/language/c/libm/current/tests/vectors/floor.c
EXIT:<Finished tests from testcase
/opt/ecos-old/eCosIRL/OS/ecos/packages/language/c/libm/current/tests/vectors/floor.c
for Math library floor() function>

I am using a compiler that I built (so that is most likely the
problem). I am using OS X for my host, and there are not pre-built
binaries for that. Here is the version information for my gcc:

david$ i386-elf-gcc -v
Using built-in specs.
Target: i386-elf
Configured with: /src/gcc-4.4.5/configure --target=i386-elf
--prefix=/gnutools --enable-languages=c,c++ --with-gnu-as
--with-gnu-ld --with-newlib
--with-gxx-include-dir=/gnutools/i386-elf/include
--disable-__cxa_atexit --disable-hosted-libstdcxx --enable-threads -v
Thread model: single
gcc version 4.4.5 (GCC)

Is there something obvious that I did wrong?

For reference here is the build line for tests/floor

i386-elf-gcc -c  -I/opt/ramHigh/install/include
-I/opt/ecos-old/eCosIRL/OS/ecos/packages/language/c/libm/current
-I/opt/ecos-old/eCosIRL/OS/ecos/packages/language/c/libm/current/src
-I/opt/ecos-old/eCosIRL/OS/ecos/packages/language/c/libm/current/tests
-I. -I/opt/ecos-old/eCosIRL/OS/ecos/packages/language/c/libm/current/tests/vectors/
-finline-limit=7000 -Wall -Wpointer-arith -Wstrict-prototypes -Winline
-Wundef  -g -O2 -ffunction-sections -fdata-sections  -fno-exceptions
--param inline-unit-growth=1000 --param large-function-growth=1000
-Wp,-MD,tests/vectors/floor.tmp -o tests/vectors/floor.o
/opt/ecos-old/eCosIRL/OS/ecos/packages/language/c/libm/current/tests/vectors/floor.c
i386-elf-gcc -L/opt/ramHigh/install/lib -Ttarget.ld -o
/opt/ramHigh/install/tests/language/c/libm/current/tests/vectors/floor
tests/vectors/floor.o -g -nostdlib -Wl,--gc-sections -Wl,-static


Any help would be greatly appreciated.

David Brennan

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss



More information about the Ecos-discuss mailing list