Commits

David Schneider committed 53622aa

(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

Comments (0)

Files changed (1)

pypy/rlib/longlong2float.py

 from pypy.translator.tool.cbuild import ExternalCompilationInfo
 eci = ExternalCompilationInfo(post_include_bits=["""
 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;
 }
 static long long pypy__float2longlong(double x) {
+    int i;
+    long long ll;
     char *p = (char*)&x;
-    return *((long long*)p);
+    char *l = (char*)&ll;
+    for(i = 0; i < 8; i++) {
+        l[i] = p[i];
+    }
+    return ll;
 }
 """])