-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #125 from yultide/master
Janus build fixes for OSX
- Loading branch information
Showing
9 changed files
with
106 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ docs/html/ | |
|
||
Makefile | ||
Makefile.in | ||
/build | ||
/configure | ||
/autom4te.cache | ||
/aclocal.m4 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#ifndef MACH_GETTIME_H | ||
#define MACH_GETTIME_H | ||
|
||
#include <sys/types.h> | ||
#include <sys/_types/_timespec.h> | ||
#include <mach/mach.h> | ||
#include <mach/clock.h> | ||
#include <mach/mach_time.h> | ||
|
||
/* The opengroup spec isn't clear on the mapping from REALTIME to CALENDAR | ||
being appropriate or not. | ||
http://pubs.opengroup.org/onlinepubs/009695299/basedefs/time.h.html */ | ||
|
||
// XXX only supports a single timer | ||
#define TIMER_ABSTIME -1 | ||
#define CLOCK_REALTIME CALENDAR_CLOCK | ||
#define CLOCK_MONOTONIC SYSTEM_CLOCK | ||
|
||
typedef int clockid_t; | ||
|
||
/* the mach kernel uses struct mach_timespec, so struct timespec | ||
is loaded from <sys/_types/_timespec.h> for compatability */ | ||
// struct timespec { time_t tv_sec; long tv_nsec; }; | ||
|
||
int clock_gettime(clockid_t clk_id, struct timespec *tp); | ||
|
||
#include <mach/mach_time.h> | ||
|
||
#define MT_NANO (+1.0E-9) | ||
#define MT_GIGA UINT64_C(1000000000) | ||
|
||
// TODO create a list of timers, | ||
static double mt_timebase = 0.0; | ||
static uint64_t mt_timestart = 0; | ||
|
||
// TODO be more careful in a multithreaded environement | ||
int clock_gettime(clockid_t clk_id, struct timespec *tp) | ||
{ | ||
kern_return_t retval = KERN_SUCCESS; | ||
if( clk_id == TIMER_ABSTIME) | ||
{ | ||
if (!mt_timestart) { // only one timer, initilized on the first call to the TIMER | ||
mach_timebase_info_data_t tb = { 0 }; | ||
mach_timebase_info(&tb); | ||
mt_timebase = tb.numer; | ||
mt_timebase /= tb.denom; | ||
mt_timestart = mach_absolute_time(); | ||
} | ||
|
||
double diff = (mach_absolute_time() - mt_timestart) * mt_timebase; | ||
tp->tv_sec = diff * MT_NANO; | ||
tp->tv_nsec = diff - (tp->tv_sec * MT_GIGA); | ||
} | ||
else // other clk_ids are mapped to the coresponding mach clock_service | ||
{ | ||
clock_serv_t cclock; | ||
mach_timespec_t mts; | ||
|
||
host_get_clock_service(mach_host_self(), clk_id, &cclock); | ||
retval = clock_get_time(cclock, &mts); | ||
mach_port_deallocate(mach_task_self(), cclock); | ||
|
||
tp->tv_sec = mts.tv_sec; | ||
tp->tv_nsec = mts.tv_nsec; | ||
} | ||
|
||
return retval; | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters