Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Unbreak build on glibc 2.5.1

Summary:
Also move manually-generated stuff away from folly-config.h and into
Portability.h.  This should be only for things that differs between the
various (compiler, library) pairs used internally at FB; everything else
should be autoconf-ed and therefore go into folly-config.h.

Test Plan: built and ran file_util_test on various platforms

Reviewed By: delong.j@fb.com

FB internal diff: D807067

Blame Revision: D806781
  • Loading branch information...
commit 9cdd19b750f66db9171344c9db2d21c27de467d9 1 parent 531568a
@tudor tudor authored sgolemon committed
View
4 folly/FileUtil.cpp
@@ -85,17 +85,21 @@ ssize_t readvFull(int fd, iovec* iov, int count) {
return wrapvFull(readv, fd, iov, count);
}
+#ifdef FOLLY_HAVE_PREADV
ssize_t preadvFull(int fd, iovec* iov, int count, off_t offset) {
return wrapvFull(preadv, fd, iov, count, offset);
}
+#endif
ssize_t writevFull(int fd, iovec* iov, int count) {
return wrapvFull(writev, fd, iov, count);
}
+#ifdef FOLLY_HAVE_PWRITEV
ssize_t pwritevFull(int fd, iovec* iov, int count, off_t offset) {
return wrapvFull(pwritev, fd, iov, count, offset);
}
+#endif
} // namespaces
View
6 folly/FileUtil.h
@@ -17,6 +17,8 @@
#ifndef FOLLY_FILEUTIL_H_
#define FOLLY_FILEUTIL_H_
+#include "folly/Portability.h"
+
#include <sys/uio.h>
#include <unistd.h>
@@ -63,7 +65,9 @@ ssize_t writevNoInt(int fd, const iovec* iov, int count);
ssize_t readFull(int fd, void* buf, size_t n);
ssize_t preadFull(int fd, void* buf, size_t n, off_t offset);
ssize_t readvFull(int fd, iovec* iov, int count);
+#ifdef FOLLY_HAVE_PREADV
ssize_t preadvFull(int fd, iovec* iov, int count, off_t offset);
+#endif
/**
* Similar to readFull and preadFull above, wrappers around write() and
@@ -82,7 +86,9 @@ ssize_t preadvFull(int fd, iovec* iov, int count, off_t offset);
ssize_t writeFull(int fd, const void* buf, size_t n);
ssize_t pwriteFull(int fd, const void* buf, size_t n, off_t offset);
ssize_t writevFull(int fd, iovec* iov, int count);
+#ifdef FOLLY_HAVE_PWRITEV
ssize_t pwritevFull(int fd, iovec* iov, int count, off_t offset);
+#endif
} // namespaces
View
2  folly/Malloc.h
@@ -43,7 +43,7 @@ namespace folly {
#pragma GCC system_header
#define FOLLY_HAVE_MALLOC_H 1
#else
-#include "folly-config.h"
+#include "folly/Portability.h"
#endif
// for malloc_usable_size
View
31 folly/Portability.h
@@ -19,6 +19,11 @@
#include "folly-config.h"
+#ifdef FOLLY_HAVE_FEATURES_H
+#include <features.h>
+#endif
+
+
#ifdef FOLLY_HAVE_SCHED_H
#include <sched.h>
#ifndef FOLLY_HAVE_PTHREAD_YIELD
@@ -34,10 +39,36 @@ struct MaxAlign { char c; } __attribute__((aligned));
# error Cannot define MaxAlign on this platform
#endif
+
+// noreturn
#if defined(__clang__) || defined(__GNUC__)
# define FOLLY_NORETURN __attribute__((noreturn))
#else
# define FOLLY_NORETURN
#endif
+
+/* Define macro wrappers for C++11's "final" and "override" keywords, which
+ * are supported in gcc 4.7 but not gcc 4.6. */
+#if !defined(FOLLY_FINAL) && !defined(FOLLY_OVERRIDE)
+# if defined(__clang__) || \
+ (defined(__GNUC__) && defined(__GNUC_MINOR__) && \
+ ((__GNUC__ << 16) + __GNUC_MINOR__) >= ((4 << 16) + 7))
+# define FOLLY_FINAL final
+# define FOLLY_OVERRIDE override
+# else
+# define FOLLY_FINAL /**/
+# define FOLLY_OVERRIDE /**/
+# endif
+#endif
+
+
+// Define to 1 if you have the `preadv' and `pwritev' functions, respectively
+#if !defined(FOLLY_HAVE_PREADV) && !defined(FOLLY_HAVE_PWRITEV)
+# if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 10)
+# define FOLLY_HAVE_PREADV 1
+# define FOLLY_HAVE_PWRITEV 1
+# endif
+#endif
+
#endif // FOLLY_PORTABILITY_H_
View
2  folly/Range.h
@@ -20,7 +20,7 @@
#ifndef FOLLY_RANGE_H_
#define FOLLY_RANGE_H_
-#include "folly/folly-config.h"
+#include "folly/Portability.h"
#include "folly/FBString.h"
#include <glog/logging.h>
#include <algorithm>
View
2  folly/configure.ac
@@ -38,7 +38,7 @@ AX_BOOST_SYSTEM
# Checks for header files.
AC_HEADER_STDC
-AC_CHECK_HEADERS([fcntl.h inttypes.h limits.h stdint.h stdlib.h string.h sys/time.h unistd.h mutex.h malloc.h emmintrin.h byteswap.h])
+AC_CHECK_HEADERS([fcntl.h features.h inttypes.h limits.h stdint.h stdlib.h string.h sys/time.h unistd.h mutex.h malloc.h emmintrin.h byteswap.h])
AC_CHECK_HEADER(double-conversion.h, [], [AC_MSG_ERROR(
[Couldn't find double-conversion.h, please download from \
View
11 folly/io/RecordIO.cpp
@@ -22,6 +22,7 @@
#include "folly/Exception.h"
#include "folly/FileUtil.h"
#include "folly/Memory.h"
+#include "folly/Portability.h"
#include "folly/ScopeGuard.h"
#include "folly/String.h"
@@ -51,11 +52,19 @@ void RecordIOWriter::write(std::unique_ptr<IOBuf> buf) {
}
DCHECK_EQ(buf->computeChainDataLength(), totalLength);
- auto iov = buf->getIov();
// We're going to write. Reserve space for ourselves.
off_t pos = filePos_.fetch_add(totalLength);
+
+#ifdef FOLLY_HAVE_PWRITEV
+ auto iov = buf->getIov();
ssize_t bytes = pwritevFull(file_.fd(), iov.data(), iov.size(), pos);
+#else
+ buf->unshare();
+ buf->coalesce();
+ ssize_t bytes = pwriteFull(file_.fd(), buf->data(), buf->length(), pos);
+#endif
+
checkUnixError(bytes, "pwrite() failed");
DCHECK_EQ(bytes, totalLength);
}
View
2  folly/test/FileUtilTest.cpp
@@ -222,6 +222,7 @@ TEST_F(FileUtilTest, readv) {
}
}
+#ifdef FOLLY_HAVE_PREADV
TEST_F(FileUtilTest, preadv) {
for (auto& p : readers_) {
IovecBuffers buf({12, 19, 31});
@@ -235,6 +236,7 @@ TEST_F(FileUtilTest, preadv) {
}
}
}
+#endif
}} // namespaces
Please sign in to comment.
Something went wrong with that request. Please try again.