From 9f70328b70d00bf1920e59540dc2b56577216229 Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Wed, 7 Jun 2023 23:10:47 +0900 Subject: [PATCH] systemclock: Use Windows interlocked APIs MSVC most likely does not support C11 atomic operations with given compile options Part-of: --- subprojects/gstreamer/gst/gstsystemclock.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/subprojects/gstreamer/gst/gstsystemclock.c b/subprojects/gstreamer/gst/gstsystemclock.c index 403cc3d170..827a7e1b56 100644 --- a/subprojects/gstreamer/gst/gstsystemclock.c +++ b/subprojects/gstreamer/gst/gstsystemclock.c @@ -91,6 +91,27 @@ gst_atomic_int_set_release (gst_atomic_int * x, gint val) { atomic_store_explicit (x, val, memory_order_release); } +#elif defined G_OS_WIN32 +/* MSVC's C11 atomic might require special cflags + * https://devblogs.microsoft.com/cppblog/c11-atomics-in-visual-studio-2022-version-17-5-preview-2/ + * + * Can remove this code once below GLib MR is merged + * https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3436 + */ + +typedef LONG gst_atomic_int; + +static inline int +gst_atomic_int_get_acquire (gst_atomic_int * x) +{ + return InterlockedAndAcquire (x, 1); +} + +static inline void +gst_atomic_int_set_release (gst_atomic_int * x, gint val) +{ + InterlockedOrRelease (x, 1); +} #else /* defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && !defined(__STDC_NO_ATOMICS) */ typedef int gst_atomic_int; #define gst_atomic_int_get_acquire(x) g_atomic_int_get(x)