xserver: Branch 'master' - 4 commits

Peter Hutterer whot at kemper.freedesktop.org
Mon Apr 27 22:58:57 PDT 2009


 configure.ac                        |   22 +-
 dix/Makefile.am                     |    6 
 dix/dispatch.c                      |  341 +++++++++++++++++++++++++++++++++
 dix/events.c                        |    6 
 dix/main.c                          |  368 ------------------------------------
 dix/swaprep.c                       |   15 +
 hw/dmx/Makefile.am                  |    1 
 hw/vfb/Makefile.am                  |    1 
 hw/xfree86/Makefile.am              |    2 
 hw/xquartz/mach-startup/Makefile.am |    2 
 include/dix.h                       |    1 
 test/Makefile.am                    |   39 +++
 test/README                         |   36 +++
 test/input.c                        |  227 ++++++++++++++++++++++
 test/xkb.c                          |  173 ++++++++++++++++
 15 files changed, 863 insertions(+), 377 deletions(-)

New commits:
commit dc2767d1c5db60385867c76ba2de507fe0cb8a90
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Tue Apr 21 22:18:23 2009 +1000

    test: add InternalEvent to core event conversion tests.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/test/input.c b/test/input.c
index bcb4c57..eb0543e 100644
--- a/test/input.c
+++ b/test/input.c
@@ -32,6 +32,7 @@
 #include <X11/Xatom.h>
 #include "windowstr.h"
 #include "inputstr.h"
+#include "eventconvert.h"
 
 #include <glib.h>
 
@@ -72,12 +73,155 @@ static void dix_init_valuators(void)
     g_assert(dev.last.numValuators == num_axes);
 }
 
+
+/**
+ * Convert various internal events to the matching core event and verify the
+ * parameters.
+ */
+static void dix_event_to_core(int type)
+{
+    DeviceEvent ev;
+    xEvent core;
+    int time;
+    int x, y;
+    int rc;
+    int state;
+    int detail;
+
+    /* EventToCore memsets the event to 0 */
+#define test_event() \
+    g_assert(rc == Success); \
+    g_assert(core.u.u.type == type); \
+    g_assert(core.u.u.detail == detail); \
+    g_assert(core.u.keyButtonPointer.time == time); \
+    g_assert(core.u.keyButtonPointer.rootX == x); \
+    g_assert(core.u.keyButtonPointer.rootY == y); \
+    g_assert(core.u.keyButtonPointer.state == state); \
+    g_assert(core.u.keyButtonPointer.eventX == 0); \
+    g_assert(core.u.keyButtonPointer.eventY == 0); \
+    g_assert(core.u.keyButtonPointer.root == 0); \
+    g_assert(core.u.keyButtonPointer.event == 0); \
+    g_assert(core.u.keyButtonPointer.child == 0); \
+    g_assert(core.u.keyButtonPointer.sameScreen == FALSE);
+
+    x = 0;
+    y = 0;
+    time = 12345;
+    state = 0;
+    detail = 0;
+
+    ev.header   = 0xFF;
+    ev.length   = sizeof(DeviceEvent);
+    ev.time     = time;
+    ev.root_y   = x;
+    ev.root_x   = y;
+    ev.corestate = state;
+    ev.detail.key = detail;
+
+    ev.type = type;
+    ev.detail.key = 0;
+    rc = EventToCore((InternalEvent*)&ev, &core);
+    test_event();
+
+    x = 1;
+    y = 2;
+    ev.root_x = x;
+    ev.root_y = y;
+    rc = EventToCore((InternalEvent*)&ev, &core);
+    test_event();
+
+    x = 0x7FFF;
+    y = 0x7FFF;
+    ev.root_x = x;
+    ev.root_y = y;
+    rc = EventToCore((InternalEvent*)&ev, &core);
+    test_event();
+
+    x = 0x8000; /* too high */
+    y = 0x8000; /* too high */
+    ev.root_x = x;
+    ev.root_y = y;
+    rc = EventToCore((InternalEvent*)&ev, &core);
+    g_assert(core.u.keyButtonPointer.rootX != x);
+    g_assert(core.u.keyButtonPointer.rootY != y);
+
+    x = 0x7FFF;
+    y = 0x7FFF;
+    ev.root_x = x;
+    ev.root_y = y;
+    time = 0;
+    ev.time = time;
+    rc = EventToCore((InternalEvent*)&ev, &core);
+    test_event();
+
+    detail = 1;
+    ev.detail.key = detail;
+    rc = EventToCore((InternalEvent*)&ev, &core);
+    test_event();
+
+    detail = 0xFF; /* highest value */
+    ev.detail.key = detail;
+    rc = EventToCore((InternalEvent*)&ev, &core);
+    test_event();
+
+    detail = 0xFFF; /* too big */
+    ev.detail.key = detail;
+    rc = EventToCore((InternalEvent*)&ev, &core);
+    g_assert(rc == BadMatch);
+
+    detail = 0xFF; /* too big */
+    ev.detail.key = detail;
+    state = 0xFFFF; /* highest value */
+    ev.corestate = state;
+    rc = EventToCore((InternalEvent*)&ev, &core);
+    test_event();
+
+    state = 0x10000; /* too big */
+    ev.corestate = state;
+    rc = EventToCore((InternalEvent*)&ev, &core);
+    g_assert(core.u.keyButtonPointer.state != state);
+    g_assert(core.u.keyButtonPointer.state == (state & 0xFFFF));
+
+#undef test_event
+}
+
+static void dix_event_to_core_conversion(void)
+{
+    DeviceEvent ev;
+    xEvent core;
+    int rc;
+
+    ev.header   = 0xFF;
+    ev.length   = sizeof(DeviceEvent);
+
+    ev.type     = 0;
+    rc = EventToCore((InternalEvent*)&ev, &core);
+    g_assert(rc == BadImplementation);
+
+    ev.type     = 1;
+    rc = EventToCore((InternalEvent*)&ev, &core);
+    g_assert(rc == BadImplementation);
+
+    ev.type     = ET_ProximityOut + 1;
+    rc = EventToCore((InternalEvent*)&ev, &core);
+    g_assert(rc == BadImplementation);
+
+    dix_event_to_core(ET_KeyPress);
+    dix_event_to_core(ET_KeyRelease);
+    dix_event_to_core(ET_ButtonPress);
+    dix_event_to_core(ET_ButtonRelease);
+    dix_event_to_core(ET_Motion);
+    dix_event_to_core(ET_ProximityIn);
+    dix_event_to_core(ET_ProximityOut);
+}
+
 int main(int argc, char** argv)
 {
     g_test_init(&argc, &argv,NULL);
     g_test_bug_base("https://bugzilla.freedesktop.org/show_bug.cgi?id=");
 
     g_test_add_func("/dix/input/init-valuators", dix_init_valuators);
+    g_test_add_func("/dix/input/event-core-conversion", dix_event_to_core_conversion);
 
     return g_test_run();
 }
commit 1127ca097cb75450bcccfc5f5d82e435de2fb5b7
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Thu Apr 16 11:41:58 2009 +1000

    test: add a simple test to verify device axis intialization.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/test/Makefile.am b/test/Makefile.am
index 5b1daac..dbad93b 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1,5 +1,5 @@
 if UNITTESTS
-check_PROGRAMS = xkb
+check_PROGRAMS = xkb input
 check_LTLIBRARIES = libxservertest.la
 
 TESTS=$(check_PROGRAMS)
@@ -9,7 +9,7 @@ INCLUDES = @XORG_INCS@
 TEST_LDADD=libxservertest.la $(XORG_SYS_LIBS) $(XSERVER_SYS_LIBS) $(GLIB_LIBS)
 
 xkb_LDADD=$(TEST_LDADD)
-
+input_LDADD=$(TEST_LDADD)
 
 libxservertest_la_LIBADD = \
             $(XSERVER_LIBS) \
diff --git a/test/input.c b/test/input.c
new file mode 100644
index 0000000..bcb4c57
--- /dev/null
+++ b/test/input.c
@@ -0,0 +1,83 @@
+/**
+ * Copyright © 2009 Red Hat, Inc.
+ *
+ *  Permission is hereby granted, free of charge, to any person obtaining a
+ *  copy of this software and associated documentation files (the "Software"),
+ *  to deal in the Software without restriction, including without limitation
+ *  the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ *  and/or sell copies of the Software, and to permit persons to whom the
+ *  Software is furnished to do so, subject to the following conditions:
+ *
+ *  The above copyright notice and this permission notice (including the next
+ *  paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "misc.h"
+#include "resource.h"
+#include <X11/Xproto.h>
+#include <X11/Xatom.h>
+#include "windowstr.h"
+#include "inputstr.h"
+
+#include <glib.h>
+
+/**
+ * Init a device with axes.
+ * Verify values set on the device.
+ *
+ * Result: All axes set to default values (usually 0).
+ */
+static void dix_init_valuators(void)
+{
+    DeviceIntRec dev;
+    ValuatorClassPtr val;
+    const int num_axes = 2;
+    int i;
+
+
+    memset(&dev, 0, sizeof(DeviceIntRec));
+    dev.isMaster = TRUE; /* claim it's a master to stop ptracccel */
+
+    g_assert(InitValuatorClassDeviceStruct(NULL, 0, 0, 0) == FALSE);
+    g_assert(InitValuatorClassDeviceStruct(&dev, num_axes, 0, Absolute));
+
+    val = dev.valuator;
+    g_assert(val);
+    g_assert(val->numAxes == num_axes);
+    g_assert(val->numMotionEvents == 0);
+    g_assert(val->mode == Absolute);
+    g_assert(val->axisVal);
+
+    for (i = 0; i < num_axes; i++)
+    {
+        g_assert(val->axisVal[i] == 0);
+        g_assert(val->axes->min_value == NO_AXIS_LIMITS);
+        g_assert(val->axes->max_value == NO_AXIS_LIMITS);
+    }
+
+    g_assert(dev.last.numValuators == num_axes);
+}
+
+int main(int argc, char** argv)
+{
+    g_test_init(&argc, &argv,NULL);
+    g_test_bug_base("https://bugzilla.freedesktop.org/show_bug.cgi?id=");
+
+    g_test_add_func("/dix/input/init-valuators", dix_init_valuators);
+
+    return g_test_run();
+}
commit 4124c465a85713fe44843a16c5e2b13ece17e9d2
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Wed Apr 15 17:21:08 2009 +1000

    Add a test-suite for in-server unit-testing.
    
    This patch adds a test/ directory that contains the setup for a unit-testing
    suite designed for in-server unit-testing. All functions available to the X
    server are available to the test binaries through static linking.
    
    This test suite uses the glib testing framework.
    Do not use glib calls outside of the test/ directory.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/configure.ac b/configure.ac
index 6628a44..2151ed1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -439,6 +439,9 @@ AC_ARG_ENABLE(werror,        AS_HELP_STRING([--enable-werror],
 AC_ARG_ENABLE(debug,         AS_HELP_STRING([--enable-debug],
 				  [Enable debugging (default: disabled)]),
 			        [DEBUGGING=$enableval], [DEBUGGING=no])
+AC_ARG_ENABLE(unit-tests,    AS_HELP_STRING([--enable-unit-tests],
+                                  [Enable unit-tests (default: enabled)]),
+                                [UNITTESTS=$enableval], [UNITTESTS=yes])
 AC_ARG_WITH(int10,           AS_HELP_STRING([--with-int10=BACKEND], [int10 backend: vm86, x86emu or stub]),
 				[INT10="$withval"],
 				[INT10="$DEFAULT_INT10"])
@@ -1141,6 +1144,14 @@ if test "x$DEBUGGING" = xyes; then
 fi
 AM_CONDITIONAL(DEBUG, [test "x$DEBUGGING" = xyes])
 
+if test "x$UNITTESTS" = xyes; then
+       AC_DEFINE(UNITTESTS, 1, [Enable unit tests])
+       PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.16])
+       AC_SUBST([GLIB_LIBS])
+       AC_SUBST([GLIB_CFLAGS])
+fi
+AM_CONDITIONAL(UNITTESTS, [test "x$UNITTESTS" = xyes])
+
 AC_DEFINE(XTEST, 1, [Support XTest extension])
 AC_DEFINE(XSYNC, 1, [Support XSync extension])
 AC_DEFINE(XCMISC, 1, [Support XCMisc extension])
@@ -1980,5 +1991,6 @@ hw/kdrive/fbdev/Makefile
 hw/kdrive/linux/Makefile
 hw/kdrive/sdl/Makefile
 hw/kdrive/src/Makefile
+test/Makefile
 xorg-server.pc
 ])
diff --git a/test/Makefile.am b/test/Makefile.am
new file mode 100644
index 0000000..5b1daac
--- /dev/null
+++ b/test/Makefile.am
@@ -0,0 +1,39 @@
+if UNITTESTS
+check_PROGRAMS = xkb
+check_LTLIBRARIES = libxservertest.la
+
+TESTS=$(check_PROGRAMS)
+
+AM_CFLAGS = $(DIX_CFLAGS) $(GLIB_CFLAGS) @XORG_CFLAGS@
+INCLUDES = @XORG_INCS@
+TEST_LDADD=libxservertest.la $(XORG_SYS_LIBS) $(XSERVER_SYS_LIBS) $(GLIB_LIBS)
+
+xkb_LDADD=$(TEST_LDADD)
+
+
+libxservertest_la_LIBADD = \
+            $(XSERVER_LIBS) \
+            $(top_builddir)/hw/xfree86/loader/libloader.la \
+            $(top_builddir)/hw/xfree86/os-support/libxorgos.la \
+            $(top_builddir)/hw/xfree86/common/libcommon.la \
+            $(top_builddir)/hw/xfree86/parser/libxf86config.la \
+            $(top_builddir)/hw/xfree86/dixmods/libdixmods.la \
+            $(top_builddir)/hw/xfree86/modes/libxf86modes.la \
+            $(top_builddir)/hw/xfree86/ramdac/libramdac.la \
+            $(top_builddir)/hw/xfree86/ddc/libddc.la \
+            $(top_builddir)/hw/xfree86/i2c/libi2c.la \
+            $(top_builddir)/hw/xfree86/dixmods/libxorgxkb.la \
+            $(top_builddir)/hw/xfree86/libxorg.la \
+            $(top_builddir)/mi/libmi.la \
+            $(top_builddir)/os/libos.la \
+            @XORG_LIBS@
+
+CLEANFILES=libxservertest.c
+
+libxservertest.c:
+	touch $@
+
+all:
+	@echo "Run 'make check' to run the test suite"
+
+endif
diff --git a/test/README b/test/README
new file mode 100644
index 0000000..5759a72
--- /dev/null
+++ b/test/README
@@ -0,0 +1,36 @@
+                        X server test suite
+
+This suite contains a set of tests to verify the behaviour of functions used
+internally to the server. This test suite is based on glib's testing
+framework [1].
+
+= How it works =
+Through some automake abuse, we link the test programs with the same static
+libraries as the Xorg binary. The test suites can then call various functions
+and verify their behaviour - without the need to start the server or connect
+clients.
+
+This testing only works for functions that do not rely on a particular state
+of the X server. Unless the test suite replicates the expected state, which
+may be difficult.
+
+= How to run the tests =
+Run "make check" the test directory. This will compile the tests and execute
+them in the order specified in the TESTS variable in test/Makefile.am.
+
+Each set of tests related to a subsystem are available as a binary that can be
+executed directly. For example, run "xkb" to perform some xkb-related tests.
+
+== Adding a new test ==
+When adding a new test, ensure that you add a short description of what the
+test does and what the expected outcome is. If the test reproduces a
+particular bug, using g_test_bug().
+
+== Misc ==
+
+The programs "gtester" and "gtester-report" may be used to generate XML/HTML
+log files of tests succeeded and failed.
+
+---------
+
+[1] http://library.gnome.org/devel/glib/stable/glib-Testing.html
diff --git a/test/xkb.c b/test/xkb.c
new file mode 100644
index 0000000..6fbb26a
--- /dev/null
+++ b/test/xkb.c
@@ -0,0 +1,173 @@
+/**
+ * Copyright © 2009 Red Hat, Inc.
+ *
+ *  Permission is hereby granted, free of charge, to any person obtaining a
+ *  copy of this software and associated documentation files (the "Software"),
+ *  to deal in the Software without restriction, including without limitation
+ *  the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ *  and/or sell copies of the Software, and to permit persons to whom the
+ *  Software is furnished to do so, subject to the following conditions:
+ *
+ *  The above copyright notice and this permission notice (including the next
+ *  paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <xkb-config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <unistd.h>
+#include <math.h>
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/keysym.h>
+#include <X11/Xatom.h>
+#include "misc.h"
+#include "inputstr.h"
+#include "opaque.h"
+#include "property.h"
+#define	XKBSRV_NEED_FILE_FUNCS
+#include <xkbsrv.h>
+#include "../xkb/xkbgeom.h"
+#include <X11/extensions/XKMformat.h>
+#include "xkbfile.h"
+#include "../xkb/xkb.h"
+
+#include <glib.h>
+
+/**
+ * Initialize an empty XkbRMLVOSet.
+ * Call XkbGetRulesDflts to obtain the default ruleset.
+ * Compare obtained ruleset with the built-in defaults.
+ *
+ * Result: RMLVO defaults are the same as obtained.
+ */
+static void xkb_get_rules_test(void)
+{
+    XkbRMLVOSet rmlvo = { NULL};
+    XkbGetRulesDflts(&rmlvo);
+
+
+    g_assert(rmlvo.rules);
+    g_assert(rmlvo.model);
+    g_assert(rmlvo.layout);
+    g_assert(rmlvo.variant);
+    g_assert(rmlvo.options);
+    g_assert(strcmp(rmlvo.rules, XKB_DFLT_RULES) == 0);
+    g_assert(strcmp(rmlvo.model, XKB_DFLT_MODEL) == 0);
+    g_assert(strcmp(rmlvo.layout, XKB_DFLT_LAYOUT) == 0);
+    g_assert(strcmp(rmlvo.variant, XKB_DFLT_VARIANT) == 0);
+    g_assert(strcmp(rmlvo.options, XKB_DFLT_OPTIONS) == 0);
+}
+
+/**
+ * Initialize an random XkbRMLVOSet.
+ * Call XkbGetRulesDflts to obtain the default ruleset.
+ * Compare obtained ruleset with the built-in defaults.
+ * Result: RMLVO defaults are the same as obtained.
+ */
+static void xkb_set_rules_test(void)
+{
+    XkbRMLVOSet rmlvo = {
+        .rules = "test-rules",
+        .model = "test-model",
+        .layout = "test-layout",
+        .variant = "test-variant",
+        .options = "test-options"
+    };
+    XkbRMLVOSet rmlvo_new = { NULL };
+
+    XkbSetRulesDflts(&rmlvo);
+    XkbGetRulesDflts(&rmlvo_new);
+
+    /* XkbGetRulesDflts strdups the values */
+    g_assert(rmlvo.rules != rmlvo_new.rules);
+    g_assert(rmlvo.model != rmlvo_new.model);
+    g_assert(rmlvo.layout != rmlvo_new.layout);
+    g_assert(rmlvo.variant != rmlvo_new.variant);
+    g_assert(rmlvo.options != rmlvo_new.options);
+
+    g_assert(strcmp(rmlvo.rules, rmlvo_new.rules) == 0);
+    g_assert(strcmp(rmlvo.model, rmlvo_new.model) == 0);
+    g_assert(strcmp(rmlvo.layout, rmlvo_new.layout) == 0);
+    g_assert(strcmp(rmlvo.variant, rmlvo_new.variant) == 0);
+    g_assert(strcmp(rmlvo.options, rmlvo_new.options) == 0);
+}
+
+
+/**
+ * Get the default RMLVO set.
+ * Set the default RMLVO set.
+ * Get the default RMLVO set.
+ * Repeat the last two steps.
+ *
+ * Result: RMLVO set obtained is the same as previously set.
+ */
+static void xkb_set_get_rules_test(void)
+{
+/* This test failed before XkbGetRulesDftlts changed to strdup.
+   We test this twice because the first time using XkbGetRulesDflts we obtain
+   the built-in defaults. The unexpected free isn't triggered until the second
+   XkbSetRulesDefaults.
+ */
+    XkbRMLVOSet rmlvo = { NULL };
+    XkbRMLVOSet rmlvo_backup;
+
+    XkbGetRulesDflts(&rmlvo);
+
+    /* pass 1 */
+    XkbSetRulesDflts(&rmlvo);
+    XkbGetRulesDflts(&rmlvo);
+
+    /* Make a backup copy */
+    rmlvo_backup.rules = strdup(rmlvo.rules);
+    rmlvo_backup.layout = strdup(rmlvo.layout);
+    rmlvo_backup.model = strdup(rmlvo.model);
+    rmlvo_backup.variant = strdup(rmlvo.variant);
+    rmlvo_backup.options = strdup(rmlvo.options);
+
+    /* pass 2 */
+    XkbSetRulesDflts(&rmlvo);
+
+    /* This test is iffy, because strictly we may be comparing against already
+     * freed memory */
+    g_assert(strcmp(rmlvo.rules, rmlvo_backup.rules) == 0);
+    g_assert(strcmp(rmlvo.model, rmlvo_backup.model) == 0);
+    g_assert(strcmp(rmlvo.layout, rmlvo_backup.layout) == 0);
+    g_assert(strcmp(rmlvo.variant, rmlvo_backup.variant) == 0);
+    g_assert(strcmp(rmlvo.options, rmlvo_backup.options) == 0);
+
+    XkbGetRulesDflts(&rmlvo);
+    g_assert(strcmp(rmlvo.rules, rmlvo_backup.rules) == 0);
+    g_assert(strcmp(rmlvo.model, rmlvo_backup.model) == 0);
+    g_assert(strcmp(rmlvo.layout, rmlvo_backup.layout) == 0);
+    g_assert(strcmp(rmlvo.variant, rmlvo_backup.variant) == 0);
+    g_assert(strcmp(rmlvo.options, rmlvo_backup.options) == 0);
+}
+
+
+int main(int argc, char** argv)
+{
+    g_test_init(&argc, &argv,NULL);
+    g_test_bug_base("https://bugzilla.freedesktop.org/show_bug.cgi?id=");
+
+    g_test_add_func("/xkb/set-get-rules", xkb_set_get_rules_test);
+    g_test_add_func("/xkb/get-rules", xkb_get_rules_test);
+    g_test_add_func("/xkb/set-rules", xkb_set_rules_test);
+
+    return g_test_run();
+}
commit 987579c930bda803427a28cb82773c389f5110d6
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Wed Apr 22 13:26:40 2009 +1000

    dix: remove all but main() from main.c
    
    All other functions are pushed into where they seemed to fit.
    main.c is now linked separately into libmain.a and linked in by the various
    DDXs.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/configure.ac b/configure.ac
index 438ee08..6628a44 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1153,6 +1153,10 @@ else
   DIX_LIB='$(top_builddir)/dix/libdix.la'
   OS_LIB='$(top_builddir)/os/libos.la'
 fi
+
+MAIN_LIB='$(top_builddir)/dix/libmain.la'
+AC_SUBST([MAIN_LIB])
+
 MI_LIB='$(top_builddir)/mi/libmi.la'
 MI_EXT_LIB='$(top_builddir)/mi/libmiext.la'
 MI_INC='-I$(top_srcdir)/mi'
@@ -1271,7 +1275,7 @@ AC_MSG_RESULT([$XNEST])
 AM_CONDITIONAL(XNEST, [test "x$XNEST" = xyes])
 
 if test "x$XNEST" = xyes; then
-	XNEST_LIBS="$FB_LIB $FIXES_LIB $MI_LIB $XEXT_LIB $DBE_LIB $RECORD_LIB $GLX_LIBS $RANDR_LIB $RENDER_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $DIX_LIB $OS_LIB $CONFIG_LIB"
+	XNEST_LIBS="$FB_LIB $FIXES_LIB $MI_LIB $XEXT_LIB $DBE_LIB $RECORD_LIB $GLX_LIBS $RANDR_LIB $RENDER_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $DIX_LIB $MAIN_LIB $OS_LIB $CONFIG_LIB"
 	XNEST_SYS_LIBS="$XNESTMODULES_LIBS $GLX_SYS_LIBS"
 	AC_SUBST([XNEST_LIBS])
 	AC_SUBST([XNEST_SYS_LIBS])
@@ -1643,7 +1647,7 @@ if test "x$XQUARTZ" = xyes; then
 	AC_DEFINE(XQUARTZ,1,[Have Quartz])
 	AC_DEFINE(ROOTLESS,1,[Build Rootless code])
 
-	DARWIN_LIBS="$MI_LIB $OS_LIB $DIX_LIB $FB_LIB $FIXES_LIB $XEXT_LIB $CONFIG_LIB $DBE_LIB $RECORD_LIB $RANDR_LIB $RENDER_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $XPSTUBS_LIB"
+	DARWIN_LIBS="$MI_LIB $OS_LIB $DIX_LIB $MAIN_LIB $FB_LIB $FIXES_LIB $XEXT_LIB $CONFIG_LIB $DBE_LIB $RECORD_LIB $RANDR_LIB $RENDER_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $XPSTUBS_LIB"
 	AC_SUBST([DARWIN_LIBS])
 
 	AC_CHECK_LIB([Xplugin],[xp_init],[:])
@@ -1828,7 +1832,7 @@ if test "$KDRIVE" = yes; then
 	    ;;
     esac
     KDRIVE_STUB_LIB='$(top_builddir)/hw/kdrive/src/libkdrivestubs.la'
-    KDRIVE_LOCAL_LIBS="$DIX_LIB $KDRIVE_LIB $KDRIVE_STUB_LIB $CONFIG_LIB"
+    KDRIVE_LOCAL_LIBS="$DIX_LIB $MAIN_LIB $KDRIVE_LIB $KDRIVE_STUB_LIB $CONFIG_LIB"
     KDRIVE_LOCAL_LIBS="$KDRIVE_LOCAL_LIBS $FB_LIB $MI_LIB $KDRIVE_PURE_LIBS"
     KDRIVE_LOCAL_LIBS="$KDRIVE_LOCAL_LIBS $KDRIVE_OS_LIB $OS_LIB"
     KDRIVE_LIBS="$TSLIB_LIBS $KDRIVE_LOCAL_LIBS $XSERVER_SYS_LIBS $GLX_SYS_LIBS"
diff --git a/dix/Makefile.am b/dix/Makefile.am
index 83b8c62..ab702f7 100644
--- a/dix/Makefile.am
+++ b/dix/Makefile.am
@@ -1,7 +1,10 @@
-noinst_LTLIBRARIES = libdix.la
+noinst_LTLIBRARIES = libdix.la libmain.la
 
 AM_CFLAGS = $(DIX_CFLAGS)
 
+libmain_la_SOURCES =    \
+	main.c
+
 libdix_la_SOURCES = 	\
 	atom.c		\
 	colormap.c	\
@@ -26,7 +29,6 @@ libdix_la_SOURCES = 	\
 	grabs.c		\
 	initatoms.c	\
 	inpututils.c	\
-	main.c		\
 	pixmap.c	\
 	privates.c	\
 	property.c	\
diff --git a/dix/dispatch.c b/dix/dispatch.c
index a9f9367..16a51bd 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -107,6 +107,7 @@ Equipment Corporation.
 
 #ifdef HAVE_DIX_CONFIG_H
 #include <dix-config.h>
+#include <version-config.h>
 #endif
 
 #ifdef PANORAMIX_DEBUG
@@ -134,6 +135,7 @@ int ProcInitialConnection();
 #include "xace.h"
 #include "inputstr.h"
 #include "xkbsrv.h"
+#include "site.h"
 
 #ifdef XSERVER_DTRACE
 #include "registry.h"
@@ -150,7 +152,9 @@ typedef const char *string;
 #define BITCLEAR(buf, i) MASKWORD(buf, i) &= ~BITMASK(i)
 #define GETBIT(buf, i) (MASKWORD(buf, i) & BITMASK(i))
 
-extern xConnSetupPrefix connSetupPrefix;
+xConnSetupPrefix connSetupPrefix;
+
+PaddingInfo PixmapWidthPaddingInfo[33];
 
 static ClientPtr grabClient;
 #define GrabNone 0
@@ -160,7 +164,7 @@ static int grabState = GrabNone;
 static long grabWaiters[mskcnt];
 CallbackListPtr ServerGrabCallback = NULL;
 HWEventQueuePtr checkForInput[2];
-extern int connBlockScreenStart;
+int connBlockScreenStart;
 
 static void KillAllClients(void);
 
@@ -461,6 +465,166 @@ Dispatch(void)
 
 #undef MAJOROP
 
+static int  VendorRelease = VENDOR_RELEASE;
+static char *VendorString = VENDOR_NAME;
+
+static const int padlength[4] = {0, 3, 2, 1};
+
+void
+SetVendorRelease(int release)
+{
+    VendorRelease = release;
+}
+
+void
+SetVendorString(char *string)
+{
+    VendorString = string;
+}
+
+Bool
+CreateConnectionBlock(void)
+{
+    xConnSetup setup;
+    xWindowRoot root;
+    xDepth	depth;
+    xVisualType visual;
+    xPixmapFormat format;
+    unsigned long vid;
+    int i, j, k,
+        lenofblock,
+        sizesofar = 0;
+    char *pBuf;
+
+
+    memset(&setup, 0, sizeof(xConnSetup));
+    /* Leave off the ridBase and ridMask, these must be sent with
+       connection */
+
+    setup.release = VendorRelease;
+    /*
+     * per-server image and bitmap parameters are defined in Xmd.h
+     */
+    setup.imageByteOrder = screenInfo.imageByteOrder;
+
+    setup.bitmapScanlineUnit = screenInfo.bitmapScanlineUnit;
+    setup.bitmapScanlinePad = screenInfo.bitmapScanlinePad;
+
+    setup.bitmapBitOrder = screenInfo.bitmapBitOrder;
+    setup.motionBufferSize = NumMotionEvents();
+    setup.numRoots = screenInfo.numScreens;
+    setup.nbytesVendor = strlen(VendorString);
+    setup.numFormats = screenInfo.numPixmapFormats;
+    setup.maxRequestSize = MAX_REQUEST_SIZE;
+    QueryMinMaxKeyCodes(&setup.minKeyCode, &setup.maxKeyCode);
+
+    lenofblock = sizeof(xConnSetup) +
+            ((setup.nbytesVendor + 3) & ~3) +
+	    (setup.numFormats * sizeof(xPixmapFormat)) +
+            (setup.numRoots * sizeof(xWindowRoot));
+    ConnectionInfo = xalloc(lenofblock);
+    if (!ConnectionInfo)
+	return FALSE;
+
+    memmove(ConnectionInfo, (char *)&setup, sizeof(xConnSetup));
+    sizesofar = sizeof(xConnSetup);
+    pBuf = ConnectionInfo + sizeof(xConnSetup);
+
+    memmove(pBuf, VendorString, (int)setup.nbytesVendor);
+    sizesofar += setup.nbytesVendor;
+    pBuf += setup.nbytesVendor;
+    i = padlength[setup.nbytesVendor & 3];
+    sizesofar += i;
+    while (--i >= 0)
+	*pBuf++ = 0;
+
+    memset(&format, 0, sizeof(xPixmapFormat));
+    for (i=0; i<screenInfo.numPixmapFormats; i++)
+    {
+	format.depth = screenInfo.formats[i].depth;
+	format.bitsPerPixel = screenInfo.formats[i].bitsPerPixel;
+	format.scanLinePad = screenInfo.formats[i].scanlinePad;
+	memmove(pBuf, (char *)&format, sizeof(xPixmapFormat));
+	pBuf += sizeof(xPixmapFormat);
+	sizesofar += sizeof(xPixmapFormat);
+    }
+
+    connBlockScreenStart = sizesofar;
+    memset(&depth, 0, sizeof(xDepth));
+    memset(&visual, 0, sizeof(xVisualType));
+    for (i=0; i<screenInfo.numScreens; i++)
+    {
+	ScreenPtr	pScreen;
+	DepthPtr	pDepth;
+	VisualPtr	pVisual;
+
+	pScreen = screenInfo.screens[i];
+	root.windowId = WindowTable[i]->drawable.id;
+	root.defaultColormap = pScreen->defColormap;
+	root.whitePixel = pScreen->whitePixel;
+	root.blackPixel = pScreen->blackPixel;
+	root.currentInputMask = 0;    /* filled in when sent */
+	root.pixWidth = pScreen->width;
+	root.pixHeight = pScreen->height;
+	root.mmWidth = pScreen->mmWidth;
+	root.mmHeight = pScreen->mmHeight;
+	root.minInstalledMaps = pScreen->minInstalledCmaps;
+	root.maxInstalledMaps = pScreen->maxInstalledCmaps;
+	root.rootVisualID = pScreen->rootVisual;
+	root.backingStore = pScreen->backingStoreSupport;
+	root.saveUnders = FALSE;
+	root.rootDepth = pScreen->rootDepth;
+	root.nDepths = pScreen->numDepths;
+	memmove(pBuf, (char *)&root, sizeof(xWindowRoot));
+	sizesofar += sizeof(xWindowRoot);
+	pBuf += sizeof(xWindowRoot);
+
+	pDepth = pScreen->allowedDepths;
+	for(j = 0; j < pScreen->numDepths; j++, pDepth++)
+	{
+	    lenofblock += sizeof(xDepth) +
+		    (pDepth->numVids * sizeof(xVisualType));
+	    pBuf = (char *)xrealloc(ConnectionInfo, lenofblock);
+	    if (!pBuf)
+	    {
+		xfree(ConnectionInfo);
+		return FALSE;
+	    }
+	    ConnectionInfo = pBuf;
+	    pBuf += sizesofar;
+	    depth.depth = pDepth->depth;
+	    depth.nVisuals = pDepth->numVids;
+	    memmove(pBuf, (char *)&depth, sizeof(xDepth));
+	    pBuf += sizeof(xDepth);
+	    sizesofar += sizeof(xDepth);
+	    for(k = 0; k < pDepth->numVids; k++)
+	    {
+		vid = pDepth->vids[k];
+		for (pVisual = pScreen->visuals;
+		     pVisual->vid != vid;
+		     pVisual++)
+		    ;
+		visual.visualID = vid;
+		visual.class = pVisual->class;
+		visual.bitsPerRGB = pVisual->bitsPerRGBValue;
+		visual.colormapEntries = pVisual->ColormapEntries;
+		visual.redMask = pVisual->redMask;
+		visual.greenMask = pVisual->greenMask;
+		visual.blueMask = pVisual->blueMask;
+		memmove(pBuf, (char *)&visual, sizeof(xVisualType));
+		pBuf += sizeof(xVisualType);
+		sizesofar += sizeof(xVisualType);
+	    }
+	}
+    }
+    connSetupPrefix.success = xTrue;
+    connSetupPrefix.length = lenofblock/4;
+    connSetupPrefix.majorVersion = X_PROTOCOL;
+    connSetupPrefix.minorVersion = X_PROTOCOL_REVISION;
+    return TRUE;
+}
+
+
 int
 ProcBadRequest(ClientPtr client)
 {
@@ -3700,3 +3864,176 @@ MarkClientException(ClientPtr client)
 {
     client->noClientException = -1;
 }
+
+/*
+ * This array encodes the answer to the question "what is the log base 2
+ * of the number of pixels that fit in a scanline pad unit?"
+ * Note that ~0 is an invalid entry (mostly for the benefit of the reader).
+ */
+static int answer[6][4] = {
+	/* pad   pad   pad     pad*/
+	/*  8     16    32    64 */
+
+	{   3,     4,    5 ,   6 },	/* 1 bit per pixel */
+	{   1,     2,    3 ,   4 },	/* 4 bits per pixel */
+	{   0,     1,    2 ,   3 },	/* 8 bits per pixel */
+	{   ~0,    0,    1 ,   2 },	/* 16 bits per pixel */
+	{   ~0,    ~0,   0 ,   1 },	/* 24 bits per pixel */
+	{   ~0,    ~0,   0 ,   1 }	/* 32 bits per pixel */
+};
+
+/*
+ * This array gives the answer to the question "what is the first index for
+ * the answer array above given the number of bits per pixel?"
+ * Note that ~0 is an invalid entry (mostly for the benefit of the reader).
+ */
+static int indexForBitsPerPixel[ 33 ] = {
+	~0, 0, ~0, ~0,	/* 1 bit per pixel */
+	1, ~0, ~0, ~0,	/* 4 bits per pixel */
+	2, ~0, ~0, ~0,	/* 8 bits per pixel */
+	~0,~0, ~0, ~0,
+	3, ~0, ~0, ~0,	/* 16 bits per pixel */
+	~0,~0, ~0, ~0,
+	4, ~0, ~0, ~0,	/* 24 bits per pixel */
+	~0,~0, ~0, ~0,
+	5		/* 32 bits per pixel */
+};
+
+/*
+ * This array gives the bytesperPixel value for cases where the number
+ * of bits per pixel is a multiple of 8 but not a power of 2.
+ */
+static int answerBytesPerPixel[ 33 ] = {
+	~0, 0, ~0, ~0,	/* 1 bit per pixel */
+	0, ~0, ~0, ~0,	/* 4 bits per pixel */
+	0, ~0, ~0, ~0,	/* 8 bits per pixel */
+	~0,~0, ~0, ~0,
+	0, ~0, ~0, ~0,	/* 16 bits per pixel */
+	~0,~0, ~0, ~0,
+	3, ~0, ~0, ~0,	/* 24 bits per pixel */
+	~0,~0, ~0, ~0,
+	0		/* 32 bits per pixel */
+};
+
+/*
+ * This array gives the answer to the question "what is the second index for
+ * the answer array above given the number of bits per scanline pad unit?"
+ * Note that ~0 is an invalid entry (mostly for the benefit of the reader).
+ */
+static int indexForScanlinePad[ 65 ] = {
+	~0, ~0, ~0, ~0,
+	~0, ~0, ~0, ~0,
+	 0, ~0, ~0, ~0,	/* 8 bits per scanline pad unit */
+	~0, ~0, ~0, ~0,
+	 1, ~0, ~0, ~0,	/* 16 bits per scanline pad unit */
+	~0, ~0, ~0, ~0,
+	~0, ~0, ~0, ~0,
+	~0, ~0, ~0, ~0,
+	 2, ~0, ~0, ~0,	/* 32 bits per scanline pad unit */
+	~0, ~0, ~0, ~0,
+	~0, ~0, ~0, ~0,
+	~0, ~0, ~0, ~0,
+	~0, ~0, ~0, ~0,
+	~0, ~0, ~0, ~0,
+	~0, ~0, ~0, ~0,
+	~0, ~0, ~0, ~0,
+	 3		/* 64 bits per scanline pad unit */
+};
+
+#ifndef MIN
+#define MIN(a,b) (((a) < (b)) ? (a) : (b))
+#endif
+
+/*
+	grow the array of screenRecs if necessary.
+	call the device-supplied initialization procedure
+with its screen number, a pointer to its ScreenRec, argc, and argv.
+	return the number of successfully installed screens.
+
+*/
+
+int
+AddScreen(
+    Bool	(* pfnInit)(
+	int /*index*/,
+	ScreenPtr /*pScreen*/,
+	int /*argc*/,
+	char ** /*argv*/
+		),
+    int argc,
+    char **argv)
+{
+
+    int i;
+    int scanlinepad, format, depth, bitsPerPixel, j, k;
+    ScreenPtr pScreen;
+
+    i = screenInfo.numScreens;
+    if (i == MAXSCREENS)
+	return -1;
+
+    pScreen = (ScreenPtr) xcalloc(1, sizeof(ScreenRec));
+    if (!pScreen)
+	return -1;
+
+    pScreen->devPrivates = NULL;
+    pScreen->myNum = i;
+    pScreen->totalPixmapSize = BitmapBytePad(sizeof(PixmapRec)*8);
+    pScreen->ClipNotify = 0;	/* for R4 ddx compatibility */
+    pScreen->CreateScreenResources = 0;
+
+    /*
+     * This loop gets run once for every Screen that gets added,
+     * but thats ok.  If the ddx layer initializes the formats
+     * one at a time calling AddScreen() after each, then each
+     * iteration will make it a little more accurate.  Worst case
+     * we do this loop N * numPixmapFormats where N is # of screens.
+     * Anyway, this must be called after InitOutput and before the
+     * screen init routine is called.
+     */
+    for (format=0; format<screenInfo.numPixmapFormats; format++)
+    {
+	depth = screenInfo.formats[format].depth;
+	bitsPerPixel = screenInfo.formats[format].bitsPerPixel;
+	scanlinepad = screenInfo.formats[format].scanlinePad;
+	j = indexForBitsPerPixel[ bitsPerPixel ];
+	k = indexForScanlinePad[ scanlinepad ];
+	PixmapWidthPaddingInfo[ depth ].padPixelsLog2 = answer[j][k];
+	PixmapWidthPaddingInfo[ depth ].padRoundUp =
+	    (scanlinepad/bitsPerPixel) - 1;
+	j = indexForBitsPerPixel[ 8 ]; /* bits per byte */
+	PixmapWidthPaddingInfo[ depth ].padBytesLog2 = answer[j][k];
+	PixmapWidthPaddingInfo[ depth ].bitsPerPixel = bitsPerPixel;
+	if (answerBytesPerPixel[bitsPerPixel])
+	{
+	    PixmapWidthPaddingInfo[ depth ].notPower2 = 1;
+	    PixmapWidthPaddingInfo[ depth ].bytesPerPixel =
+		answerBytesPerPixel[bitsPerPixel];
+	}
+	else
+	{
+	    PixmapWidthPaddingInfo[ depth ].notPower2 = 0;
+	}
+    }
+
+    /* This is where screen specific stuff gets initialized.  Load the
+       screen structure, call the hardware, whatever.
+       This is also where the default colormap should be allocated and
+       also pixel values for blackPixel, whitePixel, and the cursor
+       Note that InitScreen is NOT allowed to modify argc, argv, or
+       any of the strings pointed to by argv.  They may be passed to
+       multiple screens.
+    */
+    pScreen->rgf = ~0L;  /* there are no scratch GCs yet*/
+    WindowTable[i] = NullWindow;
+    screenInfo.screens[i] = pScreen;
+    screenInfo.numScreens++;
+    if (!(*pfnInit)(i, pScreen, argc, argv))
+    {
+	dixFreePrivates(pScreen->devPrivates);
+	xfree(pScreen);
+	screenInfo.numScreens--;
+	return -1;
+    }
+    return i;
+}
diff --git a/dix/events.c b/dix/events.c
index faa8425..8af71b6 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -273,6 +273,12 @@ static struct {
 static xEvent* swapEvent = NULL;
 static int swapEventLen = 0;
 
+void
+NotImplemented(xEvent *from, xEvent *to)
+{
+    FatalError("Not implemented");
+}
+
 /**
  * Convert the given event type from an XI event to a core event.
  * @param[in] The XI 1.x event type.
diff --git a/dix/main.c b/dix/main.c
index 9d5d839..25b085e 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -118,120 +118,7 @@ Equipment Corporation.
 
 extern void Dispatch(void);
 
-xConnSetupPrefix connSetupPrefix;
-
-extern FontPtr defaultFont;
-
 extern void InitProcVectors(void);
-extern Bool CreateGCperDepthArray(void);
-
-#ifndef PANORAMIX
-static
-#endif
-Bool CreateConnectionBlock(void);
-
-PaddingInfo PixmapWidthPaddingInfo[33];
-
-int connBlockScreenStart;
-
-void
-NotImplemented(xEvent *from, xEvent *to)
-{
-    FatalError("Not implemented");
-}
-
-/*
- * Dummy entry for ReplySwapVector[]
- */
-
-void
-ReplyNotSwappd(
-	ClientPtr pClient ,
-	int size ,
-	void * pbuf
-	)
-{
-    FatalError("Not implemented");
-}
-
-/*
- * This array encodes the answer to the question "what is the log base 2
- * of the number of pixels that fit in a scanline pad unit?"
- * Note that ~0 is an invalid entry (mostly for the benefit of the reader).
- */
-static int answer[6][4] = {
-	/* pad   pad   pad     pad*/
-	/*  8     16    32    64 */
-
-	{   3,     4,    5 ,   6 },	/* 1 bit per pixel */
-	{   1,     2,    3 ,   4 },	/* 4 bits per pixel */
-	{   0,     1,    2 ,   3 },	/* 8 bits per pixel */
-	{   ~0,    0,    1 ,   2 },	/* 16 bits per pixel */
-	{   ~0,    ~0,   0 ,   1 },	/* 24 bits per pixel */
-	{   ~0,    ~0,   0 ,   1 }	/* 32 bits per pixel */
-};
-
-/*
- * This array gives the answer to the question "what is the first index for
- * the answer array above given the number of bits per pixel?"
- * Note that ~0 is an invalid entry (mostly for the benefit of the reader).
- */
-static int indexForBitsPerPixel[ 33 ] = {
-	~0, 0, ~0, ~0,	/* 1 bit per pixel */
-	1, ~0, ~0, ~0,	/* 4 bits per pixel */
-	2, ~0, ~0, ~0,	/* 8 bits per pixel */
-	~0,~0, ~0, ~0,
-	3, ~0, ~0, ~0,	/* 16 bits per pixel */
-	~0,~0, ~0, ~0,
-	4, ~0, ~0, ~0,	/* 24 bits per pixel */
-	~0,~0, ~0, ~0,
-	5		/* 32 bits per pixel */
-};
-
-/*
- * This array gives the bytesperPixel value for cases where the number
- * of bits per pixel is a multiple of 8 but not a power of 2.
- */
-static int answerBytesPerPixel[ 33 ] = {
-	~0, 0, ~0, ~0,	/* 1 bit per pixel */
-	0, ~0, ~0, ~0,	/* 4 bits per pixel */
-	0, ~0, ~0, ~0,	/* 8 bits per pixel */
-	~0,~0, ~0, ~0,
-	0, ~0, ~0, ~0,	/* 16 bits per pixel */
-	~0,~0, ~0, ~0,
-	3, ~0, ~0, ~0,	/* 24 bits per pixel */
-	~0,~0, ~0, ~0,
-	0		/* 32 bits per pixel */
-};
-
-/*
- * This array gives the answer to the question "what is the second index for
- * the answer array above given the number of bits per scanline pad unit?"
- * Note that ~0 is an invalid entry (mostly for the benefit of the reader).
- */
-static int indexForScanlinePad[ 65 ] = {
-	~0, ~0, ~0, ~0,
-	~0, ~0, ~0, ~0,
-	 0, ~0, ~0, ~0,	/* 8 bits per scanline pad unit */
-	~0, ~0, ~0, ~0,
-	 1, ~0, ~0, ~0,	/* 16 bits per scanline pad unit */
-	~0, ~0, ~0, ~0,
-	~0, ~0, ~0, ~0,
-	~0, ~0, ~0, ~0,
-	 2, ~0, ~0, ~0,	/* 32 bits per scanline pad unit */
-	~0, ~0, ~0, ~0,
-	~0, ~0, ~0, ~0,
-	~0, ~0, ~0, ~0,
-	~0, ~0, ~0, ~0,
-	~0, ~0, ~0, ~0,
-	~0, ~0, ~0, ~0,
-	~0, ~0, ~0, ~0,
-	 3		/* 64 bits per scanline pad unit */
-};
-
-#ifndef MIN
-#define MIN(a,b) (((a) < (b)) ? (a) : (b))
-#endif
 
 #ifdef XQUARTZ
 #include <pthread.h>
@@ -456,258 +343,3 @@ int main(int argc, char *argv[], char *envp[])
     return(0);
 }
 
-static int  VendorRelease = VENDOR_RELEASE;
-static char *VendorString = VENDOR_NAME;
-
-void
-SetVendorRelease(int release)
-{
-    VendorRelease = release;
-}
-
-void
-SetVendorString(char *string)
-{
-    VendorString = string;
-}
-
-static const int padlength[4] = {0, 3, 2, 1};
-
-#ifndef PANORAMIX
-static
-#endif
-Bool
-CreateConnectionBlock(void)
-{
-    xConnSetup setup;
-    xWindowRoot root;
-    xDepth	depth;
-    xVisualType visual;
-    xPixmapFormat format;
-    unsigned long vid;
-    int i, j, k,
-        lenofblock,
-        sizesofar = 0;
-    char *pBuf;
-
-
-    memset(&setup, 0, sizeof(xConnSetup));
-    /* Leave off the ridBase and ridMask, these must be sent with
-       connection */
-
-    setup.release = VendorRelease;
-    /*
-     * per-server image and bitmap parameters are defined in Xmd.h
-     */
-    setup.imageByteOrder = screenInfo.imageByteOrder;
-
-    setup.bitmapScanlineUnit = screenInfo.bitmapScanlineUnit;
-    setup.bitmapScanlinePad = screenInfo.bitmapScanlinePad;
-
-    setup.bitmapBitOrder = screenInfo.bitmapBitOrder;
-    setup.motionBufferSize = NumMotionEvents();
-    setup.numRoots = screenInfo.numScreens;
-    setup.nbytesVendor = strlen(VendorString); 
-    setup.numFormats = screenInfo.numPixmapFormats;
-    setup.maxRequestSize = MAX_REQUEST_SIZE;
-    QueryMinMaxKeyCodes(&setup.minKeyCode, &setup.maxKeyCode);
-    
-    lenofblock = sizeof(xConnSetup) + 
-            ((setup.nbytesVendor + 3) & ~3) +
-	    (setup.numFormats * sizeof(xPixmapFormat)) +
-            (setup.numRoots * sizeof(xWindowRoot));
-    ConnectionInfo = xalloc(lenofblock);
-    if (!ConnectionInfo)
-	return FALSE;
-
-    memmove(ConnectionInfo, (char *)&setup, sizeof(xConnSetup));
-    sizesofar = sizeof(xConnSetup);
-    pBuf = ConnectionInfo + sizeof(xConnSetup);
-
-    memmove(pBuf, VendorString, (int)setup.nbytesVendor);
-    sizesofar += setup.nbytesVendor;
-    pBuf += setup.nbytesVendor;
-    i = padlength[setup.nbytesVendor & 3];
-    sizesofar += i;
-    while (--i >= 0)
-	*pBuf++ = 0;
-
-    memset(&format, 0, sizeof(xPixmapFormat));
-    for (i=0; i<screenInfo.numPixmapFormats; i++)
-    {
-	format.depth = screenInfo.formats[i].depth;
-	format.bitsPerPixel = screenInfo.formats[i].bitsPerPixel;
-	format.scanLinePad = screenInfo.formats[i].scanlinePad;
-	memmove(pBuf, (char *)&format, sizeof(xPixmapFormat));
-	pBuf += sizeof(xPixmapFormat);
-	sizesofar += sizeof(xPixmapFormat);
-    }
-
-    connBlockScreenStart = sizesofar;
-    memset(&depth, 0, sizeof(xDepth));
-    memset(&visual, 0, sizeof(xVisualType));
-    for (i=0; i<screenInfo.numScreens; i++)
-    {
-	ScreenPtr	pScreen;
-	DepthPtr	pDepth;
-	VisualPtr	pVisual;
-
-	pScreen = screenInfo.screens[i];
-	root.windowId = WindowTable[i]->drawable.id;
-	root.defaultColormap = pScreen->defColormap;
-	root.whitePixel = pScreen->whitePixel;
-	root.blackPixel = pScreen->blackPixel;
-	root.currentInputMask = 0;    /* filled in when sent */
-	root.pixWidth = pScreen->width;
-	root.pixHeight = pScreen->height;
-	root.mmWidth = pScreen->mmWidth;
-	root.mmHeight = pScreen->mmHeight;
-	root.minInstalledMaps = pScreen->minInstalledCmaps;
-	root.maxInstalledMaps = pScreen->maxInstalledCmaps; 
-	root.rootVisualID = pScreen->rootVisual;		
-	root.backingStore = pScreen->backingStoreSupport;
-	root.saveUnders = FALSE;
-	root.rootDepth = pScreen->rootDepth;
-	root.nDepths = pScreen->numDepths;
-	memmove(pBuf, (char *)&root, sizeof(xWindowRoot));
-	sizesofar += sizeof(xWindowRoot);
-	pBuf += sizeof(xWindowRoot);
-
-	pDepth = pScreen->allowedDepths;
-	for(j = 0; j < pScreen->numDepths; j++, pDepth++)
-	{
-	    lenofblock += sizeof(xDepth) + 
-		    (pDepth->numVids * sizeof(xVisualType));
-	    pBuf = (char *)xrealloc(ConnectionInfo, lenofblock);
-	    if (!pBuf)
-	    {
-		xfree(ConnectionInfo);
-		return FALSE;
-	    }
-	    ConnectionInfo = pBuf;
-	    pBuf += sizesofar;            
-	    depth.depth = pDepth->depth;
-	    depth.nVisuals = pDepth->numVids;
-	    memmove(pBuf, (char *)&depth, sizeof(xDepth));
-	    pBuf += sizeof(xDepth);
-	    sizesofar += sizeof(xDepth);
-	    for(k = 0; k < pDepth->numVids; k++)
-	    {
-		vid = pDepth->vids[k];
-		for (pVisual = pScreen->visuals;
-		     pVisual->vid != vid;
-		     pVisual++)
-		    ;
-		visual.visualID = vid;
-		visual.class = pVisual->class;
-		visual.bitsPerRGB = pVisual->bitsPerRGBValue;
-		visual.colormapEntries = pVisual->ColormapEntries;
-		visual.redMask = pVisual->redMask;
-		visual.greenMask = pVisual->greenMask;
-		visual.blueMask = pVisual->blueMask;
-		memmove(pBuf, (char *)&visual, sizeof(xVisualType));
-		pBuf += sizeof(xVisualType);
-		sizesofar += sizeof(xVisualType);
-	    }
-	}
-    }
-    connSetupPrefix.success = xTrue;
-    connSetupPrefix.length = lenofblock/4;
-    connSetupPrefix.majorVersion = X_PROTOCOL;
-    connSetupPrefix.minorVersion = X_PROTOCOL_REVISION;
-    return TRUE;
-}
-
-/*
-	grow the array of screenRecs if necessary.
-	call the device-supplied initialization procedure 
-with its screen number, a pointer to its ScreenRec, argc, and argv.
-	return the number of successfully installed screens.
-
-*/
-
-int
-AddScreen(
-    Bool	(* pfnInit)(
-	int /*index*/,
-	ScreenPtr /*pScreen*/,
-	int /*argc*/,
-	char ** /*argv*/
-		),
-    int argc,
-    char **argv)
-{
-
-    int i;
-    int scanlinepad, format, depth, bitsPerPixel, j, k;
-    ScreenPtr pScreen;
-
-    i = screenInfo.numScreens;
-    if (i == MAXSCREENS)
-	return -1;
-
-    pScreen = (ScreenPtr) xcalloc(1, sizeof(ScreenRec));
-    if (!pScreen)
-	return -1;
-
-    pScreen->devPrivates = NULL;
-    pScreen->myNum = i;
-    pScreen->totalPixmapSize = BitmapBytePad(sizeof(PixmapRec)*8);
-    pScreen->ClipNotify = 0;	/* for R4 ddx compatibility */
-    pScreen->CreateScreenResources = 0;
-    
-    /*
-     * This loop gets run once for every Screen that gets added,
-     * but thats ok.  If the ddx layer initializes the formats
-     * one at a time calling AddScreen() after each, then each
-     * iteration will make it a little more accurate.  Worst case
-     * we do this loop N * numPixmapFormats where N is # of screens.
-     * Anyway, this must be called after InitOutput and before the
-     * screen init routine is called.
-     */
-    for (format=0; format<screenInfo.numPixmapFormats; format++)
-    {
- 	depth = screenInfo.formats[format].depth;
- 	bitsPerPixel = screenInfo.formats[format].bitsPerPixel;
-  	scanlinepad = screenInfo.formats[format].scanlinePad;
- 	j = indexForBitsPerPixel[ bitsPerPixel ];
-  	k = indexForScanlinePad[ scanlinepad ];
- 	PixmapWidthPaddingInfo[ depth ].padPixelsLog2 = answer[j][k];
- 	PixmapWidthPaddingInfo[ depth ].padRoundUp =
- 	    (scanlinepad/bitsPerPixel) - 1;
- 	j = indexForBitsPerPixel[ 8 ]; /* bits per byte */
- 	PixmapWidthPaddingInfo[ depth ].padBytesLog2 = answer[j][k];
-	PixmapWidthPaddingInfo[ depth ].bitsPerPixel = bitsPerPixel;
-	if (answerBytesPerPixel[bitsPerPixel])
-	{
-	    PixmapWidthPaddingInfo[ depth ].notPower2 = 1;
-	    PixmapWidthPaddingInfo[ depth ].bytesPerPixel =
-		answerBytesPerPixel[bitsPerPixel];
-	}
-	else
-	{
-	    PixmapWidthPaddingInfo[ depth ].notPower2 = 0;
-	}
-    }
-  
-    /* This is where screen specific stuff gets initialized.  Load the
-       screen structure, call the hardware, whatever.
-       This is also where the default colormap should be allocated and
-       also pixel values for blackPixel, whitePixel, and the cursor
-       Note that InitScreen is NOT allowed to modify argc, argv, or
-       any of the strings pointed to by argv.  They may be passed to
-       multiple screens. 
-    */ 
-    pScreen->rgf = ~0L;  /* there are no scratch GCs yet*/
-    WindowTable[i] = NullWindow;
-    screenInfo.screens[i] = pScreen;
-    screenInfo.numScreens++;
-    if (!(*pfnInit)(i, pScreen, argc, argv))
-    {
-	dixFreePrivates(pScreen->devPrivates);
-	xfree(pScreen);
-	screenInfo.numScreens--;
-	return -1;
-    }
-    return i;
-}
diff --git a/dix/swaprep.c b/dix/swaprep.c
index 9eb6765..8624216 100644
--- a/dix/swaprep.c
+++ b/dix/swaprep.c
@@ -1291,3 +1291,18 @@ WriteSConnSetupPrefix(ClientPtr pClient, xConnSetupPrefix *pcsp)
     SwapConnSetupPrefix(pcsp, &cspT);
     (void)WriteToClient(pClient, sizeof(cspT), (char *) &cspT);
 }
+
+/*
+ * Dummy entry for ReplySwapVector[]
+ */
+
+void
+ReplyNotSwappd(
+	ClientPtr pClient ,
+	int size ,
+	void * pbuf
+	)
+{
+    FatalError("Not implemented");
+}
+
diff --git a/hw/dmx/Makefile.am b/hw/dmx/Makefile.am
index 9d2778a..9e9b39a 100644
--- a/hw/dmx/Makefile.am
+++ b/hw/dmx/Makefile.am
@@ -85,6 +85,7 @@ XDMX_LIBS = \
 	$(GLX_LIBS) \
         input/libdmxinput.a \
         config/libdmxconfig.a \
+	$(MAIN_LIB) \
 	$(XSERVER_LIBS)
 
 Xdmx_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
diff --git a/hw/vfb/Makefile.am b/hw/vfb/Makefile.am
index a4a120a..c5b49a3 100644
--- a/hw/vfb/Makefile.am
+++ b/hw/vfb/Makefile.am
@@ -22,6 +22,7 @@ Xvfb_SOURCES = $(SRCS)
 XVFB_LIBS = \
         @XVFB_LIBS@ \
 	libfbcmap.a \
+	$(MAIN_LIB) \
 	$(XSERVER_LIBS)
 
 Xvfb_LDADD = $(XVFB_LIBS) $(XVFB_SYS_LIBS) $(XSERVER_SYS_LIBS)
diff --git a/hw/xfree86/Makefile.am b/hw/xfree86/Makefile.am
index b6a534b..3b9ff9c 100644
--- a/hw/xfree86/Makefile.am
+++ b/hw/xfree86/Makefile.am
@@ -56,7 +56,7 @@ libxorg.c xorg.c:
 DISTCLEANFILES = libxorg.c xorg.c
 
 Xorg_DEPENDENCIES = libxorg.la
-Xorg_LDADD = libxorg.la $(XORG_SYS_LIBS) $(XSERVER_SYS_LIBS)
+Xorg_LDADD = $(MAIN_LIB) libxorg.la $(XORG_SYS_LIBS) $(XSERVER_SYS_LIBS)
 
 Xorg_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
 
diff --git a/hw/xquartz/mach-startup/Makefile.am b/hw/xquartz/mach-startup/Makefile.am
index b011294..0c609e3 100644
--- a/hw/xquartz/mach-startup/Makefile.am
+++ b/hw/xquartz/mach-startup/Makefile.am
@@ -19,7 +19,7 @@ X11_bin_LDADD = \
 	$(top_builddir)/dix/dixfonts.lo \
 	$(top_builddir)/miext/rootless/librootless.la \
 	$(top_builddir)/hw/xquartz/pbproxy/libxpbproxy.la \
-	$(DARWIN_LIBS) $(XSERVER_LIBS) $(XSERVER_SYS_LIBS) -lXplugin
+	$(DARWIN_LIBS) $(MAIN_LIB) $(XSERVER_LIBS) $(XSERVER_SYS_LIBS) -lXplugin
 
 X11_bin_LDFLAGS =  \
 	-XCClinker -Objc \
diff --git a/include/dix.h b/include/dix.h
index b1333dc..896553a 100644
--- a/include/dix.h
+++ b/include/dix.h
@@ -170,6 +170,7 @@ extern _X_EXPORT void SendErrorToClient(
 extern _X_EXPORT void MarkClientException(
     ClientPtr /*client*/);
 
+extern _X_HIDDEN Bool CreateConnectionBlock(void);
 /* dixutils.c */
 
 extern _X_EXPORT void CopyISOLatin1Lowered(


More information about the xorg-commit mailing list