libdrm atomic_add_unless() may reverse return value meaning
Submitted by David Shao
Assigned to Default DRI bug account
Link to original bug (#100077)
Description
atomic_add_unless()
in libdrm xf86atomic.h
may reverse the meaning
of its return value.
Linux kernel documentation seems to indicate something like:
"Returns non-zero if @v
was not @u
, and zero otherwise."
A simple inverting the meaning of libdrm's return value allowed glxgears to properly function for a hacked version of pkgsrc on DragonFly 4.7-DEVELOPMENT on an Intel IvyBridge integrated graphics machine. glxgears was already properly functioning on the same machine for NetBSD current, NetBSD using its own atomic operations declared in its sys/atomic.h header.
A one line (character) fix is of the form:
--- xf86atomic.h.orig 2015-09-22 04:34:51.000000000 +0000
+++ xf86atomic.h
@@ -111,7 +111,7 @@ static inline int atomic_add_unless(atom
c = atomic_read(v);
while (c != unless && (old = atomic_cmpxchg(v, c, c + add)) != c)
c = old;
- return c == unless;
+ return c != unless;
}