From 09d9aa5e33dd2cc7b605ca82e9322b3aad8749e1 Mon Sep 17 00:00:00 2001 From: q66 Date: Tue, 3 Nov 2020 22:23:40 +0100 Subject: [PATCH] drawterm: use a correct atomic exchange for tas the previous behavior would just keep incrementing the lock, which is bad; emulate the x86 implementation behavior here by performing a value exchange instead we cannot use __atomic_test_and_set (which would eliminate the value check) since that 1) works on a single byte, which is okay on little endian systems but bad on big endian systems and 2) has an undefined value of 'true' (just nonzero) Fixes https://github.com/void-linux/void-packages/issues/26109 --- srcpkgs/drawterm/patches/posix_generic.patch | 4 ++-- srcpkgs/drawterm/template | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/srcpkgs/drawterm/patches/posix_generic.patch b/srcpkgs/drawterm/patches/posix_generic.patch index e7b774b4c85..aec5c76e018 100644 --- a/srcpkgs/drawterm/patches/posix_generic.patch +++ b/srcpkgs/drawterm/patches/posix_generic.patch @@ -92,8 +92,8 @@ index 0000000..289f747 +int +tas(int *x) +{ -+ /* Use the GCC builtin __sync_fetch_and_add() for optimal code */ -+ int v = __sync_fetch_and_add(x, 1); ++ /* use a gcc __atomic builtin */ ++ int v = __atomic_exchange_n(x, 1, __ATOMIC_SEQ_CST); + switch(v) { + case 0: + case 1: diff --git a/srcpkgs/drawterm/template b/srcpkgs/drawterm/template index 40443deec3f..c5e9a3615aa 100644 --- a/srcpkgs/drawterm/template +++ b/srcpkgs/drawterm/template @@ -1,7 +1,7 @@ # Template file for 'drawterm' pkgname=drawterm version=0.0.20200619 -revision=1 +revision=2 _hghash=9daaec18b823 wrksrc=${pkgname}-${_hghash} makedepends="libX11-devel libXt-devel"