Mercurial > hgrepos > FreeBSD > ports > PyPy
comparison files/patch-rpython_rlib_rposix.py @ 106:ffca34182746
Allow to build PyPy3 v7.3.11: PLIST changes and patches for os.sendmail() which is enabled now.
BUGS: Python 3.7 is not supported any more. The configuration option for PY37
needs to be removed.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Wed, 04 Jan 2023 15:50:00 +0100 |
| parents | |
| children | cf8f8a3eea6b |
comparison
equal
deleted
inserted
replaced
| 105:41f196ceb3b1 | 106:ffca34182746 |
|---|---|
| 1 --- rpython/rlib/rposix.py.orig 2022-12-29 08:05:46 UTC | |
| 2 +++ rpython/rlib/rposix.py | |
| 3 @@ -3014,6 +3014,30 @@ if sys.platform.startswith('linux'): | |
| 4 res = c_sendfile(out_fd, in_fd, lltype.nullptr(_OFF_PTR_T.TO), count) | |
| 5 return handle_posix_error('sendfile', res) | |
| 6 | |
| 7 +elif sys.platform.startswith('freebsd'): | |
| 8 + # FreeBSD | |
| 9 + # | |
| 10 + # Please note that the implementation below is partial; | |
| 11 + # the VOIDP is an iovec for sending headers and trailers which | |
| 12 + # CPython uses for the headers and trailers argument, and it also | |
| 13 + # has a flags argument. None of these are currently supported. | |
| 14 + sendfile_eci = ExternalCompilationInfo(includes=["sys/socket.h"]) | |
| 15 + _OFF_PTR_T = rffi.CArrayPtr(OFF_T) | |
| 16 + # NB: the VOIDP is an struct sf_hdtr for sending headers and trailers | |
| 17 + c_sendfile = rffi.llexternal('sendfile', | |
| 18 + [rffi.INT, rffi.INT, OFF_T, rffi.SIZE_T, rffi.VOIDP, _OFF_PTR_T, rffi.INT], | |
| 19 + rffi.INT, save_err=rffi.RFFI_SAVE_ERRNO, | |
| 20 + compilation_info=sendfile_eci) | |
| 21 + | |
| 22 + def sendfile(out_fd, in_fd, offset, count): | |
| 23 + with lltype.scoped_alloc(_OFF_PTR_T.TO, 1) as sbytes: | |
| 24 + sbytes[0] = 0 # rffi.cast(OFF_T, count) | |
| 25 + res = c_sendfile(in_fd, out_fd, offset, count, lltype.nullptr(rffi.VOIDP.TO), sbytes, 0) | |
| 26 + if res != 0: | |
| 27 + return handle_posix_error('sendfile', res) | |
| 28 + res = sbytes[0] | |
| 29 + return res | |
| 30 + | |
| 31 elif not _WIN32: | |
| 32 # Neither on Windows nor on Linux, so probably a BSD derivative of | |
| 33 # some sort. Please note that the implementation below is partial; |
