diff options
author | Kaleb Keithley <kaleb@freedesktop.org> | 2003-11-14 16:49:22 +0000 |
---|---|---|
committer | Kaleb Keithley <kaleb@freedesktop.org> | 2003-11-14 16:49:22 +0000 |
commit | d568221710959cf7d783e6ff0fb80fb43a231124 (patch) | |
tree | 8d6f039393294c6ffac8533639afdebe5d68bfc1 /Xext/sync.c | |
parent | 9508a382f8a9f241dab097d921b6d290c1c3a776 (diff) |
XFree86 4.3.0.1xf86-4_3_0_1PRE_xf86-4_3_0_1
Diffstat (limited to 'Xext/sync.c')
-rw-r--r-- | Xext/sync.c | 298 |
1 files changed, 267 insertions, 31 deletions
diff --git a/Xext/sync.c b/Xext/sync.c index 8274d2522..079a804e3 100644 --- a/Xext/sync.c +++ b/Xext/sync.c @@ -50,10 +50,10 @@ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +/* $XFree86: xc/programs/Xserver/Xext/sync.c,v 3.11 2001/12/14 19:58:51 dawes Exp $ */ #define NEED_REPLIES #define NEED_EVENTS -#include <stdio.h> #include "X.h" #include "Xproto.h" #include "Xmd.h" @@ -67,6 +67,15 @@ PERFORMANCE OF THIS SOFTWARE. #include "sync.h" #include "syncstr.h" +#ifdef EXTMODULE +#include "xf86_ansic.h" +#else +#include <stdio.h> +#if !defined(WIN32) && !defined(Lynx) +#include <sys/time.h> +#endif +#endif + /* * Local Global Variables */ @@ -87,13 +96,254 @@ static SyncCounter **SysCounterList = NULL; #define XSyncCAAllTrigger \ (XSyncCACounter | XSyncCAValueType | XSyncCAValue | XSyncCATestType) +static int +FreeAlarm( +#if NeedFunctionPrototypes + pointer /* addr */, + XID /* id */ +#endif +); + +static int +FreeAlarmClient( +#if NeedFunctionPrototypes + pointer /* value */, + XID /* id */ +#endif +); + +static int +FreeAwait( +#if NeedFunctionPrototypes + pointer /* addr */, + XID /* id */ +#endif +); + +static void +ServertimeBracketValues( +#if NeedFunctionPrototypes + pointer /* pCounter */, + CARD64 * /* pbracket_less */, + CARD64 * /* pbracket_greater */ +#endif +); + +static void +ServertimeQueryValue( +#if NeedFunctionPrototypes + pointer /* pCounter */, + CARD64 * /* pValue_return */ +#endif +); + +static void +ServertimeWakeupHandler( +#if NeedFunctionPrototypes + pointer /* env */, + int /* rc */, + pointer /* LastSelectMask */ +#endif +); + +static int +SyncInitTrigger( +#if NeedFunctionPrototypes + ClientPtr /* client */, + SyncTrigger * /* pTrigger */, + XSyncCounter /* counter */, + Mask /* changes */ +#endif +); + +static void +SAlarmNotifyEvent( +#if NeedFunctionPrototypes + xSyncAlarmNotifyEvent * /* from */, + xSyncAlarmNotifyEvent * /* to */ +#endif +); + +static void +SCounterNotifyEvent( +#if NeedFunctionPrototypes + xSyncCounterNotifyEvent * /* from */, + xSyncCounterNotifyEvent * /* to */ +#endif +); + +static void +ServertimeBlockHandler( +#if NeedFunctionPrototypes + pointer /* env */, + struct timeval ** /* wt */, + pointer /* LastSelectMask */ +#endif +); + +static int +SyncAddTriggerToCounter( +#if NeedFunctionPrototypes + SyncTrigger * /* pTrigger */ +#endif +); + +extern void +SyncAlarmCounterDestroyed( +#if NeedFunctionPrototypes + SyncTrigger * /* pTrigger */ +#endif +); + +static void +SyncAlarmTriggerFired( +#if NeedFunctionPrototypes + SyncTrigger * /* pTrigger */ +#endif +); + +static void +SyncAwaitTriggerFired( +#if NeedFunctionPrototypes + SyncTrigger * /* pTrigger */ +#endif +); + +static int +SyncChangeAlarmAttributes( +#if NeedFunctionPrototypes + ClientPtr /* client */, + SyncAlarm * /* pAlarm */, + Mask /* mask */, + CARD32 * /* values */ +#endif +); + +static Bool +SyncCheckTriggerNegativeComparison( +#if NeedFunctionPrototypes + SyncTrigger * /* pTrigger */, + CARD64 /* oldval */ +#endif +); + +static Bool +SyncCheckTriggerNegativeTransition( +#if NeedFunctionPrototypes + SyncTrigger * /* pTrigger */, + CARD64 /* oldval */ +#endif +); + +static Bool +SyncCheckTriggerPositiveComparison( +#if NeedFunctionPrototypes + SyncTrigger * /* pTrigger */, + CARD64 /* oldval */ +#endif +); + +static Bool +SyncCheckTriggerPositiveTransition( +#if NeedFunctionPrototypes + SyncTrigger * /* pTrigger */, + CARD64 /* oldval */ +#endif +); + +static SyncCounter * +SyncCreateCounter( +#if NeedFunctionPrototypes + ClientPtr /* client */, + XSyncCounter /* id */, + CARD64 /* initialvalue */ +#endif +); + static void SyncComputeBracketValues( #if NeedFunctionPrototypes - SyncCounter * /* pCounter */, - Bool /* startOver */ + SyncCounter * /* pCounter */, + Bool /* startOver */ #endif ); +static void +SyncDeleteTriggerFromCounter( +#if NeedFunctionPrototypes + SyncTrigger * /* pTrigger */ +#endif +); + +static Bool +SyncEventSelectForAlarm( +#if NeedFunctionPrototypes + SyncAlarm * /* pAlarm */, + ClientPtr /* client */, + Bool /* wantevents */ +#endif +); + +static void +SyncInitServerTime( +#if NeedFunctionPrototypes + void +#endif +); + +static void +SyncResetProc( +#if NeedFunctionPrototypes + ExtensionEntry * /* extEntry */ +#endif +); + +static void +SyncSendAlarmNotifyEvents( +#if NeedFunctionPrototypes + SyncAlarm * /* pAlarm */ +#endif +); + +static void +SyncSendCounterNotifyEvents( +#if NeedFunctionPrototypes + ClientPtr /* client */, + SyncAwait ** /* ppAwait */, + int /* num_events */ +#endif +); + +static DISPATCH_PROC(ProcSyncAwait); +static DISPATCH_PROC(ProcSyncChangeAlarm); +static DISPATCH_PROC(ProcSyncChangeCounter); +static DISPATCH_PROC(ProcSyncCreateAlarm); +static DISPATCH_PROC(ProcSyncCreateCounter); +static DISPATCH_PROC(ProcSyncDestroyAlarm); +static DISPATCH_PROC(ProcSyncDestroyCounter); +static DISPATCH_PROC(ProcSyncDispatch); +static DISPATCH_PROC(ProcSyncGetPriority); +static DISPATCH_PROC(ProcSyncInitialize); +static DISPATCH_PROC(ProcSyncListSystemCounters); +static DISPATCH_PROC(ProcSyncQueryAlarm); +static DISPATCH_PROC(ProcSyncQueryCounter); +static DISPATCH_PROC(ProcSyncSetCounter); +static DISPATCH_PROC(ProcSyncSetPriority); +static DISPATCH_PROC(SProcSyncAwait); +static DISPATCH_PROC(SProcSyncChangeAlarm); +static DISPATCH_PROC(SProcSyncChangeCounter); +static DISPATCH_PROC(SProcSyncCreateAlarm); +static DISPATCH_PROC(SProcSyncCreateCounter); +static DISPATCH_PROC(SProcSyncDestroyAlarm); +static DISPATCH_PROC(SProcSyncDestroyCounter); +static DISPATCH_PROC(SProcSyncDispatch); +static DISPATCH_PROC(SProcSyncGetPriority); +static DISPATCH_PROC(SProcSyncInitialize); +static DISPATCH_PROC(SProcSyncListSystemCounters); +static DISPATCH_PROC(SProcSyncQueryAlarm); +static DISPATCH_PROC(SProcSyncQueryCounter); +static DISPATCH_PROC(SProcSyncSetCounter); +static DISPATCH_PROC(SProcSyncSetPriority); + /* Each counter maintains a simple linked list of triggers that are * interested in the counter. The two functions below are used to * delete and add triggers on this list. @@ -462,26 +712,26 @@ SyncAlarmTriggerFired(pTrigger) { Bool overflow; CARD64 oldvalue; - SyncTrigger *pTrigger = &pAlarm->trigger; + SyncTrigger *paTrigger = &pAlarm->trigger; /* "The alarm is updated by repeatedly adding delta to the * value of the trigger and re-initializing it until it * becomes FALSE." */ - oldvalue = pTrigger->test_value; + oldvalue = paTrigger->test_value; /* XXX really should do something smarter here */ do { - XSyncValueAdd(&pTrigger->test_value, pTrigger->test_value, + XSyncValueAdd(&paTrigger->test_value, paTrigger->test_value, pAlarm->delta, &overflow); } while (!overflow && - (*pTrigger->CheckTrigger)(pTrigger, - pTrigger->pCounter->value)); + (*paTrigger->CheckTrigger)(paTrigger, + paTrigger->pCounter->value)); - new_test_value = pTrigger->test_value; - pTrigger->test_value = oldvalue; + new_test_value = paTrigger->test_value; + paTrigger->test_value = oldvalue; /* "If this update would cause value to fall outside the range * for an INT64...no change is made to value (test-value) and @@ -710,7 +960,6 @@ SyncChangeAlarmAttributes(client, pAlarm, mask, values) Mask mask; CARD32 *values; { - SyncAlarmClientList *pClients; int status; XSyncCounter counter; Mask origmask = mask; @@ -719,9 +968,9 @@ SyncChangeAlarmAttributes(client, pAlarm, mask, values) while (mask) { - int index = lowbit(mask); - mask &= ~index; - switch (index) + int index2 = lowbit(mask); + mask &= ~index2; + switch (index2) { case XSyncCACounter: mask &= ~XSyncCACounter; @@ -998,7 +1247,6 @@ FreeAlarm(addr, id) XID id; { SyncAlarm *pAlarm = (SyncAlarm *) addr; - SyncAlarmClientList *pClient; pAlarm->state = XSyncAlarmDestroyed; @@ -1139,7 +1387,6 @@ static int ProcSyncInitialize(client) ClientPtr client; { - REQUEST(xSyncInitializeReq); xSyncInitializeReply rep; int n; @@ -1166,10 +1413,9 @@ static int ProcSyncListSystemCounters(client) ClientPtr client; { - REQUEST(xSyncListSystemCountersReq); xSyncListSystemCountersReply rep; int i, len; - xSyncSystemCounter *list, *walklist; + xSyncSystemCounter *list = NULL, *walklist = NULL; REQUEST_SIZE_MATCH(xSyncListSystemCountersReq); @@ -1318,7 +1564,6 @@ ProcSyncCreateCounter(client) ClientPtr client; { REQUEST(xSyncCreateCounterReq); - SyncCounter *pCounter; CARD64 initial; REQUEST_SIZE_MATCH(xSyncCreateCounterReq); @@ -1440,9 +1685,8 @@ ProcSyncAwait(client) { REQUEST(xSyncAwaitReq); int len, items; - int n, i; + int i; xSyncWaitCondition *pProtocolWaitConds; - int ret; SyncAwaitUnion *pAwaitUnion; SyncAwait *pAwait; int status; @@ -1606,7 +1850,6 @@ ProcSyncCreateAlarm(client) REQUEST(xSyncCreateAlarmReq); SyncAlarm *pAlarm; int status; - int i; unsigned long len, vmask; SyncTrigger *pTrigger; @@ -2063,8 +2306,6 @@ static int SProcSyncDispatch(client) ClientPtr client; { - int n; - REQUEST(xReq); switch (stuff->data) @@ -2154,8 +2395,6 @@ SyncResetProc(extEntry) } -static void SyncInitServerTime(); - /* * ** Initialise the extension. */ @@ -2188,8 +2427,8 @@ SyncExtensionInit() SyncReqCode = extEntry->base; SyncEventBase = extEntry->eventBase; SyncErrorBase = extEntry->errorBase; - EventSwapVector[SyncEventBase + XSyncCounterNotify] = SCounterNotifyEvent; - EventSwapVector[SyncEventBase + XSyncAlarmNotify] = SAlarmNotifyEvent; + EventSwapVector[SyncEventBase + XSyncCounterNotify] = (EventSwapPtr) SCounterNotifyEvent; + EventSwapVector[SyncEventBase + XSyncAlarmNotify] = (EventSwapPtr) SAlarmNotifyEvent; /* * Although SERVERTIME is implemented by the OS layer, we initialise it @@ -2211,9 +2450,6 @@ SyncExtensionInit() */ -#ifndef WIN32 -#include <sys/time.h> -#endif static pointer ServertimeCounter; static XSyncValue Now; |