···99# by applications like the OpenXR runtime library.
1010#
11111212-add_library(aux_os STATIC os_documentation.h os_hid.h os_hid_hidraw.c os_threading.h)
1212+add_library(
1313+ aux_os STATIC
1414+ os_documentation.h
1515+ os_hid.h
1616+ os_hid_hidraw.c
1717+ os_threading.h
1818+ os_time.cpp
1919+ )
1320target_link_libraries(aux_os PUBLIC aux-includes xrt-pthreads)
14211522# Only uses normal Windows libraries, doesn't add anything extra.
+31
src/xrt/auxiliary/os/os_time.cpp
···11+// Copyright 2023, Collabora, Ltd.
22+// SPDX-License-Identifier: BSL-1.0
33+/*!
44+ * @file
55+ * @brief Wrapper around OS native time functions.
66+ *
77+ * These should be preferred over directly using native OS time functions in
88+ * potentially-portable code. Additionally, in most cases these are preferred
99+ * over timepoints from @ref time_state for general usage in drivers, etc.
1010+ *
1111+ * @author Christoph Haag <christoph.haag@collabora.com>
1212+ *
1313+ * @ingroup aux_os
1414+ */
1515+1616+#include "xrt/xrt_config_os.h"
1717+1818+#ifdef XRT_OS_WINDOWS
1919+2020+#include <inttypes.h>
2121+#include <chrono>
2222+2323+extern "C" uint64_t
2424+os_realtime_get_ns(void)
2525+{
2626+ auto now = std::chrono::system_clock::now();
2727+ auto nsecs = std::chrono::time_point_cast<std::chrono::nanoseconds>(now);
2828+ auto ret = nsecs.time_since_epoch().count();
2929+ return ret;
3030+}
3131+#endif
+10
src/xrt/auxiliary/os/os_time.h
···165165os_realtime_get_ns(void);
166166#endif
167167168168+#if defined(XRT_OS_WINDOWS)
169169+/*!
170170+ * Return a realtime clock in nanoseconds
171171+ *
172172+ * @ingroup aux_os_time_extra
173173+ */
174174+uint64_t
175175+os_realtime_get_ns(void);
176176+#endif
177177+168178#if defined(XRT_OS_WINDOWS) || defined(XRT_DOXYGEN)
169179/*!
170180 * @brief Return a qpc freq in nanoseconds.