Make devPrivates lookup functions ABI instead of static inlines.
This is required to preserve compatibility across changes to the internal representation of the privates list.
This commit is contained in:
parent
9e0e558f26
commit
2d7ba09dc4
|
@ -39,6 +39,12 @@ from The Open Group.
|
||||||
#include "colormapst.h"
|
#include "colormapst.h"
|
||||||
#include "inputstr.h"
|
#include "inputstr.h"
|
||||||
|
|
||||||
|
struct _Private {
|
||||||
|
DevPrivateKey key;
|
||||||
|
pointer value;
|
||||||
|
struct _Private *next;
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct _PrivateDesc {
|
typedef struct _PrivateDesc {
|
||||||
DevPrivateKey key;
|
DevPrivateKey key;
|
||||||
unsigned size;
|
unsigned size;
|
||||||
|
@ -116,6 +122,65 @@ dixAllocatePrivate(PrivateRec **privates, const DevPrivateKey key)
|
||||||
return &ptr->value;
|
return &ptr->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Look up a private pointer.
|
||||||
|
*/
|
||||||
|
_X_EXPORT pointer
|
||||||
|
dixLookupPrivate(PrivateRec **privates, const DevPrivateKey key)
|
||||||
|
{
|
||||||
|
PrivateRec *rec = *privates;
|
||||||
|
pointer *ptr;
|
||||||
|
|
||||||
|
while (rec) {
|
||||||
|
if (rec->key == key)
|
||||||
|
return rec->value;
|
||||||
|
rec = rec->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
ptr = dixAllocatePrivate(privates, key);
|
||||||
|
return ptr ? *ptr : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Look up the address of a private pointer.
|
||||||
|
*/
|
||||||
|
_X_EXPORT pointer *
|
||||||
|
dixLookupPrivateAddr(PrivateRec **privates, const DevPrivateKey key)
|
||||||
|
{
|
||||||
|
PrivateRec *rec = *privates;
|
||||||
|
|
||||||
|
while (rec) {
|
||||||
|
if (rec->key == key)
|
||||||
|
return &rec->value;
|
||||||
|
rec = rec->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
return dixAllocatePrivate(privates, key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set a private pointer.
|
||||||
|
*/
|
||||||
|
_X_EXPORT int
|
||||||
|
dixSetPrivate(PrivateRec **privates, const DevPrivateKey key, pointer val)
|
||||||
|
{
|
||||||
|
PrivateRec *rec;
|
||||||
|
|
||||||
|
top:
|
||||||
|
rec = *privates;
|
||||||
|
while (rec) {
|
||||||
|
if (rec->key == key) {
|
||||||
|
rec->value = val;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
rec = rec->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!dixAllocatePrivate(privates, key))
|
||||||
|
return FALSE;
|
||||||
|
goto top;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Called to free privates at object deletion time.
|
* Called to free privates at object deletion time.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -265,6 +265,9 @@ _X_HIDDEN void *dixLookupTab[] = {
|
||||||
SYMFUNC(dixRegisterPrivateInitFunc)
|
SYMFUNC(dixRegisterPrivateInitFunc)
|
||||||
SYMFUNC(dixRegisterPrivateDeleteFunc)
|
SYMFUNC(dixRegisterPrivateDeleteFunc)
|
||||||
SYMFUNC(dixAllocatePrivate)
|
SYMFUNC(dixAllocatePrivate)
|
||||||
|
SYMFUNC(dixLookupPrivate)
|
||||||
|
SYMFUNC(dixLookupPrivateAddr)
|
||||||
|
SYMFUNC(dixSetPrivate)
|
||||||
SYMFUNC(dixFreePrivates)
|
SYMFUNC(dixFreePrivates)
|
||||||
SYMFUNC(dixRegisterPrivateOffset)
|
SYMFUNC(dixRegisterPrivateOffset)
|
||||||
SYMFUNC(dixLookupPrivateOffset)
|
SYMFUNC(dixLookupPrivateOffset)
|
||||||
|
|
|
@ -20,12 +20,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*****************************************************************/
|
*****************************************************************/
|
||||||
|
|
||||||
typedef void *DevPrivateKey;
|
typedef void *DevPrivateKey;
|
||||||
|
struct _Private;
|
||||||
typedef struct _Private {
|
typedef struct _Private PrivateRec;
|
||||||
DevPrivateKey key;
|
|
||||||
pointer value;
|
|
||||||
struct _Private *next;
|
|
||||||
} PrivateRec;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Request pre-allocated private space for your driver/module.
|
* Request pre-allocated private space for your driver/module.
|
||||||
|
@ -43,61 +39,20 @@ dixAllocatePrivate(PrivateRec **privates, const DevPrivateKey key);
|
||||||
/*
|
/*
|
||||||
* Look up a private pointer.
|
* Look up a private pointer.
|
||||||
*/
|
*/
|
||||||
static _X_INLINE pointer
|
pointer
|
||||||
dixLookupPrivate(PrivateRec **privates, const DevPrivateKey key)
|
dixLookupPrivate(PrivateRec **privates, const DevPrivateKey key);
|
||||||
{
|
|
||||||
PrivateRec *rec = *privates;
|
|
||||||
pointer *ptr;
|
|
||||||
|
|
||||||
while (rec) {
|
|
||||||
if (rec->key == key)
|
|
||||||
return rec->value;
|
|
||||||
rec = rec->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
ptr = dixAllocatePrivate(privates, key);
|
|
||||||
return ptr ? *ptr : NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Look up the address of a private pointer.
|
* Look up the address of a private pointer.
|
||||||
*/
|
*/
|
||||||
static _X_INLINE pointer *
|
pointer *
|
||||||
dixLookupPrivateAddr(PrivateRec **privates, const DevPrivateKey key)
|
dixLookupPrivateAddr(PrivateRec **privates, const DevPrivateKey key);
|
||||||
{
|
|
||||||
PrivateRec *rec = *privates;
|
|
||||||
|
|
||||||
while (rec) {
|
|
||||||
if (rec->key == key)
|
|
||||||
return &rec->value;
|
|
||||||
rec = rec->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
return dixAllocatePrivate(privates, key);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set a private pointer.
|
* Set a private pointer.
|
||||||
*/
|
*/
|
||||||
static _X_INLINE int
|
int
|
||||||
dixSetPrivate(PrivateRec **privates, const DevPrivateKey key, pointer val)
|
dixSetPrivate(PrivateRec **privates, const DevPrivateKey key, pointer val);
|
||||||
{
|
|
||||||
PrivateRec *rec;
|
|
||||||
|
|
||||||
top:
|
|
||||||
rec = *privates;
|
|
||||||
while (rec) {
|
|
||||||
if (rec->key == key) {
|
|
||||||
rec->value = val;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
rec = rec->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!dixAllocatePrivate(privates, key))
|
|
||||||
return FALSE;
|
|
||||||
goto top;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Register callbacks to be called on private allocation/freeing.
|
* Register callbacks to be called on private allocation/freeing.
|
||||||
|
|
Loading…
Reference in New Issue