[pypy-commit] pypy default: merge heads
arigo
pypy.commits at gmail.com
Tue Aug 16 14:06:40 EDT 2016
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r86233:b7fe3a8d6872
Date: 2016-08-16 20:05 +0200
http://bitbucket.org/pypy/pypy/changeset/b7fe3a8d6872/
Log: merge heads
diff --git a/pypy/module/_multibytecodec/src/cjkcodecs/cjkcodecs.h b/pypy/module/_multibytecodec/src/cjkcodecs/cjkcodecs.h
--- a/pypy/module/_multibytecodec/src/cjkcodecs/cjkcodecs.h
+++ b/pypy/module/_multibytecodec/src/cjkcodecs/cjkcodecs.h
@@ -268,22 +268,26 @@
min = 0;
max = haystacksize;
- for (pos = haystacksize >> 1; min != max; pos = (min + max) >> 1)
+ for (pos = haystacksize >> 1; min != max; pos = (min + max) >> 1) {
if (value < haystack[pos].uniseq) {
- if (max == pos) break;
- else max = pos;
+ if (max != pos) {
+ max = pos;
+ continue;
+ }
}
else if (value > haystack[pos].uniseq) {
- if (min == pos) break;
- else min = pos;
+ if (min != pos) {
+ min = pos;
+ continue;
+ }
}
- else
- break;
+ break;
+ }
- if (value == haystack[pos].uniseq)
- return haystack[pos].code;
- else
- return DBCINV;
+ if (value == haystack[pos].uniseq) {
+ return haystack[pos].code;
+ }
+ return DBCINV;
}
#endif
diff --git a/rpython/rlib/rposix.py b/rpython/rlib/rposix.py
--- a/rpython/rlib/rposix.py
+++ b/rpython/rlib/rposix.py
@@ -96,12 +96,15 @@
return 0;
}
''',]
+ post_include_bits=['RPY_EXTERN int _PyVerify_fd(int);']
else:
separate_module_sources = []
+ post_include_bits = []
includes=['errno.h','stdio.h']
errno_eci = ExternalCompilationInfo(
includes=includes,
separate_module_sources=separate_module_sources,
+ post_include_bits=post_include_bits,
)
# Direct getters/setters, don't use directly!
@@ -2046,3 +2049,40 @@
def mknodat(path, mode, device, dir_fd=AT_FDCWD):
error = c_mknodat(dir_fd, path, mode, device)
handle_posix_error('mknodat', error)
+
+
+eci_inheritable = eci.merge(ExternalCompilationInfo(
+ separate_module_sources=["""
+RPY_EXTERN
+int rpy_set_inheritable(int fd, int inheritable)
+{
+ /* XXX minimal impl. XXX */
+ int request = inheritable ? FIONCLEX : FIOCLEX;
+ return ioctl(fd, request, NULL);
+}
+RPY_EXTERN
+int rpy_get_inheritable(int fd)
+{
+ int flags = fcntl(fd, F_GETFD, 0);
+ if (flags == -1)
+ return -1;
+ return !(flags & FD_CLOEXEC);
+}
+ """],
+ post_include_bits=['RPY_EXTERN int rpy_set_inheritable(int, int);']))
+
+c_set_inheritable = external('rpy_set_inheritable', [rffi.INT, rffi.INT],
+ rffi.INT, save_err=rffi.RFFI_SAVE_ERRNO,
+ compilation_info=eci_inheritable)
+c_get_inheritable = external('rpy_get_inheritable', [rffi.INT],
+ rffi.INT, save_err=rffi.RFFI_SAVE_ERRNO,
+ compilation_info=eci_inheritable)
+
+def set_inheritable(fd, inheritable):
+ error = c_set_inheritable(fd, inheritable)
+ handle_posix_error('set_inheritable', error)
+
+def get_inheritable(fd):
+ res = c_get_inheritable(fd)
+ res = handle_posix_error('get_inheritable', res)
+ return res != 0
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
@@ -572,3 +572,12 @@
os.close(dirfd)
assert tmpdir.join('file').check(exists=False)
assert tmpdir.join('file2').check(exists=True)
+
+def test_set_inheritable():
+ fd1, fd2 = os.pipe()
+ rposix.set_inheritable(fd1, True)
+ assert rposix.get_inheritable(fd1) == True
+ rposix.set_inheritable(fd1, False)
+ assert rposix.get_inheritable(fd1) == False
+ os.close(fd1)
+ os.close(fd2)
More information about the pypy-commit
mailing list