All of lore.kernel.org
 help / color / mirror / Atom feed
* [Bug 100077] libdrm atomic_add_unless() may reverse return value meaning
@ 2017-03-06  8:41 bugzilla-daemon
  2017-03-16  0:08 ` [PATCH libdrm] atomic: fix atomic_add_unless() fallback's return value Eric Engestrom
  2019-09-24 17:09 ` [Bug 100077] libdrm atomic_add_unless() may reverse return value meaning bugzilla-daemon
  0 siblings, 2 replies; 5+ messages in thread
From: bugzilla-daemon @ 2017-03-06  8:41 UTC (permalink / raw)
  To: dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 1560 bytes --]

https://bugs.freedesktop.org/show_bug.cgi?id=100077

            Bug ID: 100077
           Summary: libdrm atomic_add_unless() may reverse return value
                    meaning
           Product: DRI
           Version: unspecified
          Hardware: x86-64 (AMD64)
                OS: BSD (Others)
            Status: NEW
          Severity: normal
          Priority: medium
         Component: libdrm
          Assignee: dri-devel@lists.freedesktop.org
          Reporter: davshao@gmail.com

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;
 }

-- 
You are receiving this mail because:
You are the assignee for the bug.

[-- Attachment #1.2: Type: text/html, Size: 2888 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-09-24 17:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-06  8:41 [Bug 100077] libdrm atomic_add_unless() may reverse return value meaning bugzilla-daemon
2017-03-16  0:08 ` [PATCH libdrm] atomic: fix atomic_add_unless() fallback's return value Eric Engestrom
2017-03-16 16:46   ` Eric Engestrom
2017-03-17 19:08     ` Emil Velikov
2019-09-24 17:09 ` [Bug 100077] libdrm atomic_add_unless() may reverse return value meaning bugzilla-daemon

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.