mirror of https://github.com/KLayout/klayout.git
Cleaned up code
Moved current_utc_time out of the central tlUtils header where it does not belong. It a time function, so tlTimer.h is the better place. Plus it does not make sense to make this inline. This just spoils build times on changes.
This commit is contained in:
parent
3efde26584
commit
3d7bd0f32d
|
|
@ -36,9 +36,33 @@
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__MACH__)
|
||||||
|
#include <mach/clock.h>
|
||||||
|
#include <mach/mach.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace tl
|
namespace tl
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// -------------------------------------------------------------
|
||||||
|
|
||||||
|
void current_utc_time (struct timespec *ts)
|
||||||
|
{
|
||||||
|
|
||||||
|
#if defined(__MACH__)
|
||||||
|
clock_serv_t cclock;
|
||||||
|
mach_timespec_t mts;
|
||||||
|
host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
|
||||||
|
clock_get_time(cclock, &mts);
|
||||||
|
mach_port_deallocate(mach_task_self(), cclock);
|
||||||
|
ts->tv_sec = mts.tv_sec;
|
||||||
|
ts->tv_nsec = mts.tv_nsec;
|
||||||
|
#else
|
||||||
|
clock_gettime(CLOCK_REALTIME, ts);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------
|
// -------------------------------------------------------------
|
||||||
// Gets the current time in ms from epoch
|
// Gets the current time in ms from epoch
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,12 +28,19 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
class QDateTime;
|
class QDateTime;
|
||||||
|
|
||||||
namespace tl
|
namespace tl
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief clock_gettime is not implemented in Mac OS X 10.11 and lower
|
||||||
|
* From: https://gist.githubusercontent.com/jbenet/1087739/raw/638b37f76cdd9dc46d617443cab27eac297e2ee3/current_utc_time.c
|
||||||
|
*/
|
||||||
|
void current_utc_time (struct timespec *ts);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief A basic timer class
|
* @brief A basic timer class
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -27,37 +27,10 @@
|
||||||
#include "tlAssert.h"
|
#include "tlAssert.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
#if defined(__MACH__)
|
|
||||||
#include <mach/clock.h>
|
|
||||||
#include <mach/mach.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace tl
|
namespace tl
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief clock_gettime is not implemented in Mac OS X 10.11 and lower
|
|
||||||
* From: https://gist.githubusercontent.com/jbenet/1087739/raw/638b37f76cdd9dc46d617443cab27eac297e2ee3/current_utc_time.c
|
|
||||||
*/
|
|
||||||
|
|
||||||
inline void current_utc_time(struct timespec *ts) {
|
|
||||||
|
|
||||||
#if defined(__MACH__)
|
|
||||||
clock_serv_t cclock;
|
|
||||||
mach_timespec_t mts;
|
|
||||||
host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
|
|
||||||
clock_get_time(cclock, &mts);
|
|
||||||
mach_port_deallocate(mach_task_self(), cclock);
|
|
||||||
ts->tv_sec = mts.tv_sec;
|
|
||||||
ts->tv_nsec = mts.tv_nsec;
|
|
||||||
#else
|
|
||||||
clock_gettime(CLOCK_REALTIME, ts);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief A template class mapping a begin .. end iterator pair to the at_end semantics
|
* @brief A template class mapping a begin .. end iterator pair to the at_end semantics
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue