Skip to content

Instantly share code, notes, and snippets.

@tav
Created June 13, 2009 19:04
Show Gist options
  • Save tav/129385 to your computer and use it in GitHub Desktop.
Save tav/129385 to your computer and use it in GitHub Desktop.
diff --git a/third_party/generic/pypy/pypy/rpython/module/ll_os.py b/third_party/generic/pypy/pypy/rpython/module/ll_os.py
index ebcccf7..b012128 100644
--- a/third_party/generic/pypy/pypy/rpython/module/ll_os.py
+++ b/third_party/generic/pypy/pypy/rpython/module/ll_os.py
@@ -6,6 +6,9 @@ Low-level implementations for the external functions of the 'os' module.
# might be found in doc/rffi.txt
import os, sys, errno
+
+from distutils.sysconfig import get_python_inc
+
from pypy.rpython.module.support import ll_strcpy, OOSupport
from pypy.tool.sourcetools import func_with_new_name
from pypy.rlib.rarithmetic import r_longlong
@@ -89,9 +92,18 @@ class RegisterOs(BaseLazyRegistering):
self.configure(CConfig)
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>',
+ [get_python_inc()]
+ )
+
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>',
+ [get_python_inc()]
+ )
# we need an indirection via c functions to get macro calls working on llvm XXX still?
if hasattr(os, 'WCOREDUMP'):
diff --git a/third_party/generic/pypy/pypy/rpython/tool/rffi_platform.py b/third_party/generic/pypy/pypy/rpython/tool/rffi_platform.py
index 3c383e4..aa4620a 100755
--- a/third_party/generic/pypy/pypy/rpython/tool/rffi_platform.py
+++ b/third_party/generic/pypy/pypy/rpython/tool/rffi_platform.py
@@ -14,9 +14,10 @@ import distutils
#
# 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 @@ def getdefined(macro, c_header_source):
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 @@ def verify_eci(eci):
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:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment