Added devPrivates support to the ExtensionEntry structure.
This commit is contained in:
parent
c0cb8d1fb8
commit
b04d648547
|
@ -78,6 +78,40 @@ int lastEvent = EXTENSION_EVENT_BASE;
|
||||||
static int lastError = FirstExtensionError;
|
static int lastError = FirstExtensionError;
|
||||||
static unsigned int NumExtensions = 0;
|
static unsigned int NumExtensions = 0;
|
||||||
|
|
||||||
|
extern int extensionPrivateLen;
|
||||||
|
extern unsigned *extensionPrivateSizes;
|
||||||
|
extern unsigned totalExtensionSize;
|
||||||
|
|
||||||
|
static int
|
||||||
|
InitExtensionPrivates(ExtensionEntry *ext)
|
||||||
|
{
|
||||||
|
register char *ptr;
|
||||||
|
DevUnion *ppriv;
|
||||||
|
register unsigned *sizes;
|
||||||
|
register unsigned size;
|
||||||
|
register int i;
|
||||||
|
|
||||||
|
if (totalExtensionSize == sizeof(ExtensionEntry))
|
||||||
|
ppriv = (DevUnion *)NULL;
|
||||||
|
else
|
||||||
|
ppriv = (DevUnion *)(ext + 1);
|
||||||
|
|
||||||
|
ext->devPrivates = ppriv;
|
||||||
|
sizes = extensionPrivateSizes;
|
||||||
|
ptr = (char *)(ppriv + extensionPrivateLen);
|
||||||
|
for (i = extensionPrivateLen; --i >= 0; ppriv++, sizes++)
|
||||||
|
{
|
||||||
|
if ( (size = *sizes) )
|
||||||
|
{
|
||||||
|
ppriv->ptr = (pointer)ptr;
|
||||||
|
ptr += size;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ppriv->ptr = (pointer)NULL;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
_X_EXPORT ExtensionEntry *
|
_X_EXPORT ExtensionEntry *
|
||||||
AddExtension(char *name, int NumEvents, int NumErrors,
|
AddExtension(char *name, int NumEvents, int NumErrors,
|
||||||
int (*MainProc)(ClientPtr c1),
|
int (*MainProc)(ClientPtr c1),
|
||||||
|
@ -94,8 +128,8 @@ AddExtension(char *name, int NumEvents, int NumErrors,
|
||||||
(unsigned)(lastError + NumErrors > LAST_ERROR))
|
(unsigned)(lastError + NumErrors > LAST_ERROR))
|
||||||
return((ExtensionEntry *) NULL);
|
return((ExtensionEntry *) NULL);
|
||||||
|
|
||||||
ext = (ExtensionEntry *) xalloc(sizeof(ExtensionEntry));
|
ext = (ExtensionEntry *) xalloc(totalExtensionSize);
|
||||||
if (!ext)
|
if (!ext || !InitExtensionPrivates(ext))
|
||||||
return((ExtensionEntry *) NULL);
|
return((ExtensionEntry *) NULL);
|
||||||
ext->name = (char *)xalloc(strlen(name) + 1);
|
ext->name = (char *)xalloc(strlen(name) + 1);
|
||||||
ext->num_aliases = 0;
|
ext->num_aliases = 0;
|
||||||
|
|
|
@ -357,6 +357,7 @@ main(int argc, char *argv[], char *envp[])
|
||||||
InitAtoms();
|
InitAtoms();
|
||||||
InitEvents();
|
InitEvents();
|
||||||
InitGlyphCaching();
|
InitGlyphCaching();
|
||||||
|
ResetExtensionPrivates();
|
||||||
ResetClientPrivates();
|
ResetClientPrivates();
|
||||||
ResetScreenPrivates();
|
ResetScreenPrivates();
|
||||||
ResetWindowPrivates();
|
ResetWindowPrivates();
|
||||||
|
|
|
@ -45,6 +45,7 @@ from The Open Group.
|
||||||
#include "servermd.h"
|
#include "servermd.h"
|
||||||
#include "site.h"
|
#include "site.h"
|
||||||
#include "inputstr.h"
|
#include "inputstr.h"
|
||||||
|
#include "extnsionst.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* See the Wrappers and devPrivates section in "Definition of the
|
* See the Wrappers and devPrivates section in "Definition of the
|
||||||
|
@ -52,6 +53,63 @@ from The Open Group.
|
||||||
* for information on how to use devPrivates.
|
* for information on how to use devPrivates.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* extension private machinery
|
||||||
|
*/
|
||||||
|
|
||||||
|
static int extensionPrivateCount;
|
||||||
|
int extensionPrivateLen;
|
||||||
|
unsigned *extensionPrivateSizes;
|
||||||
|
unsigned totalExtensionSize;
|
||||||
|
|
||||||
|
void
|
||||||
|
ResetExtensionPrivates()
|
||||||
|
{
|
||||||
|
extensionPrivateCount = 0;
|
||||||
|
extensionPrivateLen = 0;
|
||||||
|
xfree(extensionPrivateSizes);
|
||||||
|
extensionPrivateSizes = (unsigned *)NULL;
|
||||||
|
totalExtensionSize =
|
||||||
|
((sizeof(ExtensionEntry) + sizeof(long) - 1) / sizeof(long)) * sizeof(long);
|
||||||
|
}
|
||||||
|
|
||||||
|
_X_EXPORT int
|
||||||
|
AllocateExtensionPrivateIndex()
|
||||||
|
{
|
||||||
|
return extensionPrivateCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
_X_EXPORT Bool
|
||||||
|
AllocateExtensionPrivate(int index2, unsigned amount)
|
||||||
|
{
|
||||||
|
unsigned oldamount;
|
||||||
|
|
||||||
|
/* Round up sizes for proper alignment */
|
||||||
|
amount = ((amount + (sizeof(long) - 1)) / sizeof(long)) * sizeof(long);
|
||||||
|
|
||||||
|
if (index2 >= extensionPrivateLen)
|
||||||
|
{
|
||||||
|
unsigned *nsizes;
|
||||||
|
nsizes = (unsigned *)xrealloc(extensionPrivateSizes,
|
||||||
|
(index2 + 1) * sizeof(unsigned));
|
||||||
|
if (!nsizes)
|
||||||
|
return FALSE;
|
||||||
|
while (extensionPrivateLen <= index2)
|
||||||
|
{
|
||||||
|
nsizes[extensionPrivateLen++] = 0;
|
||||||
|
totalExtensionSize += sizeof(DevUnion);
|
||||||
|
}
|
||||||
|
extensionPrivateSizes = nsizes;
|
||||||
|
}
|
||||||
|
oldamount = extensionPrivateSizes[index2];
|
||||||
|
if (amount > oldamount)
|
||||||
|
{
|
||||||
|
extensionPrivateSizes[index2] = amount;
|
||||||
|
totalExtensionSize += (amount - oldamount);
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* client private machinery
|
* client private machinery
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -60,6 +60,8 @@ extern Bool EnableDisableExtension(char *name, Bool enable);
|
||||||
|
|
||||||
extern void EnableDisableExtensionError(char *name, Bool enable);
|
extern void EnableDisableExtensionError(char *name, Bool enable);
|
||||||
|
|
||||||
|
extern void ResetExtensionPrivates(void);
|
||||||
|
|
||||||
extern void InitExtensions(int argc, char **argv);
|
extern void InitExtensions(int argc, char **argv);
|
||||||
|
|
||||||
extern void InitVisualWrap(void);
|
extern void InitVisualWrap(void);
|
||||||
|
|
|
@ -50,6 +50,7 @@ SOFTWARE.
|
||||||
#ifndef EXTENSIONSTRUCT_H
|
#ifndef EXTENSIONSTRUCT_H
|
||||||
#define EXTENSIONSTRUCT_H
|
#define EXTENSIONSTRUCT_H
|
||||||
|
|
||||||
|
#include "dix.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "screenint.h"
|
#include "screenint.h"
|
||||||
#include "extension.h"
|
#include "extension.h"
|
||||||
|
@ -70,6 +71,7 @@ typedef struct _ExtensionEntry {
|
||||||
pointer extPrivate;
|
pointer extPrivate;
|
||||||
unsigned short (* MinorOpcode)( /* called for errors */
|
unsigned short (* MinorOpcode)( /* called for errors */
|
||||||
ClientPtr /* client */);
|
ClientPtr /* client */);
|
||||||
|
DevUnion *devPrivates;
|
||||||
#ifdef XACE
|
#ifdef XACE
|
||||||
pointer securityState[4]; /* 4 slots for use */
|
pointer securityState[4]; /* 4 slots for use */
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue