Commit 328ab26d authored by David Carlier's avatar David Carlier Committed by Facebook Github Bot

FreeBSD build fix regarding native parts.

Summary: Pull Request resolved: https://github.com/facebook/folly/pull/1248

Reviewed By: yfeldblum

Differential Revision: D18094432

Pulled By: Orvid

fbshipit-source-id: 115afedc62be8881941cfb4d0e02748be349763f
parent 9b2ba17c
...@@ -53,11 +53,12 @@ inline void deallocateBytes(void* p, size_t n) { ...@@ -53,11 +53,12 @@ inline void deallocateBytes(void* p, size_t n) {
#endif #endif
} }
#if _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600 || \ #if _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600 || \
(defined(__ANDROID__) && (__ANDROID_API__ > 16)) || \ (defined(__ANDROID__) && (__ANDROID_API__ > 16)) || \
(defined(__APPLE__) && \ (defined(__APPLE__) && \
(__MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_6 || \ (__MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_6 || \
__IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_3_0)) __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_3_0)) || \
defined(__FreeBSD__)
inline void* aligned_malloc(size_t size, size_t align) { inline void* aligned_malloc(size_t size, size_t align) {
// use posix_memalign, but mimic the behaviour of memalign // use posix_memalign, but mimic the behaviour of memalign
......
...@@ -558,7 +558,11 @@ int Subprocess::prepareChild( ...@@ -558,7 +558,11 @@ int Subprocess::prepareChild(
#endif #endif
if (options.processGroupLeader_) { if (options.processGroupLeader_) {
#if !defined(__FreeBSD__)
if (setpgrp() == -1) { if (setpgrp() == -1) {
#else
if (setpgrp(getpid(), getpgrp()) == -1) {
#endif
return errno; return errno;
} }
} }
......
...@@ -24,7 +24,12 @@ namespace __cxxabiv1 { ...@@ -24,7 +24,12 @@ namespace __cxxabiv1 {
// forward declaration (originally defined in unwind-cxx.h from from libstdc++) // forward declaration (originally defined in unwind-cxx.h from from libstdc++)
struct __cxa_eh_globals; struct __cxa_eh_globals;
// declared in cxxabi.h from libstdc++-v3 // declared in cxxabi.h from libstdc++-v3
#if !defined(__FreeBSD__)
extern "C" __cxa_eh_globals* __cxa_get_globals() noexcept; extern "C" __cxa_eh_globals* __cxa_get_globals() noexcept;
#else
// Signature mismatch with FreeBSD case
extern "C" __cxa_eh_globals* __cxa_get_globals();
#endif
} // namespace __cxxabiv1 } // namespace __cxxabiv1
#elif defined(FOLLY_FORCE_EXCEPTION_COUNT_USE_STD) || defined(_MSC_VER) #elif defined(FOLLY_FORCE_EXCEPTION_COUNT_USE_STD) || defined(_MSC_VER)
#define FOLLY_EXCEPTION_COUNT_USE_STD #define FOLLY_EXCEPTION_COUNT_USE_STD
......
...@@ -98,8 +98,6 @@ mallctlbymib(const size_t*, size_t, void*, size_t*, void*, size_t) ...@@ -98,8 +98,6 @@ mallctlbymib(const size_t*, size_t, void*, size_t*, void*, size_t)
// are found in stdlib.h. // are found in stdlib.h.
#if __has_include(<malloc.h>) #if __has_include(<malloc.h>)
#include <malloc.h> #include <malloc.h>
#else
#include <stdlib.h>
#endif #endif
#include <cassert> #include <cassert>
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
// malloc_usable_size, and that's what we should be using. // malloc_usable_size, and that's what we should be using.
#include <jemalloc/jemalloc.h> // @manual #include <jemalloc/jemalloc.h> // @manual
#else #else
#ifndef __APPLE__ #if __has_include(<malloc.h>)
#include <malloc.h> #include <malloc.h>
#endif #endif
......
...@@ -22,6 +22,10 @@ ...@@ -22,6 +22,10 @@
#include <pthread.h> #include <pthread.h>
#if defined(__FreeBSD__)
#include <sys/thr.h>
#endif
#elif !FOLLY_HAVE_PTHREAD #elif !FOLLY_HAVE_PTHREAD
#include <cstdint> #include <cstdint>
......
...@@ -48,6 +48,11 @@ char*** _NSGetEnviron(void); ...@@ -48,6 +48,11 @@ char*** _NSGetEnviron(void);
#define environ (*_NSGetEnviron()) #define environ (*_NSGetEnviron())
#endif #endif
#if defined(__FreeBSD__)
// Needed to resolve linkage
char** environ;
#endif
#if !__linux__ && !FOLLY_MOBILE #if !__linux__ && !FOLLY_MOBILE
int clearenv(); int clearenv();
#endif #endif
......
...@@ -84,6 +84,10 @@ inline uint64_t getOSThreadID() { ...@@ -84,6 +84,10 @@ inline uint64_t getOSThreadID() {
return tid; return tid;
#elif defined(_WIN32) #elif defined(_WIN32)
return uint64_t(GetCurrentThreadId()); return uint64_t(GetCurrentThreadId());
#elif defined(__FreeBSD__)
long tid;
thr_self(&tid);
return uint64_t(tid);
#else #else
return uint64_t(syscall(FOLLY_SYS_gettid)); return uint64_t(syscall(FOLLY_SYS_gettid));
#endif #endif
......
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