Unverified Commit eaae9610 authored by Mihai Moldovan's avatar Mihai Moldovan

Merge branch 'uli42-pr/update_record' into 3.6.x

parents 92d80639 e5833a6a
...@@ -41,6 +41,7 @@ and Jim Haggerty of Metheus. ...@@ -41,6 +41,7 @@ and Jim Haggerty of Metheus.
#define _XRECORD_SERVER_ #define _XRECORD_SERVER_
#include <nx-X11/extensions/recordstr.h> #include <nx-X11/extensions/recordstr.h>
#include "set.h" #include "set.h"
#include "swaprep.h"
#include <stdio.h> #include <stdio.h>
#include <assert.h> #include <assert.h>
...@@ -201,8 +202,7 @@ static int numEnabledContexts; ...@@ -201,8 +202,7 @@ static int numEnabledContexts;
* Side Effects: none. * Side Effects: none.
*/ */
static int static int
RecordFindContextOnAllContexts(pContext) RecordFindContextOnAllContexts(RecordContextPtr pContext)
RecordContextPtr pContext;
{ {
int i; int i;
...@@ -465,10 +465,7 @@ RecordFindClientOnContext( ...@@ -465,10 +465,7 @@ RecordFindClientOnContext(
* Note: this function exists mainly to make RecordARequest smaller. * Note: this function exists mainly to make RecordARequest smaller.
*/ */
static void static void
RecordABigRequest(pContext, client, stuff) RecordABigRequest(RecordContextPtr pContext, ClientPtr client, xReq *stuff)
RecordContextPtr pContext;
ClientPtr client;
xReq *stuff;
{ {
CARD32 bigLength; CARD32 bigLength;
int bytesLeft; int bytesLeft;
...@@ -516,8 +513,7 @@ RecordABigRequest(pContext, client, stuff) ...@@ -516,8 +513,7 @@ RecordABigRequest(pContext, client, stuff)
* request for this client. The real Proc function is called. * request for this client. The real Proc function is called.
*/ */
static int static int
RecordARequest(client) RecordARequest(ClientPtr client)
ClientPtr client;
{ {
RecordContextPtr pContext; RecordContextPtr pContext;
RecordClientsAndProtocolPtr pRCAP; RecordClientsAndProtocolPtr pRCAP;
...@@ -600,10 +596,7 @@ RecordARequest(client) ...@@ -600,10 +596,7 @@ RecordARequest(client)
* the word skip in ddx.tbl.ms (the porting layer document). * the word skip in ddx.tbl.ms (the porting layer document).
*/ */
static void static void
RecordASkippedRequest(pcbl , nulldata, calldata) RecordASkippedRequest(CallbackListPtr *pcbl, void * nulldata, void * calldata)
CallbackListPtr *pcbl;
void * nulldata;
void * calldata;
{ {
SkippedRequestInfoRec *psi = (SkippedRequestInfoRec *)calldata; SkippedRequestInfoRec *psi = (SkippedRequestInfoRec *)calldata;
RecordContextPtr pContext; RecordContextPtr pContext;
...@@ -690,10 +683,7 @@ RecordASkippedRequest(pcbl , nulldata, calldata) ...@@ -690,10 +683,7 @@ RecordASkippedRequest(pcbl , nulldata, calldata)
* chunk of data belonging to this reply, it is set to 0. * chunk of data belonging to this reply, it is set to 0.
*/ */
static void static void
RecordAReply(pcbl, nulldata, calldata) RecordAReply(CallbackListPtr *pcbl, void * nulldata, void * calldata)
CallbackListPtr *pcbl;
void * nulldata;
void * calldata;
{ {
RecordContextPtr pContext; RecordContextPtr pContext;
RecordClientsAndProtocolPtr pRCAP; RecordClientsAndProtocolPtr pRCAP;
...@@ -775,10 +765,7 @@ RecordAReply(pcbl, nulldata, calldata) ...@@ -775,10 +765,7 @@ RecordAReply(pcbl, nulldata, calldata)
* it for this client. * it for this client.
*/ */
static void static void
RecordADeliveredEventOrError(pcbl, nulldata, calldata) RecordADeliveredEventOrError(CallbackListPtr *pcbl, void * nulldata, void * calldata)
CallbackListPtr *pcbl;
void * nulldata;
void * calldata;
{ {
EventInfoRec *pei = (EventInfoRec *)calldata; EventInfoRec *pei = (EventInfoRec *)calldata;
RecordContextPtr pContext; RecordContextPtr pContext;
...@@ -797,13 +784,13 @@ RecordADeliveredEventOrError(pcbl, nulldata, calldata) ...@@ -797,13 +784,13 @@ RecordADeliveredEventOrError(pcbl, nulldata, calldata)
xEvent *pev = pei->events; xEvent *pev = pei->events;
for (ev = 0; ev < pei->count; ev++, pev++) for (ev = 0; ev < pei->count; ev++, pev++)
{ {
int recordit; int recordit = 0;
if (pev->u.u.type == X_Error) if (pRCAP->pErrorSet)
{ {
recordit = RecordIsMemberOfSet(pRCAP->pErrorSet, recordit = RecordIsMemberOfSet(pRCAP->pErrorSet,
((xError *)(pev))->errorCode); ((xError *)(pev))->errorCode);
} }
else else if (pRCAP->pDeliveredEventSet)
{ {
recordit = RecordIsMemberOfSet(pRCAP->pDeliveredEventSet, recordit = RecordIsMemberOfSet(pRCAP->pDeliveredEventSet,
pev->u.u.type & 0177); pev->u.u.type & 0177);
...@@ -844,10 +831,7 @@ RecordADeliveredEventOrError(pcbl, nulldata, calldata) ...@@ -844,10 +831,7 @@ RecordADeliveredEventOrError(pcbl, nulldata, calldata)
* it for this client. * it for this client.
*/ */
static void static void
RecordADeviceEvent(pcbl, nulldata, calldata) RecordADeviceEvent(CallbackListPtr *pcbl, void * nulldata, void * calldata)
CallbackListPtr *pcbl;
void * nulldata;
void * calldata;
{ {
DeviceEventInfoRec *pei = (DeviceEventInfoRec *)calldata; DeviceEventInfoRec *pei = (DeviceEventInfoRec *)calldata;
RecordContextPtr pContext; RecordContextPtr pContext;
...@@ -968,9 +952,7 @@ RecordFlushAllContexts( ...@@ -968,9 +952,7 @@ RecordFlushAllContexts(
* various callback lists. * various callback lists.
*/ */
static int static int
RecordInstallHooks(pRCAP, oneclient) RecordInstallHooks(RecordClientsAndProtocolPtr pRCAP, XID oneclient)
RecordClientsAndProtocolPtr pRCAP;
XID oneclient;
{ {
int i = 0; int i = 0;
XID client; XID client;
...@@ -1063,9 +1045,7 @@ RecordInstallHooks(pRCAP, oneclient) ...@@ -1063,9 +1045,7 @@ RecordInstallHooks(pRCAP, oneclient)
* various callback lists. * various callback lists.
*/ */
static void static void
RecordUninstallHooks(pRCAP, oneclient) RecordUninstallHooks(RecordClientsAndProtocolPtr pRCAP, XID oneclient)
RecordClientsAndProtocolPtr pRCAP;
XID oneclient;
{ {
int i = 0; int i = 0;
XID client; XID client;
...@@ -1164,9 +1144,7 @@ RecordUninstallHooks(pRCAP, oneclient) ...@@ -1164,9 +1144,7 @@ RecordUninstallHooks(pRCAP, oneclient)
* have at least one client.) * have at least one client.)
*/ */
static void static void
RecordDeleteClientFromRCAP(pRCAP, position) RecordDeleteClientFromRCAP(RecordClientsAndProtocolPtr pRCAP, int position)
RecordClientsAndProtocolPtr pRCAP;
int position;
{ {
if (pRCAP->pContext->pRecordingClient) if (pRCAP->pContext->pRecordingClient)
RecordUninstallHooks(pRCAP, pRCAP->pClientIDs[position]); RecordUninstallHooks(pRCAP, pRCAP->pClientIDs[position]);
...@@ -1213,9 +1191,7 @@ RecordDeleteClientFromRCAP(pRCAP, position) ...@@ -1213,9 +1191,7 @@ RecordDeleteClientFromRCAP(pRCAP, position)
* is no more room to hold clients internal to the RCAP. * is no more room to hold clients internal to the RCAP.
*/ */
static void static void
RecordAddClientToRCAP(pRCAP, clientspec) RecordAddClientToRCAP(RecordClientsAndProtocolPtr pRCAP, XID clientspec)
RecordClientsAndProtocolPtr pRCAP;
XID clientspec;
{ {
if (pRCAP->numClients == pRCAP->sizeClients) if (pRCAP->numClients == pRCAP->sizeClients)
{ {
...@@ -1261,9 +1237,7 @@ RecordAddClientToRCAP(pRCAP, clientspec) ...@@ -1261,9 +1237,7 @@ RecordAddClientToRCAP(pRCAP, clientspec)
* RCAP. (A given clientspec can only be on one RCAP of a context.) * RCAP. (A given clientspec can only be on one RCAP of a context.)
*/ */
static void static void
RecordDeleteClientFromContext(pContext, clientspec) RecordDeleteClientFromContext(RecordContextPtr pContext, XID clientspec)
RecordContextPtr pContext;
XID clientspec;
{ {
RecordClientsAndProtocolPtr pRCAP; RecordClientsAndProtocolPtr pRCAP;
int position; int position;
...@@ -1286,10 +1260,7 @@ RecordDeleteClientFromContext(pContext, clientspec) ...@@ -1286,10 +1260,7 @@ RecordDeleteClientFromContext(pContext, clientspec)
* Side Effects: none. * Side Effects: none.
*/ */
static int static int
RecordSanityCheckClientSpecifiers(clientspecs, nspecs, errorspec) RecordSanityCheckClientSpecifiers(XID *clientspecs, int nspecs, XID errorspec)
XID *clientspecs;
int nspecs;
XID errorspec;
{ {
int i; int i;
int clientIndex; int clientIndex;
...@@ -1348,10 +1319,7 @@ RecordSanityCheckClientSpecifiers(clientspecs, nspecs, errorspec) ...@@ -1348,10 +1319,7 @@ RecordSanityCheckClientSpecifiers(clientspecs, nspecs, errorspec)
* pClientspecs may be modified in place. * pClientspecs may be modified in place.
*/ */
static XID * static XID *
RecordCanonicalizeClientSpecifiers(pClientspecs, pNumClientspecs, excludespec) RecordCanonicalizeClientSpecifiers(XID *pClientspecs, int *pNumClientspecs, XID excludespec)
XID *pClientspecs;
int *pNumClientspecs;
XID excludespec;
{ {
int i; int i;
int numClients = *pNumClientspecs; int numClients = *pNumClientspecs;
...@@ -1448,10 +1416,7 @@ RecordPadAlign(int size, int align) ...@@ -1448,10 +1416,7 @@ RecordPadAlign(int size, int align)
* Side Effects: none. * Side Effects: none.
*/ */
static int static int
RecordSanityCheckRegisterClients(pContext, client, stuff) RecordSanityCheckRegisterClients(RecordContextPtr pContext, ClientPtr client, xRecordRegisterClientsReq *stuff)
RecordContextPtr pContext;
ClientPtr client;
xRecordRegisterClientsReq *stuff;
{ {
int err; int err;
xRecordRange *pRange; xRecordRange *pRange;
...@@ -1586,9 +1551,7 @@ enum {REQ, /* set info for requests */ ...@@ -1586,9 +1551,7 @@ enum {REQ, /* set info for requests */
* RecordSetIntervals, all zeroed, and psi->size is set to size. * RecordSetIntervals, all zeroed, and psi->size is set to size.
*/ */
static int static int
RecordAllocIntervals(psi, nIntervals) RecordAllocIntervals(SetInfoPtr psi, int nIntervals)
SetInfoPtr psi;
int nIntervals;
{ {
assert(!psi->intervals); assert(!psi->intervals);
psi->intervals = (RecordSetInterval *) psi->intervals = (RecordSetInterval *)
...@@ -1710,10 +1673,7 @@ RecordConvertRangesToIntervals( ...@@ -1710,10 +1673,7 @@ RecordConvertRangesToIntervals(
* to record the new clients and protocol. * to record the new clients and protocol.
*/ */
static int static int
RecordRegisterClients(pContext, client, stuff) RecordRegisterClients(RecordContextPtr pContext, ClientPtr client, xRecordRegisterClientsReq *stuff)
RecordContextPtr pContext;
ClientPtr client;
xRecordRegisterClientsReq *stuff;
{ {
int err; int err;
int i; int i;
...@@ -1986,8 +1946,7 @@ bailout: ...@@ -1986,8 +1946,7 @@ bailout:
*/ */
static int static int
ProcRecordQueryVersion(client) ProcRecordQueryVersion(ClientPtr client)
ClientPtr client;
{ {
/* REQUEST(xRecordQueryVersionReq); */ /* REQUEST(xRecordQueryVersionReq); */
xRecordQueryVersionReply rep; xRecordQueryVersionReply rep;
...@@ -2011,8 +1970,7 @@ ProcRecordQueryVersion(client) ...@@ -2011,8 +1970,7 @@ ProcRecordQueryVersion(client)
static int static int
ProcRecordCreateContext(client) ProcRecordCreateContext(ClientPtr client)
ClientPtr client;
{ {
REQUEST(xRecordCreateContextReq); REQUEST(xRecordCreateContextReq);
RecordContextPtr pContext; RecordContextPtr pContext;
...@@ -2067,8 +2025,7 @@ bailout: ...@@ -2067,8 +2025,7 @@ bailout:
static int static int
ProcRecordRegisterClients(client) ProcRecordRegisterClients(ClientPtr client)
ClientPtr client;
{ {
RecordContextPtr pContext; RecordContextPtr pContext;
REQUEST(xRecordRegisterClientsReq); REQUEST(xRecordRegisterClientsReq);
...@@ -2081,8 +2038,7 @@ ProcRecordRegisterClients(client) ...@@ -2081,8 +2038,7 @@ ProcRecordRegisterClients(client)
static int static int
ProcRecordUnregisterClients(client) ProcRecordUnregisterClients(ClientPtr client)
ClientPtr client;
{ {
RecordContextPtr pContext; RecordContextPtr pContext;
int err; int err;
...@@ -2146,9 +2102,7 @@ typedef struct { ...@@ -2146,9 +2102,7 @@ typedef struct {
* number of ranges. Newly allocated ranges are zeroed. * number of ranges. Newly allocated ranges are zeroed.
*/ */
static int static int
RecordAllocRanges(pri, nRanges) RecordAllocRanges(GetContextRangeInfoPtr pri, int nRanges)
GetContextRangeInfoPtr pri;
int nRanges;
{ {
int newsize; int newsize;
xRecordRange *pNewRange; xRecordRange *pNewRange;
...@@ -2308,9 +2262,7 @@ RecordConvertMinorOpInfoToRanges( ...@@ -2308,9 +2262,7 @@ RecordConvertMinorOpInfoToRanges(
* The 16 bit fields of each xRecordRange are byte swapped. * The 16 bit fields of each xRecordRange are byte swapped.
*/ */
static void static void
RecordSwapRanges(pRanges, nRanges) RecordSwapRanges(xRecordRange *pRanges, int nRanges)
xRecordRange *pRanges;
int nRanges;
{ {
int i; int i;
for (i = 0; i < nRanges; i++, pRanges++) for (i = 0; i < nRanges; i++, pRanges++)
...@@ -2324,8 +2276,7 @@ RecordSwapRanges(pRanges, nRanges) ...@@ -2324,8 +2276,7 @@ RecordSwapRanges(pRanges, nRanges)
static int static int
ProcRecordGetContext(client) ProcRecordGetContext(ClientPtr client)
ClientPtr client;
{ {
RecordContextPtr pContext; RecordContextPtr pContext;
REQUEST(xRecordGetContextReq); REQUEST(xRecordGetContextReq);
...@@ -2470,8 +2421,7 @@ bailout: ...@@ -2470,8 +2421,7 @@ bailout:
static int static int
ProcRecordEnableContext(client) ProcRecordEnableContext(ClientPtr client)
ClientPtr client;
{ {
RecordContextPtr pContext; RecordContextPtr pContext;
REQUEST(xRecordEnableContextReq); REQUEST(xRecordEnableContextReq);
...@@ -2549,8 +2499,7 @@ ProcRecordEnableContext(client) ...@@ -2549,8 +2499,7 @@ ProcRecordEnableContext(client)
* is resumed. * is resumed.
*/ */
static void static void
RecordDisableContext(pContext) RecordDisableContext(RecordContextPtr pContext)
RecordContextPtr pContext;
{ {
RecordClientsAndProtocolPtr pRCAP; RecordClientsAndProtocolPtr pRCAP;
int i; int i;
...@@ -2587,8 +2536,7 @@ RecordDisableContext(pContext) ...@@ -2587,8 +2536,7 @@ RecordDisableContext(pContext)
static int static int
ProcRecordDisableContext(client) ProcRecordDisableContext(ClientPtr client)
ClientPtr client;
{ {
RecordContextPtr pContext; RecordContextPtr pContext;
REQUEST(xRecordDisableContextReq); REQUEST(xRecordDisableContextReq);
...@@ -2613,9 +2561,7 @@ ProcRecordDisableContext(client) ...@@ -2613,9 +2561,7 @@ ProcRecordDisableContext(client)
* it from the ppAllContexts array. * it from the ppAllContexts array.
*/ */
static int static int
RecordDeleteContext(value, id) RecordDeleteContext(void * value, XID id)
void * value;
XID id;
{ {
int i; int i;
RecordContextPtr pContext = (RecordContextPtr)value; RecordContextPtr pContext = (RecordContextPtr)value;
...@@ -2655,8 +2601,7 @@ RecordDeleteContext(value, id) ...@@ -2655,8 +2601,7 @@ RecordDeleteContext(value, id)
static int static int
ProcRecordFreeContext(client) ProcRecordFreeContext(ClientPtr client)
ClientPtr client;
{ {
RecordContextPtr pContext; RecordContextPtr pContext;
REQUEST(xRecordFreeContextReq); REQUEST(xRecordFreeContextReq);
...@@ -2669,8 +2614,7 @@ ProcRecordFreeContext(client) ...@@ -2669,8 +2614,7 @@ ProcRecordFreeContext(client)
static int static int
ProcRecordDispatch(client) ProcRecordDispatch(ClientPtr client)
ClientPtr client;
{ {
REQUEST(xReq); REQUEST(xReq);
...@@ -2699,8 +2643,7 @@ ProcRecordDispatch(client) ...@@ -2699,8 +2643,7 @@ ProcRecordDispatch(client)
static int static int
SProcRecordQueryVersion(client) SProcRecordQueryVersion(ClientPtr client)
ClientPtr client;
{ {
REQUEST(xRecordQueryVersionReq); REQUEST(xRecordQueryVersionReq);
...@@ -2737,8 +2680,7 @@ SwapCreateRegister(xRecordRegisterClientsReq *stuff) ...@@ -2737,8 +2680,7 @@ SwapCreateRegister(xRecordRegisterClientsReq *stuff)
static int static int
SProcRecordCreateContext(client) SProcRecordCreateContext(ClientPtr client)
ClientPtr client;
{ {
REQUEST(xRecordCreateContextReq); REQUEST(xRecordCreateContextReq);
int status; int status;
...@@ -2752,8 +2694,7 @@ SProcRecordCreateContext(client) ...@@ -2752,8 +2694,7 @@ SProcRecordCreateContext(client)
static int static int
SProcRecordRegisterClients(client) SProcRecordRegisterClients(ClientPtr client)
ClientPtr client;
{ {
REQUEST(xRecordRegisterClientsReq); REQUEST(xRecordRegisterClientsReq);
int status; int status;
...@@ -2767,8 +2708,7 @@ SProcRecordRegisterClients(client) ...@@ -2767,8 +2708,7 @@ SProcRecordRegisterClients(client)
static int static int
SProcRecordUnregisterClients(client) SProcRecordUnregisterClients(ClientPtr client)
ClientPtr client;
{ {
REQUEST(xRecordUnregisterClientsReq); REQUEST(xRecordUnregisterClientsReq);
...@@ -2782,8 +2722,7 @@ SProcRecordUnregisterClients(client) ...@@ -2782,8 +2722,7 @@ SProcRecordUnregisterClients(client)
static int static int
SProcRecordGetContext(client) SProcRecordGetContext(ClientPtr client)
ClientPtr client;
{ {
REQUEST(xRecordGetContextReq); REQUEST(xRecordGetContextReq);
...@@ -2794,8 +2733,7 @@ SProcRecordGetContext(client) ...@@ -2794,8 +2733,7 @@ SProcRecordGetContext(client)
} /* SProcRecordGetContext */ } /* SProcRecordGetContext */
static int static int
SProcRecordEnableContext(client) SProcRecordEnableContext(ClientPtr client)
ClientPtr client;
{ {
REQUEST(xRecordEnableContextReq); REQUEST(xRecordEnableContextReq);
...@@ -2807,8 +2745,7 @@ SProcRecordEnableContext(client) ...@@ -2807,8 +2745,7 @@ SProcRecordEnableContext(client)
static int static int
SProcRecordDisableContext(client) SProcRecordDisableContext(ClientPtr client)
ClientPtr client;
{ {
REQUEST(xRecordDisableContextReq); REQUEST(xRecordDisableContextReq);
...@@ -2820,8 +2757,7 @@ SProcRecordDisableContext(client) ...@@ -2820,8 +2757,7 @@ SProcRecordDisableContext(client)
static int static int
SProcRecordFreeContext(client) SProcRecordFreeContext(ClientPtr client)
ClientPtr client;
{ {
REQUEST(xRecordFreeContextReq); REQUEST(xRecordFreeContextReq);
...@@ -2833,8 +2769,7 @@ SProcRecordFreeContext(client) ...@@ -2833,8 +2769,7 @@ SProcRecordFreeContext(client)
static int static int
SProcRecordDispatch(client) SProcRecordDispatch(ClientPtr client)
ClientPtr client;
{ {
REQUEST(xReq); REQUEST(xReq);
...@@ -2861,9 +2796,6 @@ SProcRecordDispatch(client) ...@@ -2861,9 +2796,6 @@ SProcRecordDispatch(client)
} }
} /* SProcRecordDispatch */ } /* SProcRecordDispatch */
/* XXX goes in header file */
extern void SwapConnSetupInfo(), SwapConnSetupPrefix();
/* RecordConnectionSetupInfo /* RecordConnectionSetupInfo
* *
* Arguments: * Arguments:
...@@ -2877,20 +2809,18 @@ extern void SwapConnSetupInfo(), SwapConnSetupPrefix(); ...@@ -2877,20 +2809,18 @@ extern void SwapConnSetupInfo(), SwapConnSetupPrefix();
* The connection setup info is sent to the recording client. * The connection setup info is sent to the recording client.
*/ */
static void static void
RecordConnectionSetupInfo(pContext, pci) RecordConnectionSetupInfo(RecordContextPtr pContext, NewClientInfoRec *pci)
RecordContextPtr pContext;
NewClientInfoRec *pci;
{ {
int prefixsize = SIZEOF(xConnSetupPrefix); int prefixsize = SIZEOF(xConnSetupPrefix);
int restsize = pci->prefix->length * 4; int restsize = pci->prefix->length * 4;
if (pci->client->swapped) if (pci->client->swapped)
{ {
char * pConnSetup = (char *)malloc(prefixsize + restsize); char *pConnSetup = (char *)malloc(prefixsize + restsize);
if (!pConnSetup) if (!pConnSetup)
return; return;
SwapConnSetupPrefix(pci->prefix, pConnSetup); SwapConnSetupPrefix(pci->prefix, (xConnSetupPrefix*)pConnSetup);
SwapConnSetupInfo(pci->setup, pConnSetup + prefixsize); SwapConnSetupInfo((char *)pci->setup, (char *)(pConnSetup + prefixsize));
RecordAProtocolElement(pContext, pci->client, XRecordClientStarted, RecordAProtocolElement(pContext, pci->client, XRecordClientStarted,
(void *)pConnSetup, prefixsize + restsize, 0); (void *)pConnSetup, prefixsize + restsize, 0);
free(pConnSetup); free(pConnSetup);
...@@ -2932,10 +2862,7 @@ RecordConnectionSetupInfo(pContext, pci) ...@@ -2932,10 +2862,7 @@ RecordConnectionSetupInfo(pContext, pci)
*/ */
static void static void
RecordAClientStateChange(pcbl, nulldata, calldata) RecordAClientStateChange(CallbackListPtr *pcbl, void * nulldata, void * calldata)
CallbackListPtr *pcbl;
void * nulldata;
void * calldata;
{ {
NewClientInfoRec *pci = (NewClientInfoRec *)calldata; NewClientInfoRec *pci = (NewClientInfoRec *)calldata;
int i; int i;
...@@ -2998,8 +2925,7 @@ RecordAClientStateChange(pcbl, nulldata, calldata) ...@@ -2998,8 +2925,7 @@ RecordAClientStateChange(pcbl, nulldata, calldata)
* *
*/ */
static void static void
RecordCloseDown(extEntry) RecordCloseDown(ExtensionEntry *extEntry)
ExtensionEntry *extEntry;
{ {
DeleteCallback(&ClientStateCallback, RecordAClientStateChange, NULL); DeleteCallback(&ClientStateCallback, RecordAClientStateChange, NULL);
} /* RecordCloseDown */ } /* RecordCloseDown */
...@@ -3015,7 +2941,7 @@ RecordCloseDown(extEntry) ...@@ -3015,7 +2941,7 @@ RecordCloseDown(extEntry)
* Enables the RECORD extension if possible. * Enables the RECORD extension if possible.
*/ */
void void
RecordExtensionInit() RecordExtensionInit(void)
{ {
ExtensionEntry *extentry; ExtensionEntry *extentry;
......
/* /*
Copyright 1995, 1998 The Open Group Copyright 1995, 1998 The Open Group
...@@ -44,9 +43,6 @@ from The Open Group. ...@@ -44,9 +43,6 @@ from The Open Group.
implemented, and RecordCreateSet will decide heuristically which one implemented, and RecordCreateSet will decide heuristically which one
to use based on the set members. to use based on the set members.
Note: When compiling for use in the server, do not use -DTESTING.
When compiling for stand-alone testing of the set ADT, use -DTESTING.
*/ */
#ifdef HAVE_DIX_CONFIG_H #ifdef HAVE_DIX_CONFIG_H
...@@ -55,34 +51,11 @@ from The Open Group. ...@@ -55,34 +51,11 @@ from The Open Group.
#include <string.h> #include <string.h>
#ifndef TESTING
#include "misc.h" #include "misc.h"
#else
#include <stdio.h>
#include <stdlib.h>
/* stuff that you normally get from the X Server's environment */
typedef int Bool;
#ifndef TRUE
#define TRUE 1
#define FALSE 0
#endif
typedef unsigned short CARD16;
#ifndef max
#define max(_a, _b) ( ((_a) > (_b)) ? (_a) : (_b) )
#endif
#endif /* TESTING */
#include "set.h" #include "set.h"
static int static int
maxMemberInInterval(pIntervals, nIntervals) maxMemberInInterval(RecordSetInterval *pIntervals, int nIntervals)
RecordSetInterval *pIntervals;
int nIntervals;
{ {
int i; int i;
int maxMember = -1; int maxMember = -1;
...@@ -95,8 +68,7 @@ maxMemberInInterval(pIntervals, nIntervals) ...@@ -95,8 +68,7 @@ maxMemberInInterval(pIntervals, nIntervals)
} }
static void static void
NoopDestroySet(pSet) NoopDestroySet(RecordSetPtr pSet)
RecordSetPtr pSet;
{ {
} }
...@@ -113,16 +85,13 @@ typedef struct { ...@@ -113,16 +85,13 @@ typedef struct {
#define BITS_PER_LONG (sizeof(unsigned long) * 8) #define BITS_PER_LONG (sizeof(unsigned long) * 8)
static void static void
BitVectorDestroySet(pSet) BitVectorDestroySet(RecordSetPtr pSet)
RecordSetPtr pSet;
{ {
free(pSet); free(pSet);
} }
static unsigned long static unsigned long
BitVectorIsMemberOfSet(pSet, pm) BitVectorIsMemberOfSet(RecordSetPtr pSet, int pm)
RecordSetPtr pSet;
int pm;
{ {
BitVectorSetPtr pbvs = (BitVectorSetPtr)pSet; BitVectorSetPtr pbvs = (BitVectorSetPtr)pSet;
unsigned long *pbitvec; unsigned long *pbitvec;
...@@ -134,10 +103,7 @@ BitVectorIsMemberOfSet(pSet, pm) ...@@ -134,10 +103,7 @@ BitVectorIsMemberOfSet(pSet, pm)
static int static int
BitVectorFindBit(pSet, iterbit, bitval) BitVectorFindBit(RecordSetPtr pSet, int iterbit, Bool bitval)
RecordSetPtr pSet;
int iterbit;
Bool bitval;
{ {
BitVectorSetPtr pbvs = (BitVectorSetPtr)pSet; BitVectorSetPtr pbvs = (BitVectorSetPtr)pSet;
unsigned long *pbitvec = (unsigned long *)(&pbvs[1]); unsigned long *pbitvec = (unsigned long *)(&pbvs[1]);
...@@ -183,10 +149,8 @@ BitVectorFindBit(pSet, iterbit, bitval) ...@@ -183,10 +149,8 @@ BitVectorFindBit(pSet, iterbit, bitval)
static RecordSetIteratePtr static RecordSetIteratePtr
BitVectorIterateSet(pSet, pIter, pInterval) BitVectorIterateSet(RecordSetPtr pSet, RecordSetIteratePtr pIter,
RecordSetPtr pSet; RecordSetInterval *pInterval)
RecordSetIteratePtr pIter;
RecordSetInterval *pInterval;
{ {
int iterbit = (int)(long)pIter; int iterbit = (int)(long)pIter;
int b; int b;
...@@ -200,18 +164,15 @@ BitVectorIterateSet(pSet, pIter, pInterval) ...@@ -200,18 +164,15 @@ BitVectorIterateSet(pSet, pIter, pInterval)
return (RecordSetIteratePtr)(long)(pInterval->last + 1); return (RecordSetIteratePtr)(long)(pInterval->last + 1);
} }
RecordSetOperations BitVectorSetOperations = { static RecordSetOperations BitVectorSetOperations = {
BitVectorDestroySet, BitVectorIsMemberOfSet, BitVectorIterateSet }; BitVectorDestroySet, BitVectorIsMemberOfSet, BitVectorIterateSet };
RecordSetOperations BitVectorNoFreeOperations = { static RecordSetOperations BitVectorNoFreeOperations = {
NoopDestroySet, BitVectorIsMemberOfSet, BitVectorIterateSet }; NoopDestroySet, BitVectorIsMemberOfSet, BitVectorIterateSet };
static int static int
BitVectorSetMemoryRequirements(pIntervals, nIntervals, maxMember, alignment) BitVectorSetMemoryRequirements(RecordSetInterval *pIntervals, int nIntervals,
RecordSetInterval *pIntervals; int maxMember, int *alignment)
int nIntervals;
int maxMember;
int *alignment;
{ {
int nlongs; int nlongs;
...@@ -221,11 +182,8 @@ BitVectorSetMemoryRequirements(pIntervals, nIntervals, maxMember, alignment) ...@@ -221,11 +182,8 @@ BitVectorSetMemoryRequirements(pIntervals, nIntervals, maxMember, alignment)
} }
static RecordSetPtr static RecordSetPtr
BitVectorCreateSet(pIntervals, nIntervals, pMem, memsize) BitVectorCreateSet(RecordSetInterval *pIntervals, int nIntervals,
RecordSetInterval *pIntervals; void *pMem, int memsize)
int nIntervals;
void *pMem;
int memsize;
{ {
BitVectorSetPtr pbvs; BitVectorSetPtr pbvs;
int i, j; int i, j;
...@@ -273,16 +231,13 @@ typedef struct { ...@@ -273,16 +231,13 @@ typedef struct {
} IntervalListSet, *IntervalListSetPtr; } IntervalListSet, *IntervalListSetPtr;
static void static void
IntervalListDestroySet(pSet) IntervalListDestroySet(RecordSetPtr pSet)
RecordSetPtr pSet;
{ {
free(pSet); free(pSet);
} }
static unsigned long static unsigned long
IntervalListIsMemberOfSet(pSet, pm) IntervalListIsMemberOfSet(RecordSetPtr pSet, int pm)
RecordSetPtr pSet;
int pm;
{ {
IntervalListSetPtr prls = (IntervalListSetPtr)pSet; IntervalListSetPtr prls = (IntervalListSetPtr)pSet;
RecordSetInterval *pInterval = (RecordSetInterval *)(&prls[1]); RecordSetInterval *pInterval = (RecordSetInterval *)(&prls[1]);
...@@ -302,10 +257,8 @@ IntervalListIsMemberOfSet(pSet, pm) ...@@ -302,10 +257,8 @@ IntervalListIsMemberOfSet(pSet, pm)
static RecordSetIteratePtr static RecordSetIteratePtr
IntervalListIterateSet(pSet, pIter, pIntervalReturn) IntervalListIterateSet(RecordSetPtr pSet, RecordSetIteratePtr pIter,
RecordSetPtr pSet; RecordSetInterval *pIntervalReturn)
RecordSetIteratePtr pIter;
RecordSetInterval *pIntervalReturn;
{ {
RecordSetInterval *pInterval = (RecordSetInterval *)pIter; RecordSetInterval *pInterval = (RecordSetInterval *)pIter;
IntervalListSetPtr prls = (IntervalListSetPtr)pSet; IntervalListSetPtr prls = (IntervalListSetPtr)pSet;
...@@ -324,29 +277,23 @@ IntervalListIterateSet(pSet, pIter, pIntervalReturn) ...@@ -324,29 +277,23 @@ IntervalListIterateSet(pSet, pIter, pIntervalReturn)
return (RecordSetIteratePtr)NULL; return (RecordSetIteratePtr)NULL;
} }
RecordSetOperations IntervalListSetOperations = { static RecordSetOperations IntervalListSetOperations = {
IntervalListDestroySet, IntervalListIsMemberOfSet, IntervalListIterateSet }; IntervalListDestroySet, IntervalListIsMemberOfSet, IntervalListIterateSet };
RecordSetOperations IntervalListNoFreeOperations = { static RecordSetOperations IntervalListNoFreeOperations = {
NoopDestroySet, IntervalListIsMemberOfSet, IntervalListIterateSet }; NoopDestroySet, IntervalListIsMemberOfSet, IntervalListIterateSet };
static int static int
IntervalListMemoryRequirements(pIntervals, nIntervals, maxMember, alignment) IntervalListMemoryRequirements(RecordSetInterval *pIntervals, int nIntervals,
RecordSetInterval *pIntervals; int maxMember, int *alignment)
int nIntervals;
int maxMember;
int *alignment;
{ {
*alignment = sizeof(unsigned long); *alignment = sizeof(unsigned long);
return sizeof(IntervalListSet) + nIntervals * sizeof(RecordSetInterval); return sizeof(IntervalListSet) + nIntervals * sizeof(RecordSetInterval);
} }
static RecordSetPtr static RecordSetPtr
IntervalListCreateSet(pIntervals, nIntervals, pMem, memsize) IntervalListCreateSet(RecordSetInterval *pIntervals, int nIntervals,
RecordSetInterval *pIntervals; void *pMem, int memsize)
int nIntervals;
void *pMem;
int memsize;
{ {
IntervalListSetPtr prls; IntervalListSetPtr prls;
int i, j, k; int i, j, k;
...@@ -417,20 +364,6 @@ bailout: ...@@ -417,20 +364,6 @@ bailout:
return (RecordSetPtr)prls; return (RecordSetPtr)prls;
} }
#ifdef TESTING
typedef enum {
BitVectorImplementation, IntervalListImplementation} RecordSetImplementation;
RecordSetImplementation _RecordSetImpl;
static void
_RecordForceSetImplementation(setimpl)
RecordSetImplementation setimpl;
{
_RecordSetImpl = setimpl;
}
#endif
typedef RecordSetPtr (*RecordCreateSetProcPtr)( typedef RecordSetPtr (*RecordCreateSetProcPtr)(
RecordSetInterval *pIntervals, RecordSetInterval *pIntervals,
int nIntervals, int nIntervals,
...@@ -439,11 +372,9 @@ typedef RecordSetPtr (*RecordCreateSetProcPtr)( ...@@ -439,11 +372,9 @@ typedef RecordSetPtr (*RecordCreateSetProcPtr)(
); );
static int static int
_RecordSetMemoryRequirements(pIntervals, nIntervals, alignment, ppCreateSet) _RecordSetMemoryRequirements(RecordSetInterval *pIntervals, int nIntervals,
RecordSetInterval *pIntervals; int *alignment,
int nIntervals; RecordCreateSetProcPtr *ppCreateSet)
int *alignment;
RecordCreateSetProcPtr *ppCreateSet;
{ {
int bmsize, rlsize, bma, rla; int bmsize, rlsize, bma, rla;
int maxMember; int maxMember;
...@@ -455,12 +386,8 @@ _RecordSetMemoryRequirements(pIntervals, nIntervals, alignment, ppCreateSet) ...@@ -455,12 +386,8 @@ _RecordSetMemoryRequirements(pIntervals, nIntervals, alignment, ppCreateSet)
&bma); &bma);
rlsize = IntervalListMemoryRequirements(pIntervals, nIntervals, maxMember, rlsize = IntervalListMemoryRequirements(pIntervals, nIntervals, maxMember,
&rla); &rla);
#ifdef TESTING
if (_RecordSetImpl == BitVectorImplementation)
#else
if ( ( (nIntervals > 1) && (maxMember <= 255) ) if ( ( (nIntervals > 1) && (maxMember <= 255) )
|| (bmsize < rlsize) ) || (bmsize < rlsize) )
#endif
{ {
*alignment = bma; *alignment = bma;
*ppCreateSet = BitVectorCreateSet; *ppCreateSet = BitVectorCreateSet;
...@@ -509,183 +436,3 @@ RecordCreateSet(pIntervals, nIntervals, pMem, memsize) ...@@ -509,183 +436,3 @@ RecordCreateSet(pIntervals, nIntervals, pMem, memsize)
} }
return (*pCreateSet)(pIntervals, nIntervals, pMem, size); return (*pCreateSet)(pIntervals, nIntervals, pMem, size);
} }
/***************************************************************************/
#ifdef TESTING
/*
Test Strategy
Having two set representations is convenient for testing because we
can play them against each other. The test code will be able to
specify which implementation to use. This breaks the encapsulation,
but that seems acceptable for testing. The crux of the test loop
looks like this:
loop:
generate random list of Intervals
create set A using bit vector implementation
create set B using Interval list implementation
for each possible set member
if set A and set B disagree on whether this is a member error;
iterate over both sets, comparing the intervals returned by each.
if intervals or number of intervals are different error;
iterate over intervals of set A
for i = interval.first to interval.last
if i is not a member of set B error;
iterate over intervals of set B
for i = interval.first to interval.last
if i is not a member of set A error;
destroy sets A, B
*/
int GenerateRandomIntervals(pIntervals, maxintervals)
RecordSetInterval *pIntervals;
int maxintervals;
{
int i, nIntervals;
nIntervals = rand() % maxintervals;
for (i = 0; i < nIntervals; i++)
{
pIntervals[i].first = rand();
pIntervals[i].last = pIntervals[i].first + rand();
}
return nIntervals;
}
#define MAXINTERVALS 100
int main(argc, argv)
int argc;
char **argv;
{
RecordSetPtr bs, rs;
RecordSetInterval br, rr;
RecordSetIteratePtr bi, ri;
CARD16 i;
int testcount;
RecordSetInterval intervals[MAXINTERVALS];
int nIntervals;
int bsize, rsize;
int balign, ralign;
int pad;
for (testcount = 0; 1; testcount++)
{
nIntervals = GenerateRandomIntervals(intervals, MAXINTERVALS);
printf("%d nIntervals %d\n", testcount, nIntervals);
if (testcount & 1)
{
_RecordForceSetImplementation(BitVectorImplementation);
bsize = RecordSetMemoryRequirements(intervals, nIntervals, &balign);
_RecordForceSetImplementation(IntervalListImplementation);
rsize = RecordSetMemoryRequirements(intervals, nIntervals, &ralign);
pad = (ralign - (bsize & (ralign - 1))) & (ralign - 1);
bs = (RecordSetPtr)malloc(bsize + pad + rsize );
if (!bs)
{
fprintf(stderr, "%d: failed to alloc memory for sets\n",
testcount);
continue;
}
rs = (RecordSetPtr)(((char *)bs) + bsize + pad);
}
else
{
bs = rs = NULL;
bsize = rsize = 0;
}
_RecordForceSetImplementation(BitVectorImplementation);
bs = RecordCreateSet(intervals, nIntervals, bs, bsize);
_RecordForceSetImplementation(IntervalListImplementation);
rs = RecordCreateSet(intervals, nIntervals, rs, rsize);
if (!bs || !rs)
{
fprintf(stderr, "%d: failed to create sets\n", testcount);
continue;
}
for (i = 0; i < 65535; i++)
{
unsigned long b, r;
b = RecordIsMemberOfSet(bs, i);
r = RecordIsMemberOfSet(rs, i);
if ( (b && !r) || (!b && r) )
{
fprintf(stderr, "%d: isMemberOfSet %d\n",
testcount, (int)i);
}
}
bi = RecordIterateSet(bs, NULL, &br);
ri = RecordIterateSet(rs, NULL, &rr);
while (bi && ri)
{
if ( (rr.first != br.first) || (rr.last != br.last) )
{
fprintf(stderr, "%d: iterateSet interval value mismatch\n",
testcount);
}
bi = RecordIterateSet(bs, bi, &br);
ri = RecordIterateSet(rs, ri, &rr);
}
if (bi != ri)
{
fprintf(stderr, "%d: iterateSet interval count mismatch\n",
testcount);
}
bi = NULL;
while (bi = RecordIterateSet(bs, bi, &br))
{
for (i = br.first; i <= br.last; i++)
{
if (!RecordIsMemberOfSet(rs, i))
{
fprintf(stderr, "%d: iterateSet b / isMemberOfSet r %d\n",
testcount, (int)i);
}
}
}
ri = NULL;
while (ri = RecordIterateSet(rs, ri, &rr))
{
for (i = rr.first; i <= rr.last; i++)
{
if (!RecordIsMemberOfSet(bs, i) )
{
fprintf(stderr, "%d: iterateSet r / isMemberOfSet b %d\n",
testcount, (int)i);
}
}
}
RecordDestroySet(bs);
RecordDestroySet(rs);
if (testcount & 1)
{
free(bs);
}
}
}
#endif /* TESTING */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment