[PATCH weston 7/8] Add ifdefs for platform-specific clocks

Greg V greg at unrelenting.technology
Sun Dec 17 19:04:41 UTC 2017


+ add FreeBSD/DragonFlyBSD _FAST clocks, similar to Linux _COARSE
---
 clients/weston-info.c  | 6 ++++++
 compositor/main.c      | 5 +++++
 libweston/compositor.c | 8 ++++++++
 3 files changed, 19 insertions(+)

diff --git a/clients/weston-info.c b/clients/weston-info.c
index 386bd412..e4fa9555 100644
--- a/clients/weston-info.c
+++ b/clients/weston-info.c
@@ -695,9 +695,15 @@ clock_name(clockid_t clk_id)
 	static const char *names[] = {
 		[CLOCK_REALTIME] =		"CLOCK_REALTIME",
 		[CLOCK_MONOTONIC] =		"CLOCK_MONOTONIC",
+#ifdef __linux__
 		[CLOCK_MONOTONIC_RAW] =		"CLOCK_MONOTONIC_RAW",
 		[CLOCK_REALTIME_COARSE] =	"CLOCK_REALTIME_COARSE",
 		[CLOCK_MONOTONIC_COARSE] =	"CLOCK_MONOTONIC_COARSE",
+#elif defined(__FreeBSD__) || defined(__DragonFly__)
+		[CLOCK_REALTIME_FAST] =		"CLOCK_REALTIME_FAST",
+		[CLOCK_MONOTONIC_FAST] =	"CLOCK_MONOTONIC_FAST",
+#endif
+
 #ifdef CLOCK_BOOTTIME
 		[CLOCK_BOOTTIME] =		"CLOCK_BOOTTIME",
 #endif
diff --git a/compositor/main.c b/compositor/main.c
index dedb5e64..dfe4dca4 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -685,9 +685,14 @@ clock_name(clockid_t clk_id)
 	static const char *names[] = {
 		[CLOCK_REALTIME] =		"CLOCK_REALTIME",
 		[CLOCK_MONOTONIC] =		"CLOCK_MONOTONIC",
+#ifdef __linux__
 		[CLOCK_MONOTONIC_RAW] =		"CLOCK_MONOTONIC_RAW",
 		[CLOCK_REALTIME_COARSE] =	"CLOCK_REALTIME_COARSE",
 		[CLOCK_MONOTONIC_COARSE] =	"CLOCK_MONOTONIC_COARSE",
+#elif defined(__FreeBSD__) || defined(__DragonFly__)
+		[CLOCK_REALTIME_FAST] =		"CLOCK_REALTIME_FAST",
+		[CLOCK_MONOTONIC_FAST] =	"CLOCK_MONOTONIC_FAST",
+#endif
 #ifdef CLOCK_BOOTTIME
 		[CLOCK_BOOTTIME] =		"CLOCK_BOOTTIME",
 #endif
diff --git a/libweston/compositor.c b/libweston/compositor.c
index 7d7a17ed..a6c77e6b 100644
--- a/libweston/compositor.c
+++ b/libweston/compositor.c
@@ -5435,10 +5435,18 @@ weston_compositor_set_presentation_clock_software(
 {
 	/* In order of preference */
 	static const clockid_t clocks[] = {
+#ifdef __linux__
 		CLOCK_MONOTONIC_RAW,	/* no jumps, no crawling */
 		CLOCK_MONOTONIC_COARSE,	/* no jumps, may crawl, fast & coarse */
+#elif defined(__FreeBSD__) || defined(__DragonFly__)
+		CLOCK_MONOTONIC_FAST,	/* no jumps, may crawl, fast & coarse */
+#endif
 		CLOCK_MONOTONIC,	/* no jumps, may crawl */
+#ifdef __linux__
 		CLOCK_REALTIME_COARSE,	/* may jump and crawl, fast & coarse */
+#elif defined(__FreeBSD__) || defined(__DragonFly__)
+		CLOCK_REALTIME_FAST,	/* may jump and crawl, fast & coarse */
+#endif
 		CLOCK_REALTIME		/* may jump and crawl */
 	};
 	unsigned i;
-- 
2.15.1



More information about the wayland-devel mailing list