Commits

Armin Rigo committed 6e9d3f5

(bivab, arigo)

Found here that using memcpy() is the recommend way; that makes sense.
http://blog.llvm.org/2011/05/what-every-c-programmer-should-know.html

Comments (0)

Files changed (1)

pypy/rlib/longlong2float.py

     return llval
 
 from pypy.translator.tool.cbuild import ExternalCompilationInfo
-eci = ExternalCompilationInfo(post_include_bits=["""
+eci = ExternalCompilationInfo(includes=['string.h'],
+                              post_include_bits=["""
 static double pypy__longlong2float(long long x) {
-    int i;
     double dd;
-    char *p = (char*)&x;
-    char *d = (char*)ⅆ
-    for(i = 0; i < 8; i++) {
-        d[i] = p[i];
-    }
+    memcpy(&dd, &x, 8);
     return dd;
 }
 static long long pypy__float2longlong(double x) {
-    int i;
     long long ll;
-    char *p = (char*)&x;
-    char *l = (char*)&ll;
-    for(i = 0; i < 8; i++) {
-        l[i] = p[i];
-    }
+    memcpy(&ll, &x, 8);
     return ll;
 }
 """])