[pypy-svn] r18525 - in pypy/dist/pypy/translator/c: src test

tismer at codespeak.net tismer at codespeak.net
Fri Oct 14 10:35:08 CEST 2005


Author: tismer
Date: Fri Oct 14 10:35:06 2005
New Revision: 18525

Modified:
   pypy/dist/pypy/translator/c/src/address.h
   pypy/dist/pypy/translator/c/test/test_lladdresses.py
Log:
made addresses work on windows.
Arithmetic with void pointers is not supported.
Added comparison tests, too.

Modified: pypy/dist/pypy/translator/c/src/address.h
==============================================================================
--- pypy/dist/pypy/translator/c/src/address.h	(original)
+++ pypy/dist/pypy/translator/c/src/address.h	Fri Oct 14 10:35:06 2005
@@ -5,9 +5,9 @@
 
 /***  binary operations ***/
 
-#define OP_ADR_DELTA(x,y,r,err) r = ((x) - (y))
-#define OP_ADR_SUB(x,y,r,err)   r = ((x) - (y))
-#define OP_ADR_ADD(x,y,r,err)   r = ((x) + (y))
+#define OP_ADR_DELTA(x,y,r,err) r = ((char *)(x) - (char *)(y))
+#define OP_ADR_SUB(x,y,r,err)   r = ((char *)(x) - (y))
+#define OP_ADR_ADD(x,y,r,err)   r = ((char *)(x) + (y))
 
 #define OP_ADR_EQ(x,y,r,err)	  r = ((x) == (y))
 #define OP_ADR_NE(x,y,r,err)	  r = ((x) != (y))

Modified: pypy/dist/pypy/translator/c/test/test_lladdresses.py
==============================================================================
--- pypy/dist/pypy/translator/c/test/test_lladdresses.py	(original)
+++ pypy/dist/pypy/translator/c/test/test_lladdresses.py	Fri Oct 14 10:35:06 2005
@@ -71,4 +71,18 @@
     res = fc()
     assert res
 
-
+def test_pointer_comparison():
+    def f():
+        result = 0
+        for addr1 in [raw_malloc(1), NULL]:
+            addr2 = addr1 + 1
+            result = result * 2 + int(addr1 == addr2)
+            result = result * 2 + int(addr1 != addr2)
+            result = result * 2 + int(addr1 <  addr2)
+            result = result * 2 + int(addr1 <= addr2)
+            result = result * 2 + int(addr1 >  addr2)
+            result = result * 2 + int(addr1 >= addr2)
+        return result
+    fc = compile(f, [])
+    res = fc()
+    assert res == int('011100' * 2, 2)



More information about the Pypy-commit mailing list