[pypy-commit] pypy default: Quite a lot of trivial (hmm, not really) changes merged in from win64.
ctismer
noreply at buildbot.pypy.org
Wed Mar 14 06:54:07 CET 2012
Author: Christian Tismer <tismer at stackless.com>
Branch:
Changeset: r53533:6cdf4341d56c
Date: 2012-03-13 22:48 -0700
http://bitbucket.org/pypy/pypy/changeset/6cdf4341d56c/
Log: Quite a lot of trivial (hmm, not really) changes merged in from
win64. Hopefully I did not break too much. Anyway, it still builds.
diff --git a/pypy/jit/backend/test/runner_test.py b/pypy/jit/backend/test/runner_test.py
--- a/pypy/jit/backend/test/runner_test.py
+++ b/pypy/jit/backend/test/runner_test.py
@@ -16,7 +16,7 @@
from pypy.rpython.annlowlevel import llhelper
from pypy.rpython.llinterp import LLException
from pypy.jit.codewriter import heaptracker, longlong
-from pypy.rlib.rarithmetic import intmask
+from pypy.rlib.rarithmetic import intmask, is_valid_int
from pypy.jit.backend.detect_cpu import autodetect_main_model_and_size
def boxfloat(x):
@@ -493,7 +493,7 @@
if cpu.supports_floats:
def func(f, i):
assert isinstance(f, float)
- assert isinstance(i, int)
+ assert is_valid_int(i)
return f - float(i)
FPTR = self.Ptr(self.FuncType([lltype.Float, lltype.Signed],
lltype.Float))
diff --git a/pypy/jit/backend/x86/test/conftest.py b/pypy/jit/backend/x86/test/conftest.py
--- a/pypy/jit/backend/x86/test/conftest.py
+++ b/pypy/jit/backend/x86/test/conftest.py
@@ -1,4 +1,4 @@
-import py
+import py, os
from pypy.jit.backend import detect_cpu
cpu = detect_cpu.autodetect()
@@ -6,5 +6,7 @@
if cpu not in ('x86', 'x86_64'):
py.test.skip("x86/x86_64 tests skipped: cpu is %r" % (cpu,))
if cpu == 'x86_64':
+ if os.name == "nt":
+ py.test.skip("Windows cannot allocate non-reserved memory")
from pypy.rpython.lltypesystem import ll2ctypes
ll2ctypes.do_allocation_in_far_regions()
diff --git a/pypy/jit/backend/x86/tool/viewcode.py b/pypy/jit/backend/x86/tool/viewcode.py
--- a/pypy/jit/backend/x86/tool/viewcode.py
+++ b/pypy/jit/backend/x86/tool/viewcode.py
@@ -34,7 +34,7 @@
# I am porting it in a lazy fashion... See py-utils/xam.py
if sys.platform == "win32":
- XXX # lots more in Psyco
+ pass # lots more in Psyco
def machine_code_dump(data, originaddr, backend_name, label_list=None):
objdump_backend_option = {
diff --git a/pypy/jit/codewriter/test/test_longlong.py b/pypy/jit/codewriter/test/test_longlong.py
--- a/pypy/jit/codewriter/test/test_longlong.py
+++ b/pypy/jit/codewriter/test/test_longlong.py
@@ -1,6 +1,6 @@
import py, sys
-from pypy.rlib.rarithmetic import r_longlong, intmask
+from pypy.rlib.rarithmetic import r_longlong, intmask, is_valid_int
from pypy.objspace.flow.model import SpaceOperation, Variable, Constant
from pypy.objspace.flow.model import Block, Link
from pypy.translator.unsimplify import varoftype
@@ -32,7 +32,7 @@
def test_functions():
xll = longlong.getfloatstorage(3.5)
assert longlong.getrealfloat(xll) == 3.5
- assert isinstance(longlong.gethash(xll), int)
+ assert is_valid_int(longlong.gethash(xll))
class TestLongLong:
diff --git a/pypy/jit/metainterp/executor.py b/pypy/jit/metainterp/executor.py
--- a/pypy/jit/metainterp/executor.py
+++ b/pypy/jit/metainterp/executor.py
@@ -2,7 +2,7 @@
"""
from pypy.rpython.lltypesystem import lltype, rstr
-from pypy.rlib.rarithmetic import ovfcheck, r_longlong
+from pypy.rlib.rarithmetic import ovfcheck, r_longlong, is_valid_int
from pypy.rlib.rtimer import read_timestamp
from pypy.rlib.unroll import unrolling_iterable
from pypy.jit.metainterp.history import BoxInt, BoxPtr, BoxFloat, check_descr
@@ -248,7 +248,7 @@
def do_read_timestamp(cpu, _):
x = read_timestamp()
if longlong.is_64_bit:
- assert isinstance(x, int) # 64-bit
+ assert is_valid_int(x) # 64-bit
return BoxInt(x)
else:
assert isinstance(x, r_longlong) # 32-bit
diff --git a/pypy/jit/metainterp/history.py b/pypy/jit/metainterp/history.py
--- a/pypy/jit/metainterp/history.py
+++ b/pypy/jit/metainterp/history.py
@@ -5,6 +5,7 @@
from pypy.rlib.objectmodel import we_are_translated, Symbolic
from pypy.rlib.objectmodel import compute_unique_id
from pypy.rlib.rarithmetic import r_int64, is_valid_int
+
from pypy.conftest import option
from pypy.jit.metainterp.resoperation import ResOperation, rop
@@ -448,7 +449,7 @@
def __init__(self, value=0):
if not we_are_translated():
- if isinstance(value, int):
+ if is_valid_int(value):
value = int(value) # bool -> int
else:
assert isinstance(value, Symbolic)
diff --git a/pypy/jit/metainterp/optimizeopt/vstring.py b/pypy/jit/metainterp/optimizeopt/vstring.py
--- a/pypy/jit/metainterp/optimizeopt/vstring.py
+++ b/pypy/jit/metainterp/optimizeopt/vstring.py
@@ -10,6 +10,8 @@
from pypy.rlib.unroll import unrolling_iterable
from pypy.rpython import annlowlevel
from pypy.rpython.lltypesystem import lltype, rstr
+from pypy.rlib.rarithmetic import is_valid_int
+
class StrOrUnicode(object):
@@ -730,7 +732,7 @@
for name in dir(OptString):
if name.startswith(prefix):
value = getattr(EffectInfo, 'OS_' + name[len(prefix):])
- assert isinstance(value, int) and value != 0
+ assert is_valid_int(value) and value != 0
result.append((value, getattr(OptString, name)))
return unrolling_iterable(result)
opt_call_oopspec_ops = _findall_call_oopspec()
diff --git a/pypy/jit/metainterp/test/test_ajit.py b/pypy/jit/metainterp/test/test_ajit.py
--- a/pypy/jit/metainterp/test/test_ajit.py
+++ b/pypy/jit/metainterp/test/test_ajit.py
@@ -14,7 +14,7 @@
loop_invariant, elidable, promote, jit_debug, assert_green,
AssertGreenFailed, unroll_safe, current_trace_length, look_inside_iff,
isconstant, isvirtual, promote_string, set_param, record_known_class)
-from pypy.rlib.rarithmetic import ovfcheck
+from pypy.rlib.rarithmetic import ovfcheck, is_valid_int
from pypy.rpython.lltypesystem import lltype, llmemory, rffi
from pypy.rpython.ootypesystem import ootype
@@ -2296,7 +2296,7 @@
self.check_resops(int_rshift=3)
bigval = 1
- while (bigval << 3).__class__ is int:
+ while is_valid_int(bigval << 3):
bigval = bigval << 1
assert self.meta_interp(f, [bigval, 5]) == 0
@@ -2341,7 +2341,7 @@
self.check_resops(int_rshift=3)
bigval = 1
- while (bigval << 3).__class__ is int:
+ while is_valid_int(bigval << 3):
bigval = bigval << 1
assert self.meta_interp(f, [bigval, 5]) == 0
diff --git a/pypy/module/_ffi/test/test__ffi.py b/pypy/module/_ffi/test/test__ffi.py
--- a/pypy/module/_ffi/test/test__ffi.py
+++ b/pypy/module/_ffi/test/test__ffi.py
@@ -4,6 +4,8 @@
from pypy.module._rawffi.interp_rawffi import TYPEMAP
from pypy.module._rawffi.tracker import Tracker
from pypy.translator.platform import platform
+from pypy.rlib.rarithmetic import is_valid_int
+
import os, sys, py
@@ -185,7 +187,7 @@
types.void)
assert get_dummy() == 0
ptr = get_dummy_ptr()
- assert type(ptr) in (int, long)
+ assert is_valid_int(ptr)
ptr2 = MyPointerWrapper(ptr)
set_val_to_ptr(ptr2, 123)
assert get_dummy() == 123
diff --git a/pypy/module/_multiprocessing/test/test_semaphore.py b/pypy/module/_multiprocessing/test/test_semaphore.py
--- a/pypy/module/_multiprocessing/test/test_semaphore.py
+++ b/pypy/module/_multiprocessing/test/test_semaphore.py
@@ -1,6 +1,8 @@
from pypy.conftest import gettestobjspace
from pypy.module._multiprocessing.interp_semaphore import (
RECURSIVE_MUTEX, SEMAPHORE)
+from pypy.rlib.rarithmetic import is_valid_int
+
class AppTestSemaphore:
def setup_class(cls):
@@ -20,7 +22,7 @@
sem = SemLock(kind, value, maxvalue)
assert sem.kind == kind
assert sem.maxvalue == maxvalue
- assert isinstance(sem.handle, (int, long))
+ assert is_valid_int(sem.handle)
assert sem._count() == 0
if sys.platform == 'darwin':
diff --git a/pypy/module/_ssl/test/test_ssl.py b/pypy/module/_ssl/test/test_ssl.py
--- a/pypy/module/_ssl/test/test_ssl.py
+++ b/pypy/module/_ssl/test/test_ssl.py
@@ -1,6 +1,8 @@
from pypy.conftest import gettestobjspace
import os
import py
+from pypy.rlib.rarithmetic import is_valid_int
+
class AppTestSSL:
def setup_class(cls):
@@ -29,7 +31,7 @@
assert isinstance(_ssl.SSL_ERROR_EOF, int)
assert isinstance(_ssl.SSL_ERROR_INVALID_ERROR_CODE, int)
- assert isinstance(_ssl.OPENSSL_VERSION_NUMBER, (int, long))
+ assert is_valid_int(_ssl.OPENSSL_VERSION_NUMBER)
assert isinstance(_ssl.OPENSSL_VERSION_INFO, tuple)
assert len(_ssl.OPENSSL_VERSION_INFO) == 5
assert isinstance(_ssl.OPENSSL_VERSION, str)
diff --git a/pypy/rpython/memory/gctransform/asmgcroot.py b/pypy/rpython/memory/gctransform/asmgcroot.py
--- a/pypy/rpython/memory/gctransform/asmgcroot.py
+++ b/pypy/rpython/memory/gctransform/asmgcroot.py
@@ -533,10 +533,11 @@
# The initial gcmap table contains addresses to a JMP
# instruction that jumps indirectly to the real code.
# Replace them with the target addresses.
+ assert rffi.SIGNEDP is rffi.LONGP, "win64 support missing"
while start < end:
code = rffi.cast(rffi.CCHARP, start.address[0])[0]
if code == '\xe9': # jmp
- rel32 = rffi.cast(rffi.LONGP, start.address[0]+1)[0]
+ rel32 = rffi.cast(rffi.SIGNEDP, start.address[0]+1)[0]
target = start.address[0] + (rel32 + 5)
start.address[0] = target
start += arrayitemsize
diff --git a/pypy/rpython/rint.py b/pypy/rpython/rint.py
--- a/pypy/rpython/rint.py
+++ b/pypy/rpython/rint.py
@@ -7,7 +7,8 @@
SignedLongLong, build_number, Number, cast_primitive, typeOf
from pypy.rpython.rmodel import IntegerRepr, inputconst
from pypy.rpython.robject import PyObjRepr, pyobj_repr
-from pypy.rlib.rarithmetic import intmask, r_int, r_uint, r_ulonglong, r_longlong
+from pypy.rlib.rarithmetic import intmask, r_int, r_uint, r_ulonglong, \
+ r_longlong, is_emulated_long
from pypy.rpython.error import TyperError, MissingRTypeOperation
from pypy.rpython.rmodel import log
from pypy.rlib import objectmodel
@@ -437,6 +438,11 @@
Unsigned: ('RPyLong_AsUnsignedLong', lambda pyo: r_uint(pyo._obj.value)),
Signed: ('PyInt_AsLong', lambda pyo: int(pyo._obj.value))
}
+if is_emulated_long: # win64
+ py_to_ll_conversion_functions.update( {
+ Unsigned: ('RPyLong_AsUnsignedLongLong', lambda pyo: r_ulonglong(pyo._obj.value)),
+ Signed: ('RPyLong_AsLongLong', lambda pyo: r_longlong(pyo._obj.value)),
+ } )
ll_to_py_conversion_functions = {
UnsignedLongLong: ('PyLong_FromUnsignedLongLong', lambda i: pyobjectptr(i)),
@@ -444,6 +450,11 @@
Unsigned: ('PyLong_FromUnsignedLong', lambda i: pyobjectptr(i)),
Signed: ('PyInt_FromLong', lambda i: pyobjectptr(i)),
}
+if is_emulated_long: # win64
+ ll_to_py_conversion_functions.update( {
+ Unsigned: ('PyLong_FromUnsignedLongLong', lambda i: pyobjectptr(i)),
+ Signed: ('PyLong_FromLongLong', lambda i: pyobjectptr(i)),
+ } )
class __extend__(pairtype(PyObjRepr, IntegerRepr)):
diff --git a/pypy/rpython/rmodel.py b/pypy/rpython/rmodel.py
--- a/pypy/rpython/rmodel.py
+++ b/pypy/rpython/rmodel.py
@@ -339,11 +339,11 @@
def _get_opprefix(self):
if self._opprefix is None:
- raise TyperError("arithmetic not supported on %r" %
+ raise TyperError("arithmetic not supported on %r, it's size is too small" %
self.lowleveltype)
return self._opprefix
- opprefix =property(_get_opprefix)
+ opprefix = property(_get_opprefix)
class BoolRepr(IntegerRepr):
lowleveltype = Bool
diff --git a/pypy/translator/c/primitive.py b/pypy/translator/c/primitive.py
--- a/pypy/translator/c/primitive.py
+++ b/pypy/translator/c/primitive.py
@@ -1,7 +1,7 @@
import sys
from pypy.rlib.objectmodel import Symbolic, ComputedIntSymbolic
from pypy.rlib.objectmodel import CDefinedIntSymbolic
-from pypy.rlib.rarithmetic import r_longlong
+from pypy.rlib.rarithmetic import r_longlong, is_emulated_long
from pypy.rlib.rfloat import isinf, isnan
from pypy.rpython.lltypesystem.lltype import *
from pypy.rpython.lltypesystem import rffi, llgroup
@@ -16,6 +16,15 @@
#
# Primitives
+# win64: we need different constants, since we emulate 64 bit long.
+# this function simply replaces 'L' by 'LL' in a format string
+if is_emulated_long:
+ def lll(fmt):
+ return fmt.replace('L', 'LL')
+else:
+ def lll(fmt):
+ return fmt
+
def name_signed(value, db):
if isinstance(value, Symbolic):
if isinstance(value, FieldOffset):
@@ -61,22 +70,22 @@
elif isinstance(value, llgroup.CombinedSymbolic):
name = name_small_integer(value.lowpart, db)
assert (value.rest & value.MASK) == 0
- return '(%s+%dL)' % (name, value.rest)
+ return lll('(%s+%dL)') % (name, value.rest)
elif isinstance(value, AddressAsInt):
- return '((long)%s)' % name_address(value.adr, db)
+ return '((Signed)%s)' % name_address(value.adr, db)
else:
raise Exception("unimplemented symbolic %r"%value)
if value is None:
assert not db.completed
return None
if value == -sys.maxint-1: # blame C
- return '(-%dL-1L)' % sys.maxint
+ return lll('(-%dL-1L)') % sys.maxint
else:
- return '%dL' % value
+ return lll('%dL') % value
def name_unsigned(value, db):
assert value >= 0
- return '%dUL' % value
+ return lll('%dUL') % value
def name_unsignedlonglong(value, db):
assert value >= 0
@@ -184,6 +193,7 @@
# On 64 bit machines, SignedLongLong and Signed are the same, so the
# order matters, because we want the Signed implementation.
+# (some entries collapse during dict creation)
PrimitiveName = {
SignedLongLong: name_signedlonglong,
Signed: name_signed,
@@ -202,9 +212,9 @@
PrimitiveType = {
SignedLongLong: 'long long @',
- Signed: 'long @',
+ Signed: 'Signed @',
UnsignedLongLong: 'unsigned long long @',
- Unsigned: 'unsigned long @',
+ Unsigned: 'Unsigned @',
Float: 'double @',
SingleFloat: 'float @',
LongFloat: 'long double @',
diff --git a/pypy/translator/c/src/address.h b/pypy/translator/c/src/address.h
--- a/pypy/translator/c/src/address.h
+++ b/pypy/translator/c/src/address.h
@@ -16,5 +16,5 @@
#define OP_ADR_LT(x,y,r) r = ((x) < (y))
#define OP_ADR_GE(x,y,r) r = ((x) >= (y))
-#define OP_CAST_ADR_TO_INT(x, mode, r) r = ((long)x)
+#define OP_CAST_ADR_TO_INT(x, mode, r) r = ((Signed)x)
#define OP_CAST_INT_TO_ADR(x, r) r = ((void *)(x))
diff --git a/pypy/translator/c/src/asm_gcc_x86_64.h b/pypy/translator/c/src/asm_gcc_x86_64.h
--- a/pypy/translator/c/src/asm_gcc_x86_64.h
+++ b/pypy/translator/c/src/asm_gcc_x86_64.h
@@ -2,7 +2,7 @@
*/
#define READ_TIMESTAMP(val) do { \
- unsigned long _rax, _rdx; \
+ Unsigned _rax, _rdx; \
asm volatile("rdtsc" : "=a"(_rax), "=d"(_rdx)); \
val = (_rdx << 32) | _rax; \
} while (0)
diff --git a/pypy/translator/c/src/commondefs.h b/pypy/translator/c/src/commondefs.h
--- a/pypy/translator/c/src/commondefs.h
+++ b/pypy/translator/c/src/commondefs.h
@@ -11,6 +11,21 @@
In particular, Win64 is not supported because it has sizeof(long) == 4.
To fix this, find and review all the places that cast a pointer to a long.
+
+ Update:
+ We are trying to lift this restriction for Win64:
+
+ Win64 int long long long void*
+ --64-bit-- 32 32 64 64
+
+ The migration to this platform is complicated and tedious, because
+ PyPy assumes that a void* fits into a long. Therefore, the created PyPy
+ will (first) have a 64 bit int type. The dependency of sys.maxint must
+ be removed in very many places, and the distinction between Python int
+ and long must be changed in explicit range checks.
+
+ This is work in progress with first successes.
+
*/
#include <limits.h>
@@ -54,16 +69,32 @@
/******************** 64-bit support ********************/
#else
-# if LONG_MAX != 9223372036854775807L
-# error "error in LONG_MAX (64-bit sources but a 32-bit compiler?)"
+# ifndef _WIN64
+# if LONG_MAX != 9223372036854775807L
+# error "error in LONG_MAX (64-bit sources but a 32-bit compiler?)"
+# endif
+# if LONG_MIN != -9223372036854775807L-1L
+# error "unsupported value for LONG_MIN"
+# endif
+
+# define SIZEOF_INT 4
+# define SIZEOF_LONG 8
+# define SIZEOF_LONG_LONG 8
+
+/******************** Win-64 support ********************/
+# else
+# if LONG_MAX != 2147483647L
+# error "error in LONG_MAX (64-bit sources but incompatible compiler?)"
+# endif
+# if LONG_MIN != -2147483647L-1L
+# error "unsupported value for LONG_MIN"
+# endif
+
+# define SIZEOF_INT 4
+# define SIZEOF_LONG 4
+# define SIZEOF_LONG_LONG 8
+
# endif
-# if LONG_MIN != -9223372036854775807L-1L
-# error "unsupported value for LONG_MIN"
-# endif
-
-# define SIZEOF_INT 4
-# define SIZEOF_LONG 8
-# define SIZEOF_LONG_LONG 8
#endif
diff --git a/pypy/translator/c/src/float.h b/pypy/translator/c/src/float.h
--- a/pypy/translator/c/src/float.h
+++ b/pypy/translator/c/src/float.h
@@ -31,8 +31,8 @@
/*** conversions ***/
-#define OP_CAST_FLOAT_TO_INT(x,r) r = (long)(x)
-#define OP_CAST_FLOAT_TO_UINT(x,r) r = (unsigned long)(x)
+#define OP_CAST_FLOAT_TO_INT(x,r) r = (Signed)(x)
+#define OP_CAST_FLOAT_TO_UINT(x,r) r = (Unsigned)(x)
#define OP_CAST_INT_TO_FLOAT(x,r) r = (double)(x)
#define OP_CAST_UINT_TO_FLOAT(x,r) r = (double)(x)
#define OP_CAST_LONGLONG_TO_FLOAT(x,r) r = (double)(x)
diff --git a/pypy/translator/c/src/int.h b/pypy/translator/c/src/int.h
--- a/pypy/translator/c/src/int.h
+++ b/pypy/translator/c/src/int.h
@@ -5,18 +5,31 @@
/*** unary operations ***/
+/************ win64 support:
+
+ 'Signed' must be defined as
+
+ __int64 in case of win64
+ long in all other cases
+
+ 'SIGNED_MIN' must be defined as
+
+ LLONG_MIN in case of win64
+ LONG_MIN in all other cases
+ */
+
#define OP_INT_IS_TRUE(x,r) r = ((x) != 0)
#define OP_INT_INVERT(x,r) r = ~(x)
#define OP_INT_NEG(x,r) r = -(x)
#define OP_INT_NEG_OVF(x,r) \
- if ((x) == LONG_MIN) FAIL_OVF("integer negate"); \
+ if ((x) == SIGNED_MIN) FAIL_OVF("integer negate"); \
OP_INT_NEG(x,r)
#define OP_INT_ABS(x,r) r = (x) >= 0 ? x : -(x)
#define OP_INT_ABS_OVF(x,r) \
- if ((x) == LONG_MIN) FAIL_OVF("integer absolute"); \
+ if ((x) == SIGNED_MIN) FAIL_OVF("integer absolute"); \
OP_INT_ABS(x,r)
/*** binary operations ***/
@@ -33,8 +46,8 @@
for the case of a == 0 (both subtractions are then constant-folded).
Note that the following line only works if a <= c in the first place,
which we assume is true. */
-#define OP_INT_BETWEEN(a,b,c,r) r = (((unsigned long)b - (unsigned long)a) \
- < ((unsigned long)c - (unsigned long)a))
+#define OP_INT_BETWEEN(a,b,c,r) r = (((Unsigned)b - (Unsigned)a) \
+ < ((Unsigned)c - (Unsigned)a))
/* addition, subtraction */
@@ -42,22 +55,22 @@
/* cast to avoid undefined behaviour on overflow */
#define OP_INT_ADD_OVF(x,y,r) \
- r = (long)((unsigned long)x + y); \
+ r = (Signed)((Unsigned)x + y); \
if ((r^x) < 0 && (r^y) < 0) FAIL_OVF("integer addition")
#define OP_INT_ADD_NONNEG_OVF(x,y,r) /* y can be assumed >= 0 */ \
- r = (long)((unsigned long)x + y); \
+ r = (Signed)((Unsigned)x + y); \
if ((r&~x) < 0) FAIL_OVF("integer addition")
#define OP_INT_SUB(x,y,r) r = (x) - (y)
#define OP_INT_SUB_OVF(x,y,r) \
- r = (long)((unsigned long)x - y); \
+ r = (Signed)((Unsigned)x - y); \
if ((r^x) < 0 && (r^~y) < 0) FAIL_OVF("integer subtraction")
#define OP_INT_MUL(x,y,r) r = (x) * (y)
-#if SIZEOF_LONG * 2 <= SIZEOF_LONG_LONG
+#if SIZEOF_LONG * 2 <= SIZEOF_LONG_LONG && !defined(_WIN64)
#define OP_INT_MUL_OVF(x,y,r) \
{ \
long long _lr = (long long)x * y; \
@@ -78,7 +91,7 @@
#define OP_INT_RSHIFT(x,y,r) CHECK_SHIFT_RANGE(y, PYPY_LONG_BIT); \
- r = Py_ARITHMETIC_RIGHT_SHIFT(long, x, (y))
+ r = Py_ARITHMETIC_RIGHT_SHIFT(Signed, x, (y))
#define OP_UINT_RSHIFT(x,y,r) CHECK_SHIFT_RANGE(y, PYPY_LONG_BIT); \
r = (x) >> (y)
#define OP_LLONG_RSHIFT(x,y,r) CHECK_SHIFT_RANGE(y, PYPY_LONGLONG_BIT); \
@@ -98,7 +111,7 @@
#define OP_INT_LSHIFT_OVF(x,y,r) \
OP_INT_LSHIFT(x,y,r); \
- if ((x) != Py_ARITHMETIC_RIGHT_SHIFT(long, r, (y))) \
+ if ((x) != Py_ARITHMETIC_RIGHT_SHIFT(Signed, r, (y))) \
FAIL_OVF("x<<y losing bits or changing sign")
/* floor division */
@@ -109,7 +122,7 @@
#define OP_ULLONG_FLOORDIV(x,y,r) r = (x) / (y)
#define OP_INT_FLOORDIV_OVF(x,y,r) \
- if ((y) == -1 && (x) == LONG_MIN) \
+ if ((y) == -1 && (x) == SIGNED_MIN) \
{ FAIL_OVF("integer division"); r=0; } \
else \
r = (x) / (y)
@@ -149,7 +162,7 @@
#define OP_ULLONG_MOD(x,y,r) r = (x) % (y)
#define OP_INT_MOD_OVF(x,y,r) \
- if ((y) == -1 && (x) == LONG_MIN) \
+ if ((y) == -1 && (x) == SIGNED_MIN) \
{ FAIL_OVF("integer modulo"); r=0; } \
else \
r = (x) % (y)
@@ -188,18 +201,18 @@
/*** conversions ***/
-#define OP_CAST_BOOL_TO_INT(x,r) r = (long)(x)
-#define OP_CAST_BOOL_TO_UINT(x,r) r = (unsigned long)(x)
-#define OP_CAST_UINT_TO_INT(x,r) r = (long)(x)
-#define OP_CAST_INT_TO_UINT(x,r) r = (unsigned long)(x)
+#define OP_CAST_BOOL_TO_INT(x,r) r = (Signed)(x)
+#define OP_CAST_BOOL_TO_UINT(x,r) r = (Unsigned)(x)
+#define OP_CAST_UINT_TO_INT(x,r) r = (Signed)(x)
+#define OP_CAST_INT_TO_UINT(x,r) r = (Unsigned)(x)
#define OP_CAST_INT_TO_LONGLONG(x,r) r = (long long)(x)
-#define OP_CAST_CHAR_TO_INT(x,r) r = (long)((unsigned char)(x))
+#define OP_CAST_CHAR_TO_INT(x,r) r = (Signed)((unsigned char)(x))
#define OP_CAST_INT_TO_CHAR(x,r) r = (char)(x)
-#define OP_CAST_PTR_TO_INT(x,r) r = (long)(x) /* XXX */
+#define OP_CAST_PTR_TO_INT(x,r) r = (Signed)(x) /* XXX */
-#define OP_TRUNCATE_LONGLONG_TO_INT(x,r) r = (long)(x)
+#define OP_TRUNCATE_LONGLONG_TO_INT(x,r) r = (Signed)(x)
-#define OP_CAST_UNICHAR_TO_INT(x,r) r = (long)((unsigned long)(x)) /*?*/
+#define OP_CAST_UNICHAR_TO_INT(x,r) r = (Signed)((Unsigned)(x)) /*?*/
#define OP_CAST_INT_TO_UNICHAR(x,r) r = (unsigned int)(x)
/* bool operations */
diff --git a/pypy/translator/c/src/main.h b/pypy/translator/c/src/main.h
--- a/pypy/translator/c/src/main.h
+++ b/pypy/translator/c/src/main.h
@@ -41,11 +41,14 @@
#endif
instrument_setup();
+#ifndef MS_WINDOWS
+ /* this message does no longer apply to win64 :-) */
if (sizeof(void*) != SIZEOF_LONG) {
errmsg = "only support platforms where sizeof(void*) == sizeof(long),"
" for now";
goto error;
}
+#endif
#ifdef MS_WINDOWS
pypy_Windows_startup();
diff --git a/pypy/translator/c/src/mem.h b/pypy/translator/c/src/mem.h
--- a/pypy/translator/c/src/mem.h
+++ b/pypy/translator/c/src/mem.h
@@ -53,7 +53,7 @@
extern void* __gcmapstart;
extern void* __gcmapend;
extern char* __gccallshapes;
-extern long pypy_asm_stackwalk(void*, void*);
+extern Signed pypy_asm_stackwalk(void*, void*);
/* With the msvc Microsoft Compiler, the optimizer seems free to move
any code (even asm) that involves local memory (registers and stack).
@@ -66,14 +66,20 @@
pypy_asm_gcroot(void* _r1)
{
static volatile int _constant_always_one_ = 1;
- (long)_r1 *= _constant_always_one_;
+ (Signed)_r1 *= _constant_always_one_;
_ReadWriteBarrier();
return _r1;
}
#define pypy_asm_gc_nocollect(f) "/* GC_NOCOLLECT " #f " */"
-#define pypy_asm_keepalive(v) __asm { }
+#ifndef _WIN64
+# define pypy_asm_keepalive(v) __asm { }
+#else
+ /* is there something cheaper? */
+# define pypy_asm_keepalive(v) _ReadWriteBarrier();
+#endif
+
static __declspec(noinline) void pypy_asm_stack_bottom() { }
#define OP_GC_ASMGCROOT_STATIC(i, r) r = \
@@ -86,7 +92,7 @@
/* used by pypy.rlib.rstack, but also by asmgcc */
-#define OP_STACK_CURRENT(r) r = (long)&r
+#define OP_STACK_CURRENT(r) r = (Signed)&r
#define RAW_MALLOC_ZERO_FILLED 0
diff --git a/pypy/translator/c/src/obmalloc.c b/pypy/translator/c/src/obmalloc.c
--- a/pypy/translator/c/src/obmalloc.c
+++ b/pypy/translator/c/src/obmalloc.c
@@ -224,10 +224,10 @@
#define uint unsigned int /* assuming >= 16 bits */
#undef ulong
-#define ulong unsigned long /* assuming >= 32 bits */
+#define ulong Unsigned /* assuming >= 32 bits */
#undef uptr
-#define uptr unsigned long
+#define uptr Unsigned
/* When you say memory, my mind reasons in terms of (pointers to) blocks */
typedef uchar block;
diff --git a/pypy/translator/c/src/rtyper.h b/pypy/translator/c/src/rtyper.h
--- a/pypy/translator/c/src/rtyper.h
+++ b/pypy/translator/c/src/rtyper.h
@@ -30,7 +30,7 @@
char *RPyString_AsCharP(RPyString *rps)
{
- long len = RPyString_Size(rps);
+ Signed len = RPyString_Size(rps);
struct _RPyString_dump_t *dump = \
malloc(sizeof(struct _RPyString_dump_t) + len);
if (!dump)
diff --git a/pypy/translator/c/src/signals.h b/pypy/translator/c/src/signals.h
--- a/pypy/translator/c/src/signals.h
+++ b/pypy/translator/c/src/signals.h
@@ -54,7 +54,7 @@
/* When a signal is received, pypysig_counter is set to -1. */
/* This is a struct for the JIT. See interp_signal.py. */
struct pypysig_long_struct {
- long value;
+ Signed value;
};
extern struct pypysig_long_struct pypysig_counter;
diff --git a/pypy/translator/goal/win32/gc_patch_windows.py b/pypy/translator/goal/win32/gc_patch_windows.py
--- a/pypy/translator/goal/win32/gc_patch_windows.py
+++ b/pypy/translator/goal/win32/gc_patch_windows.py
@@ -1,6 +1,9 @@
# patches for the Boehm GC for PyPy under Windows
"""
+This file is obsolete now since gc-7.0 / gc-7.1 .
+Please use the instructions in pypy\doc\windows.rst .
+
How to build a pypy compatible version of the Boehm collector
for Windows and Visual Studio .net 2003.
diff --git a/pypy/translator/platform/__init__.py b/pypy/translator/platform/__init__.py
--- a/pypy/translator/platform/__init__.py
+++ b/pypy/translator/platform/__init__.py
@@ -272,8 +272,12 @@
else:
host_factory = OpenBSD_64
elif os.name == 'nt':
- from pypy.translator.platform.windows import Windows
- host_factory = Windows
+ from pypy.translator.platform.windows import Windows, Windows_x64
+ import platform
+ if platform.architecture()[0] == '32bit':
+ host_factory = Windows
+ else:
+ host_factory = Windows_x64
else:
# pray
from pypy.translator.platform.distutils_platform import DistutilsPlatform
diff --git a/pypy/translator/platform/windows.py b/pypy/translator/platform/windows.py
--- a/pypy/translator/platform/windows.py
+++ b/pypy/translator/platform/windows.py
@@ -11,15 +11,24 @@
if cc == 'mingw32':
return MingwPlatform(cc)
else:
- return MsvcPlatform(cc)
+ return MsvcPlatform(cc, False)
+
+def Windows_x64(cc=None):
+ return MsvcPlatform(cc, True)
-def _get_msvc_env(vsver):
+def _get_msvc_env(vsver, x64flag):
try:
toolsdir = os.environ['VS%sCOMNTOOLS' % vsver]
except KeyError:
return None
- vcvars = os.path.join(toolsdir, 'vsvars32.bat')
+ if x64flag:
+ vsinstalldir = os.path.abspath(os.path.join(toolsdir, '..', '..'))
+ vcinstalldir = os.path.join(vsinstalldir, 'VC')
+ vcbindir = os.path.join(vcinstalldir, 'BIN')
+ vcvars = os.path.join(vcbindir, 'amd64', 'vcvarsamd64.bat')
+ else:
+ vcvars = os.path.join(toolsdir, 'vsvars32.bat')
import subprocess
popen = subprocess.Popen('"%s" & set' % (vcvars,),
@@ -42,21 +51,21 @@
## log.msg("Updated environment with %s" % (vcvars,))
return env
-def find_msvc_env():
+def find_msvc_env(x64flag=False):
# First, try to get the compiler which served to compile python
msc_pos = sys.version.find('MSC v.')
if msc_pos != -1:
msc_ver = int(sys.version[msc_pos+6:msc_pos+10])
# 1300 -> 70, 1310 -> 71, 1400 -> 80, 1500 -> 90
vsver = (msc_ver / 10) - 60
- env = _get_msvc_env(vsver)
+ env = _get_msvc_env(vsver, x64flag)
if env is not None:
return env
# Then, try any other version
for vsver in (100, 90, 80, 71, 70): # All the versions I know
- env = _get_msvc_env(vsver)
+ env = _get_msvc_env(vsver, x64flag)
if env is not None:
return env
@@ -64,13 +73,14 @@
log.error("Could not find a Microsoft Compiler")
# Assume that the compiler is already part of the environment
-msvc_compiler_environ = find_msvc_env()
+msvc_compiler_environ32 = find_msvc_env(False)
+msvc_compiler_environ64 = find_msvc_env(True)
class MsvcPlatform(Platform):
name = "msvc"
so_ext = 'dll'
exe_ext = 'exe'
-
+
relevant_environ = ('PATH', 'INCLUDE', 'LIB')
cc = 'cl.exe'
@@ -81,8 +91,13 @@
standalone_only = ()
shared_only = ()
environ = None
-
+
def __init__(self, cc=None, x64=False):
+ self.x64 = x64
+ if x64:
+ msvc_compiler_environ = msvc_compiler_environ64
+ else:
+ msvc_compiler_environ = msvc_compiler_environ32
Platform.__init__(self, 'cl.exe')
if msvc_compiler_environ:
self.c_environ = os.environ.copy()
@@ -288,7 +303,10 @@
('CC_LINK', self.link),
('LINKFILES', eci.link_files),
('MASM', self.masm),
+ ('_WIN32', '1'),
]
+ if self.x64:
+ definitions.append(('_WIN64', '1'))
for args in definitions:
m.definition(*args)
diff --git a/pypy/translator/tool/cbuild.py b/pypy/translator/tool/cbuild.py
--- a/pypy/translator/tool/cbuild.py
+++ b/pypy/translator/tool/cbuild.py
@@ -320,4 +320,13 @@
#define __XSI_VISIBLE 700
/* Windows: winsock/winsock2 mess */
#define WIN32_LEAN_AND_MEAN
+#ifdef _WIN64
+ typedef __int64 Signed;
+ typedef unsigned __int64 Unsigned;
+# define SIGNED_MIN LLONG_MIN
+#else
+ typedef long Signed;
+ typedef unsigned long Unsigned;
+# define SIGNED_MIN LONG_MIN
+#endif
'''
More information about the pypy-commit
mailing list