Merge branch 'master' of git+ssh://git.freedesktop.org/git/xorg/xserver into input-hotplug
This commit is contained in:
commit
a73cef1f00
|
@ -52,7 +52,6 @@ extern Bool xf86DoConfigurePass1;
|
||||||
extern int xf86ScreenIndex; /* Index into pScreen.devPrivates */
|
extern int xf86ScreenIndex; /* Index into pScreen.devPrivates */
|
||||||
extern int xf86CreateRootWindowIndex; /* Index into pScreen.devPrivates */
|
extern int xf86CreateRootWindowIndex; /* Index into pScreen.devPrivates */
|
||||||
extern int xf86PixmapIndex;
|
extern int xf86PixmapIndex;
|
||||||
extern Bool xf86ResAccessEnter;
|
|
||||||
extern ScrnInfoPtr *xf86Screens; /* List of pointers to ScrnInfoRecs */
|
extern ScrnInfoPtr *xf86Screens; /* List of pointers to ScrnInfoRecs */
|
||||||
extern const unsigned char byte_reversed[256];
|
extern const unsigned char byte_reversed[256];
|
||||||
extern ScrnInfoPtr xf86CurrentScreen;
|
extern ScrnInfoPtr xf86CurrentScreen;
|
||||||
|
@ -165,9 +164,6 @@ void xf86EnablePciBusMaster(pciVideoPtr pPci, Bool enable);
|
||||||
#endif
|
#endif
|
||||||
void xf86RegisterStateChangeNotificationCallback(xf86StateChangeNotificationCallbackFunc func, pointer arg);
|
void xf86RegisterStateChangeNotificationCallback(xf86StateChangeNotificationCallbackFunc func, pointer arg);
|
||||||
Bool xf86DeregisterStateChangeNotificationCallback(xf86StateChangeNotificationCallbackFunc func);
|
Bool xf86DeregisterStateChangeNotificationCallback(xf86StateChangeNotificationCallbackFunc func);
|
||||||
#ifdef async
|
|
||||||
Bool xf86QueueAsyncEvent(void (*func)(pointer),pointer arg);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int xf86GetLastScrnFlag(int entityIndex);
|
int xf86GetLastScrnFlag(int entityIndex);
|
||||||
void xf86SetLastScrnFlag(int entityIndex, int scrnIndex);
|
void xf86SetLastScrnFlag(int entityIndex, int scrnIndex);
|
||||||
|
|
|
@ -65,7 +65,7 @@ xf86CurrentAccessRec xf86CurrentAccess = {NULL,NULL};
|
||||||
|
|
||||||
BusRec primaryBus = { BUS_NONE, {{0}}};
|
BusRec primaryBus = { BUS_NONE, {{0}}};
|
||||||
|
|
||||||
Bool xf86ResAccessEnter = FALSE;
|
static Bool xf86ResAccessEnter = FALSE;
|
||||||
|
|
||||||
#ifdef REDUCER
|
#ifdef REDUCER
|
||||||
/* Resources that temporarily conflict with estimated resources */
|
/* Resources that temporarily conflict with estimated resources */
|
||||||
|
@ -664,32 +664,6 @@ xf86AccessRestoreState(void)
|
||||||
* Otherwise resources needed for access control might be shadowed
|
* Otherwise resources needed for access control might be shadowed
|
||||||
* by other resources!
|
* by other resources!
|
||||||
*/
|
*/
|
||||||
#ifdef async
|
|
||||||
|
|
||||||
static AsyncQPtr *AsyncQ = NULL;
|
|
||||||
_X_EXPORT ScrnInfoPtr xf86CurrentScreen = NULL;
|
|
||||||
|
|
||||||
#define SETUP_Q org = AsyncQ; \
|
|
||||||
AsyncQ = &new;
|
|
||||||
|
|
||||||
#define PROCESS_Q xf86CurrentScreen = pScrn;
|
|
||||||
if (!new) AsyncQ = org; \
|
|
||||||
else { \
|
|
||||||
AsyncQPtr tmp_Q; \
|
|
||||||
while (1) {\
|
|
||||||
new->func(new->arg);\
|
|
||||||
if (!(new->next)) {\
|
|
||||||
AsyncQ = org; xfree(new); break; \
|
|
||||||
} \
|
|
||||||
tmp_Q = new->next; \
|
|
||||||
xfree(new); \
|
|
||||||
new = tmp_Q; \
|
|
||||||
} \
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
#define SETUP_Q
|
|
||||||
#define PROCESS_Q
|
|
||||||
#endif
|
|
||||||
|
|
||||||
_X_EXPORT void
|
_X_EXPORT void
|
||||||
xf86EnableAccess(ScrnInfoPtr pScrn)
|
xf86EnableAccess(ScrnInfoPtr pScrn)
|
||||||
|
@ -698,9 +672,6 @@ xf86EnableAccess(ScrnInfoPtr pScrn)
|
||||||
register EntityAccessPtr pceAcc;
|
register EntityAccessPtr pceAcc;
|
||||||
register xf86AccessPtr pAcc;
|
register xf86AccessPtr pAcc;
|
||||||
EntityAccessPtr tmp;
|
EntityAccessPtr tmp;
|
||||||
#ifdef async
|
|
||||||
AsyncQPtr *org, new = NULL;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
ErrorF("Enable access %i\n",pScrn->scrnIndex);
|
ErrorF("Enable access %i\n",pScrn->scrnIndex);
|
||||||
|
@ -709,9 +680,7 @@ xf86EnableAccess(ScrnInfoPtr pScrn)
|
||||||
/* Entity is not under access control or currently enabled */
|
/* Entity is not under access control or currently enabled */
|
||||||
if (!pScrn->access) {
|
if (!pScrn->access) {
|
||||||
if (pScrn->busAccess) {
|
if (pScrn->busAccess) {
|
||||||
SETUP_Q;
|
|
||||||
((BusAccPtr)pScrn->busAccess)->set_f(pScrn->busAccess);
|
((BusAccPtr)pScrn->busAccess)->set_f(pScrn->busAccess);
|
||||||
PROCESS_Q;
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -722,7 +691,6 @@ xf86EnableAccess(ScrnInfoPtr pScrn)
|
||||||
if (peAcc == pceAcc) {
|
if (peAcc == pceAcc) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SETUP_Q;
|
|
||||||
if (pScrn->CurrentAccess->pMemAccess == pceAcc)
|
if (pScrn->CurrentAccess->pMemAccess == pceAcc)
|
||||||
pScrn->CurrentAccess->pMemAccess = NULL;
|
pScrn->CurrentAccess->pMemAccess = NULL;
|
||||||
while (pceAcc) {
|
while (pceAcc) {
|
||||||
|
@ -740,13 +708,11 @@ xf86EnableAccess(ScrnInfoPtr pScrn)
|
||||||
peAcc = peAcc->next;
|
peAcc = peAcc->next;
|
||||||
}
|
}
|
||||||
pScrn->CurrentAccess->pIoAccess = (EntityAccessPtr) pScrn->access;
|
pScrn->CurrentAccess->pIoAccess = (EntityAccessPtr) pScrn->access;
|
||||||
PROCESS_Q;
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case MEM_IO:
|
case MEM_IO:
|
||||||
pceAcc = pScrn->CurrentAccess->pIoAccess;
|
pceAcc = pScrn->CurrentAccess->pIoAccess;
|
||||||
if (peAcc != pceAcc) { /* current Io != pAccess */
|
if (peAcc != pceAcc) { /* current Io != pAccess */
|
||||||
SETUP_Q;
|
|
||||||
tmp = pceAcc;
|
tmp = pceAcc;
|
||||||
while (pceAcc) {
|
while (pceAcc) {
|
||||||
pAcc = pceAcc->pAccess;
|
pAcc = pceAcc->pAccess;
|
||||||
|
@ -769,7 +735,6 @@ xf86EnableAccess(ScrnInfoPtr pScrn)
|
||||||
if (pceAcc == peAcc) { /* current Mem == pAccess */
|
if (pceAcc == peAcc) { /* current Mem == pAccess */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SETUP_Q;
|
|
||||||
while (pceAcc) { /* current Mem != pAccess */
|
while (pceAcc) { /* current Mem != pAccess */
|
||||||
pAcc = pceAcc->pAccess;
|
pAcc = pceAcc->pAccess;
|
||||||
if (pAcc && pAcc->AccessDisable)
|
if (pAcc && pAcc->AccessDisable)
|
||||||
|
@ -787,7 +752,6 @@ xf86EnableAccess(ScrnInfoPtr pScrn)
|
||||||
}
|
}
|
||||||
pScrn->CurrentAccess->pMemAccess =
|
pScrn->CurrentAccess->pMemAccess =
|
||||||
pScrn->CurrentAccess->pIoAccess = (EntityAccessPtr) pScrn->access;
|
pScrn->CurrentAccess->pIoAccess = (EntityAccessPtr) pScrn->access;
|
||||||
PROCESS_Q;
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case MEM:
|
case MEM:
|
||||||
|
@ -795,7 +759,6 @@ xf86EnableAccess(ScrnInfoPtr pScrn)
|
||||||
if (peAcc == pceAcc) {
|
if (peAcc == pceAcc) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SETUP_Q;
|
|
||||||
if (pScrn->CurrentAccess->pIoAccess == pceAcc)
|
if (pScrn->CurrentAccess->pIoAccess == pceAcc)
|
||||||
pScrn->CurrentAccess->pIoAccess = NULL;
|
pScrn->CurrentAccess->pIoAccess = NULL;
|
||||||
while (pceAcc) {
|
while (pceAcc) {
|
||||||
|
@ -813,14 +776,11 @@ xf86EnableAccess(ScrnInfoPtr pScrn)
|
||||||
peAcc = peAcc->next;
|
peAcc = peAcc->next;
|
||||||
}
|
}
|
||||||
pScrn->CurrentAccess->pMemAccess = (EntityAccessPtr) pScrn->access;
|
pScrn->CurrentAccess->pMemAccess = (EntityAccessPtr) pScrn->access;
|
||||||
PROCESS_Q;
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case NONE:
|
case NONE:
|
||||||
if (pScrn->busAccess) {
|
if (pScrn->busAccess) {
|
||||||
SETUP_Q;
|
|
||||||
((BusAccPtr)pScrn->busAccess)->set_f(pScrn->busAccess);
|
((BusAccPtr)pScrn->busAccess)->set_f(pScrn->busAccess);
|
||||||
PROCESS_Q;
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -3160,23 +3120,6 @@ notifyStateChange(xf86NotifyState state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef async
|
|
||||||
_X_EXPORT Bool
|
|
||||||
xf86QueueAsyncEvent(void (*func)(pointer),pointer arg)
|
|
||||||
{
|
|
||||||
AsyncQPtr new;
|
|
||||||
|
|
||||||
if (!AsyncQ) return FALSE;
|
|
||||||
|
|
||||||
new = (AsyncQPtr)xfnalloc(sizeof(AsyncQRec));
|
|
||||||
new->func = func;
|
|
||||||
new->arg = arg;
|
|
||||||
(*AsyncQPtr)->next = new;
|
|
||||||
AsyncQPtr = &new;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Multihead accel sharing accessor functions and entity Private handling */
|
/* Multihead accel sharing accessor functions and entity Private handling */
|
||||||
|
|
||||||
_X_EXPORT int
|
_X_EXPORT int
|
||||||
|
|
|
@ -74,15 +74,6 @@ typedef struct {
|
||||||
IOADDRESS domainIO;
|
IOADDRESS domainIO;
|
||||||
} EntityRec, *EntityPtr;
|
} EntityRec, *EntityPtr;
|
||||||
|
|
||||||
/* asynchronous event handling */
|
|
||||||
#ifdef async
|
|
||||||
typedef struct _AsyncQRec {
|
|
||||||
void (*func)(pointer);
|
|
||||||
pointer arg;
|
|
||||||
struct _AsyncQRec *next;
|
|
||||||
} AsyncQRec, *AsyncQPtr;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define NO_SEPARATE_IO_FROM_MEM 0x0001
|
#define NO_SEPARATE_IO_FROM_MEM 0x0001
|
||||||
#define NO_SEPARATE_MEM_FROM_IO 0x0002
|
#define NO_SEPARATE_MEM_FROM_IO 0x0002
|
||||||
#define NEED_VGA_ROUTED 0x0004
|
#define NEED_VGA_ROUTED 0x0004
|
||||||
|
|
|
@ -129,7 +129,7 @@ DLFindSymbol(const char *name)
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
void *
|
||||||
DLLoadModule(loaderPtr modrec, int fd, int flags)
|
DLLoadModule(loaderPtr modrec, int flags)
|
||||||
{
|
{
|
||||||
DLModulePtr dlfile;
|
DLModulePtr dlfile;
|
||||||
DLModuleList *l;
|
DLModuleList *l;
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
#ifndef _DLLOADER_H
|
#ifndef _DLLOADER_H
|
||||||
#define _DLLOADER_H
|
#define _DLLOADER_H
|
||||||
|
|
||||||
extern void *DLLoadModule(loaderPtr, int, int flags);
|
extern void *DLLoadModule(loaderPtr, int flags);
|
||||||
extern void DLUnloadModule(void *);
|
extern void DLUnloadModule(void *);
|
||||||
extern void *DLFindSymbol(const char *name);
|
extern void *DLFindSymbol(const char *name);
|
||||||
|
|
||||||
|
|
|
@ -313,7 +313,6 @@ LoaderOpen(const char *module, const char *cname, int handle,
|
||||||
{
|
{
|
||||||
loaderPtr tmp;
|
loaderPtr tmp;
|
||||||
int new_handle;
|
int new_handle;
|
||||||
int fd;
|
|
||||||
|
|
||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
ErrorF("LoaderOpen(%s)\n", module);
|
ErrorF("LoaderOpen(%s)\n", module);
|
||||||
|
@ -369,16 +368,6 @@ LoaderOpen(const char *module, const char *cname, int handle,
|
||||||
freeHandles[new_handle] = HANDLE_USED;
|
freeHandles[new_handle] = HANDLE_USED;
|
||||||
refCount[new_handle] = 1;
|
refCount[new_handle] = 1;
|
||||||
|
|
||||||
if ((fd = open(module, O_RDONLY)) < 0) {
|
|
||||||
xf86Msg(X_ERROR, "Unable to open %s\n", module);
|
|
||||||
freeHandles[new_handle] = HANDLE_FREE;
|
|
||||||
if (errmaj)
|
|
||||||
*errmaj = LDR_NOMODOPEN;
|
|
||||||
if (errmin)
|
|
||||||
*errmin = errno;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
tmp = _LoaderListPush();
|
tmp = _LoaderListPush();
|
||||||
tmp->name = malloc(strlen(module) + 1);
|
tmp->name = malloc(strlen(module) + 1);
|
||||||
strcpy(tmp->name, module);
|
strcpy(tmp->name, module);
|
||||||
|
@ -387,7 +376,7 @@ LoaderOpen(const char *module, const char *cname, int handle,
|
||||||
tmp->handle = new_handle;
|
tmp->handle = new_handle;
|
||||||
tmp->module = moduleseq++;
|
tmp->module = moduleseq++;
|
||||||
|
|
||||||
if ((tmp->private = DLLoadModule(tmp, fd, flags)) == NULL) {
|
if ((tmp->private = DLLoadModule(tmp, flags)) == NULL) {
|
||||||
xf86Msg(X_ERROR, "Failed to load %s\n", module);
|
xf86Msg(X_ERROR, "Failed to load %s\n", module);
|
||||||
_LoaderListPop(new_handle);
|
_LoaderListPop(new_handle);
|
||||||
freeHandles[new_handle] = HANDLE_FREE;
|
freeHandles[new_handle] = HANDLE_FREE;
|
||||||
|
@ -398,8 +387,6 @@ LoaderOpen(const char *module, const char *cname, int handle,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
close(fd);
|
|
||||||
|
|
||||||
return new_handle;
|
return new_handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -115,6 +115,17 @@ FreeStringList(char **paths)
|
||||||
|
|
||||||
static char **defaultPathList = NULL;
|
static char **defaultPathList = NULL;
|
||||||
|
|
||||||
|
static Bool
|
||||||
|
PathIsAbsolute(const char *path)
|
||||||
|
{
|
||||||
|
#ifdef __UNIXOS2__
|
||||||
|
return (*path == '/' || (strlen(path) > 2 && isalpha(elem[0]) &&
|
||||||
|
elem[1] == ':' && elem[2] == '/'));
|
||||||
|
#else
|
||||||
|
return (*path == '/');
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Convert a comma-separated path into a NULL-terminated array of path
|
* Convert a comma-separated path into a NULL-terminated array of path
|
||||||
* elements, rejecting any that are not full absolute paths, and appending
|
* elements, rejecting any that are not full absolute paths, and appending
|
||||||
|
@ -138,13 +149,7 @@ InitPathList(const char *path)
|
||||||
return NULL;
|
return NULL;
|
||||||
elem = strtok(fullpath, ",");
|
elem = strtok(fullpath, ",");
|
||||||
while (elem) {
|
while (elem) {
|
||||||
/* Only allow fully specified paths */
|
if (PathIsAbsolute(elem))
|
||||||
#ifndef __UNIXOS2__
|
|
||||||
if (*elem == '/')
|
|
||||||
#else
|
|
||||||
if (*elem == '/' || (strlen(elem) > 2 && isalpha(elem[0]) &&
|
|
||||||
elem[1] == ':' && elem[2] == '/'))
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
len = strlen(elem);
|
len = strlen(elem);
|
||||||
addslash = (elem[len - 1] != '/');
|
addslash = (elem[len - 1] != '/');
|
||||||
|
@ -750,13 +755,7 @@ LoadSubModule(ModuleDescPtr parent, const char *module,
|
||||||
|
|
||||||
xf86MsgVerb(X_INFO, 3, "Loading sub module \"%s\"\n", module);
|
xf86MsgVerb(X_INFO, 3, "Loading sub module \"%s\"\n", module);
|
||||||
|
|
||||||
/* Absolute module paths are not allowed here */
|
if (PathIsAbsolute(module)) {
|
||||||
#ifndef __UNIXOS2__
|
|
||||||
if (module[0] == '/')
|
|
||||||
#else
|
|
||||||
if (isalpha(module[0]) && module[1] == ':' && module[2] == '/')
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
xf86Msg(X_ERROR,
|
xf86Msg(X_ERROR,
|
||||||
"LoadSubModule: Absolute module path not permitted: \"%s\"\n",
|
"LoadSubModule: Absolute module path not permitted: \"%s\"\n",
|
||||||
module);
|
module);
|
||||||
|
@ -786,12 +785,7 @@ LoadSubModuleLocal(ModuleDescPtr parent, const char *module,
|
||||||
|
|
||||||
xf86MsgVerb(X_INFO, 3, "Loading local sub module \"%s\"\n", module);
|
xf86MsgVerb(X_INFO, 3, "Loading local sub module \"%s\"\n", module);
|
||||||
|
|
||||||
/* Absolute module paths are not allowed here */
|
if (PathIsAbsolute(module))
|
||||||
#ifndef __UNIXOS2__
|
|
||||||
if (module[0] == '/')
|
|
||||||
#else
|
|
||||||
if (isalpha(module[0]) && module[1] == ':' && module[2] == '/')
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
xf86Msg(X_ERROR,
|
xf86Msg(X_ERROR,
|
||||||
"LoadSubModule: Absolute module path not permitted: \"%s\"\n",
|
"LoadSubModule: Absolute module path not permitted: \"%s\"\n",
|
||||||
|
@ -908,14 +902,8 @@ doLoadModule(const char *module, const char *path, const char **subdirlist,
|
||||||
* if the module name is not a full pathname, we need to
|
* if the module name is not a full pathname, we need to
|
||||||
* check the elements in the path
|
* check the elements in the path
|
||||||
*/
|
*/
|
||||||
#ifndef __UNIXOS2__
|
if (PathIsAbsolute(module))
|
||||||
if (module[0] == '/')
|
xstrdup(module);
|
||||||
found = xstrdup(module);
|
|
||||||
#else
|
|
||||||
/* accept a drive name here */
|
|
||||||
if (isalpha(module[0]) && module[1] == ':' && module[2] == '/')
|
|
||||||
found = xstrdup(module);
|
|
||||||
#endif
|
|
||||||
path_elem = pathlist;
|
path_elem = pathlist;
|
||||||
while (!found && *path_elem != NULL) {
|
while (!found && *path_elem != NULL) {
|
||||||
found = FindModule(m, *path_elem, subdirlist, patterns);
|
found = FindModule(m, *path_elem, subdirlist, patterns);
|
||||||
|
|
|
@ -354,9 +354,6 @@ _X_HIDDEN void *xfree86LookupTab[] = {
|
||||||
SYMFUNC(xf86RegisterStateChangeNotificationCallback)
|
SYMFUNC(xf86RegisterStateChangeNotificationCallback)
|
||||||
SYMFUNC(xf86DeregisterStateChangeNotificationCallback)
|
SYMFUNC(xf86DeregisterStateChangeNotificationCallback)
|
||||||
SYMFUNC(xf86NoSharedResources)
|
SYMFUNC(xf86NoSharedResources)
|
||||||
#ifdef async
|
|
||||||
SYMFUNC(xf86QueueAsyncEvent)
|
|
||||||
#endif
|
|
||||||
/* Shared Accel Accessor Functions */
|
/* Shared Accel Accessor Functions */
|
||||||
SYMFUNC(xf86GetLastScrnFlag)
|
SYMFUNC(xf86GetLastScrnFlag)
|
||||||
SYMFUNC(xf86SetLastScrnFlag)
|
SYMFUNC(xf86SetLastScrnFlag)
|
||||||
|
@ -1139,9 +1136,6 @@ _X_HIDDEN void *xfree86LookupTab[] = {
|
||||||
SYMVAR(xf86DummyVar3)
|
SYMVAR(xf86DummyVar3)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef async
|
|
||||||
SYMVAR(xf86CurrentScreen)
|
|
||||||
#endif
|
|
||||||
/* predefined resource lists from xf86Bus.h */
|
/* predefined resource lists from xf86Bus.h */
|
||||||
SYMVAR(resVgaExclusive)
|
SYMVAR(resVgaExclusive)
|
||||||
SYMVAR(resVgaShared)
|
SYMVAR(resVgaShared)
|
||||||
|
|
236
record/set.c
236
record/set.c
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
Copyright 1995, 1998 The Open Group
|
Copyright 1995, 1998 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,41 +51,7 @@ 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;
|
|
||||||
|
|
||||||
#define xalloc malloc
|
|
||||||
#define xfree free
|
|
||||||
#define ALLOCATE_LOCAL malloc
|
|
||||||
#define DEALLOCATE_LOCAL free
|
|
||||||
|
|
||||||
void *Xcalloc(size)
|
|
||||||
int size;
|
|
||||||
{
|
|
||||||
void *p = malloc(size);
|
|
||||||
if (p) memset(p, 0, size);
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef max
|
|
||||||
#define max(_a, _b) ( ((_a) > (_b)) ? (_a) : (_b) )
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* TESTING */
|
|
||||||
|
|
||||||
#include "set.h"
|
#include "set.h"
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -402,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,
|
||||||
|
@ -438,12 +386,8 @@ _RecordSetMemoryRequirements(RecordSetInterval *pIntervals, int nIntervals,
|
||||||
&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;
|
||||||
|
@ -492,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)xalloc(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)
|
|
||||||
{
|
|
||||||
xfree(bs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* TESTING */
|
|
||||||
|
|
Loading…
Reference in New Issue