2016-10-26 22:27:38 +00:00
|
|
|
#pragma once
|
|
|
|
/** Allows to build on MacOS X
|
|
|
|
*
|
|
|
|
* Highly experimental, not recommended, disabled by default.
|
|
|
|
*
|
|
|
|
* To use, include this file with -include compiler parameter.
|
|
|
|
*/
|
|
|
|
|
2018-06-19 18:09:09 +00:00
|
|
|
#include <time.h>
|
|
|
|
|
2017-02-07 21:26:32 +00:00
|
|
|
#ifdef __APPLE__
|
|
|
|
|
2018-07-20 16:56:39 +00:00
|
|
|
# if !defined(APPLE_HAVE_CLOCK_GETTIME)
|
|
|
|
# include <AvailabilityMacros.h>
|
|
|
|
# if !defined(MAC_OS_X_VERSION_10_12)
|
|
|
|
# define MAC_OS_X_VERSION_10_12 101200
|
|
|
|
# endif
|
|
|
|
# define APPLE_HAVE_CLOCK_GETTIME MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12
|
|
|
|
# endif
|
|
|
|
|
|
|
|
# if !APPLE_HAVE_CLOCK_GETTIME || !defined(CLOCK_MONOTONIC)
|
2016-10-26 22:27:38 +00:00
|
|
|
/**
|
|
|
|
* MacOS X doesn't support different clock sources
|
|
|
|
*
|
|
|
|
* Mapping all of them to 0, except for
|
|
|
|
* CLOCK_THREAD_CPUTIME_ID, because there is a way
|
|
|
|
* to implement it using in-kernel stats about threads
|
|
|
|
*/
|
2018-07-20 16:56:39 +00:00
|
|
|
# if !defined(CLOCK_MONOTONIC)
|
|
|
|
# define CLOCK_MONOTONIC 0
|
|
|
|
# endif
|
|
|
|
# if !defined(CLOCK_REALTIME)
|
|
|
|
# define CLOCK_REALTIME CLOCK_MONOTONIC
|
|
|
|
# endif
|
|
|
|
# if !defined(CLOCK_THREAD_CPUTIME_ID)
|
|
|
|
# define CLOCK_THREAD_CPUTIME_ID 3
|
|
|
|
# endif
|
2016-10-26 22:27:38 +00:00
|
|
|
|
|
|
|
typedef int clockid_t;
|
|
|
|
int clock_gettime(int clk_id, struct timespec* t);
|
2018-07-20 16:56:39 +00:00
|
|
|
# else
|
2018-06-19 18:09:09 +00:00
|
|
|
|
2018-07-20 16:56:39 +00:00
|
|
|
# endif
|
2018-06-19 18:09:09 +00:00
|
|
|
|
2018-07-20 16:56:39 +00:00
|
|
|
# if !defined(CLOCK_MONOTONIC_COARSE)
|
|
|
|
# define CLOCK_MONOTONIC_COARSE CLOCK_MONOTONIC
|
|
|
|
# endif
|
2017-02-07 21:26:32 +00:00
|
|
|
|
|
|
|
#endif
|