diff -ur xc.vanilla/config/cf/Imake.cf xc/config/cf/Imake.cf
--- xc.vanilla/config/cf/Imake.cf	Tue Dec  5 22:40:45 1995
+++ xc/config/cf/Imake.cf	Sat May 25 20:27:28 1996
@@ -395,13 +395,19 @@
 # define Win32Architecture
 #endif /* WIN32 */
 
-#ifdef linux 
+#ifdef linux
 # define MacroIncludeFile <linux.cf>
 # define MacroFile linux.cf
 # undef linux
 # define LinuxArchitecture
-# define i386Architecture
-# undef i386
+# ifdef 386
+#  define i386Architecture
+#  undef i386
+# endif
+# if defined(__sparc__) || defined(sparc)
+#  define SparcArchitecture
+#  undef sparc
+# endif
 #endif /* linux */
 
 #ifdef __uxp__
diff -ur xc.vanilla/config/cf/linux.cf xc/config/cf/linux.cf
--- xc.vanilla/config/cf/linux.cf	Sat Feb  3 01:00:56 1996
+++ xc/config/cf/linux.cf	Sun May 26 09:54:38 1996
@@ -4,16 +4,16 @@
 #define OSName			Linux
 #endif
 #ifndef OSVendor
-#define OSVendor		Slackware 2.3.0 ELF
+#define OSVendor		RedHat 4.0 (sparc)
 #endif
 #ifndef OSMajorVersion
 #define OSMajorVersion		1
 #endif
 #ifndef OSMinorVersion
-#define OSMinorVersion		2
+#define OSMinorVersion		3
 #endif
 #ifndef OSTeenyVersion
-#define OSTeenyVersion		11
+#define OSTeenyVersion		100
 #endif
 
 #ifndef UseElfFormat
@@ -59,15 +59,19 @@
 #define LdCmd			ld -m elf_i386
 #endif
 #define AsmDefines		-D__ELF__
+#ifdef i386Architecture
 #define CplusplusCmd		g++ -b i486-linuxelf
 #else
+#define CplusplusCmd		g++
+#endif
+#else
 #define CcCmd			gcc
 #if OSMinorVersion < 2
 #define AsCmd			as
 #define LdCmd			ld
 #else
-#define AsCmd			/usr/i486-linuxaout/bin/as
-#define LdCmd			ld -m i386linux
+#define AsCmd			as
+#define LdCmd			ld
 #endif
 #define AsmDefines		-DUSE_GAS -U__ELF__
 #endif
@@ -79,15 +83,24 @@
 #define PreProcessCmd		CcCmd -E
 #define PostIncDir		`CcCmd --print-libgcc-file-name | sed 's/libgcc.a/include/'`
 #define LdCombineFlags		-r
-#define OptimizedCDebugFlags	-O2 -m486
-#define StandardDefines		-Dlinux -D__i386__ -D_POSIX_SOURCE \
+#define OptimizedCDebugFlags	-O2
+#define StandardDefines		-Dlinux -D__sparc__ -D_POSIX_SOURCE \
 				-D_BSD_SOURCE -D_GNU_SOURCE -DX_LOCALE
 #define XawI18nDefines		-DUSE_XWCHAR_STRING -DUSE_XMBTOWC
 #define HasWChar32		YES
 #define StandardCppDefines	-traditional StandardDefines
+#ifdef i386Architecture
 #define ServerOSDefines		XFree86ServerOSDefines -DDDXTIME
-#define ExtensionOSDefines	-DXTESTEXT1
 #define ServerExtraDefines	-DGCCUSESGAS XFree86ServerDefines
+#define ExtensionOSDefines	-DXTESTEXT1
+#else
+#ifdef SparcArchitecture
+#define ServerOSDefines   -DDDXOSINIT
+#define ServerExtraDefines	-DGCCUSESGAS 
+#define HasSharedLibraries       YES
+#endif
+#endif
+
 #define ConnectionFlags		-DUNIXCONN -DTCPCONN
 #define InstUidFlags		-s -m 4711
 
@@ -112,4 +125,25 @@
 #endif
 
 #include <lnxLib.rules>
+#ifdef i386Architecture
 #include <xfree86.cf>
+#else
+#ifdef SparcArchitecture
+#ifndef Xsun24Server
+#define Xsun24Server      NO            /* color, mono, multiple depths */
+#endif
+#ifndef XsunServer
+#define XsunServer        YES           /* color and mono, 8 bit only */
+#endif
+#ifndef XsunMonoServer
+#define XsunMonoServer    NO            /* monochrome only */
+#endif
+#ifndef HasNdbm
+#define HasNdbm		  YES
+#endif
+#ifndef DBMLibrary
+#define DBMLibrary /usr/lib/libdb.a
+#endif
+#endif
+#endif /* not i386Architecture */
+
diff -ur xc.vanilla/config/cf/site.def xc/config/cf/site.def
--- xc.vanilla/config/cf/site.def	Thu Dec 14 19:04:57 1995
+++ xc/config/cf/site.def	Tue May 28 18:17:14 1996
@@ -100,6 +100,12 @@
 #endif
 */
 
+#if defined(SparcArchitecture) && defined(LinuxArchitecture)
+#define InstallXserverSetUID YES
+#endif
+#undef ForceNormalLib
+#define ForceNormalLib	YES
+
 /* #include <host.def> */
 
 #endif /* AfterVendorCF */
diff -ur xc.vanilla/fonts/PEX/to_wfont.y xc/fonts/PEX/to_wfont.y
--- xc.vanilla/fonts/PEX/to_wfont.y	Mon Nov 21 23:11:41 1994
+++ xc/fonts/PEX/to_wfont.y	Sun May 26 10:43:00 1996
@@ -617,7 +617,7 @@
 	}
 
 	(void) fclose(fp);
-	freeall();
+/*	freeall(); */
 #	undef BY_BYE
 }
 
diff -ur xc.vanilla/programs/Xserver/Imakefile xc/programs/Xserver/Imakefile
--- xc.vanilla/programs/Xserver/Imakefile	Sat Feb  3 00:44:47 1996
+++ xc/programs/Xserver/Imakefile	Thu May 23 18:52:47 1996
@@ -11,7 +11,7 @@
 #include <Server.tmpl>
 
 #define PreFbLibs $(DIX) $(OS) $(FONT)
-#define BarePostFbLibs $(MFB) $(MI)
+#define BarePostFbLibs $(MFB) $(MI) $(CBRT)
 #define PostFbLibs BarePostFbLibs $(EXTENSIONS)
 #define NoMfbBarePostFbLibs $(MI)
 #define NoMfbPostFbLibs NoMfbBarePostFbLibs $(EXTENSIONS)
diff -ur xc.vanilla/programs/Xserver/cfb/cfbcmap.c xc/programs/Xserver/cfb/cfbcmap.c
--- xc.vanilla/programs/Xserver/cfb/cfbcmap.c	Mon Apr 18 02:28:46 1994
+++ xc/programs/Xserver/cfb/cfbcmap.c	Thu May 23 18:52:47 1996
@@ -34,6 +34,7 @@
 #include "scrnintstr.h"
 #include "colormapst.h"
 #include "resource.h"
+#include <syslog.h>
 
 #ifdef	STATIC_COLOR
 
@@ -156,6 +157,7 @@
 	limr = pVisual->redMask >> pVisual->offsetRed;
 	limg = pVisual->greenMask >> pVisual->offsetGreen;
 	limb = pVisual->blueMask >> pVisual->offsetBlue;
+
 	for(i = 0; i <= maxent; i++)
 	{
 	    /* rescale to [0..65535] then rgb bits */
@@ -302,8 +304,9 @@
     if (CreateColormap(pScreen->defColormap, pScreen, pVisual, &cmap,
 		       (pVisual->class & DynamicClass) ? AllocNone : AllocAll,
 		       0)
-	!= Success)
+	!= Success) {
 	return FALSE;
+    }
     wp = pScreen->whitePixel;
     bp = pScreen->blackPixel;
     if ((AllocColor(cmap, &ones, &ones, &ones, &wp, 0) !=
diff -ur xc.vanilla/programs/Xserver/cfb/stipsparc.s xc/programs/Xserver/cfb/stipsparc.s
--- xc.vanilla/programs/Xserver/cfb/stipsparc.s	Mon Apr 18 02:29:09 1994
+++ xc/programs/Xserver/cfb/stipsparc.s	Mon May 27 09:24:03 1996
@@ -85,7 +85,7 @@
 #define ForEachBits	LY4
 #define NextBits	LY5
 
-#ifdef SVR4
+#if defined(SVR4) || ( defined(linux) && defined(__ELF__) )
 #ifdef TETEXT
 #define	_cfbStippleStack	cfbStippleStackTE
 #else
diff -ur xc.vanilla/programs/Xserver/cfb/stipsprc32.s xc/programs/Xserver/cfb/stipsprc32.s
--- xc.vanilla/programs/Xserver/cfb/stipsprc32.s	Mon Apr 18 02:29:10 1994
+++ xc/programs/Xserver/cfb/stipsprc32.s	Mon May 27 09:10:23 1996
@@ -81,7 +81,7 @@
 #define ForEachBits	LY4
 #define NextBits	LY5
 
-#ifdef SVR4
+#if defined(SVR4) || defined(linux)
 #ifdef TETEXT
 #define	_cfb32StippleStack	cfb32StippleStackTE
 #else
diff -ur xc.vanilla/programs/Xserver/dix/colormap.c xc/programs/Xserver/dix/colormap.c
--- xc.vanilla/programs/Xserver/dix/colormap.c	Fri May 19 03:08:14 1995
+++ xc/programs/Xserver/dix/colormap.c	Thu May 23 18:52:48 1996
@@ -58,6 +58,8 @@
 #include "scrnintstr.h"
 #include "resource.h"
 #include "windowstr.h"
+#include <syslog.h>
+#include <malloc.h>
 
 extern XID clientErrorValue;
 
@@ -269,21 +271,25 @@
     register	EntryPtr	pent;
     int		i;
     register	Pixel	*ppix, **pptr;
+    unsigned long 		mysize;
 
     class = pVisual->class;
-    if(!(class & DynamicClass) && (alloc != AllocNone) && (client != SERVER_ID))
+    if(!(class & DynamicClass) && (alloc != AllocNone) && (client != SERVER_ID)) {
 	return (BadMatch);
+    }
 
     size = pVisual->ColormapEntries;
     sizebytes = (size * sizeof(Entry)) +
 		(MAXCLIENTS * sizeof(Pixel *)) +
 		(MAXCLIENTS * sizeof(int));
-    if ((class | DynamicClass) == DirectColor)
+    if ((class | DynamicClass) == DirectColor) {
 	sizebytes *= 3;
+    }
     sizebytes += sizeof(ColormapRec);
-    pmap = (ColormapPtr) xalloc(sizebytes);
-    if (!pmap)
+    pmap = (ColormapPtr) xalloc((unsigned long)sizebytes);
+    if (!pmap) {
 	return (BadAlloc);
+    }
     pmap->red = (EntryPtr)((char *)pmap + sizeof(ColormapRec));    
     sizebytes = size * sizeof(Entry);
     pmap->clientPixelsRed = (Pixel **)((char *)pmap->red + sizebytes);
@@ -386,8 +392,9 @@
 	    pmap->numPixelsBlue[client] = size;
 	}
     }
-    if (!AddResource(mid, RT_COLORMAP, (pointer)pmap))
+    if (!AddResource(mid, RT_COLORMAP, (pointer)pmap)) {
 	return (BadAlloc);
+    }
     /* If the device wants a chance to initialize the colormap in any way,
      * this is it.  In specific, if this is a Static colormap, this is the
      * time to fill in the colormap's values */
diff -ur xc.vanilla/programs/Xserver/dix/main.c xc/programs/Xserver/dix/main.c
--- xc.vanilla/programs/Xserver/dix/main.c	Sat Apr  8 00:59:06 1995
+++ xc/programs/Xserver/dix/main.c	Thu May 23 18:52:48 1996
@@ -65,6 +65,7 @@
 #include "servermd.h"
 #include "site.h"
 #include "dixfont.h"
+#include <syslog.h>
 
 extern CARD32 defaultScreenSaverTime;
 extern CARD32 defaultScreenSaverInterval;
@@ -547,12 +548,15 @@
     if (!pScreen)
 	return -1;
 
-    pScreen->devPrivates = (DevUnion *)xalloc(screenPrivateCount *
+    if (screenPrivateCount != 0) {
+      pScreen->devPrivates = (DevUnion *)xalloc(screenPrivateCount *
 					      sizeof(DevUnion));
-    if (!pScreen->devPrivates && screenPrivateCount)
-    {
-	xfree(pScreen);
-	return -1;
+    } else {
+      if (!pScreen->devPrivates && screenPrivateCount)
+      {
+	  xfree(pScreen);
+	  return -1;
+      }
     }
     pScreen->myNum = i;
     pScreen->WindowPrivateLen = 0;
diff -ur xc.vanilla/programs/Xserver/hw/sun/Imakefile xc/programs/Xserver/hw/sun/Imakefile
--- xc.vanilla/programs/Xserver/hw/sun/Imakefile	Thu Jul 28 22:44:16 1994
+++ xc/programs/Xserver/hw/sun/Imakefile	Tue May 28 18:19:26 1996
@@ -21,7 +21,7 @@
 OFILES = sunInit.o sunInitMono.o sunInExMono.o sunInitMulti.o
 #endif
 
-OBJS = 	sunCfb.o \
+OBJs = 	sunCfb.o \
 	sunCfb24.o \
 	sunCursor.o \
 	sunFbs.o \
@@ -31,6 +31,11 @@
 	sunMouse.o \
 	sunGX.o \
 	sunKeyMap.o
+#ifdef LinuxArchitecture
+OBJS = $(OBJs) linux.o
+#else
+OBJS = $(OBJs)
+#endif
 
    INCLUDES = -I. -I../.. -I../../mi -I../../mfb -I../../cfb -I../../cfb32 \
 	      -I../../include -I$(INCLUDESRC) -I$(FONTINCSRC)
diff -ur xc.vanilla/programs/Xserver/hw/sun/constype.c xc/programs/Xserver/hw/sun/constype.c
--- xc.vanilla/programs/Xserver/hw/sun/constype.c	Thu Oct  5 12:36:06 1995
+++ xc/programs/Xserver/hw/sun/constype.c	Sat May 25 22:25:52 1996
@@ -58,7 +58,11 @@
 	dev = argv[1];
 	argc--; argv++;
     } else
+#ifndef linux
 	dev = "/dev/fb";
+#else
+	dev = "/dev/fb0";
+#endif
     consoleid = wu_fbid(dev, &retval);
     if (argc > 1 && strncmp (argv[1], "-num", strlen(argv[1])) == 0)
 	print_num = 1;
@@ -76,7 +80,11 @@
 #include <sys/fbio.h>
 #else
 #ifndef __NetBSD__
+# ifndef linux
 #include <sun/fbio.h>
+# else
+#include <asm/fbio.h>
+# endif
 #else
 #include <machine/fbio.h>
 #endif
diff -ur xc.vanilla/programs/Xserver/hw/sun/kbd_mode.c xc/programs/Xserver/hw/sun/kbd_mode.c
--- xc.vanilla/programs/Xserver/hw/sun/kbd_mode.c	Thu Oct  5 12:36:40 1995
+++ xc/programs/Xserver/hw/sun/kbd_mode.c	Sat May 25 22:25:24 1996
@@ -53,8 +53,37 @@
 #endif
 #else
 #ifndef __NetBSD__
+# ifndef linux
 #include <sundev/kbio.h>
 #include <sundev/kbd.h>
+# else
+#include <asm/kbio.h>
+/*
+ * Commands to the Sun-2 keyboard.
+ */
+#define KBD_CMD_RESET           0x01    /* Reset keyboard as if power-up */
+#define KBD_CMD_BELL            0x02    /* Turn on the bell */
+#define KBD_CMD_NOBELL          0x03    /* Turn off the bell */
+#define KBD_CMD_LED1            0x04    /* Turn on LED 1 */
+#define KBD_CMD_NOLED1          0x05    /* Turn off LED 1 */
+#define KBD_CMD_LED2            0x06    /* Turn on LED 2 */
+#define KBD_CMD_NOLED2          0x07    /* Turn off LED 2 */
+ 
+/*
+ * Commands to the Type 3 keyboard.  KBD_CMD_BELL & KBD_CMD_NOBELL work
+ * as well.
+ */
+#define KBD_CMD_CLICK           0x0A    /* Turn on the click annunciator */
+#define KBD_CMD_NOCLICK         0x0B    /* Turn off the click annunciator */
+ 
+/*
+ * Commands to the Type 4 keyboard, in addition to those above.
+ */
+#define KBD_CMD_SETLED          0x0E    /* Set keyboard LED's */
+#define KBD_CMD_GETLAYOUT       0x0F    /* Request that keyboard indicate layout
+ */
+
+# endif
 #else
 #include <machine/kbio.h>
 #include <machine/kbd.h>
diff -ur xc.vanilla/programs/Xserver/hw/sun/linux.c xc/programs/Xserver/hw/sun/linux.c
--- xc.vanilla/programs/Xserver/hw/sun/linux.c	Wed May 29 15:15:05 1996
+++ xc/programs/Xserver/hw/sun/linux.c	Wed May 29 14:55:48 1996
@@ -0,0 +1,294 @@
+/* $Xsun: xc/programs/Xserver/hw/sun/linux.c,v 3.3 1995/06/24 10:29:11 dawes Exp $ */
+/*
+ * Copyright 1992 by Orest Zborowski <obz@Kodak.com>
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ * Copyright 1996 by Jakub Jelinek <jj@sunsite.mff.cuni.cz>
+ *
+ * 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, and that the names of Orest Zborowski and David Wexelblat 
+ * not be used in advertising or publicity pertaining to distribution of 
+ * the software without specific, written prior permission.  Orest Zborowski
+ * and David Wexelblat make no representations about the suitability of this 
+ * software for any purpose.  It is provided "as is" without express or 
+ * implied warranty.
+ *
+ * OREST ZBOROWSKI AND DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD 
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 
+ * FITNESS, IN NO EVENT SHALL OREST ZBOROWSKI OR DAVID WEXELBLAT 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.
+ *
+ */
+/* $XConsortium: linux.c /main/4 1995/11/13 05:58:38 kaleb $ */
+
+#include "X.h"
+#include "Xmd.h"
+#include "input.h"
+#include "scrnintstr.h"
+#include <linux/vt.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <asm/ioctls.h>
+#include <signal.h>
+#include <linux/kd.h>
+#include <errno.h>
+
+static Bool KeepTty = FALSE;
+static int VTnum = -1;
+static int activeVT = -1;
+int consoleFd = -1;
+int vtno;
+Bool vtRequestsPending = FALSE;
+Bool vtSwitchSema = TRUE;
+DevicePtr linuxMouse, linuxKeyboard;
+
+#include <stdio.h>
+static void Debug(char *fmt, int arg)
+{
+    FILE *f = fopen("/tmp/Xdebug","a");
+    fprintf(f,fmt,arg);
+    fclose(f);
+}
+#define Debug0(fmt) Debug(fmt,0)
+
+static void vtRequest(int sig)
+{
+    vtRequestsPending = TRUE;
+    Debug0("Got SIGUSR1\n");
+    signal(SIGUSR1,vtRequest);
+}
+
+static void VTSwitch()
+{
+    int j;
+	
+    vtRequestsPending = FALSE;
+    if (vtSwitchSema) {
+	Debug0("SwitchAway\n");
+	DisableDevice((DeviceIntPtr)linuxMouse);
+	DisableDevice((DeviceIntPtr)linuxKeyboard);
+	if (ioctl(consoleFd, VT_RELDISP, 1) < 0) {
+	    SaveScreens(SCREEN_SAVER_FORCER,ScreenSaverReset);
+	    EnableDevice((DeviceIntPtr)linuxMouse);
+	    EnableDevice((DeviceIntPtr)linuxKeyboard);
+	} else
+	    vtSwitchSema = FALSE;
+    } else {
+	Debug0("SwitchTo\n");
+	if (ioctl(consoleFd, VT_RELDISP, VT_ACKACQ) < 0)
+	    return;
+	vtSwitchSema = TRUE;
+	SaveScreens(SCREEN_SAVER_FORCER,ScreenSaverReset);
+	EnableDevice((DeviceIntPtr)linuxMouse);
+	EnableDevice((DeviceIntPtr)linuxKeyboard);
+    }
+}
+
+/* ARGSUSED */
+void linuxBlock(pointer blockData, OSTimePtr pTimeout, pointer pReadmask)
+{
+}
+
+/* ARGSUSED */
+void linuxWakeup(pointer blockData, int result, pointer pReadmask)
+{
+    if (vtRequestsPending) VTSwitch();
+}
+
+void OpenLinuxConsole()
+{
+    int i, fd;
+    struct vt_mode VT;
+    char vtname[11];
+    struct vt_stat vts;
+
+    if (serverGeneration == 1) 
+    {
+	/* check if we're run with euid==0 */
+	if (geteuid() != 0)
+	{
+	    FatalError("OpenLinuxConsole: Server must be suid root\n");
+	}
+
+	RegisterBlockAndWakeupHandlers(linuxBlock, linuxWakeup, (void *)0);
+	/*
+	 * setup the virtual terminal manager
+	 */
+	if (VTnum != -1)
+	{
+	    vtno = VTnum;
+	}
+	else 
+	{
+	    if ((fd = open("/dev/console",O_WRONLY,0)) < 0) 
+	    {
+		FatalError(
+		    "OpenLinuxConsole: Cannot open /dev/console (%s)\n",
+		    strerror(errno));
+	    }
+	    if ((ioctl(fd, VT_OPENQRY, &vtno) < 0) ||
+		(vtno == -1))
+	    {
+		FatalError("OpenLinuxConsole: Cannot find a free VT\n");
+	    }
+	    close(fd);
+	}
+	ErrorF("(using VT number %d)\n\n", vtno);
+
+	sprintf(vtname,"/dev/tty%d",vtno); /* /dev/tty1-64 */
+
+	if (!KeepTty)
+	{
+	    setpgrp();
+	}
+
+	if ((consoleFd = open(vtname, O_RDWR|O_NDELAY, 0)) < 0)
+	{
+	    FatalError("OpenLinuxConsole: Cannot open %s (%s)\n",
+		       vtname, strerror(errno));
+	}
+
+	/* change ownership of the vt */
+	chown(vtname, getuid(), getgid());
+
+	/*
+	 * the current VT device we're running on is not "console", we want
+	 * to grab all consoles too
+	 */
+	chown("/dev/console", getuid(), getgid());
+	chown("/dev/tty0", getuid(), getgid());
+
+	/*
+	 * Linux doesn't switch to an active vt after the last close of a vt,
+	 * so we do this ourselves by remembering which is active now.
+	 */
+	if (ioctl(consoleFd, VT_GETSTATE, &vts) == 0)
+	{
+	    activeVT = vts.v_active;
+	}
+	Debug("activeVT %d\n",activeVT);
+	
+	if (!KeepTty)
+	{
+	    /*
+	     * Detach from the controlling tty to avoid char loss
+	     */
+	    if ((i = open("/dev/tty",O_RDWR)) >= 0)
+	    {
+		ioctl(i, TIOCNOTTY, 0);
+		close(i);
+	    }
+	}
+
+	/*
+	 * now get the VT
+	 */
+	if (ioctl(consoleFd, VT_ACTIVATE, vtno) != 0)
+	{
+	    ErrorF("OpenLinuxConsole: VT_ACTIVATE failed\n");
+	}
+	if (ioctl(consoleFd, VT_WAITACTIVE, vtno) != 0)
+	{
+	    ErrorF("OpenLinuxConsole: VT_WAITACTIVE failed\n");
+	}
+	if (ioctl(consoleFd, VT_GETMODE, &VT) < 0) 
+	{
+	    FatalError ("OpenLinuxConsole: VT_GETMODE failed\n");
+	}
+
+	signal(SIGUSR1, vtRequest);
+
+	VT.mode = VT_PROCESS;
+	VT.relsig = SIGUSR1;
+	VT.acqsig = SIGUSR1;
+	if (ioctl(consoleFd, VT_SETMODE, &VT) < 0) 
+	{
+	    FatalError("OpenLinuxConsole: VT_SETMODE VT_PROCESS failed\n");
+	}
+#if 0    	
+	if (ioctl(consoleFd, KDSETMODE, KD_GRAPHICS) < 0)
+	{
+	    FatalError("OpenLinuxConsole: KDSETMODE KD_GRAPHICS failed\n");
+	}
+#endif	
+    }
+    else 
+    {
+	/* serverGeneration != 1 */
+	/*
+	 * now get the VT
+	 */
+	if (ioctl(consoleFd, VT_ACTIVATE, vtno) != 0)
+	{
+	    ErrorF("OpenLinuxConsole: VT_ACTIVATE failed\n");
+	}
+	if (ioctl(consoleFd, VT_WAITACTIVE, vtno) != 0)
+	{
+	    ErrorF("OpenLinuxConsole: VT_WAITACTIVE failed\n");
+	}
+    }
+    return;
+}
+
+void CloseLinuxConsole()
+{
+    struct vt_mode   VT;
+
+#if 0
+    ioctl(consoleFd, KDSETMODE, KD_TEXT);  /* Back to text mode ... */
+#endif    
+    if (ioctl(consoleFd, VT_GETMODE, &VT) != -1)
+    {
+	VT.mode = VT_AUTO;
+	if (ioctl(consoleFd, VT_SETMODE, &VT) < 0) { /* set dflt vt handling */
+	    ErrorF("OpenLinuxConsole: VT_SETMODE failed\n");
+	    Debug0("Setmode failed\n");
+	}
+    }
+    /*
+     * Perform a switch back to the active VT when we were started
+     */
+    if (activeVT >= 0)
+    {
+	if (ioctl(consoleFd, VT_ACTIVATE, activeVT) < 0) {
+	    ErrorF("OpenLinuxConsole: VT_ACTIVATE failed\n");
+	    Debug0("Activate failed\n");
+	}
+	if (ioctl(consoleFd, VT_WAITACTIVE, activeVT) < 0) {
+	    ErrorF("OpenLinuxConsole: VT_WAITACTIVE failed\n");
+	    Debug0("Wait active failed\n");
+	}
+	activeVT = -1;
+    }
+    close(consoleFd);                /* make the vt-manager happy */
+    return;
+}
+
+int linuxProcessArgument (int argc, char *argv[], int i)
+{
+	/*
+	 * Keep server from detaching from controlling tty.  This is useful 
+	 * when debugging (so the server can receive keyboard signals.
+	 */
+	if (!strcmp(argv[i], "-keeptty"))
+	{
+		KeepTty = TRUE;
+		return(1);
+	}
+	if ((argv[i][0] == 'v') && (argv[i][1] == 't'))
+	{
+		if (sscanf(argv[i], "vt%2d", &VTnum) == 0)
+		{
+			UseMsg();
+			VTnum = -1;
+			return(0);
+		}
+		return(1);
+	}
+	return(0);
+}
diff -ur xc.vanilla/programs/Xserver/hw/sun/sun.h xc/programs/Xserver/hw/sun/sun.h
--- xc.vanilla/programs/Xserver/hw/sun/sun.h	Sun Oct  8 16:11:23 1995
+++ xc/programs/Xserver/hw/sun/sun.h	Sat May 25 21:36:16 1996
@@ -33,10 +33,15 @@
 /* system headers common to both SunOS and Solaris */
 #include <sys/param.h>
 #include <sys/file.h>
-#include <sys/filio.h>
 #include <sys/ioctl.h>
 #include <sys/resource.h>
 
+#ifndef linux
+#include <sys/filio.h>
+#else
+#include <linux/termios.h>
+#endif
+
 #ifdef SVR4
 # ifdef X_POSIX_C_SOURCE
 #  define _POSIX_C_SOURCE X_POSIX_C_SOURCE
@@ -51,8 +56,8 @@
 
 #include <fcntl.h>
 
-#ifndef __bsdi_
-# ifndef __NetBSD__
+#ifndef linux
+# ifndef __NetBSD__ 
 #  ifndef i386
 #   include <poll.h>
 #  else
@@ -78,15 +83,15 @@
  */
 #ifdef SVR4
 # include <sys/fbio.h>
-# include <sys/kbd.h>
 # include <sys/kbio.h>
+# include <sys/kbd.h>
 # include <sys/msio.h>
 # include <sys/vuid_event.h>
 # include <sys/memreg.h>
 # include <stropts.h>
 # define usleep(usec) poll((struct pollfd *) 0, (size_t) 0, usec / 1000)
 #else
-# ifndef __NetBSD__
+# if !defined (__NetBSD__) && !defined (__linux__) && !defined (linux)
 #  include <sun/fbio.h>
 #  include <sundev/kbd.h>
 #  include <sundev/kbio.h>
@@ -99,6 +104,57 @@
 extern int setrlimit();
 extern int getpagesize();
 # else
+#  ifdef linux
+#define KB_KLUNK        0x00            /* Micro Switch 103SD32-2 */
+#define KB_VT100        0x01            /* Keytronics VT100 compatible */
+#define KB_SUN2         0x02            /* Sun-2 custom keyboard */
+#define KB_SUN3         0x03            /* Type 3 Sun keyboard */
+#define KB_SUN4         0x04            /* Type 4 Sun keyboard */
+#define KB_VT220        0x81            /* Emulation vt220 */
+#define KB_VT220I       0x82            /* International vt220 Emulation */
+
+#define KB_ASCII        0x0F            /* Ascii terminal masquerading as kbd */
+
+/*
+ * Commands to the Sun-2 keyboard.
+ */
+#define KBD_CMD_RESET           0x01    /* Reset keyboard as if power-up */
+#define KBD_CMD_BELL            0x02    /* Turn on the bell */
+#define KBD_CMD_NOBELL          0x03    /* Turn off the bell */
+#define KBD_CMD_LED1            0x04    /* Turn on LED 1 */
+#define KBD_CMD_NOLED1          0x05    /* Turn off LED 1 */
+#define KBD_CMD_LED2            0x06    /* Turn on LED 2 */
+#define KBD_CMD_NOLED2          0x07    /* Turn off LED 2 */
+ 
+/*
+ * Commands to the Type 3 keyboard.  KBD_CMD_BELL & KBD_CMD_NOBELL work
+ * as well.
+ */
+#define KBD_CMD_CLICK           0x0A    /* Turn on the click annunciator */
+#define KBD_CMD_NOCLICK         0x0B    /* Turn off the click annunciator */
+ 
+/*
+ * Commands to the Type 4 keyboard, in addition to those above.
+ */
+#define KBD_CMD_SETLED          0x0E    /* Set keyboard LED's */
+#define KBD_CMD_GETLAYOUT       0x0F    /* Request that keyboard indicate layout
+ */
+ 
+/*
+ * Type 4 keyboard LED masks (used to set LED's)
+ */
+#define LED_NUM_LOCK    0x1
+#define LED_COMPOSE     0x2
+#define LED_SCROLL_LOCK 0x4
+#define LED_CAPS_LOCK   0x8
+
+# include <asm/fbio.h>
+# include <asm/kbio.h>
+# include <asm/vuid_event.h>
+# include <asm/memreg.h>
+# include <signal.h>
+#endif
+
 #  ifdef __NetBSD__
 #   include <machine/fbio.h>
 #   include <machine/kbd.h>
diff -ur xc.vanilla/programs/Xserver/hw/sun/sunCfb.c xc/programs/Xserver/hw/sun/sunCfb.c
--- xc.vanilla/programs/Xserver/hw/sun/sunCfb.c	Thu Oct  5 12:36:45 1995
+++ xc/programs/Xserver/hw/sun/sunCfb.c	Thu May 23 19:00:46 1996
@@ -87,6 +87,7 @@
 #include "sun.h"
 #include "cfb/cfb.h"
 #include "mi/miline.h"
+#include <syslog.h>
 
 #define GXZEROLINEBIAS	(OCTANT1 | OCTANT3 | OCTANT4 | OCTANT6)
 
@@ -270,7 +271,7 @@
 }
 
 #if !defined(i386) && !defined(__bsdi__) /* { */
-
+#ifndef linux /* Only have definations for cg6 */
 #ifdef SVR4
 #include <sys/cg2reg.h>
 #else
@@ -399,6 +400,7 @@
 	cfbCreateDefColormap, sunSaveScreen, (int) ((CG4Ptr) 0)->cpixel);
 }
 
+#endif /* !linux */
 #ifdef FBTYPE_SUNFAST_COLOR /* { */
 
 #define CG6_MMAP_OFFSET 0x70000000
@@ -421,8 +423,9 @@
 			sunFbs[screen].info.fb_height + CG6_IMAGE_OFFSET
 	if ((fb = sunMemoryMap (FBSIZE,
 			     (off_t) CG6_MMAP_OFFSET, 
-			     sunFbs[screen].fd)) == NULL)
+			     sunFbs[screen].fd)) == NULL) {
 	    return FALSE;
+        }
 	sunFbs[screen].fb = fb;
 #undef FBSIZE
     }
@@ -436,8 +439,9 @@
 	    sunFbs[screen].info.fb_depth))
 	return FALSE;
     if (sunNoGX == FALSE) {
-	if (!sunGXInit (pScreen, &sunFbs[screen]))
+	if (!sunGXInit (pScreen, &sunFbs[screen])) {
 	    return FALSE;
+	}
     }
     if (!sunCfbFinishScreenInit(pScreen,
 	    sunFbs[screen].fb + CG6_IMAGE_OFFSET,
@@ -445,14 +449,16 @@
 	    sunFbs[screen].info.fb_height,
 	    monitorResolution, monitorResolution, 
 	    sunFbs[screen].info.fb_width,
-	    sunFbs[screen].info.fb_depth))
+	    sunFbs[screen].info.fb_depth)) {
 	return FALSE;
+    }
     if (sunNoGX == FALSE) {
 	miSetZeroLineBias(pScreen, GXZEROLINEBIAS);
     }
     CGScreenInit (pScreen);
-    if (!sunScreenInit (pScreen))
+    if (!sunScreenInit (pScreen)) {
 	return FALSE;
+    }
     sunSaveScreen (pScreen, SCREEN_SAVER_OFF);
     return cfbCreateDefColormap(pScreen);
 }
diff -ur xc.vanilla/programs/Xserver/hw/sun/sunFbs.c xc/programs/Xserver/hw/sun/sunFbs.c
--- xc.vanilla/programs/Xserver/hw/sun/sunFbs.c	Thu Oct  5 12:36:47 1995
+++ xc/programs/Xserver/hw/sun/sunFbs.c	Thu May 23 19:00:46 1996
@@ -103,7 +103,7 @@
     mapsize = ((int) len + pagemask) & ~pagemask;
     addr = 0;
 
-#if !defined(__bsdi__) && !defined(_MAP_NEW)
+#if !defined(linux) && (!defined(__bsdi__) && !defined(_MAP_NEW))
     if ((addr = (caddr_t) valloc (mapsize)) == NULL) {
 	Error ("Couldn't allocate frame buffer memory");
 	(void) close (fd);
@@ -118,12 +118,13 @@
      */
     if ((int)(mapaddr = (pointer) mmap (addr,
 		mapsize,
-		PROT_READ | PROT_WRITE, MAP_PRIVATE,
-		fd, off)) == -1)
+		PROT_READ | PROT_WRITE, MAP_PRIVATE|_MAP_NEW,
+		fd, off)) == -1){
 	mapaddr = (pointer) mmap (addr,
 		    mapsize,
-		    PROT_READ | PROT_WRITE, MAP_SHARED,
+		    PROT_READ | PROT_WRITE, MAP_SHARED|_MAP_NEW,
 		    fd, off);
+}
     if (mapaddr == (pointer) -1) {
 	Error ("mapping frame buffer memory");
 	(void) close (fd);
@@ -267,8 +268,9 @@
     if (!fb) {
 	if ((fb = sunMemoryMap ((size_t) sunFbs[scrn].info.fb_size, 
 			     offset, 
-			     sunFbs[scrn].fd)) == NULL)
+			     sunFbs[scrn].fd)) == NULL) {
 	    return FALSE;
+        }
 	sunFbs[scrn].fb = fb;
     }
     /* mfbScreenInit() or cfbScreenInit() */
diff -ur xc.vanilla/programs/Xserver/hw/sun/sunInit.c xc/programs/Xserver/hw/sun/sunInit.c
--- xc.vanilla/programs/Xserver/hw/sun/sunInit.c	Thu Oct  5 12:36:49 1995
+++ xc/programs/Xserver/hw/sun/sunInit.c	Wed May 29 13:41:05 1996
@@ -50,6 +50,7 @@
 #include    "mi.h"
 #include    "mibstore.h"
 #include    "cfb.h"
+#include <syslog.h>
 
 /* maximum pixmap depth */
 #ifndef SUNMAXDEPTH
@@ -85,7 +86,7 @@
 #endif
 );
 #define CG3I sunCG3Init
-#if defined(i386) || defined(__bsdi__) /* { */
+#if defined(linux) || defined(i386) || defined(__bsdi__) /* { */
 #define CG2I NULL
 #define CG4I NULL
 #else /* }{ */
@@ -240,7 +241,11 @@
 #if SUNMAXDEPTH > 8 /* { */
     CGEIGHT0DEV,
 #endif /* } */
+#ifndef linux
     "/dev/fb"
+#else
+    "/dev/fb0"
+#endif
 };
 #endif /* } */
 
@@ -311,9 +316,9 @@
 	    if (fbattr)
 		sunFbs[screen].info = fbattr->fbtype;
 	    sunFbs[screen].fbPriv = (pointer) fbattr;
-	    if (fbattr && 
-		fbattr->fbtype.fb_type < FBTYPE_LASTPLUSONE && 
-		!sunFbData[fbattr->fbtype.fb_type].init) {
+	    if ((fbattr) && 
+		(fbattr->fbtype.fb_type < FBTYPE_LASTPLUSONE) && 
+		(!sunFbData[fbattr->fbtype.fb_type].init)) {
 		int _i;
 		ret = FALSE;
 		for (_i = 0; _i < FB_ATTR_NEMUTYPES; _i++) {
@@ -442,7 +447,7 @@
  * matter since no 386i has ever been shipped with a type 3 keyboard.
  * SunOS 4.1 no longer needs this kludge.
  */
-#if !defined(i386) && !defined(KIOCGKEY)
+#if !defined(i386) && defined(KIOCGKEY)
 #define TYPE4KEYBOARDOVERRIDE
 #endif
 
@@ -520,6 +525,9 @@
     }
 }
 
+#ifdef linux
+extern void OpenLinuxConsole();
+#endif
 /*-
  *-----------------------------------------------------------------------
  * InitOutput --
@@ -579,6 +587,9 @@
 	    ErrorF("InitOutput: can't put stderr in non-block mode\n");
 	}
     }
+#ifdef linux
+    OpenLinuxConsole();
+#endif    
     pScreenInfo->imageByteOrder = IMAGE_BYTE_ORDER;
     pScreenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
     pScreenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
@@ -596,16 +607,20 @@
 	for (scr = 0; scr < MAXSCREENS; scr++)
 	    sunFbs[scr].fd = -1;
 	devList = GetDeviceList (argc, argv);
-	for (i = 0, scr = 0; devList[i] != NULL && scr < MAXSCREENS; i++)
-	    if (OpenFrameBuffer (devList[i], scr))
+	for (i = 0, scr = 0; devList[i] != NULL && scr < MAXSCREENS; i++) {
+	    if (OpenFrameBuffer (devList[i], scr)) {
 		scr++;
+            }
+        }
 	sunDevsInited = TRUE;
 	xfree (devList);
     }
-    for (scr = 0; scr < MAXSCREENS; scr++)
-	if (sunFbs[scr].fd != -1)
+    for (scr = 0; scr < MAXSCREENS; scr++) {
+	if (sunFbs[scr].fd != -1) {
 	    (void) AddScreen (sunFbData[sunFbs[scr].info.fb_type].init, 
 			      argc, argv);
+	}
+    }
     (void) OsSignal(SIGWINCH, SIG_IGN);
 }
 
@@ -630,11 +645,18 @@
 {
     DevicePtr	p, k;
     extern Bool mieqInit();
+#ifdef linux
+    extern DevicePtr linuxMouse, linuxKeyboard;
+#endif    
 
     p = AddInputDevice(sunMouseProc, TRUE);
     k = AddInputDevice(sunKbdProc, TRUE);
     if (!p || !k)
 	FatalError("failed to create input devices in InitInput");
+#ifdef linux
+    linuxMouse = p;
+    linuxKeyboard = k;
+#endif	
 
     RegisterPointerDevice(p);
     RegisterKeyboardDevice(k);
diff -ur xc.vanilla/programs/Xserver/hw/sun/sunIo.c xc/programs/Xserver/hw/sun/sunIo.c
--- xc.vanilla/programs/Xserver/hw/sun/sunIo.c	Thu Oct  5 12:36:52 1995
+++ xc/programs/Xserver/hw/sun/sunIo.c	Wed May 29 14:39:08 1996
@@ -188,6 +188,11 @@
 void
 ddxGiveUp()
 {
+#ifdef linux
+    extern void CloseLinuxConsole();
+    
+    CloseLinuxConsole();
+#endif
     AbortDDX ();
 }
 
@@ -199,6 +204,13 @@
 {
     extern void UseMsg();
 
+#ifdef linux
+    extern int linuxProcessArgument(int argc, char *argv[], int i);
+    int ret;
+    
+    ret = linuxProcessArgument(argc, argv, i);
+    if (ret) return ret;
+#endif
 #ifndef XKB
     if (strcmp (argv[i], "-ar1") == 0) {	/* -ar1 int */
 	if (++i >= argc) UseMsg ();
@@ -277,4 +289,10 @@
     ErrorF("-cg4frob            don't use the mono plane of the cgfour\n");
     ErrorF("-noGX               treat the GX as a dumb frame buffer\n");
 #endif
+#ifdef linux
+    ErrorF("vtXX                use the specified VT number\n");
+    ErrorF("-keeptty               ");
+    ErrorF("don't detach controlling tty (for debugging only)\n");
+#endif
 }
+
diff -ur xc.vanilla/programs/Xserver/hw/sun/sunKbd.c xc/programs/Xserver/hw/sun/sunKbd.c
--- xc.vanilla/programs/Xserver/hw/sun/sunKbd.c	Sat Feb  3 21:49:34 1996
+++ xc/programs/Xserver/hw/sun/sunKbd.c	Wed May 29 13:02:24 1996
@@ -80,6 +80,11 @@
 extern KeySymsRec sunKeySyms[];
 extern SunModmapRec* sunModMaps[];
 
+#ifdef linux
+extern int consoleFd;
+#include <linux/vt.h>
+#endif
+
 long	  	  sunAutoRepeatInitiate = 1000 * AUTOREPEAT_INITIATE;
 long	  	  sunAutoRepeatDelay = 1000 * AUTOREPEAT_DELAY;
 
@@ -783,7 +788,7 @@
 	|| ksym == SunXK_Compose
 	|| (keyModifiers & LockMask))) 
 	return TRUE;
-
+	
     kptr = &device->key->down[keycode >> 3];
     bit = 1 << (keycode & 7);
     if ((*kptr & bit) &&
@@ -835,6 +840,9 @@
     xEvent		xE;
     BYTE		keycode;
     CARD8		keyModifiers;
+#ifdef linux
+    KeySym		ksym;
+#endif    
 
     keycode = (fe->id & 0x7f) + MIN_KEYCODE;
 
@@ -855,6 +863,32 @@
     xE.u.keyButtonPointer.time = TVTOMILLI(fe->time);
     xE.u.u.type = ((fe->value == VKEY_UP) ? KeyRelease : KeyPress);
     xE.u.u.detail = keycode;
+    
+#ifdef linux
+    if (xE.u.u.type == KeyPress 
+    	&& (device->key->state & ControlMask)
+    	&& (device->key->state & Mod1Mask))
+    	switch (ksym = device->key->curKeySyms.map[(fe->id - 1) * device->key->curKeySyms.mapWidth]) {
+    		case XK_BackSpace:
+    			GiveUp(0);
+    			return;
+    		case XK_F1:
+    		case XK_F2:
+    		case XK_F3:
+    		case XK_F4:
+    		case XK_F5:
+    		case XK_F6:
+    		case XK_F7:
+    		case XK_F8:
+    		case XK_F9:
+    		case XK_F10:
+    		case XK_F11:
+    		case XK_F12:
+    			ioctl(consoleFd, VT_ACTIVATE, ksym - XK_F1 + 1);
+    			return;
+    	}
+#endif
+
 #ifdef XKB
     if (noXkbExtension) {
 #endif
diff -ur xc.vanilla/programs/Xserver/include/misc.h xc/programs/Xserver/include/misc.h
--- xc.vanilla/programs/Xserver/include/misc.h	Fri Mar  3 07:54:22 1995
+++ xc/programs/Xserver/include/misc.h	Thu May 23 19:00:46 1996
@@ -93,7 +93,11 @@
 #ifndef MAXSCREENS
 #define MAXSCREENS	3
 #endif
+#if 0
 #define MAXCLIENTS	128
+#else
+#define MAXCLIENTS	64
+#endif
 #define MAXDITS		1
 #define MAXEXTENSIONS	128
 #define MAXFORMATS	8
diff -ur xc.vanilla/programs/Xserver/include/servermd.h xc/programs/Xserver/include/servermd.h
--- xc.vanilla/programs/Xserver/include/servermd.h	Thu Jan  4 23:21:22 1996
+++ xc/programs/Xserver/include/servermd.h	Thu May 23 19:00:46 1996
@@ -133,7 +133,7 @@
 
 #if (defined(sun) && !(defined(i386) && defined(SVR4))) || \
     (defined(AMOEBA) && (defined(sparc) || defined(mc68000))) || \
-    (defined(__NetBSD__) && (defined(__sparc__) || defined(mc68000)))
+    ((defined(sparc) || defined(__NetBSD__)) && (defined(__sparc__) || defined(mc68000))) 
 
 #if defined(sun386) || defined(sun5)
 # define IMAGE_BYTE_ORDER	LSBFirst        /* Values for the SUN only */
@@ -313,7 +313,7 @@
      (defined(__NetBSD__) && defined(__i386__)) || \
      defined(__FreeBSD__) || \
      defined(MACH386) || \
-     defined(linux) || \
+     (defined(linux) && !defined(sparc)) || \
      (defined(AMOEBA) && defined(i80386)) || \
      defined(MINIX))
 
diff -ur xc.vanilla/programs/Xserver/mi/miarc.c xc/programs/Xserver/mi/miarc.c
--- xc.vanilla/programs/Xserver/mi/miarc.c	Wed Dec  6 23:05:38 1995
+++ xc/programs/Xserver/mi/miarc.c	Thu May 23 19:00:46 1996
@@ -69,7 +69,7 @@
 #include "Xfuncproto.h"
 
 static double miDsin(), miDcos(), miDasin(), miDatan2();
-double	cbrt(
+extern double	cbrt(
 #if NeedFunctionPrototypes
 	     double
 #endif
diff -ur xc.vanilla/programs/Xserver/os/utils.c xc/programs/Xserver/os/utils.c
--- xc.vanilla/programs/Xserver/os/utils.c	Sun Jan 14 22:46:43 1996
+++ xc/programs/Xserver/os/utils.c	Thu May 23 19:00:47 1996
@@ -80,6 +80,7 @@
 #if NeedVarargsPrototypes
 #include <stdarg.h>
 #endif
+#include <errno.h>
 
 extern char *display;
 
@@ -796,8 +797,13 @@
 	((random() % MEM_FAIL_SCALE) < Memory_fail))
 	return (unsigned long *)NULL;
 #endif
-    if (ptr = (pointer)malloc(amount))
+errno=0;
+    ptr = (pointer)malloc((size_t)amount);
+
+    if ((ptr) && (errno !=ENOMEM) && (errno!=-ENOMEM))
+    {
 	return (unsigned long *)ptr;
+    }
     if (Must_have_memory)
 	FatalError("Out of memory");
     return (unsigned long *)NULL;
@@ -821,8 +827,9 @@
     }
     /* aligned extra on long word boundary */
     amount = (amount + (sizeof(long) - 1)) & ~(sizeof(long) - 1);
+errno=0;
     ptr = (pointer)malloc(amount);
-    if (!ptr)
+    if ((!ptr) || (errno ==ENOMEM) || (errno==-ENOMEM))
     {
         FatalError("Out of memory");
     }
@@ -869,11 +876,12 @@
 	return (unsigned long *)NULL;
     }
     amount = (amount + (sizeof(long) - 1)) & ~(sizeof(long) - 1);
-    if (ptr)
+    if (ptr) {
         ptr = (pointer)realloc((char *)ptr, amount);
-    else
+    } else {
 	ptr = (pointer)malloc(amount);
-    if (ptr)
+    }
+    if ((ptr) && (errno!=ENOMEM) && (errno!=-ENOMEM))
         return (unsigned long *)ptr;
     if (Must_have_memory)
 	FatalError("Out of memory");
diff -ur xc.vanilla/programs/rgb/Imakefile xc/programs/rgb/Imakefile
--- xc.vanilla/programs/rgb/Imakefile	Sat Jan 27 00:22:18 1996
+++ xc/programs/rgb/Imakefile	Tue May 28 10:11:30 1996
@@ -20,7 +20,7 @@
          OBJS = $(OBJS1) $(OBJS2)
      PROGRAMS = $(RGB_PROG) showrgb
 #if !UseRgbTxt
-#ifdef BSD386Architecture
+#if defined(BSD386Architecture) || ( defined(SparcArchitecture) && defined(LinuxArchitecture) ) )
     DATAFILES = rgb.db
       DATADEP = rgb.db
 #else
diff -ur xc.vanilla/programs/xterm/main.c xc/programs/xterm/main.c
--- xc.vanilla/programs/xterm/main.c	Sun Dec 10 23:23:29 1995
+++ xc/programs/xterm/main.c	Thu May 23 19:00:47 1996
@@ -354,6 +354,40 @@
 #endif
 #endif
 
+#ifdef linux /* Lets undefine all the SunOS specific stuff */
+#undef TIOCHPCL
+#undef TIOCMODG
+#undef TIOCMODS
+#undef TIOCGETP
+#undef TIOCSETP
+#undef TIOCSETN
+#undef TIOCFLUSH
+#undef TIOCSETC
+#undef TIOCGETC
+#undef TIOCTCNTL
+#undef TIOCSIGNAL
+#undef TIOCSETX
+#undef TIOCGETX
+#undef TIOCSSIZE
+#undef TIOCGSIZE
+#undef TIOCUCNTL
+#undef TIOCREMOTE
+#undef TIOCSTART
+#undef TIOCSTOP
+#undef TIOCGLTC
+#undef TIOCSLTC
+#undef TIOCCDTR
+#undef TIOCSDTR
+#undef TIOCCBRK
+#undef TIOCSBRK
+#undef TIOCLGET
+#undef TIOCLSET
+#undef TIOCLBIC
+#undef TIOCLBIS
+#undef TIOCISPACE
+#undef TIOCISIZE
+#endif
+
 #ifndef X_NOT_STDC_ENV
 #include <stdlib.h>
 #else
@@ -405,7 +439,7 @@
 static struct ltchars d_ltc;
 #endif	/* TIOCSLTC */
 
-#ifdef __sgi
+#if defined(__sgi) || (defined(linux) && defined(sparc))
 #undef TIOCLSET /* XXX why is this undef-ed again? */
 #endif
 
@@ -437,6 +471,9 @@
 /* allow use of system default characters if defined and reasonable */
 #ifndef CEOF
 #define CEOF ('D'&037)
+#endif
+#ifndef CDSUSP
+#define CDSUSP ('Y'&037)
 #endif
 #ifndef CSUSP
 #define CSUSP ('Z'&037)
