[uClibc] What's up with floats? Test program inside. (mipsel, Aug 3 uClibc, gcc-3.3)
David Wuertele
dave-gnus at bfnet.com
Sat Aug 9 04:55:30 UTC 2003
Test program:
#include <stdio.h>
int main ()
{
unsigned long height1 = 120;
unsigned long height2 = 1200;
float scale1 = (float)height1 / (float)height2;
double scale2 = (double)height1 / (double)height2;
fprintf (stderr, "height1=%d, height2=%d, scale1=%f, scale2=%lf\n",
height1, height2, scale1, scale2);
return 0;
}
Compile it once with -msoft-float and once without:
$ build_mipsel/staging_dir/bin/mipsel-uclibc-g++ -msoft-float -o test1 test.cpp
$ build_mipsel/staging_dir/bin/mipsel-uclibc-g++ -o test2 test.cpp
Execute them on the target:
/ # ./test1
height1=120, height2=1200, scale1=nan, scale2=nan
/ # ./test2
height1=120, height2=1200, scale1=nan, scale2=nan
/ #
They're both wrong! What's up with the floats? Here is the output I
see on RH9.0-i386:
$ g++ test.cpp -o test
$ ./test
height1=120, height2=1200, scale1=0.100000, scale2=0.100000
I've appended my uClibc/.config file. Architecture is mipsel. I'm
using uClibc from Aug 3 and gcc-3.3.
Dave
#
# Automatically generated make config: don't edit
#
#
# Target Architecture Features and Options
#
HAVE_ELF=y
ARCH_CFLAGS="-mno-split-addresses"
UCLIBC_HAS_MMU=y
UCLIBC_HAS_FLOATS=y
# HAS_FPU is not set
UCLIBC_HAS_SOFT_FLOAT=y
DO_C99_MATH=y
WARNINGS="-Wall"
KERNEL_SOURCE="/home/dave/C/perforce/source/deschutes/buildroot-M14.0-X225/build_mipsel/roku-linux"
C_SYMBOL_PREFIX=""
HAVE_DOT_CONFIG=y
#
# General Library Settings
#
DOPIC=y
HAVE_SHARED=y
ADD_LIBGCC_FUNCTIONS=y
BUILD_UCLIBC_LDSO=y
LDSO_LDD_SUPPORT=y
UCLIBC_CTOR_DTOR=y
# UCLIBC_PROFILING is not set
UCLIBC_HAS_THREADS=y
PTHREADS_DEBUG_SUPPORT=y
UCLIBC_HAS_LFS=y
# MALLOC is not set
MALLOC_930716=y
UCLIBC_DYNAMIC_ATEXIT=y
HAS_SHADOW=y
UCLIBC_HAS_REGEX=y
UNIX98PTY_ONLY=y
ASSUME_DEVPTS=y
UCLIBC_HAS_TM_EXTENSIONS=y
#
# Networking Support
#
# UCLIBC_HAS_IPV6 is not set
UCLIBC_HAS_RPC=y
# UCLIBC_HAS_FULL_RPC is not set
#
# String and Stdio Support
#
UCLIBC_HAS_CTYPE_SIGNED=y
# UCLIBC_HAS_CTYPE_UNSAFE is not set
UCLIBC_HAS_CTYPE_CHECKED=y
# UCLIBC_HAS_CTYPE_ENFORCED is not set
UCLIBC_HAS_WCHAR=y
# UCLIBC_HAS_LOCALE is not set
# UCLIBC_HAS_SCANF_GLIBC_A_FLAG is not set
# UCLIBC_HAS_HEXADECIMAL_FLOATS is not set
# USE_OLD_VFPRINTF is not set
UCLIBC_PRINTF_SCANF_POSITIONAL_ARGS=9
UCLIBC_HAS_TZ_CACHING=y
UCLIBC_HAS_TZ_FILE=y
UCLIBC_TZ_FILE_PATH="/etc/TZ"
UCLIBC_HAS_TZ_FILE_READ_MANY=y
# UCLIBC_HAS_STDIO_BUFSIZ_NONE is not set
UCLIBC_HAS_STDIO_BUFSIZ_256=y
# UCLIBC_HAS_STDIO_BUFSIZ_512 is not set
# UCLIBC_HAS_STDIO_BUFSIZ_1024 is not set
# UCLIBC_HAS_STDIO_BUFSIZ_2048 is not set
# UCLIBC_HAS_STDIO_BUFSIZ_4096 is not set
# UCLIBC_HAS_STDIO_BUFSIZ_8192 is not set
UCLIBC_HAS_STDIO_GETC_MACRO=y
UCLIBC_HAS_STDIO_PUTC_MACRO=y
UCLIBC_HAS_STDIO_AUTO_RW_TRANSITION=y
# UCLIBC_HAS_FOPEN_LARGEFILE_MODE is not set
# UCLIBC_HAS_FOPEN_EXCLUSIVE_MODE is not set
# UCLIBC_HAS_GLIBC_CUSTOM_STREAMS is not set
UCLIBC_HAS_STDIO_BUILTIN_BUFFER_NONE=y
# UCLIBC_HAS_STDIO_BUILTIN_BUFFER_4 is not set
# UCLIBC_HAS_STDIO_BUILTIN_BUFFER_8 is not set
# UCLIBC_HAS_PRINTF_M_SPEC is not set
# UCLIBC_HAS_GLIBC_CUSTOM_PRINTF is not set
UCLIBC_HAS_ERRNO_MESSAGES=y
UCLIBC_HAS_SYS_ERRLIST=y
UCLIBC_HAS_SIGNUM_MESSAGES=y
# UCLIBC_HAS_SYS_SIGLIST is not set
#
# Library Installation Options
#
SHARED_LIB_LOADER_PATH="/lib"
DEVEL_PREFIX="/home/dave/C/perforce/source/deschutes/buildroot-M14.0-X225/build_mipsel/staging_dir"
SYSTEM_DEVEL_PREFIX="/home/dave/C/perforce/source/deschutes/buildroot-M14.0-X225/build_mipsel/staging_dir"
DEVEL_TOOL_PREFIX="/home/dave/C/perforce/source/deschutes/buildroot-M14.0-X225/build_mipsel/staging_dir/usr"
#
# uClibc hacking options
#
# DODEBUG is not set
# DOASSERTS is not set
# SUPPORT_LD_DEBUG is not set
# SUPPORT_LD_DEBUG_EARLY is not set
# UCLIBC_MJN3_ONLY is not set
More information about the uClibc
mailing list