[pypy-svn] r15795 - in pypy/dist/pypy/translator/c: . src
arigo at codespeak.net
arigo at codespeak.net
Mon Aug 8 22:22:42 CEST 2005
Author: arigo
Date: Mon Aug 8 22:22:37 2005
New Revision: 15795
Modified:
pypy/dist/pypy/translator/c/funcgen.py
pypy/dist/pypy/translator/c/genc.py
pypy/dist/pypy/translator/c/src/char.h
pypy/dist/pypy/translator/c/src/exception.h
pypy/dist/pypy/translator/c/src/float.h
pypy/dist/pypy/translator/c/src/int.h
pypy/dist/pypy/translator/c/src/mem.h
pypy/dist/pypy/translator/c/src/module.h
pypy/dist/pypy/translator/c/src/pyobj.h
pypy/dist/pypy/translator/c/src/support.h
pypy/dist/pypy/translator/c/src/trace.h
pypy/dist/pypy/translator/c/src/unichar.h
Log:
issue107 testing
Normalizing the macro call conventions: now the macros no longer contain the
final ';', which is traditional in C. Previously, some macros didn't require
an extra ';' after the call -- typically the OP_* and FAIL* macros.
Modified: pypy/dist/pypy/translator/c/funcgen.py
==============================================================================
--- pypy/dist/pypy/translator/c/funcgen.py (original)
+++ pypy/dist/pypy/translator/c/funcgen.py Mon Aug 8 22:22:37 2005
@@ -207,7 +207,7 @@
lst = [self.expr(v) for v in op.args]
lst.append(self.expr(op.result))
lst.append(err)
- yield '%s(%s)' % (macro, ', '.join(lst))
+ yield '%s(%s);' % (macro, ', '.join(lst))
to_release.append(op.result)
err_reachable = False
@@ -326,48 +326,48 @@
args = [self.expr(v) for v in op.args]
r = self.expr(op.result)
if len(args) == 0:
- return 'OP_NEWLIST0(%s, %s)' % (r, err)
+ return 'OP_NEWLIST0(%s, %s);' % (r, err)
else:
args.insert(0, '%d' % len(args))
- return 'OP_NEWLIST((%s), %s, %s)' % (', '.join(args), r, err)
+ return 'OP_NEWLIST((%s), %s, %s);' % (', '.join(args), r, err)
def OP_NEWDICT(self, op, err):
args = [self.expr(v) for v in op.args]
r = self.expr(op.result)
if len(args) == 0:
- return 'OP_NEWDICT0(%s, %s)' % (r, err)
+ return 'OP_NEWDICT0(%s, %s);' % (r, err)
else:
assert len(args) % 2 == 0
args.insert(0, '%d' % (len(args)//2))
- return 'OP_NEWDICT((%s), %s, %s)' % (', '.join(args), r, err)
+ return 'OP_NEWDICT((%s), %s, %s);' % (', '.join(args), r, err)
def OP_NEWTUPLE(self, op, err):
args = [self.expr(v) for v in op.args]
r = self.expr(op.result)
args.insert(0, '%d' % len(args))
- return 'OP_NEWTUPLE((%s), %s, %s)' % (', '.join(args), r, err)
+ return 'OP_NEWTUPLE((%s), %s, %s);' % (', '.join(args), r, err)
def OP_SIMPLE_CALL(self, op, err):
args = [self.expr(v) for v in op.args]
r = self.expr(op.result)
args.append('NULL')
- return 'OP_SIMPLE_CALL((%s), %s, %s)' % (', '.join(args), r, err)
+ return 'OP_SIMPLE_CALL((%s), %s, %s);' % (', '.join(args), r, err)
def OP_CALL_ARGS(self, op, err):
args = [self.expr(v) for v in op.args]
r = self.expr(op.result)
- return 'OP_CALL_ARGS((%s), %s, %s)' % (', '.join(args), r, err)
+ return 'OP_CALL_ARGS((%s), %s, %s);' % (', '.join(args), r, err)
def OP_DIRECT_CALL(self, op, err):
# skip 'void' arguments
args = [self.expr(v) for v in op.args if self.lltypemap(v) != Void]
if self.lltypemap(op.result) == Void:
# skip assignment of 'void' return value
- return '%s(%s); if (RPyExceptionOccurred()) FAIL(%s)' % (
+ return '%s(%s); if (RPyExceptionOccurred()) FAIL(%s);' % (
args[0], ', '.join(args[1:]), err)
else:
r = self.expr(op.result)
- return '%s = %s(%s); if (RPyExceptionOccurred()) FAIL(%s)' % (
+ return '%s = %s(%s); if (RPyExceptionOccurred()) FAIL(%s);' % (
r, args[0], ', '.join(args[1:]), err)
# low-level operations
@@ -463,9 +463,9 @@
TYPE = self.lltypemap(op.result).TO
typename = self.db.gettype(TYPE)
eresult = self.expr(op.result)
- result = ['OP_ZERO_MALLOC(sizeof(%s), %s, %s)' % (cdecl(typename, ''),
- eresult,
- err),
+ result = ['OP_ZERO_MALLOC(sizeof(%s), %s, %s);' % (cdecl(typename, ''),
+ eresult,
+ err),
'%s->%s = 1;' % (eresult,
self.db.gettypedefnode(TYPE).refcount),
]
@@ -490,9 +490,9 @@
size = 'sizeof(%s)+((%s-1)*sizeof(%s))' % (cdecl(typename, ''),
elength,
cdecl(itemtypename, ''))
- result = ['OP_ZERO_MALLOC(%s, %s, %s)' % (size,
- eresult,
- err),
+ result = ['OP_ZERO_MALLOC(%s, %s, %s);' % (size,
+ eresult,
+ err),
'%s->%s = %s;' % (eresult, lenfld,
elength),
'%s->%s = 1;' % (eresult,
Modified: pypy/dist/pypy/translator/c/genc.py
==============================================================================
--- pypy/dist/pypy/translator/c/genc.py (original)
+++ pypy/dist/pypy/translator/c/genc.py Mon Aug 8 22:22:37 2005
@@ -303,7 +303,7 @@
print >> f
print >> f, 'MODULE_INITFUNC(%s)' % modulename
print >> f, '{'
- print >> f, '\tSETUP_MODULE(%s)' % modulename
+ print >> f, '\tSETUP_MODULE(%s);' % modulename
for publicname, pyobjptr in exports.items():
# some fishing needed to find the name of the obj
pyobjnode = database.containernodes[pyobjptr._obj]
Modified: pypy/dist/pypy/translator/c/src/char.h
==============================================================================
--- pypy/dist/pypy/translator/c/src/char.h (original)
+++ pypy/dist/pypy/translator/c/src/char.h Mon Aug 8 22:22:37 2005
@@ -6,10 +6,10 @@
/*** binary operations ***/
-#define OP_CHAR_EQ(x,y,r,err) r = ((x) == (y));
-#define OP_CHAR_NE(x,y,r,err) r = ((x) != (y));
-#define OP_CHAR_LE(x,y,r,err) r = ((unsigned char)(x) <= (unsigned char)(y));
-#define OP_CHAR_GT(x,y,r,err) r = ((unsigned char)(x) > (unsigned char)(y));
-#define OP_CHAR_LT(x,y,r,err) r = ((unsigned char)(x) < (unsigned char)(y));
-#define OP_CHAR_GE(x,y,r,err) r = ((unsigned char)(x) >= (unsigned char)(y));
+#define OP_CHAR_EQ(x,y,r,err) r = ((x) == (y))
+#define OP_CHAR_NE(x,y,r,err) r = ((x) != (y))
+#define OP_CHAR_LE(x,y,r,err) r = ((unsigned char)(x) <= (unsigned char)(y))
+#define OP_CHAR_GT(x,y,r,err) r = ((unsigned char)(x) > (unsigned char)(y))
+#define OP_CHAR_LT(x,y,r,err) r = ((unsigned char)(x) < (unsigned char)(y))
+#define OP_CHAR_GE(x,y,r,err) r = ((unsigned char)(x) >= (unsigned char)(y))
Modified: pypy/dist/pypy/translator/c/src/exception.h
==============================================================================
--- pypy/dist/pypy/translator/c/src/exception.h (original)
+++ pypy/dist/pypy/translator/c/src/exception.h Mon Aug 8 22:22:37 2005
@@ -65,7 +65,7 @@
_RPyConvertExceptionToCPython(); \
vanishing = rpython_exc_value; \
rpython_exc_type = NULL; \
- rpython_exc_value = NULL;
+ rpython_exc_value = NULL
#endif /* !PYPY_STANDALONE */
Modified: pypy/dist/pypy/translator/c/src/float.h
==============================================================================
--- pypy/dist/pypy/translator/c/src/float.h (original)
+++ pypy/dist/pypy/translator/c/src/float.h Mon Aug 8 22:22:37 2005
@@ -6,35 +6,35 @@
/*** unary operations ***/
#define OP_FLOAT_IS_TRUE(x,r,err) OP_FLOAT_NE(x,0.0,r,err)
-#define OP_FLOAT_NEG(x,r,err) r = -x;
-#define OP_FLOAT_ABS(x,r,err) r = fabs(x);
+#define OP_FLOAT_NEG(x,r,err) r = -x
+#define OP_FLOAT_ABS(x,r,err) r = fabs(x)
/*** binary operations ***/
-#define OP_FLOAT_EQ(x,y,r,err) r = (x == y);
-#define OP_FLOAT_NE(x,y,r,err) r = (x != y);
-#define OP_FLOAT_LE(x,y,r,err) r = (x <= y);
-#define OP_FLOAT_GT(x,y,r,err) r = (x > y);
-#define OP_FLOAT_LT(x,y,r,err) r = (x < y);
-#define OP_FLOAT_GE(x,y,r,err) r = (x >= y);
+#define OP_FLOAT_EQ(x,y,r,err) r = (x == y)
+#define OP_FLOAT_NE(x,y,r,err) r = (x != y)
+#define OP_FLOAT_LE(x,y,r,err) r = (x <= y)
+#define OP_FLOAT_GT(x,y,r,err) r = (x > y)
+#define OP_FLOAT_LT(x,y,r,err) r = (x < y)
+#define OP_FLOAT_GE(x,y,r,err) r = (x >= y)
#define OP_FLOAT_CMP(x,y,r,err) \
r = ((x > y) - (x < y))
/* addition, subtraction */
-#define OP_FLOAT_ADD(x,y,r,err) r = x + y;
-#define OP_FLOAT_SUB(x,y,r,err) r = x - y;
-#define OP_FLOAT_MUL(x,y,r,err) r = x * y;
-#define OP_FLOAT_DIV(x,y,r,err) r = x / y;
+#define OP_FLOAT_ADD(x,y,r,err) r = x + y
+#define OP_FLOAT_SUB(x,y,r,err) r = x - y
+#define OP_FLOAT_MUL(x,y,r,err) r = x * y
+#define OP_FLOAT_DIV(x,y,r,err) r = x / y
#define OP_FLOAT_TRUEDIV(x,y,r,err) OP_FLOAT_DIV(x,y,r,err)
-#define OP_FLOAT_MOD(x,y,r,err) r = fmod(x, y);
-#define OP_FLOAT_POW(x,y,r,err) r = pow(x, y);
+#define OP_FLOAT_MOD(x,y,r,err) r = fmod(x, y)
+#define OP_FLOAT_POW(x,y,r,err) r = pow(x, y)
/*** conversions ***/
-#define OP_CAST_FLOAT_TO_INT(x,r,err) r = (long)(x);
-#define OP_CAST_FLOAT_TO_UINT(x,r,err) r = (unsigned long)(x);
-#define OP_CAST_INT_TO_FLOAT(x,r,err) r = (double)(x);
-#define OP_CAST_UINT_TO_FLOAT(x,r,err) r = (double)(x);
-#define OP_CAST_BOOL_TO_FLOAT(x,r,err) r = (double)(x);
+#define OP_CAST_FLOAT_TO_INT(x,r,err) r = (long)(x)
+#define OP_CAST_FLOAT_TO_UINT(x,r,err) r = (unsigned long)(x)
+#define OP_CAST_INT_TO_FLOAT(x,r,err) r = (double)(x)
+#define OP_CAST_UINT_TO_FLOAT(x,r,err) r = (double)(x)
+#define OP_CAST_BOOL_TO_FLOAT(x,r,err) r = (double)(x)
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 Mon Aug 8 22:22:37 2005
@@ -6,54 +6,54 @@
#define OP_INT_IS_TRUE(x,r,err) OP_INT_NE(x,0,r,err)
-#define OP_INT_INVERT(x,r,err) r = ~((x));
+#define OP_INT_INVERT(x,r,err) r = ~((x))
-#define OP_INT_POS(x,r,err) r = x;
+#define OP_INT_POS(x,r,err) r = x
-#define OP_INT_NEG(x,r,err) r = -(x);
+#define OP_INT_NEG(x,r,err) r = -(x)
#define OP_INT_NEG_OVF(x,r,err) \
- OP_INT_NEG(x,r,err) \
+ OP_INT_NEG(x,r,err); \
if ((x) >= 0 || (x) != -(x)); \
else FAIL_OVF(err, "integer negate")
-#define OP_INT_ABS(x,r,err) r = (x) >= 0 ? x : -(x);
-#define OP_UINT_ABS(x,r,err) r = (x);
+#define OP_INT_ABS(x,r,err) r = (x) >= 0 ? x : -(x)
+#define OP_UINT_ABS(x,r,err) r = (x)
#define OP_INT_ABS_OVF(x,r,err) \
- OP_INT_ABS(x,r,err) \
+ OP_INT_ABS(x,r,err); \
if ((x) >= 0 || (x) != -(x)); \
else FAIL_OVF(err, "integer absolute")
/*** binary operations ***/
-#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_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 = (((x) > (y)) - ((x) < (y)))
/* addition, subtraction */
-#define OP_INT_ADD(x,y,r,err) r = (x) + (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) \
+ OP_INT_ADD(x,y,r,err); \
if ((r^(x)) >= 0 || (r^(y)) >= 0); \
else FAIL_OVF(err, "integer addition")
-#define OP_INT_SUB(x,y,r,err) r = (x) - (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) \
+ OP_INT_SUB(x,y,r,err); \
if ((r^(x)) >= 0 || (r^~(y)) >= 0); \
else FAIL_OVF(err, "integer subtraction")
-#define OP_INT_MUL(x,y,r,err) r = (x) * (y);
+#define OP_INT_MUL(x,y,r,err) r = (x) * (y)
#ifndef HAVE_LONG_LONG
@@ -68,7 +68,7 @@
PY_LONG_LONG lr = (PY_LONG_LONG)(x) * (PY_LONG_LONG)(y); \
r = lr; \
if ((PY_LONG_LONG)r == lr); \
- else FAIL_OVF(err, "integer multiplication") \
+ else FAIL_OVF(err, "integer multiplication"); \
}
#endif
@@ -76,96 +76,96 @@
/* NB. shifting has same limitations as C: the shift count must be
>= 0 and < LONG_BITS. */
-#define OP_INT_RSHIFT(x,y,r,err) r = Py_ARITHMETIC_RIGHT_SHIFT(long, x, y);
-#define OP_UINT_RSHIFT(x,y,r,err) r = (x) >> (y);
+#define OP_INT_RSHIFT(x,y,r,err) r = Py_ARITHMETIC_RIGHT_SHIFT(long, x, y)
+#define OP_UINT_RSHIFT(x,y,r,err) r = (x) >> (y)
-#define OP_INT_LSHIFT(x,y,r,err) r = (x) << (y);
-#define OP_UINT_LSHIFT(x,y,r,err) r = (x) << (y);
+#define OP_INT_LSHIFT(x,y,r,err) r = (x) << (y)
+#define OP_UINT_LSHIFT(x,y,r,err) r = (x) << (y)
#define OP_INT_LSHIFT_OVF(x,y,r,err) \
- OP_INT_LSHIFT(x,y,r,err) \
+ OP_INT_LSHIFT(x,y,r,err); \
if ((x) != Py_ARITHMETIC_RIGHT_SHIFT(long, r, (y))) \
FAIL_OVF(err, "x<<y loosing bits or changing sign")
/* the safe value-checking version of the above macros */
#define OP_INT_RSHIFT_VAL(x,y,r,err) \
- if ((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_VAL(x,y,r,err) \
- if ((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_VAL(x,y,r,err) \
- if ((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")
/* floor division */
-#define OP_INT_FLOORDIV(x,y,r,err) r = op_divmod_adj(x, y, NULL);
-#define OP_UINT_FLOORDIV(x,y,r,err) r = (x) / (y);
+#define OP_INT_FLOORDIV(x,y,r,err) r = op_divmod_adj(x, y, NULL)
+#define OP_UINT_FLOORDIV(x,y,r,err) r = (x) / (y)
#define OP_INT_FLOORDIV_OVF(x,y,r,err) \
if ((y) == -1 && (x) < 0 && ((unsigned long)(x) << 1) == 0) \
- FAIL_OVF(err, "integer division") \
+ FAIL_OVF(err, "integer division"); \
OP_INT_FLOORDIV(x,y,r,err)
#define OP_INT_FLOORDIV_ZER(x,y,r,err) \
- if ((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_UINT_FLOORDIV_ZER(x,y,r,err) \
- if ((y)) { OP_UINT_FLOORDIV(x,y,r,err) } \
+ if ((y)) { OP_UINT_FLOORDIV(x,y,r,err); } \
else FAIL_ZER(err, "unsigned integer division")
#define OP_INT_FLOORDIV_OVF_ZER(x,y,r,err) \
- if ((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 */
-#define OP_INT_MOD(x,y,r,err) op_divmod_adj(x, y, &r);
-#define OP_UINT_MOD(x,y,r,err) r = (x) % (y);
+#define OP_INT_MOD(x,y,r,err) op_divmod_adj(x, y, &r)
+#define OP_UINT_MOD(x,y,r,err) r = (x) % (y)
#define OP_INT_MOD_OVF(x,y,r,err) \
if ((y) == -1 && (x) < 0 && ((unsigned long)(x) << 1) == 0) \
- FAIL_OVF(err, "integer modulo") \
- OP_INT_MOD(x,y,r,err);
+ FAIL_OVF(err, "integer modulo"); \
+ OP_INT_MOD(x,y,r,err)
#define OP_INT_MOD_ZER(x,y,r,err) \
- if ((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_UINT_MOD_ZER(x,y,r,err) \
- if ((y)) { OP_UINT_MOD(x,y,r,err) } \
+ if ((y)) { OP_UINT_MOD(x,y,r,err); } \
else FAIL_ZER(err, "unsigned integer modulo")
#define OP_INT_MOD_OVF_ZER(x,y,r,err) \
- if ((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 = (x) & (y);
-#define OP_INT_OR( x,y,r,err) r = (x) | (y);
-#define OP_INT_XOR(x,y,r,err) r = (x) ^ (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 ***/
-#define OP_CAST_BOOL_TO_INT(x,r,err) r = (long)(x);
-#define OP_CAST_BOOL_TO_UINT(x,r,err) r = (unsigned long)(x);
-#define OP_CAST_UINT_TO_INT(x,r,err) r = (long)(x);
-#define OP_CAST_INT_TO_UINT(x,r,err) r = (unsigned long)(x);
-#define OP_CAST_CHAR_TO_INT(x,r,err) r = (long)((unsigned char)(x));
-#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_BOOL_TO_INT(x,r,err) r = (long)(x)
+#define OP_CAST_BOOL_TO_UINT(x,r,err) r = (unsigned long)(x)
+#define OP_CAST_UINT_TO_INT(x,r,err) r = (long)(x)
+#define OP_CAST_INT_TO_UINT(x,r,err) r = (unsigned long)(x)
+#define OP_CAST_CHAR_TO_INT(x,r,err) r = (long)((unsigned char)(x))
+#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)((unsigned long)(x)); /*?*/
-#define OP_CAST_INT_TO_UNICHAR(x,r,err) r = (unsigned int)(x);
+#define OP_CAST_UNICHAR_TO_INT(x,r,err) r = (long)((unsigned long)(x)) /*?*/
+#define OP_CAST_INT_TO_UNICHAR(x,r,err) r = (unsigned int)(x)
/* bool operations */
-#define OP_BOOL_NOT(x, r, err) r = !(x);
+#define OP_BOOL_NOT(x, r, err) r = !(x)
/* _________________ certain implementations __________________ */
Modified: pypy/dist/pypy/translator/c/src/mem.h
==============================================================================
--- pypy/dist/pypy/translator/c/src/mem.h (original)
+++ pypy/dist/pypy/translator/c/src/mem.h Mon Aug 8 22:22:37 2005
@@ -10,12 +10,12 @@
#define OP_ZERO_MALLOC(size, r, err) { \
r = (void*) PyObject_Malloc(size); \
- if (r == NULL) FAIL_EXCEPTION(err, PyExc_MemoryError, "out of memory")\
+ if (r == NULL) FAIL_EXCEPTION(err, PyExc_MemoryError, "out of memory");\
memset((void*) r, 0, size); \
- COUNT_MALLOC \
+ COUNT_MALLOC; \
}
-#define OP_FREE(p) { PyObject_Free(p); COUNT_FREE }
+#define OP_FREE(p) { PyObject_Free(p); COUNT_FREE; }
/*------------------------------------------------------------*/
@@ -31,8 +31,8 @@
static int count_mallocs=0, count_frees=0;
-#define COUNT_MALLOC count_mallocs++;
-#define COUNT_FREE count_frees++;
+#define COUNT_MALLOC count_mallocs++
+#define COUNT_FREE count_frees++
PyObject* malloc_counters(PyObject* self, PyObject* args)
{
Modified: pypy/dist/pypy/translator/c/src/module.h
==============================================================================
--- pypy/dist/pypy/translator/c/src/module.h (original)
+++ pypy/dist/pypy/translator/c/src/module.h Mon Aug 8 22:22:37 2005
@@ -34,7 +34,7 @@
if (setup_initcode(frozen_initcode, FROZEN_INITCODE_SIZE) < 0) \
return; \
if (setup_globalobjects(globalobjectdefs) < 0) \
- return;
+ return
/*** table of global objects ***/
Modified: pypy/dist/pypy/translator/c/src/pyobj.h
==============================================================================
--- pypy/dist/pypy/translator/c/src/pyobj.h (original)
+++ pypy/dist/pypy/translator/c/src/pyobj.h Mon Aug 8 22:22:37 2005
@@ -6,9 +6,7 @@
#define op_bool(r,err,what) { \
int _retval = what; \
- if (_retval < 0) { \
- CFAIL(err) \
- } \
+ if (_retval < 0) CFAIL(err); \
r = PyBool_FromLong(_retval); \
}
@@ -28,9 +26,7 @@
#define OP_LEN(x,r,err) { \
int _retval = PyObject_Size(x); \
- if (_retval < 0) { \
- CFAIL(err) \
- } \
+ if (_retval < 0) CFAIL(err); \
r = PyInt_FromLong(_retval); \
}
#define OP_NEG(x,r,err) if (!(r=PyNumber_Negative(x))) CFAIL(err)
@@ -80,20 +76,20 @@
#define OP_INPLACE_XOR(x,y,r,err) if (!(r=PyNumber_InPlaceXor(x,y))) \
CFAIL(err)
-#define OP_GETITEM(x,y,r,err) if (!(r=PyObject_GetItem1(x,y))) CFAIL(err)
-#define OP_SETITEM(x,y,z,r,err) if ((PyObject_SetItem1(x,y,z))<0) CFAIL(err) \
- r=Py_None; Py_INCREF(r);
-#define OP_DELITEM(x,y,r,err) if ((PyObject_DelItem(x,y))<0) CFAIL(err) \
- r=Py_None; Py_INCREF(r);
+#define OP_GETITEM(x,y,r,err) if (!(r=PyObject_GetItem1(x,y))) CFAIL(err)
+#define OP_SETITEM(x,y,z,r,err) if ((PyObject_SetItem1(x,y,z))<0) CFAIL(err);\
+ r=Py_None; Py_INCREF(r)
+#define OP_DELITEM(x,y,r,err) if ((PyObject_DelItem(x,y))<0) CFAIL(err);\
+ r=Py_None; Py_INCREF(r)
#define OP_CONTAINS(x,y,r,err) op_bool(r,err,(PySequence_Contains(x,y)))
-#define OP_GETATTR(x,y,r,err) if (!(r=PyObject_GetAttr(x,y))) CFAIL(err)
-#define OP_SETATTR(x,y,z,r,err) if ((PyObject_SetAttr(x,y,z))<0) CFAIL(err) \
- r=Py_None; Py_INCREF(r);
-#define OP_DELATTR(x,y,r,err) if ((PyObject_SetAttr(x,y,NULL))<0)CFAIL(err) \
- r=Py_None; Py_INCREF(r);
+#define OP_GETATTR(x,y,r,err) if (!(r=PyObject_GetAttr(x,y))) CFAIL(err)
+#define OP_SETATTR(x,y,z,r,err) if ((PyObject_SetAttr(x,y,z))<0) CFAIL(err);\
+ r=Py_None; Py_INCREF(r)
+#define OP_DELATTR(x,y,r,err) if ((PyObject_SetAttr(x,y,NULL))<0)CFAIL(err);\
+ r=Py_None; Py_INCREF(r)
-#define OP_NEWSLICE(x,y,z,r,err) if (!(r=PySlice_New(x,y,z))) CFAIL(err)
+#define OP_NEWSLICE(x,y,z,r,err) if (!(r=PySlice_New(x,y,z))) CFAIL(err)
#define OP_GETSLICE(x,y,z,r,err) { \
PyObject *__yo = y, *__zo = z; \
@@ -102,14 +98,14 @@
if (__zo == Py_None) __zo = NULL; \
if (!_PyEval_SliceIndex(__yo, &__y) || \
!_PyEval_SliceIndex(__zo, &__z) || \
- !(r=PySequence_GetSlice(x, __y, __z))) CFAIL(err) \
+ !(r=PySequence_GetSlice(x, __y, __z))) CFAIL(err); \
}
#define OP_ALLOC_AND_SET(x,y,r,err) { \
/* XXX check for long/int overflow */ \
int __i, __x = PyInt_AsLong(x); \
- if (PyErr_Occurred()) CFAIL(err) \
- if (!(r = PyList_New(__x))) CFAIL(err) \
+ if (PyErr_Occurred()) CFAIL(err); \
+ if (!(r = PyList_New(__x))) CFAIL(err); \
for (__i=0; __i<__x; __i++) { \
Py_INCREF(y); \
PyList_SET_ITEM(r, __i, y); \
@@ -119,7 +115,7 @@
#define OP_ITER(x,r,err) if (!(r=PyObject_GetIter(x))) CFAIL(err)
#define OP_NEXT(x,r,err) if (!(r=PyIter_Next(x))) { \
if (!PyErr_Occurred()) PyErr_SetNone(PyExc_StopIteration); \
- CFAIL(err) \
+ CFAIL(err); \
}
#define OP_STR(x,r,err) if (!(r=PyObject_Str(x))) CFAIL(err)
@@ -127,21 +123,21 @@
#define OP_ORD(s,r,err) { \
char *__c = PyString_AsString(s); \
int __len; \
- if ( !__c) CFAIL(err) \
+ if ( !__c) CFAIL(err); \
if ((__len = PyString_GET_SIZE(s)) != 1) { \
PyErr_Format(PyExc_TypeError, \
"ord() expected a character, but string of length %d found", \
__len); \
- CFAIL(err) \
+ CFAIL(err); \
} \
if (!(r = PyInt_FromLong((unsigned char)(__c[0])))) \
- CFAIL(err) \
+ CFAIL(err); \
}
#define OP_ID(x,r,err) if (!(r=PyLong_FromVoidPtr(x))) CFAIL(err)
#define OP_HASH(x,r,err) { \
long __hash = PyObject_Hash(x); \
- if (__hash == -1 && PyErr_Occurred()) CFAIL(err) \
- if (!(r = PyInt_FromLong(__hash))) CFAIL(err) \
+ if (__hash == -1 && PyErr_Occurred()) CFAIL(err); \
+ if (!(r = PyInt_FromLong(__hash))) CFAIL(err); \
}
#define OP_HEX(x,r,err) { \
@@ -150,9 +146,9 @@
__nb->nb_hex == NULL) { \
PyErr_SetString(PyExc_TypeError, \
"hex() argument can't be converted to hex"); \
- CFAIL(err) \
+ CFAIL(err); \
} \
- if (!(r = (*__nb->nb_hex)(x))) CFAIL(err) \
+ if (!(r = (*__nb->nb_hex)(x))) CFAIL(err); \
}
#define OP_OCT(x,r,err) { \
PyNumberMethods *__nb; \
@@ -160,26 +156,26 @@
__nb->nb_oct == NULL) { \
PyErr_SetString(PyExc_TypeError, \
"oct() argument can't be converted to oct"); \
- CFAIL(err) \
+ CFAIL(err); \
} \
- if (!(r = (*__nb->nb_oct)(x))) CFAIL(err) \
+ if (!(r = (*__nb->nb_oct)(x))) CFAIL(err); \
}
#define OP_INT(x,r,err) { \
long __val = PyInt_AsLong(x); \
- if (__val == -1 && PyErr_Occurred()) CFAIL(err) \
- if (!(r = PyInt_FromLong(__val))) CFAIL (err) \
+ if (__val == -1 && PyErr_Occurred()) CFAIL(err); \
+ if (!(r = PyInt_FromLong(__val))) CFAIL (err); \
}
#define OP_FLOAT(x,r,err) { \
double __val = PyFloat_AsDouble(x); \
- if (PyErr_Occurred()) CFAIL(err) \
- if (!(r = PyFloat_FromDouble(__val))) CFAIL (err) \
+ if (PyErr_Occurred()) CFAIL(err); \
+ if (!(r = PyFloat_FromDouble(__val))) CFAIL (err); \
}
#define OP_CMP(x,y,r,err) { \
int __val = PyObject_Compare(x, y); \
- if (PyErr_Occurred()) CFAIL(err) \
- if (!(r = PyInt_FromLong(__val))) CFAIL (err) \
+ if (PyErr_Occurred()) CFAIL(err); \
+ if (!(r = PyInt_FromLong(__val))) CFAIL (err); \
}
Modified: pypy/dist/pypy/translator/c/src/support.h
==============================================================================
--- pypy/dist/pypy/translator/c/src/support.h (original)
+++ pypy/dist/pypy/translator/c/src/support.h Mon Aug 8 22:22:37 2005
@@ -12,12 +12,12 @@
#define FAIL_EXCEPTION(err, exc, msg) \
{ \
RPyRaiseSimpleException(exc, msg); \
- FAIL(err) \
+ FAIL(err); \
}
#define FAIL_OVF(err, msg) FAIL_EXCEPTION(err, PyExc_OverflowError, msg)
#define FAIL_VAL(err, msg) FAIL_EXCEPTION(err, PyExc_ValueError, msg)
#define FAIL_ZER(err, msg) FAIL_EXCEPTION(err, PyExc_ZeroDivisionError, msg)
-#define CFAIL(err) { RPyConvertExceptionFromCPython(); FAIL(err) }
+#define CFAIL(err) { RPyConvertExceptionFromCPython(); FAIL(err); }
#ifndef PYPY_STANDALONE
Modified: pypy/dist/pypy/translator/c/src/trace.h
==============================================================================
--- pypy/dist/pypy/translator/c/src/trace.h (original)
+++ pypy/dist/pypy/translator/c/src/trace.h Mon Aug 8 22:22:37 2005
@@ -32,11 +32,7 @@
#else /* !defined(USE_CALL_TRACE) */
-#define FAIL(err) { goto err; }
-
-#define ERR_DECREF(arg) { Py_DECREF(arg); }
-
-#define FUNCTION_RETURN(rval) return rval;
+#define FAIL(err) goto err
#endif /* defined(USE_CALL_TRACE) */
Modified: pypy/dist/pypy/translator/c/src/unichar.h
==============================================================================
--- pypy/dist/pypy/translator/c/src/unichar.h (original)
+++ pypy/dist/pypy/translator/c/src/unichar.h Mon Aug 8 22:22:37 2005
@@ -6,6 +6,6 @@
/*** binary operations ***/
/* typedef unsigned pypy_unichar; */
-#define OP_UNICHAR_EQ(x,y,r,err) r = ((x) == (y));
-#define OP_UNICHAR_NE(x,y,r,err) r = ((x) != (y));
+#define OP_UNICHAR_EQ(x,y,r,err) r = ((x) == (y))
+#define OP_UNICHAR_NE(x,y,r,err) r = ((x) != (y))
More information about the Pypy-commit
mailing list