Moving os-support/*/*_mouse.c to mouse input module?

Alan Coopersmith alan.coopersmith at sun.com
Thu Jul 21 12:18:03 EST 2005


We had a brief discussion this week on moving the OS-specific mouse 
files to the mouse input module, since it's all that uses it (and
because the current sun_mouse.c has a dependency on the headers in
the mouse input module, so can't build in the modular tree, but
that could be argued to be a misuse of those headers).

I've poked at this a bit and it seems a bit more complicated than I
originally thought, because I forgot that it would require converting
that code to run properly in a loadable module, and some platforms
may require calls or libraries (like libusb) not usually available in
loadable modules.

I've attached the patch to the monolithic tree that I have so far - I've
only converted the sun_mouse.c and built on Solaris though.   Any
thoughts on whether this should be continued or abandoned?

-- 
	-Alan Coopersmith-           alan.coopersmith at sun.com
	 Sun Microsystems, Inc. - X Window System Engineering
-------------- next part --------------
Index: input/mouse/Imakefile
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/input/mouse/Imakefile,v
retrieving revision 1.3
diff -u -r1.3 Imakefile
--- input/mouse/Imakefile	7 Mar 2005 19:27:28 -0000	1.3
+++ input/mouse/Imakefile	21 Jul 2005 01:58:51 -0000
@@ -3,16 +3,86 @@
 #define IHaveModules
 #include <Server.tmpl>
 
-SRCS = mouse.c pnp.c
-OBJS = mouse.o pnp.o
+#if defined(FreeBSDArchitecture) || defined(NetBSDArchitecture) || \
+    defined(OpenBSDArchitecture)
+OSDIR=bsd
+OS_MOUSE_SRC=bsd_mouse.c
+#if UsbMouseSupport
+USBMOUSEDEFINES1 = -DUSBMOUSE_SUPPORT
+#if !HasLibUsb
+OS_MOUSE_INCLUDES = -I$(XF86OSSRC)/$(OSDIR)/libusb
+#else
+#if HasLibUsbHid
+USBMOUSEDEFINES2 = -DHAS_LIB_USB_HID
+#endif
+#endif
+#endif
+OS_MOUSE_DEFINES = $(USBMOUSEDEFINES1) $(USBMOUSEDEFINES2)
+#endif
+
+#if defined(BSDOSArchitecture)
+OSDIR=bsdi
+OS_MOUSE_SRC=bsdi_mouse.c
+#endif
+
+#if defined(GNUMachArchitecture)
+OSDIR=hurd
+OS_MOUSE_SRC=hurd_mouse.c
+#endif
+
+#if defined(LinuxArchitecture)
+OSDIR=linux
+OS_MOUSE_SRC=lnx_mouse.c
+#endif
+
+#if defined(LynxOSArchitecture)
+OSDIR=lynxos
+OS_MOUSE_SRC=lynx_mouse.c
+#endif
+
+#if defined(NTOArchitecture)
+OSDIR=nto
+OS_MOUSE_SRC=nto_mouse.c
+#endif
+
+#if defined(OS2Architecture)
+OSDIR=os2
+OS_MOUSE_SRC=os2_mouse.c
+#endif
+
+#if defined(QNX4Architecture)
+OSDIR=qnx4
+OS_MOUSE_SRC=qnx_mouse.c
+#endif
+
+#if defined(SVR3Architecture) || defined(SVR4Architecture)
+# if defined(i386ScoArchitecture)
+OSDIR=sco
+OS_MOUSE_SRC=sco_mouse.c
+# elif defined(SunArchitecture)
+OS_SUBDIR=sunos
+OS_MOUSE_SRC=sun_mouse.c
+# elif defined(PmaxOSArchitecture)
+OSDIR=pmax
+OS_MOUSE_SRC=pmax_mouse.c
+# else
+OSDIR=sysv
+OS_MOUSE_SRC=sysv_mouse.c
+# endif
+#endif
+
+OS_MOUSE_OBJ=$(OS_MOUSE_SRC:.c=.o)
+
+SRCS = mouse.c pnp.c $(OS_MOUSE_SRC)
+OBJS = mouse.o pnp.o $(OS_MOUSE_OBJ)
 
 DRIVER = mouse
 
 INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86SRC)/loader -I$(XF86OSSRC) \
 	   -I$(SERVERSRC)/mi -I$(SERVERSRC)/include -I$(XINCLUDESRC) \
-	   -I$(EXTINCSRC)
+	   -I$(EXTINCSRC) $(OS_MOUSE_INCLUDES)
 
-DEFINES = -DPNP_MOUSE
+DEFINES = -DPNP_MOUSE $(OS_MOUSE_DEFINES)
 
 #if MakeHasPosixVariableSubstitutions
 SubdirLibraryRule($(OBJS))
@@ -28,6 +98,8 @@
 InstallModuleManPage($(DRIVER))
 #endif
 
+LinkSourceFile($(OS_MOUSE_SRC),$(XF86OSSRC)/$(OS_SUBDIR))
+
 DependTarget()
 
 InstallDriverSDKObjectModule($(DRIVER),$(DRIVERSDKMODULEDIR),input)
Index: os-support/bsd/Imakefile
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/os-support/bsd/Imakefile,v
retrieving revision 1.4
diff -u -r1.4 Imakefile
--- os-support/bsd/Imakefile	24 Jul 2004 16:32:39 -0000	1.4
+++ os-support/bsd/Imakefile	21 Jul 2005 01:58:51 -0000
@@ -63,8 +63,10 @@
 DRI_OBJ = sigio.o
 #endif
 
+#if 0 /* Moved to ../../input/mouse */
 MOUSESRC = bsd_mouse.c
 MOUSEOBJ = bsd_mouse.o
+#endif
 
 KBDSRC = bsd_kbd.c bsd_KbdMap.c at_scancode.c
 KBDOBJ = bsd_kbd.o bsd_KbdMap.o at_scancode.o
Index: os-support/linux/Imakefile
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/os-support/linux/Imakefile,v
retrieving revision 1.6
diff -u -r1.6 Imakefile
--- os-support/linux/Imakefile	21 Jan 2005 14:25:26 -0000	1.6
+++ os-support/linux/Imakefile	21 Jul 2005 01:58:51 -0000
@@ -23,8 +23,10 @@
 DRI_SRC = sigio.c
 DRI_OBJ = sigio.o
 
+#if 0 /* Moved to ../../input/mouse */
 MOUSESRC = lnx_mouse.c
 MOUSEOBJ = lnx_mouse.o
+#endif
 
 KBDSRC = lnx_kbd.c lnx_KbdMap.c at_scancode.c
 KBDOBJ = lnx_kbd.o lnx_KbdMap.o at_scancode.o 
cvs diff: Diffing os-support/lynxos
Index: os-support/lynxos/Imakefile
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/os-support/lynxos/Imakefile,v
retrieving revision 1.4
diff -u -r1.4 Imakefile
--- os-support/lynxos/Imakefile	26 Aug 2004 11:58:09 -0000	1.4
+++ os-support/lynxos/Imakefile	21 Jul 2005 01:58:51 -0000
@@ -20,8 +20,10 @@
 PPC_OBJS=lynx_noinline.o lynx_ppc.o
 #endif
 
+#if 0 /* Moved to ../../input/mouse */
 MOUSESRC = lynx_mouse.c
 MOUSEOBJ = lynx_mouse.o
+#endif
 
 SRCS = lynx_init.c lynx_video.c lynx_io.c lynx_mmap.c \
        VTsw_usl.c std_kbdEv.c posix_tty.c $(MOUSESRC) \
Index: os-support/nto/Imakefile
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/os-support/nto/Imakefile,v
retrieving revision 1.2
diff -u -r1.2 Imakefile
--- os-support/nto/Imakefile	23 Apr 2004 19:54:11 -0000	1.2
+++ os-support/nto/Imakefile	21 Jul 2005 01:58:51 -0000
@@ -3,14 +3,18 @@
 
 #include <Server.tmpl>
 
+#if 0 /* Moved to ../../input/mouse */
+MOUSESRC = nto_mouse.c
+MOUSEOBJ = nto_mouse.o
+#endif
 
 SRCS = nto_io.c nto_init.c nto_kbdEv.c nto_ioperm.c nto_video.c \
        VTsw_noop.c posix_tty.c kmod_noop.c agp_noop.c stdResource.c \
-       stdPci.c libc_wrapper.c sigiostubs.c pm_noop.c nto_mouse.c
+       stdPci.c libc_wrapper.c sigiostubs.c pm_noop.c $(MOUSESRC)
 
 OBJS = nto_io.o nto_init.o nto_kbdEv.o nto_ioperm.o nto_video.o \
        VTsw_noop.o posix_tty.o kmod_noop.o agp_noop.o stdResource.o \
-       stdPci.o libc_wrapper.o sigiostubs.o pm_noop.o nto_mouse.o
+       stdPci.o libc_wrapper.o sigiostubs.o pm_noop.o $(MOUSEOBJ)
 
 INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \
            -I$(XINCLUDESRC)
Index: os-support/os2/Imakefile
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/os-support/os2/Imakefile,v
retrieving revision 1.2
diff -u -r1.2 Imakefile
--- os-support/os2/Imakefile	23 Apr 2004 19:54:11 -0000	1.2
+++ os-support/os2/Imakefile	21 Jul 2005 01:58:51 -0000
@@ -9,14 +9,19 @@
 
 BIOS_MOD = os2_bios
 
+#if 0 /* Moved to ../../input/mouse */
+MOUSESRC = os2_mouse.c
+MOUSEOBJ = os2_mouse.o
+#endif
+
 SRCS = os2_init.c os2_video.c os2_io.c $(BIOS_MOD).c \
-       os2_ioperm.c os2_VTsw.c os2_mouse.c os2_KbdEv.c os2_stubs.c \
+       os2_ioperm.c os2_VTsw.c $(MOUSESRC) os2_KbdEv.c os2_stubs.c \
        os2_select.c os2_diag.c libc_wrapper.c stdResource.c stdPci.c \
        vidmem.c sigiostubs.c pm_noop.c kmod_noop.c agp_noop.c os2_serial.c \
        os2_kbd.c
 
 OBJS = os2_init.o os2_video.o os2_io.o $(BIOS_MOD).o \
-       os2_ioperm.o os2_VTsw.o os2_mouse.o os2_kbdEv.o os2_stubs.o \
+       os2_ioperm.o os2_VTsw.o $(MOUSEOBJ) os2_kbdEv.o os2_stubs.o \
        os2_select.o os2_diag.o libc_wrapper.o stdResource.o stdPci.o \
        vidmem.o sigiostubs.o pm_noop.o kmod_noop.o agp_noop.o os2_serial.o \
        os2_kbd.o
Index: os-support/pmax/Imakefile
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/os-support/pmax/Imakefile,v
retrieving revision 1.2
diff -u -r1.2 Imakefile
--- os-support/pmax/Imakefile	23 Apr 2004 19:54:12 -0000	1.2
+++ os-support/pmax/Imakefile	21 Jul 2005 01:58:51 -0000
@@ -3,8 +3,10 @@
 
 #include <Server.tmpl>
 
+#if 0 /* Moved to ../../input/mouse */
 MOUSESRC = pmax_mouse.c
 MOUSEOBJ = pmax_mouse.o
+#endif
 
 SRCS =  pmax_devs.c pmax_init.c pmax_map.c pmax_pci.c pmax_ppc.c \
 	bios_V4mmap.c VTsw_usl.c sysv_kbd.c std_kbdEv.c \
Index: os-support/qnx4/Imakefile
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/os-support/qnx4/Imakefile,v
retrieving revision 1.2
diff -u -r1.2 Imakefile
--- os-support/qnx4/Imakefile	23 Apr 2004 19:54:12 -0000	1.2
+++ os-support/qnx4/Imakefile	21 Jul 2005 01:58:51 -0000
@@ -2,14 +2,18 @@
 
 #include <Server.tmpl>
 
+#if 0 /* Moved to ../../input/mouse */
+MOUSESRC = qnx_mouse.c
+MOUSEOBJ = qnx_mouse.o
+#endif
 
 SRCS = qnx_io.c qnx_init.c qnx_utils.c ioperm_noop.c qnx_video.c \
-       qnx_VTsw.c qnx_kbd.c posix_tty.c qnx_mouse.c qnx_select.c \
+       qnx_VTsw.c qnx_kbd.c posix_tty.c $(MOUSESRC) qnx_select.c \
        libc_wrapper.c stdResource.c stdPci.c sigiostubs.c pm_noop.c \
        kmod_noop.c agp_noop.c
 
 OBJS = qnx_io.o qnx_init.o qnx_utils.o ioperm_noop.o qnx_video.o \
-       qnx_VTsw.o qnx_kbd.o posix_tty.o qnx_mouse.o qnx_select.o \
+       qnx_VTsw.o qnx_kbd.o posix_tty.o $(MOUSEOBJ) qnx_select.o \
        libc_wrapper.o stdResource.o stdPci.o sigiostubs.o pm_noop.o \
        kmod_noop.o agp_noop.o
 
Index: os-support/sco/Imakefile
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/os-support/sco/Imakefile,v
retrieving revision 1.2
diff -u -r1.2 Imakefile
--- os-support/sco/Imakefile	23 Apr 2004 19:54:12 -0000	1.2
+++ os-support/sco/Imakefile	21 Jul 2005 01:58:51 -0000
@@ -7,12 +7,17 @@
 
 #include <Server.tmpl>
 
-SRCS = sco_init.c sco_video.c sco_io.c sco_iop.c sco_mouse.c VTsw_sco.c \
+#if 0 /* Moved to ../../input/mouse */
+MOUSESRC = sco_mouse.c
+MOUSEOBJ = sco_mouse.o
+#endif
+
+SRCS = sco_init.c sco_video.c sco_io.c sco_iop.c $(MOUSESRC) VTsw_sco.c \
        std_kbdEv.c posix_tty.c bios_mmap.c vidmem.c \
        libc_wrapper.c stdResource.c stdPci.c sigiostubs.c pm_noop.c \
        kmod_noop.c agp_noop.c
 
-OBJS = sco_init.o sco_video.o sco_io.o sco_iop.o sco_mouse.o VTsw_sco.o \
+OBJS = sco_init.o sco_video.o sco_io.o sco_iop.o $(MOUSEOBJ) VTsw_sco.o \
        std_kbdEv.o posix_tty.o bios_mmap.o vidmem.o \
        libc_wrapper.o stdResource.o stdPci.o sigiostubs.o pm_noop.o \
        kmod_noop.o agp_noop.o
Index: os-support/sunos/Imakefile
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/os-support/sunos/Imakefile,v
retrieving revision 1.6
diff -u -r1.6 Imakefile
--- os-support/sunos/Imakefile	9 Jun 2005 03:11:58 -0000	1.6
+++ os-support/sunos/Imakefile	21 Jul 2005 01:58:51 -0000
@@ -89,15 +89,20 @@
 AGP_OBJ = agp_noop.o
 #endif
 
+#if 0 /* Moved to ../../input/mouse */
+MOUSESRC = sun_mouse.c
+MOUSEOBJ = sun_mouse.o
+#endif
+
 #ifdef SVR4Architecture
 SYSVIPCDEFINES = -DHAVE_SYSV_IPC
 #endif
 
 SRCS = sun_bios.c sun_init.c $(IO_SRC) $(KBD_SRCS) $(PROWORKS_INOUT_SRC) \
-       sun_mouse.c sun_vid.c $(AGP_SRC) libc_wrapper.c kmod_noop.c pm_noop.c \
+       $(MOUSESRC) sun_vid.c $(AGP_SRC) libc_wrapper.c kmod_noop.c pm_noop.c \
        posix_tty.c sigiostubs.c stdPci.c stdResource.c $(VTSW_SRC)
 OBJS = sun_bios.o sun_init.o $(IO_OBJ) $(KBD_OBJS) $(PROWORKS_INOUT_OBJ) \
-       sun_mouse.o sun_vid.o $(AGP_OBJ) libc_wrapper.o kmod_noop.o pm_noop.o \
+       $(MOUSEOBJ) sun_vid.o $(AGP_OBJ) libc_wrapper.o kmod_noop.o pm_noop.o \
        posix_tty.o sigiostubs.o stdPci.o stdResource.o $(VTSW_OBJ)
 
 INCLUDES = -I. -I$(XF86OSSRC) -I$(XF86COMSRC) \
Index: os-support/sunos/sun_mouse.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_mouse.c,v
retrieving revision 1.7
diff -u -r1.7 sun_mouse.c
--- os-support/sunos/sun_mouse.c	3 Jul 2005 07:01:36 -0000	1.7
+++ os-support/sunos/sun_mouse.c	21 Jul 2005 01:58:51 -0000
@@ -53,19 +53,20 @@
  * of the copyright holder.
  */
 
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
 #endif
 
 #include "xf86.h"
-#include "xf86_OSlib.h"
 #include "xf86OSmouse.h"
+#include "xf86_ansic.h"
+#include "xf86_OSproc.h"
 
 #if defined(__SOL8__) || !defined(__i386)
 
 #include "xisb.h"
 #include "mipointer.h"
-#include "../../input/mouse/mousePriv.h"
+#include "mousePriv.h"
 #include <sys/stropts.h>
 #include <sys/vuid_event.h>
 #include <sys/msio.h>
@@ -586,7 +587,9 @@
 	if ((*device != NULL) && (strcmp(*device, *pdev) != 0)) {
 	    continue;
 	}
-        SYSCALL (fd = open(*pdev, O_RDWR | O_NONBLOCK));
+        do {
+	    fd = open(*pdev, O_RDWR /* | O_NONBLOCK */);
+	} while ((fd == -1) && (errno == EINTR));
 	if (fd == -1) {
 #ifdef DEBUG
 	    ErrorF("Cannot open %s (%s)\n", pdev, strerror(errno));
Index: os-support/sysv/Imakefile
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/os-support/sysv/Imakefile,v
retrieving revision 1.2
diff -u -r1.2 Imakefile
--- os-support/sysv/Imakefile	23 Apr 2004 19:54:13 -0000	1.2
+++ os-support/sysv/Imakefile	21 Jul 2005 01:58:51 -0000
@@ -14,8 +14,10 @@
 BIOS_MOD = bios_devmem
 #endif
 
+#if 0 /* Moved to ../../input/mouse */
 MOUSESRC = sysv_mouse.c
 MOUSEOBJ = sysv_mouse.o
+#endif 
 
 SRCS = sysv_init.c sysv_video.c sysv_io.c $(BIOS_MOD).c VTsw_usl.c \
        sysv_kbd.c std_kbdEv.c posix_tty.c $(MOUSESRC) xqueue.c \


More information about the xorg-modular mailing list