[pypy-svn] r72579 - in pypy/trunk/pypy/translator/c: . src
arigo at codespeak.net
arigo at codespeak.net
Mon Mar 22 17:55:06 CET 2010
Author: arigo
Date: Mon Mar 22 17:55:05 2010
New Revision: 72579
Modified:
pypy/trunk/pypy/translator/c/funcgen.py
pypy/trunk/pypy/translator/c/node.py
pypy/trunk/pypy/translator/c/primitive.py
pypy/trunk/pypy/translator/c/src/support.h
Log:
Silence some more C compilation warnings.
Modified: pypy/trunk/pypy/translator/c/funcgen.py
==============================================================================
--- pypy/trunk/pypy/translator/c/funcgen.py (original)
+++ pypy/trunk/pypy/translator/c/funcgen.py Mon Mar 22 17:55:05 2010
@@ -485,16 +485,20 @@
assert isinstance(op.args[1], Constant)
STRUCT = self.lltypemap(op.args[0]).TO
structdef = self.db.gettypedefnode(STRUCT)
+ baseexpr_is_const = isinstance(op.args[0], Constant)
expr = ampersand + structdef.ptr_access_expr(self.expr(op.args[0]),
- op.args[1].value)
+ op.args[1].value,
+ baseexpr_is_const)
return self.generic_get(op, expr)
def OP_BARE_SETFIELD(self, op):
assert isinstance(op.args[1], Constant)
STRUCT = self.lltypemap(op.args[0]).TO
structdef = self.db.gettypedefnode(STRUCT)
+ baseexpr_is_const = isinstance(op.args[0], Constant)
expr = structdef.ptr_access_expr(self.expr(op.args[0]),
- op.args[1].value)
+ op.args[1].value,
+ baseexpr_is_const)
return self.generic_set(op, expr)
def OP_GETSUBSTRUCT(self, op):
Modified: pypy/trunk/pypy/translator/c/node.py
==============================================================================
--- pypy/trunk/pypy/translator/c/node.py (original)
+++ pypy/trunk/pypy/translator/c/node.py Mon Mar 22 17:55:05 2010
@@ -130,8 +130,10 @@
fldname = self.c_struct_field_name(fldname)
return '%s.%s' % (baseexpr, fldname)
- def ptr_access_expr(self, baseexpr, fldname):
+ def ptr_access_expr(self, baseexpr, fldname, baseexpr_is_const=False):
fldname = self.c_struct_field_name(fldname)
+ if baseexpr_is_const:
+ return '%s->%s' % (baseexpr, fldname)
return 'RPyField(%s, %s)' % (baseexpr, fldname)
def definition(self):
Modified: pypy/trunk/pypy/translator/c/primitive.py
==============================================================================
--- pypy/trunk/pypy/translator/c/primitive.py (original)
+++ pypy/trunk/pypy/translator/c/primitive.py Mon Mar 22 17:55:05 2010
@@ -95,7 +95,9 @@
elif isnan(value):
return '(Py_HUGE_VAL/Py_HUGE_VAL)'
else:
- return repr(value)
+ x = repr(value)
+ assert not x.startswith('n')
+ return x
def name_singlefloat(value, db):
value = float(value)
Modified: pypy/trunk/pypy/translator/c/src/support.h
==============================================================================
--- pypy/trunk/pypy/translator/c/src/support.h (original)
+++ pypy/trunk/pypy/translator/c/src/support.h Mon Mar 22 17:55:05 2010
@@ -74,7 +74,7 @@
* it's a "guaranteed" segfault and not one that can be used by
* attackers.
*/
-# define RPyCHECK(x) ((x) || RPyAbort())
+# define RPyCHECK(x) ((x)?(void)0:RPyAbort())
# define RPyField(ptr, name) ((RPyCHECK(ptr), (ptr))->name)
# define RPyItem(array, index) \
((RPyCHECK((index) >= 0 && (index) < (array)->length), \
@@ -87,12 +87,11 @@
# define RPyBareItem(array, index) \
((RPyCHECK((array) && (index) >= 0), (array))[index])
-int RPyAbort(void);
+void RPyAbort(void);
#ifndef PYPY_NOT_MAIN_FILE
-int RPyAbort(void) {
+void RPyAbort(void) {
fprintf(stderr, "Invalid RPython operation (NULL ptr or bad array index)\n");
abort();
- return 0;
}
#endif
More information about the Pypy-commit
mailing list