[PATCH 1/5] dix: Extract blockhandler.c from within dixutils.c

Fernando Carrijo fcarrijo at yahoo.com.br
Tue Jul 27 22:42:19 PDT 2010


The file dixutils.c has grown into an incohesive and bloated beast. The time has
come to refactor some of its routines to their own files. This patch gives a new
home for all of those which deal with block and wake up handlers.
---
 dix/Makefile.am    |    1 +
 dix/blockhandler.c |  243 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 dix/dixutils.c     |  144 -------------------------------
 3 files changed, 244 insertions(+), 144 deletions(-)
 create mode 100644 dix/blockhandler.c

diff --git a/dix/Makefile.am b/dix/Makefile.am
index 5e2dad7..8164a34 100644
--- a/dix/Makefile.am
+++ b/dix/Makefile.am
@@ -7,6 +7,7 @@ libmain_la_SOURCES =    \
 
 libdix_la_SOURCES = 	\
 	atom.c		\
+	blockhandler.c	\
 	colormap.c	\
 	cursor.c	\
 	deprecated.c	\
diff --git a/dix/blockhandler.c b/dix/blockhandler.c
new file mode 100644
index 0000000..3a55600
--- /dev/null
+++ b/dix/blockhandler.c
@@ -0,0 +1,243 @@
+/***********************************************************
+
+Copyright 1987, 1998  The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+                        All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its 
+documentation for any purpose and without fee is hereby granted, 
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in 
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.  
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/*
+
+(c)Copyright 1988,1991 Adobe Systems Incorporated. All rights reserved.
+
+Permission to use, copy, modify, distribute, and sublicense this software and its
+documentation for any purpose and without fee is hereby granted, provided that
+the above copyright notices appear in all copies and that both those copyright
+notices and this permission notice appear in supporting documentation and that
+the name of Adobe Systems Incorporated not be used in advertising or publicity
+pertaining to distribution of the software without specific, written prior
+permission.  No trademark license to use the Adobe trademarks is hereby
+granted.  If the Adobe trademark "Display PostScript"(tm) is used to describe
+this software, its functionality or for any other purpose, such use shall be
+limited to a statement that this software works in conjunction with the Display
+PostScript system.  Proper trademark attribution to reflect Adobe's ownership
+of the trademark shall be given whenever any such reference to the Display
+PostScript system is made.
+
+ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR ANY
+PURPOSE.  IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.  ADOBE
+DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-
+INFRINGEMENT OF THIRD PARTY RIGHTS.  IN NO EVENT SHALL ADOBE BE LIABLE TO YOU
+OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
+DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,NEGLIGENCE, STRICT
+LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+PERFORMANCE OF THIS SOFTWARE.  ADOBE WILL NOT PROVIDE ANY TRAINING OR OTHER
+SUPPORT FOR THE SOFTWARE.
+
+Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
+Incorporated which may be registered in certain jurisdictions.
+
+Author:  Adobe Systems Incorporated
+
+*/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include "misc.h"
+#include "windowstr.h"
+#include "dixstruct.h"
+#include "pixmapstr.h"
+#include "gcstruct.h"
+#include "scrnintstr.h"
+#define  XK_LATIN1
+#include <X11/keysymdef.h>
+#include "xace.h"
+
+typedef struct _BlockHandler {
+    BlockHandlerProcPtr BlockHandler;
+    WakeupHandlerProcPtr WakeupHandler;
+    pointer blockData;
+    Bool    deleted;
+} BlockHandlerRec, *BlockHandlerPtr;
+
+static BlockHandlerPtr	handlers;
+static int		numHandlers;
+static int		sizeHandlers;
+static Bool		inHandler;
+static Bool		handlerDeleted;
+
+/**
+ * 
+ *  \param pTimeout   DIX doesn't want to know how OS represents time
+ *  \param pReadMask  nor how it represents the det of descriptors
+ */
+void
+BlockHandler(pointer pTimeout, pointer pReadmask)
+{
+    int i, j;
+    
+    ++inHandler;
+    for (i = 0; i < screenInfo.numScreens; i++)
+	(* screenInfo.screens[i]->BlockHandler)(i, 
+				screenInfo.screens[i]->blockData,
+				pTimeout, pReadmask);
+    for (i = 0; i < numHandlers; i++)
+	(*handlers[i].BlockHandler) (handlers[i].blockData,
+				     pTimeout, pReadmask);
+    if (handlerDeleted)
+    {
+	for (i = 0; i < numHandlers;)
+	    if (handlers[i].deleted)
+	    {
+	    	for (j = i; j < numHandlers - 1; j++)
+		    handlers[j] = handlers[j+1];
+	    	numHandlers--;
+	    }
+	    else
+		i++;
+	handlerDeleted = FALSE;
+    }
+    --inHandler;
+}
+
+/**
+ *
+ *  \param result    32 bits of undefined result from the wait
+ *  \param pReadmask the resulting descriptor mask
+ */
+void
+WakeupHandler(int result, pointer pReadmask)
+{
+    int i, j;
+
+    ++inHandler;
+    for (i = numHandlers - 1; i >= 0; i--)
+	(*handlers[i].WakeupHandler) (handlers[i].blockData,
+				      result, pReadmask);
+    for (i = 0; i < screenInfo.numScreens; i++)
+	(* screenInfo.screens[i]->WakeupHandler)(i, 
+				screenInfo.screens[i]->wakeupData,
+				result, pReadmask);
+    if (handlerDeleted)
+    {
+	for (i = 0; i < numHandlers;)
+	    if (handlers[i].deleted)
+	    {
+	    	for (j = i; j < numHandlers - 1; j++)
+		    handlers[j] = handlers[j+1];
+	    	numHandlers--;
+	    }
+	    else
+		i++;
+	handlerDeleted = FALSE;
+    }
+    --inHandler;
+}
+
+/**
+ * Reentrant with BlockHandler and WakeupHandler, except wakeup won't
+ * get called until next time
+ */
+Bool
+RegisterBlockAndWakeupHandlers (BlockHandlerProcPtr blockHandler, 
+                                WakeupHandlerProcPtr wakeupHandler, 
+                                pointer blockData)
+{
+    BlockHandlerPtr new;
+
+    if (numHandlers >= sizeHandlers)
+    {
+        new = (BlockHandlerPtr) realloc(handlers, (numHandlers + 1) *
+				      	  sizeof (BlockHandlerRec));
+    	if (!new)
+	    return FALSE;
+    	handlers = new;
+	sizeHandlers = numHandlers + 1;
+    }
+    handlers[numHandlers].BlockHandler = blockHandler;
+    handlers[numHandlers].WakeupHandler = wakeupHandler;
+    handlers[numHandlers].blockData = blockData;
+    handlers[numHandlers].deleted = FALSE;
+    numHandlers = numHandlers + 1;
+    return TRUE;
+}
+
+void
+RemoveBlockAndWakeupHandlers (BlockHandlerProcPtr blockHandler, 
+                              WakeupHandlerProcPtr wakeupHandler, 
+                              pointer blockData)
+{
+    int	    i;
+
+    for (i = 0; i < numHandlers; i++)
+	if (handlers[i].BlockHandler == blockHandler &&
+	    handlers[i].WakeupHandler == wakeupHandler &&
+	    handlers[i].blockData == blockData)
+	{
+	    if (inHandler)
+	    {
+		handlerDeleted = TRUE;
+		handlers[i].deleted = TRUE;
+	    }
+	    else
+	    {
+	    	for (; i < numHandlers - 1; i++)
+		    handlers[i] = handlers[i+1];
+	    	numHandlers--;
+	    }
+	    break;
+	}
+}
+
+void
+InitBlockAndWakeupHandlers (void)
+{
+    free(handlers);
+    handlers = (BlockHandlerPtr) 0;
+    numHandlers = 0;
+    sizeHandlers = 0;
+}
diff --git a/dix/dixutils.c b/dix/dixutils.c
index 470bb5d..9ce63e2 100644
--- a/dix/dixutils.c
+++ b/dix/dixutils.c
@@ -357,150 +357,6 @@ NoopDDA(void)
 {
 }
 
-typedef struct _BlockHandler {
-    BlockHandlerProcPtr BlockHandler;
-    WakeupHandlerProcPtr WakeupHandler;
-    pointer blockData;
-    Bool    deleted;
-} BlockHandlerRec, *BlockHandlerPtr;
-
-static BlockHandlerPtr	handlers;
-static int		numHandlers;
-static int		sizeHandlers;
-static Bool		inHandler;
-static Bool		handlerDeleted;
-
-/**
- * 
- *  \param pTimeout   DIX doesn't want to know how OS represents time
- *  \param pReadMask  nor how it represents the det of descriptors
- */
-void
-BlockHandler(pointer pTimeout, pointer pReadmask)
-{
-    int i, j;
-    
-    ++inHandler;
-    for (i = 0; i < screenInfo.numScreens; i++)
-	(* screenInfo.screens[i]->BlockHandler)(i, 
-				screenInfo.screens[i]->blockData,
-				pTimeout, pReadmask);
-    for (i = 0; i < numHandlers; i++)
-	(*handlers[i].BlockHandler) (handlers[i].blockData,
-				     pTimeout, pReadmask);
-    if (handlerDeleted)
-    {
-	for (i = 0; i < numHandlers;)
-	    if (handlers[i].deleted)
-	    {
-	    	for (j = i; j < numHandlers - 1; j++)
-		    handlers[j] = handlers[j+1];
-	    	numHandlers--;
-	    }
-	    else
-		i++;
-	handlerDeleted = FALSE;
-    }
-    --inHandler;
-}
-
-/**
- *
- *  \param result    32 bits of undefined result from the wait
- *  \param pReadmask the resulting descriptor mask
- */
-void
-WakeupHandler(int result, pointer pReadmask)
-{
-    int i, j;
-
-    ++inHandler;
-    for (i = numHandlers - 1; i >= 0; i--)
-	(*handlers[i].WakeupHandler) (handlers[i].blockData,
-				      result, pReadmask);
-    for (i = 0; i < screenInfo.numScreens; i++)
-	(* screenInfo.screens[i]->WakeupHandler)(i, 
-				screenInfo.screens[i]->wakeupData,
-				result, pReadmask);
-    if (handlerDeleted)
-    {
-	for (i = 0; i < numHandlers;)
-	    if (handlers[i].deleted)
-	    {
-	    	for (j = i; j < numHandlers - 1; j++)
-		    handlers[j] = handlers[j+1];
-	    	numHandlers--;
-	    }
-	    else
-		i++;
-	handlerDeleted = FALSE;
-    }
-    --inHandler;
-}
-
-/**
- * Reentrant with BlockHandler and WakeupHandler, except wakeup won't
- * get called until next time
- */
-Bool
-RegisterBlockAndWakeupHandlers (BlockHandlerProcPtr blockHandler, 
-                                WakeupHandlerProcPtr wakeupHandler, 
-                                pointer blockData)
-{
-    BlockHandlerPtr new;
-
-    if (numHandlers >= sizeHandlers)
-    {
-        new = (BlockHandlerPtr) realloc(handlers, (numHandlers + 1) *
-				      	  sizeof (BlockHandlerRec));
-    	if (!new)
-	    return FALSE;
-    	handlers = new;
-	sizeHandlers = numHandlers + 1;
-    }
-    handlers[numHandlers].BlockHandler = blockHandler;
-    handlers[numHandlers].WakeupHandler = wakeupHandler;
-    handlers[numHandlers].blockData = blockData;
-    handlers[numHandlers].deleted = FALSE;
-    numHandlers = numHandlers + 1;
-    return TRUE;
-}
-
-void
-RemoveBlockAndWakeupHandlers (BlockHandlerProcPtr blockHandler, 
-                              WakeupHandlerProcPtr wakeupHandler, 
-                              pointer blockData)
-{
-    int	    i;
-
-    for (i = 0; i < numHandlers; i++)
-	if (handlers[i].BlockHandler == blockHandler &&
-	    handlers[i].WakeupHandler == wakeupHandler &&
-	    handlers[i].blockData == blockData)
-	{
-	    if (inHandler)
-	    {
-		handlerDeleted = TRUE;
-		handlers[i].deleted = TRUE;
-	    }
-	    else
-	    {
-	    	for (; i < numHandlers - 1; i++)
-		    handlers[i] = handlers[i+1];
-	    	numHandlers--;
-	    }
-	    break;
-	}
-}
-
-void
-InitBlockAndWakeupHandlers (void)
-{
-    free(handlers);
-    handlers = (BlockHandlerPtr) 0;
-    numHandlers = 0;
-    sizeHandlers = 0;
-}
 
 /*
  * A general work queue.  Perform some task before the server
-- 
1.7.0.4




More information about the xorg-devel mailing list