Commit edf5a373 authored by Daniel Sloof's avatar Daniel Sloof Committed by Owen Yamauchi

make folly build on OSX

Summary:
A squash of https://github.com/danslo/folly/compare/master

Github Author: danslo

Test Plan: he said it compiles on OSX

Reviewed By: oyamauchi@fb.com

FB internal diff: D830883
parent 93435568
...@@ -210,7 +210,8 @@ static double runBenchmarkGetNSPerIteration(const BenchmarkFun& fun, ...@@ -210,7 +210,8 @@ static double runBenchmarkGetNSPerIteration(const BenchmarkFun& fun,
// the clock resolution is worse than that, it will be larger. In // the clock resolution is worse than that, it will be larger. In
// essence we're aiming at making the quantization noise 0.01%. // essence we're aiming at making the quantization noise 0.01%.
static const auto minNanoseconds = static const auto minNanoseconds =
max(FLAGS_bm_min_usec * 1000UL, min(resolutionInNs * 100000, 1000000000UL)); max(FLAGS_bm_min_usec * 1000UL,
min(resolutionInNs * 100000, 1000000000ULL));
// We do measurements in several epochs and take the minimum, to // We do measurements in several epochs and take the minimum, to
// account for jitter. // account for jitter.
......
...@@ -65,7 +65,10 @@ ...@@ -65,7 +65,10 @@
#error GCC required #error GCC required
#endif #endif
#ifndef FOLLY_NO_CONFIG
#include "folly/folly-config.h" #include "folly/folly-config.h"
#endif
#include "folly/detail/BitsDetail.h" #include "folly/detail/BitsDetail.h"
#include "folly/detail/BitIteratorDetail.h" #include "folly/detail/BitIteratorDetail.h"
#include "folly/Likely.h" #include "folly/Likely.h"
......
...@@ -17,6 +17,9 @@ ...@@ -17,6 +17,9 @@
#include "folly/FileUtil.h" #include "folly/FileUtil.h"
#include <cerrno> #include <cerrno>
#ifdef __APPLE__
#include <fcntl.h>
#endif
#include "folly/detail/FileUtilDetail.h" #include "folly/detail/FileUtilDetail.h"
...@@ -50,7 +53,11 @@ int fsyncNoInt(int fd) { ...@@ -50,7 +53,11 @@ int fsyncNoInt(int fd) {
} }
int fdatasyncNoInt(int fd) { int fdatasyncNoInt(int fd) {
#ifndef __APPLE__
return wrapNoInt(fdatasync, fd); return wrapNoInt(fdatasync, fd);
#else
return wrapNoInt(fcntl, fd, F_FULLFSYNC);
#endif
} }
int ftruncateNoInt(int fd, off_t len) { int ftruncateNoInt(int fd, off_t len) {
......
...@@ -64,14 +64,6 @@ namespace folly { ...@@ -64,14 +64,6 @@ namespace folly {
#include <bits/functexcept.h> #include <bits/functexcept.h>
/**
* Declare rallocm() and malloc_usable_size() as weak symbols. It
* will be provided by jemalloc if we are using jemalloc, or it will
* be NULL if we are using another malloc implementation.
*/
extern "C" int rallocm(void**, size_t*, size_t, size_t, int)
__attribute__((weak));
/** /**
* Define various ALLOCM_* macros normally provided by jemalloc. We define * Define various ALLOCM_* macros normally provided by jemalloc. We define
* them so that we don't have to include jemalloc.h, in case the program is * them so that we don't have to include jemalloc.h, in case the program is
...@@ -88,7 +80,19 @@ __attribute__((weak)); ...@@ -88,7 +80,19 @@ __attribute__((weak));
#define ALLOCM_LG_ALIGN(la) (la) #define ALLOCM_LG_ALIGN(la) (la)
#endif /* !ALLOCM_SUCCESS */ #if defined(JEMALLOC_MANGLE) && defined(JEMALLOC_EXPERIMENTAL)
#define rallocm je_rallocm
#endif
#endif /* ALLOCM_SUCCESS */
/**
* Declare rallocm() and malloc_usable_size() as weak symbols. It
* will be provided by jemalloc if we are using jemalloc, or it will
* be NULL if we are using another malloc implementation.
*/
extern "C" int rallocm(void**, size_t*, size_t, size_t, int)
__attribute__((weak));
#ifdef _LIBSTDCXX_FBSTRING #ifdef _LIBSTDCXX_FBSTRING
namespace std _GLIBCXX_VISIBILITY(default) { namespace std _GLIBCXX_VISIBILITY(default) {
......
...@@ -17,7 +17,9 @@ ...@@ -17,7 +17,9 @@
#ifndef FOLLY_PORTABILITY_H_ #ifndef FOLLY_PORTABILITY_H_
#define FOLLY_PORTABILITY_H_ #define FOLLY_PORTABILITY_H_
#ifndef FOLLY_NO_CONFIG
#include "folly-config.h" #include "folly-config.h"
#endif
#ifdef FOLLY_HAVE_FEATURES_H #ifdef FOLLY_HAVE_FEATURES_H
#include <features.h> #include <features.h>
...@@ -48,12 +50,21 @@ struct MaxAlign { char c; } __attribute__((aligned)); ...@@ -48,12 +50,21 @@ struct MaxAlign { char c; } __attribute__((aligned));
#endif #endif
// portable version check
#ifndef __GNUC_PREREQ
# if defined __GNUC__ && defined __GNUC_MINOR__
# define __GNUC_PREREQ(maj, min) ((__GNUC__ << 16) + __GNUC_MINOR__ >= \
((maj) << 16) + (min))
# else
# define __GNUC_PREREQ(maj, min) 0
# endif
#endif
/* Define macro wrappers for C++11's "final" and "override" keywords, which /* Define macro wrappers for C++11's "final" and "override" keywords, which
* are supported in gcc 4.7 but not gcc 4.6. */ * are supported in gcc 4.7 but not gcc 4.6. */
#if !defined(FOLLY_FINAL) && !defined(FOLLY_OVERRIDE) #if !defined(FOLLY_FINAL) && !defined(FOLLY_OVERRIDE)
# if defined(__clang__) || \ # if defined(__clang__) || __GNUC_PREREQ(4, 7)
(defined(__GNUC__) && defined(__GNUC_MINOR__) && \
((__GNUC__ << 16) + __GNUC_MINOR__) >= ((4 << 16) + 7))
# define FOLLY_FINAL final # define FOLLY_FINAL final
# define FOLLY_OVERRIDE override # define FOLLY_OVERRIDE override
# else # else
...@@ -65,10 +76,12 @@ struct MaxAlign { char c; } __attribute__((aligned)); ...@@ -65,10 +76,12 @@ struct MaxAlign { char c; } __attribute__((aligned));
// Define to 1 if you have the `preadv' and `pwritev' functions, respectively // Define to 1 if you have the `preadv' and `pwritev' functions, respectively
#if !defined(FOLLY_HAVE_PREADV) && !defined(FOLLY_HAVE_PWRITEV) #if !defined(FOLLY_HAVE_PREADV) && !defined(FOLLY_HAVE_PWRITEV)
# if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 10) # if defined(__GLIBC_PREREQ)
# if __GLIBC_PREREQ(2, 10)
# define FOLLY_HAVE_PREADV 1 # define FOLLY_HAVE_PREADV 1
# define FOLLY_HAVE_PWRITEV 1 # define FOLLY_HAVE_PWRITEV 1
# endif # endif
# endif
#endif #endif
#endif // FOLLY_PORTABILITY_H_ #endif // FOLLY_PORTABILITY_H_
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <boost/thread/locks.hpp> #include <boost/thread/locks.hpp>
#include <boost/thread/mutex.hpp> #include <boost/thread/mutex.hpp>
#include <boost/thread/locks.hpp>
#include <glog/logging.h> #include <glog/logging.h>
......
...@@ -43,6 +43,10 @@ ...@@ -43,6 +43,10 @@
#include "folly/experimental/FileGen.h" #include "folly/experimental/FileGen.h"
#include "folly/experimental/StringGen.h" #include "folly/experimental/StringGen.h"
#ifndef MAP_POPULATE
#define MAP_POPULATE 0
#endif
namespace folly { namespace folly {
namespace { namespace {
......
...@@ -1010,7 +1010,7 @@ private: ...@@ -1010,7 +1010,7 @@ private:
try { try {
new (&newp[pos]) value_type(std::move(*v)); new (&newp[pos]) value_type(std::move(*v));
} catch (...) { } catch (...) {
std::free(newh); free(newh);
throw; throw;
} }
...@@ -1019,7 +1019,7 @@ private: ...@@ -1019,7 +1019,7 @@ private:
detail::moveToUninitialized(begin(), begin() + pos, newp); detail::moveToUninitialized(begin(), begin() + pos, newp);
} catch (...) { } catch (...) {
newp[pos].~value_type(); newp[pos].~value_type();
std::free(newh); free(newh);
throw; throw;
} }
...@@ -1032,7 +1032,7 @@ private: ...@@ -1032,7 +1032,7 @@ private:
for (size_type i = 0; i <= pos; ++i) { for (size_type i = 0; i <= pos; ++i) {
newp[i].~value_type(); newp[i].~value_type();
} }
std::free(newh); free(newh);
throw; throw;
} }
} else { } else {
...@@ -1040,7 +1040,7 @@ private: ...@@ -1040,7 +1040,7 @@ private:
try { try {
detail::moveToUninitialized(begin(), end(), newp); detail::moveToUninitialized(begin(), end(), newp);
} catch (...) { } catch (...) {
std::free(newh); free(newh);
throw; throw;
} }
} }
...@@ -1161,7 +1161,7 @@ private: ...@@ -1161,7 +1161,7 @@ private:
void freeHeap() { void freeHeap() {
auto vp = detail::pointerFlagClear(pdata_.heap_); auto vp = detail::pointerFlagClear(pdata_.heap_);
std::free(vp); free(vp);
} }
} FB_PACKED u; } FB_PACKED u;
} FB_PACKED; } FB_PACKED;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment