[ELDK] Unable to run log & log10

Wolfgang Denk wd at denx.de
Mon Jan 11 11:44:14 CET 2010


Dear =?iso-8859-1?B?ZXJzaW4g9nprYW4=?=,

In message <COL118-W18BA24C0357E1C8F9DCB53CB6D0 at phx.gbl> you wrote:
>
> Hi, i have a problem with running log, log10 ... functions on my tqm5200 module.
> i have 2.4 kernel which is compiled from source : http://git.denx.de/?p=linuxppc_2_4_devel.git;a=summary
> and i have eldk 3.1.1

Note that this is very old stuff which should not be used any more in
any recent projects. Please consider  updating  and  using  a  recent
kernel version (2.6.32+) instead...

> when i use log log sqrt or pow functions, result is always zero. i am using
> '-lm' parameter when compiling and those functions work when i compile for PC.
> is there anything that i can do?

It would certainly help if you provided your test code, the exact
commands you used to compile and run it, and the resulting output.

I am sure that you must be doing something wrong - there have never
been any problems in this area, and as expected a quick tezt is
working perfectly fine for me:

On the cross host:

-> cat log.c
#include <stdio.h>
#include <math.h>

int main (void)
{
        double x;

        for (x=0.1; x<2; x+=0.1) {
                printf("x=%.3f  log(x)=%.8f  log10(x)=%.8f\n",
                        x,
                        log(x),
                        log10(x)
                );
        }

        return 0;
}
-> echo $CROSS_COMPILE
ppc_6xx-
-> ppc_6xx-gcc -v
Reading specs from /opt/eldk-3.1.1/usr/bin/../lib/gcc-lib/ppc-linux/3.3.3/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --with-newlib --enable-languages=c,c++ --disable-libgcj --host=i386-redhat-linux --target=ppc-linux
Thread model: posix
gcc version 3.3.3 (DENX ELDK 3.1.1 3.3.3-9)
-> ppc_6xx-gcc -Wall -pedantic -o log_cross log.c -lm

On the target:

bash-2.05b# ./log_cross
x=0.100  log(x)=-2.30258509  log10(x)=-1.00000000
x=0.200  log(x)=-1.60943791  log10(x)=-0.69897000
x=0.300  log(x)=-1.20397280  log10(x)=-0.52287875
x=0.400  log(x)=-0.91629073  log10(x)=-0.39794001
x=0.500  log(x)=-0.69314718  log10(x)=-0.30103000
x=0.600  log(x)=-0.51082562  log10(x)=-0.22184875
x=0.700  log(x)=-0.35667494  log10(x)=-0.15490196
x=0.800  log(x)=-0.22314355  log10(x)=-0.09691001
x=0.900  log(x)=-0.10536052  log10(x)=-0.04575749
x=1.000  log(x)=-0.00000000  log10(x)=-0.00000000
x=1.100  log(x)=0.09531018  log10(x)=0.04139269
x=1.200  log(x)=0.18232156  log10(x)=0.07918125
x=1.300  log(x)=0.26236426  log10(x)=0.11394335
x=1.400  log(x)=0.33647224  log10(x)=0.14612804
x=1.500  log(x)=0.40546511  log10(x)=0.17609126
x=1.600  log(x)=0.47000363  log10(x)=0.20411998
x=1.700  log(x)=0.53062825  log10(x)=0.23044892
x=1.800  log(x)=0.58778666  log10(x)=0.25527251
x=1.900  log(x)=0.64185389  log10(x)=0.27875360

bash-2.05b# gcc -v
Reading specs from /usr/lib/gcc-lib/ppc-linux/3.3.3/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --disable-libgcj --build=i386-redhat-linux-gnu --host=ppc-linux --target=ppc-linux --with-newlib --with-gnu-ld --with-gnu-as --enable-languages=c,c++ --enable-multilib=no --enable-nls=yes
Thread model: posix
gcc version 3.3.3 (DENX ELDK 3.1.1 3.3.3-12)
bash-2.05b# gcc -Wall -pedantic -o log_native log.c -lm
bash-2.05b# ./log_native
x=0.100  log(x)=-2.30258509  log10(x)=-1.00000000
x=0.200  log(x)=-1.60943791  log10(x)=-0.69897000
x=0.300  log(x)=-1.20397280  log10(x)=-0.52287875
x=0.400  log(x)=-0.91629073  log10(x)=-0.39794001
x=0.500  log(x)=-0.69314718  log10(x)=-0.30103000
x=0.600  log(x)=-0.51082562  log10(x)=-0.22184875
x=0.700  log(x)=-0.35667494  log10(x)=-0.15490196
x=0.800  log(x)=-0.22314355  log10(x)=-0.09691001
x=0.900  log(x)=-0.10536052  log10(x)=-0.04575749
x=1.000  log(x)=-0.00000000  log10(x)=-0.00000000
x=1.100  log(x)=0.09531018  log10(x)=0.04139269
x=1.200  log(x)=0.18232156  log10(x)=0.07918125
x=1.300  log(x)=0.26236426  log10(x)=0.11394335
x=1.400  log(x)=0.33647224  log10(x)=0.14612804
x=1.500  log(x)=0.40546511  log10(x)=0.17609126
x=1.600  log(x)=0.47000363  log10(x)=0.20411998
x=1.700  log(x)=0.53062825  log10(x)=0.23044892
x=1.800  log(x)=0.58778666  log10(x)=0.25527251
x=1.900  log(x)=0.64185389  log10(x)=0.27875360


As you can see, both cross and native compiling indicate no problems,
the code runs without erroirs, and the resulting output looks
reasonable.

You must be doing somethign wrong.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
There's an old proverb that says just about whatever you want it to.


More information about the eldk mailing list