[PATCH v2 4/9] Xext: add a private field to SyncSystemCounters

Peter Hutterer peter.hutterer at who-t.net
Wed Mar 14 21:10:25 PDT 2012


Will be used to store counter-specific data.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>
---
Changes to v1:
- use inline function instead of macro to access private

 Xext/sync.c    |   10 ++++++++++
 Xext/syncsrv.h |    1 +
 2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/Xext/sync.c b/Xext/sync.c
index 15fc50f..7c9f59c 100644
--- a/Xext/sync.c
+++ b/Xext/sync.c
@@ -113,6 +113,14 @@ static void SyncInitServerTime(void);
 
 static void SyncInitIdleTime(void);
 
+static inline void*
+SysCounterGetPrivate(SyncCounter *counter)
+{
+    BUG_WARN(!IsSystemCounter(counter));
+
+    return counter->pSysCounterInfo ? counter->pSysCounterInfo->private : NULL;
+}
+
 static Bool
 SyncCheckWarnIsCounter(const SyncObject* pSync, const char *warning)
 {
@@ -1011,6 +1019,7 @@ SyncCreateSystemCounter(
 	psci->counterType = counterType;
 	psci->QueryValue = QueryValue;
 	psci->BracketValues = BracketValues;
+	psci->private = NULL;
 	XSyncMaxValue(&psci->bracket_greater);
 	XSyncMinValue(&psci->bracket_less);
 	xorg_list_add(&psci->entry, &SysCounterList);
@@ -1169,6 +1178,7 @@ FreeCounter(void *env, XID id)
     if (IsSystemCounter(pCounter))
     {
 	xorg_list_del(&pCounter->pSysCounterInfo->entry);
+	free(pCounter->pSysCounterInfo->private);
 	free(pCounter->pSysCounterInfo);
     }
     free(pCounter);
diff --git a/Xext/syncsrv.h b/Xext/syncsrv.h
index c8930a8..d252935 100644
--- a/Xext/syncsrv.h
+++ b/Xext/syncsrv.h
@@ -81,6 +81,7 @@ typedef struct _SysCounterInfo {
     SyncCounterType counterType;  /* how can this counter change */
     SyncSystemCounterQueryValue QueryValue;
     SyncSystemCounterBracketValues BracketValues;
+    void	*private;
     struct xorg_list entry;
 } SysCounterInfo;
 
-- 
1.7.7.6



More information about the xorg-devel mailing list