2018-05-28 10:10:41 +02:00
|
|
|
/*
|
2019-08-03 19:43:48 +02:00
|
|
|
* This software is licensed under the terms of the MIT License.
|
2018-05-28 10:10:41 +02:00
|
|
|
* See COPYING for further information.
|
|
|
|
* ---
|
2024-05-16 23:30:41 +02:00
|
|
|
* Copyright (c) 2011-2024, Lukas Weber <laochailan@web.de>.
|
|
|
|
* Copyright (c) 2012-2024, Andrei Alexeyev <akari@taisei-project.org>.
|
2018-05-28 10:10:41 +02:00
|
|
|
*/
|
|
|
|
|
2019-05-01 06:03:22 +02:00
|
|
|
#include "systime.h"
|
2018-05-28 10:10:41 +02:00
|
|
|
|
2024-05-17 04:41:28 +02:00
|
|
|
#include <time.h>
|
|
|
|
|
2018-05-28 10:10:41 +02:00
|
|
|
void get_system_time(SystemTime *systime) {
|
|
|
|
#if defined(TAISEI_BUILDCONF_HAVE_TIMESPEC)
|
2021-04-29 19:43:57 +02:00
|
|
|
#if defined(TAISEI_BUILDCONF_HAVE_BUILTIN_AVAILABLE)
|
|
|
|
if(__builtin_available(macOS 10.15, *)) {
|
|
|
|
timespec_get(systime, TIME_UTC);
|
|
|
|
} else {
|
|
|
|
systime->tv_sec = time(NULL);
|
|
|
|
systime->tv_nsec = 0;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
timespec_get(systime, TIME_UTC);
|
|
|
|
#endif
|
2018-05-28 10:10:41 +02:00
|
|
|
#else
|
|
|
|
systime->tv_sec = time(NULL);
|
|
|
|
systime->tv_nsec = 0;
|
|
|
|
#endif
|
|
|
|
}
|