comparison lang/pypy311/files/patch-rpython_rlib_rposix.py @ 201:aa93453cd531

Build PyPy3 for Python implementation 3.11. BUGS: - pypy39 not yet deleted. - Tests are not working yet.
author Franz Glasner <fzglas.hg@dom66.de>
date Wed, 12 Mar 2025 17:01:42 +0100
parents lang/pypy310/files/patch-rpython_rlib_rposix.py@8b567a874360
children
comparison
equal deleted inserted replaced
200:792fb463576a 201:aa93453cd531
1 --- rpython/rlib/rposix.py.orig 2025-02-24 17:28:26 UTC
2 +++ rpython/rlib/rposix.py
3 @@ -212,6 +212,8 @@ else:
4 includes.append('sys/sysmacros.h')
5 if sys.platform.startswith('freebsd') or sys.platform.startswith('openbsd'):
6 includes.append('sys/ttycom.h')
7 + if sys.platform.startswith('freebsd') or sys.platform.startswith('openbsd'):
8 + includes.append('termios.h')
9 libraries = ['util']
10
11 eci = ExternalCompilationInfo(
12 @@ -3067,6 +3069,30 @@ if sys.platform.startswith('linux'):
13 """Passes offset==NULL; not support on all OSes"""
14 res = c_sendfile(out_fd, in_fd, lltype.nullptr(_OFF_PTR_T.TO), count)
15 return handle_posix_error('sendfile', res)
16 +
17 +elif sys.platform.startswith('freebsd'):
18 + # FreeBSD
19 + #
20 + # Please note that the implementation below is partial;
21 + # the VOIDP is an iovec for sending headers and trailers which
22 + # CPython uses for the headers and trailers argument, and it also
23 + # has a flags argument. None of these are currently supported.
24 + sendfile_eci = ExternalCompilationInfo(includes=["sys/socket.h"])
25 + _OFF_PTR_T = rffi.CArrayPtr(OFF_T)
26 + # NB: the VOIDP is an struct sf_hdtr for sending headers and trailers
27 + c_sendfile = rffi.llexternal('sendfile',
28 + [rffi.INT, rffi.INT, OFF_T, rffi.SIZE_T, rffi.VOIDP, _OFF_PTR_T, rffi.INT],
29 + rffi.INT, save_err=rffi.RFFI_SAVE_ERRNO,
30 + compilation_info=sendfile_eci)
31 +
32 + def sendfile(out_fd, in_fd, offset, count):
33 + with lltype.scoped_alloc(_OFF_PTR_T.TO, 1) as sbytes:
34 + sbytes[0] = 0 # rffi.cast(OFF_T, count)
35 + res = c_sendfile(in_fd, out_fd, offset, count, lltype.nullptr(rffi.VOIDP.TO), sbytes, 0)
36 + if res != 0:
37 + return handle_posix_error('sendfile', res)
38 + res = sbytes[0]
39 + return res
40
41 elif not _WIN32:
42 # Neither on Windows nor on Linux, so probably a BSD derivative of