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

Fernando Carrijo fcarrijo at yahoo.com.br
Fri Jul 30 14:16:44 PDT 2010


Signed-off-by: Fernando Carrijo <fcarrijo at yahoo.com.br>
---
 dix/Makefile.am    |    1 +
 dix/blockhandler.c |  233 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 dix/dixutils.c     |  145 --------------------------------
 include/dix.h      |    1 +
 4 files changed, 235 insertions(+), 145 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..edcb790
--- /dev/null
+++ b/dix/blockhandler.c
@@ -0,0 +1,233 @@
+/***********************************************************
+
+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 "scrnintstr.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..bddd854 100644
--- a/dix/dixutils.c
+++ b/dix/dixutils.c
@@ -357,151 +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
  * sleeps for input.
diff --git a/include/dix.h b/include/dix.h
index a282a08..db11315 100644
--- a/include/dix.h
+++ b/include/dix.h
@@ -222,6 +222,7 @@ extern _X_EXPORT int AlterSaveSetForClient(
   
 extern _X_EXPORT void DeleteWindowFromAnySaveSet(
     WindowPtr /*pWin*/);
+/* blockhandler.c */
 
 extern _X_EXPORT void BlockHandler(
     pointer /*pTimeout*/,
-- 
1.7.0.4




More information about the xorg-devel mailing list