[PATCH] Xext: replace the macro with a static inline function.

Peter Hutterer peter.hutterer at who-t.net
Wed Mar 14 16:27:24 PDT 2012


Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 Xext/sync.c    |   24 ++++++++++++++++++------
 Xext/syncsrv.h |    2 --
 2 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/Xext/sync.c b/Xext/sync.c
index 6c8c564..5f74dab 100644
--- a/Xext/sync.c
+++ b/Xext/sync.c
@@ -115,6 +115,15 @@ 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)
 {
@@ -2747,7 +2756,8 @@ IdleTimeQueryValue (pointer pCounter, CARD64 *pValue_return)
     CARD32 idle;
 
     if (pCounter) {
-        IdleCounterPriv *priv = SYSCOUNTERPRIV(pCounter);
+        SyncCounter *counter = pCounter;
+        IdleCounterPriv *priv = SysCounterGetPrivate(counter);
         deviceid = priv->deviceid;
     } else
         deviceid = XIAllDevices;
@@ -2758,8 +2768,8 @@ IdleTimeQueryValue (pointer pCounter, CARD64 *pValue_return)
 static void
 IdleTimeBlockHandler(pointer pCounter, struct timeval **wt, pointer LastSelectMask)
 {
-    IdleCounterPriv *priv = SYSCOUNTERPRIV(pCounter);
     SyncCounter *counter = pCounter;
+    IdleCounterPriv *priv = SysCounterGetPrivate(counter);
     XSyncValue *less = priv->value_less,
 	       *greater = priv->value_greater;
     XSyncValue idle, old_idle;
@@ -2835,7 +2845,8 @@ IdleTimeBlockHandler(pointer pCounter, struct timeval **wt, pointer LastSelectMa
 static void
 IdleTimeWakeupHandler (pointer pCounter, int rc, pointer LastSelectMask)
 {
-    IdleCounterPriv *priv = SYSCOUNTERPRIV(pCounter);
+    SyncCounter *counter = pCounter;
+    IdleCounterPriv *priv = SysCounterGetPrivate(counter);
     XSyncValue *less = priv->value_less,
 	       *greater = priv->value_greater;
     XSyncValue idle;
@@ -2856,7 +2867,8 @@ static void
 IdleTimeBracketValues (pointer pCounter, CARD64 *pbracket_less,
                        CARD64 *pbracket_greater)
 {
-    IdleCounterPriv *priv = SYSCOUNTERPRIV(pCounter);
+    SyncCounter *counter = pCounter;
+    IdleCounterPriv *priv = SysCounterGetPrivate(counter);
     XSyncValue *less = priv->value_less,
 	       *greater = priv->value_greater;
     Bool registered = (less || greater);
@@ -2897,7 +2909,7 @@ init_system_idle_counter(const char *name, int deviceid)
     priv->deviceid = deviceid;
     priv->value_less = priv->value_greater = NULL;
 
-    SYSCOUNTERPRIV(idle_time_counter) = priv;
+    idle_time_counter->pSysCounterInfo->private = priv;
 
     return idle_time_counter;
 }
diff --git a/Xext/syncsrv.h b/Xext/syncsrv.h
index 361b68d..6c0bf74 100644
--- a/Xext/syncsrv.h
+++ b/Xext/syncsrv.h
@@ -71,8 +71,6 @@ typedef void (*SyncSystemCounterBracketValues)(pointer counter,
 					       CARD64 *pbracket_less,
 					       CARD64 *pbracket_greater);
 
-#define SYSCOUNTERPRIV(counter) (((SyncCounter*)(counter))->pSysCounterInfo->private)
-
 typedef struct _SysCounterInfo {
     char	*name;
     CARD64	resolution;
-- 
1.7.7.6





> 
> The series looks fine generally; these are just minor details.
> 
> Jamey
> 
> On 3/13/12, Peter Hutterer <peter.hutterer at who-t.net> wrote:
> >
> > We currently have one global idlecounter. This patch series adds additional
> > counters named "DEVICEIDLETIME n" (where n is the device id) that apply to
> > that device only.
> >
> > One use-case here is as syndaemon replacement. A client can simply put an
> > idlecounter on the keyboard above the touchpad. When that keyboard goes out
> > of idle, disable the touchpad, then re-enable when the keyboard goes idle
> > again.
> >
> > Cheers,
> >   Peter
> > _______________________________________________
> > xorg-devel at lists.x.org: X.Org development
> > Archives: http://lists.x.org/archives/xorg-devel
> > Info: http://lists.x.org/mailman/listinfo/xorg-devel
> >


More information about the xorg-devel mailing list