5 * Copyright (C) Bob 2009
7 * boblight is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * boblight is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 * See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
22 #if defined(__APPLE__)
23 #include <mach/mach_time.h>
24 #include <CoreVideo/CVHostTime.h>
25 #elif defined(__WINDOWS__)
33 inline int64_t GetTimeMs()
35 #if defined(__APPLE__)
36 return (int64_t) (CVGetCurrentHostTime() * 1000 / CVGetHostClockFrequency());
37 #elif defined(__WINDOWS__)
41 LARGE_INTEGER tickPerSecond
;
43 if (QueryPerformanceFrequency(&tickPerSecond
))
45 QueryPerformanceCounter(&tick
);
46 return (int64_t) (tick
.QuadPart
/ 1000.);
51 gettimeofday(&time
, NULL
);
52 return (int64_t) (time
.tv_sec
* 1000 + time
.tv_usec
/ 1000);
59 return (T
)GetTimeMs() / (T
)1000.0;