[pypy-svn] r32766 - pypy/dist/pypy/translator/c/src

arigo at codespeak.net arigo at codespeak.net
Sat Sep 30 16:36:45 CEST 2006


Author: arigo
Date: Sat Sep 30 16:36:39 2006
New Revision: 32766

Modified:
   pypy/dist/pypy/translator/c/src/int.h
Log:
Add a missing operation.  Most LLONG_*_OVF operations are still missing.


Modified: pypy/dist/pypy/translator/c/src/int.h
==============================================================================
--- pypy/dist/pypy/translator/c/src/int.h	(original)
+++ pypy/dist/pypy/translator/c/src/int.h	Sat Sep 30 16:36:39 2006
@@ -2,6 +2,18 @@
 /************************************************************/
  /***  C header subsection: operations between ints        ***/
 
+#ifndef LLONG_MAX
+# if SIZEOF_LONG_LONG == 8
+#  define LLONG_MAX 0X7FFFFFFFFFFFFFFFLL
+# else
+#  error "fix LLONG_MAX"
+# endif
+#endif
+
+#ifndef LLONG_MIN
+# define LLONG_MIN (-LLONG_MAX-1)
+#endif
+
 /*** unary operations ***/
 
 #define OP_INT_IS_TRUE(x,r)   OP_INT_NE(x,0,r)
@@ -11,16 +23,20 @@
 #define OP_INT_NEG(x,r)    r = -(x)
 
 #define OP_INT_NEG_OVF(x,r) \
-	OP_INT_NEG(x,r); \
-	if ((x) >= 0 || (x) != -(x)); \
-	else FAIL_OVF("integer negate")
+    if ((x) == LONG_MIN) FAIL_OVF("integer negate"); \
+	OP_INT_NEG(x,r)
+#define OP_LLONG_NEG_OVF(x,r) \
+    if ((x) == LLONG_MIN) FAIL_OVF("integer negate"); \
+	OP_LLONG_NEG(x,r)
 
 #define OP_INT_ABS(x,r)    r = (x) >= 0 ? x : -(x)
 
 #define OP_INT_ABS_OVF(x,r) \
-	OP_INT_ABS(x,r); \
-	if ((x) >= 0 || (x) != -(x)); \
-	else FAIL_OVF("integer absolute")
+    if ((x) == LONG_MIN) FAIL_OVF("integer absolute"); \
+	OP_INT_ABS(x,r)
+#define OP_LLONG_ABS_OVF(x,r) \
+    if ((x) == LLONG_MIN) FAIL_OVF("integer absolute"); \
+	OP_LLONG_ABS(x,r)
 
 /***  binary operations ***/
 



More information about the Pypy-commit mailing list