comparison lang/pypy3/files/patch-rpython_rlib_rposix.py @ 120:3b09db02a788

Move the old lang/pypy3 repo into the lang/pypy3 folder
author Franz Glasner <fzglas.hg@dom66.de>
date Fri, 12 Jan 2024 09:23:35 +0100
parents files/patch-rpython_rlib_rposix.py@cf8f8a3eea6b
children
comparison
equal deleted inserted replaced
119:cbf8c9785be8 120:3b09db02a788
1 --- rpython/rlib/rposix.py.orig 2023-12-24 19:15:32 UTC
2 +++ rpython/rlib/rposix.py
3 @@ -214,6 +214,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 @@ -3057,6 +3059,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