[pypy-dev] [pypy-commit] pypy default: (arigo, bivab) implement longlong2float and float2longlong in a way that is more close to the C standard. On ARM/32bit this code was causing a reodering of instructions that filled one of the two words with garbage

Antonio Cuni anto.cuni at gmail.com
Mon Jun 6 20:58:59 CEST 2011


On 06/06/11 18:07, bivab wrote:

>  static double pypy__longlong2float(long long x) {
> +    int i;
> +    double dd;
>      char *p = (char*)&x;
> -    return *((double*)p);
> +    char *d = (char*)ⅆ
> +    for(i = 0; i < 8; i++) {
> +        d[i] = p[i];
> +    }
> +    return dd;

speaking of portability, what about using sizeof(double)/sizeof(char) instead
of hardcoding 8?

ciao,
Anto


More information about the pypy-dev mailing list