PicoSpinLock.h \
Portability.h \
portability/Syscall.h \
+ portability/SysUio.h \
ConditionallyExistent.h \
Preprocessor.h \
ProducerConsumerQueue.h \
#include <cerrno>
#include <unistd.h>
-#include <sys/uio.h>
+#include <folly/portability/SysUio.h>
/**
* Helper functions and templates for FileUtil.cpp. Declared here so
ssize_t totalBytes = 0;
size_t r;
do {
- r = f(fd, iov, std::min(count, IOV_MAX), offset...);
+ r = f(fd, iov, std::min<int>(count, kIovMax), offset...);
if (r == (size_t)-1) {
if (errno == EINTR) {
continue;
#include <folly/io/async/EventHandler.h>
#include <folly/SocketAddress.h>
#include <folly/io/IOBuf.h>
+#include <folly/portability/SysUio.h>
#include <poll.h>
#include <errno.h>
msg.msg_name = nullptr;
msg.msg_namelen = 0;
msg.msg_iov = const_cast<iovec *>(vec);
-#ifdef IOV_MAX // not defined on Android
- msg.msg_iovlen = std::min(count, (uint32_t)IOV_MAX);
-#else
- msg.msg_iovlen = std::min(count, (uint32_t)UIO_MAXIOV);
-#endif
+ msg.msg_iovlen = std::min<size_t>(count, kIovMax);
msg.msg_control = nullptr;
msg.msg_controllen = 0;
msg.msg_flags = 0;
--- /dev/null
+/*
+ * Copyright 2016 Facebook, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FOLLY_SYSUIO_H_
+#define FOLLY_SYSUIO_H_
+
+#include <sys/uio.h>
+
+namespace folly {
+
+#ifdef IOV_MAX // not defined on Android
+constexpr size_t kIovMax = IOV_MAX;
+#else
+constexpr size_t kIovMax = UIO_MAXIOV;
+#endif
+}
+
+#endif