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
This commit is contained in:
parent
1833b9b9bb
commit
09d9aa5e33
|
@ -92,8 +92,8 @@ index 0000000..289f747
|
||||||
+int
|
+int
|
||||||
+tas(int *x)
|
+tas(int *x)
|
||||||
+{
|
+{
|
||||||
+ /* Use the GCC builtin __sync_fetch_and_add() for optimal code */
|
+ /* use a gcc __atomic builtin */
|
||||||
+ int v = __sync_fetch_and_add(x, 1);
|
+ int v = __atomic_exchange_n(x, 1, __ATOMIC_SEQ_CST);
|
||||||
+ switch(v) {
|
+ switch(v) {
|
||||||
+ case 0:
|
+ case 0:
|
||||||
+ case 1:
|
+ case 1:
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# Template file for 'drawterm'
|
# Template file for 'drawterm'
|
||||||
pkgname=drawterm
|
pkgname=drawterm
|
||||||
version=0.0.20200619
|
version=0.0.20200619
|
||||||
revision=1
|
revision=2
|
||||||
_hghash=9daaec18b823
|
_hghash=9daaec18b823
|
||||||
wrksrc=${pkgname}-${_hghash}
|
wrksrc=${pkgname}-${_hghash}
|
||||||
makedepends="libX11-devel libXt-devel"
|
makedepends="libX11-devel libXt-devel"
|
||||||
|
|
Loading…
Reference in New Issue