[pypy-svn] r65762 - in pypy/trunk/pypy/rpython: module tool
tav at codespeak.net
tav at codespeak.net
Sat Jun 13 22:39:11 CEST 2009
Author: tav
Date: Sat Jun 13 22:39:08 2009
New Revision: 65762
Modified:
pypy/trunk/pypy/rpython/module/ll_os.py
pypy/trunk/pypy/rpython/tool/rffi_platform.py
Log:
Patch to fix translation errors w.r.t setpgrp() on OS X Leopard.
Modified: pypy/trunk/pypy/rpython/module/ll_os.py
==============================================================================
--- pypy/trunk/pypy/rpython/module/ll_os.py (original)
+++ pypy/trunk/pypy/rpython/module/ll_os.py Sat Jun 13 22:39:08 2009
@@ -88,10 +88,31 @@
def __init__(self):
self.configure(CConfig)
+ # on some platforms, e.g. OS X Leopard, the following constants which
+ # may be defined in pyconfig.h triggers "legacy" behaviour for functions
+ # like setpgrp():
+ #
+ # _POSIX_C_SOURCE 200112L
+ # _XOPEN_SOURCE 600
+ # _DARWIN_C_SOURCE 1
+ #
+ # since the translation currently includes pyconfig.h, the checkcompiles
+ # call below include the pyconfig.h file so that the same behaviour is
+ # present in both the check and the final translation...
+
if hasattr(os, 'getpgrp'):
- self.GETPGRP_HAVE_ARG = platform.checkcompiles("getpgrp(0)", "#include <unistd.h>")
+ self.GETPGRP_HAVE_ARG = platform.checkcompiles(
+ "getpgrp(0)",
+ '#include "pyconfig.h"\n#include <unistd.h>',
+ [platform.get_python_include_dir()]
+ )
+
if hasattr(os, 'setpgrp'):
- self.SETPGRP_HAVE_ARG = platform.checkcompiles("setpgrp(0,0)", "#include <unistd.h>")
+ self.SETPGRP_HAVE_ARG = platform.checkcompiles(
+ "setpgrp(0,0)",
+ '#include "pyconfig.h"\n#include <unistd.h>',
+ [platform.get_python_include_dir()]
+ )
# we need an indirection via c functions to get macro calls working on llvm XXX still?
if hasattr(os, 'WCOREDUMP'):
Modified: pypy/trunk/pypy/rpython/tool/rffi_platform.py
==============================================================================
--- pypy/trunk/pypy/rpython/tool/rffi_platform.py (original)
+++ pypy/trunk/pypy/rpython/tool/rffi_platform.py Sat Jun 13 22:39:08 2009
@@ -14,9 +14,10 @@
#
# Helpers for simple cases
-def eci_from_header(c_header_source):
+def eci_from_header(c_header_source, include_dirs=[]):
return ExternalCompilationInfo(
- pre_include_bits=[c_header_source]
+ pre_include_bits=[c_header_source],
+ include_dirs=include_dirs
)
def getstruct(name, c_header_source, interesting_fields):
@@ -43,9 +44,9 @@
DEFINED = Defined(macro)
return configure(CConfig)['DEFINED']
-def has(name, c_header_source):
+def has(name, c_header_source, include_dirs=[]):
class CConfig:
- _compilation_info_ = eci_from_header(c_header_source)
+ _compilation_info_ = eci_from_header(c_header_source, include_dirs)
HAS = Has(name)
return configure(CConfig)['HAS']
@@ -57,9 +58,9 @@
WORKS = Works()
configure(CConfig)
-def checkcompiles(expression, c_header_source):
+def checkcompiles(expression, c_header_source, include_dirs=[]):
"""Check if expression compiles. If not, returns False"""
- return has(expression, c_header_source)
+ return has(expression, c_header_source, include_dirs)
def sizeof(name, eci, **kwds):
class CConfig:
More information about the Pypy-commit
mailing list