tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] uint64_t/int64_t => double broken on ARM


From: Christian Jullien
Subject: Re: [Tinycc-devel] uint64_t/int64_t => double broken on ARM
Date: Wed, 29 Jan 2014 06:14:04 +0100

Thank you for your reply Daniel but I don’t understand if it is a libgcc or
tcc issue.

If I compile my example with gcc (which I suppose also uses libgcc), I get
the correct result:

$ gcc foo.c
$ ./a.out
d = 1.23457e+08
123456789 => 1.23457e+08
123456789 => 1.23457e+08

So libgcc looks to have the mechanisms to correctly do the job (perhaps
using a non-standard eabi function)

If I modify my test program as:

#include <stdint.h>
#include <stdio.h>

static uint64_t x1 = 123456789;
static uint32_t x2 = 123456789;
int
main()
{
        double d1 = (double)((uint32_t)(x1 & 0xFFFFFFFF)) +
                                (double)((uint32_t)(x1 >> 32)) *
(double)0xFFFFFFFF;
        printf("d = %g\n", d1);
        printf("%d => %g\n", (uint32_t)x1, d1); // x1 is not 0
}

i.e. I simulate a cast using 2 high and low 32bits parts of uint64_t, tcc
this time gives me the same result:

$ ./a.out
d = 1.23457e+08
123456789 => 1.23457e+08

My 2 possible conclusions are (fix me if I'm wrong)
- tcc do not correctly pass argument to libgcc that correctly does the job
- tcc compiler has problem to easily cast uint64_t to double, in this case,
the compiler can simulate this 64bit => double cast with my quick hack which
breaks the 64bit integer into 2x32bit integers.

Am I missing something?

Christian

-----Original Message-----
From: address@hidden
[mailto:address@hidden On Behalf Of
Daniel Glöckner
Sent: mercredi 29 janvier 2014 01:28
To: address@hidden
Subject: Re: [Tinycc-devel] uint64_t/int64_t => double broken on ARM

On Tue, Jan 28, 2014 at 06:51:53AM +0100, Christian Jullien wrote:
> Playing with clock_gettime and uint64_t/int64_t on RPi (ARM), I 
> discovered uint64_t => double conversion bug :
> 
> NOTE: tcc is compiled using --with-libgcc

The problem is that the EABI functions provided by libgcc still expect and
return doubles in integer registers, even on hardfloat systems.
This also affects casts in the other direction.

  Daniel

_______________________________________________
Tinycc-devel mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/tinycc-devel




reply via email to

[Prev in Thread] Current Thread [Next in Thread]