[pypy-commit] pypy py3.5: hg merge default
rlamy
pypy.commits at gmail.com
Wed Oct 26 14:36:58 EDT 2016
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: py3.5
Changeset: r87950:8a61624582bf
Date: 2016-10-26 19:36 +0100
http://bitbucket.org/pypy/pypy/changeset/8a61624582bf/
Log: hg merge default
diff --git a/rpython/rlib/rposix.py b/rpython/rlib/rposix.py
--- a/rpython/rlib/rposix.py
+++ b/rpython/rlib/rposix.py
@@ -249,6 +249,7 @@
SEEK_SET = rffi_platform.DefinedConstantInteger('SEEK_SET')
SEEK_CUR = rffi_platform.DefinedConstantInteger('SEEK_CUR')
SEEK_END = rffi_platform.DefinedConstantInteger('SEEK_END')
+ O_NONBLOCK = rffi_platform.DefinedConstantInteger('O_NONBLOCK')
OFF_T_SIZE = rffi_platform.SizeOf('off_t')
HAVE_UTIMES = rffi_platform.Has('utimes')
@@ -2353,3 +2354,42 @@
def cpu_count():
return rffi.cast(lltype.Signed, _cpu_count())
+
+if not _WIN32:
+ eci_status_flags = eci.merge(ExternalCompilationInfo(separate_module_sources=["""
+ RPY_EXTERN
+ int rpy_get_status_flags(int fd)
+ {
+ int flags;
+ flags = fcntl(fd, F_GETFL, 0);
+ return flags;
+ }
+
+ RPY_EXTERN
+ int rpy_set_status_flags(int fd, int flags)
+ {
+ int res;
+ res = fcntl(fd, F_SETFL, flags);
+ return res;
+ }
+ """], post_include_bits=[
+ "RPY_EXTERN int rpy_get_status_flags(int);\n"
+ "RPY_EXTERN int rpy_set_status_flags(int, int);"]
+ ))
+
+
+ c_get_status_flags = external('rpy_get_status_flags', [rffi.INT],
+ rffi.INT, save_err=rffi.RFFI_SAVE_ERRNO,
+ compilation_info=eci_status_flags)
+ c_set_status_flags = external('rpy_set_status_flags', [rffi.INT, rffi.INT],
+ rffi.INT, save_err=rffi.RFFI_SAVE_ERRNO,
+ compilation_info=eci_status_flags)
+
+ def get_status_flags(fd):
+ res = c_get_status_flags(fd)
+ res = handle_posix_error('get_status_flags', res)
+ return res
+
+ def set_status_flags(fd, flags):
+ res = c_set_status_flags(fd, flags)
+ handle_posix_error('set_status_flags', res)
diff --git a/rpython/rlib/test/test_rposix.py b/rpython/rlib/test/test_rposix.py
--- a/rpython/rlib/test/test_rposix.py
+++ b/rpython/rlib/test/test_rposix.py
@@ -612,3 +612,15 @@
def test_cpu_count():
cc = rposix.cpu_count()
assert cc >= 1
+
+ at rposix_requires('set_status_flags')
+def test_set_status_flags():
+ fd1, fd2 = os.pipe()
+ try:
+ flags = rposix.get_status_flags(fd1)
+ assert flags & rposix.O_NONBLOCK == 0
+ rposix.set_status_flags(fd1, flags | rposix.O_NONBLOCK)
+ assert rposix.get_status_flags(fd1) & rposix.O_NONBLOCK != 0
+ finally:
+ os.close(fd1)
+ os.close(fd2)
More information about the pypy-commit
mailing list