[PATCH 0/4] devPrivates rework (v3): introduction/RFC

Eamon Walsh ewalsh at tycho.nsa.gov
Thu Mar 8 13:43:44 PST 2007

This is a rework of the devPrivates mechanism to use a common set of

This latest version drops the RC_PRIVATES class and is fully independent
of the resource system.  The type and parent parameters to the initial
registration function are dropped, as is the preallocation function; all
privates are allocated just-in-time in this version.

This version coexists with the existing DevUnion arrays.  The third patch
shows how the first DevUnion in the "old" array is reserved for the "new"
privates list.  This would allow a slow phase out of the old mechanism.

The fourth patch shows an example of converting the Composite code to
use the new mechanism.  There are savings from the fact that the initial
registration doesn't have to be done if extra memory isn't needed.  All
the "fooGeneration == serverGeneration" checks could be dispensed with.

Interface Overview

int dixRequestPrivate(devprivate_key_t *const key, unsigned size);
Requests that size bytes of private space be preallocated for
privates referenced by key.

pointer dixLookupPrivate(PrivateRec **privates, devprivate_key_t *const 
Returns a pointer to the private data associated with key.

int dixSetPrivate(PrivateRec **privates, devprivate_key_t *const key, 
pointer newvalue);
Sets a private pointer to the specified value.

int dixRegisterPrivateInitFunc(devprivate_key_t *const key, 
CallbackProcPtr callbackfunc, pointer userdata);
int dixRegisterPrivateDeleteFunc(devprivate_key_t *const key,
CallbackProcPtr callbackfunc, pointer userdata);
Registers callbacks that can be used to initialize the newly allocated
space (zeroed out by default), or cleanup just before the space gets
freed.  Users do not free the private pointer themselves!  The argument
to the callback is a structure that contains the key and private pointer.

Eamon Walsh <ewalsh at tycho.nsa.gov>
National Security Agency

More information about the xorg mailing list