Skip to content

Commit

Permalink
fixup (macOS)
Browse files Browse the repository at this point in the history
  • Loading branch information
arvidn committed Oct 28, 2024
1 parent 49202df commit 4e641c5
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 16 deletions.
4 changes: 0 additions & 4 deletions include/libtorrent/aux_/file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ see LICENSE file.
#define _GNU_SOURCE
#endif

#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE 600
#endif

#include <unistd.h>
#include <sys/uio.h>
#include <fcntl.h>
Expand Down
4 changes: 0 additions & 4 deletions include/libtorrent/aux_/path.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ see LICENSE file.
#define _GNU_SOURCE
#endif

#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE 600
#endif

#include <unistd.h>
#include <sys/uio.h>
#include <fcntl.h>
Expand Down
4 changes: 2 additions & 2 deletions include/libtorrent/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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__

Expand All @@ -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 ===
Expand Down
4 changes: 0 additions & 4 deletions src/copy_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <unistd.h>
Expand Down
8 changes: 6 additions & 2 deletions src/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ see LICENSE file.
#endif // posix part

#if TORRENT_USE_PWRITEV && defined TORRENT_BSD
#include <unistd.h>
#include <sys/uio.h> // for pwritev() and iovec
#include <sys/types.h> // for pwritev() and iovec
#endif

#include "libtorrent/aux_/disable_warnings_pop.hpp"
Expand All @@ -115,7 +117,7 @@ namespace {
}

bufs.front().iov_base = static_cast<char*>(bufs.front().iov_base) + advance_bytes;
bufs.front().iov_len -= advance_bytes;
bufs.front().iov_len -= static_cast<size_t>(advance_bytes);
return bufs;
}
return bufs;
Expand All @@ -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)
Expand All @@ -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<int>(vec.size()), file_offset);
if (r == 0)
{
ec = boost::asio::error::eof;
Expand Down

0 comments on commit 4e641c5

Please sign in to comment.