[pypy-commit] pypy default: On Windows it's a compilation error to try to assign to "stdin". Fix by
arigo
noreply at buildbot.pypy.org
Fri Nov 7 15:51:43 CET 2014
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r74374:7bea28d4aab3
Date: 2014-11-07 15:48 +0100
http://bitbucket.org/pypy/pypy/changeset/7bea28d4aab3/
Log: On Windows it's a compilation error to try to assign to "stdin".
Fix by not generating the setter function if not required.
diff --git a/rpython/rlib/rfile.py b/rpython/rlib/rfile.py
--- a/rpython/rlib/rfile.py
+++ b/rpython/rlib/rfile.py
@@ -96,9 +96,12 @@
c_ferror = llexternal('ferror', [FILEP], rffi.INT)
c_clearerr = llexternal('clearerr', [FILEP], lltype.Void)
-c_stdin = rffi.CExternVariable(FILEP, 'stdin', eci, c_type='FILE*')[0]
-c_stdout = rffi.CExternVariable(FILEP, 'stdout', eci, c_type='FILE*')[0]
-c_stderr = rffi.CExternVariable(FILEP, 'stderr', eci, c_type='FILE*')[0]
+c_stdin = rffi.CExternVariable(FILEP, 'stdin', eci, c_type='FILE*',
+ getter_only=True)
+c_stdout = rffi.CExternVariable(FILEP, 'stdout', eci, c_type='FILE*',
+ getter_only=True)
+c_stderr = rffi.CExternVariable(FILEP, 'stderr', eci, c_type='FILE*',
+ getter_only=True)
def _error(ll_file):
diff --git a/rpython/rtyper/lltypesystem/rffi.py b/rpython/rtyper/lltypesystem/rffi.py
--- a/rpython/rtyper/lltypesystem/rffi.py
+++ b/rpython/rtyper/lltypesystem/rffi.py
@@ -605,7 +605,7 @@
def CExternVariable(TYPE, name, eci, _CConstantClass=CConstant,
sandboxsafe=False, _nowrapper=False,
- c_type=None):
+ c_type=None, getter_only=False):
"""Return a pair of functions - a getter and a setter - to access
the given global C variable.
"""
@@ -638,19 +638,26 @@
if sys.platform != 'win32':
lines.append('extern %s %s;' % (c_type, name))
lines.append(c_getter)
- lines.append(c_setter)
+ if not getter_only:
+ lines.append(c_setter)
+ prototypes = [getter_prototype]
+ if not getter_only:
+ prototypes.append(setter_prototype)
sources = ('\n'.join(lines),)
new_eci = eci.merge(ExternalCompilationInfo(
separate_module_sources = sources,
- post_include_bits = [getter_prototype, setter_prototype],
+ post_include_bits = prototypes,
))
getter = llexternal(getter_name, [], TYPE, compilation_info=new_eci,
sandboxsafe=sandboxsafe, _nowrapper=_nowrapper)
- setter = llexternal(setter_name, [TYPE], lltype.Void,
- compilation_info=new_eci, sandboxsafe=sandboxsafe,
- _nowrapper=_nowrapper)
- return getter, setter
+ if getter_only:
+ return getter
+ else:
+ setter = llexternal(setter_name, [TYPE], lltype.Void,
+ compilation_info=new_eci, sandboxsafe=sandboxsafe,
+ _nowrapper=_nowrapper)
+ return getter, setter
# char, represented as a Python character
# (use SIGNEDCHAR or UCHAR for the small integer types)
More information about the pypy-commit
mailing list