diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lang/pypy311/files/patch-rpython_rlib_rposix.py	Wed Mar 12 17:01:42 2025 +0100
@@ -0,0 +1,42 @@
+--- rpython/rlib/rposix.py.orig	2025-02-24 17:28:26 UTC
++++ rpython/rlib/rposix.py
+@@ -212,6 +212,8 @@ else:
+         includes.append('sys/sysmacros.h')
+     if sys.platform.startswith('freebsd') or sys.platform.startswith('openbsd'):
+         includes.append('sys/ttycom.h')
++    if sys.platform.startswith('freebsd') or sys.platform.startswith('openbsd'):
++        includes.append('termios.h')
+     libraries = ['util']
+ 
+ eci = ExternalCompilationInfo(
+@@ -3067,6 +3069,30 @@ if sys.platform.startswith('linux'):
+         """Passes offset==NULL; not support on all OSes"""
+         res = c_sendfile(out_fd, in_fd, lltype.nullptr(_OFF_PTR_T.TO), count)
+         return handle_posix_error('sendfile', res)
++
++elif sys.platform.startswith('freebsd'):    
++    # FreeBSD
++    #
++    # Please note that the implementation below is partial;
++    # the VOIDP is an iovec for sending headers and trailers which
++    # CPython uses for the headers and trailers argument, and it also
++    # has a flags argument. None of these are currently supported.
++    sendfile_eci = ExternalCompilationInfo(includes=["sys/socket.h"])
++    _OFF_PTR_T = rffi.CArrayPtr(OFF_T)
++    # NB: the VOIDP is an struct sf_hdtr for sending headers and trailers
++    c_sendfile = rffi.llexternal('sendfile',
++            [rffi.INT, rffi.INT, OFF_T, rffi.SIZE_T, rffi.VOIDP, _OFF_PTR_T, rffi.INT],
++            rffi.INT, save_err=rffi.RFFI_SAVE_ERRNO,
++            compilation_info=sendfile_eci)
++
++    def sendfile(out_fd, in_fd, offset, count):
++        with lltype.scoped_alloc(_OFF_PTR_T.TO, 1) as sbytes:
++            sbytes[0] = 0  # rffi.cast(OFF_T, count)
++            res = c_sendfile(in_fd, out_fd, offset, count, lltype.nullptr(rffi.VOIDP.TO), sbytes, 0)
++            if res != 0:
++                return handle_posix_error('sendfile', res)
++            res = sbytes[0]
++        return res    
+ 
+ elif not _WIN32:
+     # Neither on Windows nor on Linux, so probably a BSD derivative of