[PATCH libXext (rev3) 4/5] Add XSyncQueryFence()

James Jones jajones at nvidia.com
Thu Dec 2 09:26:30 PST 2010


Allows callers to query whether or not a given
fence sync object is currently triggered.

Signed-off-by: James Jones <jajones at nvidia.com>
Reviewed-by: Aaron Plattner <aplattner at nvidia.com>
---
 include/X11/extensions/sync.h |    6 ++++++
 src/XSync.c                   |   29 +++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/include/X11/extensions/sync.h b/include/X11/extensions/sync.h
index 7f4b5c5..6a44ab9 100644
--- a/include/X11/extensions/sync.h
+++ b/include/X11/extensions/sync.h
@@ -356,6 +356,12 @@ extern Bool XSyncDestroyFence(
     XSyncFence /*fence*/
 );
 
+extern Bool XSyncQueryFence(
+    Display* /*dpy*/,
+    XSyncFence /*fence*/,
+    Bool* /*triggered*/
+);
+
 _XFUNCPROTOEND
 
 #endif /* _SYNC_SERVER */
diff --git a/src/XSync.c b/src/XSync.c
index 5236b40..ca9a67c 100644
--- a/src/XSync.c
+++ b/src/XSync.c
@@ -845,6 +845,35 @@ XSyncDestroyFence(Display *dpy, XSyncFence fence)
     return True;
 }
 
+Bool
+XSyncQueryFence(Display *dpy, XSyncFence fence, Bool *triggered)
+{
+    XExtDisplayInfo *info = find_display(dpy);
+    xSyncQueryFenceReply rep;
+    xSyncQueryFenceReq *req;
+
+    SyncCheckExtension(dpy, info, None);
+
+    LockDisplay(dpy);
+    GetReq(SyncQueryFence, req);
+    req->reqType = info->codes->major_opcode;
+    req->syncReqType = X_SyncQueryFence;
+    req->fid = fence;
+
+    if (!_XReply(dpy, (xReply *) & rep, 0, xFalse))
+    {
+	UnlockDisplay(dpy);
+	SyncHandle();
+	return False;
+    }
+    if (triggered)
+	*triggered = rep.triggered;
+
+    UnlockDisplay(dpy);
+    SyncHandle();
+    return True;
+}
+
 /*
  *  Functions corresponding to the macros for manipulating 64-bit values
  */
-- 
1.7.1



More information about the xorg-devel mailing list