[pypy-svn] r13963 - pypy/dist/pypy/translator/c

tismer at codespeak.net tismer at codespeak.net
Sun Jun 26 16:20:07 CEST 2005


Author: tismer
Date: Sun Jun 26 16:20:06 2005
New Revision: 13963

Modified:
   pypy/dist/pypy/translator/c/int_include.h
Log:
removed no-longer needed casts.
reason:
without the casts, most macros can be re-used to
implement the r_uint operations.

Modified: pypy/dist/pypy/translator/c/int_include.h
==============================================================================
--- pypy/dist/pypy/translator/c/int_include.h	(original)
+++ pypy/dist/pypy/translator/c/int_include.h	Sun Jun 26 16:20:06 2005
@@ -6,53 +6,53 @@
 
 #define OP_INT_IS_TRUE(x,r,err)   OP_INT_NE(x,0,r,err)
 
-#define OP_INT_INVERT(x,r,err)    r = ~((long)(x));
+#define OP_INT_INVERT(x,r,err)    r = ~((x));
 
 #define OP_INT_POS(x,r,err)    r = x;
 
-#define OP_INT_NEG(x,r,err)    r = -((long)x);
+#define OP_INT_NEG(x,r,err)    r = -(x);
 
 #define OP_INT_NEG_OVF(x,r,err) \
 	OP_INT_NEG(x,r,err) \
-	if ((long)(x) >= 0 || (long)(x) != -(long)(x)); \
+	if ((x) >= 0 || (x) != -(x)); \
 	else FAIL_OVF(err, "integer negate")
 
-#define OP_INT_ABS(x,r,err)    r = (long)(x) >= 0 ? x : -((long)x);
+#define OP_INT_ABS(x,r,err)    r = (x) >= 0 ? x : -(x);
 
 #define OP_INT_ABS_OVF(x,r,err) \
 	OP_INT_ABS(x,r,err) \
-	if ((long)(x) >= 0 || (long)(x) != -(long)(x)); \
+	if ((x) >= 0 || (x) != -(x)); \
 	else FAIL_OVF(err, "integer absolute")
 
 /***  binary operations ***/
 
-#define OP_INT_EQ(x,y,r,err)	  r = ((long)(x) == (long)(y));
-#define OP_INT_NE(x,y,r,err)	  r = ((long)(x) != (long)(y));
-#define OP_INT_LE(x,y,r,err)	  r = ((long)(x) <= (long)(y));
-#define OP_INT_GT(x,y,r,err)	  r = ((long)(x) >  (long)(y));
-#define OP_INT_LT(x,y,r,err)	  r = ((long)(x) <  (long)(y));
-#define OP_INT_GE(x,y,r,err)	  r = ((long)(x) >= (long)(y));
+#define OP_INT_EQ(x,y,r,err)	  r = ((x) == (y));
+#define OP_INT_NE(x,y,r,err)	  r = ((x) != (y));
+#define OP_INT_LE(x,y,r,err)	  r = ((x) <= (y));
+#define OP_INT_GT(x,y,r,err)	  r = ((x) >  (y));
+#define OP_INT_LT(x,y,r,err)	  r = ((x) <  (y));
+#define OP_INT_GE(x,y,r,err)	  r = ((x) >= (y));
 
 #define OP_INT_CMP(x,y,r,err) \
-	r = (((long)(x) > (long)(y)) - ((long)(x) < (long)(y)))
+	r = (((x) > (y)) - ((x) < (y)))
 
 /* addition, subtraction */
 
-#define OP_INT_ADD(x,y,r,err)     r = (long)(x) + (long)(y);
+#define OP_INT_ADD(x,y,r,err)     r = (x) + (y);
 
 #define OP_INT_ADD_OVF(x,y,r,err) \
 	OP_INT_ADD(x,y,r,err) \
-	if ((r^((long)x)) >= 0 || (r^((long)y)) >= 0); \
+	if ((r^(x)) >= 0 || (r^(y)) >= 0); \
 	else FAIL_OVF(err, "integer addition")
 
-#define OP_INT_SUB(x,y,r,err)     r = (long)(x) - (long)(y);
+#define OP_INT_SUB(x,y,r,err)     r = (x) - (y);
 
 #define OP_INT_SUB_OVF(x,y,r,err) \
 	OP_INT_SUB(x,y,r,err) \
-	if ((r^(long)(x)) >= 0 || (r^~(long)(y)) >= 0); \
+	if ((r^(x)) >= 0 || (r^~(y)) >= 0); \
 	else FAIL_OVF(err, "integer subtraction")
 
-#define OP_INT_MUL(x,y,r,err)     r = (long)(x) * (long)(y);
+#define OP_INT_MUL(x,y,r,err)     r = (x) * (y);
 
 #ifndef HAVE_LONG_LONG
 
@@ -65,7 +65,7 @@
 #define OP_INT_MUL_OVF(x,y,r,err) \
 	{ \
 		PY_LONG_LONG lr = (PY_LONG_LONG)(x) * (PY_LONG_LONG)(y); \
-		r = (long)lr; \
+		r = lr; \
 		if ((PY_LONG_LONG)r == lr); \
 		else FAIL_OVF(err, "integer multiplication") \
 	}
@@ -74,30 +74,30 @@
 /* shifting */
 
 #define OP_INT_RSHIFT(x,y,r,err) \
-	if ((long)(y) < LONG_BIT) \
-		r = Py_ARITHMETIC_RIGHT_SHIFT(long, (long)(x), (long)(y)); \
-	else r = (long)(x) < 0 ? -1 : 0;
+	if ((y) < LONG_BIT) \
+		r = Py_ARITHMETIC_RIGHT_SHIFT(long, (x), (y)); \
+	else r = (x) < 0 ? -1 : 0;
 
 #define OP_INT_RSHIFT_VAL(x,y,r,err) \
-	if ((long)(y) >= 0) { OP_INT_RSHIFT(x,y,r,err) } \
+	if ((y) >= 0) { OP_INT_RSHIFT(x,y,r,err) } \
 	else FAIL_VAL(err, "negative shift count")
 
 #define OP_INT_LSHIFT(x,y,r,err) \
-	if ((long)(y) < LONG_BIT) \
-		r = (long)(x) << (long)(y); \
+	if ((y) < LONG_BIT) \
+		r = (x) << (y); \
 	else r = 0;
 
 #define OP_INT_LSHIFT_VAL(x,y,r,err) \
-	if ((long)(y) >= 0) { OP_INT_LSHIFT(x,y,r,err) } \
+	if ((y) >= 0) { OP_INT_LSHIFT(x,y,r,err) } \
 	else FAIL_VAL(err, "negative shift count")
 
 #define OP_INT_LSHIFT_OVF(x,y,r,err) \
 	OP_INT_LSHIFT(x,y,r,err) \
-	if ((long)(x) != Py_ARITHMETIC_RIGHT_SHIFT(long, r, (long)(y))) \
+	if ((x) != Py_ARITHMETIC_RIGHT_SHIFT(long, r, (y))) \
 		FAIL_OVF(err, "x<<y loosing bits or changing sign")
 
 #define OP_INT_LSHIFT_OVF_VAL(x,y,r,err) \
-	if ((long)(y) >= 0) { OP_INT_LSHIFT_OVF(x,y,r,err) } \
+	if ((y) >= 0) { OP_INT_LSHIFT_OVF(x,y,r,err) } \
 	else FAIL_VAL(err, "negative shift count")
 
 
@@ -106,16 +106,16 @@
 #define OP_INT_FLOORDIV(x,y,r,err) r = op_divmod_adj(x, y, NULL);
 
 #define OP_INT_FLOORDIV_OVF(x,y,r,err) \
-	if ((long)(y) == -1 && (long)(x) < 0 && ((unsigned long)(x) << 1) == 0) \
+	if ((y) == -1 && (x) < 0 && ((unsigned long)(x) << 1) == 0) \
 		FAIL_OVF(err, "integer division") \
 	OP_INT_FLOORDIV(x,y,r,err)
 
 #define OP_INT_FLOORDIV_ZER(x,y,r,err) \
-	if ((long)(y)) { OP_INT_FLOORDIV(x,y,r,err) } \
+	if ((y)) { OP_INT_FLOORDIV(x,y,r,err) } \
 	else FAIL_ZER(err, "integer division")
 		
 #define OP_INT_FLOORDIV_OVF_ZER(x,y,r,err) \
-	if ((long)(y)) { OP_INT_FLOORDIV_OVF(x,y,r,err) } \
+	if ((y)) { OP_INT_FLOORDIV_OVF(x,y,r,err) } \
 	else FAIL_ZER(err, "integer division")
 
 /* modulus */
@@ -123,23 +123,23 @@
 #define OP_INT_MOD(x,y,r,err)     op_divmod_adj(x, y, &r);
 
 #define OP_INT_MOD_OVF(x,y,r,err) \
-	if ((long)(y) == -1 && (long)(x) < 0 && ((unsigned long)(x) << 1) == 0) \
+	if ((y) == -1 && (x) < 0 && ((unsigned long)(x) << 1) == 0) \
 		FAIL_OVF(err, "integer modulo") \
 	OP_INT_MOD(x,y,r,err);
 
 #define OP_INT_MOD_ZER(x,y,r,err) \
-	if ((long)(y)) { OP_INT_MOD(x,y,r,err) } \
+	if ((y)) { OP_INT_MOD(x,y,r,err) } \
 	else FAIL_ZER(err, "integer modulo")
 		
 #define OP_INT_MOD_OVF_ZER(x,y,r,err) \
-	if ((long)(y)) { OP_INT_MOD_OVF(x,y,r,err) } \
+	if ((y)) { OP_INT_MOD_OVF(x,y,r,err) } \
 	else FAIL_ZER(err, "integer modulo")
 
 /* bit operations */
 
-#define OP_INT_AND(x,y,r,err)     r = (long)(x) & (long)(y);
-#define OP_INT_OR( x,y,r,err)     r = (long)(x) | (long)(y);
-#define OP_INT_XOR(x,y,r,err)     r = (long)(x) ^ (long)(y);
+#define OP_INT_AND(x,y,r,err)     r = (x) & (y);
+#define OP_INT_OR( x,y,r,err)     r = (x) | (y);
+#define OP_INT_XOR(x,y,r,err)     r = (x) ^ (y);
 
 /*** conversions ***/
 
@@ -151,7 +151,7 @@
 #define OP_CAST_INT_TO_CHAR(x,r,err)    r = (char)(x);
 #define OP_CAST_PTR_TO_INT(x,r,err)     r = (long)(x);    /* XXX */
 
-#define OP_CAST_UNICHAR_TO_INT(x,r,err)    r = (long)(x);
+#define OP_CAST_UNICHAR_TO_INT(x,r,err)    r = (x);
 #define OP_CAST_INT_TO_UNICHAR(x,r,err)    r = (Py_UCS4)(x);
 
 /* bool operations */



More information about the Pypy-commit mailing list