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,
// the clock resolution is worse than that, it will be larger. In
// essence we're aiming at making the quantization noise 0.01%.
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
// account for jitter.
......
......@@ -65,7 +65,10 @@
#error GCC required
#endif
#ifndef FOLLY_NO_CONFIG
#include "folly/folly-config.h"
#endif
#include "folly/detail/BitsDetail.h"
#include "folly/detail/BitIteratorDetail.h"
#include "folly/Likely.h"
......
......@@ -17,6 +17,9 @@
#include "folly/FileUtil.h"
#include <cerrno>
#ifdef __APPLE__
#include <fcntl.h>
#endif
#include "folly/detail/FileUtilDetail.h"
......@@ -50,7 +53,11 @@ int fsyncNoInt(int fd) {
}
int fdatasyncNoInt(int fd) {
#ifndef __APPLE__
return wrapNoInt(fdatasync, fd);
#else
return wrapNoInt(fcntl, fd, F_FULLFSYNC);
#endif
}
int ftruncateNoInt(int fd, off_t len) {
......
......@@ -64,14 +64,6 @@ namespace folly {
#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
* them so that we don't have to include jemalloc.h, in case the program is
......@@ -88,7 +80,19 @@ __attribute__((weak));
#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
namespace std _GLIBCXX_VISIBILITY(default) {
......
......@@ -17,7 +17,9 @@
#ifndef FOLLY_PORTABILITY_H_
#define FOLLY_PORTABILITY_H_
#ifndef FOLLY_NO_CONFIG
#include "folly-config.h"
#endif
#ifdef FOLLY_HAVE_FEATURES_H
#include <features.h>
......@@ -48,12 +50,21 @@ struct MaxAlign { char c; } __attribute__((aligned));
#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
* 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))
# if defined(__clang__) || __GNUC_PREREQ(4, 7)
# define FOLLY_FINAL final
# define FOLLY_OVERRIDE override
# else
......@@ -65,9 +76,11 @@ struct MaxAlign { char c; } __attribute__((aligned));
// 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
# if defined(__GLIBC_PREREQ)
# if __GLIBC_PREREQ(2, 10)
# define FOLLY_HAVE_PREADV 1
# define FOLLY_HAVE_PWRITEV 1
# endif
# endif
#endif
......
......@@ -25,6 +25,7 @@
#include <boost/thread/locks.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/locks.hpp>
#include <glog/logging.h>
......
......@@ -43,6 +43,10 @@
#include "folly/experimental/FileGen.h"
#include "folly/experimental/StringGen.h"
#ifndef MAP_POPULATE
#define MAP_POPULATE 0
#endif
namespace folly {
namespace {
......
......@@ -1010,7 +1010,7 @@ private:
try {
new (&newp[pos]) value_type(std::move(*v));
} catch (...) {
std::free(newh);
free(newh);
throw;
}
......@@ -1019,7 +1019,7 @@ private:
detail::moveToUninitialized(begin(), begin() + pos, newp);
} catch (...) {
newp[pos].~value_type();
std::free(newh);
free(newh);
throw;
}
......@@ -1032,7 +1032,7 @@ private:
for (size_type i = 0; i <= pos; ++i) {
newp[i].~value_type();
}
std::free(newh);
free(newh);
throw;
}
} else {
......@@ -1040,7 +1040,7 @@ private:
try {
detail::moveToUninitialized(begin(), end(), newp);
} catch (...) {
std::free(newh);
free(newh);
throw;
}
}
......@@ -1161,7 +1161,7 @@ private:
void freeHeap() {
auto vp = detail::pointerFlagClear(pdata_.heap_);
std::free(vp);
free(vp);
}
} FB_PACKED u;
} 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