Ticket #45091: 0001-HHVM-3.2.0-cpu_set_t-compilation-fix-on-Mac-OS-10.9.diff

File 0001-HHVM-3.2.0-cpu_set_t-compilation-fix-on-Mac-OS-10.9.diff, 1.4 KB (added by c9s (Yo-An Lin), 10 years ago)

patch file

  • hphp/runtime/ext/ext_hotprofiler.h

     
    2020
    2121#include "hphp/runtime/ext/ext_fb.h"
    2222
     23#ifdef __FreeBSD__
     24#include <sys/param.h>
     25#include <sys/cpuset.h>
     26#define cpu_set_t cpuset_t
     27#define SET_AFFINITY(pid, size, mask) \
     28           cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_TID, -1, size, mask)
     29#define GET_AFFINITY(pid, size, mask) \
     30           cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_TID, -1, size, mask)
     31#elif defined(__APPLE__)
     32#include <mach/mach_init.h>
     33#include <mach/thread_policy.h>
     34#include <mach/thread_act.h>
     35
     36#define cpu_set_t thread_affinity_policy_data_t
     37#define CPU_SET(cpu_id, new_mask) \
     38        (*(new_mask)).affinity_tag = (cpu_id + 1)
     39#define CPU_ZERO(new_mask)                 \
     40        (*(new_mask)).affinity_tag = THREAD_AFFINITY_TAG_NULL
     41#define GET_AFFINITY(pid, size, mask) \
     42         (*(mask)).affinity_tag = THREAD_AFFINITY_TAG_NULL
     43#define SET_AFFINITY(pid, size, mask)       \
     44        thread_policy_set(mach_thread_self(), THREAD_AFFINITY_POLICY, \
     45                          (int *)mask, THREAD_AFFINITY_POLICY_COUNT)
     46#else
     47#include <sched.h>
     48#define SET_AFFINITY(pid, size, mask) sched_setaffinity(0, size, mask)
     49#define GET_AFFINITY(pid, size, mask) sched_getaffinity(0, size, mask)
     50#endif
     51
     52
    2353namespace HPHP {
    2454
    2555///////////////////////////////////////////////////////////////////////////////