diff --git a/VERSION b/VERSION index 9c7cef11..31c8b6fc 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -B1-140-g4c185799f6+1 \ No newline at end of file +B1-140-gcc2c49644d+1 \ No newline at end of file diff --git a/c-host/platform/Windows/capture/DXGI/src/dxgi.c b/c-host/platform/Windows/capture/DXGI/src/dxgi.c index 6e5cf89a..d1c9404c 100644 --- a/c-host/platform/Windows/capture/DXGI/src/dxgi.c +++ b/c-host/platform/Windows/capture/DXGI/src/dxgi.c @@ -61,7 +61,7 @@ struct iface IDXGIOutput * output; ID3D11Device * device; ID3D11DeviceContext * deviceContext; - volatile int deviceContextLock; + LG_Lock deviceContextLock; bool useAcquireLock; D3D_FEATURE_LEVEL featureLevel; IDXGIOutputDuplication * dup; @@ -335,7 +335,8 @@ static bool dxgi_init() &this->device, &this->featureLevel, &this->deviceContext); - this->deviceContextLock = 0; + + LG_LOCK_INIT(this->deviceContextLock); IDXGIAdapter_Release(tmp); @@ -588,6 +589,7 @@ static bool dxgi_deinit() } } + LG_LOCK_FREE(this->deviceContextLock); this->initialized = false; return true; } diff --git a/client/spice/src/spice.c b/client/spice/src/spice.c index 75b40032..0f189da5 100644 --- a/client/spice/src/spice.c +++ b/client/spice/src/spice.c @@ -27,7 +27,6 @@ Place, Suite 330, Boston, MA 02111-1307 USA #include #include #include -#include #include #include diff --git a/common/include/common/locking.h b/common/include/common/locking.h index 406ea9fa..14e086f6 100644 --- a/common/include/common/locking.h +++ b/common/include/common/locking.h @@ -20,27 +20,21 @@ Place, Suite 330, Boston, MA 02111-1307 USA #include "time.h" -#define INTERLOCKED_AND8 __sync_fetch_and_and -#define INTERLOCKED_OR8 __sync_fetch_and_or -#define INTERLOCKED_INC(x) __sync_fetch_and_add((x), 1) -#define INTERLOCKED_DEC(x) __sync_fetch_and_sub((x), 1) -#define INTERLOCKED_GET(x) __sync_fetch_and_add((x), 0) -#define INTERLOCKED_CE(x, c, v) __sync_val_compare_and_swap((x), (c), (v)) +#include -#define INTERLOCKED_ENTER(lock) \ - while(__sync_lock_test_and_set(&(lock), 1)) while((lock)); +#define LG_LOCK_MODE "Atomic" +typedef atomic_flag LG_Lock; +#define LG_LOCK_INIT(x) atomic_flag_clear(&(x)) +#define LG_LOCK(x) \ + while(atomic_flag_test_and_set_explicit(&(x), memory_order_acquire)) { ; } +#define LG_UNLOCK(x) \ + atomic_flag_clear_explicit(&(x), memory_order_release); +#define LG_LOCK_FREE(x) -#define INTERLOCKED_EXIT(lock) \ - __sync_lock_release(&(lock)); +#define INTERLOCKED_INC(x) atomic_fetch_add((x), 1) +#define INTERLOCKED_DEC(x) atomic_fetch_sub((x), 1) #define INTERLOCKED_SECTION(lock, x) \ - while(__sync_lock_test_and_set(&(lock), 1)) while((lock)); \ - x\ - __sync_lock_release(&(lock)); - -#define LG_LOCK_MODE "Atomic" -typedef volatile int LG_Lock; -#define LG_LOCK_INIT(x) (x) = 0 -#define LG_LOCK(x) while(__sync_lock_test_and_set(&(x), 1)) {nsleep(100);} -#define LG_UNLOCK(x) __sync_lock_release(&x) -#define LG_LOCK_FREE(x) + LG_LOCK(lock) \ + x \ + LG_UNLOCK(lock)