Fixed Mac support

This commit is contained in:
Thulinma 2014-06-17 12:07:35 +02:00
parent 8f97995b1b
commit d3bb5b13e4
2 changed files with 4 additions and 4 deletions

View file

@ -20,7 +20,7 @@
#include "config.h" #include "config.h"
static const char* DBG_LVL_LIST[] = {"NONE","FAIL","ERROR","WARN","INFO","MEDIUM","HIGH","VERYHIGH","EXTREME","INSANE","DONTEVEN"}; static const char* DBG_LVL_LIST[] = {"NONE","FAIL","ERROR","WARN","INFO","MEDIUM","HIGH","VERYHIGH","EXTREME","INSANE","DONTEVEN"};
#ifdef __GNUC__ #if !defined(__APPLE__) && !defined(__MACH__) && defined(__GNUC__)
#include <errno.h> #include <errno.h>
extern char * program_invocation_short_name; extern char * program_invocation_short_name;

View file

@ -4,17 +4,17 @@
#include "timing.h" #include "timing.h"
#include <sys/time.h>//for gettimeofday #include <sys/time.h>//for gettimeofday
#include <time.h>//for time and nanosleep #include <time.h>//for time and nanosleep
#include <sys/sysinfo.h> //forsysinfo
//emulate clock_gettime() for OSX compatibility //emulate clock_gettime() for OSX compatibility
#if defined(__APPLE__) || defined(__MACH__) #if defined(__APPLE__) || defined(__MACH__)
#include <mach/clock.h> #include <mach/clock.h>
#include <mach/mach.h> #include <mach/mach.h>
#define CLOCK_REALTIME 0 #define CLOCK_REALTIME CALENDAR_CLOCK
#define CLOCK_MONOTONIC SYSTEM_CLOCK
void clock_gettime(int ign, struct timespec * ts){ void clock_gettime(int ign, struct timespec * ts){
clock_serv_t cclock; clock_serv_t cclock;
mach_timespec_t mts; mach_timespec_t mts;
host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock); host_get_clock_service(mach_host_self(), ign, &cclock);
clock_get_time(cclock, &mts); clock_get_time(cclock, &mts);
mach_port_deallocate(mach_task_self(), cclock); mach_port_deallocate(mach_task_self(), cclock);
ts->tv_sec = mts.tv_sec; ts->tv_sec = mts.tv_sec;