xref: /OK3568_Linux_fs/external/xserver/include/privates.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /***********************************************************
2*4882a593Smuzhiyun 
3*4882a593Smuzhiyun THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
4*4882a593Smuzhiyun IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
5*4882a593Smuzhiyun FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
6*4882a593Smuzhiyun AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
7*4882a593Smuzhiyun AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
8*4882a593Smuzhiyun CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9*4882a593Smuzhiyun 
10*4882a593Smuzhiyun ******************************************************************/
11*4882a593Smuzhiyun 
12*4882a593Smuzhiyun #ifndef PRIVATES_H
13*4882a593Smuzhiyun #define PRIVATES_H 1
14*4882a593Smuzhiyun 
15*4882a593Smuzhiyun #include <X11/Xdefs.h>
16*4882a593Smuzhiyun #include <X11/Xosdefs.h>
17*4882a593Smuzhiyun #include <X11/Xfuncproto.h>
18*4882a593Smuzhiyun #include "misc.h"
19*4882a593Smuzhiyun 
20*4882a593Smuzhiyun /*****************************************************************
21*4882a593Smuzhiyun  * STUFF FOR PRIVATES
22*4882a593Smuzhiyun  *****************************************************************/
23*4882a593Smuzhiyun 
24*4882a593Smuzhiyun typedef struct _Private PrivateRec, *PrivatePtr;
25*4882a593Smuzhiyun 
26*4882a593Smuzhiyun typedef enum {
27*4882a593Smuzhiyun     /* XSELinux uses the same private keys for numerous objects */
28*4882a593Smuzhiyun     PRIVATE_XSELINUX,
29*4882a593Smuzhiyun 
30*4882a593Smuzhiyun     /* Otherwise, you get a private in just the requested structure
31*4882a593Smuzhiyun      */
32*4882a593Smuzhiyun     /* These can have objects created before all of the keys are registered */
33*4882a593Smuzhiyun     PRIVATE_SCREEN,
34*4882a593Smuzhiyun     PRIVATE_EXTENSION,
35*4882a593Smuzhiyun     PRIVATE_COLORMAP,
36*4882a593Smuzhiyun     PRIVATE_DEVICE,
37*4882a593Smuzhiyun 
38*4882a593Smuzhiyun     /* These cannot have any objects before all relevant keys are registered */
39*4882a593Smuzhiyun     PRIVATE_CLIENT,
40*4882a593Smuzhiyun     PRIVATE_PROPERTY,
41*4882a593Smuzhiyun     PRIVATE_SELECTION,
42*4882a593Smuzhiyun     PRIVATE_WINDOW,
43*4882a593Smuzhiyun     PRIVATE_PIXMAP,
44*4882a593Smuzhiyun     PRIVATE_GC,
45*4882a593Smuzhiyun     PRIVATE_CURSOR,
46*4882a593Smuzhiyun     PRIVATE_CURSOR_BITS,
47*4882a593Smuzhiyun 
48*4882a593Smuzhiyun     /* extension privates */
49*4882a593Smuzhiyun     PRIVATE_GLYPH,
50*4882a593Smuzhiyun     PRIVATE_GLYPHSET,
51*4882a593Smuzhiyun     PRIVATE_PICTURE,
52*4882a593Smuzhiyun     PRIVATE_SYNC_FENCE,
53*4882a593Smuzhiyun 
54*4882a593Smuzhiyun     /* last private type */
55*4882a593Smuzhiyun     PRIVATE_LAST,
56*4882a593Smuzhiyun } DevPrivateType;
57*4882a593Smuzhiyun 
58*4882a593Smuzhiyun typedef struct _DevPrivateKeyRec {
59*4882a593Smuzhiyun     int offset;
60*4882a593Smuzhiyun     int size;
61*4882a593Smuzhiyun     Bool initialized;
62*4882a593Smuzhiyun     Bool allocated;
63*4882a593Smuzhiyun     DevPrivateType type;
64*4882a593Smuzhiyun     struct _DevPrivateKeyRec *next;
65*4882a593Smuzhiyun } DevPrivateKeyRec, *DevPrivateKey;
66*4882a593Smuzhiyun 
67*4882a593Smuzhiyun typedef struct _DevPrivateSetRec {
68*4882a593Smuzhiyun     DevPrivateKey key;
69*4882a593Smuzhiyun     unsigned offset;
70*4882a593Smuzhiyun     int created;
71*4882a593Smuzhiyun     int allocated;
72*4882a593Smuzhiyun } DevPrivateSetRec, *DevPrivateSetPtr;
73*4882a593Smuzhiyun 
74*4882a593Smuzhiyun typedef struct _DevScreenPrivateKeyRec {
75*4882a593Smuzhiyun     DevPrivateKeyRec screenKey;
76*4882a593Smuzhiyun } DevScreenPrivateKeyRec, *DevScreenPrivateKey;
77*4882a593Smuzhiyun 
78*4882a593Smuzhiyun /*
79*4882a593Smuzhiyun  * Let drivers know how to initialize private keys
80*4882a593Smuzhiyun  */
81*4882a593Smuzhiyun 
82*4882a593Smuzhiyun #define HAS_DEVPRIVATEKEYREC		1
83*4882a593Smuzhiyun #define HAS_DIXREGISTERPRIVATEKEY	1
84*4882a593Smuzhiyun 
85*4882a593Smuzhiyun /*
86*4882a593Smuzhiyun  * Register a new private index for the private type.
87*4882a593Smuzhiyun  *
88*4882a593Smuzhiyun  * This initializes the specified key and optionally requests pre-allocated
89*4882a593Smuzhiyun  * private space for your driver/module. If you request no extra space, you
90*4882a593Smuzhiyun  * may set and get a single pointer value using this private key. Otherwise,
91*4882a593Smuzhiyun  * you can get the address of the extra space and store whatever data you like
92*4882a593Smuzhiyun  * there.
93*4882a593Smuzhiyun  *
94*4882a593Smuzhiyun  * You may call dixRegisterPrivateKey more than once on the same key, but the
95*4882a593Smuzhiyun  * size and type must match or the server will abort.
96*4882a593Smuzhiyun  *
97*4882a593Smuzhiyun  * dixRegisterPrivateKey returns FALSE if it fails to allocate memory
98*4882a593Smuzhiyun  * during its operation.
99*4882a593Smuzhiyun  */
100*4882a593Smuzhiyun extern _X_EXPORT Bool
101*4882a593Smuzhiyun  dixRegisterPrivateKey(DevPrivateKey key, DevPrivateType type, unsigned size);
102*4882a593Smuzhiyun 
103*4882a593Smuzhiyun /*
104*4882a593Smuzhiyun  * Check whether a private key has been registered
105*4882a593Smuzhiyun  */
106*4882a593Smuzhiyun static inline Bool
dixPrivateKeyRegistered(DevPrivateKey key)107*4882a593Smuzhiyun dixPrivateKeyRegistered(DevPrivateKey key)
108*4882a593Smuzhiyun {
109*4882a593Smuzhiyun     return key->initialized;
110*4882a593Smuzhiyun }
111*4882a593Smuzhiyun 
112*4882a593Smuzhiyun /*
113*4882a593Smuzhiyun  * Get the address of the private storage.
114*4882a593Smuzhiyun  *
115*4882a593Smuzhiyun  * For keys with pre-defined storage, this gets the base of that storage
116*4882a593Smuzhiyun  * Otherwise, it returns the place where the private pointer is stored.
117*4882a593Smuzhiyun  */
118*4882a593Smuzhiyun static inline void *
dixGetPrivateAddr(PrivatePtr * privates,const DevPrivateKey key)119*4882a593Smuzhiyun dixGetPrivateAddr(PrivatePtr *privates, const DevPrivateKey key)
120*4882a593Smuzhiyun {
121*4882a593Smuzhiyun     assert(key->initialized);
122*4882a593Smuzhiyun     return (char *) (*privates) + key->offset;
123*4882a593Smuzhiyun }
124*4882a593Smuzhiyun 
125*4882a593Smuzhiyun /*
126*4882a593Smuzhiyun  * Fetch a private pointer stored in the object
127*4882a593Smuzhiyun  *
128*4882a593Smuzhiyun  * Returns the pointer stored with dixSetPrivate.
129*4882a593Smuzhiyun  * This must only be used with keys that have
130*4882a593Smuzhiyun  * no pre-defined storage
131*4882a593Smuzhiyun  */
132*4882a593Smuzhiyun static inline void *
dixGetPrivate(PrivatePtr * privates,const DevPrivateKey key)133*4882a593Smuzhiyun dixGetPrivate(PrivatePtr *privates, const DevPrivateKey key)
134*4882a593Smuzhiyun {
135*4882a593Smuzhiyun     assert(key->size == 0);
136*4882a593Smuzhiyun     return *(void **) dixGetPrivateAddr(privates, key);
137*4882a593Smuzhiyun }
138*4882a593Smuzhiyun 
139*4882a593Smuzhiyun /*
140*4882a593Smuzhiyun  * Associate 'val' with 'key' in 'privates' so that later calls to
141*4882a593Smuzhiyun  * dixLookupPrivate(privates, key) will return 'val'.
142*4882a593Smuzhiyun  */
143*4882a593Smuzhiyun static inline void
dixSetPrivate(PrivatePtr * privates,const DevPrivateKey key,void * val)144*4882a593Smuzhiyun dixSetPrivate(PrivatePtr *privates, const DevPrivateKey key, void *val)
145*4882a593Smuzhiyun {
146*4882a593Smuzhiyun     assert(key->size == 0);
147*4882a593Smuzhiyun     *(void **) dixGetPrivateAddr(privates, key) = val;
148*4882a593Smuzhiyun }
149*4882a593Smuzhiyun 
150*4882a593Smuzhiyun #include "dix.h"
151*4882a593Smuzhiyun #include "resource.h"
152*4882a593Smuzhiyun 
153*4882a593Smuzhiyun /*
154*4882a593Smuzhiyun  * Lookup a pointer to the private record.
155*4882a593Smuzhiyun  *
156*4882a593Smuzhiyun  * For privates with defined storage, return the address of the
157*4882a593Smuzhiyun  * storage. For privates without defined storage, return the pointer
158*4882a593Smuzhiyun  * contents
159*4882a593Smuzhiyun  */
160*4882a593Smuzhiyun static inline void *
dixLookupPrivate(PrivatePtr * privates,const DevPrivateKey key)161*4882a593Smuzhiyun dixLookupPrivate(PrivatePtr *privates, const DevPrivateKey key)
162*4882a593Smuzhiyun {
163*4882a593Smuzhiyun     if (key->size)
164*4882a593Smuzhiyun         return dixGetPrivateAddr(privates, key);
165*4882a593Smuzhiyun     else
166*4882a593Smuzhiyun         return dixGetPrivate(privates, key);
167*4882a593Smuzhiyun }
168*4882a593Smuzhiyun 
169*4882a593Smuzhiyun /*
170*4882a593Smuzhiyun  * Look up the address of the pointer to the storage
171*4882a593Smuzhiyun  *
172*4882a593Smuzhiyun  * This returns the place where the private pointer is stored,
173*4882a593Smuzhiyun  * which is only valid for privates without predefined storage.
174*4882a593Smuzhiyun  */
175*4882a593Smuzhiyun static inline void **
dixLookupPrivateAddr(PrivatePtr * privates,const DevPrivateKey key)176*4882a593Smuzhiyun dixLookupPrivateAddr(PrivatePtr *privates, const DevPrivateKey key)
177*4882a593Smuzhiyun {
178*4882a593Smuzhiyun     assert(key->size == 0);
179*4882a593Smuzhiyun     return (void **) dixGetPrivateAddr(privates, key);
180*4882a593Smuzhiyun }
181*4882a593Smuzhiyun 
182*4882a593Smuzhiyun extern _X_EXPORT Bool
183*4882a593Smuzhiyun 
184*4882a593Smuzhiyun dixRegisterScreenPrivateKey(DevScreenPrivateKey key, ScreenPtr pScreen,
185*4882a593Smuzhiyun                             DevPrivateType type, unsigned size);
186*4882a593Smuzhiyun 
187*4882a593Smuzhiyun extern _X_EXPORT DevPrivateKey
188*4882a593Smuzhiyun  _dixGetScreenPrivateKey(const DevScreenPrivateKey key, ScreenPtr pScreen);
189*4882a593Smuzhiyun 
190*4882a593Smuzhiyun static inline void *
dixGetScreenPrivateAddr(PrivatePtr * privates,const DevScreenPrivateKey key,ScreenPtr pScreen)191*4882a593Smuzhiyun dixGetScreenPrivateAddr(PrivatePtr *privates, const DevScreenPrivateKey key,
192*4882a593Smuzhiyun                         ScreenPtr pScreen)
193*4882a593Smuzhiyun {
194*4882a593Smuzhiyun     return dixGetPrivateAddr(privates, _dixGetScreenPrivateKey(key, pScreen));
195*4882a593Smuzhiyun }
196*4882a593Smuzhiyun 
197*4882a593Smuzhiyun static inline void *
dixGetScreenPrivate(PrivatePtr * privates,const DevScreenPrivateKey key,ScreenPtr pScreen)198*4882a593Smuzhiyun dixGetScreenPrivate(PrivatePtr *privates, const DevScreenPrivateKey key,
199*4882a593Smuzhiyun                     ScreenPtr pScreen)
200*4882a593Smuzhiyun {
201*4882a593Smuzhiyun     return dixGetPrivate(privates, _dixGetScreenPrivateKey(key, pScreen));
202*4882a593Smuzhiyun }
203*4882a593Smuzhiyun 
204*4882a593Smuzhiyun static inline void
dixSetScreenPrivate(PrivatePtr * privates,const DevScreenPrivateKey key,ScreenPtr pScreen,void * val)205*4882a593Smuzhiyun dixSetScreenPrivate(PrivatePtr *privates, const DevScreenPrivateKey key,
206*4882a593Smuzhiyun                     ScreenPtr pScreen, void *val)
207*4882a593Smuzhiyun {
208*4882a593Smuzhiyun     dixSetPrivate(privates, _dixGetScreenPrivateKey(key, pScreen), val);
209*4882a593Smuzhiyun }
210*4882a593Smuzhiyun 
211*4882a593Smuzhiyun static inline void *
dixLookupScreenPrivate(PrivatePtr * privates,const DevScreenPrivateKey key,ScreenPtr pScreen)212*4882a593Smuzhiyun dixLookupScreenPrivate(PrivatePtr *privates, const DevScreenPrivateKey key,
213*4882a593Smuzhiyun                        ScreenPtr pScreen)
214*4882a593Smuzhiyun {
215*4882a593Smuzhiyun     return dixLookupPrivate(privates, _dixGetScreenPrivateKey(key, pScreen));
216*4882a593Smuzhiyun }
217*4882a593Smuzhiyun 
218*4882a593Smuzhiyun static inline void **
dixLookupScreenPrivateAddr(PrivatePtr * privates,const DevScreenPrivateKey key,ScreenPtr pScreen)219*4882a593Smuzhiyun dixLookupScreenPrivateAddr(PrivatePtr *privates, const DevScreenPrivateKey key,
220*4882a593Smuzhiyun                            ScreenPtr pScreen)
221*4882a593Smuzhiyun {
222*4882a593Smuzhiyun     return dixLookupPrivateAddr(privates,
223*4882a593Smuzhiyun                                 _dixGetScreenPrivateKey(key, pScreen));
224*4882a593Smuzhiyun }
225*4882a593Smuzhiyun 
226*4882a593Smuzhiyun /*
227*4882a593Smuzhiyun  * These functions relate to allocations related to a specific screen;
228*4882a593Smuzhiyun  * space will only be available for objects allocated for use on that
229*4882a593Smuzhiyun  * screen. As such, only objects which are related directly to a specific
230*4882a593Smuzhiyun  * screen are candidates for allocation this way, this includes
231*4882a593Smuzhiyun  * windows, pixmaps, gcs, pictures and colormaps. This key is
232*4882a593Smuzhiyun  * used just like any other key using dixGetPrivate and friends.
233*4882a593Smuzhiyun  *
234*4882a593Smuzhiyun  * This is distinctly different from the ScreenPrivateKeys above which
235*4882a593Smuzhiyun  * allocate space in global objects like cursor bits for a specific
236*4882a593Smuzhiyun  * screen, allowing multiple screen-related chunks of storage in a
237*4882a593Smuzhiyun  * single global object.
238*4882a593Smuzhiyun  */
239*4882a593Smuzhiyun 
240*4882a593Smuzhiyun #define HAVE_SCREEN_SPECIFIC_PRIVATE_KEYS       1
241*4882a593Smuzhiyun 
242*4882a593Smuzhiyun extern _X_EXPORT Bool
243*4882a593Smuzhiyun dixRegisterScreenSpecificPrivateKey(ScreenPtr pScreen, DevPrivateKey key,
244*4882a593Smuzhiyun                                     DevPrivateType type, unsigned size);
245*4882a593Smuzhiyun 
246*4882a593Smuzhiyun /* Clean up screen-specific privates before CloseScreen */
247*4882a593Smuzhiyun extern void
248*4882a593Smuzhiyun dixFreeScreenSpecificPrivates(ScreenPtr pScreen);
249*4882a593Smuzhiyun 
250*4882a593Smuzhiyun /* Initialize screen-specific privates in AddScreen */
251*4882a593Smuzhiyun extern void
252*4882a593Smuzhiyun dixInitScreenSpecificPrivates(ScreenPtr pScreen);
253*4882a593Smuzhiyun 
254*4882a593Smuzhiyun /* is this private created - so hotplug can avoid crashing */
255*4882a593Smuzhiyun Bool dixPrivatesCreated(DevPrivateType type);
256*4882a593Smuzhiyun 
257*4882a593Smuzhiyun extern _X_EXPORT void *
258*4882a593Smuzhiyun _dixAllocateScreenObjectWithPrivates(ScreenPtr pScreen,
259*4882a593Smuzhiyun                                      unsigned size,
260*4882a593Smuzhiyun                                      unsigned clear,
261*4882a593Smuzhiyun                                      unsigned offset,
262*4882a593Smuzhiyun                                      DevPrivateType type);
263*4882a593Smuzhiyun 
264*4882a593Smuzhiyun #define dixAllocateScreenObjectWithPrivates(s, t, type) _dixAllocateScreenObjectWithPrivates(s, sizeof(t), sizeof(t), offsetof(t, devPrivates), type)
265*4882a593Smuzhiyun 
266*4882a593Smuzhiyun extern _X_EXPORT int
267*4882a593Smuzhiyun dixScreenSpecificPrivatesSize(ScreenPtr pScreen, DevPrivateType type);
268*4882a593Smuzhiyun 
269*4882a593Smuzhiyun extern _X_EXPORT void
270*4882a593Smuzhiyun _dixInitScreenPrivates(ScreenPtr pScreen, PrivatePtr *privates, void *addr, DevPrivateType type);
271*4882a593Smuzhiyun 
272*4882a593Smuzhiyun #define dixInitScreenPrivates(s, o, v, type) _dixInitScreenPrivates(s, &(o)->devPrivates, (v), type);
273*4882a593Smuzhiyun 
274*4882a593Smuzhiyun /*
275*4882a593Smuzhiyun  * Allocates private data separately from main object.
276*4882a593Smuzhiyun  *
277*4882a593Smuzhiyun  * For objects created during server initialization, this allows those
278*4882a593Smuzhiyun  * privates to be re-allocated as new private keys are registered.
279*4882a593Smuzhiyun  *
280*4882a593Smuzhiyun  * This includes screens, the serverClient, default colormaps and
281*4882a593Smuzhiyun  * extensions entries.
282*4882a593Smuzhiyun  */
283*4882a593Smuzhiyun extern _X_EXPORT Bool
284*4882a593Smuzhiyun  dixAllocatePrivates(PrivatePtr *privates, DevPrivateType type);
285*4882a593Smuzhiyun 
286*4882a593Smuzhiyun /*
287*4882a593Smuzhiyun  * Frees separately allocated private data
288*4882a593Smuzhiyun  */
289*4882a593Smuzhiyun extern _X_EXPORT void
290*4882a593Smuzhiyun  dixFreePrivates(PrivatePtr privates, DevPrivateType type);
291*4882a593Smuzhiyun 
292*4882a593Smuzhiyun /*
293*4882a593Smuzhiyun  * Initialize privates by zeroing them
294*4882a593Smuzhiyun  */
295*4882a593Smuzhiyun extern _X_EXPORT void
296*4882a593Smuzhiyun _dixInitPrivates(PrivatePtr *privates, void *addr, DevPrivateType type);
297*4882a593Smuzhiyun 
298*4882a593Smuzhiyun #define dixInitPrivates(o, v, type) _dixInitPrivates(&(o)->devPrivates, (v), type);
299*4882a593Smuzhiyun 
300*4882a593Smuzhiyun /*
301*4882a593Smuzhiyun  * Clean up privates
302*4882a593Smuzhiyun  */
303*4882a593Smuzhiyun extern _X_EXPORT void
304*4882a593Smuzhiyun  _dixFiniPrivates(PrivatePtr privates, DevPrivateType type);
305*4882a593Smuzhiyun 
306*4882a593Smuzhiyun #define dixFiniPrivates(o,t)	_dixFiniPrivates((o)->devPrivates,t)
307*4882a593Smuzhiyun 
308*4882a593Smuzhiyun /*
309*4882a593Smuzhiyun  * Allocates private data at object creation time. Required
310*4882a593Smuzhiyun  * for almost all objects, except for the list described
311*4882a593Smuzhiyun  * above for dixAllocatePrivates.
312*4882a593Smuzhiyun  */
313*4882a593Smuzhiyun extern _X_EXPORT void *_dixAllocateObjectWithPrivates(unsigned size,
314*4882a593Smuzhiyun                                                       unsigned clear,
315*4882a593Smuzhiyun                                                       unsigned offset,
316*4882a593Smuzhiyun                                                       DevPrivateType type);
317*4882a593Smuzhiyun 
318*4882a593Smuzhiyun #define dixAllocateObjectWithPrivates(t, type) (t *) _dixAllocateObjectWithPrivates(sizeof(t), sizeof(t), offsetof(t, devPrivates), type)
319*4882a593Smuzhiyun 
320*4882a593Smuzhiyun extern _X_EXPORT void
321*4882a593Smuzhiyun 
322*4882a593Smuzhiyun _dixFreeObjectWithPrivates(void *object, PrivatePtr privates,
323*4882a593Smuzhiyun                            DevPrivateType type);
324*4882a593Smuzhiyun 
325*4882a593Smuzhiyun #define dixFreeObjectWithPrivates(o,t) _dixFreeObjectWithPrivates(o, (o)->devPrivates, t)
326*4882a593Smuzhiyun 
327*4882a593Smuzhiyun /*
328*4882a593Smuzhiyun  * Return size of privates for the specified type
329*4882a593Smuzhiyun  */
330*4882a593Smuzhiyun extern _X_EXPORT int
331*4882a593Smuzhiyun  dixPrivatesSize(DevPrivateType type);
332*4882a593Smuzhiyun 
333*4882a593Smuzhiyun /*
334*4882a593Smuzhiyun  * Dump out private stats to ErrorF
335*4882a593Smuzhiyun  */
336*4882a593Smuzhiyun extern void
337*4882a593Smuzhiyun  dixPrivateUsage(void);
338*4882a593Smuzhiyun 
339*4882a593Smuzhiyun /*
340*4882a593Smuzhiyun  * Resets the privates subsystem.  dixResetPrivates is called from the main loop
341*4882a593Smuzhiyun  * before each server generation.  This function must only be called by main().
342*4882a593Smuzhiyun  */
343*4882a593Smuzhiyun extern _X_EXPORT void
344*4882a593Smuzhiyun  dixResetPrivates(void);
345*4882a593Smuzhiyun 
346*4882a593Smuzhiyun /*
347*4882a593Smuzhiyun  * Looks up the offset where the devPrivates field is located.
348*4882a593Smuzhiyun  *
349*4882a593Smuzhiyun  * Returns -1 if the specified resource has no dev privates.
350*4882a593Smuzhiyun  * The position of the devPrivates field varies by structure
351*4882a593Smuzhiyun  * and calling code might only know the resource type, not the
352*4882a593Smuzhiyun  * structure definition.
353*4882a593Smuzhiyun  */
354*4882a593Smuzhiyun extern _X_EXPORT int
355*4882a593Smuzhiyun  dixLookupPrivateOffset(RESTYPE type);
356*4882a593Smuzhiyun 
357*4882a593Smuzhiyun /*
358*4882a593Smuzhiyun  * Convenience macro for adding an offset to an object pointer
359*4882a593Smuzhiyun  * when making a call to one of the devPrivates functions
360*4882a593Smuzhiyun  */
361*4882a593Smuzhiyun #define DEVPRIV_AT(ptr, offset) ((PrivatePtr *)((char *)(ptr) + offset))
362*4882a593Smuzhiyun 
363*4882a593Smuzhiyun #endif                          /* PRIVATES_H */
364