this clock moves on while the machine was suspended. This is what we prefer
actually.
Signed-off-by: Björn Jacke <bj@sernet.de>
Reviewed-by: Simo Sorce <idra@samba.org>
Autobuild-User(master): Simo Sorce <idra@samba.org>
Autobuild-Date(master): Fri Jul 5 16:47:34 CEST 2013 on sn-devel-104
**/
_PUBLIC_ void clock_gettime_mono(struct timespec *tp)
{
- if (clock_gettime(CUSTOM_CLOCK_MONOTONIC,tp) != 0) {
- clock_gettime(CLOCK_REALTIME,tp);
+/* prefer a suspend aware monotonic CLOCK_BOOTTIME: */
+#ifdef CLOCK_BOOTTIME
+ if (clock_gettime(CLOCK_BOOTTIME,tp) == 0) {
+ return;
}
+#endif
+/* then try the monotonic clock: */
+#if CUSTOM_CLOCK_MONOTONIC != CLOCK_REALTIME
+ if (clock_gettime(CUSTOM_CLOCK_MONOTONIC,tp) == 0) {
+ return;
+ }
+#endif
+ clock_gettime(CLOCK_REALTIME,tp);
}
/**