Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] C double type problem - at91sam9263
@ 2008-08-04 13:58 Richard Hardy
  2008-08-04 14:16 ` Hinko Kocevar
  0 siblings, 1 reply; 15+ messages in thread
From: Richard Hardy @ 2008-08-04 13:58 UTC (permalink / raw)
  To: buildroot

> I see it too on cris architecture. I think it is uClibc related, at
least
> 0.9.29.
> I'll try to reproduce on x86..
> IMHO only printf is buggy, otherwise doubles and floats seem to have
> correct value.

When you say "doubles and floats seem to have correct value" how are you
testing them? I have tried using gdb to look at and set double values,
but I seem to get weird results. This is what led me to try to fprintf
the double values in the first place.

e.g. if I call a function with a double parameter set to "1.0", inside
the called function, gdb reports that parameter to have a value of
35532351778122413e-313. If I try to use gdb to "set" a double value I
get a segmentation fault. Integers seem to work ok.

Thanks,
Richard.

^ permalink raw reply	[flat|nested] 15+ messages in thread
* [Buildroot] C double type problem - at91sam9263
@ 2008-08-06 13:16 Richard Hardy
  2008-08-06 13:36 ` Hinko Kocevar
  2008-08-06 16:37 ` Ulf Samuelsson
  0 siblings, 2 replies; 15+ messages in thread
From: Richard Hardy @ 2008-08-06 13:16 UTC (permalink / raw)
  To: buildroot


> -----Original Message-----
> From: Christopher Taylor [mailto:chtaylo3 at gmail.com]
> Sent: 05 August 2008 18:38
> To: Richard Hardy
> Cc: Ulf Samuelsson; buildroot at uclibc.org
> Subject: Re: [Buildroot] C double type problem - at91sam9263
> 
> Could this be related to how you are compiling the code, uclibc, and
> the OS as far as endian-ness ?  big vs middle vs little endian?
> 
> just a thought.  I've been burned by the middle-endianness on the
> arm9261.  Last I looked there were some defects in how buildroot took
> your parameters and implemented them in uClibc and the kernel (I seem
> to remeber there was a bug in uClibc that buildroot incorrectly worked
> around, but I wouldn't swear to it)
> 
> -Chris
> 

Thanks very much for everyone who has given me some hints so far. I
think that, as suggested, the fprintf problem is an output problem
(rather than storage). I am sort-of ignoring that for the time being.

However, the reason that I was trying to print out double values in the
first place was that I am getting lots of segmentation faults when I do
calculations involving int64_t and double values. 

I am using arm-linux-gcc v4.2.1., compiled on an intel Linux box to run
on an atmel at91sam9263. 

For example, one problem I found was that I was getting stack
corruptions when using "-Os" as a compiler option in (some) functions
that were being passed int64_t and double values. I fixed that by using
"-O0" instead. 

However, I am getting lots of other really weird segmentation faults
when I run the compiled program, which I am having to work around one by
one (I am trying to cross-compile and use ffmpeg which does lots of
complicated internal calculations for playing mpeg files).

Is it possible that gcc 4.2.1 is a very buggy compiler version? Can
anyone suggest whether I might be better to try another version (ideally
one that Buildroot supports), and if so, which one?

Thanks again,
Richard.

^ permalink raw reply	[flat|nested] 15+ messages in thread
* [Buildroot] C double type problem - at91sam9263
@ 2008-08-05 10:51 Richard Hardy
  2008-08-05 16:37 ` Christopher Taylor
  0 siblings, 1 reply; 15+ messages in thread
From: Richard Hardy @ 2008-08-05 10:51 UTC (permalink / raw)
  To: buildroot



> -----Original Message-----
> From: Ulf Samuelsson [mailto:ulf.samuelsson at atmel.com]
> Sent: 05 August 2008 12:21
> To: Richard Hardy; buildroot at uclibc.org
> Subject: Re: [Buildroot] C double type problem - at91sam9263
> 
> ----- Original Message -----
> 
> 	From: Richard Hardy <mailto:richardh@oakleafconsultancy.com>
> 	To: buildroot at uclibc.org
> 	Sent: Monday, August 04, 2008 12:29 PM
> 	Subject: [Buildroot] C double type problem - at91sam9263
> 
> 
> 
> 	Hi Everyone,
> 
> 	I am quite new to using buildroot and embedded linux systems in
> general. However, I have managed to use buildroot to get a (nearly)
> working system up and running for an at91sam9263 board. (kernel v
2.6.22,
> uClibc v 0.9.29)
> 
> 
> 
> 	I have one annoying problem though. One of the packages I am
> compiling from source uses C's "double" type, and this does not seem
to be
> behaving as I need it to.
> 
> 
> 
> 	I have created a simple example program:
> 
> 
> 
> 	...
> 
> 	int main (int argc, char *argv[])
> 
> 	{
> 
> 	double test;
> 
> 	test = 1;
> 
> 	fprintf(stderr, "Test double = %f.\n", test);
> 
> 	}
> 
> 
> 
> 
> 
> Should you not be using "%lf" instead of "%f" ?
> 
>    fprintf(stderr, "Test double = %lf.\n", test);
> 
>    fprintf(stderr, "Test double = %f.\n", test);
> 
> Best Regards
> Ulf Samuelsson
> 

Yes, you are right. But, it makes no difference to the output.

Best regards,
Richard.

^ permalink raw reply	[flat|nested] 15+ messages in thread
* [Buildroot] C double type problem - at91sam9263
@ 2008-08-04 13:52 Richard Hardy
  0 siblings, 0 replies; 15+ messages in thread
From: Richard Hardy @ 2008-08-04 13:52 UTC (permalink / raw)
  To: buildroot


> Do you get any warnings when compiling your test program? What happens
if
> you: test = 1.0;
> 
> I'm thinking maybe it's a casting problem.
> 
> John
> 

If I do:
test = 1.0;
fprintf(stderr, "Test double = %f.\n", test);

I get exactly the same results. i.e. it displays:
1000000

Richard.

^ permalink raw reply	[flat|nested] 15+ messages in thread
* [Buildroot] C double type problem - at91sam9263
@ 2008-08-04 10:29 Richard Hardy
  2008-08-04 12:41 ` John Voltz
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Richard Hardy @ 2008-08-04 10:29 UTC (permalink / raw)
  To: buildroot

Hi Everyone,

I am quite new to using buildroot and embedded linux systems in general.
However, I have managed to use buildroot to get a (nearly) working
system up and running for an at91sam9263 board. (kernel v 2.6.22, uClibc
v 0.9.29)

 

I have one annoying problem though. One of the packages I am compiling
from source uses C's "double" type, and this does not seem to be
behaving as I need it to.

 

I have created a simple example program:

 

...

int main (int argc, char *argv[])

{

double test;

test = 1;

fprintf(stderr, "Test double = %f.\n", test);

}

 

And the output that I see is:

 

Test double = 1000000.

 

 

I guess that this is due to one of the options, somewhere, in either the
Linux Kernel, uClibc or something else, but I don't know how to find out
which one. 

 

Can anyone point me in the right direction of where to look?

 

Thanks for your help,

 

Richard.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://busybox.net/lists/buildroot/attachments/20080804/8b13e62e/attachment.htm 

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2008-08-06 16:37 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-04 13:58 [Buildroot] C double type problem - at91sam9263 Richard Hardy
2008-08-04 14:16 ` Hinko Kocevar
2008-08-04 21:27   ` Matthew Dombroski
2008-08-05  8:31     ` Hinko Kocevar
2008-08-05  9:15       ` Hinko Kocevar
  -- strict thread matches above, loose matches on Subject: below --
2008-08-06 13:16 Richard Hardy
2008-08-06 13:36 ` Hinko Kocevar
2008-08-06 16:37 ` Ulf Samuelsson
2008-08-05 10:51 Richard Hardy
2008-08-05 16:37 ` Christopher Taylor
2008-08-04 13:52 Richard Hardy
2008-08-04 10:29 Richard Hardy
2008-08-04 12:41 ` John Voltz
2008-08-04 12:43 ` Hinko Kocevar
2008-08-05 10:20 ` Ulf Samuelsson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox