fix HHVM compilation on FreeBSD

- fix HHVM compilation on FreeBSD

Closes #874
Esse commit está contido em:
Martin Matuska
2013-07-23 14:43:24 -07:00
commit de Sara Golemon
commit 1a5cc943e5
9 arquivos alterados com 36 adições e 29 exclusões
+1 -1
Ver Arquivo
@@ -1300,7 +1300,7 @@ static void on_timeout(int sig, siginfo_t* info, void* context) {
void hphp_process_init() {
pthread_attr_t attr;
#ifndef __APPLE__
#ifdef _GNU_SOURCE
pthread_getattr_np(pthread_self(), &attr);
#else
pthread_attr_init(&attr);
+18 -17
Ver Arquivo
@@ -27,32 +27,33 @@
#include "hphp/util/cycles.h"
#ifdef __FreeBSD__
# include <sys/resource.h>
# include <sys/cpuset.h>
# define cpu_set_t cpuset_t
# define SET_AFFINITY(pid, size, mask) \
#include <sys/resource.h>
#include <sys/param.h>
#include <sys/cpuset.h>
#define cpu_set_t cpuset_t
#define SET_AFFINITY(pid, size, mask) \
cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_TID, -1, size, mask)
# define GET_AFFINITY(pid, size, mask) \
#define GET_AFFINITY(pid, size, mask) \
cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_TID, -1, size, mask)
#elif __APPLE__
# include <mach/mach_init.h>
# include <mach/thread_policy.h>
# include <mach/thread_act.h>
#elif defined(__APPLE__)
#include <mach/mach_init.h>
#include <mach/thread_policy.h>
#include <mach/thread_act.h>
# define cpu_set_t thread_affinity_policy_data_t
# define CPU_SET(cpu_id, new_mask) \
#define cpu_set_t thread_affinity_policy_data_t
#define CPU_SET(cpu_id, new_mask) \
(*(new_mask)).affinity_tag = (cpu_id + 1)
# define CPU_ZERO(new_mask) \
#define CPU_ZERO(new_mask) \
(*(new_mask)).affinity_tag = THREAD_AFFINITY_TAG_NULL
# define GET_AFFINITY(pid, size, mask) \
#define GET_AFFINITY(pid, size, mask) \
(*(mask)).affinity_tag = THREAD_AFFINITY_TAG_NULL
# define SET_AFFINITY(pid, size, mask) \
#define SET_AFFINITY(pid, size, mask) \
thread_policy_set(mach_thread_self(), THREAD_AFFINITY_POLICY, \
(int *)mask, THREAD_AFFINITY_POLICY_COUNT)
#else
# include <sched.h>
# define SET_AFFINITY(pid, size, mask) sched_setaffinity(0, size, mask)
# define GET_AFFINITY(pid, size, mask) sched_getaffinity(0, size, mask)
#include <sched.h>
#define SET_AFFINITY(pid, size, mask) sched_setaffinity(0, size, mask)
#define GET_AFFINITY(pid, size, mask) sched_getaffinity(0, size, mask)
#endif
+4 -1
Ver Arquivo
@@ -20,6 +20,9 @@
#include <sys/times.h>
#include <sys/utsname.h>
#include <sys/types.h>
#ifdef __FreeBSD__
#include <sys/param.h>
#endif
#include <sys/time.h>
#include <pwd.h>
#include <memory>
@@ -421,7 +424,7 @@ Variant f_posix_uname() {
ret.set(s_release, String(u.release, CopyString));
ret.set(s_version, String(u.version, CopyString));
ret.set(s_machine, String(u.machine, CopyString));
#if defined(_GNU_SOURCE) && !defined(__APPLE__) && !defined(__FreeBSD__)
#if defined(_GNU_SOURCE)
ret.set(s_domainname, String(u.domainname, CopyString));
#endif
return ret;
+5 -5
Ver Arquivo
@@ -17,7 +17,7 @@
#include <stdio.h>
#include "debug.h"
#ifndef __APPLE__
#if !defined(__APPLE__) && !defined(__FreeBSD__)
#include "hphp/runtime/vm/debug/elfwriter.h"
#endif
#include "hphp/runtime/vm/debug/gdb-jit.h"
@@ -36,7 +36,7 @@ namespace Debug {
int g_dwarfCallback(char *name, int size, Dwarf_Unsigned type,
Dwarf_Unsigned flags, Dwarf_Unsigned link, Dwarf_Unsigned info,
Dwarf_Unsigned *sect_name_index, Dwarf_Ptr handle, int *error) {
#ifndef __APPLE__
#if !defined(__APPLE__) && !defined(__FreeBSD__)
ElfWriter *e = reinterpret_cast<ElfWriter *>(handle);
return e->dwarfCallback(name, size, type, flags, link, info);
#else
@@ -221,7 +221,7 @@ void DwarfInfo::compactChunks() {
m_dwarfChunks[j] = nullptr;
}
m_dwarfChunks[i] = chunk;
#ifndef __APPLE__
#if !defined(__APPLE__) && !defined(__FreeBSD__)
// register compacted chunk with gdb
ElfWriter e = ElfWriter(chunk);
#endif
@@ -291,7 +291,7 @@ DwarfChunk* DwarfInfo::addTracelet(TCRange range, const char* name,
f->m_chunk = chunk;
}
#ifndef __APPLE__
#if !defined(__APPLE__) && !defined(__FreeBSD__)
if (f->m_chunk->m_functions.size() >= RuntimeOption::EvalGdbSyncChunks) {
ElfWriter e = ElfWriter(f->m_chunk);
}
@@ -306,7 +306,7 @@ void DwarfInfo::syncChunks() {
for (i = 0; i < m_dwarfChunks.size(); i++) {
if (m_dwarfChunks[i] && !m_dwarfChunks[i]->isSynced()) {
unregister_gdb_chunk(m_dwarfChunks[i]);
#ifndef __APPLE__
#if !defined(__APPLE__) && !defined(__FreeBSD__)
ElfWriter e = ElfWriter(m_dwarfChunks[i]);
#endif
}
+3
Ver Arquivo
@@ -28,6 +28,9 @@
#include <unwind.h>
#include <unordered_set>
#include <signal.h>
#ifdef __FreeBSD__
#include <sys/ucontext.h>
#endif
#ifdef __FreeBSD__
#define RIP_REGISTER(v) (v).mc_rip
+1 -1
Ver Arquivo
@@ -86,7 +86,7 @@ inline void assert_fail(const char* e,
const char* file,
unsigned int line,
const char* func) {
#if !defined(NDEBUG) && !defined(__APPLE__)
#if !defined(NDEBUG) && defined(_GNU_SOURCE)
__assert_fail(e, file, line, func);
#else
extern void impl_assert_fail(const char*,
+2 -2
Ver Arquivo
@@ -20,7 +20,7 @@
namespace HPHP {
///////////////////////////////////////////////////////////////////////////////
#if defined(__APPLE__)
#if defined(__APPLE__) || defined(__FreeBSD__)
char *strndup(const char* str, size_t len) {
size_t str_len = strlen(str);
if (len < str_len) {
@@ -54,7 +54,7 @@ int dprintf(int fd, const char *format, ...) {
#endif
int gettime(clockid_t which_clock, struct timespec *tp) {
#if defined(__APPLE__)
#if defined(__APPLE__) || defined(__FreeBSD__)
// XXX: OSX doesn't support realtime so we ignore which_clock
struct timeval tv;
int ret = gettimeofday(&tv, nullptr);
+1 -1
Ver Arquivo
@@ -24,7 +24,7 @@ namespace HPHP {
#define PHP_DIR_SEPARATOR '/'
#if defined(__APPLE__)
#if defined(__APPLE__) || defined(__FreeBSD__)
char *strndup(const char* str, size_t len);
int dprintf(int fd, const char *format, ...) ATTRIBUTE_PRINTF(2,3);
typedef int clockid_t;
+1 -1
Ver Arquivo
@@ -14,9 +14,9 @@
+----------------------------------------------------------------------+
*/
#define _GNU_SOURCE 1
#include "hphp/util/vdso.h"
#define _GNU_SOURCE 1
#include <dlfcn.h>