Author: Armin Rigo <[email protected]>
Branch:
Changeset: r44760:6e9d3f5647bb
Date: 2011-06-06 18:57 +0200
http://bitbucket.org/pypy/pypy/changeset/6e9d3f5647bb/
Log: (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
diff --git a/pypy/rlib/longlong2float.py b/pypy/rlib/longlong2float.py
--- a/pypy/rlib/longlong2float.py
+++ b/pypy/rlib/longlong2float.py
@@ -30,25 +30,16 @@
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*)≪
- for(i = 0; i < 8; i++) {
- l[i] = p[i];
- }
+ memcpy(&ll, &x, 8);
return ll;
}
"""])
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit