diff options
Diffstat (limited to 'hw/xfree86')
60 files changed, 792 insertions, 780 deletions
diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h index 064107428..183c3cdb3 100644 --- a/hw/xfree86/common/xf86.h +++ b/hw/xfree86/common/xf86.h @@ -57,9 +57,9 @@ /* General parameters */ extern int xf86DoConfigure; extern Bool xf86DoConfigurePass1; -extern int xf86ScreenIndex; /* Index into pScreen.devPrivates */ -extern int xf86CreateRootWindowIndex; /* Index into pScreen.devPrivates */ -extern int xf86PixmapIndex; +extern DevPrivateKey xf86ScreenKey; +extern DevPrivateKey xf86CreateRootWindowKey; +extern DevPrivateKey xf86PixmapKey; extern ScrnInfoPtr *xf86Screens; /* List of pointers to ScrnInfoRecs */ extern const unsigned char byte_reversed[256]; extern ScrnInfoPtr xf86CurrentScreen; @@ -72,8 +72,8 @@ extern Bool sbusSlotClaimed; extern confDRIRec xf86ConfigDRI; extern Bool xf86inSuspend; -#define XF86SCRNINFO(p) ((ScrnInfoPtr)((p)->devPrivates[xf86ScreenIndex].ptr)) - +#define XF86SCRNINFO(p) ((ScrnInfoPtr)dixLookupPrivate(&(p)->devPrivates, \ + xf86ScreenKey)) #define XF86FLIP_PIXELS() \ do { \ if (xf86GetFlipPixels()) { \ diff --git a/hw/xfree86/common/xf86DGA.c b/hw/xfree86/common/xf86DGA.c index 9474ec8e0..68f538fae 100644 --- a/hw/xfree86/common/xf86DGA.c +++ b/hw/xfree86/common/xf86DGA.c @@ -49,8 +49,7 @@ #include "mi.h" -static unsigned long DGAGeneration = 0; -static int DGAScreenIndex = -1; +static DevPrivateKey DGAScreenKey = NULL; static int mieq_installed = 0; static Bool DGACloseScreen(int i, ScreenPtr pScreen); @@ -68,8 +67,8 @@ DGACopyModeInfo( _X_EXPORT int *XDGAEventBase = NULL; -#define DGA_GET_SCREEN_PRIV(pScreen) \ - ((DGAScreenPtr)((pScreen)->devPrivates[DGAScreenIndex].ptr)) +#define DGA_GET_SCREEN_PRIV(pScreen) ((DGAScreenPtr) \ + dixLookupPrivate(&(pScreen)->devPrivates, DGAScreenKey)) typedef struct _FakedVisualList{ @@ -116,11 +115,7 @@ DGAInit( if(!modes || num <= 0) return FALSE; - if(DGAGeneration != serverGeneration) { - if((DGAScreenIndex = AllocateScreenPrivateIndex()) < 0) - return FALSE; - DGAGeneration = serverGeneration; - } + DGAScreenKey = &DGAScreenKey; if(!(pScreenPriv = (DGAScreenPtr)xalloc(sizeof(DGAScreenRec)))) return FALSE; @@ -148,7 +143,7 @@ DGAInit( modes[i].flags &= ~DGA_PIXMAP_AVAILABLE; #endif - pScreen->devPrivates[DGAScreenIndex].ptr = (pointer)pScreenPriv; + dixSetPrivate(&pScreen->devPrivates, DGAScreenKey, pScreenPriv); pScreenPriv->CloseScreen = pScreen->CloseScreen; pScreen->CloseScreen = DGACloseScreen; pScreenPriv->DestroyColormap = pScreen->DestroyColormap; @@ -176,7 +171,7 @@ DGAReInitModes( int i; /* No DGA? Ignore call (but don't make it look like it failed) */ - if(DGAScreenIndex < 0) + if(DGAScreenKey == NULL) return TRUE; pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen); @@ -350,7 +345,7 @@ xf86SetDGAMode( DGAModePtr pMode = NULL; /* First check if DGAInit was successful on this screen */ - if (DGAScreenIndex < 0) + if (DGAScreenKey == NULL) return BadValue; pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen); if (!pScreenPriv) @@ -485,7 +480,7 @@ DGAChangePixmapMode(int index, int *x, int *y, int mode) DGAModePtr pMode; PixmapPtr pPix; - if(DGAScreenIndex < 0) + if(DGAScreenKey == NULL) return FALSE; pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]); @@ -535,11 +530,12 @@ DGAChangePixmapMode(int index, int *x, int *y, int mode) _X_EXPORT Bool DGAAvailable(int index) { - if(DGAScreenIndex < 0) + if(DGAScreenKey == NULL) return FALSE; - if (!xf86NoSharedResources(((ScrnInfoPtr)screenInfo.screens[index]-> - devPrivates[xf86ScreenIndex].ptr)->scrnIndex,MEM)) + if (!xf86NoSharedResources(((ScrnInfoPtr)dixLookupPrivate( + &screenInfo.screens[index]->devPrivates, + xf86ScreenKey))->scrnIndex, MEM)) return FALSE; if(DGA_GET_SCREEN_PRIV(screenInfo.screens[index])) @@ -553,7 +549,7 @@ DGAActive(int index) { DGAScreenPtr pScreenPriv; - if(DGAScreenIndex < 0) + if(DGAScreenKey == NULL) return FALSE; pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]); @@ -574,7 +570,7 @@ DGAShutdown() ScrnInfoPtr pScrn; int i; - if(DGAScreenIndex < 0) + if(DGAScreenKey == NULL) return; for(i = 0; i < screenInfo.numScreens; i++) { @@ -904,7 +900,7 @@ DGAVTSwitch(void) /* Alternatively, this could send events to DGA clients */ - if(DGAScreenIndex >= 0) { + if(DGAScreenKey) { DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen); if(pScreenPriv && pScreenPriv->current) @@ -921,7 +917,7 @@ DGAStealKeyEvent(int index, int key_code, int is_down) DGAScreenPtr pScreenPriv; dgaEvent de; - if(DGAScreenIndex < 0) /* no DGA */ + if(DGAScreenKey == NULL) /* no DGA */ return FALSE; pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]); @@ -945,7 +941,7 @@ DGAStealMotionEvent(int index, int dx, int dy) DGAScreenPtr pScreenPriv; dgaEvent de; - if(DGAScreenIndex < 0) /* no DGA */ + if(DGAScreenKey == NULL) /* no DGA */ return FALSE; pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]); @@ -980,7 +976,7 @@ DGAStealButtonEvent(int index, int button, int is_down) DGAScreenPtr pScreenPriv; dgaEvent de; - if (DGAScreenIndex < 0) + if (DGAScreenKey == NULL) return FALSE; pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]); @@ -1006,7 +1002,7 @@ Bool DGAIsDgaEvent (xEvent *e) { int coreEquiv; - if (DGAScreenIndex < 0 || XDGAEventBase == 0) + if (DGAScreenKey == NULL || XDGAEventBase == 0) return FALSE; coreEquiv = e->u.u.type - *XDGAEventBase; if (KeyPress <= coreEquiv && coreEquiv <= MotionNotify) @@ -1275,7 +1271,7 @@ DGAHandleEvent(int screen_num, xEvent *event, DeviceIntPtr device, int nevents) int coreEquiv; /* no DGA */ - if (DGAScreenIndex < 0 || XDGAEventBase == 0) + if (DGAScreenKey == NULL || XDGAEventBase == 0) return; pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen); diff --git a/hw/xfree86/common/xf86DPMS.c b/hw/xfree86/common/xf86DPMS.c index 3aa83e882..536d38e8f 100644 --- a/hw/xfree86/common/xf86DPMS.c +++ b/hw/xfree86/common/xf86DPMS.c @@ -47,8 +47,7 @@ #ifdef DPMSExtension -static int DPMSGeneration = 0; -static int DPMSIndex = -1; +static DevPrivateKey DPMSKey = NULL; static Bool DPMSClose(int i, ScreenPtr pScreen); static int DPMSCount = 0; #endif @@ -62,18 +61,15 @@ xf86DPMSInit(ScreenPtr pScreen, DPMSSetProcPtr set, int flags) DPMSPtr pDPMS; pointer DPMSOpt; - if (serverGeneration != DPMSGeneration) { - if ((DPMSIndex = AllocateScreenPrivateIndex()) < 0) - return FALSE; - DPMSGeneration = serverGeneration; - } + DPMSKey = &DPMSKey; if (DPMSDisabledSwitch) DPMSEnabled = FALSE; - if (!(pScreen->devPrivates[DPMSIndex].ptr = xcalloc(sizeof(DPMSRec), 1))) + if (!dixSetPrivate(&pScreen->devPrivates, DPMSKey, + xcalloc(sizeof(DPMSRec), 1))) return FALSE; - pDPMS = (DPMSPtr)pScreen->devPrivates[DPMSIndex].ptr; + pDPMS = (DPMSPtr)dixLookupPrivate(&pScreen->devPrivates, DPMSKey); pScrn->DPMSSet = set; pDPMS->Flags = flags; DPMSOpt = xf86FindOption(pScrn->options, "dpms"); @@ -110,10 +106,10 @@ DPMSClose(int i, ScreenPtr pScreen) DPMSPtr pDPMS; /* This shouldn't happen */ - if (DPMSIndex < 0) + if (DPMSKey == NULL) return FALSE; - pDPMS = (DPMSPtr)pScreen->devPrivates[DPMSIndex].ptr; + pDPMS = (DPMSPtr)dixLookupPrivate(&pScreen->devPrivates, DPMSKey); /* This shouldn't happen */ if (!pDPMS) @@ -132,9 +128,9 @@ DPMSClose(int i, ScreenPtr pScreen) } xfree((pointer)pDPMS); - pScreen->devPrivates[DPMSIndex].ptr = NULL; + dixSetPrivate(&pScreen->devPrivates, DPMSKey, NULL); if (--DPMSCount == 0) - DPMSIndex = -1; + DPMSKey = NULL; return pScreen->CloseScreen(i, pScreen); } @@ -144,30 +140,35 @@ DPMSClose(int i, ScreenPtr pScreen) * Device dependent DPMS mode setting hook. This is called whenever * the DPMS mode is to be changed. */ -_X_EXPORT void -DPMSSet(int level) +_X_EXPORT int +DPMSSet(ClientPtr client, int level) { - int i; + int rc, i; DPMSPtr pDPMS; ScrnInfoPtr pScrn; DPMSPowerLevel = level; - if (DPMSIndex < 0) - return; + if (DPMSKey == NULL) + return Success; - if (level != DPMSModeOn) - SaveScreens(SCREEN_SAVER_FORCER, ScreenSaverActive); + if (level != DPMSModeOn) { + rc = SaveScreens(client, SCREEN_SAVER_FORCER, ScreenSaverActive); + if (rc != Success) + return rc; + } /* For each screen, set the DPMS level */ for (i = 0; i < xf86NumScreens; i++) { pScrn = xf86Screens[i]; - pDPMS = (DPMSPtr)screenInfo.screens[i]->devPrivates[DPMSIndex].ptr; + pDPMS = (DPMSPtr)dixLookupPrivate(&screenInfo.screens[i]->devPrivates, + DPMSKey); if (pDPMS && pScrn->DPMSSet && pDPMS->Enabled && pScrn->vtSema) { xf86EnableAccess(pScrn); pScrn->DPMSSet(pScrn, level, 0); } } + return Success; } @@ -182,14 +183,15 @@ DPMSSupported(void) DPMSPtr pDPMS; ScrnInfoPtr pScrn; - if (DPMSIndex < 0) { + if (DPMSKey == NULL) { return FALSE; } /* For each screen, check if DPMS is supported */ for (i = 0; i < xf86NumScreens; i++) { pScrn = xf86Screens[i]; - pDPMS = (DPMSPtr)screenInfo.screens[i]->devPrivates[DPMSIndex].ptr; + pDPMS = (DPMSPtr)dixLookupPrivate(&screenInfo.screens[i]->devPrivates, + DPMSKey); if (pDPMS && pScrn->DPMSSet) return TRUE; } diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c index 785815c6a..574602f43 100644 --- a/hw/xfree86/common/xf86Events.c +++ b/hw/xfree86/common/xf86Events.c @@ -855,7 +855,7 @@ xf86VTSwitch() #endif #ifdef DPMSExtension if (DPMSPowerLevel != DPMSModeOn) - DPMSSet(DPMSModeOn); + DPMSSet(serverClient, DPMSModeOn); #endif for (i = 0; i < xf86NumScreens; i++) { if (!(dispatchException & DE_TERMINATE)) @@ -904,7 +904,7 @@ xf86VTSwitch() (*xf86Screens[i]->EnableDisableFBAccess) (i, TRUE); } } - SaveScreens(SCREEN_SAVER_FORCER, ScreenSaverReset); + SaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset); pInfo = xf86InputDevs; while (pInfo) { @@ -968,7 +968,7 @@ xf86VTSwitch() } /* Turn screen saver off when switching back */ - SaveScreens(SCREEN_SAVER_FORCER,ScreenSaverReset); + SaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset); pInfo = xf86InputDevs; while (pInfo) { diff --git a/hw/xfree86/common/xf86Globals.c b/hw/xfree86/common/xf86Globals.c index b3969b102..d796d627c 100644 --- a/hw/xfree86/common/xf86Globals.c +++ b/hw/xfree86/common/xf86Globals.c @@ -46,10 +46,12 @@ /* Globals that video drivers may access */ -_X_EXPORT int xf86ScreenIndex = -1; /* Index of ScrnInfo in pScreen.devPrivates */ -int xf86CreateRootWindowIndex = -1; /* Index into pScreen.devPrivates */ +/* Index into pScreen.devPrivates */ +DevPrivateKey xf86CreateRootWindowKey = &xf86CreateRootWindowKey; +/* Index of ScrnInfo in pScreen.devPrivates */ +_X_EXPORT DevPrivateKey xf86ScreenKey = &xf86ScreenKey; +_X_EXPORT DevPrivateKey xf86PixmapKey = &xf86PixmapKey; _X_EXPORT ScrnInfoPtr *xf86Screens = NULL; /* List of ScrnInfos */ -_X_EXPORT int xf86PixmapIndex = 0; _X_EXPORT const unsigned char byte_reversed[256] = { 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c index bf577e6ad..b3cae2707 100644 --- a/hw/xfree86/common/xf86Init.c +++ b/hw/xfree86/common/xf86Init.c @@ -139,8 +139,8 @@ xf86CreateRootWindow(WindowPtr pWin) int err = Success; ScreenPtr pScreen = pWin->drawable.pScreen; RootWinPropPtr pProp; - CreateWindowProcPtr CreateWindow = - (CreateWindowProcPtr)(pScreen->devPrivates[xf86CreateRootWindowIndex].ptr); + CreateWindowProcPtr CreateWindow = (CreateWindowProcPtr) + dixLookupPrivate(&pScreen->devPrivates, xf86CreateRootWindowKey); #ifdef DEBUG ErrorF("xf86CreateRootWindow(%p)\n", pWin); @@ -156,7 +156,7 @@ xf86CreateRootWindow(WindowPtr pWin) /* Unhook this function ... */ pScreen->CreateWindow = CreateWindow; - pScreen->devPrivates[xf86CreateRootWindowIndex].ptr = NULL; + dixSetPrivate(&pScreen->devPrivates, xf86CreateRootWindowKey, NULL); /* ... and call the previous CreateWindow fuction, if any */ if (NULL!=pScreen->CreateWindow) { @@ -476,7 +476,6 @@ void InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv) { int i, j, k, scr_index; - static unsigned long generation = 0; char **modulelist; pointer *optionlist; screenLayoutPtr layout; @@ -487,14 +486,6 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv) xf86Initialising = TRUE; - /* Do this early? */ - if (generation != serverGeneration) { - xf86ScreenIndex = AllocateScreenPrivateIndex(); - xf86CreateRootWindowIndex = AllocateScreenPrivateIndex(); - xf86PixmapIndex = AllocatePixmapPrivateIndex(); - generation = serverGeneration; - } - if (serverGeneration == 1) { pScreenInfo->numScreens = 0; @@ -1070,8 +1061,8 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv) * Hook in our ScrnInfoRec, and initialise some other pScreen * fields. */ - screenInfo.screens[scr_index]->devPrivates[xf86ScreenIndex].ptr - = (pointer)xf86Screens[i]; + dixSetPrivate(&screenInfo.screens[scr_index]->devPrivates, + xf86ScreenKey, xf86Screens[i]); xf86Screens[i]->pScreen = screenInfo.screens[scr_index]; /* The driver should set this, but make sure it is set anyway */ xf86Screens[i]->vtSema = TRUE; @@ -1087,8 +1078,9 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv) i, xf86Screens[i]->pScreen->CreateWindow ); #endif - screenInfo.screens[scr_index]->devPrivates[xf86CreateRootWindowIndex].ptr - = (void*)(xf86Screens[i]->pScreen->CreateWindow); + dixSetPrivate(&screenInfo.screens[scr_index]->devPrivates, + xf86CreateRootWindowKey, + xf86Screens[i]->pScreen->CreateWindow); xf86Screens[i]->pScreen->CreateWindow = xf86CreateRootWindow; #ifdef RENDER @@ -1313,7 +1305,7 @@ AbortDDX() #endif #ifdef DPMSExtension /* Turn screens back on */ if (DPMSPowerLevel != DPMSModeOn) - DPMSSet(DPMSModeOn); + DPMSSet(serverClient, DPMSModeOn); #endif if (xf86Screens) { if (xf86Screens[0]->vtSema) diff --git a/hw/xfree86/common/xf86PM.c b/hw/xfree86/common/xf86PM.c index a6bcc3421..278a51474 100644 --- a/hw/xfree86/common/xf86PM.c +++ b/hw/xfree86/common/xf86PM.c @@ -116,7 +116,7 @@ resume(pmEvent event, Bool undo) if (xf86Screens[i]->EnableDisableFBAccess) (*xf86Screens[i]->EnableDisableFBAccess) (i, TRUE); } - SaveScreens(SCREEN_SAVER_FORCER, ScreenSaverReset); + SaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset); pInfo = xf86InputDevs; while (pInfo) { EnableDevice(pInfo->dev); diff --git a/hw/xfree86/common/xf86RandR.c b/hw/xfree86/common/xf86RandR.c index 288d72193..4432ad96b 100644 --- a/hw/xfree86/common/xf86RandR.c +++ b/hw/xfree86/common/xf86RandR.c @@ -45,10 +45,9 @@ typedef struct _xf86RandRInfo { Rotation rotation; } XF86RandRInfoRec, *XF86RandRInfoPtr; -static int xf86RandRIndex = -1; -static int xf86RandRGeneration; +static DevPrivateKey xf86RandRKey = NULL; -#define XF86RANDRINFO(p) ((XF86RandRInfoPtr) (p)->devPrivates[xf86RandRIndex].ptr) +#define XF86RANDRINFO(p) ((XF86RandRInfoPtr)dixLookupPrivate(&(p)->devPrivates, xf86RandRKey)) static int xf86RandRModeRefresh (DisplayModePtr mode) @@ -338,14 +337,14 @@ xf86RandRCloseScreen (int index, ScreenPtr pScreen) scrp->currentMode = scrp->modes; pScreen->CloseScreen = randrp->CloseScreen; xfree (randrp); - pScreen->devPrivates[xf86RandRIndex].ptr = 0; + dixSetPrivate(&pScreen->devPrivates, xf86RandRKey, NULL); return (*pScreen->CloseScreen) (index, pScreen); } _X_EXPORT Rotation xf86GetRotation(ScreenPtr pScreen) { - if (xf86RandRIndex == -1) + if (xf86RandRKey == NULL) return RR_Rotate_0; return XF86RANDRINFO(pScreen)->rotation; @@ -359,7 +358,7 @@ xf86RandRSetNewVirtualAndDimensions(ScreenPtr pScreen, { XF86RandRInfoPtr randrp; - if (xf86RandRIndex == -1) + if (xf86RandRKey == NULL) return FALSE; randrp = XF86RANDRINFO(pScreen); @@ -401,11 +400,8 @@ xf86RandRInit (ScreenPtr pScreen) if (!noPanoramiXExtension) return TRUE; #endif - if (xf86RandRGeneration != serverGeneration) - { - xf86RandRIndex = AllocateScreenPrivateIndex(); - xf86RandRGeneration = serverGeneration; - } + + xf86RandRKey = &xf86RandRKey; randrp = xalloc (sizeof (XF86RandRInfoRec)); if (!randrp) @@ -433,7 +429,7 @@ xf86RandRInit (ScreenPtr pScreen) randrp->rotation = RR_Rotate_0; - pScreen->devPrivates[xf86RandRIndex].ptr = randrp; + dixSetPrivate(&pScreen->devPrivates, xf86RandRKey, randrp); return TRUE; } diff --git a/hw/xfree86/common/xf86VidMode.c b/hw/xfree86/common/xf86VidMode.c index fb9151346..763e5c540 100644 --- a/hw/xfree86/common/xf86VidMode.c +++ b/hw/xfree86/common/xf86VidMode.c @@ -47,12 +47,11 @@ #include "vidmodeproc.h" #include "xf86cmap.h" -static int VidModeGeneration = 0; -static int VidModeIndex = -1; +static DevPrivateKey VidModeKey = NULL; static int VidModeCount = 0; static Bool VidModeClose(int i, ScreenPtr pScreen); -#define VMPTR(p) ((VidModePtr)(p)->devPrivates[VidModeIndex].ptr) +#define VMPTR(p) ((VidModePtr)dixLookupPrivate(&(p)->devPrivates, VidModeKey)) #endif @@ -75,15 +74,10 @@ VidModeExtensionInit(ScreenPtr pScreen) return FALSE; } - if (serverGeneration != VidModeGeneration) { - if ((VidModeIndex = AllocateScreenPrivateIndex()) < 0) { - DEBUG_P("AllocateScreenPrivateIndex() failed"); - return FALSE; - } - VidModeGeneration = serverGeneration; - } + VidModeKey = &VidModeKey; - if (!(pScreen->devPrivates[VidModeIndex].ptr = xcalloc(sizeof(VidModeRec), 1))) { + if (!dixSetPrivate(&pScreen->devPrivates, VidModeKey, + xcalloc(sizeof(VidModeRec), 1))) { DEBUG_P("xcalloc failed"); return FALSE; } @@ -118,10 +112,9 @@ VidModeClose(int i, ScreenPtr pScreen) pScreen->CloseScreen = pVidMode->CloseScreen; if (--VidModeCount == 0) { - if (pScreen->devPrivates[VidModeIndex].ptr) - xfree(pScreen->devPrivates[VidModeIndex].ptr); - pScreen->devPrivates[VidModeIndex].ptr = NULL; - VidModeIndex = -1; + xfree(dixLookupPrivate(&pScreen->devPrivates, VidModeKey)); + dixSetPrivate(&pScreen->devPrivates, VidModeKey, NULL); + VidModeKey = NULL; } return pScreen->CloseScreen(i, pScreen); } @@ -134,8 +127,8 @@ VidModeAvailable(int scrnIndex) DEBUG_P("VidModeAvailable"); - if (VidModeIndex < 0) { - DEBUG_P("VidModeIndex < 0"); + if (VidModeKey == NULL) { + DEBUG_P("VidModeKey == NULL"); return FALSE; } diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c index e45d44c02..b694b7303 100644 --- a/hw/xfree86/common/xf86Xinput.c +++ b/hw/xfree86/common/xf86Xinput.c @@ -77,7 +77,6 @@ #define EXTENSION_PROC_ARGS void * #include "extnsionst.h" -#include "extinit.h" /* LookupDeviceIntRec */ #include "windowstr.h" /* screenIsSaved */ diff --git a/hw/xfree86/common/xf86cmap.c b/hw/xfree86/common/xf86cmap.c index ea6a26dcd..764647ee4 100644 --- a/hw/xfree86/common/xf86cmap.c +++ b/hw/xfree86/common/xf86cmap.c @@ -60,7 +60,7 @@ #include "xf86cmap.h" #define SCREEN_PROLOGUE(pScreen, field) ((pScreen)->field = \ - ((CMapScreenPtr) (pScreen)->devPrivates[CMapScreenIndex].ptr)->field) + ((CMapScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, CMapScreenKey))->field) #define SCREEN_EPILOGUE(pScreen, field, wrapper)\ ((pScreen)->field = wrapper) @@ -102,9 +102,8 @@ typedef struct { int overscan; } CMapColormapRec, *CMapColormapPtr; -static unsigned long CMapGeneration = 0; -static int CMapScreenIndex = -1; -static int CMapColormapIndex = -1; +static DevPrivateKey CMapScreenKey = NULL; +static DevPrivateKey CMapColormapKey = &CMapColormapKey; static void CMapInstallColormap(ColormapPtr); static void CMapStoreColors(ColormapPtr, int, xColorItem *); @@ -119,7 +118,6 @@ static int CMapChangeGamma(int, Gamma); static void ComputeGamma(CMapScreenPtr); static Bool CMapAllocateColormapPrivate(ColormapPtr); -static Bool CMapInitDefMap(ColormapPtr,int); static void CMapRefreshColors(ColormapPtr, int, int*); static void CMapSetOverscan(ColormapPtr, int, int *); static void CMapReinstallMap(ColormapPtr); @@ -145,13 +143,7 @@ _X_EXPORT Bool xf86HandleColormaps( if(!maxColors || !sigRGBbits || !loadPalette) return FALSE; - if(CMapGeneration != serverGeneration) { - if(((CMapScreenIndex = AllocateScreenPrivateIndex()) < 0) || - ((CMapColormapIndex = AllocateColormapPrivateIndex( - CMapInitDefMap)) < 0)) - return FALSE; - CMapGeneration = serverGeneration; - } + CMapScreenKey = &CMapScreenKey; elements = 1 << sigRGBbits; @@ -169,7 +161,7 @@ _X_EXPORT Bool xf86HandleColormaps( return FALSE; } - pScreen->devPrivates[CMapScreenIndex].ptr = (pointer)pScreenPriv; + dixSetPrivate(&pScreen->devPrivates, CMapScreenKey, pScreenPriv); pScreenPriv->CloseScreen = pScreen->CloseScreen; pScreenPriv->CreateColormap = pScreen->CreateColormap; @@ -225,12 +217,6 @@ _X_EXPORT Bool xf86HandleColormaps( return TRUE; } -static Bool -CMapInitDefMap(ColormapPtr cmap, int index) -{ - return TRUE; -} - /**** Screen functions ****/ @@ -254,8 +240,8 @@ CMapColormapUseMax(VisualPtr pVisual, CMapScreenPtr pScreenPriv) static Bool CMapAllocateColormapPrivate(ColormapPtr pmap) { - CMapScreenPtr pScreenPriv = - (CMapScreenPtr) pmap->pScreen->devPrivates[CMapScreenIndex].ptr; + CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate( + &pmap->pScreen->devPrivates, CMapScreenKey); CMapColormapPtr pColPriv; CMapLinkPtr pLink; int numColors; @@ -274,7 +260,7 @@ CMapAllocateColormapPrivate(ColormapPtr pmap) return FALSE; } - pmap->devPrivates[CMapColormapIndex].ptr = (pointer)pColPriv; + dixSetPrivate(&pmap->devPrivates, CMapColormapKey, pColPriv); pColPriv->numColors = numColors; pColPriv->colors = colors; @@ -296,8 +282,8 @@ static Bool CMapCreateColormap (ColormapPtr pmap) { ScreenPtr pScreen = pmap->pScreen; - CMapScreenPtr pScreenPriv = - (CMapScreenPtr)pScreen->devPrivates[CMapScreenIndex].ptr; + CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, CMapScreenKey); Bool ret = FALSE; pScreen->CreateColormap = pScreenPriv->CreateColormap; @@ -314,10 +300,10 @@ static void CMapDestroyColormap (ColormapPtr cmap) { ScreenPtr pScreen = cmap->pScreen; - CMapScreenPtr pScreenPriv = - (CMapScreenPtr) pScreen->devPrivates[CMapScreenIndex].ptr; - CMapColormapPtr pColPriv = - (CMapColormapPtr) cmap->devPrivates[CMapColormapIndex].ptr; + CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, CMapScreenKey); + CMapColormapPtr pColPriv = (CMapColormapPtr)dixLookupPrivate( + &cmap->devPrivates, CMapColormapKey); CMapLinkPtr prevLink = NULL, pLink = pScreenPriv->maps; if(pColPriv) { @@ -356,8 +342,8 @@ CMapStoreColors( ){ ScreenPtr pScreen = pmap->pScreen; VisualPtr pVisual = pmap->pVisual; - CMapScreenPtr pScreenPriv = - (CMapScreenPtr) pScreen->devPrivates[CMapScreenIndex].ptr; + CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, CMapScreenKey); int *indices = pScreenPriv->PreAllocIndices; int num = ndef; @@ -373,8 +359,8 @@ CMapStoreColors( return; if(pVisual->class == DirectColor) { - CMapColormapPtr pColPriv = - (CMapColormapPtr) pmap->devPrivates[CMapColormapIndex].ptr; + CMapColormapPtr pColPriv = (CMapColormapPtr)dixLookupPrivate( + &pmap->devPrivates, CMapColormapKey); int i; if (CMapColormapUseMax(pVisual, pScreenPriv)) { @@ -431,8 +417,8 @@ CMapInstallColormap(ColormapPtr pmap) { ScreenPtr pScreen = pmap->pScreen; int index = pScreen->myNum; - CMapScreenPtr pScreenPriv = - (CMapScreenPtr) pScreen->devPrivates[CMapScreenIndex].ptr; + CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, CMapScreenKey); if (pmap == miInstalledMaps[index]) return; @@ -462,8 +448,8 @@ static Bool CMapEnterVT(int index, int flags) { ScreenPtr pScreen = screenInfo.screens[index]; - CMapScreenPtr pScreenPriv = - (CMapScreenPtr) pScreen->devPrivates[CMapScreenIndex].ptr; + CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, CMapScreenKey); if((*pScreenPriv->EnterVT)(index, flags)) { if(miInstalledMaps[index]) @@ -478,8 +464,8 @@ static Bool CMapSwitchMode(int index, DisplayModePtr mode, int flags) { ScreenPtr pScreen = screenInfo.screens[index]; - CMapScreenPtr pScreenPriv = - (CMapScreenPtr) pScreen->devPrivates[CMapScreenIndex].ptr; + CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, CMapScreenKey); if((*pScreenPriv->SwitchMode)(index, mode, flags)) { if(miInstalledMaps[index]) @@ -494,8 +480,8 @@ static int CMapSetDGAMode(int index, int num, DGADevicePtr dev) { ScreenPtr pScreen = screenInfo.screens[index]; - CMapScreenPtr pScreenPriv = - (CMapScreenPtr) pScreen->devPrivates[CMapScreenIndex].ptr; + CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, CMapScreenKey); int ret; ret = (*pScreenPriv->SetDGAMode)(index, num, dev); @@ -516,10 +502,10 @@ CMapSetDGAMode(int index, int num, DGADevicePtr dev) static void CMapReinstallMap(ColormapPtr pmap) { - CMapScreenPtr pScreenPriv = - (CMapScreenPtr) pmap->pScreen->devPrivates[CMapScreenIndex].ptr; - CMapColormapPtr cmapPriv = - (CMapColormapPtr) pmap->devPrivates[CMapColormapIndex].ptr; + CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate( + &pmap->pScreen->devPrivates, CMapScreenKey); + CMapColormapPtr cmapPriv = (CMapColormapPtr)dixLookupPrivate( + &pmap->devPrivates, CMapColormapKey); ScrnInfoPtr pScrn = xf86Screens[pmap->pScreen->myNum]; int i = cmapPriv->numColors; int *indices = pScreenPriv->PreAllocIndices; @@ -547,10 +533,10 @@ CMapReinstallMap(ColormapPtr pmap) static void CMapRefreshColors(ColormapPtr pmap, int defs, int* indices) { - CMapScreenPtr pScreenPriv = - (CMapScreenPtr) pmap->pScreen->devPrivates[CMapScreenIndex].ptr; - CMapColormapPtr pColPriv = - (CMapColormapPtr) pmap->devPrivates[CMapColormapIndex].ptr; + CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate( + &pmap->pScreen->devPrivates, CMapScreenKey); + CMapColormapPtr pColPriv = (CMapColormapPtr)dixLookupPrivate( + &pmap->devPrivates, CMapColormapKey); VisualPtr pVisual = pmap->pVisual; ScrnInfoPtr pScrn = xf86Screens[pmap->pScreen->myNum]; int numColors, i; @@ -681,10 +667,10 @@ CMapCompareColors(LOCO *color1, LOCO *color2) static void CMapSetOverscan(ColormapPtr pmap, int defs, int *indices) { - CMapScreenPtr pScreenPriv = - (CMapScreenPtr) pmap->pScreen->devPrivates[CMapScreenIndex].ptr; - CMapColormapPtr pColPriv = - (CMapColormapPtr) pmap->devPrivates[CMapColormapIndex].ptr; + CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate( + &pmap->pScreen->devPrivates, CMapScreenKey); + CMapColormapPtr pColPriv = (CMapColormapPtr)dixLookupPrivate( + &pmap->devPrivates, CMapColormapKey); ScrnInfoPtr pScrn = xf86Screens[pmap->pScreen->myNum]; VisualPtr pVisual = pmap->pVisual; int i; @@ -819,8 +805,8 @@ CMapSetOverscan(ColormapPtr pmap, int defs, int *indices) static void CMapUnwrapScreen(ScreenPtr pScreen) { - CMapScreenPtr pScreenPriv = - (CMapScreenPtr) pScreen->devPrivates[CMapScreenIndex].ptr; + CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, CMapScreenKey); ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; pScreen->CloseScreen = pScreenPriv->CloseScreen; @@ -904,10 +890,11 @@ CMapChangeGamma( CMapLinkPtr pLink; /* Is this sufficient checking ? */ - if(CMapScreenIndex == -1) + if(CMapScreenKey == NULL) return BadImplementation; - pScreenPriv = (CMapScreenPtr)pScreen->devPrivates[CMapScreenIndex].ptr; + pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates, + CMapScreenKey); if(!pScreenPriv) return BadImplementation; @@ -925,8 +912,8 @@ CMapChangeGamma( /* mark all colormaps on this screen */ pLink = pScreenPriv->maps; while(pLink) { - pColPriv = - (CMapColormapPtr) pLink->cmap->devPrivates[CMapColormapIndex].ptr; + pColPriv = (CMapColormapPtr)dixLookupPrivate(&pLink->cmap->devPrivates, + CMapColormapKey); pColPriv->recalculate = TRUE; pLink = pLink->next; } @@ -997,10 +984,11 @@ xf86ChangeGammaRamp( CMapScreenPtr pScreenPriv; CMapLinkPtr pLink; - if(CMapScreenIndex == -1) + if(CMapScreenKey == NULL) return BadImplementation; - pScreenPriv = (CMapScreenPtr)pScreen->devPrivates[CMapScreenIndex].ptr; + pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates, + CMapScreenKey); if(!pScreenPriv) return BadImplementation; @@ -1012,8 +1000,8 @@ xf86ChangeGammaRamp( /* mark all colormaps on this screen */ pLink = pScreenPriv->maps; while(pLink) { - pColPriv = - (CMapColormapPtr) pLink->cmap->devPrivates[CMapColormapIndex].ptr; + pColPriv = (CMapColormapPtr)dixLookupPrivate(&pLink->cmap->devPrivates, + CMapColormapKey); pColPriv->recalculate = TRUE; pLink = pLink->next; } @@ -1056,9 +1044,10 @@ xf86GetGammaRampSize(ScreenPtr pScreen) { CMapScreenPtr pScreenPriv; - if(CMapScreenIndex == -1) return 0; + if(CMapScreenKey == NULL) return 0; - pScreenPriv = (CMapScreenPtr)pScreen->devPrivates[CMapScreenIndex].ptr; + pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates, + CMapScreenKey); if(!pScreenPriv) return 0; return pScreenPriv->gammaElements; @@ -1076,10 +1065,11 @@ xf86GetGammaRamp( LOCO *entry; int shift, sigbits; - if(CMapScreenIndex == -1) + if(CMapScreenKey == NULL) return BadImplementation; - pScreenPriv = (CMapScreenPtr)pScreen->devPrivates[CMapScreenIndex].ptr; + pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates, + CMapScreenKey); if(!pScreenPriv) return BadImplementation; diff --git a/hw/xfree86/common/xf86fbman.c b/hw/xfree86/common/xf86fbman.c index 537d53d7d..9fd2e6c70 100644 --- a/hw/xfree86/common/xf86fbman.c +++ b/hw/xfree86/common/xf86fbman.c @@ -42,21 +42,15 @@ #define DEBUG */ -static int xf86FBMangerIndex = -1; -static unsigned long xf86ManagerGeneration = 0; +static DevPrivateKey xf86FBManagerKey = NULL; _X_EXPORT Bool xf86RegisterOffscreenManager( ScreenPtr pScreen, FBManagerFuncsPtr funcs ){ - if(xf86ManagerGeneration != serverGeneration) { - if((xf86FBMangerIndex = AllocateScreenPrivateIndex()) < 0) - return FALSE; - xf86ManagerGeneration = serverGeneration; - } - - pScreen->devPrivates[xf86FBMangerIndex].ptr = (pointer)funcs; + xf86FBManagerKey = &xf86FBManagerKey; + dixSetPrivate(&pScreen->devPrivates, xf86FBManagerKey, funcs); return TRUE; } @@ -65,9 +59,9 @@ _X_EXPORT Bool xf86RegisterOffscreenManager( _X_EXPORT Bool xf86FBManagerRunning(ScreenPtr pScreen) { - if(xf86FBMangerIndex < 0) + if(xf86FBManagerKey == NULL) return FALSE; - if(!pScreen->devPrivates[xf86FBMangerIndex].ptr) + if(!dixLookupPrivate(&pScreen->devPrivates, xf86FBManagerKey)) return FALSE; return TRUE; @@ -81,9 +75,10 @@ xf86RegisterFreeBoxCallback( ){ FBManagerFuncsPtr funcs; - if(xf86FBMangerIndex < 0) + if(xf86FBManagerKey == NULL) return FALSE; - if(!(funcs = (FBManagerFuncsPtr)pScreen->devPrivates[xf86FBMangerIndex].ptr)) + if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBManagerKey))) return FALSE; return (*funcs->RegisterFreeBoxCallback)(pScreen, FreeBoxCallback, devPriv); @@ -101,9 +96,10 @@ xf86AllocateOffscreenArea( ){ FBManagerFuncsPtr funcs; - if(xf86FBMangerIndex < 0) + if(xf86FBManagerKey == NULL) return NULL; - if(!(funcs = (FBManagerFuncsPtr)pScreen->devPrivates[xf86FBMangerIndex].ptr)) + if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBManagerKey))) return NULL; return (*funcs->AllocateOffscreenArea)( @@ -122,9 +118,10 @@ xf86AllocateOffscreenLinear( ){ FBManagerFuncsPtr funcs; - if(xf86FBMangerIndex < 0) + if(xf86FBManagerKey == NULL) return NULL; - if(!(funcs = (FBManagerFuncsPtr)pScreen->devPrivates[xf86FBMangerIndex].ptr)) + if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBManagerKey))) return NULL; return (*funcs->AllocateOffscreenLinear)( @@ -139,10 +136,10 @@ xf86FreeOffscreenArea(FBAreaPtr area) if(!area) return; - if(xf86FBMangerIndex < 0) + if(xf86FBManagerKey == NULL) return; - if(!(funcs = - (FBManagerFuncsPtr)area->pScreen->devPrivates[xf86FBMangerIndex].ptr)) + if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate( + &area->pScreen->devPrivates, xf86FBManagerKey))) return; (*funcs->FreeOffscreenArea)(area); @@ -158,10 +155,10 @@ xf86FreeOffscreenLinear(FBLinearPtr linear) if(!linear) return; - if(xf86FBMangerIndex < 0) + if(xf86FBManagerKey == NULL) return; - if(!(funcs = - (FBManagerFuncsPtr)linear->pScreen->devPrivates[xf86FBMangerIndex].ptr)) + if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate( + &linear->pScreen->devPrivates, xf86FBManagerKey))) return; (*funcs->FreeOffscreenLinear)(linear); @@ -179,10 +176,10 @@ xf86ResizeOffscreenArea( if(!resize) return FALSE; - if(xf86FBMangerIndex < 0) + if(xf86FBManagerKey == NULL) return FALSE; - if(!(funcs = - (FBManagerFuncsPtr)resize->pScreen->devPrivates[xf86FBMangerIndex].ptr)) + if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate( + &resize->pScreen->devPrivates, xf86FBManagerKey))) return FALSE; return (*funcs->ResizeOffscreenArea)(resize, w, h); @@ -197,10 +194,10 @@ xf86ResizeOffscreenLinear( if(!resize) return FALSE; - if(xf86FBMangerIndex < 0) + if(xf86FBManagerKey == NULL) return FALSE; - if(!(funcs = - (FBManagerFuncsPtr)resize->pScreen->devPrivates[xf86FBMangerIndex].ptr)) + if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate( + &resize->pScreen->devPrivates, xf86FBManagerKey))) return FALSE; return (*funcs->ResizeOffscreenLinear)(resize, size); @@ -220,9 +217,10 @@ xf86QueryLargestOffscreenArea( *w = 0; *h = 0; - if(xf86FBMangerIndex < 0) + if(xf86FBManagerKey == NULL) return FALSE; - if(!(funcs = (FBManagerFuncsPtr)pScreen->devPrivates[xf86FBMangerIndex].ptr)) + if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBManagerKey))) return FALSE; return (*funcs->QueryLargestOffscreenArea)( @@ -240,9 +238,10 @@ xf86QueryLargestOffscreenLinear( *size = 0; - if(xf86FBMangerIndex < 0) + if(xf86FBManagerKey == NULL) return FALSE; - if(!(funcs = (FBManagerFuncsPtr)pScreen->devPrivates[xf86FBMangerIndex].ptr)) + if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBManagerKey))) return FALSE; return (*funcs->QueryLargestOffscreenLinear)( @@ -255,9 +254,10 @@ xf86PurgeUnlockedOffscreenAreas(ScreenPtr pScreen) { FBManagerFuncsPtr funcs; - if(xf86FBMangerIndex < 0) + if(xf86FBManagerKey == NULL) return FALSE; - if(!(funcs = (FBManagerFuncsPtr)pScreen->devPrivates[xf86FBMangerIndex].ptr)) + if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBManagerKey))) return FALSE; return (*funcs->PurgeOffscreenAreas)(pScreen); @@ -269,8 +269,7 @@ xf86PurgeUnlockedOffscreenAreas(ScreenPtr pScreen) \************************************************************/ -static unsigned long xf86FBGeneration = 0; -static int xf86FBScreenIndex = -1; +static DevPrivateKey xf86FBScreenKey = &xf86FBScreenKey; typedef struct _FBLink { FBArea area; @@ -320,8 +319,8 @@ localRegisterFreeBoxCallback( FreeBoxCallbackProcPtr *newCallbacks; DevUnion *newPrivates; - offman = pScreen->devPrivates[xf86FBScreenIndex].ptr; - + offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBScreenKey); newCallbacks = xrealloc( offman->FreeBoxesUpdateCallback, sizeof(FreeBoxCallbackProcPtr) * (offman->NumCallbacks + 1)); @@ -446,8 +445,8 @@ localAllocateOffscreenArea( FBManagerPtr offman; FBAreaPtr area = NULL; - offman = pScreen->devPrivates[xf86FBScreenIndex].ptr; - + offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBScreenKey); if((area = AllocateArea(offman, w, h, gran, moveCB, removeCB, privData))) SendCallFreeBoxCallbacks(offman); @@ -464,8 +463,8 @@ localFreeOffscreenArea(FBAreaPtr area) ScreenPtr pScreen; pScreen = area->pScreen; - offman = pScreen->devPrivates[xf86FBScreenIndex].ptr; - + offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBScreenKey); pLink = offman->UsedAreas; if(!pLink) return; @@ -505,8 +504,8 @@ localResizeOffscreenArea( FBLinkPtr pLink, newLink, pLinkPrev = NULL; pScreen = resize->pScreen; - offman = pScreen->devPrivates[xf86FBScreenIndex].ptr; - + offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBScreenKey); /* find this link */ if(!(pLink = offman->UsedAreas)) return FALSE; @@ -625,8 +624,8 @@ localQueryLargestOffscreenArea( if((preferences < 0) || (preferences > 3)) return FALSE; - offman = pScreen->devPrivates[xf86FBScreenIndex].ptr; - + offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBScreenKey); if(severity < 0) severity = 0; if(severity > 2) severity = 2; @@ -731,8 +730,8 @@ localPurgeUnlockedOffscreenAreas(ScreenPtr pScreen) RegionRec FreedRegion; Bool anyUsed = FALSE; - offman = pScreen->devPrivates[xf86FBScreenIndex].ptr; - + offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBScreenKey); pLink = offman->UsedAreas; if(!pLink) return TRUE; @@ -780,8 +779,8 @@ LinearRemoveCBWrapper(FBAreaPtr area) FBLinearLinkPtr pLink, pLinkPrev = NULL; ScreenPtr pScreen = area->pScreen; - offman = pScreen->devPrivates[xf86FBScreenIndex].ptr; - + offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBScreenKey); pLink = offman->LinearAreas; if(!pLink) return; @@ -911,7 +910,8 @@ localAllocateOffscreenLinear( BoxPtr extents; int w, h, pitch; - offman = pScreen->devPrivates[xf86FBScreenIndex].ptr; + offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBScreenKey); /* Try to allocate from linear memory first...... */ #ifdef DEBUG @@ -991,8 +991,8 @@ localFreeOffscreenLinear(FBLinearPtr linear) FBLinearLinkPtr pLink, pLinkPrev = NULL; ScreenPtr pScreen = linear->pScreen; - offman = pScreen->devPrivates[xf86FBScreenIndex].ptr; - + offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBScreenKey); pLink = offman->LinearAreas; if(!pLink) return; @@ -1049,8 +1049,8 @@ localResizeOffscreenLinear(FBLinearPtr resize, int length) FBLinearLinkPtr pLink; ScreenPtr pScreen = resize->pScreen; - offman = pScreen->devPrivates[xf86FBScreenIndex].ptr; - + offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBScreenKey); pLink = offman->LinearAreas; if(!pLink) return FALSE; @@ -1099,7 +1099,8 @@ localQueryLargestOffscreenLinear( int priority ) { - FBManagerPtr offman = pScreen->devPrivates[xf86FBScreenIndex].ptr; + FBManagerPtr offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBScreenKey); FBLinearLinkPtr pLink; FBLinearLinkPtr pLinkRet; @@ -1130,7 +1131,8 @@ localQueryLargestOffscreenLinear( FBManagerPtr offman; BoxPtr extents; - offman = pScreen->devPrivates[xf86FBScreenIndex].ptr; + offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBScreenKey); extents = REGION_EXTENTS(pScreen, offman->InitialBoxes); if((extents->x2 - extents->x1) == w) *size = w * h; @@ -1162,9 +1164,8 @@ xf86FBCloseScreen (int i, ScreenPtr pScreen) { FBLinkPtr pLink, tmp; FBLinearLinkPtr pLinearLink, tmp2; - FBManagerPtr offman = - (FBManagerPtr) pScreen->devPrivates[xf86FBScreenIndex].ptr; - + FBManagerPtr offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBScreenKey); pScreen->CloseScreen = offman->CloseScreen; @@ -1188,7 +1189,7 @@ xf86FBCloseScreen (int i, ScreenPtr pScreen) xfree(offman->FreeBoxesUpdateCallback); xfree(offman->devPrivates); xfree(offman); - pScreen->devPrivates[xf86FBScreenIndex].ptr = NULL; + dixSetPrivate(&pScreen->devPrivates, xf86FBScreenKey, NULL); return (*pScreen->CloseScreen) (i, pScreen); } @@ -1332,19 +1333,13 @@ xf86InitFBManagerRegion( if(REGION_NIL(FullRegion)) return FALSE; - if(xf86FBGeneration != serverGeneration) { - if((xf86FBScreenIndex = AllocateScreenPrivateIndex()) < 0) - return FALSE; - xf86FBGeneration = serverGeneration; - } - if(!xf86RegisterOffscreenManager(pScreen, &xf86FBManFuncs)) return FALSE; offman = xalloc(sizeof(FBManager)); if(!offman) return FALSE; - pScreen->devPrivates[xf86FBScreenIndex].ptr = (pointer)offman; + dixSetPrivate(&pScreen->devPrivates, xf86FBScreenKey, offman); offman->CloseScreen = pScreen->CloseScreen; pScreen->CloseScreen = xf86FBCloseScreen; @@ -1380,11 +1375,11 @@ xf86InitFBManagerLinear( return FALSE; /* we expect people to have called the Area setup first for pixmap cache */ - if (!pScreen->devPrivates[xf86FBScreenIndex].ptr) + if (!dixLookupPrivate(&pScreen->devPrivates, xf86FBScreenKey)) return FALSE; - offman = pScreen->devPrivates[xf86FBScreenIndex].ptr; - + offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBScreenKey); offman->LinearAreas = xalloc(sizeof(FBLinearLink)); if (!offman->LinearAreas) return FALSE; @@ -1424,13 +1419,14 @@ xf86AllocateLinearOffscreenArea ( BoxPtr extents; int w, h; - if(xf86FBMangerIndex < 0) + if(xf86FBManagerKey == NULL) return NULL; - if(!(funcs = (FBManagerFuncsPtr)pScreen->devPrivates[xf86FBMangerIndex].ptr)) + if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBManagerKey))) return NULL; - offman = pScreen->devPrivates[xf86FBScreenIndex].ptr; - + offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates, + xf86FBScreenKey); extents = REGION_EXTENTS(pScreen, offman->InitialBoxes); w = extents->x2 - extents->x1; diff --git a/hw/xfree86/common/xf86sbusBus.c b/hw/xfree86/common/xf86sbusBus.c index 2e06ffac4..4ec099a19 100644 --- a/hw/xfree86/common/xf86sbusBus.c +++ b/hw/xfree86/common/xf86sbusBus.c @@ -602,8 +602,7 @@ xf86SbusUseBuiltinMode(ScrnInfoPtr pScrn, sbusDevicePtr psdp) pScrn->virtualY = psdp->height; } -static int sbusPaletteIndex = -1; -static unsigned long sbusPaletteGeneration = 0; +static DevPrivateKey sbusPaletteKey = &sbusPaletteKey; typedef struct _sbusCmap { sbusDevicePtr psdp; CloseScreenProcPtr CloseScreen; @@ -613,7 +612,8 @@ typedef struct _sbusCmap { unsigned char origBlue[16]; } sbusCmapRec, *sbusCmapPtr; -#define SBUSCMAPPTR(pScreen) ((sbusCmapPtr)((pScreen)->devPrivates[sbusPaletteIndex].ptr)) +#define SBUSCMAPPTR(pScreen) ((sbusCmapPtr) \ + dixLookupPrivate(&(pScreen)->devPrivates, sbusPaletteKey)) static void xf86SbusCmapLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, @@ -673,13 +673,8 @@ xf86SbusHandleColormaps(ScreenPtr pScreen, sbusDevicePtr psdp) struct fbcmap fbcmap; unsigned char data[2]; - if(sbusPaletteGeneration != serverGeneration) { - if((sbusPaletteIndex = AllocateScreenPrivateIndex()) < 0) - return FALSE; - sbusPaletteGeneration = serverGeneration; - } cmap = xnfcalloc(1, sizeof(sbusCmapRec)); - pScreen->devPrivates[sbusPaletteIndex].ptr = cmap; + dixSetPrivate(&pScreen->devPrivates, sbusPaletteKey, cmap); cmap->psdp = psdp; fbcmap.index = 0; fbcmap.count = 16; diff --git a/hw/xfree86/common/xf86xv.c b/hw/xfree86/common/xf86xv.c index 6abe31c2f..f972b1f18 100644 --- a/hw/xfree86/common/xf86xv.c +++ b/hw/xfree86/common/xf86xv.c @@ -110,23 +110,22 @@ static void xf86XVAdjustFrame(int index, int x, int y, int flags); static Bool xf86XVInitAdaptors(ScreenPtr, XF86VideoAdaptorPtr*, int); -static int XF86XVWindowIndex = -1; -int XF86XvScreenIndex = -1; -static unsigned long XF86XVGeneration = 0; +static DevPrivateKey XF86XVWindowKey = &XF86XVWindowKey; +DevPrivateKey XF86XvScreenKey; static unsigned long PortResource = 0; -int (*XvGetScreenIndexProc)(void) = NULL; +DevPrivateKey (*XvGetScreenKeyProc)(void) = NULL; unsigned long (*XvGetRTPortProc)(void) = NULL; int (*XvScreenInitProc)(ScreenPtr) = NULL; #define GET_XV_SCREEN(pScreen) \ - ((XvScreenPtr)((pScreen)->devPrivates[XF86XvScreenIndex].ptr)) + ((XvScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, XF86XvScreenKey)) #define GET_XF86XV_SCREEN(pScreen) \ - ((XF86XVScreenPtr)(GET_XV_SCREEN(pScreen)->devPriv.ptr)) + ((XF86XVScreenPtr)(GET_XV_SCREEN(pScreen)->devPriv.ptr)) #define GET_XF86XV_WINDOW(pWin) \ - ((XF86XVWindowPtr)((pWin)->devPrivates[XF86XVWindowIndex].ptr)) + ((XF86XVWindowPtr)dixLookupPrivate(&(pWin)->devPrivates, XF86XVWindowKey)) static xf86XVInitGenericAdaptorPtr *GenDrivers = NULL; static int NumGenDrivers = 0; @@ -233,21 +232,12 @@ xf86XVScreenInit( XvScreenPtr pxvs; if(num <= 0 || - !XvGetScreenIndexProc || !XvGetRTPortProc || !XvScreenInitProc) - return FALSE; - - if(XF86XVGeneration != serverGeneration) { - if((XF86XVWindowIndex = AllocateWindowPrivateIndex()) < 0) - return FALSE; - XF86XVGeneration = serverGeneration; - } - - if(!AllocateWindowPrivate(pScreen,XF86XVWindowIndex,0)) + !XvGetScreenKeyProc || !XvGetRTPortProc || !XvScreenInitProc) return FALSE; if(Success != (*XvScreenInitProc)(pScreen)) return FALSE; - XF86XvScreenIndex = (*XvGetScreenIndexProc)(); + XF86XvScreenKey = (*XvGetScreenKeyProc)(); PortResource = (*XvGetRTPortProc)(); pxvs = GET_XV_SCREEN(pScreen); @@ -977,7 +967,7 @@ xf86XVEnlistPortInWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv) memset(winPriv, 0, sizeof(XF86XVWindowRec)); winPriv->PortRec = portPriv; winPriv->next = PrivRoot; - pWin->devPrivates[XF86XVWindowIndex].ptr = (pointer)winPriv; + dixSetPrivate(&pWin->devPrivates, XF86XVWindowKey, winPriv); } portPriv->pDraw = (DrawablePtr)pWin; @@ -998,8 +988,8 @@ xf86XVRemovePortFromWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv) if(prevPriv) prevPriv->next = winPriv->next; else - pWin->devPrivates[XF86XVWindowIndex].ptr = - (pointer)winPriv->next; + dixSetPrivate(&pWin->devPrivates, XF86XVWindowKey, + winPriv->next); xfree(winPriv); break; } @@ -1037,7 +1027,7 @@ xf86XVDestroyWindow(WindowPtr pWin) xfree(tmp); } - pWin->devPrivates[XF86XVWindowIndex].ptr = NULL; + dixSetPrivate(&pWin->devPrivates, XF86XVWindowKey, NULL); pScreen->DestroyWindow = ScreenPriv->DestroyWindow; ret = (*pScreen->DestroyWindow)(pWin); @@ -1094,8 +1084,8 @@ xf86XVWindowExposures(WindowPtr pWin, RegionPtr reg1, RegionPtr reg2) pPriv->pDraw = NULL; if(!pPrev) - pWin->devPrivates[XF86XVWindowIndex].ptr = - (pointer)(WinPriv->next); + dixSetPrivate(&pWin->devPrivates, XF86XVWindowKey, + WinPriv->next); else pPrev->next = WinPriv->next; tmp = WinPriv; @@ -1146,8 +1136,8 @@ xf86XVClipNotify(WindowPtr pWin, int dx, int dy) pPriv->pDraw = NULL; if(!pPrev) - pWin->devPrivates[XF86XVWindowIndex].ptr = - (pointer)(WinPriv->next); + dixSetPrivate(&pWin->devPrivates, XF86XVWindowKey, + WinPriv->next); else pPrev->next = WinPriv->next; tmp = WinPriv; @@ -1844,7 +1834,8 @@ xf86XVFillKeyHelperDrawable (DrawablePtr pDraw, CARD32 key, RegionPtr clipboxes) int status; pval[0] = key; pval[1] = IncludeInferiors; - pGC = CreateGC(pDraw, GCForeground | GCSubwindowMode, pval, &status); + pGC = CreateGC(pDraw, GCForeground | GCSubwindowMode, pval, &status, + (XID)0, serverClient); if(!pGC) return; ValidateGC(pDraw, pGC); if (pPriv) pPriv->pGC = pGC; diff --git a/hw/xfree86/common/xf86xvmc.c b/hw/xfree86/common/xf86xvmc.c index f8ff0bed4..05267a240 100644 --- a/hw/xfree86/common/xf86xvmc.c +++ b/hw/xfree86/common/xf86xvmc.c @@ -56,11 +56,10 @@ typedef struct { XvMCAdaptorPtr dixinfo; } xf86XvMCScreenRec, *xf86XvMCScreenPtr; -static unsigned long XF86XvMCGeneration = 0; -static int XF86XvMCScreenIndex = -1; +static DevPrivateKey XF86XvMCScreenKey = &XF86XvMCScreenKey; -#define XF86XVMC_GET_PRIVATE(pScreen) \ - (xf86XvMCScreenPtr)((pScreen)->devPrivates[XF86XvMCScreenIndex].ptr) +#define XF86XVMC_GET_PRIVATE(pScreen) (xf86XvMCScreenPtr) \ + dixLookupPrivate(&(pScreen)->devPrivates, XF86XvMCScreenKey) static int @@ -164,19 +163,12 @@ _X_EXPORT Bool xf86XvMCScreenInit( { XvMCAdaptorPtr pAdapt; xf86XvMCScreenPtr pScreenPriv; - XvScreenPtr pxvs = - (XvScreenPtr)(pScreen->devPrivates[XF86XvScreenIndex].ptr); - + XvScreenPtr pxvs = (XvScreenPtr)dixLookupPrivate(&pScreen->devPrivates, + XF86XvScreenKey); int i, j; if(!XvMCScreenInitProc) return FALSE; - if(XF86XvMCGeneration != serverGeneration) { - if((XF86XvMCScreenIndex = AllocateScreenPrivateIndex()) < 0) - return FALSE; - XF86XvMCGeneration = serverGeneration; - } - if(!(pAdapt = xalloc(sizeof(XvMCAdaptorRec) * num_adaptors))) return FALSE; @@ -185,7 +177,7 @@ _X_EXPORT Bool xf86XvMCScreenInit( return FALSE; } - pScreen->devPrivates[XF86XvMCScreenIndex].ptr = (pointer)pScreenPriv; + dixSetPrivate(&pScreen->devPrivates, XF86XvMCScreenKey, pScreenPriv); pScreenPriv->CloseScreen = pScreen->CloseScreen; pScreen->CloseScreen = xf86XvMCCloseScreen; diff --git a/hw/xfree86/common/xf86xvpriv.h b/hw/xfree86/common/xf86xvpriv.h index e716c9c6a..4200dac80 100644 --- a/hw/xfree86/common/xf86xvpriv.h +++ b/hw/xfree86/common/xf86xvpriv.h @@ -30,10 +30,11 @@ #define _XF86XVPRIV_H_ #include "xf86xv.h" +#include "privates.h" /*** These are DDX layer privates ***/ -extern int XF86XvScreenIndex; +extern DevPrivateKey XF86XvScreenKey; typedef struct { DestroyWindowProcPtr DestroyWindow; diff --git a/hw/xfree86/dixmods/extmod/modinit.h b/hw/xfree86/dixmods/extmod/modinit.h index 41f060b2a..191b3ef89 100644 --- a/hw/xfree86/dixmods/extmod/modinit.h +++ b/hw/xfree86/dixmods/extmod/modinit.h @@ -129,8 +129,11 @@ extern void ShmRegisterFuncs( extern void XaceExtensionInit(INITARGS); #endif +#ifdef XSELINUX +extern void XSELinuxExtensionInit(INITARGS); +#endif + #if 1 -extern void SecurityExtensionSetup(INITARGS); extern void SecurityExtensionInit(INITARGS); #endif diff --git a/hw/xfree86/dixmods/extmod/xf86dga2.c b/hw/xfree86/dixmods/extmod/xf86dga2.c index fa9530860..3b866c798 100644 --- a/hw/xfree86/dixmods/extmod/xf86dga2.c +++ b/hw/xfree86/dixmods/extmod/xf86dga2.c @@ -22,6 +22,7 @@ #include "cursorstr.h" #include "scrnintstr.h" #include "servermd.h" +#include "registry.h" #define _XF86DGA_SERVER_ #include <X11/extensions/xf86dga.h> #include <X11/extensions/xf86dgastr.h> @@ -62,8 +63,7 @@ unsigned char DGAReqCode = 0; int DGAErrorBase; int DGAEventBase; -static int DGAGeneration = 0; -static int DGAClientPrivateIndex; +static DevPrivateKey DGAClientPrivateKey = &DGAClientPrivateKey; static int DGACallbackRefCount = 0; /* This holds the client's version information */ @@ -72,7 +72,11 @@ typedef struct { int minor; } DGAPrivRec, *DGAPrivPtr; -#define DGAPRIV(c) ((c)->devPrivates[DGAClientPrivateIndex].ptr) +#define DGA_GETPRIV(c) ((DGAPrivPtr) \ + dixLookupPrivate(&(c)->devPrivates, DGAClientPrivateKey)) +#define DGA_SETPRIV(c,p) \ + dixSetPrivate(&(c)->devPrivates, DGAClientPrivateKey, p) + void XFree86DGAExtensionInit(INITARGS) @@ -96,24 +100,72 @@ XFree86DGAExtensionInit(INITARGS) DGAEventBase = extEntry->eventBase; for (i = KeyPress; i <= MotionNotify; i++) SetCriticalEvent (DGAEventBase + i); - } - - /* - * Allocate a client private index to hold the client's version - * information. - */ - if (DGAGeneration != serverGeneration) { - DGAClientPrivateIndex = AllocateClientPrivateIndex(); - /* - * Allocate 0 length, and use the private to hold a pointer to - * our DGAPrivRec. - */ - if (!AllocateClientPrivate(DGAClientPrivateIndex, 0)) { - ErrorF("XFree86DGAExtensionInit: AllocateClientPrivate failed\n"); - return; - } - DGAGeneration = serverGeneration; - } + } else + return; + + RegisterRequestName(DGAReqCode, X_XF86DGAQueryVersion, + XF86DGANAME ":QueryVersion"); + RegisterRequestName(DGAReqCode, X_XF86DGAGetVideoLL, + XF86DGANAME ":GetVideoLL"); + RegisterRequestName(DGAReqCode, X_XF86DGADirectVideo, + XF86DGANAME ":DirectVideo"); + RegisterRequestName(DGAReqCode, X_XF86DGAGetViewPortSize, + XF86DGANAME ":GetViewPortSize"); + RegisterRequestName(DGAReqCode, X_XF86DGASetViewPort, + XF86DGANAME ":SetViewPort"); + RegisterRequestName(DGAReqCode, X_XF86DGAGetVidPage, + XF86DGANAME ":GetVidPage"); + RegisterRequestName(DGAReqCode, X_XF86DGASetVidPage, + XF86DGANAME ":SetVidPage"); + RegisterRequestName(DGAReqCode, X_XF86DGAInstallColormap, + XF86DGANAME ":InstallColormap"); + RegisterRequestName(DGAReqCode, X_XF86DGAQueryDirectVideo, + XF86DGANAME ":QueryDirectVideo"); + RegisterRequestName(DGAReqCode, X_XF86DGAViewPortChanged, + XF86DGANAME ":ViewPortChanged"); + RegisterRequestName(DGAReqCode, X_XDGAQueryModes, + XF86DGANAME ":QueryModes"); + RegisterRequestName(DGAReqCode, X_XDGASetMode, + XF86DGANAME ":SetMode"); + RegisterRequestName(DGAReqCode, X_XDGASetViewport, + XF86DGANAME ":SetViewport"); + RegisterRequestName(DGAReqCode, X_XDGAInstallColormap, + XF86DGANAME ":InstallColormap"); + RegisterRequestName(DGAReqCode, X_XDGASelectInput, + XF86DGANAME ":SelectInput"); + RegisterRequestName(DGAReqCode, X_XDGAFillRectangle, + XF86DGANAME ":FillRectangle"); + RegisterRequestName(DGAReqCode, X_XDGACopyArea, + XF86DGANAME ":CopyArea"); + RegisterRequestName(DGAReqCode, X_XDGACopyTransparentArea, + XF86DGANAME ":CopyTransparentArea"); + RegisterRequestName(DGAReqCode, X_XDGAGetViewportStatus, + XF86DGANAME ":GetViewportStatus"); + RegisterRequestName(DGAReqCode, X_XDGASync, + XF86DGANAME ":Sync"); + RegisterRequestName(DGAReqCode, X_XDGAOpenFramebuffer, + XF86DGANAME ":OpenFramebuffer"); + RegisterRequestName(DGAReqCode, X_XDGACloseFramebuffer, + XF86DGANAME ":CloseFramebuffer"); + RegisterRequestName(DGAReqCode, X_XDGASetClientVersion, + XF86DGANAME ":SetClientVersion"); + RegisterRequestName(DGAReqCode, X_XDGAChangePixmapMode, + XF86DGANAME ":ChangePixmapMode"); + RegisterRequestName(DGAReqCode, X_XDGACreateColormap, + XF86DGANAME ":CreateColormap"); + + /* 7 Events: Don't know where they are defined. EFW */ + + RegisterErrorName(extEntry->errorBase + XF86DGAClientNotLocal, + XF86DGANAME ":ClientNotLocal"); + RegisterErrorName(extEntry->errorBase + XF86DGANoDirectVideoMode, + XF86DGANAME ":NoDirectVideoMode"); + RegisterErrorName(extEntry->errorBase + XF86DGAScreenNotActive, + XF86DGANAME ":ScreenNotActive"); + RegisterErrorName(extEntry->errorBase + XF86DGADirectNotActivated, + XF86DGANAME ":DirectNotActivated"); + RegisterErrorName(extEntry->errorBase + XF86DGAOperationNotSupported, + XF86DGANAME ":OperationNotSupported"); } @@ -590,12 +642,12 @@ ProcXDGASetClientVersion(ClientPtr client) DGAPrivPtr pPriv; REQUEST_SIZE_MATCH(xXDGASetClientVersionReq); - if ((pPriv = DGAPRIV(client)) == NULL) { + if ((pPriv = DGA_GETPRIV(client)) == NULL) { pPriv = xalloc(sizeof(DGAPrivRec)); /* XXX Need to look into freeing this */ if (!pPriv) return BadAlloc; - DGAPRIV(client) = pPriv; + DGA_SETPRIV(client, pPriv); } pPriv->major = stuff->major; pPriv->minor = stuff->minor; diff --git a/hw/xfree86/dixmods/extmod/xf86misc.c b/hw/xfree86/dixmods/extmod/xf86misc.c index 3a6f83eca..274b1d3f1 100644 --- a/hw/xfree86/dixmods/extmod/xf86misc.c +++ b/hw/xfree86/dixmods/extmod/xf86misc.c @@ -19,6 +19,7 @@ #include "scrnintstr.h" #include "inputstr.h" #include "servermd.h" +#include "registry.h" #define _XF86MISC_SERVER_ #undef _XF86MISC_SAVER_COMPAT_ #include <X11/extensions/xf86mscstr.h> @@ -41,8 +42,7 @@ #endif static int miscErrorBase; -static int MiscGeneration = 0; -static int MiscClientPrivateIndex; +static DevPrivateKey MiscClientPrivateKey = &MiscClientPrivateKey; /* This holds the client's version information */ typedef struct { @@ -50,7 +50,10 @@ typedef struct { int minor; } MiscPrivRec, *MiscPrivPtr; -#define MPRIV(c) ((c)->devPrivates[MiscClientPrivateIndex].ptr) +#define M_GETPRIV(c) ((MiscPrivPtr) \ + dixLookupPrivate(&(c)->devPrivates, MiscClientPrivateKey)) +#define M_SETPRIV(c,p) \ + dixSetPrivate(&(c)->devPrivates, MiscClientPrivateKey, p) static void XF86MiscResetProc( ExtensionEntry* /* extEntry */ @@ -61,7 +64,7 @@ ClientVersion(ClientPtr client, int *major, int *minor) { MiscPrivPtr pPriv; - pPriv = MPRIV(client); + pPriv = M_GETPRIV(client); if (!pPriv) { if (major) *major = 0; if (minor) *minor = 0; @@ -123,24 +126,6 @@ XFree86MiscExtensionInit(void) if (!xf86GetModInDevEnabled()) return; - /* - * Allocate a client private index to hold the client's version - * information. - */ - if (MiscGeneration != serverGeneration) { - MiscClientPrivateIndex = AllocateClientPrivateIndex(); - /* - * Allocate 0 length, and use the private to hold a pointer to our - * MiscPrivRec. - */ - if (!AllocateClientPrivate(MiscClientPrivateIndex, 0)) { - ErrorF("XFree86MiscExtensionInit: " - "AllocateClientPrivate failed\n"); - return; - } - MiscGeneration = serverGeneration; - } - if ( (extEntry = AddExtension(XF86MISCNAME, XF86MiscNumberEvents, @@ -153,7 +138,50 @@ XFree86MiscExtensionInit(void) XF86MiscReqCode = (unsigned char)extEntry->base; #endif miscErrorBase = extEntry->errorBase; - } + } else + return; + + RegisterRequestName(extEntry->base, X_XF86MiscQueryVersion, + XF86MISCNAME ":QueryVersion"); +#ifdef _XF86MISC_SAVER_COMPAT_ + RegisterRequestName(extEntry->base, X_XF86MiscGetSaver, + XF86MISCNAME ":GetSaver"); + RegisterRequestName(extEntry->base, X_XF86MiscSetSaver, + XF86MISCNAME ":SetSaver"); +#endif + RegisterRequestName(extEntry->base, X_XF86MiscGetMouseSettings, + XF86MISCNAME ":GetMouseSettings"); + RegisterRequestName(extEntry->base, X_XF86MiscGetKbdSettings, + XF86MISCNAME ":GetKbdSettings"); + RegisterRequestName(extEntry->base, X_XF86MiscSetMouseSettings, + XF86MISCNAME ":SetMouseSettings"); + RegisterRequestName(extEntry->base, X_XF86MiscSetKbdSettings, + XF86MISCNAME ":SetKbdSettings"); + RegisterRequestName(extEntry->base, X_XF86MiscSetGrabKeysState, + XF86MISCNAME ":SetGrabKeysState"); + RegisterRequestName(extEntry->base, X_XF86MiscSetClientVersion, + XF86MISCNAME ":SetClientVersion"); + RegisterRequestName(extEntry->base, X_XF86MiscGetFilePaths, + XF86MISCNAME ":GetFilePaths"); + RegisterRequestName(extEntry->base, X_XF86MiscPassMessage, + XF86MISCNAME ":PassMessage"); + + RegisterErrorName(extEntry->errorBase + XF86MiscBadMouseProtocol, + XF86MISCNAME ":BadMouseProtocol"); + RegisterErrorName(extEntry->errorBase + XF86MiscBadMouseBaudRate, + XF86MISCNAME ":BadMouseBaudRate"); + RegisterErrorName(extEntry->errorBase + XF86MiscBadMouseFlags, + XF86MISCNAME ":BadMouseFlags"); + RegisterErrorName(extEntry->errorBase + XF86MiscBadMouseCombo, + XF86MISCNAME ":BadMouseCombo"); + RegisterErrorName(extEntry->errorBase + XF86MiscBadKbdType, + XF86MISCNAME ":BadKbdType"); + RegisterErrorName(extEntry->errorBase + XF86MiscModInDevDisabled, + XF86MISCNAME ":ModInDevDisabled"); + RegisterErrorName(extEntry->errorBase + XF86MiscModInDevClientNotLocal, + XF86MISCNAME ":ModInDevClientNotLocal"); + RegisterErrorName(extEntry->errorBase + XF86MiscNoModule, + XF86MISCNAME ":NoModule"); } /*ARGSUSED*/ @@ -205,7 +233,9 @@ ProcXF86MiscSetSaver(client) if (stuff->screen > screenInfo.numScreens) return BadValue; - vptr = (ScrnInfoPtr) screenInfo.screens[stuff->screen]->devPrivates[xf86ScreenIndex].ptr; + vptr = (ScrnInfoPtr) + dixLookupPrivate(&screenInfo.screens[stuff->screen]->devPrivates, + xf86ScreenKey); REQUEST_SIZE_MATCH(xXF86MiscSetSaverReq); @@ -233,7 +263,9 @@ ProcXF86MiscGetSaver(client) if (stuff->screen > screenInfo.numScreens) return BadValue; - vptr = (ScrnInfoPtr) screenInfo.screens[stuff->screen]->devPrivates[xf86ScreenIndex].ptr; + vptr = (ScrnInfoPtr) + dixLookupPrivate(&screenInfo.screens[stuff->screen]->devPrivates, + xf86ScreenKey); REQUEST_SIZE_MATCH(xXF86MiscGetSaverReq); rep.type = X_Reply; @@ -497,11 +529,11 @@ ProcXF86MiscSetClientVersion(ClientPtr client) REQUEST_SIZE_MATCH(xXF86MiscSetClientVersionReq); - if ((pPriv = MPRIV(client)) == NULL) { + if ((pPriv = M_GETPRIV(client)) == NULL) { pPriv = xalloc(sizeof(MiscPrivRec)); if (!pPriv) return BadAlloc; - MPRIV(client) = pPriv; + M_SETPRIV(client, pPriv); } if (xf86GetVerbosity() > 1) ErrorF("SetClientVersion: %i %i\n",stuff->major,stuff->minor); diff --git a/hw/xfree86/dixmods/extmod/xf86vmode.c b/hw/xfree86/dixmods/extmod/xf86vmode.c index 44ec9f11d..2ad681c90 100644 --- a/hw/xfree86/dixmods/extmod/xf86vmode.c +++ b/hw/xfree86/dixmods/extmod/xf86vmode.c @@ -43,6 +43,7 @@ from Kaleb S. KEITHLEY #include "extnsionst.h" #include "scrnintstr.h" #include "servermd.h" +#include "registry.h" #define _XF86VIDMODE_SERVER_ #include <X11/extensions/xf86vmstr.h> #include "swaprep.h" @@ -52,8 +53,7 @@ from Kaleb S. KEITHLEY #define DEFAULT_XF86VIDMODE_VERBOSITY 3 static int VidModeErrorBase; -static int VidModeGeneration = 0; -static int VidModeClientPrivateIndex; +static DevPrivateKey VidModeClientPrivateKey = &VidModeClientPrivateKey; /* This holds the client's version information */ typedef struct { @@ -61,7 +61,10 @@ typedef struct { int minor; } VidModePrivRec, *VidModePrivPtr; -#define VMPRIV(c) ((c)->devPrivates[VidModeClientPrivateIndex].ptr) +#define VM_GETPRIV(c) ((VidModePrivPtr) \ + dixLookupPrivate(&(c)->devPrivates, VidModeClientPrivateKey)) +#define VM_SETPRIV(c,p) \ + dixSetPrivate(&(c)->devPrivates, VidModeClientPrivateKey, p) static void XF86VidModeResetProc( ExtensionEntry* /* extEntry */ @@ -145,10 +148,12 @@ typedef struct _XF86VidModeScreenPrivate { Bool hasWindow; } XF86VidModeScreenPrivateRec, *XF86VidModeScreenPrivatePtr; -static int ScreenPrivateIndex; +static DevPrivateKey ScreenPrivateKey = &ScreenPrivateKey; -#define GetScreenPrivate(s) ((ScreenSaverScreenPrivatePtr)(s)->devPrivates[ScreenPrivateIndex].ptr) -#define SetScreenPrivate(s,v) ((s)->devPrivates[ScreenPrivateIndex].ptr = (pointer) v); +#define GetScreenPrivate(s) ((ScreenSaverScreenPrivatePtr) \ + dixLookupPrivate(&(s)->devPrivates, ScreenPrivateKey)) +#define SetScreenPrivate(s,v) \ + dixSetPrivate(&(s)->devPrivates, ScreenPrivateKey, v) #define SetupScreen(s) ScreenSaverScreenPrivatePtr pPriv = GetScreenPrivate(s) #define New(t) (xalloc (sizeof (t))) @@ -172,7 +177,6 @@ XFree86VidModeExtensionInit(void) #ifdef XF86VIDMODE_EVENTS EventType = CreateNewResourceType(XF86VidModeFreeEvents); - ScreenPrivateIndex = AllocateScreenPrivateIndex (); #endif for(i = 0; i < screenInfo.numScreens; i++) { @@ -187,27 +191,9 @@ XFree86VidModeExtensionInit(void) if (!enabled) return; - /* - * Allocate a client private index to hold the client's version - * information. - */ - if (VidModeGeneration != serverGeneration) { - VidModeClientPrivateIndex = AllocateClientPrivateIndex(); - /* - * Allocate 0 length, and use the private to hold a pointer to our - * VidModePrivRec. - */ - if (!AllocateClientPrivate(VidModeClientPrivateIndex, 0)) { - ErrorF("XFree86VidModeExtensionInit: " - "AllocateClientPrivate failed\n"); - return; - } - VidModeGeneration = serverGeneration; - } - if ( #ifdef XF86VIDMODE_EVENTS - EventType && ScreenPrivateIndex != -1 && + EventType && #endif (extEntry = AddExtension(XF86VIDMODENAME, XF86VidModeNumberEvents, @@ -224,7 +210,71 @@ XFree86VidModeExtensionInit(void) XF86VidModeEventBase = extEntry->eventBase; EventSwapVector[XF86VidModeEventBase] = (EventSwapPtr)SXF86VidModeNotifyEvent; #endif - } + } else + return; + + RegisterRequestName(extEntry->base, X_XF86VidModeQueryVersion, + XF86VIDMODENAME ":QueryVersion"); + RegisterRequestName(extEntry->base, X_XF86VidModeGetModeLine, + XF86VIDMODENAME ":GetModeLine"); + RegisterRequestName(extEntry->base, X_XF86VidModeModModeLine, + XF86VIDMODENAME ":ModModeLine"); + RegisterRequestName(extEntry->base, X_XF86VidModeSwitchMode, + XF86VIDMODENAME ":SwitchMode"); + RegisterRequestName(extEntry->base, X_XF86VidModeGetMonitor, + XF86VIDMODENAME ":GetMonitor"); + RegisterRequestName(extEntry->base, X_XF86VidModeLockModeSwitch, + XF86VIDMODENAME ":LockModeSwitch"); + RegisterRequestName(extEntry->base, X_XF86VidModeGetAllModeLines, + XF86VIDMODENAME ":GetAllModeLines"); + RegisterRequestName(extEntry->base, X_XF86VidModeAddModeLine, + XF86VIDMODENAME ":AddModeLine"); + RegisterRequestName(extEntry->base, X_XF86VidModeDeleteModeLine, + XF86VIDMODENAME ":DeleteModeLine"); + RegisterRequestName(extEntry->base, X_XF86VidModeValidateModeLine, + XF86VIDMODENAME ":ValidateModeLine"); + RegisterRequestName(extEntry->base, X_XF86VidModeSwitchToMode, + XF86VIDMODENAME ":SwitchToMode"); + RegisterRequestName(extEntry->base, X_XF86VidModeGetViewPort, + XF86VIDMODENAME ":GetViewPort"); + RegisterRequestName(extEntry->base, X_XF86VidModeSetViewPort, + XF86VIDMODENAME ":SetViewPort"); + RegisterRequestName(extEntry->base, X_XF86VidModeGetDotClocks, + XF86VIDMODENAME ":GetDotClocks"); + RegisterRequestName(extEntry->base, X_XF86VidModeSetClientVersion, + XF86VIDMODENAME ":SetClientVersion"); + RegisterRequestName(extEntry->base, X_XF86VidModeSetGamma, + XF86VIDMODENAME ":SetGamma"); + RegisterRequestName(extEntry->base, X_XF86VidModeGetGamma, + XF86VIDMODENAME ":GetGamma"); + RegisterRequestName(extEntry->base, X_XF86VidModeGetGammaRamp, + XF86VIDMODENAME ":GetGammaRamp"); + RegisterRequestName(extEntry->base, X_XF86VidModeSetGammaRamp, + XF86VIDMODENAME ":SetGammaRamp"); + RegisterRequestName(extEntry->base, X_XF86VidModeGetGammaRampSize, + XF86VIDMODENAME ":GetGammaRampSize"); + RegisterRequestName(extEntry->base, X_XF86VidModeGetPermissions, + XF86VIDMODENAME ":GetPermissions"); + +#ifdef XF86VIDMODE_EVENTS + RegisterEventName(extEntry->eventBase + XF86VidModeNotify, + XF86VIDMODENAME ":Notify"); +#endif + + RegisterErrorName(extEntry->errorBase + XF86VidModeBadClock, + XF86VIDMODENAME ":BadClock"); + RegisterErrorName(extEntry->errorBase + XF86VidModeBadHTimings, + XF86VIDMODENAME ":BadHTimings"); + RegisterErrorName(extEntry->errorBase + XF86VidModeBadVTimings, + XF86VIDMODENAME ":BadVTimings"); + RegisterErrorName(extEntry->errorBase + XF86VidModeModeUnsuitable, + XF86VIDMODENAME ":ModeUnsuitable"); + RegisterErrorName(extEntry->errorBase + XF86VidModeExtensionDisabled, + XF86VIDMODENAME ":ExtensionDisabled"); + RegisterErrorName(extEntry->errorBase + XF86VidModeClientNotLocal, + XF86VIDMODENAME ":ClientNotLocal"); + RegisterErrorName(extEntry->errorBase + XF86VidModeZoomLocked, + XF86VIDMODENAME ":ZoomLocked"); } /*ARGSUSED*/ @@ -239,7 +289,7 @@ ClientMajorVersion(ClientPtr client) { VidModePrivPtr pPriv; - pPriv = VMPRIV(client); + pPriv = VM_GETPRIV(client); if (!pPriv) return 0; else @@ -1682,11 +1732,11 @@ ProcXF86VidModeSetClientVersion(ClientPtr client) REQUEST_SIZE_MATCH(xXF86VidModeSetClientVersionReq); - if ((pPriv = VMPRIV(client)) == NULL) { + if ((pPriv = VM_GETPRIV(client)) == NULL) { pPriv = xalloc(sizeof(VidModePrivRec)); if (!pPriv) return BadAlloc; - VMPRIV(client) = pPriv; + VM_SETPRIV(client, pPriv); } pPriv->major = stuff->major; pPriv->minor = stuff->minor; diff --git a/hw/xfree86/dixmods/extmod/xvmod.c b/hw/xfree86/dixmods/extmod/xvmod.c index 7c1450c7a..6b3f1149a 100644 --- a/hw/xfree86/dixmods/extmod/xvmod.c +++ b/hw/xfree86/dixmods/extmod/xvmod.c @@ -16,7 +16,7 @@ void XvRegister() { XvScreenInitProc = XvScreenInit; - XvGetScreenIndexProc = XvGetScreenIndex; + XvGetScreenKeyProc = XvGetScreenKey; XvGetRTPortProc = XvGetRTPort; XvMCScreenInitProc = XvMCScreenInit; } diff --git a/hw/xfree86/dixmods/extmod/xvmodproc.h b/hw/xfree86/dixmods/extmod/xvmodproc.h index 81356a149..b39c915b4 100644 --- a/hw/xfree86/dixmods/extmod/xvmodproc.h +++ b/hw/xfree86/dixmods/extmod/xvmodproc.h @@ -5,7 +5,7 @@ #include "xvmcext.h" -extern int (*XvGetScreenIndexProc)(void); +extern DevPrivateKey (*XvGetScreenKeyProc)(void); extern unsigned long (*XvGetRTPortProc)(void); extern int (*XvScreenInitProc)(ScreenPtr); extern int (*XvMCScreenInitProc)(ScreenPtr, int, XvMCAdaptorPtr); diff --git a/hw/xfree86/dri/dri.c b/hw/xfree86/dri/dri.c index 1a54f2c03..c35386354 100644 --- a/hw/xfree86/dri/dri.c +++ b/hw/xfree86/dri/dri.c @@ -79,8 +79,8 @@ extern Bool noPanoramiXExtension; #endif static int DRIEntPrivIndex = -1; -static int DRIScreenPrivIndex = -1; -static int DRIWindowPrivIndex = -1; +static DevPrivateKey DRIScreenPrivKey = &DRIScreenPrivKey; +static DevPrivateKey DRIWindowPrivKey = &DRIWindowPrivKey; static unsigned long DRIGeneration = 0; static unsigned int DRIDrawableValidationStamp = 0; @@ -343,20 +343,18 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD) pDRIEntPriv = DRI_ENT_PRIV(pScrn); - if (DRIGeneration != serverGeneration) { - if ((DRIScreenPrivIndex = AllocateScreenPrivateIndex()) < 0) - return FALSE; + DRIScreenPrivKey = &DRIScreenPrivKey; + if (DRIGeneration != serverGeneration) DRIGeneration = serverGeneration; - } pDRIPriv = (DRIScreenPrivPtr) xcalloc(1, sizeof(DRIScreenPrivRec)); if (!pDRIPriv) { - pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL; - DRIScreenPrivIndex = -1; + dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL); + DRIScreenPrivKey = NULL; return FALSE; } - pScreen->devPrivates[DRIScreenPrivIndex].ptr = (pointer) pDRIPriv; + dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, pDRIPriv); pDRIPriv->drmFD = pDRIEntPriv->drmFD; pDRIPriv->directRenderingSupport = TRUE; pDRIPriv->pDriverInfo = pDRIInfo; @@ -381,7 +379,7 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD) &pDRIPriv->hSAREA) < 0) { pDRIPriv->directRenderingSupport = FALSE; - pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL; + dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL); drmClose(pDRIPriv->drmFD); DRIDrvMsg(pScreen->myNum, X_INFO, "[drm] drmAddMap failed\n"); @@ -398,7 +396,7 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD) (drmAddressPtr)(&pDRIPriv->pSAREA)) < 0) { pDRIPriv->directRenderingSupport = FALSE; - pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL; + dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL); drmClose(pDRIPriv->drmFD); DRIDrvMsg(pScreen->myNum, X_INFO, "[drm] drmMap failed\n"); @@ -428,7 +426,7 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD) &pDRIPriv->pDriverInfo->hFrameBuffer) < 0) { pDRIPriv->directRenderingSupport = FALSE; - pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL; + dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL); drmUnmap(pDRIPriv->pSAREA, pDRIPriv->pDriverInfo->SAREASize); drmClose(pDRIPriv->drmFD); DRIDrvMsg(pScreen->myNum, X_INFO, @@ -744,8 +742,8 @@ DRICloseScreen(ScreenPtr pScreen) } xfree(pDRIPriv); - pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL; - DRIScreenPrivIndex = -1; + dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL); + DRIScreenPrivKey = NULL; } } @@ -772,30 +770,13 @@ drmServerInfo DRIDRMServerInfo = { Bool DRIExtensionInit(void) { - int i; - ScreenPtr pScreen; - - if (DRIScreenPrivIndex < 0 || DRIGeneration != serverGeneration) { + if (!DRIScreenPrivKey || DRIGeneration != serverGeneration) { return FALSE; } - /* Allocate a window private index with a zero sized private area for - * each window, then should a window become a DRI window, we'll hang - * a DRIWindowPrivateRec off of this private index. - */ - if ((DRIWindowPrivIndex = AllocateWindowPrivateIndex()) < 0) - return FALSE; - DRIDrawablePrivResType = CreateNewResourceType(DRIDrawablePrivDelete); DRIContextPrivResType = CreateNewResourceType(DRIContextPrivDelete); - for (i = 0; i < screenInfo.numScreens; i++) - { - pScreen = screenInfo.screens[i]; - if (!AllocateWindowPrivate(pScreen, DRIWindowPrivIndex, 0)) - return FALSE; - } - RegisterBlockAndWakeupHandlers(DRIBlockHandler, DRIWakeupHandler, NULL); return TRUE; @@ -1302,9 +1283,8 @@ DRICreateDrawable(ScreenPtr pScreen, ClientPtr client, DrawablePtr pDrawable, pDRIDrawablePriv->nrects = REGION_NUM_RECTS(&pWin->clipList); /* save private off of preallocated index */ - pWin->devPrivates[DRIWindowPrivIndex].ptr = - (pointer)pDRIDrawablePriv; - + dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey, + pDRIDrawablePriv); pDRIPriv->nrWindows++; if (pDRIDrawablePriv->nrects) @@ -1362,7 +1342,7 @@ DRIDrawablePrivDestroy(WindowPtr pWin) drmDestroyDrawable(pDRIPriv->drmFD, pDRIDrawablePriv->hwDrawable); xfree(pDRIDrawablePriv); - pWin->devPrivates[DRIWindowPrivIndex].ptr = NULL; + dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey, NULL); } static Bool diff --git a/hw/xfree86/dri/dristruct.h b/hw/xfree86/dri/dristruct.h index c3b0aeede..ae970d834 100644 --- a/hw/xfree86/dri/dristruct.h +++ b/hw/xfree86/dri/dristruct.h @@ -37,15 +37,10 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "xf86drm.h" -#define DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin) \ - ((DRIWindowPrivIndex < 0) ? \ - NULL : \ - ((DRIDrawablePrivPtr)((pWin)->devPrivates[DRIWindowPrivIndex].ptr))) - -#define DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix) \ - ((DRIPixmapPrivIndex < 0) ? \ - NULL : \ - ((DRIDrawablePrivPtr)((pPix)->devPrivates[DRIWindowPrivIndex].ptr))) +#define DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin) ((DRIDrawablePrivPtr) \ + dixLookupPrivate(&(pWin)->devPrivates, DRIWindowPrivKey)) +#define DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix) ((DRIDrawablePrivPtr) \ + dixLookupPrivate(&(pPix)->devPrivates, DRIWindowPrivKey)) typedef struct _DRIDrawablePrivRec { @@ -65,13 +60,12 @@ struct _DRIContextPrivRec void** pContextStore; }; -#define DRI_SCREEN_PRIV(pScreen) \ - ((DRIScreenPrivIndex < 0) ? \ - NULL : \ - ((DRIScreenPrivPtr)((pScreen)->devPrivates[DRIScreenPrivIndex].ptr))) +#define DRI_SCREEN_PRIV(pScreen) ((DRIScreenPrivPtr) \ + dixLookupPrivate(&(pScreen)->devPrivates, DRIScreenPrivKey)) #define DRI_SCREEN_PRIV_FROM_INDEX(screenIndex) ((DRIScreenPrivPtr) \ - (screenInfo.screens[screenIndex]->devPrivates[DRIScreenPrivIndex].ptr)) + dixLookupPrivate(&screenInfo.screens[screenIndex]->devPrivates, \ + DRIScreenPrivKey)) #define DRI_ENT_PRIV(pScrn) \ ((DRIEntPrivIndex < 0) ? \ diff --git a/hw/xfree86/dri/xf86dri.c b/hw/xfree86/dri/xf86dri.c index fdf0e9983..c658421e8 100644 --- a/hw/xfree86/dri/xf86dri.c +++ b/hw/xfree86/dri/xf86dri.c @@ -53,6 +53,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "cursorstr.h" #include "scrnintstr.h" #include "servermd.h" +#include "registry.h" #define _XF86DRI_SERVER_ #include "xf86dristr.h" #include "swaprep.h" @@ -112,7 +113,42 @@ XFree86DRIExtensionInit(void) StandardMinorOpcode))) { DRIReqCode = (unsigned char)extEntry->base; DRIErrorBase = extEntry->errorBase; - } + } else + return; + + RegisterRequestName(DRIReqCode, X_XF86DRIQueryVersion, + XF86DRINAME ":QueryVersion"); + RegisterRequestName(DRIReqCode, X_XF86DRIQueryDirectRenderingCapable, + XF86DRINAME ":QueryDirectRenderingCapable"); + RegisterRequestName(DRIReqCode, X_XF86DRIOpenConnection, + XF86DRINAME ":OpenConnection"); + RegisterRequestName(DRIReqCode, X_XF86DRICloseConnection, + XF86DRINAME ":CloseConnection"); + RegisterRequestName(DRIReqCode, X_XF86DRIGetClientDriverName, + XF86DRINAME ":GetClientDriverName"); + RegisterRequestName(DRIReqCode, X_XF86DRICreateContext, + XF86DRINAME ":CreateContext"); + RegisterRequestName(DRIReqCode, X_XF86DRIDestroyContext, + XF86DRINAME ":DestroyContext"); + RegisterRequestName(DRIReqCode, X_XF86DRICreateDrawable, + XF86DRINAME ":CreateDrawable"); + RegisterRequestName(DRIReqCode, X_XF86DRIDestroyDrawable, + XF86DRINAME ":DestroyDrawable"); + RegisterRequestName(DRIReqCode, X_XF86DRIGetDrawableInfo, + XF86DRINAME ":GetDrawableInfo"); + RegisterRequestName(DRIReqCode, X_XF86DRIGetDeviceInfo, + XF86DRINAME ":GetDeviceInfo"); + RegisterRequestName(DRIReqCode, X_XF86DRIAuthConnection, + XF86DRINAME ":AuthConnection"); + RegisterRequestName(DRIReqCode, X_XF86DRIOpenFullScreen, + XF86DRINAME ":OpenFullScreen"); + RegisterRequestName(DRIReqCode, X_XF86DRICloseFullScreen, + XF86DRINAME ":CloseFullScreen"); + + RegisterErrorName(DRIErrorBase + XF86DRIClientNotLocal, + XF86DRINAME ":ClientNotLocal"); + RegisterErrorName(DRIErrorBase + XF86DRIOperationNotSupported, + XF86DRINAME ":OperationNotSupported"); } /*ARGSUSED*/ diff --git a/hw/xfree86/exa/examodule.c b/hw/xfree86/exa/examodule.c index 4dce58fd8..aac32949c 100644 --- a/hw/xfree86/exa/examodule.c +++ b/hw/xfree86/exa/examodule.c @@ -42,8 +42,7 @@ typedef struct _ExaXorgScreenPrivRec { OptionInfoPtr options; } ExaXorgScreenPrivRec, *ExaXorgScreenPrivPtr; -static int exaXorgServerGeneration; -static int exaXorgScreenPrivateIndex; +static DevPrivateKey exaXorgScreenPrivateKey = &exaXorgScreenPrivateKey; typedef enum { EXAOPT_MIGRATION_HEURISTIC, @@ -69,8 +68,8 @@ static Bool exaXorgCloseScreen (int i, ScreenPtr pScreen) { ScrnInfoPtr pScrn = XF86SCRNINFO(pScreen); - ExaXorgScreenPrivPtr pScreenPriv = - pScreen->devPrivates[exaXorgScreenPrivateIndex].ptr; + ExaXorgScreenPrivPtr pScreenPriv = (ExaXorgScreenPrivPtr) + dixLookupPrivate(&pScreen->devPrivates, exaXorgScreenPrivateKey); pScreen->CloseScreen = pScreenPriv->SavedCloseScreen; @@ -86,8 +85,8 @@ static void exaXorgEnableDisableFBAccess (int index, Bool enable) { ScreenPtr pScreen = screenInfo.screens[index]; - ExaXorgScreenPrivPtr pScreenPriv = - pScreen->devPrivates[exaXorgScreenPrivateIndex].ptr; + ExaXorgScreenPrivPtr pScreenPriv = (ExaXorgScreenPrivPtr) + dixLookupPrivate(&pScreen->devPrivates, exaXorgScreenPrivateKey); if (!enable) exaEnableDisableFBAccess (index, enable); @@ -111,11 +110,6 @@ exaDDXDriverInit(ScreenPtr pScreen) ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; ExaXorgScreenPrivPtr pScreenPriv; - if (exaXorgServerGeneration != serverGeneration) { - exaXorgScreenPrivateIndex = AllocateScreenPrivateIndex(); - exaXorgServerGeneration = serverGeneration; - } - pScreenPriv = xcalloc (1, sizeof(ExaXorgScreenPrivRec)); if (pScreenPriv == NULL) return; @@ -166,7 +160,7 @@ exaDDXDriverInit(ScreenPtr pScreen) pExaScr->info->DownloadFromScreen = NULL; } - pScreen->devPrivates[exaXorgScreenPrivateIndex].ptr = pScreenPriv; + dixSetPrivate(&pScreen->devPrivates, exaXorgScreenPrivateKey, pScreenPriv); pScreenPriv->SavedEnableDisableFBAccess = pScrn->EnableDisableFBAccess; pScrn->EnableDisableFBAccess = exaXorgEnableDisableFBAccess; diff --git a/hw/xfree86/loader/dixsym.c b/hw/xfree86/loader/dixsym.c index 5d06b05c7..139e23c6e 100644 --- a/hw/xfree86/loader/dixsym.c +++ b/hw/xfree86/loader/dixsym.c @@ -63,7 +63,9 @@ #include "globals.h" #include "os.h" #include "osdep.h" +#include "privates.h" #include "resource.h" +#include "registry.h" #include "servermd.h" #include "scrnintstr.h" #include "windowstr.h" @@ -113,6 +115,16 @@ _X_HIDDEN void *dixLookupTab[] = { SYMFUNC(QueryColors) /* cursor.c */ SYMFUNC(FreeCursor) + /* deprecated.c */ + SYMFUNC(LookupClient) + SYMFUNC(LookupDrawable) + SYMFUNC(LookupWindow) + SYMFUNC(SecurityLookupDrawable) + SYMFUNC(SecurityLookupWindow) + SYMFUNC(LookupIDByType) + SYMFUNC(LookupIDByClass) + SYMFUNC(SecurityLookupIDByClass) + SYMFUNC(SecurityLookupIDByType) /* devices.c */ SYMFUNC(Ones) SYMFUNC(InitButtonClassDeviceStruct) @@ -128,8 +140,6 @@ _X_HIDDEN void *dixLookupTab[] = { SYMFUNC(InitKeyboardDeviceStruct) SYMFUNC(SendMappingNotify) SYMFUNC(InitPointerDeviceStruct) - SYMFUNC(LookupKeyboardDevice) - SYMFUNC(LookupPointerDevice) /* dispatch.c */ SYMFUNC(SetInputCheck) SYMFUNC(SendErrorToClient) @@ -159,13 +169,6 @@ _X_HIDDEN void *dixLookupTab[] = { SYMFUNC(dixLookupWindow) SYMFUNC(dixLookupClient) SYMFUNC(dixLookupGC) - /* following are deprecated */ - SYMFUNC(LookupClient) - SYMFUNC(LookupDrawable) - SYMFUNC(LookupWindow) - SYMFUNC(SecurityLookupDrawable) - SYMFUNC(SecurityLookupWindow) - /* end deprecated */ SYMFUNC(NoopDDA) SYMFUNC(QueueWorkProc) SYMFUNC(RegisterBlockAndWakeupHandlers) @@ -191,11 +194,11 @@ _X_HIDDEN void *dixLookupTab[] = { #endif /* property.c */ SYMFUNC(ChangeWindowProperty) + SYMFUNC(dixChangeWindowProperty) /* extension.c */ SYMFUNC(AddExtension) SYMFUNC(AddExtensionAlias) SYMFUNC(CheckExtension) - SYMFUNC(DeclareExtensionSecurity) SYMFUNC(MinorOpcodeOfRequest) SYMFUNC(StandardMinorOpcode) #ifdef XEVIE @@ -234,7 +237,7 @@ _X_HIDDEN void *dixLookupTab[] = { #ifdef XV /* XXX These are exported from the DDX, not DIX. */ SYMVAR(XvScreenInitProc) - SYMVAR(XvGetScreenIndexProc) + SYMVAR(XvGetScreenKeyProc) SYMVAR(XvGetRTPortProc) SYMVAR(XvMCScreenInitProc) #endif @@ -259,42 +262,36 @@ _X_HIDDEN void *dixLookupTab[] = { SYMFUNC(GetScratchPixmapHeader) SYMFUNC(FreeScratchPixmapHeader) /* privates.c */ - SYMFUNC(AllocateExtensionPrivate) - SYMFUNC(AllocateExtensionPrivateIndex) - SYMFUNC(AllocateClientPrivate) - SYMFUNC(AllocateClientPrivateIndex) - SYMFUNC(AllocateGCPrivate) - SYMFUNC(AllocateGCPrivateIndex) - SYMFUNC(AllocateWindowPrivate) - SYMFUNC(AllocateWindowPrivateIndex) - SYMFUNC(AllocateScreenPrivateIndex) - SYMFUNC(AllocateColormapPrivateIndex) - SYMFUNC(AllocateDevicePrivateIndex) - SYMFUNC(AllocateDevicePrivate) - SYMFUNC(AllocatePixmapPrivateIndex) - SYMFUNC(AllocatePixmapPrivate) + SYMFUNC(dixRequestPrivate) + SYMFUNC(dixRegisterPrivateInitFunc) + SYMFUNC(dixRegisterPrivateDeleteFunc) + SYMFUNC(dixAllocatePrivate) + SYMFUNC(dixFreePrivates) + SYMFUNC(dixRegisterPrivateOffset) + SYMFUNC(dixLookupPrivateOffset) /* resource.c */ SYMFUNC(AddResource) SYMFUNC(ChangeResourceValue) SYMFUNC(CreateNewResourceClass) SYMFUNC(CreateNewResourceType) + SYMFUNC(dixLookupResource) SYMFUNC(FakeClientID) SYMFUNC(FreeResource) SYMFUNC(FreeResourceByType) SYMFUNC(GetXIDList) SYMFUNC(GetXIDRange) - SYMFUNC(LookupIDByType) - SYMFUNC(LookupIDByClass) SYMFUNC(LegalNewID) - SYMFUNC(SecurityLookupIDByClass) - SYMFUNC(SecurityLookupIDByType) SYMFUNC(FindClientResourcesByType) SYMFUNC(FindAllClientResources) SYMVAR(lastResourceType) SYMVAR(TypeMask) -#ifdef RES + SYMVAR(ResourceStateCallback) + /* registry.c */ +#ifdef XREGISTRY + SYMFUNC(RegisterRequestName) + SYMFUNC(RegisterEventName) + SYMFUNC(RegisterErrorName) SYMFUNC(RegisterResourceName) - SYMVAR(ResourceNames) #endif /* swaprep.c */ SYMFUNC(CopySwap32Write) @@ -512,7 +509,7 @@ _X_HIDDEN void *dixLookupTab[] = { SYMFUNC(PictureTransformPoint3d) SYMFUNC(PictureGetSubpixelOrder) SYMFUNC(PictureSetSubpixelOrder) - SYMVAR(PictureScreenPrivateIndex) + SYMVAR(PictureScreenPrivateKey) /* mipict.c */ SYMFUNC(miPictureInit) SYMFUNC(miComputeCompositeRegion) diff --git a/hw/xfree86/loader/misym.c b/hw/xfree86/loader/misym.c index 78ae10e02..e87d35408 100644 --- a/hw/xfree86/loader/misym.c +++ b/hw/xfree86/loader/misym.c @@ -200,9 +200,9 @@ _X_HIDDEN void *miLookupTab[] = { SYMFUNC(miOverlaySetRootClip) SYMVAR(miEmptyBox) SYMVAR(miEmptyData) - SYMVAR(miZeroLineScreenIndex) + SYMVAR(miZeroLineScreenKey) SYMVAR(miSpritePointerFuncs) - SYMVAR(miPointerScreenIndex) + SYMVAR(miPointerScreenKey) SYMVAR(miInstalledMaps) SYMVAR(miInitVisualsProc) #ifdef RENDER diff --git a/hw/xfree86/loader/xf86sym.c b/hw/xfree86/loader/xf86sym.c index 7c46e0266..67a2fe784 100644 --- a/hw/xfree86/loader/xf86sym.c +++ b/hw/xfree86/loader/xf86sym.c @@ -1097,8 +1097,8 @@ _X_HIDDEN void *xfree86LookupTab[] = { SYMVAR(xf86HUGE_VAL) /* General variables (from xf86.h) */ - SYMVAR(xf86ScreenIndex) - SYMVAR(xf86PixmapIndex) + SYMVAR(xf86ScreenKey) + SYMVAR(xf86PixmapKey) SYMVAR(xf86Screens) SYMVAR(byte_reversed) SYMVAR(xf86inSuspend) diff --git a/hw/xfree86/modes/xf86Cursors.c b/hw/xfree86/modes/xf86Cursors.c index b5101642b..acf34c1d1 100644 --- a/hw/xfree86/modes/xf86Cursors.c +++ b/hw/xfree86/modes/xf86Cursors.c @@ -226,7 +226,8 @@ xf86_set_cursor_colors (ScrnInfoPtr scrn, int bg, int fg) xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); CursorPtr cursor = xf86_config->cursor; int c; - CARD8 *bits = cursor ? cursor->devPriv[screen->myNum] : NULL; + CARD8 *bits = cursor ? dixLookupPrivate(&cursor->devPrivates, + screen) : NULL; /* Save ARGB versions of these colors */ xf86_config->cursor_fg = (CARD32) fg | 0xff000000; @@ -612,7 +613,7 @@ xf86_reload_cursors (ScreenPtr screen) else #endif (*cursor_info->LoadCursorImage)(cursor_info->pScrn, - cursor->devPriv[screen->myNum]); + dixLookupPrivate(&cursor->devPrivates, screen)); (*cursor_info->SetCursorPosition)(cursor_info->pScrn, x, y); (*cursor_info->ShowCursor)(cursor_info->pScrn); diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c index 38435c924..d58cc7070 100644 --- a/hw/xfree86/modes/xf86RandR12.c +++ b/hw/xfree86/modes/xf86RandR12.c @@ -59,11 +59,11 @@ static Bool xf86RandR12Init12 (ScreenPtr pScreen); static Bool xf86RandR12CreateScreenResources12 (ScreenPtr pScreen); #endif -static int xf86RandR12Index; -static int xf86RandR12Generation; +static int xf86RandR12Generation; +static DevPrivateKey xf86RandR12Key = &xf86RandR12Key; -#define XF86RANDRINFO(p) \ - ((XF86RandRInfoPtr)(p)->devPrivates[xf86RandR12Index].ptr) +#define XF86RANDRINFO(p) ((XF86RandRInfoPtr) \ + dixLookupPrivate(&(p)->devPrivates, xf86RandR12Key)) static int xf86RandR12ModeRefresh (DisplayModePtr mode) @@ -482,10 +482,7 @@ xf86RandR12Init (ScreenPtr pScreen) return TRUE; #endif if (xf86RandR12Generation != serverGeneration) - { - xf86RandR12Index = AllocateScreenPrivateIndex(); xf86RandR12Generation = serverGeneration; - } randrp = xalloc (sizeof (XF86RandRInfoRec)); if (!randrp) @@ -511,7 +508,7 @@ xf86RandR12Init (ScreenPtr pScreen) randrp->maxX = randrp->maxY = 0; - pScreen->devPrivates[xf86RandR12Index].ptr = randrp; + dixSetPrivate(&pScreen->devPrivates, xf86RandR12Key, randrp); #if RANDR_12_INTERFACE if (!xf86RandR12Init12 (pScreen)) diff --git a/hw/xfree86/os-support/solaris/sun_mouse.c b/hw/xfree86/os-support/solaris/sun_mouse.c index aa509d08b..b1b7797f1 100644 --- a/hw/xfree86/os-support/solaris/sun_mouse.c +++ b/hw/xfree86/os-support/solaris/sun_mouse.c @@ -121,8 +121,11 @@ static void vuidMouseSendScreenSize(ScreenPtr pScreen, VuidMsePtr pVuidMse); static void vuidMouseAdjustFrame(int index, int x, int y, int flags); static int vuidMouseGeneration = 0; -static int vuidMouseScreenIndex; -#define vuidMouseScreenPrivate(s) ((s)->devPrivates[vuidMouseScreenIndex].ptr) +static DevPrivateKey vuidMouseScreenKey = &vuidMouseScreenKey; +#define vuidGetMouseScreenPrivate(s) ((VuidMsePtr) \ + dixLookupPrivate(&(s)->devPrivates, vuidMouseScreenKey)) +#define vuidSetMouseScreenPrivate(s,p) \ + dixSetPrivate(&(s)->devPrivates, vuidMouseScreenKey, p) #endif /* HAVE_ABSOLUTE_MOUSE_SCALING */ static inline @@ -455,7 +458,7 @@ static void vuidMouseAdjustFrame(int index, int x, int y, int flags) ScrnInfoPtr pScrn = xf86Screens[index]; ScreenPtr pScreen = pScrn->pScreen; xf86AdjustFrameProc *wrappedAdjustFrame - = (xf86AdjustFrameProc *) vuidMouseScreenPrivate(pScreen); + = (xf86AdjustFrameProc *) vuidMouseGetScreenPrivate(pScreen); VuidMsePtr m; if(wrappedAdjustFrame) { @@ -496,15 +499,12 @@ vuidMouseProc(DeviceIntPtr pPointer, int what) case DEVICE_INIT: #ifdef HAVE_ABSOLUTE_MOUSE_SCALING if (vuidMouseGeneration != serverGeneration) { - if ((vuidMouseScreenIndex = AllocateScreenPrivateIndex()) >= 0) { for (i = 0; i < screenInfo.numScreens; i++) { ScreenPtr pScreen = screenInfo.screens[i]; ScrnInfoPtr pScrn = XF86SCRNINFO(pScreen); - vuidMouseScreenPrivate(pScreen) - = (pointer) pScrn->AdjustFrame; + vuidMouseSetScreenPrivate(pScreen, pScrn->AdjustFrame); pScrn->AdjustFrame = vuidMouseAdjustFrame; } - } vuidMouseGeneration = serverGeneration; } #endif diff --git a/hw/xfree86/rac/xf86RAC.c b/hw/xfree86/rac/xf86RAC.c index 9d2812c49..eb05f2e14 100644 --- a/hw/xfree86/rac/xf86RAC.c +++ b/hw/xfree86/rac/xf86RAC.c @@ -39,9 +39,8 @@ pScreen->x = y;} #define UNWRAP_SCREEN(x) pScreen->x = pScreenPriv->x -#define SCREEN_PROLOG(x) \ - pScreen->x = \ - ((RACScreenPtr) (pScreen)->devPrivates[RACScreenIndex].ptr)->x +#define SCREEN_PROLOG(x) pScreen->x = ((RACScreenPtr) \ + dixLookupPrivate(&(pScreen)->devPrivates, RACScreenKey))->x #define SCREEN_EPILOG(x,y) pScreen->x = y; #define WRAP_PICT_COND(x,y,cond) if (ps)\ @@ -50,9 +49,8 @@ ps->x = y;} #define UNWRAP_PICT(x) if (ps) {ps->x = pScreenPriv->x;} -#define PICTURE_PROLOGUE(field) \ - ps->field = \ - ((RACScreenPtr) (pScreen)->devPrivates[RACScreenIndex].ptr)->field +#define PICTURE_PROLOGUE(field) ps->field = \ + ((RACScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, RACScreenKey))->field #define PICTURE_EPILOGUE(field, wrap) \ ps->field = wrap @@ -65,9 +63,9 @@ #define UNWRAP_SCREEN_INFO(x) pScrn->x = pScreenPriv->x #define SPRITE_PROLOG miPointerScreenPtr PointPriv = \ -(miPointerScreenPtr)pScreen->devPrivates[miPointerScreenIndex].ptr;\ - RACScreenPtr pScreenPriv = \ -((RACScreenPtr) (pScreen)->devPrivates[RACScreenIndex].ptr);\ + (miPointerScreenPtr)dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey); \ + RACScreenPtr pScreenPriv = \ + ((RACScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, RACScreenKey));\ PointPriv->spriteFuncs = pScreenPriv->miSprite; #define SPRITE_EPILOG pScreenPriv->miSprite = PointPriv->spriteFuncs;\ PointPriv->spriteFuncs = &RACSpriteFuncs; @@ -82,7 +80,7 @@ (x)->ops = &RACGCOps;\ (x)->funcs = &RACGCFuncs; #define GC_UNWRAP(x)\ - RACGCPtr pGCPriv = (RACGCPtr) (x)->devPrivates[RACGCIndex].ptr;\ + RACGCPtr pGCPriv = (RACGCPtr)dixLookupPrivate(&(x)->devPrivates, RACGCKey);\ (x)->ops = pGCPriv->wrapOps;\ (x)->funcs = pGCPriv->wrapFuncs; @@ -251,9 +249,8 @@ static miPointerSpriteFuncRec RACSpriteFuncs = { RACSpriteMoveCursor }; -static int RACScreenIndex = -1; -static int RACGCIndex = -1; -static unsigned long RACGeneration = 0; +static DevPrivateKey RACScreenKey = &RACScreenKey; +static DevPrivateKey RACGCKey = &RACGCKey; Bool @@ -267,24 +264,17 @@ xf86RACInit(ScreenPtr pScreen, unsigned int flag) #endif pScrn = xf86Screens[pScreen->myNum]; - PointPriv = (miPointerScreenPtr)pScreen->devPrivates[miPointerScreenIndex].ptr; - + PointPriv = (miPointerScreenPtr)dixLookupPrivate(&pScreen->devPrivates, + miPointerScreenKey); DPRINT_S("RACInit",pScreen->myNum); - if (RACGeneration != serverGeneration) { - if ( ((RACScreenIndex = AllocateScreenPrivateIndex()) < 0) || - ((RACGCIndex = AllocateGCPrivateIndex()) < 0)) - return FALSE; - - RACGeneration = serverGeneration; - } - if (!AllocateGCPrivate(pScreen, RACGCIndex, sizeof(RACGCRec))) + if (!dixRequestPrivate(RACGCKey, sizeof(RACGCRec))) return FALSE; if (!(pScreenPriv = xalloc(sizeof(RACScreenRec)))) return FALSE; - pScreen->devPrivates[RACScreenIndex].ptr = (pointer)pScreenPriv; + dixSetPrivate(&pScreen->devPrivates, RACScreenKey, pScreenPriv); WRAP_SCREEN(CloseScreen, RACCloseScreen); WRAP_SCREEN(SaveScreen, RACSaveScreen); @@ -321,10 +311,10 @@ static Bool RACCloseScreen (int i, ScreenPtr pScreen) { ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - RACScreenPtr pScreenPriv = - (RACScreenPtr) pScreen->devPrivates[RACScreenIndex].ptr; - miPointerScreenPtr PointPriv - = (miPointerScreenPtr)pScreen->devPrivates[miPointerScreenIndex].ptr; + RACScreenPtr pScreenPriv = (RACScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, RACScreenKey); + miPointerScreenPtr PointPriv = (miPointerScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, miPointerScreenKey); #ifdef RENDER PictureScreenPtr ps = GetPictureScreenIfSet(pScreen); #endif @@ -580,8 +570,8 @@ static void RACAdjustFrame(int index, int x, int y, int flags) { ScreenPtr pScreen = screenInfo.screens[index]; - RACScreenPtr pScreenPriv = - (RACScreenPtr) pScreen->devPrivates[RACScreenIndex].ptr; + RACScreenPtr pScreenPriv = (RACScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, RACScreenKey); DPRINT_S("RACAdjustFrame",index); xf86EnableAccess(xf86Screens[index]); @@ -593,8 +583,8 @@ static Bool RACSwitchMode(int index, DisplayModePtr mode, int flags) { ScreenPtr pScreen = screenInfo.screens[index]; - RACScreenPtr pScreenPriv = - (RACScreenPtr) pScreen->devPrivates[RACScreenIndex].ptr; + RACScreenPtr pScreenPriv = (RACScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, RACScreenKey); DPRINT_S("RACSwitchMode",index); xf86EnableAccess(xf86Screens[index]); @@ -606,8 +596,8 @@ static Bool RACEnterVT(int index, int flags) { ScreenPtr pScreen = screenInfo.screens[index]; - RACScreenPtr pScreenPriv = - (RACScreenPtr) pScreen->devPrivates[RACScreenIndex].ptr; + RACScreenPtr pScreenPriv = (RACScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, RACScreenKey); DPRINT_S("RACEnterVT",index); xf86EnableAccess(xf86Screens[index]); @@ -619,8 +609,8 @@ static void RACLeaveVT(int index, int flags) { ScreenPtr pScreen = screenInfo.screens[index]; - RACScreenPtr pScreenPriv = - (RACScreenPtr) pScreen->devPrivates[RACScreenIndex].ptr; + RACScreenPtr pScreenPriv = (RACScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, RACScreenKey); DPRINT_S("RACLeaveVT",index); xf86EnableAccess(xf86Screens[index]); @@ -632,8 +622,8 @@ static void RACFreeScreen(int index, int flags) { ScreenPtr pScreen = screenInfo.screens[index]; - RACScreenPtr pScreenPriv = - (RACScreenPtr) pScreen->devPrivates[RACScreenIndex].ptr; + RACScreenPtr pScreenPriv = (RACScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, RACScreenKey); DPRINT_S("RACFreeScreen",index); xf86EnableAccess(xf86Screens[index]); @@ -645,7 +635,7 @@ static Bool RACCreateGC(GCPtr pGC) { ScreenPtr pScreen = pGC->pScreen; - RACGCPtr pGCPriv = (RACGCPtr) (pGC)->devPrivates[RACGCIndex].ptr; + RACGCPtr pGCPriv = (RACGCPtr)dixLookupPrivate(&pGC->devPrivates, RACGCKey); Bool ret; DPRINT_S("RACCreateGC",pScreen->myNum); diff --git a/hw/xfree86/ramdac/xf86Cursor.c b/hw/xfree86/ramdac/xf86Cursor.c index 457807698..5b1ce5e1f 100644 --- a/hw/xfree86/ramdac/xf86Cursor.c +++ b/hw/xfree86/ramdac/xf86Cursor.c @@ -8,8 +8,7 @@ #include "colormapst.h" #include "cursorstr.h" -int xf86CursorScreenIndex = -1; -static unsigned long xf86CursorGeneration = 0; +DevPrivateKey xf86CursorScreenKey = &xf86CursorScreenKey; /* sprite functions */ @@ -48,12 +47,6 @@ xf86InitCursor( xf86CursorScreenPtr ScreenPriv; miPointerScreenPtr PointPriv; - if (xf86CursorGeneration != serverGeneration) { - if ((xf86CursorScreenIndex = AllocateScreenPrivateIndex()) < 0) - return FALSE; - xf86CursorGeneration = serverGeneration; - } - if (!xf86InitHardwareCursor(pScreen, infoPtr)) return FALSE; @@ -61,7 +54,7 @@ xf86InitCursor( if (!ScreenPriv) return FALSE; - pScreen->devPrivates[xf86CursorScreenIndex].ptr = ScreenPriv; + dixSetPrivate(&pScreen->devPrivates, xf86CursorScreenKey, ScreenPriv); ScreenPriv->SWCursor = TRUE; ScreenPriv->isUp = FALSE; @@ -84,7 +77,7 @@ xf86InitCursor( ScreenPriv->PalettedCursor = TRUE; } - PointPriv = pScreen->devPrivates[miPointerScreenIndex].ptr; + PointPriv = dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey); ScreenPriv->showTransparent = PointPriv->showTransparent; if (infoPtr->Flags & HARDWARE_CURSOR_SHOW_TRANSPARENT) @@ -113,10 +106,10 @@ static Bool xf86CursorCloseScreen(int i, ScreenPtr pScreen) { ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - miPointerScreenPtr PointPriv = - pScreen->devPrivates[miPointerScreenIndex].ptr; - xf86CursorScreenPtr ScreenPriv = - pScreen->devPrivates[xf86CursorScreenIndex].ptr; + miPointerScreenPtr PointPriv = (miPointerScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, miPointerScreenKey); + xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, xf86CursorScreenKey); if (ScreenPriv->isUp && pScrn->vtSema) xf86SetCursor(pScreen, NullCursor, ScreenPriv->x, ScreenPriv->y); @@ -146,8 +139,8 @@ xf86CursorQueryBestSize( unsigned short *height, ScreenPtr pScreen) { - xf86CursorScreenPtr ScreenPriv = - pScreen->devPrivates[xf86CursorScreenIndex].ptr; + xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, xf86CursorScreenKey); if (class == CursorShape) { if(*width > ScreenPriv->CursorInfoPtr->MaxWidth) @@ -161,8 +154,8 @@ xf86CursorQueryBestSize( static void xf86CursorInstallColormap(ColormapPtr pMap) { - xf86CursorScreenPtr ScreenPriv = - pMap->pScreen->devPrivates[xf86CursorScreenIndex].ptr; + xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate( + &pMap->pScreen->devPrivates, xf86CursorScreenKey); ScreenPriv->pInstalledMap = pMap; @@ -175,8 +168,8 @@ xf86CursorRecolorCursor( CursorPtr pCurs, Bool displayed) { - xf86CursorScreenPtr ScreenPriv = - pScreen->devPrivates[xf86CursorScreenIndex].ptr; + xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, xf86CursorScreenKey); if (!displayed) return; @@ -195,8 +188,8 @@ xf86CursorEnableDisableFBAccess( Bool enable) { ScreenPtr pScreen = screenInfo.screens[index]; - xf86CursorScreenPtr ScreenPriv = - pScreen->devPrivates[xf86CursorScreenIndex].ptr; + xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, xf86CursorScreenKey); if (!enable && ScreenPriv->CurrentCursor != NullCursor) { CursorPtr currentCursor = ScreenPriv->CurrentCursor; @@ -226,10 +219,10 @@ xf86CursorSwitchMode(int index, DisplayModePtr mode, int flags) { Bool ret; ScreenPtr pScreen = screenInfo.screens[index]; - xf86CursorScreenPtr ScreenPriv = - pScreen->devPrivates[xf86CursorScreenIndex].ptr; - miPointerScreenPtr PointPriv = - pScreen->devPrivates[miPointerScreenIndex].ptr; + xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, xf86CursorScreenKey); + miPointerScreenPtr PointPriv = (miPointerScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, miPointerScreenKey); if (ScreenPriv->isUp) { xf86SetCursor(pScreen, NullCursor, ScreenPriv->x, ScreenPriv->y); @@ -254,11 +247,11 @@ xf86CursorSwitchMode(int index, DisplayModePtr mode, int flags) static Bool xf86CursorRealizeCursor(ScreenPtr pScreen, CursorPtr pCurs) { - xf86CursorScreenPtr ScreenPriv = - pScreen->devPrivates[xf86CursorScreenIndex].ptr; + xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, xf86CursorScreenKey); if (pCurs->refcnt <= 1) - pCurs->devPriv[pScreen->myNum] = NULL; + dixSetPrivate(&pCurs->devPrivates, pScreen, NULL); return (*ScreenPriv->spriteFuncs->RealizeCursor)(pScreen, pCurs); } @@ -266,12 +259,12 @@ xf86CursorRealizeCursor(ScreenPtr pScreen, CursorPtr pCurs) static Bool xf86CursorUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCurs) { - xf86CursorScreenPtr ScreenPriv = - pScreen->devPrivates[xf86CursorScreenIndex].ptr; + xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, xf86CursorScreenKey); if (pCurs->refcnt <= 1) { - xfree(pCurs->devPriv[pScreen->myNum]); - pCurs->devPriv[pScreen->myNum] = NULL; + xfree(dixLookupPrivate(&pCurs->devPrivates, pScreen)); + dixSetPrivate(&pCurs->devPrivates, pScreen, NULL); } return (*ScreenPriv->spriteFuncs->UnrealizeCursor)(pScreen, pCurs); @@ -280,8 +273,8 @@ xf86CursorUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCurs) static void xf86CursorSetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y) { - xf86CursorScreenPtr ScreenPriv = - pScreen->devPrivates[xf86CursorScreenIndex].ptr; + xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, xf86CursorScreenKey); xf86CursorInfoPtr infoPtr = ScreenPriv->CursorInfoPtr; miPointerScreenPtr PointPriv; @@ -306,8 +299,8 @@ xf86CursorSetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y) ScreenPriv->HotX = pCurs->bits->xhot; ScreenPriv->HotY = pCurs->bits->yhot; - PointPriv = pScreen->devPrivates[miPointerScreenIndex].ptr; - + PointPriv = (miPointerScreenPtr)dixLookupPrivate(&pScreen->devPrivates, + miPointerScreenKey); if (infoPtr->pScrn->vtSema && (ScreenPriv->ForceHWCursorCount || (( #ifdef ARGB_CURSOR pCurs->bits->argb && infoPtr->UseHWCursorARGB && @@ -351,8 +344,8 @@ xf86CursorSetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y) static void xf86CursorMoveCursor(ScreenPtr pScreen, int x, int y) { - xf86CursorScreenPtr ScreenPriv = - pScreen->devPrivates[xf86CursorScreenIndex].ptr; + xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, xf86CursorScreenKey); ScreenPriv->x = x; ScreenPriv->y = y; @@ -369,8 +362,8 @@ xf86CursorMoveCursor(ScreenPtr pScreen, int x, int y) void xf86ForceHWCursor (ScreenPtr pScreen, Bool on) { - xf86CursorScreenPtr ScreenPriv = - pScreen->devPrivates[xf86CursorScreenIndex].ptr; + xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, xf86CursorScreenKey); if (on) { diff --git a/hw/xfree86/ramdac/xf86CursorPriv.h b/hw/xfree86/ramdac/xf86CursorPriv.h index 472e2b06b..f82be2edc 100644 --- a/hw/xfree86/ramdac/xf86CursorPriv.h +++ b/hw/xfree86/ramdac/xf86CursorPriv.h @@ -45,6 +45,6 @@ Bool xf86InitHardwareCursor(ScreenPtr pScreen, xf86CursorInfoPtr infoPtr); CARD32 xf86ReverseBitOrder(CARD32 data); -extern int xf86CursorScreenIndex; +extern DevPrivateKey xf86CursorScreenKey; #endif /* _XF86CURSORPRIV_H */ diff --git a/hw/xfree86/ramdac/xf86HWCurs.c b/hw/xfree86/ramdac/xf86HWCurs.c index 91caea047..d10e283d7 100644 --- a/hw/xfree86/ramdac/xf86HWCurs.c +++ b/hw/xfree86/ramdac/xf86HWCurs.c @@ -113,8 +113,8 @@ xf86InitHardwareCursor(ScreenPtr pScreen, xf86CursorInfoPtr infoPtr) void xf86SetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y) { - xf86CursorScreenPtr ScreenPriv = - pScreen->devPrivates[xf86CursorScreenIndex].ptr; + xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, xf86CursorScreenKey); xf86CursorInfoPtr infoPtr = ScreenPriv->CursorInfoPtr; unsigned char *bits; @@ -123,7 +123,7 @@ xf86SetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y) return; } - bits = pCurs->devPriv[pScreen->myNum]; + bits = (unsigned char *)dixLookupPrivate(&pCurs->devPrivates, pScreen); x -= infoPtr->pScrn->frameX0 + ScreenPriv->HotX; y -= infoPtr->pScrn->frameY0 + ScreenPriv->HotY; @@ -133,7 +133,7 @@ xf86SetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y) #endif if (!bits) { bits = (*infoPtr->RealizeCursor)(infoPtr, pCurs); - pCurs->devPriv[pScreen->myNum] = bits; + dixSetPrivate(&pCurs->devPrivates, pScreen, bits); } if (!(infoPtr->Flags & HARDWARE_CURSOR_UPDATE_UNHIDDEN)) @@ -157,8 +157,8 @@ xf86SetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y) void xf86SetTransparentCursor(ScreenPtr pScreen) { - xf86CursorScreenPtr ScreenPriv = - pScreen->devPrivates[xf86CursorScreenIndex].ptr; + xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, xf86CursorScreenKey); xf86CursorInfoPtr infoPtr = ScreenPriv->CursorInfoPtr; if (!ScreenPriv->transparentData) @@ -178,8 +178,8 @@ xf86SetTransparentCursor(ScreenPtr pScreen) void xf86MoveCursor(ScreenPtr pScreen, int x, int y) { - xf86CursorScreenPtr ScreenPriv = - pScreen->devPrivates[xf86CursorScreenIndex].ptr; + xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, xf86CursorScreenKey); xf86CursorInfoPtr infoPtr = ScreenPriv->CursorInfoPtr; x -= infoPtr->pScrn->frameX0 + ScreenPriv->HotX; @@ -191,8 +191,8 @@ xf86MoveCursor(ScreenPtr pScreen, int x, int y) void xf86RecolorCursor(ScreenPtr pScreen, CursorPtr pCurs, Bool displayed) { - xf86CursorScreenPtr ScreenPriv = - pScreen->devPrivates[xf86CursorScreenIndex].ptr; + xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate( + &pScreen->devPrivates, xf86CursorScreenKey); xf86CursorInfoPtr infoPtr = ScreenPriv->CursorInfoPtr; #ifdef ARGB_CURSOR diff --git a/hw/xfree86/shadowfb/shadow.c b/hw/xfree86/shadowfb/shadow.c index 3511a635e..c3bd61c1e 100644 --- a/hw/xfree86/shadowfb/shadow.c +++ b/hw/xfree86/shadowfb/shadow.c @@ -94,14 +94,13 @@ typedef struct { } ShadowGCRec, *ShadowGCPtr; -static int ShadowScreenIndex = -1; -static int ShadowGCIndex = -1; -static unsigned long ShadowGeneration = 0; +static DevPrivateKey ShadowScreenKey = &ShadowScreenKey; +static DevPrivateKey ShadowGCKey = &ShadowGCKey; #define GET_SCREEN_PRIVATE(pScreen) \ - (ShadowScreenPtr)((pScreen)->devPrivates[ShadowScreenIndex].ptr) + (ShadowScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, ShadowScreenKey) #define GET_GC_PRIVATE(pGC) \ - (ShadowGCPtr)((pGC)->devPrivates[ShadowGCIndex].ptr) + (ShadowGCPtr)dixLookupPrivate(&(pGC)->devPrivates, ShadowGCKey); #define SHADOW_GC_FUNC_PROLOGUE(pGC)\ ShadowGCPtr pGCPriv = GET_GC_PRIVATE(pGC);\ @@ -172,20 +171,13 @@ ShadowFBInit2 ( if(!preRefreshArea && !postRefreshArea) return FALSE; - if (ShadowGeneration != serverGeneration) { - if(((ShadowScreenIndex = AllocateScreenPrivateIndex ()) < 0) || - ((ShadowGCIndex = AllocateGCPrivateIndex()) < 0)) - return FALSE; - ShadowGeneration = serverGeneration; - } - - if(!AllocateGCPrivate(pScreen, ShadowGCIndex, sizeof(ShadowGCRec))) + if(!dixRequestPrivate(ShadowGCKey, sizeof(ShadowGCRec))) return FALSE; if(!(pPriv = (ShadowScreenPtr)xalloc(sizeof(ShadowScreenRec)))) return FALSE; - pScreen->devPrivates[ShadowScreenIndex].ptr = (pointer)pPriv; + dixSetPrivate(&pScreen->devPrivates, ShadowScreenKey, pPriv); pPriv->pScrn = pScrn; pPriv->preRefresh = preRefreshArea; diff --git a/hw/xfree86/xaa/xaaDashLine.c b/hw/xfree86/xaa/xaaDashLine.c index 1a4732baa..63233e05d 100644 --- a/hw/xfree86/xaa/xaaDashLine.c +++ b/hw/xfree86/xaa/xaaDashLine.c @@ -35,7 +35,8 @@ XAAPolyLinesDashed( #endif ){ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - XAAGCPtr pGCPriv = (XAAGCPtr) (pGC)->devPrivates[XAAGetGCIndex()].ptr; + XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&pGC->devPrivates, + XAAGetGCKey()); BoxPtr pboxInit = REGION_RECTS(pGC->pCompositeClip); int nboxInit = REGION_NUM_RECTS(pGC->pCompositeClip); unsigned int bias = miGetZeroLineBias(pDrawable->pScreen); diff --git a/hw/xfree86/xaa/xaaGC.c b/hw/xfree86/xaa/xaaGC.c index b3dc83ada..e6083d529 100644 --- a/hw/xfree86/xaa/xaaGC.c +++ b/hw/xfree86/xaa/xaaGC.c @@ -38,7 +38,8 @@ Bool XAACreateGC(GCPtr pGC) { ScreenPtr pScreen = pGC->pScreen; - XAAGCPtr pGCPriv = (XAAGCPtr)(pGC->devPrivates[XAAGetGCIndex()].ptr); + XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&pGC->devPrivates, + XAAGetGCKey()); Bool ret; XAA_SCREEN_PROLOGUE(pScreen,CreateGC); diff --git a/hw/xfree86/xaa/xaaGCmisc.c b/hw/xfree86/xaa/xaaGCmisc.c index a7a3f4081..5823cc064 100644 --- a/hw/xfree86/xaa/xaaGCmisc.c +++ b/hw/xfree86/xaa/xaaGCmisc.c @@ -305,7 +305,8 @@ XAAValidatePolylines( DrawablePtr pDraw ) { XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - XAAGCPtr pGCPriv = (XAAGCPtr) (pGC)->devPrivates[XAAGetGCIndex()].ptr; + XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&pGC->devPrivates, + XAAGetGCKey()); if(pGC->lineStyle == LineSolid) changes &= ~GCDashList; if(!changes) return; diff --git a/hw/xfree86/xaa/xaaInit.c b/hw/xfree86/xaa/xaaInit.c index 422242513..f1757c866 100644 --- a/hw/xfree86/xaa/xaaInit.c +++ b/hw/xfree86/xaa/xaaInit.c @@ -38,22 +38,20 @@ static int XAASetDGAMode(int index, int num, DGADevicePtr devRet); static void XAAEnableDisableFBAccess (int index, Bool enable); static Bool XAAChangeWindowAttributes (WindowPtr pWin, unsigned long mask); -static int XAAScreenIndex = -1; -static int XAAGCIndex = -1; -static int XAAPixmapIndex = -1; +static DevPrivateKey XAAScreenKey = &XAAScreenKey; +static DevPrivateKey XAAGCKey = &XAAGCKey; +static DevPrivateKey XAAPixmapKey = &XAAPixmapKey; -static unsigned long XAAGeneration = 0; - -int XAAGetScreenIndex(void) { - return XAAScreenIndex; +DevPrivateKey XAAGetScreenKey(void) { + return XAAScreenKey; } -int XAAGetGCIndex(void) { - return XAAGCIndex; +DevPrivateKey XAAGetGCKey(void) { + return XAAGCKey; } -int XAAGetPixmapIndex(void) { - return XAAPixmapIndex; +DevPrivateKey XAAGetPixmapKey(void) { + return XAAPixmapKey; } /* temp kludge */ @@ -103,25 +101,16 @@ XAAInit(ScreenPtr pScreen, XAAInfoRecPtr infoRec) if (!infoRec) return TRUE; - if (XAAGeneration != serverGeneration) { - if ( ((XAAScreenIndex = AllocateScreenPrivateIndex()) < 0) || - ((XAAGCIndex = AllocateGCPrivateIndex()) < 0) || - ((XAAPixmapIndex = AllocatePixmapPrivateIndex()) < 0)) - return FALSE; - - XAAGeneration = serverGeneration; - } - - if (!AllocateGCPrivate(pScreen, XAAGCIndex, sizeof(XAAGCRec))) + if (!dixRequestPrivate(XAAGCKey, sizeof(XAAGCRec))) return FALSE; - if (!AllocatePixmapPrivate(pScreen, XAAPixmapIndex, sizeof(XAAPixmapRec))) + if (!dixRequestPrivate(XAAPixmapKey, sizeof(XAAPixmapRec))) return FALSE; if (!(pScreenPriv = xalloc(sizeof(XAAScreenRec)))) return FALSE; - pScreen->devPrivates[XAAScreenIndex].ptr = (pointer)pScreenPriv; + dixSetPrivate(&pScreen->devPrivates, XAAScreenKey, pScreenPriv); if(!xf86FBManagerRunning(pScreen)) infoRec->Flags &= ~(PIXMAP_CACHE | OFFSCREEN_PIXMAPS); @@ -218,7 +207,7 @@ XAACloseScreen (int i, ScreenPtr pScreen) { ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; XAAScreenPtr pScreenPriv = - (XAAScreenPtr) pScreen->devPrivates[XAAScreenIndex].ptr; + (XAAScreenPtr)dixLookupPrivate(&pScreen->devPrivates, XAAScreenKey); pScrn->EnterVT = pScreenPriv->EnterVT; pScrn->LeaveVT = pScreenPriv->LeaveVT; @@ -514,7 +503,7 @@ XAAEnterVT(int index, int flags) { ScreenPtr pScreen = screenInfo.screens[index]; XAAScreenPtr pScreenPriv = - (XAAScreenPtr) pScreen->devPrivates[XAAScreenIndex].ptr; + (XAAScreenPtr)dixLookupPrivate(&pScreen->devPrivates, XAAScreenKey); return((*pScreenPriv->EnterVT)(index, flags)); } @@ -524,7 +513,7 @@ XAALeaveVT(int index, int flags) { ScreenPtr pScreen = screenInfo.screens[index]; XAAScreenPtr pScreenPriv = - (XAAScreenPtr) pScreen->devPrivates[XAAScreenIndex].ptr; + (XAAScreenPtr)dixLookupPrivate(&pScreen->devPrivates, XAAScreenKey); XAAInfoRecPtr infoRec = pScreenPriv->AccelInfoRec; if(infoRec->NeedToSync) { @@ -547,7 +536,7 @@ XAASetDGAMode(int index, int num, DGADevicePtr devRet) ScreenPtr pScreen = screenInfo.screens[index]; XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen); XAAScreenPtr pScreenPriv = - (XAAScreenPtr) pScreen->devPrivates[XAAScreenIndex].ptr; + (XAAScreenPtr)dixLookupPrivate(&pScreen->devPrivates, XAAScreenKey); int ret; if (!num && infoRec->dgaSaves) { /* restore old pixmap cache state */ @@ -609,7 +598,7 @@ XAAEnableDisableFBAccess (int index, Bool enable) ScreenPtr pScreen = screenInfo.screens[index]; XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen); XAAScreenPtr pScreenPriv = - (XAAScreenPtr) pScreen->devPrivates[XAAScreenIndex].ptr; + (XAAScreenPtr)dixLookupPrivate(&pScreen->devPrivates, XAAScreenKey); if(!enable) { if((infoRec->Flags & OFFSCREEN_PIXMAPS) && (infoRec->OffscreenPixmaps)) diff --git a/hw/xfree86/xaa/xaaLineMisc.c b/hw/xfree86/xaa/xaaLineMisc.c index 537b08b97..cefb59a8e 100644 --- a/hw/xfree86/xaa/xaaLineMisc.c +++ b/hw/xfree86/xaa/xaaLineMisc.c @@ -64,7 +64,8 @@ void XAAComputeDash(GCPtr pGC) { XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - XAAGCPtr pGCPriv = (XAAGCPtr) (pGC)->devPrivates[XAAGetGCIndex()].ptr; + XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&pGC->devPrivates, + XAAGetGCKey()); Bool EvenDash = (pGC->numInDashList & 0x01) ? FALSE : TRUE; int PatternLength = 0; unsigned char* DashPtr = (unsigned char*)pGC->dash; diff --git a/hw/xfree86/xaa/xaaOverlayDF.c b/hw/xfree86/xaa/xaaOverlayDF.c index bf910982a..508b5c6f1 100644 --- a/hw/xfree86/xaa/xaaOverlayDF.c +++ b/hw/xfree86/xaa/xaaOverlayDF.c @@ -151,11 +151,10 @@ typedef struct { int (*TiledFillChooser)(GCPtr); } XAAOverlayRec, *XAAOverlayPtr; -static int XAAOverlayIndex = -1; -static unsigned long XAAOverlayGeneration = 0; +static DevPrivateKey XAAOverlayKey = &XAAOverlayKey; #define GET_OVERLAY_PRIV(pScreen) \ - ((XAAOverlayPtr)((pScreen)->devPrivates[XAAOverlayIndex].ptr)) + (XAAOverlayPtr)dixLookupPrivate(&(pScreen)->devPrivates, XAAOverlayKey) #define SWITCH_DEPTH(d) \ if(pOverPriv->currentDepth != d) { \ @@ -173,18 +172,10 @@ XAAInitDualFramebufferOverlay( XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen); XAAOverlayPtr pOverPriv; - if (XAAOverlayGeneration != serverGeneration) { - if((XAAOverlayIndex = AllocateScreenPrivateIndex()) < 0) - return FALSE; - - XAAOverlayGeneration = serverGeneration; - } - - if(!(pOverPriv = xalloc(sizeof(XAAOverlayRec)))) return FALSE; - pScreen->devPrivates[XAAOverlayIndex].ptr = (pointer)pOverPriv; + dixSetPrivate(&pScreen->devPrivates, XAAOverlayKey, pOverPriv); pOverPriv->pScrn = pScrn; pOverPriv->callback = callback; diff --git a/hw/xfree86/xaa/xaaStateChange.c b/hw/xfree86/xaa/xaaStateChange.c index 02c556b33..443bda628 100644 --- a/hw/xfree86/xaa/xaaStateChange.c +++ b/hw/xfree86/xaa/xaaStateChange.c @@ -274,18 +274,17 @@ typedef struct _XAAStateWrapRec { #endif } XAAStateWrapRec, *XAAStateWrapPtr; -static int XAAStateIndex = -1; -static unsigned long XAAStateGeneration = 0; +static DevPrivateKey XAAStateKey = &XAAStateKey; /* Wrap functions start here */ #define GET_STATEPRIV_GC(pGC) XAAStateWrapPtr pStatePriv =\ -(XAAStateWrapPtr)(pGC->pScreen->devPrivates[XAAStateIndex].ptr) +(XAAStateWrapPtr)dixLookupPrivate(&(pGC)->pScreen->devPrivates, XAAStateKey) #define GET_STATEPRIV_SCREEN(pScreen) XAAStateWrapPtr pStatePriv =\ -(XAAStateWrapPtr)(pScreen->devPrivates[XAAStateIndex].ptr) +(XAAStateWrapPtr)dixLookupPrivate(&(pScreen)->devPrivates, XAAStateKey) #define GET_STATEPRIV_PSCRN(pScrn) XAAStateWrapPtr pStatePriv =\ -(XAAStateWrapPtr)(pScrn->pScreen->devPrivates[XAAStateIndex].ptr) +(XAAStateWrapPtr)dixLookupPrivate(&(pScrn)->pScreen->devPrivates, XAAStateKey) #define STATE_CHECK_SP(pStatePriv) {\ ScrnInfoPtr pScrn = pStatePriv->pScrn;\ @@ -1504,12 +1503,8 @@ XAAInitStateWrap(ScreenPtr pScreen, XAAInfoRecPtr infoRec) XAAStateWrapPtr pStatePriv; int i = 0; - if (XAAStateGeneration != serverGeneration) { - if((XAAStateIndex = AllocateScreenPrivateIndex()) < 0) return FALSE; - XAAStateGeneration = serverGeneration; - } if(!(pStatePriv = xalloc(sizeof(XAAStateWrapRec)))) return FALSE; - pScreen->devPrivates[XAAStateIndex].ptr = (pointer)pStatePriv; + dixSetPrivate(&pScreen->devPrivates, XAAStateKey, pStatePriv); pStatePriv->RestoreAccelState = infoRec->RestoreAccelState; pStatePriv->pScrn = pScrn; diff --git a/hw/xfree86/xaa/xaaWrapper.c b/hw/xfree86/xaa/xaaWrapper.c index b0176f03f..5d6ea05cf 100644 --- a/hw/xfree86/xaa/xaaWrapper.c +++ b/hw/xfree86/xaa/xaaWrapper.c @@ -86,10 +86,8 @@ typedef struct { int depth; } xaaWrapperScrPrivRec, *xaaWrapperScrPrivPtr; -#define xaaWrapperGetScrPriv(s) ((xaaWrapperScrPrivPtr)( \ - (xaaWrapperScrPrivateIndex != -1) \ - ? (s)->devPrivates[xaaWrapperScrPrivateIndex].ptr\ - : NULL)) +#define xaaWrapperGetScrPriv(s) ((xaaWrapperScrPrivPtr) \ + dixLookupPrivate(&(s)->devPrivates, xaaWrapperScrPrivateKey)) #define xaaWrapperScrPriv(s) xaaWrapperScrPrivPtr pScrPriv = xaaWrapperGetScrPriv(s) #define wrap(priv,real,mem,func) {\ @@ -127,13 +125,12 @@ typedef struct _xaaWrapperGCPriv { } xaaWrapperGCPrivRec, *xaaWrapperGCPrivPtr; #define xaaWrapperGetGCPriv(pGC) ((xaaWrapperGCPrivPtr) \ - (pGC)->devPrivates[xaaWrapperGCPrivateIndex].ptr) + dixLookupPrivate(&(pGC)->devPrivates, xaaWrapperGCPrivateKey)) #define xaaWrapperGCPriv(pGC) xaaWrapperGCPrivPtr pGCPriv = xaaWrapperGetGCPriv(pGC) -static int xaaWrapperScrPrivateIndex = -1; -static int xaaWrapperGCPrivateIndex = -1; -static int xaaWrapperGeneration = -1; +static DevPrivateKey xaaWrapperScrPrivateKey = &xaaWrapperScrPrivateKey; +static DevPrivateKey xaaWrapperGCPrivateKey = &xaaWrapperGCPrivateKey; static Bool xaaWrapperCreateScreenResources(ScreenPtr pScreen) @@ -274,18 +271,8 @@ xaaSetupWrapper(ScreenPtr pScreen, XAAInfoRecPtr infoPtr, int depth, SyncFunc *f #ifdef RENDER PictureScreenPtr ps = GetPictureScreenIfSet(pScreen); #endif - if (xaaWrapperGeneration != serverGeneration) { - xaaWrapperScrPrivateIndex = AllocateScreenPrivateIndex (); - if (xaaWrapperScrPrivateIndex == -1) - return FALSE; - xaaWrapperGCPrivateIndex = AllocateGCPrivateIndex (); - if (xaaWrapperGCPrivateIndex == -1) - return FALSE; - xaaWrapperGeneration = serverGeneration; - } - if (!AllocateGCPrivate (pScreen, xaaWrapperGCPrivateIndex, - sizeof (xaaWrapperGCPrivRec))) + if (!dixRequestPrivate(xaaWrapperGCPrivateKey, sizeof(xaaWrapperGCPrivRec))) return FALSE; pScrPriv = (xaaWrapperScrPrivPtr) xalloc (sizeof (xaaWrapperScrPrivRec)); @@ -335,7 +322,7 @@ xaaSetupWrapper(ScreenPtr pScreen, XAAInfoRecPtr infoPtr, int depth, SyncFunc *f } #endif pScrPriv->depth = depth; - pScreen->devPrivates[xaaWrapperScrPrivateIndex].ptr = (pointer) pScrPriv; + dixSetPrivate(&pScreen->devPrivates, xaaWrapperScrPrivateKey, pScrPriv); *func = XAASync; @@ -486,8 +473,8 @@ xaaWrapperGlyphs (CARD8 op, PicturePtr pSrc, PicturePtr pDst, void XAASync(ScreenPtr pScreen) { - XAAScreenPtr pScreenPriv = - (XAAScreenPtr) pScreen->devPrivates[XAAGetScreenIndex()].ptr; + XAAScreenPtr pScreenPriv = (XAAScreenPtr) + dixLookupPrivate(&pScreen->devPrivates, XAAGetScreenKey()); XAAInfoRecPtr infoRec = pScreenPriv->AccelInfoRec; if(infoRec->NeedToSync) { diff --git a/hw/xfree86/xaa/xaalocal.h b/hw/xfree86/xaa/xaalocal.h index 686cc876d..e25b9df52 100644 --- a/hw/xfree86/xaa/xaalocal.h +++ b/hw/xfree86/xaa/xaalocal.h @@ -1629,9 +1629,9 @@ XAAGetPixelFromRGBA ( extern GCOps XAAFallbackOps; extern GCOps *XAAGetFallbackOps(void); extern GCFuncs XAAGCFuncs; -extern int XAAGetScreenIndex(void); -extern int XAAGetGCIndex(void); -extern int XAAGetPixmapIndex(void); +extern DevPrivateKey XAAGetScreenKey(void); +extern DevPrivateKey XAAGetGCKey(void); +extern DevPrivateKey XAAGetPixmapKey(void); extern unsigned int XAAShiftMasks[32]; @@ -1640,28 +1640,28 @@ extern unsigned int byte_expand3[256], byte_reversed_expand3[256]; CARD32 XAAReverseBitOrder(CARD32 data); #define GET_XAASCREENPTR_FROM_SCREEN(pScreen)\ - (pScreen)->devPrivates[XAAGetScreenIndex()].ptr + dixLookupPrivate(&(pScreen)->devPrivates, XAAGetScreenKey()) #define GET_XAASCREENPTR_FROM_GC(pGC)\ - (pGC)->pScreen->devPrivates[XAAGetScreenIndex()].ptr + dixLookupPrivate(&(pGC)->pScreen->devPrivates, XAAGetScreenKey()) #define GET_XAASCREENPTR_FROM_DRAWABLE(pDraw)\ - (pDraw)->pScreen->devPrivates[XAAGetScreenIndex()].ptr + dixLookupPrivate(&(pDraw)->pScreen->devPrivates, XAAGetScreenKey()) #define GET_XAAINFORECPTR_FROM_SCREEN(pScreen)\ - ((XAAScreenPtr)((pScreen)->devPrivates[XAAGetScreenIndex()].ptr))->AccelInfoRec +((XAAScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, XAAGetScreenKey()))->AccelInfoRec #define GET_XAAINFORECPTR_FROM_GC(pGC)\ -((XAAScreenPtr)((pGC)->pScreen->devPrivates[XAAGetScreenIndex()].ptr))->AccelInfoRec +((XAAScreenPtr)dixLookupPrivate(&(pGC)->pScreen->devPrivates, XAAGetScreenKey()))->AccelInfoRec #define GET_XAAINFORECPTR_FROM_DRAWABLE(pDraw)\ -((XAAScreenPtr)((pDraw)->pScreen->devPrivates[XAAGetScreenIndex()].ptr))->AccelInfoRec +((XAAScreenPtr)dixLookupPrivate(&(pDraw)->pScreen->devPrivates, XAAGetScreenKey()))->AccelInfoRec #define GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn)\ -((XAAScreenPtr)((pScrn)->pScreen->devPrivates[XAAGetScreenIndex()].ptr))->AccelInfoRec +((XAAScreenPtr)dixLookupPrivate(&(pScrn)->pScreen->devPrivates, XAAGetScreenKey()))->AccelInfoRec #define XAA_GET_PIXMAP_PRIVATE(pix)\ - (XAAPixmapPtr)((pix)->devPrivates[XAAGetPixmapIndex()].ptr) + (XAAPixmapPtr)dixLookupPrivate(&(pix)->devPrivates, XAAGetPixmapKey()) #define CHECK_RGB_EQUAL(c) (!((((c) >> 8) ^ (c)) & 0xffff)) diff --git a/hw/xfree86/xaa/xaawrap.h b/hw/xfree86/xaa/xaawrap.h index 32c17a60c..38c97d70b 100644 --- a/hw/xfree86/xaa/xaawrap.h +++ b/hw/xfree86/xaa/xaawrap.h @@ -1,14 +1,14 @@ #define XAA_SCREEN_PROLOGUE(pScreen, field)\ ((pScreen)->field = \ - ((XAAScreenPtr) (pScreen)->devPrivates[XAAGetScreenIndex()].ptr)->field) + ((XAAScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, XAAGetScreenKey()))->field) #define XAA_SCREEN_EPILOGUE(pScreen, field, wrapper)\ ((pScreen)->field = wrapper) #define XAA_GC_FUNC_PROLOGUE(pGC)\ - XAAGCPtr pGCPriv = (XAAGCPtr) (pGC)->devPrivates[XAAGetGCIndex()].ptr;\ + XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&(pGC)->devPrivates, XAAGetGCKey()); \ (pGC)->funcs = pGCPriv->wrapFuncs;\ if(pGCPriv->flags)\ (pGC)->ops = pGCPriv->wrapOps @@ -24,13 +24,13 @@ #define XAA_GC_OP_PROLOGUE(pGC)\ - XAAGCPtr pGCPriv = (XAAGCPtr)(pGC->devPrivates[XAAGetGCIndex()].ptr);\ + XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&(pGC)->devPrivates, XAAGetGCKey()); \ GCFuncs *oldFuncs = pGC->funcs;\ pGC->funcs = pGCPriv->wrapFuncs;\ pGC->ops = pGCPriv->wrapOps #define XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC)\ - XAAGCPtr pGCPriv = (XAAGCPtr)(pGC->devPrivates[XAAGetGCIndex()].ptr);\ + XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&(pGC)->devPrivates, XAAGetGCKey()); \ GCFuncs *oldFuncs = pGC->funcs;\ if(!REGION_NUM_RECTS(pGC->pCompositeClip)) return; \ pGC->funcs = pGCPriv->wrapFuncs;\ @@ -44,7 +44,7 @@ #define XAA_PIXMAP_OP_PROLOGUE(pGC, pDraw)\ - XAAGCPtr pGCPriv = (XAAGCPtr)(pGC->devPrivates[XAAGetGCIndex()].ptr);\ + XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&(pGC)->devPrivates, XAAGetGCKey()); \ XAAPixmapPtr pixPriv = XAA_GET_PIXMAP_PRIVATE((PixmapPtr)(pDraw));\ GCFuncs *oldFuncs = pGC->funcs;\ pGC->funcs = pGCPriv->wrapFuncs;\ @@ -64,7 +64,7 @@ #ifdef RENDER #define XAA_RENDER_PROLOGUE(pScreen,field)\ (GetPictureScreen(pScreen)->field = \ - ((XAAScreenPtr) (pScreen)->devPrivates[XAAGetScreenIndex()].ptr)->field) + ((XAAScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, XAAGetScreenKey()))->field) #define XAA_RENDER_EPILOGUE(pScreen, field, wrapper)\ (GetPictureScreen(pScreen)->field = wrapper) @@ -74,7 +74,7 @@ #define SYNC_CHECK(pGC) {\ XAAInfoRecPtr infoRec =\ -((XAAScreenPtr)((pGC)->pScreen->devPrivates[XAAGetScreenIndex()].ptr))->AccelInfoRec;\ +((XAAScreenPtr)dixLookupPrivate(&(pGC)->pScreen->devPrivates, XAAGetScreenKey()))->AccelInfoRec; \ if(infoRec->NeedToSync) {\ (*infoRec->Sync)(infoRec->pScrn);\ infoRec->NeedToSync = FALSE;\ diff --git a/hw/xfree86/xf4bpp/mfbfillarc.c b/hw/xfree86/xf4bpp/mfbfillarc.c index d5b5372f5..89aeadd2b 100644 --- a/hw/xfree86/xf4bpp/mfbfillarc.c +++ b/hw/xfree86/xf4bpp/mfbfillarc.c @@ -253,7 +253,8 @@ xf4bppPolyFillArcSolid mfbPrivGC *priv; int rop; - priv = (mfbPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr; + priv = (mfbPrivGC *)dixLookupPrivate(&pGC->devPrivates, + mfbGetGCPrivateKey()); rop = priv->rop; if ((rop == RROP_NOP) || !(pGC->planemask & 1)) #else diff --git a/hw/xfree86/xf4bpp/mfbimggblt.c b/hw/xfree86/xf4bpp/mfbimggblt.c index bf53f4ce9..711a16ee5 100644 --- a/hw/xfree86/xf4bpp/mfbimggblt.c +++ b/hw/xfree86/xf4bpp/mfbimggblt.c @@ -149,7 +149,8 @@ xf4bppImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase) backrect.height = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font); - pPrivGC = pGC->devPrivates[mfbGetGCPrivateIndex()].ptr; + pPrivGC = (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, + mfbGetGCPrivateKey()); oldfillStyle = pPrivGC->colorRrop.fillStyle; /* GJA */ oldfg = pPrivGC->colorRrop.fgPixel; /* GJA */ oldalu = pPrivGC->colorRrop.alu; /* GJA */ diff --git a/hw/xfree86/xf4bpp/mfbzerarc.c b/hw/xfree86/xf4bpp/mfbzerarc.c index c7a8c4d56..61fc7b184 100644 --- a/hw/xfree86/xf4bpp/mfbzerarc.c +++ b/hw/xfree86/xf4bpp/mfbzerarc.c @@ -108,7 +108,8 @@ v16ZeroArcSS int pmask; register int *paddr; - if (((mfbPrivGC *)(pGC->devPrivates[mfbGetGCPrivateIndex()].ptr))->rop == + if (((mfbPrivGC *)dixLookupPrivate(&pGC->devPrivates, + mfbGetGCPrivateKey()))->rop == RROP_BLACK) pixel = 0; else diff --git a/hw/xfree86/xf4bpp/ppcArea.c b/hw/xfree86/xf4bpp/ppcArea.c index e95696260..df7856a35 100644 --- a/hw/xfree86/xf4bpp/ppcArea.c +++ b/hw/xfree86/xf4bpp/ppcArea.c @@ -49,7 +49,7 @@ int alu ; unsigned long int fg, bg, pm ; int xSrc, ySrc ; PixmapPtr pPixmap ; -ppcPrivGC *pPrivGC = pGC->devPrivates[mfbGetGCPrivateIndex()].ptr; +ppcPrivGC *pPrivGC = dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()); TRACE( ( "xf4bppFillArea(0x%x,%d,0x%x,0x%x)\n", pWin, nboxes, pBox, pGC ) ) ; diff --git a/hw/xfree86/xf4bpp/ppcGC.c b/hw/xfree86/xf4bpp/ppcGC.c index 674a38b78..7ef312d39 100644 --- a/hw/xfree86/xf4bpp/ppcGC.c +++ b/hw/xfree86/xf4bpp/ppcGC.c @@ -182,7 +182,7 @@ register GCPtr pGC ; * a pointer to a ppcPrivGC in its slot. */ *pPriv = vgaPrototypeGCPriv; - (pGC->devPrivates[mfbGetGCPrivateIndex()].ptr) = (pointer) pPriv; + dixSetPrivate(&pGC->devPrivates, mfbGetGCPrivateKey(), pPriv); /* Set the vgaGCOps */ *pOps = vgaGCOps; @@ -202,7 +202,7 @@ xf4bppDestroyGC( pGC ) if ( pGC->freeCompClip && pGC->pCompositeClip ) REGION_DESTROY(pGC->pScreen, pGC->pCompositeClip); if(pGC->ops->devPrivate.val) xfree( pGC->ops ); - xfree( pGC->devPrivates[mfbGetGCPrivateIndex()].ptr ) ; + xfree(dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey())); return ; } @@ -213,7 +213,7 @@ ppcChangePixmapGC register Mask changes ) { -register ppcPrivGCPtr devPriv = (ppcPrivGCPtr) (pGC->devPrivates[mfbGetGCPrivateIndex()].ptr ) ; +register ppcPrivGCPtr devPriv = (ppcPrivGCPtr)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()); register unsigned long int idx ; /* used for stepping through bitfields */ #define LOWBIT( x ) ( x & - x ) /* Two's complement */ @@ -291,8 +291,8 @@ xf4bppValidateGC( pGC, changes, pDrawable ) register ppcPrivGCPtr devPriv ; WindowPtr pWin ; - devPriv = (ppcPrivGCPtr) (pGC->devPrivates[mfbGetGCPrivateIndex()].ptr ) ; - + devPriv = (ppcPrivGCPtr)dixLookupPrivate(&pGC->devPrivates, + mfbGetGCPrivateKey()); if ( pDrawable->type != devPriv->lastDrawableType ) { devPriv->lastDrawableType = pDrawable->type ; xf4bppChangeGCtype( pGC, devPriv ) ; diff --git a/hw/xfree86/xf4bpp/ppcPixFS.c b/hw/xfree86/xf4bpp/ppcPixFS.c index f24168bb0..91b753255 100644 --- a/hw/xfree86/xf4bpp/ppcPixFS.c +++ b/hw/xfree86/xf4bpp/ppcPixFS.c @@ -124,7 +124,7 @@ xf4bppSolidPixmapFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) return ; } - if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.alu ) == GXnoop ) + if ( ( alu = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()))->colorRrop.alu ) == GXnoop ) return ; n = nInit * miFindMaxBand(pGC->pCompositeClip) ; @@ -142,8 +142,8 @@ xf4bppSolidPixmapFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) n = miClipSpans( pGC->pCompositeClip, pptInit, pwidthInit, nInit, ppt, pwidth, fSorted ) ; - pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.planemask ; - fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.fgPixel ; + pm = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.planemask ; + fg = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.fgPixel ; npm = ( ~ pm ) & ( ( 1 << pDrawable->depth ) - 1 ) ; for ( ; n-- ; ppt++, pwidth++ ) { @@ -258,14 +258,14 @@ int fSorted ; return ; } - if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.alu ) == GXnoop ) + if ( ( alu = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.alu ) == GXnoop ) return ; SETSPANPTRS( nInit, n, pwidthInit, pwidthFree, pptInit, pptFree, pwidth, ppt, fSorted ) ; - pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.planemask ; - fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.fgPixel ; + pm = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.planemask ; + fg = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.fgPixel ; pTile = pGC->stipple ; tlwidth = pTile->devKind ; @@ -356,15 +356,15 @@ int fSorted ; return ; } - if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.alu ) == GXnoop ) + if ( ( alu = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.alu ) == GXnoop ) return ; SETSPANPTRS( nInit, n, pwidthInit, pwidthFree, pptInit, pptFree, pwidth, ppt, fSorted ) ; - fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.fgPixel ; - bg = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.bgPixel ; - pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.planemask ; + fg = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.fgPixel ; + bg = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.bgPixel ; + pm = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.planemask ; npm = ( ~ pm ) & ( ( 1 << pDrawable->depth ) - 1 ) ; pTile = pGC->stipple ; @@ -459,14 +459,14 @@ int fSorted ; return ; } - if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.alu ) == GXnoop ) + if ( ( alu = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.alu ) == GXnoop ) return ; SETSPANPTRS( nInit, n, pwidthInit, pwidthFree, pptInit, pptFree, pwidth, ppt, fSorted ) ; /* the following code is for 8 bits per pixel addressable memory only */ - pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.planemask ; + pm = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.planemask ; npm = ( ~ pm ) & ( ( 1 << pDrawable->depth ) - 1 ) ; pTile = pGC->tile.pixmap ; tileWidth = pTile->drawable.width ; diff --git a/hw/xfree86/xf4bpp/ppcPixmap.c b/hw/xfree86/xf4bpp/ppcPixmap.c index ec181cfaf..2079e2ee6 100644 --- a/hw/xfree86/xf4bpp/ppcPixmap.c +++ b/hw/xfree86/xf4bpp/ppcPixmap.c @@ -137,6 +137,7 @@ xf4bppCopyPixmap(pSrc) pDst = xalloc(sizeof(PixmapRec) + size); if (!pDst) return NullPixmap; + pDst->devPrivates = NULL; pDst->drawable = pSrc->drawable; pDst->drawable.id = 0; pDst->drawable.serialNumber = NEXT_SERIAL_NUMBER; diff --git a/hw/xfree86/xf4bpp/ppcPolyPnt.c b/hw/xfree86/xf4bpp/ppcPolyPnt.c index 1d6905563..c61fd6d26 100644 --- a/hw/xfree86/xf4bpp/ppcPolyPnt.c +++ b/hw/xfree86/xf4bpp/ppcPolyPnt.c @@ -102,7 +102,7 @@ if ( pDrawable->type == DRAWABLE_PIXMAP ) { return ; } -devPriv = (ppcPrivGC *) ( pGC->devPrivates[mfbGetGCPrivateIndex()].ptr ) ; +devPriv = (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()); if ( ( alu = devPriv->colorRrop.alu ) == GXnoop ) return ; diff --git a/hw/xfree86/xf4bpp/ppcWinFS.c b/hw/xfree86/xf4bpp/ppcWinFS.c index e19ce0d40..982bf424c 100644 --- a/hw/xfree86/xf4bpp/ppcWinFS.c +++ b/hw/xfree86/xf4bpp/ppcWinFS.c @@ -96,7 +96,7 @@ xf4bppSolidWindowFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) return ; } - if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.alu ) == GXnoop ) + if ( ( alu = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.alu ) == GXnoop ) return ; n = nInit * miFindMaxBand( pGC->pCompositeClip ) ; @@ -114,8 +114,8 @@ xf4bppSolidWindowFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) n = miClipSpans( pGC->pCompositeClip, pptInit, pwidthInit, nInit, ppt, pwidth, fSorted ) ; - pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.planemask ; - fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.fgPixel ; + pm = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.planemask ; + fg = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.fgPixel ; for ( ; n-- ; ppt++, pwidth++ ) if ( *pwidth ) @@ -163,14 +163,14 @@ int fSorted ; return ; } - if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.alu ) == GXnoop ) + if ( ( alu = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.alu ) == GXnoop ) return ; SETSPANPTRS( nInit, n, pwidthInit, pwidthFree, pptInit, pptFree, pwidth, ppt, fSorted ) ; - pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.planemask ; - fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.fgPixel ; + pm = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.planemask ; + fg = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.fgPixel ; xSrc = pGC->patOrg.x + pDrawable->x ; ySrc = pGC->patOrg.y + pDrawable->y ; @@ -215,15 +215,15 @@ int fSorted ; return ; } - if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.alu ) == GXnoop ) + if ( ( alu = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.alu ) == GXnoop ) return ; SETSPANPTRS( nInit, n, pwidthInit, pwidthFree, pptInit, pptFree, pwidth, ppt, fSorted ) ; - pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.planemask ; - fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.fgPixel ; - bg = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.bgPixel ; + pm = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.planemask ; + fg = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.fgPixel ; + bg = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.bgPixel ; xSrc = pGC->patOrg.x + pDrawable->x ; ySrc = pGC->patOrg.y + pDrawable->y ; @@ -260,7 +260,7 @@ int fSorted ; TRACE( ( "xf4bppTileWindowFS(pDrawable=0x%x,pGC=0x%x,nInit=%d,pptInit=0x%x,pwidthInit=0x%x,fSorted=%d)\n", pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) ) ; - if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.alu ) == GXnoop ) + if ( ( alu = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.alu ) == GXnoop ) return ; SETSPANPTRS( nInit, n, pwidthInit, pwidthFree, pptInit, @@ -268,7 +268,7 @@ int fSorted ; xSrc = pGC->patOrg.x + pDrawable->x ; ySrc = pGC->patOrg.y + pDrawable->y ; - pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.planemask ; + pm = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.planemask ; for ( ; n-- ; ppt++, pwidth++ ) xf4bppTileRect( (WindowPtr)pDrawable, pGC->tile.pixmap, alu, pm, diff --git a/hw/xfree86/xf4bpp/vgaGC.c b/hw/xfree86/xf4bpp/vgaGC.c index 5a8604090..6495e5638 100644 --- a/hw/xfree86/xf4bpp/vgaGC.c +++ b/hw/xfree86/xf4bpp/vgaGC.c @@ -107,7 +107,7 @@ xf4bppChangeWindowGC( pGC, changes ) register GC *pGC ; register Mask changes ; { -register ppcPrivGCPtr devPriv = (ppcPrivGCPtr) (pGC->devPrivates[mfbGetGCPrivateIndex()].ptr) ; +register ppcPrivGCPtr devPriv = (ppcPrivGCPtr)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()); register unsigned long int idx ; /* used for stepping through bitfields */ #define LOWBIT( x ) ( x & - x ) /* Two's complement */ diff --git a/hw/xfree86/xf8_32bpp/cfb8_32.h b/hw/xfree86/xf8_32bpp/cfb8_32.h index e14096568..6e985da20 100644 --- a/hw/xfree86/xf8_32bpp/cfb8_32.h +++ b/hw/xfree86/xf8_32bpp/cfb8_32.h @@ -22,10 +22,8 @@ typedef struct { } cfb8_32ScreenRec, *cfb8_32ScreenPtr; -extern int cfb8_32GCPrivateIndex; /* XXX */ -extern int cfb8_32GetGCPrivateIndex(void); -extern int cfb8_32ScreenPrivateIndex; /* XXX */ -extern int cfb8_32GetScreenPrivateIndex(void); +extern DevPrivateKey cfb8_32GetGCPrivateKey(void); +extern DevPrivateKey cfb8_32GetScreenPrivateKey(void); RegionPtr cfb8_32CopyArea( @@ -182,11 +180,11 @@ cfb8_32ChangeWindowAttributes( ); -#define CFB8_32_GET_GC_PRIVATE(pGC)\ - (cfb8_32GCPtr)((pGC)->devPrivates[cfb8_32GetGCPrivateIndex()].ptr) +#define CFB8_32_GET_GC_PRIVATE(pGC) ((cfb8_32GCPtr) \ + dixLookupPrivate(&(pGC)->devPrivates, cfb8_32GetGCPrivateKey())) -#define CFB8_32_GET_SCREEN_PRIVATE(pScreen)\ - (cfb8_32ScreenPtr)((pScreen)->devPrivates[cfb8_32GetScreenPrivateIndex()].ptr) +#define CFB8_32_GET_SCREEN_PRIVATE(pScreen) ((cfb8_32ScreenPtr) \ + dixLookupPrivate(&(pScreen)->devPrivates, cfb8_32GetScreenPrivateKey())) Bool xf86Overlay8Plus32Init (ScreenPtr pScreen); diff --git a/hw/xfree86/xf8_32bpp/cfbscrinit.c b/hw/xfree86/xf8_32bpp/cfbscrinit.c index 5e2657f2b..c3432b803 100644 --- a/hw/xfree86/xf8_32bpp/cfbscrinit.c +++ b/hw/xfree86/xf8_32bpp/cfbscrinit.c @@ -31,38 +31,37 @@ /* CAUTION: We require that cfb8 and cfb32 were NOT compiled with CFB_NEED_SCREEN_PRIVATE */ -int cfb8_32GCPrivateIndex; -int cfb8_32GetGCPrivateIndex(void) { return cfb8_32GCPrivateIndex; } -int cfb8_32ScreenPrivateIndex; -int cfb8_32GetScreenPrivateIndex(void) { return cfb8_32ScreenPrivateIndex; } -static unsigned long cfb8_32Generation = 0; +static DevPrivateKey cfb8_32GCPrivateKey = &cfb8_32GCPrivateKey; +DevPrivateKey cfb8_32GetGCPrivateKey(void) +{ + return cfb8_32GCPrivateKey; +} + +static DevPrivateKey cfb8_32ScreenPrivateKey = &cfb8_32ScreenPrivateKey; +DevPrivateKey cfb8_32GetScreenPrivateKey(void) +{ + return cfb8_32ScreenPrivateKey; +} static Bool cfb8_32AllocatePrivates(ScreenPtr pScreen) { cfb8_32ScreenPtr pScreenPriv; - if(cfb8_32Generation != serverGeneration) { - if(((cfb8_32GCPrivateIndex = AllocateGCPrivateIndex()) < 0) || - ((cfb8_32ScreenPrivateIndex = AllocateScreenPrivateIndex()) < 0)) - return FALSE; - cfb8_32Generation = serverGeneration; - } - if (!(pScreenPriv = xalloc(sizeof(cfb8_32ScreenRec)))) return FALSE; - pScreen->devPrivates[cfb8_32ScreenPrivateIndex].ptr = (pointer)pScreenPriv; + dixSetPrivate(&pScreen->devPrivates, cfb8_32ScreenPrivateKey, pScreenPriv); /* All cfb will have the same GC and Window private indicies */ - if(!mfbAllocatePrivates(pScreen, &cfbGCPrivateIndex)) + if(!mfbAllocatePrivates(pScreen, &cfbGCPrivateKey)) return FALSE; - if(!AllocateGCPrivate(pScreen, cfbGCPrivateIndex, sizeof(cfbPrivGC))) + if(!dixRequestPrivate(cfbGCPrivateKey, sizeof(cfbPrivGC))) return FALSE; - if(!AllocateGCPrivate(pScreen, cfb8_32GCPrivateIndex, sizeof(cfb8_32GCRec))) + if(!dixRequestPrivate(cfb8_32GCPrivateKey, sizeof(cfb8_32GCRec))) return FALSE; return TRUE; @@ -160,7 +159,7 @@ cfb8_32CloseScreen (int i, ScreenPtr pScreen) xfree(pScreenPriv->visualData); xfree((pointer) pScreenPriv); - pScreen->devPrivates[cfb8_32ScreenPrivateIndex].ptr = NULL; + dixSetPrivate(&pScreen->devPrivates, cfb8_32ScreenPrivateKey, NULL); return(cfb32CloseScreen(i, pScreen)); } diff --git a/hw/xfree86/xf8_32bpp/xf86overlay.c b/hw/xfree86/xf8_32bpp/xf86overlay.c index 3cd351ad0..700c71ada 100644 --- a/hw/xfree86/xf8_32bpp/xf86overlay.c +++ b/hw/xfree86/xf8_32bpp/xf86overlay.c @@ -177,23 +177,22 @@ typedef struct { } OverlayPixmapRec, *OverlayPixmapPtr; -static int OverlayScreenIndex = -1; -static int OverlayGCIndex = -1; -static int OverlayPixmapIndex = -1; -static unsigned long OverlayGeneration = 0; +static DevPrivateKey OverlayScreenKey = &OverlayScreenKey; +static DevPrivateKey OverlayGCKey = &OverlayGCKey; +static DevPrivateKey OverlayPixmapKey = &OverlayPixmapKey; /** Macros **/ #define TILE_EXISTS(pGC) (!(pGC)->tileIsPixel && (pGC)->tile.pixmap) -#define OVERLAY_GET_PIXMAP_PRIVATE(pPix) \ - (OverlayPixmapPtr)((pPix)->devPrivates[OverlayPixmapIndex].ptr) +#define OVERLAY_GET_PIXMAP_PRIVATE(pPix) ((OverlayPixmapPtr) \ + dixLookupPrivate(&(pPix)->devPrivates, OverlayPixmapKey)) -#define OVERLAY_GET_SCREEN_PRIVATE(pScreen) \ - (OverlayScreenPtr)((pScreen)->devPrivates[OverlayScreenIndex].ptr) +#define OVERLAY_GET_SCREEN_PRIVATE(pScreen) ((OverlayScreenPtr) \ + dixLookupPrivate(&(pScreen)->devPrivates, OverlayScreenKey)) -#define OVERLAY_GET_GC_PRIVATE(pGC) \ - (OverlayGCPtr)((pGC)->devPrivates[OverlayGCIndex].ptr) +#define OVERLAY_GET_GC_PRIVATE(pGC) ((OverlayGCPtr) \ + dixLookupPrivate(&(pGC)->devPrivates, OverlayGCKey)) #define OVERLAY_GC_FUNC_PROLOGUE(pGC)\ OverlayGCPtr pGCPriv = OVERLAY_GET_GC_PRIVATE(pGC);\ @@ -255,26 +254,16 @@ xf86Overlay8Plus32Init (ScreenPtr pScreen) { OverlayScreenPtr pScreenPriv; - if(OverlayGeneration != serverGeneration) { - if(((OverlayScreenIndex = AllocateScreenPrivateIndex()) < 0) || - ((OverlayGCIndex = AllocateGCPrivateIndex()) < 0) || - ((OverlayPixmapIndex = AllocatePixmapPrivateIndex()) < 0)) - return FALSE; - - OverlayGeneration = serverGeneration; - } - - if (!AllocateGCPrivate(pScreen, OverlayGCIndex, sizeof(OverlayGCRec))) + if (!dixRequestPrivate(OverlayGCKey, sizeof(OverlayGCRec))) return FALSE; - if (!AllocatePixmapPrivate(pScreen, OverlayPixmapIndex, - sizeof(OverlayPixmapRec))) + if (!dixRequestPrivate(OverlayPixmapKey, sizeof(OverlayPixmapRec))) return FALSE; if (!(pScreenPriv = xalloc(sizeof(OverlayScreenRec)))) return FALSE; - pScreen->devPrivates[OverlayScreenIndex].ptr = (pointer)pScreenPriv; + dixSetPrivate(&pScreen->devPrivates, OverlayScreenKey, pScreenPriv); pScreenPriv->CreateGC = pScreen->CreateGC; pScreenPriv->CloseScreen = pScreen->CloseScreen; |