From 4e641c5a20a2c79b196804848a766b77f3358911 Mon Sep 17 00:00:00 2001 From: arvidn Date: Mon, 28 Oct 2024 16:47:43 +0100 Subject: [PATCH] fixup (macOS) --- include/libtorrent/aux_/file.hpp | 4 ---- include/libtorrent/aux_/path.hpp | 4 ---- include/libtorrent/config.hpp | 4 ++-- src/copy_file.cpp | 4 ---- src/file.cpp | 8 ++++++-- 5 files changed, 8 insertions(+), 16 deletions(-) diff --git a/include/libtorrent/aux_/file.hpp b/include/libtorrent/aux_/file.hpp index 94525ebc135..650547c6669 100644 --- a/include/libtorrent/aux_/file.hpp +++ b/include/libtorrent/aux_/file.hpp @@ -37,10 +37,6 @@ see LICENSE file. #define _GNU_SOURCE #endif -#ifndef _XOPEN_SOURCE -#define _XOPEN_SOURCE 600 -#endif - #include #include #include diff --git a/include/libtorrent/aux_/path.hpp b/include/libtorrent/aux_/path.hpp index ce88086de5e..95b5cd3509e 100644 --- a/include/libtorrent/aux_/path.hpp +++ b/include/libtorrent/aux_/path.hpp @@ -32,10 +32,6 @@ see LICENSE file. #define _GNU_SOURCE #endif -#ifndef _XOPEN_SOURCE -#define _XOPEN_SOURCE 600 -#endif - #include #include #include diff --git a/include/libtorrent/config.hpp b/include/libtorrent/config.hpp index 826463dfc2b..7ab8de523e0 100644 --- a/include/libtorrent/config.hpp +++ b/include/libtorrent/config.hpp @@ -129,7 +129,7 @@ see LICENSE file. #endif // Mac platforms added support for preadv()/pwritev() in MacOS 11, iOS 14 etc. -#if defined MAC_OS_X_VERSION_MIN_REQUIRED && MAC_OS_X_VERSION_MIN_REQUIRED >= 110000 +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 110000 # define TORRENT_USE_PWRITEV 1 #endif @@ -152,6 +152,7 @@ see LICENSE file. // non-Apple BSD #define TORRENT_USE_GETRANDOM 1 #define TORRENT_HAS_PTHREAD_SET_NAME 1 +#define TORRENT_USE_PWRITEV 1 #endif // __APPLE__ @@ -167,7 +168,6 @@ see LICENSE file. #define TORRENT_USE_IFADDRS 1 #define TORRENT_USE_SYSCTL 1 #define TORRENT_USE_IFCONF 1 -#define TORRENT_USE_PWRITEV 1 // ==== LINUX === diff --git a/src/copy_file.cpp b/src/copy_file.cpp index 536c0d36d2c..1c46d169fee 100644 --- a/src/copy_file.cpp +++ b/src/copy_file.cpp @@ -23,10 +23,6 @@ see LICENSE file. #define _GNU_SOURCE #endif -#ifndef _XOPEN_SOURCE -#define _XOPEN_SOURCE 600 -#endif - #include "libtorrent/aux_/file_descriptor.hpp" #include diff --git a/src/file.cpp b/src/file.cpp index 8d5c800cb96..1fe471a61f2 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -92,7 +92,9 @@ see LICENSE file. #endif // posix part #if TORRENT_USE_PWRITEV && defined TORRENT_BSD +#include #include // for pwritev() and iovec +#include // for pwritev() and iovec #endif #include "libtorrent/aux_/disable_warnings_pop.hpp" @@ -115,7 +117,7 @@ namespace { } bufs.front().iov_base = static_cast(bufs.front().iov_base) + advance_bytes; - bufs.front().iov_len -= advance_bytes; + bufs.front().iov_len -= static_cast(advance_bytes); return bufs; } return bufs; @@ -127,6 +129,8 @@ namespace { , std::int64_t file_offset , error_code& ec) { + // TODO: if bufs.size() > UIO_MAXIOV, we need to split up the call + // into multiple ones int ret = 0; TORRENT_ALLOCA(vec, iovec, bufs.size()); for (int i = 0; i < bufs.size(); ++i) @@ -136,7 +140,7 @@ namespace { } do { - ssize_t const r = ::pwritev(handle, vec.data(), vec.size(), file_offset); + ssize_t const r = ::pwritev(handle, vec.data(), static_cast(vec.size()), file_offset); if (r == 0) { ec = boost::asio::error::eof;