diff -ur dosemu-0.60.4-clean/ChangeLog dosemu/ChangeLog
--- dosemu-0.60.4-clean/ChangeLog	Sun Dec  3 22:19:58 1995
+++ dosemu/ChangeLog	Mon Apr 22 00:20:12 1996
@@ -1,3 +1,12 @@
+Thu Jan 25      1996
+- From Henrik Storner <storner@osiris.ping.dk>
+  Fix for malloc/valloc-bug, happens together with libc-5.3.0
+
+- From Hans
+  Fix for syscallmgr, NR_xxx wrong together with newer shared libs
+  ( found this thanks to Ronald Wahl <rwa@informatik.tu-chemnitz.de>, who
+  posted it on de.comp.os.linux )
+
 Sat Nov 25      1995
 - From Michael Beck : Fix to debugger D command
 
diff -ur dosemu-0.60.4-clean/clients/keyboard.c dosemu/clients/keyboard.c
--- dosemu-0.60.4-clean/clients/keyboard.c	Sat Nov  4 18:46:39 1995
+++ dosemu/clients/keyboard.c	Mon Apr 22 00:20:23 1996
@@ -18,8 +18,8 @@
 #include <string.h>
 #include <sys/mman.h>
 
-#include "../include/shared.h"
 #include "get_info.h"
+#include "../include/shared.h"
 
 #define E_printf printf
 #define leavedos(x) exit(x)
@@ -27,7 +27,7 @@
 char *memory;
 
 int
-shared_memory_init (char *pid)
+shared_qmemory_init (char *pid)
 {
 
   static int ret_val;
@@ -65,7 +65,7 @@
       return;
     }
 
-  if (shared_memory_init (argv[1]))
+  if (shared_qmemory_init (argv[1]))
     {
       fprintf (stderr, "Unable to access keyboard, check server\n");
     }
diff -ur dosemu-0.60.4-clean/clients/video.c dosemu/clients/video.c
--- dosemu-0.60.4-clean/clients/video.c	Sat Nov  4 18:46:39 1995
+++ dosemu/clients/video.c	Mon Apr 22 00:20:23 1996
@@ -27,12 +27,14 @@
 char *memory;
 
 int
-shared_memory_init (char *pid)
+shared_cmemory_init (char *pid)
 {
 
-  FILE *tmpfile_fd;
   static int ret_val;
+#if 0
+  FILE *tmpfile_fd;
   u_char devname[30], in_string[81];
+#endif
 
   get_shared_memory_info (pid);
   if (shm_video_id)
@@ -67,7 +69,7 @@
       return;
     }
 
-  if (shared_memory_init (argv[1]))
+  if (shared_cmemory_init (argv[1]))
     {
       fprintf (stderr, "Unable to access video, check server video mode.\n");
     }
diff -ur dosemu-0.60.4-clean/debugger/dis8086.c dosemu/debugger/dis8086.c
--- dosemu-0.60.4-clean/debugger/dis8086.c	Sat Nov  4 18:46:41 1995
+++ dosemu/debugger/dis8086.c	Mon Apr 22 00:20:10 1996
@@ -55,10 +55,12 @@
   "fadd", "fmul", "fcom", "fcomp", "fsub", "fsubr", "fdiv", "fdivr"
 };
 
+#if 0 /* Jan 96 JES */
 static const char *d9[8] =
 {
   "flds", "fxch", "fsts", "fstps", "ftst/fxam", "fldc", "fmisc1", "fmisc2"
 };
+#endif
 
 static const char *f00[8] =
 {
@@ -196,7 +198,7 @@
   if (addr32)
     {
       char index[5];
-      const char *scale;
+      const char *scale="";
       const char *base;
 
       if ((rm >> 6) == 3)
@@ -296,6 +298,10 @@
 	  return code;
 	}
     }
+/* What should return be here? JES */
+    d86_printf("No Answer in mod_rm");
+    return 0;
+
 }
 
 static const unsigned char *mod_reg_rm(FILE *out, const unsigned char *code,
diff -ur dosemu-0.60.4-clean/debugger/mhpdbg.c dosemu/debugger/mhpdbg.c
--- dosemu-0.60.4-clean/debugger/mhpdbg.c	Sat Nov  4 18:46:40 1995
+++ dosemu/debugger/mhpdbg.c	Mon Apr 22 00:20:10 1996
@@ -158,10 +158,6 @@
 
 static void mhp_poll(void)
 {
-   int clen;
-   int nbytes;
-   int rc;
-   int i;
 
    if (!mhpdbg.active) {
      mhpdbg.nbytes = 0;
@@ -288,11 +284,11 @@
 		    }
 		  }
 		  else {
-		    if (ok=mhp_bpchk( (unsigned char *) csip)) {
+		    if ((ok=mhp_bpchk( (unsigned char *) csip))) {
 			  LWORD(eip) --;
 		    }
 		    else {
-		      if (ok=test_bit(3, vm86s.vm86plus.mhpdbg_intxxtab)) {
+		      if ((ok=test_bit(3, vm86s.vm86plus.mhpdbg_intxxtab))) {
 		        /* software programmed INT3 */
 		        LWORD(eip) --;
 		        mhp_cmd("r");
diff -ur dosemu-0.60.4-clean/debugger/mhpdbgc.c dosemu/debugger/mhpdbgc.c
--- dosemu-0.60.4-clean/debugger/mhpdbgc.c	Sun Dec  3 22:19:58 1995
+++ dosemu/debugger/mhpdbgc.c	Mon Apr 22 00:20:10 1996
@@ -84,7 +84,7 @@
 static struct symbl2_entry symbl2_table[MAXSYM];
 static unsigned int last_symbol2 = 0;
 static unsigned int symbl2_org = 0;
-static unsigned int symbl2_end = 0;
+/* static unsigned int symbl2_end = 0; */
 
 /* constants */
 static const struct cmd_db cmdtab[] = {
@@ -200,7 +200,6 @@
 {
   FILE * ifp;
   unsigned char bytebuf[IBUFS];
-  unsigned long a1;
   unsigned long org;
   unsigned int	seg;
   unsigned int	off;
@@ -212,7 +211,7 @@
      return;
   }
 
-  sscanf(argv[1], "%x", &org);
+  sscanf(argv[1], "%lx", &org);
   symbl2_org = org;
 
   ifp = fopen(argv[2], "r");
@@ -245,7 +244,7 @@
      symbl2_table[last_symbol2].seg  = seg + (symbl2_org >> 4);
      symbl2_table[last_symbol2].off  = off;
      symbl2_table[last_symbol2].type = ' ';
-     sscanf(&bytebuf[17], "%s", &symbl2_table[last_symbol2].name);
+     sscanf(&bytebuf[17], "%s", (char *)&symbl2_table[last_symbol2].name);
      last_symbol2++;
   }
   fclose(ifp);
@@ -276,7 +275,7 @@
 	break;
      if (!strlen(bytebuf))
 	continue;
-     sscanf(&bytebuf[0], "%x", &a1);
+     sscanf(&bytebuf[0], "%lx", &a1);
 #ifdef __ELF__
      if (a1 < 0x08000000) continue;
 #else
@@ -287,7 +286,7 @@
 #endif
      symbol_table[last_symbol].addr = a1;
      symbol_table[last_symbol].type = bytebuf[9];
-     sscanf(&bytebuf[11], "%s", &symbol_table[last_symbol].name);
+     sscanf(&bytebuf[11], "%s", (char *)&symbol_table[last_symbol].name);
      last_symbol++;
   }
   fclose(ifp);
@@ -430,7 +429,6 @@
 static void mhp_dis(int argc, char * argv[])
 {
    unsigned int nbytes;
-   unsigned long org;
    unsigned long seekval;
    int i,i2;
    unsigned char * buf = 0;
@@ -507,7 +505,7 @@
    unsigned long seekval;
    int def_size;
    unsigned int bytesdone;
-   int i,i2;
+   int i;
    unsigned char * buf = 0;
    unsigned char bytebuf[IBUFS];
    unsigned char frmtbuf[IBUFS];
@@ -607,7 +605,7 @@
 	 break;
       workchrs[1] = *inputptr++;
       workchrs[2] = 0x00;
-      sscanf(workchrs, "%02x", &c);
+      sscanf(workchrs, "%02x", (unsigned int)&c);
       zapaddr[i1] = c;
       if (!workchrs[1])
 	 break;
@@ -633,7 +631,7 @@
    if (ul1 = lookup(a1, s1, o1)) {
       return (void*)ul1;
    }
-   if (ul1 = getaddr(a1)) {
+   if ((ul1 = getaddr(a1))) {
       *s1 = 0;
       *o1 = 0;
       return (void*)ul1;
@@ -692,8 +690,6 @@
 static void mhp_bp(int argc, char * argv[])
 {
    unsigned long seekval;
-   unsigned long org;
-   int i1;
    unsigned int seg;
    unsigned int off;
 
diff -ur dosemu-0.60.4-clean/dma/dma.c dosemu/dma/dma.c
--- dosemu-0.60.4-clean/dma/dma.c	Wed Nov  8 23:09:06 1995
+++ dosemu/dma/dma.c	Mon Apr 22 00:20:10 1996
@@ -22,7 +22,12 @@
 
 #include <fcntl.h>
 #include <errno.h>
+#include <sys/types.h>
+#include <unistd.h>
+#ifdef __linux__
 #include <linux/soundcard.h>
+#endif
+
 #include "dma.h"
 #define DMA_0_3_BASE 0x00     /* The base address for the first dma controller */
 #define DMA_4_7_BASE 0xC0     /* The base address for the second */
@@ -149,6 +154,7 @@
                        else
                          return 0;
   }
+  return 1;
 }
 
 inline unsigned char dma_read_status_0_3()
diff -ur dosemu-0.60.4-clean/dosemu/cmos.c dosemu/dosemu/cmos.c
--- dosemu-0.60.4-clean/dosemu/cmos.c	Sat Nov  4 18:46:43 1995
+++ dosemu/dosemu/cmos.c	Mon Apr 22 00:20:11 1996
@@ -187,9 +187,11 @@
 static int
 cmos_date(int reg)
 {
+#if 0
   unsigned long ticks;
   struct timeval tp;
   struct timezone tzp;
+#endif
   struct tm *tm;
   int tmp;
   time_t this_time;
diff -ur dosemu-0.60.4-clean/dosemu/cpu.c dosemu/dosemu/cpu.c
--- dosemu-0.60.4-clean/dosemu/cpu.c	Sun Nov  5 15:51:34 1995
+++ dosemu/dosemu/cpu.c	Mon Apr 22 00:20:25 1996
@@ -705,7 +705,7 @@
 
 char safe_port_in_byte(const unsigned short port)
 {
-        unsigned char value;
+        unsigned char value=0;
 
         if(i_am_root) {
                 int result;
@@ -720,7 +720,7 @@
 		priv_off();
 		if (result) error("failed to disable port %x\n", port);
         }       else i_printf("want to ");
-        i_printf("in(%x)");
+        i_printf("in(%x)", port);
         if(i_am_root)
                 i_printf(" = %x", value);
         i_printf("\n");
diff -ur dosemu-0.60.4-clean/dosemu/detach.c dosemu/dosemu/detach.c
--- dosemu-0.60.4-clean/dosemu/detach.c	Sat Nov  4 18:46:43 1995
+++ dosemu/dosemu/detach.c	Mon Apr 22 00:20:25 1996
@@ -11,6 +11,7 @@
 #include <sys/stat.h>
 #include <unistd.h>
 #include <sys/param.h>
+#include <sys/ioctl.h>
 
 /* 
  * Update to do console disallocation on exit of dosemu
@@ -46,8 +47,6 @@
 static int open_vt (int vt)  {
   char path[MAXPATHLEN];
 
-  int vt_fd = -1;
-  
   sprintf(path, "%s%d", vt_base, vt);
   return open (path, O_RDWR); 
 }
diff -ur dosemu-0.60.4-clean/dosemu/disks.c dosemu/dosemu/disks.c
--- dosemu-0.60.4-clean/dosemu/disks.c	Sun Nov  5 15:51:34 1995
+++ dosemu/dosemu/disks.c	Mon Apr 22 00:20:11 1996
@@ -290,7 +290,7 @@
     dp->heads = label.d_ntracks;
     dp->tracks = label.d_ncylinders;
     dp->start = label.d_partitions[DISKPART(stb.st_rdev)].p_offset;
-    d_printf("HDISK auto_info disk %s; h=%d, s=%d, t=%d, start=%d\n",
+    d_printf("HDISK auto_info disk %s; h=%d, s=%d, t=%d, start=%ld\n",
 	     dp->dev_name, dp->heads, dp->sectors, dp->tracks, dp->start);
   }
 #endif
@@ -460,10 +460,10 @@
 
   d_printf("SET_PART_ENT: making part table entry for device %s,\n",
 	dp->dev_name);
-  d_printf("Calculated physical start: head=%4d sect=%4d cyl=%4d,\n",
+  d_printf("Calculated physical start: head=%4d sect=%4d cyl=%4ld,\n",
 	HEAD(dp->start), SECT(dp->start), CYL(dp->start));
   end = dp->start+length-1;
-  d_printf("Calculated physical end:   head=%4d sect=%4d cyl=%4d.\n",
+  d_printf("Calculated physical end:   head=%4d sect=%4d cyl=%4ld.\n",
 	HEAD(end), SECT(end), CYL(end));
 
   /* get address of where to put new part table entry */
@@ -502,7 +502,7 @@
 }
 
 #ifdef __NetBSD__
-inline void
+void
 disk_open(struct disk *dp)
 {
   struct fd_type fl;
@@ -557,7 +557,7 @@
 #endif
 
 #ifdef __linux__
-inline void
+void
 disk_open(struct disk *dp)
 {
   struct floppy_struct fl;
diff -ur dosemu-0.60.4-clean/dosemu/dos2linux.c dosemu/dosemu/dos2linux.c
--- dosemu-0.60.4-clean/dosemu/dos2linux.c	Sun Nov  5 15:51:34 1995
+++ dosemu/dosemu/dos2linux.c	Mon Apr 22 00:20:11 1996
@@ -170,7 +170,7 @@
  * system() is used to execute the command because this function uses a 
  * shell (/bin/sh -c command), so nice things like this work: 
  *
- * C:\>unix ls -CF /usr/src/dosemu/video/*.[ch]
+ * C:\>unix ls -CF /usr/src/dosemu/video/ *.[ch]
  *
  * Even output redirection works, but you have to quote the command in 
  * dosemu:
@@ -323,5 +323,7 @@
 	result = system(p);
 	if(i_am_root)
 		priv_on();
+
+	return(result);
 }
 
diff -ur dosemu-0.60.4-clean/dosemu/dosio.c dosemu/dosemu/dosio.c
--- dosemu-0.60.4-clean/dosemu/dosio.c	Sat Nov 11 00:06:08 1995
+++ dosemu/dosemu/dosio.c	Mon Apr 22 00:20:10 1996
@@ -297,8 +297,6 @@
 
 #define PAGE_SIZE	4096
 
-static u_long secno = 0;
-
 inline int process_interrupt(SillyG_t *sg);
 
 /* my test shared memory IDs */
@@ -318,7 +316,9 @@
 static u_char *HMAkeepalive; /* Use this to keep shm_hma_alive */
 static int shm_hma_id;
 static int shm_wrap_id;
+#ifdef NCU
 static int shm_video_id;
+#endif
 static caddr_t ipc_return;
 
 void HMA_MAP(int HMA)
@@ -368,7 +368,7 @@
 void HMA_init(void)
 {
   /* initially, no HMA */
-  HMAkeepalive = malloc(HMASIZE); /* This is used only so that shmdt stays going */
+  HMAkeepalive = valloc(HMASIZE); /* This is used only so that shmdt stays going */
   sharedmem.hmastate = 0;
 
   if ((shm_hma_id = shmget(IPC_PRIVATE, HMASIZE, 0755)) < 0) {
@@ -534,7 +534,6 @@
 inline int
 process_interrupt(SillyG_t *sg)
 {
-  u_int chr;
   int irq, ret=0;
 
   if ((irq = sg->irq) != 0) {
diff -ur dosemu-0.60.4-clean/dosemu/emm.c dosemu/dosemu/emm.c
--- dosemu-0.60.4-clean/dosemu/emm.c	Sat Nov  4 18:46:43 1995
+++ dosemu/dosemu/emm.c	Mon Apr 22 01:07:33 1996
@@ -208,6 +208,7 @@
 #include <malloc.h>
 #include <fcntl.h>
 #include <sys/types.h>
+#include <sys/utsname.h>
 #ifdef __linux__
 #include <linux/utsname.h>
 #endif
@@ -544,23 +545,14 @@
 static mach_port_t
 new_memory_object(size_t bytes)
 {
-#if 0
+  /* NOTE: bytes has to be a multiple of PAGE-SIZE,
+   * else we go into trouble with mmap()-ing under Linux >= 1.3.78
+   * We use valloc(), because this is the correct way to get page-aligned
+   * chunks of memory ( malloc() of libc >5.3 won't do the job ).
+   */
   mach_port_t addr = (mach_port_t) valloc(bytes);
 
-  char *ptr;
-#else
-  mach_port_t addr = (mach_port_t) malloc(bytes);
-
-#endif
-
   E_printf("EMS: allocating 0x%08x bytes @ %p\n", bytes, (void *) addr);
-
-#if 0
-  /* touch memory */
-  for (ptr = addr; ptr < (addr + bytes); ptr += 4096)
-    *ptr = *ptr;
-#endif
-
   return (addr);		/* allocate on a PAGE boundary */
 }
 
@@ -789,6 +781,12 @@
   logical = (caddr_t) handle_info[handle].object + logical_page * EMM_PAGE_SIZE;
    
   if (ems_mmap) {
+    int i;
+    /* Touch all pages before mmap()-ing,
+     * else Linux >= 1.3.78 will return -EINVAL. (Hans, 96/04/16)
+     */
+    for (i=EMM_PAGE_SIZE-4096; i>=0 ; i-=4096) *((volatile char *)(logical+i));
+
     E_printf("EMS: mmap()ing from 0x%x to 0x%x\n", (int)base, (int)logical);
     
     if ((caddr_t)base != mmap(base,
diff -ur dosemu-0.60.4-clean/dosemu/int.c dosemu/dosemu/int.c
--- dosemu-0.60.4-clean/dosemu/int.c	Sat Nov 11 00:06:08 1995
+++ dosemu/dosemu/int.c	Mon Apr 22 00:20:11 1996
@@ -3,6 +3,8 @@
 #endif
 
 #include <stdio.h>
+#include <string.h>
+#include <ctype.h>
 #include <termios.h>
 #include <unistd.h>
 #include <stdlib.h>
@@ -23,6 +25,8 @@
 #include "xms.h"
 #include "int.h"
 #include "dos2linux.h"
+#include "video.h"
+#include "vc.h"
 
 #ifdef USING_NET
 #include "ipx.h"
@@ -304,7 +308,7 @@
     break;
 #endif
     case 0x80:
-        LWORD(eax) = (u_short) getcwd(SEG_ADR((char *), es, dx), (u_short)LWORD(eax));
+        LWORD(eax) = (char *)getcwd(SEG_ADR((char *), es, dx), (size_t)LWORD(eax));
         break;
   case 0x81:
         LWORD(eax) = chdir(SEG_ADR((char *), es, dx));
@@ -584,12 +588,15 @@
 
 static void int1a(u_char i)
 {
-  unsigned int test_date;
-  time_t akt_time; 
   time_t time_val;
-  struct timeval tp;
-  struct timezone tzp;
-  struct tm *tm, *tm2;
+  struct timeval;
+  struct timezone;
+  struct tm *tm;
+
+#ifdef USE_UNIX_TIME_FOR_INT1A_AH0
+  time_t akt_time;
+  unsigned int test_date;
+#endif
 
   switch (HI(ax)) {
 
diff -ur dosemu-0.60.4-clean/dosemu/signal.c dosemu/dosemu/signal.c
--- dosemu-0.60.4-clean/dosemu/signal.c	Wed Nov  8 23:09:06 1995
+++ dosemu/dosemu/signal.c	Mon Apr 22 00:20:10 1996
@@ -17,6 +17,7 @@
 #include "../dpmi/dpmi.h"
 #include "pic.h"
 #include "ipx.h"
+#include "pktdrvr.h"
 
 #ifdef __NetBSD__
 extern int errno;
@@ -64,7 +65,6 @@
 {
   struct sigaction sa;
   sigset_t trashset;
-  u_short counter;
 #ifdef __NetBSD__
   struct sigaltstack salt;
 
@@ -187,7 +187,6 @@
 void SIGALRM_call(void){
 
   static volatile int running = 0;
-  static volatile inalrm = 0;
   static int partials = 0;
 #if VIDEO_CHECK_DIRTY
   static int update_pending = 0;
diff -ur dosemu-0.60.4-clean/dosemu/sigsegv.c dosemu/dosemu/sigsegv.c
--- dosemu-0.60.4-clean/dosemu/sigsegv.c	Sat Nov  4 18:46:43 1995
+++ dosemu/dosemu/sigsegv.c	Mon Apr 22 00:20:10 1996
@@ -387,7 +387,6 @@
 void
 outb(unsigned int port, unsigned int byte)
 {
-  static int timer_beep = 0;
   static int lastport = 0;
   static unsigned int tmp = 0;
 
@@ -414,7 +413,8 @@
 
     flip_flop = !flip_flop;
     if (flip_flop) {
-      if (last_index = 0x10)
+/* JES This was last_index = 0x10..... WRONG? */
+      if (last_index == 0x10)
 	char_blink = (byte & 8) ? 1 : 0;
       last_byte = byte;
     }
@@ -833,7 +833,7 @@
       #define ___LOCALAUX(typ,iotyp,incr,x) \
         i_printf("untested: outs%c port 0x%04x value %04x\n", x, \
                 LWORD(edx), *(__SEG_ADR(typ,pref_seg,si))); \
-        iotyp(LWORD(edx), *(__SEG_ADR(typ,pref_seg,si))); \
+        iotyp(LWORD(edx), (unsigned int) *(__SEG_ADR(typ,pref_seg,si))); \
         if(LWORD(eflags) & DF ) LWORD(esi) -= incr; \
         else LWORD(esi) +=incr;
       
@@ -1042,7 +1042,9 @@
   struct sigcontext_struct *scp = &context;
 #endif
   unsigned char *csp;
+#if 0
   unsigned char c;
+#endif
   int i;
 
   if (in_vm86) {
diff -ur dosemu-0.60.4-clean/dosemu/timers.c dosemu/dosemu/timers.c
--- dosemu-0.60.4-clean/dosemu/timers.c	Sat Nov 11 00:06:08 1995
+++ dosemu/dosemu/timers.c	Mon Apr 22 00:20:11 1996
@@ -96,14 +96,10 @@
  *
  */
 
-#ifdef __NetBSD__
 #include <sys/time.h>
-#endif
-#ifdef __linux__
-#include <linux/time.h>
-#endif
 #include "emu.h"
 #include "timers.h"
+#include "port.h"
 #include "int.h"
 #include "pic.h"
 
@@ -337,7 +333,6 @@
 
 void pit_outp(int port, int val)
 {
-  static int timer_beep;
 
   if (port == 1)
     i_printf("PORT: someone is writing the CMOS refresh time?!?");
diff -ur dosemu-0.60.4-clean/dosemu/xms.c dosemu/dosemu/xms.c
--- dosemu-0.60.4-clean/dosemu/xms.c	Sat Nov  4 18:46:43 1995
+++ dosemu/dosemu/xms.c	Mon Apr 22 00:20:25 1996
@@ -192,8 +192,7 @@
 struct EMM get_emm(unsigned int, unsigned int);
 void show_emm(struct EMM);
 static void xms_query_freemem(int), xms_allocate_EMB(int), xms_free_EMB(void),
- xms_move_EMB(void), xms_lock_EMB(int), xms_EMB_info(int), xms_realloc_EMB(int),
- xms_request_UMB(void), xms_release_UMB(void);
+ xms_move_EMB(void), xms_lock_EMB(int), xms_EMB_info(int), xms_realloc_EMB(int);
 
 static int FindFreeHandle(int);
 
@@ -824,7 +823,7 @@
     else
       handles[h].size = (long)(REG(edx) * 1024);
 
-    x_printf("XMS: EMB size %l\n", (int) handles[h].size);
+    x_printf("XMS: EMB size %d\n", (int) handles[h].size);
 
     /* I could just rely on the behavior of malloc(0) here, but
        * I'd rather not.  I'm going to interpret the XMS 3.0 spec
diff -ur dosemu-0.60.4-clean/dpmi/dpmi.c dosemu/dpmi/dpmi.c
--- dosemu-0.60.4-clean/dpmi/dpmi.c	Sat Nov  4 18:46:44 1995
+++ dosemu/dpmi/dpmi.c	Mon Apr 22 00:20:24 1996
@@ -125,7 +125,10 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h>
+#include "vm86plus.h"
+
 #ifdef __linux__
+#include <linux/vm86.h>
 #include <linux/unistd.h>
 #include <linux/head.h>
 
@@ -185,6 +188,8 @@
 #include "pic.h"
 #include "meminfo.h"
 #include "int.h"
+#include "serial.h"
+#include "port.h"
 
 #ifdef __NetBSD__
 #define vm86_regs sigcontext
@@ -316,7 +321,6 @@
 {
 #ifdef __linux__
   struct modify_ldt_ldt_s ldt_info;
-  unsigned long *lp;
   unsigned long base2, limit2;
   int __retval;
 
@@ -359,7 +363,7 @@
     }
   }
 
-  if (__retval=modify_ldt(1, &ldt_info, sizeof(ldt_info)))
+  if ((__retval=modify_ldt(1, &ldt_info, sizeof(ldt_info))))
 	return __retval;
 #endif
 #ifdef __NetBSD__
@@ -497,7 +501,7 @@
     type = (*lp >> 10) & 7;
     if ((base_addr > 0) || (limit > 0 ) || Segments[i].used) {
       if (*lp & 1000)  {
-	D_printf("Entry 0x%04x: Base %08.8x, Limit %05.5x, Type %d\n",
+	D_printf("Entry 0x%04x: Base %08lx, Limit %05lx, Type %d\n",
 	       i, base_addr, limit, type);
 	D_printf("              ");
 	if (*lp & 0x100)
@@ -519,16 +523,16 @@
 	else
 	  D_printf("byte limit, ");
 	D_printf("\n");
-	D_printf("              %08.8x %08.8x\n", *(lp), *(lp-1));
+	D_printf("              %08lx %08lx\n", *(lp), *(lp-1));
       }
       else {
-	D_printf("Entry 0x%04x: Base %08.8x, Limit %05.5x, Type %d\n",
+	D_printf("Entry 0x%04x: Base %08lx, Limit %05lx, Type %d\n",
 	       i, base_addr, limit, type);
-	D_printf("              SYSTEM: %08.8x %08.8x\n", *lp, *(lp - 1));
+	D_printf("              SYSTEM: %08lx %08lx\n", *lp, *(lp - 1));
       }
       lp2 = (unsigned long *) &ldt_buffer[i*LDT_ENTRY_SIZE];
-      D_printf("       cache: %08.8x %08.8x\n", *(lp2+1), *(lp2)); 
-      D_printf("         seg: Base %08.8x, Limit %05.5x, Type %d, Big %d\n",
+      D_printf("       cache: %08lx %08lx\n", (unsigned long)*(lp2+1), (unsigned long)*(lp2)); 
+      D_printf("         seg: Base %08lx, Limit %05x, Type %d, Big %d\n",
 	     Segments[i].base_addr, Segments[i].limit, Segments[i].type, Segments[i].is_big); 
     }
   }
@@ -583,8 +587,6 @@
 
 void dpmi_get_entry_point(void)
 {
-    unsigned short old_es = REG(es);
-    
     D_printf("Request for DPMI entry\n");
 
     if (!config.dpmi)
@@ -662,12 +664,12 @@
   ldt_info.limit_in_pages = 0;
   ldt_info.seg_not_present = 0;
 
-  if (__retval=modify_ldt(MODIFY_LDT_CREATE_KERNEL_DESCRIPTOR,
-			  &ldt_info, sizeof(ldt_info)))
+  if ((__retval=modify_ldt(MODIFY_LDT_CREATE_KERNEL_DESCRIPTOR,
+			  &ldt_info, sizeof(ldt_info))))
 	return __retval;
 
   memcopy_from_huge((void *)lp, selector, (void *)(selector & ~7), 8);
-  Segments[ldt_entry].base_addr = (lp[0] >> 16)& 0x0000ffff |
+  Segments[ldt_entry].base_addr = ((lp[0] >> 16)& 0x0000ffff) |
                                   (lp[1] & 0xff000000) |
                                   ((lp[1] << 16) & 0x00ff0000);
   Segments[ldt_entry].limit = (lp[0] & 0x0000ffff) | (lp[1] & 0x000f0000);
@@ -810,7 +812,7 @@
 static int SetSegmentBaseAddress(unsigned short selector, unsigned long baseaddr)
 {
   unsigned short ldt_entry = selector >> 3;
-  D_printf("DPMI: SetSegmentBaseAddress[0x%04lx;0x%04lx] 0x%08lx\n", ldt_entry, selector, baseaddr);
+  D_printf("DPMI: SetSegmentBaseAddress[0x%04x;0x%04x] 0x%08lx\n", ldt_entry, selector, baseaddr);
   if (ldt_entry >= MAX_SELECTORS)
     return -1;
   if (!Segments[ldt_entry].used)
@@ -829,7 +831,7 @@
 static int SetSegmentLimit(unsigned short selector, unsigned int limit)
 {
   unsigned short ldt_entry = selector >> 3;
-  D_printf("DPMI: SetSegmentLimit[0x%04lx;0x%04lx] 0x%08lx\n", ldt_entry, selector, limit);
+  D_printf("DPMI: SetSegmentLimit[0x%04x;0x%04x] 0x%08x\n", ldt_entry, selector, limit);
   if (ldt_entry >= MAX_SELECTORS)
     return -1;
   if (!Segments[ldt_entry].used)
@@ -854,7 +856,7 @@
 static int SetDescriptorAccessRights(unsigned short selector, unsigned short type_byte)
 {
   unsigned short ldt_entry = selector >> 3;
-  D_printf("DPMI: SetDescriptorAccessRights[0x%04lx;0x%04lx] 0x%04lx\n", ldt_entry, selector, type_byte);
+  D_printf("DPMI: SetDescriptorAccessRights[0x%04x;0x%04x] 0x%04x\n", ldt_entry, selector, type_byte);
 
   if (ldt_entry >= MAX_SELECTORS)
     return -1;
@@ -910,13 +912,13 @@
 #endif  
   memcpy(lp, &ldt_buffer[selector & 0xfff8], 8);
 #endif /* KERNEL_LDTALIAS */  
-  D_printf("DPMI: GetDescriptor[0x%04lx;0x%04lx]: 0x%08lx%08lx\n", selector>>3, selector, *(lp+1), *lp);
+  D_printf("DPMI: GetDescriptor[0x%04x;0x%04x]: 0x%08lx%08lx\n", selector>>3, selector, *(lp+1), *lp);
 }
 
 static int SetDescriptor(unsigned short selector, unsigned long *lp)
 {
   unsigned long base_addr, limit;
-  D_printf("DPMI: SetDescriptor[0x%04lx;0x%04lx] 0x%08lx%08lx\n", selector>>3, selector, *(lp+1), *lp);
+  D_printf("DPMI: SetDescriptor[0x%04x;0x%04x] 0x%08lx%08lx\n", selector>>3, selector, *(lp+1), *lp);
   if (selector >= (MAX_SELECTORS << 3))
     return -1;
   if (!Segments[selector >> 3].used)
@@ -1197,7 +1199,7 @@
   case 0x0204:	/* Get Protected Mode Interrupt vector */
     _LWORD(ecx) = Interrupt_Table[_LO(bx)].selector;
     _edx = Interrupt_Table[_LO(bx)].offset;
-    D_printf("DPMI: Get Prot. vec. bx=%x sel=%x, off=%x\n", _LO(bx), _LWORD(ecx), _edx);
+    D_printf("DPMI: Get Prot. vec. bx=%x sel=%x, off=%lx\n", _LO(bx), _LWORD(ecx), _edx);
     break;
   case 0x0205:	/* Set Protected Mode Interrupt vector */
     Interrupt_Table[_LO(bx)].selector = _LWORD(ecx);
@@ -1224,7 +1226,7 @@
         default:
       }
     }
-    D_printf("DPMI: Put Prot. vec. bx=%x sel=%x, off=%x\n", _LO(bx),
+    D_printf("DPMI: Put Prot. vec. bx=%x sel=%x, off=%lx\n", _LO(bx),
       _LWORD(ecx), Interrupt_Table[_LO(bx)].offset);
     break;
   case 0x0300:	/* Simulate Real Mode Interrupt */
@@ -1314,7 +1316,7 @@
 	                         (DPMIclient_is_32 ? _edi : _LWORD(edi)));
        _LWORD(ecx) = DPMI_SEG;
        _LWORD(edx) = DPMI_OFF + HLT_OFF(DPMI_realmode_callback)+i;
-       D_printf("DPMI: Allocate realmode callback for 0x%0x4:0x%08x use #%i callback address\n",
+       D_printf("DPMI: Allocate realmode callback for 0x%0x4:0x%08lx use #%i callback address\n",
 		realModeCallBack[current_client][i].selector,
 		realModeCallBack[current_client][i].offset,i);
     }
@@ -1365,7 +1367,7 @@
 	  _LWORD(edx) = 0;
 	  *buf = DPMI_VERSION;
 	  *(buf+1) = DPMI_DRIVER_VERSION;
-	  sprintf(buf+2, "Linux DOSEMU Version %d.%d.%d\n", VERSION,
+	  sprintf(buf+2, "Linux DOSEMU Version %d.%d.%f\n", VERSION,
 		  SUBLEVEL, PATCHLEVEL);
       }
 	  
@@ -1383,8 +1385,8 @@
 	_eflags |= CF;
 	break;
       }
-      D_printf("DPMI: malloc attempt for siz 0x%08lx\n", (_LWORD(ebx))<<16 | (_LWORD(ecx)));
-      D_printf("      malloc returns address 0x%08lx\n", block->base);
+      D_printf("DPMI: malloc attempt for siz 0x%08x\n", (_LWORD(ebx))<<16 | (_LWORD(ecx)));
+      D_printf("      malloc returns address 0x%p\n", block->base);
       D_printf("                using handle 0x%08lx\n",block->handle);
       _LWORD(edi) = (block -> handle)&0xffff;
       _LWORD(esi) = ((block -> handle) >> 16) & 0xffff;
@@ -1418,7 +1420,7 @@
 	    break;
 	}
 	D_printf("DPMI: realloc attempt for siz 0x%08lx\n", newsize);
-	D_printf("      realloc returns address 0x%08lx\n", block -> base);
+	D_printf("      realloc returns address 0x%p\n", block -> base);
 	_LWORD(ecx) = (unsigned long)(block->base) & 0xffff;
 	_LWORD(ebx) = ((unsigned long)(block->base) >> 16) & 0xffff;
     }
@@ -1454,7 +1456,7 @@
 	  _esi = block -> handle;
 	  D_printf("DPMI: allocate linear mem attemp for siz 0x%08lx at 0x%08lx\n",
 		   _ecx, base_address);
-	  D_printf("      malloc returns address 0x%08lx\n", block->base);
+	  D_printf("      malloc returns address 0x%p\n", block->base);
 	  D_printf("                using handle 0x%08lx\n",block->handle);
 	  break;
       }
@@ -1465,6 +1467,8 @@
 	unsigned short *sel_array;
 	unsigned long old_base, old_len;
 	
+/* JES Unsure of ASSUMING sel_array OK to be nit to NULL */
+	sel_array = NULL;
 	handle = _esi;
 	newsize = _ecx;
 
@@ -1474,7 +1478,7 @@
 	    break;
 	}
 
-	D_printf("DPMI: Resize linear mem to size %x\n", newsize);
+	D_printf("DPMI: Resize linear mem to size %lx\n", newsize);
 	D_printf("DPMI: For Mem Blk. for handle   0x%08lx\n", handle);
 	block = lookup_pm_block(handle);
 	if(block == NULL || block -> handle != handle) {
@@ -1547,7 +1551,7 @@
 	    break;
 	}
 
-	D_printf("DPMI: Map convientional mem for handle %d, offset %x at low address %x\n", handle, offset, low_addr);
+	D_printf("DPMI: Map convientional mem for handle %ld, offset %lx at low address %lx\n", handle, offset, low_addr);
 	block = lookup_pm_block(handle);
 	if(block == NULL || block -> handle != handle) {
 	    _eflags |= CF;
@@ -1684,7 +1688,6 @@
 
 static void do_dpmi_int(struct sigcontext_struct *scp, int i)
 {
-  us *ssp;
 
   if ((i == 0x2f) && (_LWORD(eax) == 0x168a))
     return do_int31(scp, 0x0a00);
@@ -2016,7 +2019,7 @@
   cp = (unsigned char *) ((my_cs << 4) +  my_ip);
 
   D_printf("Going protected with fingers crossed\n"
-		"32bit=%d, CS=%04x SS=%04x DS=%04x PSP=%04x ip=%04x sp=%04x\n",
+		"32bit=%d, CS=%04x SS=%04x DS=%04x PSP=%04x ip=%04x sp=%04lx\n",
 		LO(ax), my_cs, LWORD(ss), LWORD(ds), psp, my_ip, REG(esp));
   /* display the 10 bytes before and after CS:EIP.  the -> points
    * to the byte at address CS:EIP
@@ -2033,10 +2036,10 @@
   D_printf("STACK: ");
   (*(unsigned short *)& sp) -= 10;
   for (i = 0; i < 10; i++)
-    D_printf("%02x ", popb(ssp, sp));
+    D_printf("%02lx ", popb(ssp, sp));
   D_printf("-> ");
   for (i = 0; i < 10; i++)
-    D_printf("%02x ", popb(ssp, sp));
+    D_printf("%02lx ", popb(ssp, sp));
   D_printf("\n");
 
   if (!(CS = AllocateDescriptors(1))) return;
@@ -2210,7 +2213,7 @@
      so this log excptions even dpmi debug is off */
   unsigned char dd = d.dpmi;
   d.dpmi = 1;
-  D_printf("DPMI: do_cpu_exception(0x%02x) called\n",_trapno);
+  D_printf("DPMI: do_cpu_exception(0x%02lx) called\n",_trapno);
   DPMI_show_state;
   if ( _trapno == 0xe)
       D_printf("DPMI: page fault. in dosemu?\n");
@@ -2282,8 +2285,6 @@
 {
   us *ssp;
   unsigned char *csp;
-  unsigned char *csp2, *ssp2;
-  int i;
 
 #ifdef SHOWREGS
 #if 1
@@ -2897,7 +2898,6 @@
 }
 void dpmi_realmode_hlt(unsigned char * lina)
 {
-  unsigned short *ssp;
 
   D_printf("DPMI: realmode hlt: %p\n", lina);
   if (lina == (unsigned char *) (DPMI_ADD + HLT_OFF(DPMI_dpmi_init))) {
diff -ur dosemu-0.60.4-clean/dpmi/dpmi.h dosemu/dpmi/dpmi.h
--- dosemu-0.60.4-clean/dpmi/dpmi.h	Sat Nov  4 18:46:44 1995
+++ dosemu/dpmi/dpmi.h	Mon Apr 22 00:20:24 1996
@@ -178,4 +178,7 @@
       D_printf("%02x ", *ssp2++); \
     D_printf("\n");
 
+extern void dpmi_sigio(struct sigcontext_struct *scp);
+extern void run_dpmi(void);
+
 #endif /* DPMI_H */
diff -ur dosemu-0.60.4-clean/dpmi/meminfo.c dosemu/dpmi/meminfo.c
--- dosemu-0.60.4-clean/dpmi/meminfo.c	Sat Nov  4 18:46:44 1995
+++ dosemu/dpmi/meminfo.c	Mon Apr 22 00:20:24 1996
@@ -13,6 +13,7 @@
  */
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <unistd.h>
 #include <fcntl.h>
 #include <math.h>
diff -ur dosemu-0.60.4-clean/dpmi/memory.c dosemu/dpmi/memory.c
--- dosemu-0.60.4-clean/dpmi/memory.c	Sun Dec  3 22:19:59 1995
+++ dosemu/dpmi/memory.c	Mon Apr 22 00:20:24 1996
@@ -140,7 +140,7 @@
     }
     
     while(fgets(line, 100, fp)) {
-	sscanf(line, "%x-%x", &beg, &end);
+	sscanf(line, "%lx-%lx", &beg, &end);
 	if ((base + size) < beg ||  base >= end)
 	    continue;
 	else
@@ -272,7 +272,7 @@
     dpmi_eflags &= ~IF;
     pic_cli();
     memmove((void *)mapped_base, (void *)low_addr, cnt*DPMI_page_size);
-    if (mmap((void *)low_addr, cnt*DPMI_page_size,
+    if ((int)mmap((void *)low_addr, cnt*DPMI_page_size,
 	     PROT_READ | PROT_WRITE | PROT_EXEC,
 	     MAP_SHARED|MAP_FILE|MAP_FIXED, fd_self_mem, (off_t)mapped_base) !=
 	     low_addr) {
diff -ur dosemu-0.60.4-clean/dpmi/msdos.h dosemu/dpmi/msdos.h
--- dosemu-0.60.4-clean/dpmi/msdos.h	Sat Nov  4 18:46:45 1995
+++ dosemu/dpmi/msdos.h	Mon Apr 22 00:20:24 1996
@@ -758,7 +758,7 @@
     return 0;
 }
 
-static 
+static void
 msdos_post_exec()
 {
     /* restore parent\'s context */
@@ -780,7 +780,6 @@
 	*(unsigned short *)((char *)(PARENT_PSP<<4) + 0x2c) =
 	                     PARENT_ENV_SEL;
     CURRENT_PSP = PARENT_PSP;
-    return;
 }
 
 /*
@@ -941,7 +940,11 @@
 	case 0x51:		/* get PSP */
 	case 0x62:
 	    {/* convert environment pointer to a descriptor*/
-		unsigned short envp, psp;
+		unsigned short 
+#if 0
+		envp, 
+#endif
+		psp;
 		psp = LWORD(ebx);
 #if 0		
 		envp = *(unsigned short *)(((char *)(psp<<4))+0x2c);
@@ -1106,6 +1109,8 @@
 	    return (unsigned char *)(GetSegmentBaseAddress(_ds)+
 				     _LWORD(ebx));
     }
+    D_printf("DPMI: decode_8e_index returns with NULL\n");
+    return(NULL);
 }
 
 static  unsigned char *
@@ -1115,6 +1120,7 @@
 
     csp = (unsigned char *) SEL_ADR(_cs, _eip);
 
+    prefix = NULL;
     use_prefix = 0;
     switch (*csp) {
     case 0x2e:
@@ -1141,6 +1147,8 @@
 	prefix = (unsigned char *)GetSegmentBaseAddress(_gs);
 	use_prefix = 1;
 	break;
+    default:
+    	D_printf("DPMI: check_prefix not covered for *csp=%x, return=NULL\n", *csp);
     }
     return prefix;
 }
@@ -1238,7 +1246,7 @@
 {
     unsigned char *prefix, *csp;
     unsigned char mod, rm, reg;
-    unsigned long *lp, base_addr;
+    unsigned long *lp=NULL;
     unsigned offset;
     int len = 0;
 
@@ -1420,6 +1428,7 @@
 }
 	
     
+#if 0 /* Not USED!  JES 96/01/2x */
 static  int msdos_fix_cs_prefix (struct sigcontext_struct *scp)
 {
     unsigned char *csp;
@@ -1440,13 +1449,13 @@
     }
     return 0;
 }
+#endif
 
 /* see if client wants to access control registers */
 static int check_control_register_access(struct sigcontext_struct *scp)
 {
     unsigned char *csp;
     unsigned char mod, rm, reg;
-    int len = 0;
 
     csp = (unsigned char *) SEL_ADR(_cs, _eip);
 
@@ -1503,7 +1512,7 @@
 {
     unsigned char reg;
     unsigned short segment, desc;
-    unsigned long len, base_addr;
+    unsigned long len;
 
     if ((_err & 0xffff) == 0) {	/*  not a selector error */
 	char fixed = 0;
diff -ur dosemu-0.60.4-clean/drivers/cdrom.c dosemu/drivers/cdrom.c
--- dosemu-0.60.4-clean/drivers/cdrom.c	Sun Nov  5 15:51:35 1995
+++ dosemu/drivers/cdrom.c	Mon Apr 22 00:20:24 1996
@@ -14,6 +14,7 @@
 #include <stdlib.h>
 #include <fcntl.h>
 #include <sys/types.h>
+#include <sys/ioctl.h>
 #include <unistd.h>
 #include <errno.h>
 #ifdef __linux__
@@ -149,7 +150,10 @@
    struct cdrom_tochdr cdrom_tochdr;
    struct cdrom_tocentry cdrom_tocentry;
    struct cdrom_volctrl cdrom_volctrl;
-   int n,ioctlin, error;
+   int n, error;
+#ifdef CDROM_DEBUG
+   int ioctlin,;
+#endif
 
 #ifdef __NetBSD__   
    struct cd_toc_entry toc_entry;
diff -ur dosemu-0.60.4-clean/emu.c dosemu/emu.c
--- dosemu-0.60.4-clean/emu.c	Sun Nov  5 15:51:35 1995
+++ dosemu/emu.c	Mon Apr 22 00:20:12 1996
@@ -484,11 +484,6 @@
 
 static int      special_nowait = 0;
 
-
-
-static int      poll_io = 1;	/* polling io, default on */
-
-
 #ifdef __NetBSD__
 
 sigjmp_buf handlerbuf;
@@ -531,7 +526,6 @@
 {
     /* FIXME: why static *? */
     static int      retval;
-    static u_short  next_signal = 0;
     /*
      * always invoke vm86() with this call.  all the messy stuff will be
      * in here.
@@ -749,12 +743,16 @@
 #ifdef SIG
     /* Get in touch with my Silly Interrupt Driver */
     if (config.sillyint) {
+#ifndef REQUIRES_EMUMODULE
 	char            devname[20];
+#endif
 	char            prio_table[] =
 	{9, 10, 11, 12, 14, 15, 3, 4, 5, 6, 7};
 	int             i,
-	                irq,
-	                fd;
+#ifndef REQUIRES_EMUMODULE
+	                fd,
+#endif
+	                irq;
 	SillyG_t       *sg = SillyG_;
 	for (i = 0; i < sizeof(prio_table); i++) {
 	    irq = prio_table[i];
@@ -796,7 +794,7 @@
 		    sg->fd = fd;
 #endif				/* NOT REQUIRES_EMUMODULE */
 		    sg->irq = irq;
-		    g_printf("SIG: IRQ%d, enabling PIC-level %d\n", irq, pic_irq_list[irq]);
+		    g_printf("SIG: IRQ%d, enabling PIC-level %ld\n", irq, pic_irq_list[irq]);
 #ifdef REQUIRES_EMUMODULE
 		    { extern int SillyG_do_irq(void);
 		    pic_seti(pic_irq_list[irq], SillyG_do_irq, 0);
diff -ur dosemu-0.60.4-clean/emumod/emusys.c dosemu/emumod/emusys.c
--- dosemu-0.60.4-clean/emumod/emusys.c	Sat Nov  4 18:46:45 1995
+++ dosemu/emumod/emusys.c	Mon Apr 22 00:43:31 1996
@@ -48,7 +48,11 @@
 #if KERNEL_VERSION < 1001089
 static void irq_handler(int intno) {
 #else
+# if KERNEL_VERSION < 1003070
 static void irq_handler(int intno, struct pt_regs * unused) {
+# else
+static void irq_handler(int intno, void *dev_id, struct pt_regs * unused) {
+# endif
 #endif
   int int_bit;
   cli();
@@ -98,13 +102,21 @@
     case EMUSYS_REQUEST_IRQ: {
       if (tasks[irqnumber]) return -1;
       irqbits &= ~(1 << irqnumber);
+#if KERNEL_VERSION < 1003070
       if (request_irq(irqnumber, &irq_handler, 0, ID_STRING )) return -1;
+#else
+      if (request_irq(irqnumber, &irq_handler, 0, ID_STRING, NULL )) return -1;
+#endif
       tasks[irqnumber] = current;
       return irqnumber;
     }
     case EMUSYS_FREE_IRQ: {
       if (!tasks[irqnumber]) return -1;
+#if KERNEL_VERSION < 1003070
       free_irq(irqnumber);
+#else
+      free_irq(irqnumber, NULL);
+#endif
       tasks[irqnumber] = 0;
       irqbits &= ~(1 << irqnumber);
       return irqnumber;
@@ -118,7 +130,11 @@
 {
   int i;
   for (i=3; i<16; i++) if (tasks[i]) {
+#if KERNEL_VERSION < 1003070
    free_irq(i);
+#else
+   free_irq(i, NULL);
+#endif
    tasks[i]=0;
   }
   irqbits = 0;
diff -ur dosemu-0.60.4-clean/emumod/ldt.c dosemu/emumod/ldt.c
--- dosemu-0.60.4-clean/emumod/ldt.c	Sat Nov  4 18:46:45 1995
+++ dosemu/emumod/ldt.c	Tue Apr  9 11:29:47 1996
@@ -138,16 +138,48 @@
     addr = (addr + PGDIR_SIZE) & PGDIR_MASK;
     dir++;
   }
+#if KERNEL_VERSION < 1003047
   invalidate();
+#else
+#if KERNEL_VERSION < 1003083
+  invalidate_all();
+#else
+  flush_tlb();
+#endif
+#endif
 }
 #endif
 
 
+static inline int limits_ok(struct modify_ldt_ldt_s *ldt_info)
+{
+	unsigned long base, limit;
+	/* linear address of first and last accessible byte */
+	unsigned long first, last;
+
+	base = ldt_info->base_addr;
+	limit = ldt_info->limit;
+	if (ldt_info->limit_in_pages)
+		limit = limit * PAGE_SIZE + PAGE_SIZE - 1;
+
+	first = base;
+	last = limit + base;
+
+	/* segment grows down? */
+	if (ldt_info->contents == 1) {
+		/* data segment grows down */
+		first = base+limit+1;
+		last = base+65535;
+		if (ldt_info->seg_32bit)
+			last = base-1;
+	}
+	return (last >= first && last < TASK_SIZE);
+}
+
 static int write_ldt(void * ptr, unsigned long bytecount)
 {
 	struct modify_ldt_ldt_s ldt_info;
 	unsigned long *lp;
-	unsigned long base, limit;
 	int error, i, userspace =bytecount;
 
 #if defined(_LOADABLE_VM86_) && defined(WANT_WINDOWS)
@@ -182,27 +214,12 @@
 #endif
 		return -EINVAL;
 
-	limit = ldt_info.limit;
-	base = ldt_info.base_addr;
 #if defined(_LOADABLE_VM86_) && defined(WANT_WINDOWS)
-	if (ldt_info.limit_in_pages) {
-		limit *= PAGE_SIZE;
-		limit += PAGE_SIZE-1; 
-	}
-	limit += base;
-	if (!userspace) {
-	  if (limit < base ) return -EINVAL;
-	}
-	else if (ptr && (limit < base || limit >= 0xC0000000) && ldt_info.seg_not_present == 0)
-		return -EINVAL;
+	if (userspace && !limits_ok(&ldt_info) && ldt_info.seg_not_present == 0)
 #else
-	if (ldt_info.limit_in_pages)
-		limit *= PAGE_SIZE;
-
-	limit += base;
-	if (limit < base || limit >= 0xC0000000)
-		return -EINVAL;
+	if (!limits_ok(&ldt_info))
 #endif
+		return -EINVAL;
 
 	if (!current->ldt) {
 		for (i=1 ; i<NR_TASKS ; i++) {
diff -ur dosemu-0.60.4-clean/emumod/vm86.c dosemu/emumod/vm86.c
--- dosemu-0.60.4-clean/emumod/vm86.c	Sat Nov  4 18:46:45 1995
+++ dosemu/emumod/vm86.c	Tue Apr  9 11:29:47 1996
@@ -186,7 +186,15 @@
 #endif
 		pte++;
  	}
+#if KERNEL_VERSION < 1003047
 	invalidate();
+#else
+  #if KERNEL_VERSION < 1003083
+	invalidate_all();
+  #else
+	flush_tlb();
+  #endif
+#endif
   #endif
 #endif
 }
diff -ur dosemu-0.60.4-clean/include/cpu.h dosemu/include/cpu.h
--- dosemu-0.60.4-clean/include/cpu.h	Sat Nov  4 18:46:47 1995
+++ dosemu/include/cpu.h	Mon Apr 22 00:20:25 1996
@@ -336,4 +336,7 @@
 void show_regs(char *, int), show_ints(int, int);
 __inline__ int do_hard_int(int), do_soft_int(int);
 
+extern unsigned int read_port_w(unsigned int port);
+extern int write_port_w(unsigned int value,unsigned int port);
+
 #endif /* CPU_H */
diff -ur dosemu-0.60.4-clean/include/emu.h dosemu/include/emu.h
--- dosemu-0.60.4-clean/include/emu.h	Sat Nov 11 00:06:08 1995
+++ dosemu/include/emu.h	Mon Apr 22 00:27:16 1996
@@ -96,12 +96,12 @@
 EXTERN int sizes INIT(0);
 
 EXTERN char *tmpdir;
-extern int screen, screen_mode;
+EXTERN int screen, screen_mode;
 
 /* number of highest vid page - 1 */
 EXTERN int max_page INIT(7);
 
-extern char *cl,		/* clear screen */
+EXTERN char *cl,		/* clear screen */
 *le,				/* cursor left */
 *cm,				/* goto */
 *ce,				/* clear to end */
@@ -122,7 +122,7 @@
 EXTERN int kbd_fd INIT(-1);
 /* the file descriptor for /dev/mem when mmap'ing the video mem */
 EXTERN int mem_fd INIT(-1);
-extern int in_readkeyboard;
+EXTERN int in_readkeyboard;
 
 /* X-pipes */
 EXTERN int keypipe;
@@ -130,17 +130,17 @@
 
 EXTERN int in_vm86 INIT(0);
 
-extern int li, co;	/* lines, columns */
-extern int scanseq;
-extern int cursor_row;
-extern int cursor_col;
+EXTERN int li, co;	/* lines, columns */
+EXTERN int scanseq;
+EXTERN int cursor_row;
+EXTERN int cursor_col;
 
 void dos_ctrlc(void), dos_ctrl_alt_del(void);
 int ext_fs(int, char *, char *, int);
 #if 0 /* Not used anymore */
 int outch(int c);
 #endif
-extern void run_vm86(void);
+EXTERN void run_vm86(void);
 
 #define NOWAIT  0
 #define WAIT    1
@@ -191,11 +191,11 @@
 # define NORETURN
 #endif
 
-extern void saytime(char *m_str);
+EXTERN void saytime(char *m_str);
 
-int
-ifprintf(unsigned int, const char *,...) FORMAT(printf, 2, 3);
-     void p_dos_str(char *,...) FORMAT(printf, 1, 2);
+int ifprintf(unsigned int, const char *,...) FORMAT(printf, 2, 3);
+
+void p_dos_str(char *,...) FORMAT(printf, 1, 2);
 
 #if 0  /* set this to 0, if you want dosemu to honor the -D flags */
  #define NO_DEBUGPRINT_AT_ALL
@@ -274,8 +274,8 @@
 
      int set_ioperm(int, int, int);
 
-     extern struct debug_flags d;
-     extern u_char in_sighandler, in_ioctl;
+     EXTERN struct debug_flags d;
+     EXTERN u_char in_sighandler, in_ioctl;
 /* one-entry queue ;-( for ioctl's */
 EXTERN struct ioctlq iq INIT({0, 0, 0, 0}); 
 EXTERN u_char in_ioctl INIT(0);
@@ -345,6 +345,13 @@
 #define TRUE	1
 #endif
 
+#ifndef True
+#define True  TRUE
+#endif
+#ifndef False
+#define False FALSE
+#endif
+
      typedef unsigned char boolean;
 
 /* would like to have this in memory.h (but emu.h is included before memory.h !) */
@@ -487,64 +494,64 @@
 
 #undef cli
 #undef sti
-extern void cli(void);
-extern void sti(void);
-extern int port_readable(unsigned int);
-extern int port_writeable(unsigned int);
-extern unsigned int read_port(unsigned int);
-extern int write_port(unsigned int, unsigned int);
-extern __inline__ void parent_nextscan(void);
-extern __inline__ void disk_close(void);
-extern void cpu_setup(void);
-extern __inline__ void run_int(int);
-extern int mfs_redirector(void);
-extern void int10(void);
-extern void int13(u_char);
-extern void int14(u_char);
-extern void int17(u_char);
-extern void io_select(fd_set);
-extern int pd_receive_packet(void);
-extern int printer_tick(u_long);
-extern int printer_tick(u_long);
-extern void floppy_tick(void);
-extern void open_kmem(void);
-extern void close_kmem(void);
-extern void CloseNetworkLink(int);
-extern int parse_config(char *);
+EXTERN void cli(void);
+EXTERN void sti(void);
+EXTERN int port_readable(unsigned int);
+EXTERN int port_writeable(unsigned int);
+EXTERN unsigned int read_port(unsigned int);
+EXTERN int write_port(unsigned int, unsigned int);
+EXTERN __inline__ void parent_nextscan(void);
+EXTERN __inline__ void disk_close(void);
+EXTERN void cpu_setup(void);
+EXTERN __inline__ void run_int(int);
+EXTERN int mfs_redirector(void);
+EXTERN void int10(void);
+EXTERN void int13(u_char);
+EXTERN void int14(u_char);
+EXTERN void int17(u_char);
+EXTERN void io_select(fd_set);
+EXTERN int pd_receive_packet(void);
+EXTERN int printer_tick(u_long);
+EXTERN int printer_tick(u_long);
+EXTERN void floppy_tick(void);
+EXTERN void open_kmem(void);
+EXTERN void close_kmem(void);
+EXTERN void CloseNetworkLink(int);
+EXTERN int parse_config(char *);
 #ifdef __NetBSD__
-extern int priv_on(void);
-extern int priv_off(void);
+EXTERN int priv_on(void);
+EXTERN int priv_off(void);
 #endif
 #ifdef __linux__
-extern int exchange_uids(void);
+EXTERN int exchange_uids(void);
 #if 0
 #define priv_on exchange_uids
 #define priv_off exchange_uids
 #endif
 #endif
-extern void disk_init(void);
-extern void serial_init(void);
-extern void close_all_printers(void);
-extern void serial_close(void);
-extern void disk_close_all(void);
-extern void init_all_printers(void);
-extern int mfs_inte6(void);
-extern void pkt_helper(void);
-extern short pop_word(struct vm86_regs *);
-extern void ems_init(void);
-extern int GetDebugFlagsHelper(char *);
-extern int SetDebugFlagsHelper(char *);
-extern void leavedos(int) NORETURN;
-extern void add_to_io_select(int, unsigned char);
-extern void remove_from_io_select(int, unsigned char);
-extern void sigquit(int);
+EXTERN void disk_init(void);
+EXTERN void serial_init(void);
+EXTERN void close_all_printers(void);
+EXTERN void serial_close(void);
+EXTERN void disk_close_all(void);
+EXTERN void init_all_printers(void);
+EXTERN int mfs_inte6(void);
+EXTERN void pkt_helper(void);
+EXTERN short pop_word(struct vm86_regs *);
+EXTERN void ems_init(void);
+EXTERN int GetDebugFlagsHelper(char *);
+EXTERN int SetDebugFlagsHelper(char *);
+EXTERN void leavedos(int) NORETURN;
+EXTERN void add_to_io_select(int, unsigned char);
+EXTERN void remove_from_io_select(int, unsigned char);
+EXTERN void sigquit(int);
 #ifdef __linux__
-extern void sigalrm(int, struct sigcontext_struct);
-extern void sigio(int, struct sigcontext_struct);
+EXTERN void sigalrm(int, struct sigcontext_struct);
+EXTERN void sigio(int, struct sigcontext_struct);
 #endif
 #ifdef __NetBSD__
-extern void sigalrm(int, int, struct sigcontext *);
-extern void sigio(int, int, struct sigcontext *);
+EXTERN void sigalrm(int, int, struct sigcontext *);
+EXTERN void sigio(int, int, struct sigcontext *);
 #endif
 
 /* signals for Linux's process control of consoles */
@@ -633,8 +640,8 @@
 			dosemu_sigaction(sig, &sa, NULL);
 #endif
 
-extern inline void SIGNAL_save( void (*signal_call)(void) );
-extern inline void handle_signals(void);
+EXTERN inline void SIGNAL_save( void (*signal_call)(void) );
+EXTERN inline void handle_signals(void);
 
 
 #ifdef REQUIRES_EMUMODULE
@@ -659,7 +666,28 @@
 EXTERN int fatalerr;
 
 #ifdef __NetBSD__
-#define iopl(value)			{ extern int errno; if (i386_iopl(value) == -1) { g_printf("iopl failed: %s\n", strerror(errno)); leavedos(4);}}
+#define iopl(value)			{ EXTERN int errno; if (i386_iopl(value) == -1) { g_printf("iopl failed: %s\n", strerror(errno)); leavedos(4);}}
 #endif
+
+EXTERN void signal_init(void);
+EXTERN void device_init(void);
+EXTERN void hardware_setup(void);
+EXTERN void memory_init(void);
+EXTERN void timer_interrupt_init(void);
+EXTERN void keyboard_flags_init(void);
+EXTERN void video_config_init(void);
+EXTERN void printer_init(void);
+EXTERN void video_close(void);
+EXTERN void hma_exit(void);
+EXTERN void ems_helper(void);
+EXTERN boolean_t ems_fn(struct vm86_regs *);
+EXTERN void serial_helper(void);
+EXTERN void mouse_helper(void);
+EXTERN void cdrom_helper(void);
+EXTERN void boot(void);
+EXTERN int pkt_int(void);
+EXTERN void read_next_scancode_from_queue (void);
+EXTERN unsigned short detach (void);
+EXTERN void HMA_init(void);
 
 #endif /* EMU_H */
diff -ur dosemu-0.60.4-clean/include/hgc.h dosemu/include/hgc.h
--- dosemu-0.60.4-clean/include/hgc.h	Sat Nov  4 18:46:47 1995
+++ dosemu/include/hgc.h	Mon Apr 22 00:20:26 1996
@@ -18,6 +18,9 @@
 extern int hgc_Page;
 extern int hgc_ctrl;
 
+extern void poshgacur(int x, int  y);
+extern void set_hgc_page(int page);
+extern void map_hgc_page( int fullmode );
 
 #endif
 /* End of video/hgc.h */
diff -ur dosemu-0.60.4-clean/include/int.h dosemu/include/int.h
--- dosemu-0.60.4-clean/include/int.h	Sat Nov  4 18:46:47 1995
+++ dosemu/include/int.h	Mon Apr 22 00:20:26 1996
@@ -54,5 +54,7 @@
 void setup_interrupts(void);
 void version_init(void);
 void int_queue_run(void);
+extern void queue_hard_int(int i, void (*callstart), void (*callend));
+extern int can_revector(int i);
 
 #endif
diff -ur dosemu-0.60.4-clean/include/memory.h dosemu/include/memory.h
--- dosemu-0.60.4-clean/include/memory.h	Sat Nov  4 18:46:47 1995
+++ dosemu/include/memory.h	Mon Apr 22 00:20:26 1996
@@ -180,8 +180,8 @@
 
 #ifndef __ASM__
 /* memcheck memory conflict finder definitions */
-int  memcheck_addtype(char map_char, char *name);
-void memcheck_reserve(char map_char, int addr_start, int size);
+int  memcheck_addtype(unsigned char map_char, char *name);
+void memcheck_reserve(unsigned char map_char, int addr_start, int size);
 void memcheck_init(void);
 int  memcheck_isfree(int addr_start, int size);
 int  memcheck_findhole(int *start_addr, int min_size, int max_size);
diff -ur dosemu-0.60.4-clean/include/pktdrvr.h dosemu/include/pktdrvr.h
--- dosemu-0.60.4-clean/include/pktdrvr.h	Sun Dec  3 22:19:59 1995
+++ dosemu/include/pktdrvr.h	Mon Apr 22 00:20:26 1996
@@ -72,3 +72,7 @@
     unsigned long   packets_lost;   /* No buffer from receiver(), card */
 				    /*  out of resources, etc. */
 };
+
+extern int pkt_check_receive(int timeout);
+extern void pkt_init (int vec);
+extern int GetDeviceMTU(char *device);
diff -ur dosemu-0.60.4-clean/include/port.h dosemu/include/port.h
--- dosemu-0.60.4-clean/include/port.h	Sat Nov  4 18:46:47 1995
+++ dosemu/include/port.h	Mon Apr 22 00:20:26 1996
@@ -71,5 +71,16 @@
 	i_printf("\n");
 	return value;
 }
+#else
+extern char safe_port_in_byte(const unsigned short port);
+extern void safe_port_out_byte(const unsigned short port, const unsigned char byte);
 #endif		
+
+extern unsigned int inb(unsigned int port);
+extern void outb(unsigned int port, unsigned int byte);
+extern int inw(int port);
+extern int ind(int port);
+extern void outw(unsigned int port, unsigned int value);
+extern void outd(unsigned int port, unsigned int value);
+
 #endif
diff -ur dosemu-0.60.4-clean/include/shared.h dosemu/include/shared.h
--- dosemu-0.60.4-clean/include/shared.h	Sat Nov  4 18:46:48 1995
+++ dosemu/include/shared.h	Mon Apr 22 00:21:39 1996
@@ -26,5 +26,8 @@
 
 
 EXTERN u_char *shared_qf_memory;
+EXTERN void shared_memory_init(void);
+EXTERN void shared_keyboard_init (void);
+
 #endif
 
diff -ur dosemu-0.60.4-clean/include/slang.h dosemu/include/slang.h
--- dosemu-0.60.4-clean/include/slang.h	Sat Nov  4 18:46:47 1995
+++ dosemu/include/slang.h	Mon Apr 22 00:21:39 1996
@@ -953,5 +953,7 @@
 }
 #endif
 
+extern int init_slang_keymaps (void);
+
 /* _davis_slang_h_ */
 #endif 
diff -ur dosemu-0.60.4-clean/include/termio.h dosemu/include/termio.h
--- dosemu-0.60.4-clean/include/termio.h	Sat Nov  4 18:46:47 1995
+++ dosemu/include/termio.h	Mon Apr 22 00:21:39 1996
@@ -221,8 +221,12 @@
    I set keepkey to reflect CF */
 EXTERN u_char keepkey INIT(1);
 
-extern void insert_into_keybuffer(void);
-extern void set_keyboard_bios(void);
-extern void do_irq1(void);
+EXTERN void insert_into_keybuffer(void);
+EXTERN void set_keyboard_bios(void);
+EXTERN void do_irq1(void);
+EXTERN int keyboard_init(void);
+EXTERN void add_scancode_to_queue (u_short scan);
+EXTERN void child_set_flags(int sc);
+EXTERN int kbd_flag (int flag);
 
 #endif /* TERMIO_H */
diff -ur dosemu-0.60.4-clean/include/timers.h dosemu/include/timers.h
--- dosemu-0.60.4-clean/include/timers.h	Sat Nov  4 18:46:47 1995
+++ dosemu/include/timers.h	Mon Apr 22 00:21:39 1996
@@ -39,4 +39,10 @@
 #define INT28_IDLE_USECS	0
 #endif
 
+extern int read_port61(void);
+extern void write_port61(int byte);
+extern int pit_control_inp(void);
+extern void pit_control_outp(int val);
+extern void initialize_timers(void);
+
 #endif /* TIMERS_H */
diff -ur dosemu-0.60.4-clean/include/video.h dosemu/include/video.h
--- dosemu-0.60.4-clean/include/video.h	Sat Nov  4 18:46:47 1995
+++ dosemu/include/video.h	Mon Apr 22 00:21:39 1996
@@ -245,4 +245,11 @@
 #define DIAMOND		3
 #define S3		4
 
+EXTERN void get_screen_size (void);
+EXTERN void set_video_bios_size(void);
+EXTERN void X_handle_events(void);
+EXTERN void X_blink_cursor(void);
+EXTERN void init_vga_card(void);
+EXTERN void scr_state_init(void);
+
 #endif
diff -ur dosemu-0.60.4-clean/init/config.c dosemu/init/config.c
--- dosemu-0.60.4-clean/init/config.c	Sat Nov 11 00:06:08 1995
+++ dosemu/init/config.c	Mon Apr 22 00:20:11 1996
@@ -600,27 +600,27 @@
     fprintf(stdout, "    -A boot from first defined floppy disk (A)\n");
     fprintf(stdout, "    -B boot from second defined floppy disk (B) (#)\n");
     fprintf(stdout, "    -C boot from first defined hard disk (C)\n");
-    fprintf(stdout, "    -c use PC console video (!%)\n");
+    fprintf(stdout, "    -c use PC console video (!%%)\n");
     fprintf(stdout, "    -k use PC console keyboard (!)\n");
 #ifdef X_SUPPORT
     fprintf(stdout, "    -X run in X Window (#)\n");
 /* seems no longer valid bo 18.7.95
     fprintf(stdout, "    -X NAME use MDA direct and FIFO NAME for keyboard (only with x2dos!)\n");
-/*
     fprintf(stdout, "    -Y NAME use FIFO NAME for mouse (only with x2dos!)\n");
+*/
     fprintf(stdout, "    -D set debug-msg mask to flags (+-)(dRWDCvXkism#pgcwhIExMnPr01)\n");
 #else				/* X_SUPPORT */
     fprintf(stdout, "    -D set debug-msg mask to flags (+-)(dRWDCvkism#pgcwhIExMnPr01)\n");
 #endif				/* X_SUPPORT */
     fprintf(stdout, "    -M set memory size to SIZE kilobytes (!)\n");
     fprintf(stdout, "    -P copy debugging output to FILE\n");
-    fprintf(stdout, "    -b map BIOS into emulator RAM (%)\n");
+    fprintf(stdout, "    -b map BIOS into emulator RAM (%%)\n");
     fprintf(stdout, "    -F use config-file File\n");
-    fprintf(stdout, "    -V use BIOS-VGA video modes (!#%)\n");
+    fprintf(stdout, "    -V use BIOS-VGA video modes (!#%%)\n");
     fprintf(stdout, "    -N No boot of DOS\n");
     fprintf(stdout, "    -t try new timer code (#)\n");
     fprintf(stdout, "    -s try new screen size code (#)\n");
-    fprintf(stdout, "    -g enable graphics modes (!%#)\n");
+    fprintf(stdout, "    -g enable graphics modes (!%%#)\n");
     fprintf(stdout, "    -x SIZE enable SIZE K XMS RAM\n");
     fprintf(stdout, "    -e SIZE enable SIZE K EMS RAM\n");
     fprintf(stdout, "    -m enable mouse support (!#)\n");
@@ -629,6 +629,6 @@
     fprintf(stdout, "    -2,3,4 choose 286, 386 or 486 CPU\n");
     fprintf(stdout, "    -K Do int9 (!#)\n\n");
     fprintf(stdout, "    (!) BE CAREFUL! READ THE DOCS FIRST!\n");
-    fprintf(stdout, "    (%) require dos be run as root (i.e. suid)\n");
+    fprintf(stdout, "    (%%) require dos be run as root (i.e. suid)\n");
     fprintf(stdout, "    (#) options do not fully work yet\n");
 }
diff -ur dosemu-0.60.4-clean/init/init.c dosemu/init/init.c
--- dosemu-0.60.4-clean/init/init.c	Wed Nov  8 23:09:06 1995
+++ dosemu/init/init.c	Mon Apr 22 00:20:11 1996
@@ -2,6 +2,7 @@
  * $Id: init.c,v 1.4 1995/05/06 16:26:13 root Exp root $
  */
 #include <stdio.h>
+#include <string.h>
 #include <termios.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -10,6 +11,7 @@
 #include <sys/times.h>
 #include <sys/time.h>
 #include <sys/stat.h>
+#include <sys/utsname.h>
 
 #ifdef __linux__
 #include <linux/config.h>
@@ -28,14 +30,19 @@
 #include "int.h"
 #include "timers.h"
 #include "termio.h"
+#include "video.h"
 #include "vc.h"
 #include "mouse.h"
 #ifdef USING_NET
+#include "pktdrvr.h"
 #include "ipx.h"
 #endif
 #include "bitops.h"
 #include "pic.h"
+#include "cmos.h"
 #include "dma.h"
+#include "xms.h"
+#include "shared.h"
 #include "sound.h"
 
 extern void pkt_check_receive_quick(void);
@@ -92,8 +99,6 @@
  */
 void stdio_init(void)
 {
-  struct stat statout, staterr;
-
   if(dbg_fd) {
     warn("DBG_FD already set\n");
     return;
@@ -148,8 +153,7 @@
 void time_setting_init(void)
 {
   struct tm *tm;
-  unsigned long ticks;
-  
+
   time(&start_time);
   tm = localtime((time_t *) &start_time);
   g_printf("Set date %02d.%02d.%02d\n", tm->tm_mday, tm->tm_mon+1, tm->tm_year);
@@ -189,7 +193,6 @@
  */
 void hardware_setup(void)
 {
-  int i;
 
   /* PIC init */
   pic_seti(PIC_IRQ0, timer_int_engine, 0);  /* do_irq0 in pic.c */
@@ -302,7 +305,9 @@
 static inline void map_custom_bios(void)
 {
   extern void bios_f000(), bios_f000_end();
+#if 0
   FILE   *f;
+#endif
   u_char *ptr;
 
   ptr = (u_char *) (BIOSSEG << 4);
diff -ur dosemu-0.60.4-clean/init/memcheck.c dosemu/init/memcheck.c
--- dosemu-0.60.4-clean/init/memcheck.c	Sat Nov  4 18:46:48 1995
+++ dosemu/init/memcheck.c	Mon Apr 22 00:20:11 1996
@@ -20,7 +20,7 @@
 #define MEM_SIZE          (1024*1024)   /* Size of memory in KB        */
 #define MAX_PAGE (MEM_SIZE/PAGE_SIZE)   /* Number of 'pages' in memory */
 
-static char  mem_map[MAX_PAGE];          /* Map of memory contents      */
+static unsigned char  mem_map[MAX_PAGE];          /* Map of memory contents      */
 static char *mem_names[256];             /* List of id. strings         */
 
 static void round_addr(int *addr)
@@ -29,7 +29,7 @@
   *addr *= PAGE_SIZE;
 }
 
-int memcheck_addtype(char map_char, char *name)
+int memcheck_addtype(unsigned char map_char, char *name)
 {
   if (mem_names[map_char] != NULL) {
     if (strcmp(mem_names[map_char], name) != 0) {
@@ -44,9 +44,10 @@
   else {
     mem_names[map_char] = name;
   }
+  return(0);
 }
 
-void memcheck_reserve(char map_char, int addr_start, int size)
+void memcheck_reserve(unsigned char map_char, int addr_start, int size)
 {
   int cntr, addr_end;
 
@@ -156,6 +157,6 @@
     if (mem_names[cntr])
       c_printf("%c:  %s\n", cntr, mem_names[cntr]);
   }
-  c_printf(".:  (unused)\n", cntr, mem_names[cntr]);
+  c_printf(".:  (unused)\n");
   c_printf("CONF:  End dump\n");
 }
diff -ur dosemu-0.60.4-clean/keyboard/Xkeyb.c dosemu/keyboard/Xkeyb.c
--- dosemu-0.60.4-clean/keyboard/Xkeyb.c	Sat Nov  4 18:46:49 1995
+++ dosemu/keyboard/Xkeyb.c	Mon Apr 22 00:20:11 1996
@@ -332,6 +332,7 @@
 };
 #endif /* NEW_KEYCODES */
 
+void X_process_char(u_char ch);
 
 /* This is a very quick'n dirty put_key...  */
 static void put_key(ushort scan, short charcode) {
diff -ur dosemu-0.60.4-clean/keyboard/keyboard-client.c dosemu/keyboard/keyboard-client.c
--- dosemu-0.60.4-clean/keyboard/keyboard-client.c	Sat Nov  4 18:46:49 1995
+++ dosemu/keyboard/keyboard-client.c	Mon Apr 22 00:20:11 1996
@@ -25,6 +25,10 @@
  * DANG_END_CHANGELOG
  */
 
+#include <string.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/times.h>
 #include <unistd.h>
 #include <termios.h>
 #include <fcntl.h>
@@ -43,6 +47,7 @@
 #include "memory.h"
 #include "termio.h"
 #include "shared.h"
+#include "slang.h"
 #include "vc.h"
 
 static int      tty_raw(int);
@@ -60,8 +65,6 @@
 extern void     terminal_close();
 void            convascii(int *);
 
-static unsigned int queue;
-
 #define put_queue(psc) (queue = psc)
 
 void            getKeys();
@@ -75,8 +78,6 @@
 
 /* initialize these in keyboard_init()! */
 unsigned int    child_kbd_flags = 0;
-
-static int      altchar = 0;
 
 static int      old_kbd_flags = -1;	/* flags for STDIN before our
 					 * fcntl */
diff -ur dosemu-0.60.4-clean/keyboard/keyboard-server.c dosemu/keyboard/keyboard-server.c
--- dosemu-0.60.4-clean/keyboard/keyboard-server.c	Sat Nov  4 18:46:49 1995
+++ dosemu/keyboard/keyboard-server.c	Mon Apr 22 00:20:11 1996
@@ -558,8 +558,6 @@
 void
 set_leds_area ()
 {
-  unsigned int led_state = 0;
-
   if (kbd_flag (KF_SCRLOCK))
     {
       set_key_flag (KKF_SCRLOCK);
@@ -1004,7 +1002,6 @@
 void
 set_keyboard_bios (void)
 {
-  int scan;
 
   if (config.keybint)
     {
@@ -1013,7 +1010,7 @@
   else
     next_scancode = convscanKey(next_scancode);
   keys_ready = 0;		/* flag character as read	*/
-  k_printf ("set keybaord bios next_scancode = 0x%04\n", next_scancode);
+  k_printf ("set keybaord bios next_scancode = 0x%04x\n", next_scancode);
 }
 
 void
diff -ur dosemu-0.60.4-clean/keyboard/slang-keyboard.c dosemu/keyboard/slang-keyboard.c
--- dosemu-0.60.4-clean/keyboard/slang-keyboard.c	Sat Nov  4 18:46:50 1995
+++ dosemu/keyboard/slang-keyboard.c	Mon Apr 22 00:20:11 1996
@@ -1,3 +1,6 @@
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
 #include "../include/slang.h"
 
 /* unsigned char DOSemu_Slang_Escape_Character = 30; */
@@ -301,7 +304,7 @@
    0x0C1F			       /* ^_ */
 };
 
-static define_key_from_keymap (unsigned char *map, unsigned long mask, int flag)
+static void define_key_from_keymap (unsigned char *map, unsigned long mask, int flag)
 {
    unsigned char buf[3], ch;
    int i, imax;
diff -ur dosemu-0.60.4-clean/mfs/mangle.c dosemu/mfs/mangle.c
--- dosemu-0.60.4-clean/mfs/mangle.c	Sat Nov  4 18:46:51 1995
+++ dosemu/mfs/mangle.c	Mon Apr 22 00:20:24 1996
@@ -549,7 +549,7 @@
 }
 
 
-static BOOL do_fwd_mangled_map(char *s, char *MangledMap)
+BOOL do_fwd_mangled_map(char *s, char *MangledMap)
 {
   /* MangledMap is a series of name pairs in () separated by spaces.
    * If s matches the first of the pair then the name given is the
diff -ur dosemu-0.60.4-clean/mfs/mangle.h dosemu/mfs/mangle.h
--- dosemu-0.60.4-clean/mfs/mangle.h	Sat Nov  4 18:46:51 1995
+++ dosemu/mfs/mangle.h	Mon Apr 22 00:20:24 1996
@@ -15,6 +15,7 @@
 #include <malloc.h>
 #include <string.h>
 #include <stddef.h>
+#include <ctype.h>
 
 
 /* no debugging - the code is perfect! */
@@ -36,8 +37,10 @@
 #define lp_strip_dot() 0
 
 #define BOOL int
+#ifndef True
 #define True 1
 #define False 0
+#endif
 
 
 #define CASE_LOWER 0
@@ -50,8 +53,10 @@
 
 /* prototypes */
 void mangle_name_83(char *s, char *MangledMap);
-static BOOL do_fwd_mangled_map(char *s, char *MangledMap);
-
+extern BOOL do_fwd_mangled_map(char *s, char *MangledMap);
+extern BOOL name_convert(char *OutName,char *InName,BOOL mangle, char *MangledMap);
+extern BOOL is_mangled(char *s);
+extern BOOL check_mangled_stack(char *s, char *MangledMap);
 
 #ifndef MANGLE
 #define MANGLE 1
diff -ur dosemu-0.60.4-clean/mfs/mfs.c dosemu/mfs/mfs.c
--- dosemu-0.60.4-clean/mfs/mfs.c	Sun Dec  3 22:20:00 1995
+++ dosemu/mfs/mfs.c	Mon Apr 22 00:20:24 1996
@@ -417,6 +417,7 @@
 #include "config.h"
 /* For passing through GetRedirection Status */
 #include "memory.h"
+#include "mangle.h"
 #endif
 
 /* these universal globals defined here (externed in dos.h) */
@@ -491,7 +492,6 @@
 static cds_t cds_base;
 static cds_t cds;
 static sda_t sda;
-static u_short com_psp = (u_short) NULL;
 
 static int dos_major;
 static int dos_minor;
@@ -1684,7 +1684,6 @@
      int cnt;
 {
   int ret;
-  sigset_t oldmask, newmask;
 
   if (cnt <= 0)
     return (0);
@@ -2341,6 +2340,7 @@
   }
 }
 
+#if 0
 static void
 debug_dump_sft(handle)
      char handle;
@@ -2403,6 +2403,7 @@
     ptr = (u_short *) Addr_8086(ptr[1], ptr[0]);
   }
 }
+#endif
 
 /* convert forward slashes to back slashes for DOS */
 
@@ -2641,14 +2642,15 @@
   char buf[1024];
   struct dir_ent *tmp;
   struct stat st;
+#if 0
   static char last_find_name[8] = "";
   static char last_find_ext[3] = "";
   static u_char last_find_dir = 0;
   static u_char last_find_drive = 0;
-#if 0
   char *resourceName;
   char *deviceName;
 #endif
+ dos_mode = 0;
 
   if (!mach_fs_enabled)
     return (REDIRECT);
@@ -2657,7 +2659,7 @@
 
   sft = (u_char *) Addr(state, es, edi);
 
-  Debug0((dbg_fd, "Entering dos_fs_redirect, FN=%02X\n",LOW(state->eax)));
+  Debug0((dbg_fd, "Entering dos_fs_redirect, FN=%02X\n",(int)LOW(state->eax)));
 
   if (!select_drive(state))
     return (REDIRECT);
diff -ur dosemu-0.60.4-clean/mouse/mouseint.c dosemu/mouse/mouseint.c
--- dosemu-0.60.4-clean/mouse/mouseint.c	Sat Nov  4 18:46:51 1995
+++ dosemu/mouse/mouseint.c	Mon Apr 22 00:20:11 1996
@@ -31,6 +31,7 @@
 
 #include <unistd.h>
 #include <sys/types.h>
+#include <sys/ioctl.h>
 #include <termios.h>
 #include <errno.h>
 #include <time.h>
diff -ur dosemu-0.60.4-clean/net/ipx.c dosemu/net/ipx.c
--- dosemu-0.60.4-clean/net/ipx.c	Sat Nov  4 18:46:52 1995
+++ dosemu/net/ipx.c	Mon Apr 22 00:20:25 1996
@@ -92,7 +92,9 @@
 void
 InitIPXFarCallHelper(void)
 {
+#if 0
   u_char *ptr;
+#endif
   char value[40];
   int addressTemp[6];
   int numFields;
diff -ur dosemu-0.60.4-clean/net/pktnew.c dosemu/net/pktnew.c
--- dosemu-0.60.4-clean/net/pktnew.c	Sat Nov  4 18:46:52 1995
+++ dosemu/net/pktnew.c	Mon Apr 22 00:20:25 1996
@@ -180,7 +180,7 @@
 
 /* this is the handler for INT calls from DOS to the packet driver */
 int
-pkt_int ()
+pkt_int (void)
 
 {
     struct per_handle *hdlp;
@@ -496,8 +496,7 @@
 }
 
 int
-pkt_check_receive(timeout)
-int timeout;
+pkt_check_receive(int timeout)
 
 {
     int size,handle;
diff -ur dosemu-0.60.4-clean/pic/pic.c dosemu/pic/pic.c
--- dosemu-0.60.4-clean/pic/pic.c	Sat Nov 11 00:06:09 1995
+++ dosemu/pic/pic.c	Mon Apr 22 00:20:11 1996
@@ -58,6 +58,8 @@
 #include "cpu.h"
 #include "emu.h"
 #include "../dpmi/dpmi.h"
+#include "serial.h"
+#include "int.h"
 #undef us
 #define us unsigned
 void timer_tick(void);
@@ -65,12 +67,15 @@
 extern void timer_int_engine(void);
 #define NEVER 0x80000000
 
+
 static unsigned long pic1_isr;         /* second isr for pic1 irqs */
-static unsigned long pic1_mask;        /* bits set for pic1 levels */
 static unsigned long pic_irq2_ivec = 0;
 
 
-static  unsigned long pic1_mask = 0x07f8; /* bits set for pic1 levels */
+#if 0
+static unsigned long pic1_mask;        /* bits set for pic1 levels */
+#endif
+static unsigned long pic1_mask = 0x07f8; /* bits set for pic1 levels */
 static unsigned long              pic_smm;          /* 32=>special mask mode, 0 otherwise */
 
 static unsigned long   pic_pirr;         /* pending requests: ->irr when icount==0 */
@@ -202,10 +207,10 @@
   if(header_count>15) header_count=0;
   
   if(s2)
-  ifprintf(d.request,"PIC: %c%2d %c%2d %08x %08x %08x %s%02d%s\n",
+  ifprintf(d.request,"PIC: %c%2ld %c%2ld %08lx %08lx %08lx %s%02d%s\n",
      cc, pic_icount, ci, pic_ilevel, pic_isr, pic_imr, pic_irr, s1, v1, s2);
   else
-  ifprintf(d.request,"PIC: %c%2d %c%2d %08x %08x %08x %s%\n",
+  ifprintf(d.request,"PIC: %c%2ld %c%2ld %08lx %08lx %08lx %s\n",
      cc, pic_icount, ci, pic_ilevel, pic_isr, pic_imr, pic_irr, s1);
   }
 }
@@ -642,7 +647,6 @@
 int do_irq()
 {
  int intr;
- long int_ptr;
  unsigned char * ssp;
  unsigned long sp;
 
@@ -654,7 +658,7 @@
     if(IS_REDIRECTED(intr)||pic_ilevel<=PIC_IRQ1||in_dpmi)
     {
 #if 1 /* BUG CATCHER (if 1) */
-g_printf("+%d",pic_ilevel);
+g_printf("+%d",(int)pic_ilevel);
 #endif
      if(pic_ilevel < 16) pic_push(pic_ilevel);
      if (in_dpmi) {
@@ -761,7 +765,7 @@
   }
   if (d.request&2) {
     /* avoid going through sprintf for non-debugging */
-    sprintf(buf,", k%d",pic_dpmi_count);
+    sprintf(buf,", k%d",(int)pic_dpmi_count);
     pic_print(2,"Zeroing vm86, DPMI from ",pic_vm86_count,buf);
   }
   pic_vm86_count=pic_dpmi_count=0;
diff -ur dosemu-0.60.4-clean/serial/ser_defs.h dosemu/serial/ser_defs.h
--- dosemu-0.60.4-clean/serial/ser_defs.h	Sat Nov  4 18:46:53 1995
+++ dosemu/serial/ser_defs.h	Mon Apr 22 00:20:11 1996
@@ -95,21 +95,21 @@
  * debugging output commands are not defined to anything in particular.
  */
 #if SER_DEBUG_MAIN 
-#define s1_printf s_printf
+#define s1_printf 1
 #else
-#define s1_printf
+#define s1_printf 0
 #endif
 
 #if SER_DEBUG_HEAVY
-#define s2_printf s_printf
+#define s2_printf 1
 #else
-#define s2_printf
+#define s2_printf 0
 #endif
 
 #if SER_DEBUG_INTERRUPT
-#define s3_printf s_printf
+#define s3_printf 1
 #else
-#define s3_printf
+#define s3_printf 0
 #endif
 
 /************************************************************
@@ -293,5 +293,8 @@
 void uart_clear_fifo(int, int);
 void pic_serial_run(void);
 void fossil_int14(int);
+void ser_termios(int num);
+void modstat_engine(int num);
+inline int msr_compute_delta_bits(int oldmsr, int newmsr);
 
 #endif /* SER_DEFS_H */
diff -ur dosemu-0.60.4-clean/serial/ser_init.c dosemu/serial/ser_init.c
--- dosemu-0.60.4-clean/serial/ser_init.c	Sat Nov  4 18:46:53 1995
+++ dosemu/serial/ser_init.c	Mon Apr 22 00:20:12 1996
@@ -30,6 +30,8 @@
 #include <sys/time.h>
 #include <termios.h>
 #include <sys/ioctl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
 #ifdef __linux__
 #include <linux/fs.h>
 #endif
@@ -427,7 +429,7 @@
   com[num].rx_fifo_size = 16;		/* Size of receive FIFO to emulate */
   uart_clear_fifo(num,UART_FCR_CLEAR_CMD);	/* Initialize FIFOs */
 
-  s2_printf("SER%d: do_ser_init: running ser_termios\n",num);
+  if (s2_printf) s_printf("SER%d: do_ser_init: running ser_termios\n",num);
   ser_termios(num);			/* Set line settings now */
   modstat_engine(num);
 
diff -ur dosemu-0.60.4-clean/serial/ser_irq.c dosemu/serial/ser_irq.c
--- dosemu-0.60.4-clean/serial/ser_irq.c	Sat Nov  4 18:46:53 1995
+++ dosemu/serial/ser_irq.c	Mon Apr 22 00:20:12 1996
@@ -110,7 +110,7 @@
         com[num].rx_timeout--;			/* Decrement counter */
         if (!com[num].rx_timeout) {		/* Has timeout counted down? */
           com[num].LSRqueued |= UART_LSR_DR;
-          s3_printf("SER%d: Func receive_engine requesting RX_INTR\n",num);
+          if (s3_printf) s_printf("SER%d: Func receive_engine requesting RX_INTR\n",num);
           serial_int_engine(num, RX_INTR);	/* Update interrupt status */
         }
       }
@@ -119,7 +119,7 @@
       if (com[num].rx_timeout) {		/* Has get_rx run since int? */
         com[num].LSRqueued |= UART_LSR_DR;
         com[num].rx_timeout = 0;		/* Reset timeout counter */
-        s3_printf("SER%d: Func receive_engine requesting RX_INTR\n",num);
+        if (s3_printf) s_printf("SER%d: Func receive_engine requesting RX_INTR\n",num);
         serial_int_engine(num, RX_INTR);	/* Update interrupt status */
       }
     }
@@ -176,7 +176,7 @@
     if (!com[num].tx_buf_bytes && com[num].tx_trigger) {
       com[num].tx_trigger = 0;
       com[num].LSRqueued |= UART_LSR_TEMT | UART_LSR_THRE;
-      s3_printf("SER%d: Func transmit_engine requesting TX_INTR\n",num);
+      if (s3_printf) s_printf("SER%d: Func transmit_engine requesting TX_INTR\n",num);
       serial_int_engine(num, TX_INTR);		/* Update interrupt status */
     }
   }
@@ -184,7 +184,7 @@
     if (com[num].tx_trigger) { 			/* Is it time to trigger int */
       com[num].tx_trigger = 0;
       com[num].LSRqueued |= UART_LSR_TEMT | UART_LSR_THRE;
-      s3_printf("SER%d: Func transmit_engine requesting TX_INTR\n",num);
+      if (s3_printf) s_printf("SER%d: Func transmit_engine requesting TX_INTR\n",num);
       serial_int_engine(num, TX_INTR);		/* Update interrupt status */
     }  
   }
@@ -220,8 +220,8 @@
   com[num].MSRqueued = (com[num].MSRqueued & UART_MSR_DELTA) | newmsr | delta;
 
   if (delta) {
-    s2_printf("SER%d: Modem Status Change: MSR -> 0x%x\n",num,newmsr);
-    s3_printf("SER%d: Func modstat_engine requesting MS_INTR\n",num);
+    if (s2_printf) s_printf("SER%d: Modem Status Change: MSR -> 0x%x\n",num,newmsr);
+    if (s3_printf) s_printf("SER%d: Func modstat_engine requesting MS_INTR\n",num);
     serial_int_engine(num, MS_INTR);		/* Update interrupt status */
   }
   else if ( !(com[num].MSRqueued & UART_MSR_DELTA)) {
@@ -232,13 +232,12 @@
   }
 }
 
-
 /* There is no need for a Line Status Engine function right now since there
  * is not much justification for one, since all the error bits that causes
  * interrupt, are handled by Linux and are difficult for this serial code
  * to detect.  When easy non-blocking break signal handling is introduced,
  * there will be justification for a simple Line Status housekeeping
- * function whose purpose is to detect an error condition (mainly a 
+ * function whose purpose is to detect an error condition (mainly a
  * break signal sent from the remote) and generate a hardware interrupt
  * on its occurance (RLSI).
  *
@@ -252,12 +251,11 @@
 #if 0
 void linestat_engine(int num)		/* Internal Line Status processing */
 {
-  s3_printf("SER%d: Func linestat_engine setting LS_INTR\n",num);
+  if (s3_printf) s_printf("SER%d: Func linestat_engine setting LS_INTR\n",num);
   serial_int_engine(num, LS_INTR);		/* Update interrupt status */
 }
 #endif
 
-
 /* This function updates the IIR for Line Status.  [num = port] */
 static inline void flag_IIR_linestat(int num)
 {
@@ -347,6 +345,7 @@
   else if ( !(com[num].MSR & UART_MSR_DELTA)) {
     com[num].int_condition &= ~MS_INTR;
   }
+  return 1;
 }
 
 
@@ -382,7 +381,7 @@
   /* See if a requested interrupt is enabled */
   if (!com[num].int_pend && com[num].int_enab && com[num].interrupt) {
     if ((int_requested | com[num].int_condition) & com[num].IER) {
-      s3_printf("SER%d: Func pic_request intlevel=%d, int_requested=%d\n", 
+      if (s3_printf) s_printf("SER%d: Func pic_request intlevel=%d, int_requested=%d\n", 
                  num, com[num].interrupt, int_requested);
       /*irq_source_num[com[num].interrupt] = num;*/ /* Permit shared IRQ */
       com[num].int_pend = 1;			/* Interrupt is now pending */
@@ -457,7 +456,7 @@
   num = irq_source_num[pic_ilevel];
   tmp = com[num].int_condition & com[num].IER;
   
-  s2_printf("SER%d: ---BEGIN INTERRUPT--- int_condition = %d\n", num,
+  if (s2_printf) s_printf("SER%d: ---BEGIN INTERRUPT--- int_condition = %d\n", num,
              com[num].int_condition);
 
   /* Execute any pre-interrupt code that may be necessary */
@@ -500,7 +499,7 @@
    * because do_irq does not completely execute all the way to IRET
    * before the code reaches here!?
    */
-  s2_printf("SER%d: ---END INTERRUPT---\n",num);
+  if (s2_printf) s_printf("SER%d: ---END INTERRUPT---\n",num);
 
   /* Update the internal serial timers */
   serial_timer_update();
diff -ur dosemu-0.60.4-clean/serial/ser_ports.c dosemu/serial/ser_ports.c
--- dosemu-0.60.4-clean/serial/ser_ports.c	Sat Nov  4 18:46:53 1995
+++ dosemu/serial/ser_ports.c	Mon Apr 22 00:20:12 1996
@@ -22,6 +22,8 @@
 #include <stdio.h>
 #include <termios.h>
 #include <sys/ioctl.h>
+#include <sys/types.h>
+#include <unistd.h>
 
 #include "config.h"
 #include "emu.h"
@@ -162,7 +164,7 @@
       
       /* Has it gone above the recieve FIFO trigger level? */
       if (com[num].rx_buf_bytes >= com[num].rx_fifo_trigger) {
-        s3_printf("SER%d: Func uart_fill requesting RX_INTR\n",num);
+        if(s3_printf) s_printf("SER%d: Func uart_fill requesting RX_INTR\n",num);
         com[num].LSRqueued |= UART_LSR_DR;	/* Update queued LSR */
         serial_int_engine(num, RX_INTR);	/* Update interrupt status */
       }
@@ -172,7 +174,7 @@
 
     com[num].rx_timeout = 0;			/* Reset receive timeout */
     com[num].LSRqueued |= UART_LSR_DR;		/* Update queued LSR */
-    s3_printf("SER%d: Func uart_fill requesting RX_INTR\n",num);
+    if(s3_printf) s_printf("SER%d: Func uart_fill requesting RX_INTR\n",num);
     serial_int_engine(num, RX_INTR);		/* Update interrupt status */
   }
 }
@@ -233,7 +235,7 @@
 
   /* Return if not a tty */
   if (tcgetattr(com[num].fd, &com[num].newset) == -1) {
-    s1_printf("SER%d: Line Control: NOT A TTY.\n",num);
+    if(s1_printf) s_printf("SER%d: Line Control: NOT A TTY.\n",num);
     return;
   }
   s_printf("SER%d: LCR = 0x%x, ",num,com[num].LCR);
@@ -394,7 +396,7 @@
    */
   if (com[num].mouse) {
     com[num].LSRqueued |= UART_LSR_FE; 		/* Set framing error */
-    s3_printf("SER%d: Func ser_termios requesting LS_INTR\n",num);
+    if(s3_printf) s_printf("SER%d: Func ser_termios requesting LS_INTR\n",num);
     serial_int_engine(num, LS_INTR);		/* Update interrupt status */
   }
 #endif
@@ -610,7 +612,7 @@
     
       /* Is the FIFO full? */
       if (com[num].rx_buf_bytes >= com[num].rx_fifo_size) {
-        s3_printf("SER%d: Func put_tx loopback overrun requesting LS_INTR\n",num);
+        if(s3_printf) s_printf("SER%d: Func put_tx loopback overrun requesting LS_INTR\n",num);
         com[num].LSR |= UART_LSR_OE;		/* Indicate overrun error */
         com[num].LSRqueued |= UART_LSR_OE;	/* Update queued LSR bits */
         serial_int_engine(num, LS_INTR);	/* Update interrupt status */
@@ -630,7 +632,7 @@
         if (com[num].rx_buf_bytes >= com[num].rx_fifo_trigger) {
           com[num].rx_timeout = 0;
           com[num].LSRqueued |= UART_LSR_DR;	/* Flag Data Ready bit */
-          s3_printf("SER%d: Func put_tx loopback requesting RX_INTR\n",num);
+          if(s3_printf) s_printf("SER%d: Func put_tx loopback requesting RX_INTR\n",num);
           serial_int_engine(num, RX_INTR);	/* Update interrupt status */
         }
       }
@@ -641,14 +643,14 @@
       if (com[num].LSR & UART_LSR_DR) {		/* Was data waiting? */
         com[num].LSR |= UART_LSR_OE;		/* Indicate overrun error */
         com[num].LSRqueued |= UART_LSR_OE;	/* Update queued LSR bits */
-        s3_printf("SER%d: Func put_tx loopback overrun requesting LS_INTR\n",num);
+        if(s3_printf) s_printf("SER%d: Func put_tx loopback overrun requesting LS_INTR\n",num);
         serial_int_engine(num, LS_INTR);	/* Update interrupt status */
       }
       else { 
         com[num].LSR |= UART_LSR_DR; 		/* Flag Data Ready bit */
         com[num].LSRqueued |= UART_LSR_DR; 	/* Flag Data Ready bit */
         com[num].rx_timeout = 0;
-        s3_printf("SER%d: Func put_tx loopback requesting RX_INTR\n",num);
+        if(s3_printf) s_printf("SER%d: Func put_tx loopback requesting RX_INTR\n",num);
         serial_int_engine(num, RX_INTR);	/* Update interrupt status */
       }
     }
@@ -717,7 +719,7 @@
 
     /* Don't need to emulate RXRDY,TXRDY pins, used for bus-mastering. */
     if (val & UART_FCR_DMA_SELECT) {
-      s1_printf("SER%d: FCR: Attempt to change RXRDY & TXRDY pin modes\n",num);
+      if(s1_printf) s_printf("SER%d: FCR: Attempt to change RXRDY & TXRDY pin modes\n",num);
     }
 
     /* Assign special variable for trigger value for easy access. */
@@ -727,7 +729,7 @@
     case UART_FCR_TRIGGER_8:   com[num].rx_fifo_trigger = 8;	break;
     case UART_FCR_TRIGGER_14:  com[num].rx_fifo_trigger = 14;	break;
     }
-    s2_printf("SER%d: FCR: Trigger Level is %d\n",num,com[num].rx_fifo_trigger);
+    if(s2_printf) s_printf("SER%d: FCR: Trigger Level is %d\n",num,com[num].rx_fifo_trigger);
   }
   else {				/* FIFO are disabled */
     /* If uart was set in 16550 mode, this will reset it back to 16450 mode.
@@ -773,7 +775,7 @@
 {
   static int newmsr, delta;
   static int changed;
-  static int control, operation;
+  static int control;
   changed = com[num].MCR ^ val;			/* Bitmask of changed bits */
   com[num].MCR = val & UART_MCR_VALID;		/* Set valid bits for MCR */
 
@@ -802,7 +804,7 @@
     com[num].MSRqueued = com[num].MSR;
 
     /* Set the MSI interrupt flag if loopback changed the modem status */
-    s3_printf("SER%d: Func put_mcr loopback requesting MS_INTR\n",num);
+    if(s3_printf) s_printf("SER%d: Func put_mcr loopback requesting MS_INTR\n",num);
     if (delta) serial_int_engine(num, MS_INTR);    /* Update interrupt status */
 
   }
@@ -818,7 +820,7 @@
 
     /* Update DTR setting on serial device only if DTR state changed */
     if (changed & UART_MCR_DTR) {
-      s1_printf("SER%d: MCR: DTR -> %d\n",num,(val & UART_MCR_DTR));
+      if(s1_printf) s_printf("SER%d: MCR: DTR -> %d\n",num,(val & UART_MCR_DTR));
       control = TIOCM_DTR;
       if (val & UART_MCR_DTR) 
         ioctl(com[num].fd, TIOCMBIS, &control);
@@ -828,7 +830,7 @@
 
     /* Update RTS setting on serial device only if RTS state changed */
     if ((changed & UART_MCR_RTS) && !com[num].system_rtscts) {
-      s1_printf("SER%d: MCR: RTS -> %d\n",num,(val & UART_MCR_RTS));
+      if(s1_printf) s_printf("SER%d: MCR: RTS -> %d\n",num,(val & UART_MCR_RTS));
       control = TIOCM_RTS;
       if (val & UART_MCR_RTS)
         ioctl(com[num].fd, TIOCMBIS, &control);
@@ -873,7 +875,7 @@
   com[num].LSRqueued = com[num].LSR;
 
   /* Update interrupt status */
-  s3_printf("SER%d: Func put_lsr caused int_type = %d\n",num,int_type);
+  if(s3_printf) s_printf("SER%d: Func put_lsr caused int_type = %d\n",num,int_type);
   serial_int_engine(num, int_type);
 }
 
@@ -892,7 +894,7 @@
   
   /* Update interrupt status */
   if (com[num].MSRqueued & UART_MSR_DELTA) {
-    s3_printf("SER%d: Func put_msr requesting MS_INTR\n",num);
+    if(s3_printf) s_printf("SER%d: Func put_msr requesting MS_INTR\n",num);
     serial_int_engine(num, MS_INTR);
   }
   else {
@@ -922,11 +924,11 @@
 /*case UART_DLL:*/      /* or Read from Baudrate Divisor Latch LSB */
     if (com[num].DLAB) {	/* Is DLAB set? */
       val = com[num].dll;	/* Then read Divisor Latch LSB */
-      s1_printf("SER%d: Read Divisor LSB = 0x%x\n",num,val);
+      if(s1_printf) s_printf("SER%d: Read Divisor LSB = 0x%x\n",num,val);
     }
     else {
       val = get_rx(num);	/* Else, read Received Byte Register */
-      s2_printf("SER%d: Receive 0x%x\n",num,val);
+      if(s2_printf) s_printf("SER%d: Receive 0x%x\n",num,val);
     }
     break;
 
@@ -934,49 +936,49 @@
 /*case UART_DLM:*/      /* or Read from Baudrate Divisor Latch MSB */
     if (com[num].DLAB) {	/* Is DLAB set? */
       val = com[num].dlm;	/* Then read Divisor Latch MSB */
-      s1_printf("SER%d: Read Divisor MSB = 0x%x\n",num,val);
+      if(s1_printf) s_printf("SER%d: Read Divisor MSB = 0x%x\n",num,val);
     }
     else {
       val = com[num].IER;	/* Else, read Interrupt Enable Register */
-      s1_printf("SER%d: Read IER = 0x%x\n",num,val);
+      if(s1_printf) s_printf("SER%d: Read IER = 0x%x\n",num,val);
     }
     break;
 
   case UART_IIR:	/* Read from Interrupt Identification Register */
     val = com[num].IIR;
     if ((com[num].IIR & UART_IIR_ID) == UART_IIR_THRI) {
-      s2_printf("SER%d: Read IIR = 0x%x (THRI now cleared)\n",num,val);
+      if(s2_printf) s_printf("SER%d: Read IIR = 0x%x (THRI now cleared)\n",num,val);
       com[num].int_condition &= ~TX_INTR;	/* Unflag TX int condition */
       serial_int_engine(num, 0);		/* Update interrupt status */
     }
     else {
-      s2_printf("SER%d: Read IIR = 0x%x\n",num,val);
+      if(s2_printf) s_printf("SER%d: Read IIR = 0x%x\n",num,val);
     }
     break;
 
   case UART_LCR:	/* Read from Line Control Register */
     val = com[num].LCR;
-    s2_printf("SER%d: Read LCR = 0x%x\n",num,val);
+    if(s2_printf) s_printf("SER%d: Read LCR = 0x%x\n",num,val);
     break;
 
   case UART_MCR:	/* Read from Modem Control Register */
     val = com[num].MCR;
-    s2_printf("SER%d: Read MCR = 0x%x\n",num,val);
+    if(s2_printf) s_printf("SER%d: Read MCR = 0x%x\n",num,val);
     break;
 
   case UART_LSR:	/* Read from Line Status Register */
     val = get_lsr(num);
-    s2_printf("SER%d: Read LSR = 0x%x\n",num,val);
+    if(s2_printf) s_printf("SER%d: Read LSR = 0x%x\n",num,val);
     break;
 
   case UART_MSR:	/* Read from Modem Status Register */
     val = get_msr(num);
-    s2_printf("SER%d: Read MSR = 0x%x\n",num,val);
+    if(s2_printf) s_printf("SER%d: Read MSR = 0x%x\n",num,val);
     break;
 
   case UART_SCR:   	/* Read from Scratch Register */
     val = com[num].SCR;
-    s2_printf("SER%d: Read SCR = 0x%x\n",num,val);
+    if(s2_printf) s_printf("SER%d: Read SCR = 0x%x\n",num,val);
     break;
 
   default:		/* The following code should never execute. */
@@ -1004,15 +1006,15 @@
 /*case UART_DLL:*/	/* or write to Baudrate Divisor Latch LSB */
     if (com[num].DLAB) {	/* If DLAB set, */
       com[num].dll = val;	/* then write to Divisor Latch LSB */
-      s2_printf("SER%d: Divisor LSB = 0x%02x\n", num, val);
+      if(s2_printf) s_printf("SER%d: Divisor LSB = 0x%02x\n", num, val);
     }
     else {
       put_tx(num, val);		/* else, Transmit character (write to THR) */
       #ifdef SER_DEBUG_HEAVY
         if (com[num].MCR & UART_MCR_LOOP)
-          s2_printf("SER%d: Transmit 0x%x Loopback\n",num,val);
+          if(s2_printf) s_printf("SER%d: Transmit 0x%x Loopback\n",num,val);
         else
-          s2_printf("SER%d: Transmit 0x%x\n",num,val);
+          if(s2_printf) s_printf("SER%d: Transmit 0x%x\n",num,val);
       #endif
     }
     break;
@@ -1021,7 +1023,7 @@
 /*case UART_DLM:*/	/* or write to Baudrate Divisor Latch MSB */
     if (com[num].DLAB) {	/* If DLAB set, */
       com[num].dlm = val;	/* then write to Divisor Latch MSB */
-      s2_printf("SER%d: Divisor MSB = 0x%x\n", num, val);
+      if(s2_printf) s_printf("SER%d: Divisor MSB = 0x%x\n", num, val);
     }
     else {			/* Else, write to Interrupt Enable Register */
       if ( !(com[num].IER & 2) && (val & 2) ) {
@@ -1029,13 +1031,13 @@
         com[num].tx_trigger = 1;
       }
       com[num].IER = (val & 0xF);	/* Write to IER */
-      s1_printf("SER%d: IER = 0x%x\n", num, val);
+      if(s1_printf) s_printf("SER%d: IER = 0x%x\n", num, val);
       serial_int_engine(num, 0);		/* Update interrupt status */
     }
     break;
 
   case UART_FCR:	/* Write to FIFO Control Register */
-    s1_printf("SER%d: FCR = 0x%x\n",num,val);
+    if(s1_printf) s_printf("SER%d: FCR = 0x%x\n",num,val);
     put_fcr(num, val);
     break;
 
@@ -1045,22 +1047,22 @@
     break;
 
   case UART_MCR:	/* Write to Modem Control Register */
-    s1_printf("SER%d: MCR = 0x%x\n",num,val);
+    if(s1_printf) s_printf("SER%d: MCR = 0x%x\n",num,val);
     put_mcr(num, val);
     break;
 
   case UART_LSR:	/* Write to Line Status Register */
     put_lsr(num, val);		/* writeable only to lower 6 bits */
-    s1_printf("SER%d: LSR = 0x%x -> 0x%x\n",num,val,com[num].LSR);
+    if(s1_printf) s_printf("SER%d: LSR = 0x%x -> 0x%x\n",num,val,com[num].LSR);
     break;
 
   case UART_MSR:	/* Write to Modem Status Register */
     put_msr(num, val);		/* writeable only to lower 4 bits */
-    s1_printf("SER%d: MSR = 0x%x -> 0x%x\n",num,val,com[num].MSR);
+    if(s1_printf) s_printf("SER%d: MSR = 0x%x -> 0x%x\n",num,val,com[num].MSR);
     break;
 
   case UART_SCR:	/* Write to Scratch Register */
-    s1_printf("SER%d: SCR = 0x%x\n",num,val);
+    if(s1_printf) s_printf("SER%d: SCR = 0x%x\n",num,val);
     com[num].SCR = val;
     break;
 
diff -ur dosemu-0.60.4-clean/sound/sound.c dosemu/sound/sound.c
--- dosemu-0.60.4-clean/sound/sound.c	Wed Nov  8 23:09:07 1995
+++ dosemu/sound/sound.c	Mon Apr 22 00:20:25 1996
@@ -8,11 +8,11 @@
 #include "emu.h" /* For S_printf */
 
 #include <fcntl.h>
+#include <sys/ioctl.h>
 #ifdef __linux__
 #include <linux/soundcard.h>
 #endif
 #ifdef __NetBSD__
-#include <sys/ioctl.h>
 #include <sys/audioio.h>
 #endif
 #include "pic.h"
diff -ur dosemu-0.60.4-clean/syscallmgr/README.syscallmgr dosemu/syscallmgr/README.syscallmgr
--- dosemu-0.60.4-clean/syscallmgr/README.syscallmgr	Sat Nov  4 18:46:54 1995
+++ dosemu/syscallmgr/README.syscallmgr	Thu Dec  7 00:09:01 1995
@@ -122,10 +122,10 @@
    This insmod can be used as a replacement for the ./insmod contained
    in the official modules-1.2.8.tar.gz from Bjorn Ekwall and Jacques Gelinas.
    It can replace the official one, because the special features are switched
-   on by command line options. Usage is:
+   on by command line options. Usage is (special features marked with *) :
 
 
-   insmod [-f] [-x] [-o name] [-msvwl] [-z | -Z mapfile] module [[sym=value]...]
+   insmod [-f] [-x] [-o name] [-msvwipl] [-z | -Z mapfile] module [[sym=value]...]
 
      module     Filename of a loadable kernel module (*.o)
      -o name    Set internal modulname to name
@@ -133,15 +133,16 @@
      -m         generate loadmap (so crashes can be traced down)
      -v         verbose output
      -s         set insmod syslogging
-     -w         print warnings
+   * -w         print warnings
      -f         Force loading under wrong kernel version
                 (together with -z also disables mapfile check)
-     -z         At last use /usr/src/linux/zSystem.map to resolve
+   * -z         At last use /usr/src/linux/zSystem.map to resolve
                 (on Linux > 1.1.76:  System.map)
-     -Z mapfile As -z, but use mapfile
-     -l         Together with -z, -Z, also take local symbols from map
-                (But note, local symbols can be multiple defined, last one is
-                taken)
+   * -Z mapfile As -z, but use mapfile
+   * -l         Together with -z, -Z, also take local symbols from map
+                (But note, local symbols can be multiple defined, last one is taken)
+   * -p         silent poll mode, just check if the module matches the kernel
+   * -i         ignore missing underscores in ksyms when resolving
 
 
   NOTE:
diff -ur dosemu-0.60.4-clean/syscallmgr/insmod.c dosemu/syscallmgr/insmod.c
--- dosemu-0.60.4-clean/syscallmgr/insmod.c	Sat Nov  4 18:46:53 1995
+++ dosemu/syscallmgr/insmod.c	Mon Apr 22 00:43:31 1996
@@ -32,6 +32,9 @@
  * Handle all combinations of ELF vs a.out kernels/modules: Bjorn
  * Added syslog error reporting with option "-s": Jacques Gelinas
  * Added MOD_AUTOCLEAN and option "-k" (for kerneld"): Bjorn and Jacques
+ * mc68000: Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+ *
+ * More fixes (ELF SHN_UNDEF et al) by  Andreas Schwab in February 1996
  *
  * ---------------------------
  * Support for (z)System.map resolving of unresolved symbols (HACKER_TOOL)
@@ -68,6 +71,19 @@
  *   This option can be used to poll a couple of compiled modules
  *   and/or System.maps in order to find the one that matches.
  *
+ * December 6, 1995  (HACKER_TOOL-4)
+ * - Added option -i
+ *   There is a problem when an ELF-module had been loaded into an AOUT-kernel
+ *   and this module had called register_symtab for his exported symbols.
+ *   These symbols then have no underscore prefix, so they could not be
+ *   resolved by a later loaded module.
+ *   If we use option -i of insmmod-HACKER_TOOL, we will ignore missing
+ *   underscore prefixes in ksyms, hence the modules can be loaded again.
+ *
+ * Mars 4, 1996 ( 1.3.69-HACKER_TOOL )
+ * - Adapted to modules-1.3.69.tar.gz from http://www.pi.se/blox/modules
+ *   ( fixes for binutils-2.6.0.* )
+ *
  * ---------------------------
  *
  * NOTE for HACKER_TOOL:
@@ -116,25 +132,32 @@
 	"/lib/modules/%s/fs",
 	"/lib/modules/%s/net",
 	"/lib/modules/%s/scsi",
+	"/lib/modules/%s/block",
+	"/lib/modules/%s/cdrom",
+	"/lib/modules/%s/ipv4",
 	"/lib/modules/%s/misc",
 	"/lib/modules/default/fs",
 	"/lib/modules/default/net",
 	"/lib/modules/default/scsi",
+	"/lib/modules/default/block",
+	"/lib/modules/default/cdrom",
+	"/lib/modules/default/ipv4",
 	"/lib/modules/default/misc",
 	"/lib/modules/fs",
 	"/lib/modules/net",
 	"/lib/modules/scsi",
+	"/lib/modules/block",
+	"/lib/modules/cdrom",
+	"/lib/modules/ipv4",
 	"/lib/modules/misc",
 	0
 };
 
-#define PATCH_STRINGS
-
 #include "insmod.h"
 #define is_global(sp) (aout_flag?(sp->u.n.n_type & N_EXT) : \
-				(ELF32_ST_BIND(sp->u.e.st_info) == STB_GLOBAL))
+				(ELF32_ST_BIND(sp->u.e.st_info) != STB_LOCAL))
 #define is_undef(sp) (aout_flag?((sp->u.n.n_type & ~N_EXT) == N_UNDF) : \
-			    (ELF32_ST_TYPE(sp->u.e.st_info) == STT_NOTYPE))
+			    (sp->u.e.st_shndx == SHN_UNDEF))
 
 /* hack: sizeof(struct elfhdr) > sizeof(struct exec) */
 Elf32_Ehdr header;
@@ -244,6 +267,7 @@
 int use_zSystem=0, use_zSystem_local=0, zsyms_valid=0;
 int warnings=0;
 int silent_poll_mode=0;
+int ign_underscore=0;
 
 char *zsystem_map_name="/usr/src/linux/zSystem.map";
 
@@ -339,7 +363,7 @@
   while (!feof(f) && n[0]) {
     n[0]=0;
     p=0;
-    fscanf(f, "%08x %c %s\n", &i, &c, n);
+    fscanf(f, "%x %c %s\n", &i, &c, n);
     switch (c) {
       case 't': case 'd': case 'b': case 'r': 
         if (!use_zSystem_local) break;
@@ -388,7 +412,7 @@
 		(strlen(tabentry + len) == 10))
 		return 0;
 	else
-		return retval;
+		return strcmp(tabentry, lookfor);
 }
 
 /*
@@ -407,19 +431,18 @@
 		(strlen(lookfor + len) == 10))
 		return 0;
 	else
-		return retval;
+		return strcmp(tabentry, lookfor);
 }
 
-#ifdef PATCH_STRINGS
 struct strpatch {
-	int *where;
+	int where; /* offset from start */
 	int what;
 };
 static struct strpatch *stringpatches;
 static int n_stringpatches;
 
 static void
-push_string(char *string, int *patchme)
+push_string(char *string, int patch_offset)
 {
 	int len;
 	unsigned int string_offset = progsize;
@@ -430,6 +453,19 @@
 	else
 		len = strlen(string);
 
+	/*
+	 * If we want to use any string (even one with only numbers):
+	 * enclose the string with quotes, i.e.  ' or "
+	 * (most probably escaped, if from a shell)
+	 *
+	 * Inspired by Giorgio Caset <gca@wag.ch>
+	 */
+	if (((string[0] == '\'') || (string[0] == '"')) &&
+	     (string[len - 1] == string[0])) {
+		++string; /* strip quote */
+		len -= 2; /* and quote at the end as well */
+	}
+
 	progsize += len + 1;
 	/* JEJB: don't like this, but if we're copying strings, better make
 	 * sure memory actually exists to copy them into */
@@ -443,11 +479,10 @@
 		stringpatches = (struct strpatch *)ckrealloc(stringpatches,
 			(n_stringpatches + 1) * sizeof(struct strpatch));
 
-	(*(stringpatches + n_stringpatches)).where = patchme;
+	(*(stringpatches + n_stringpatches)).where = patch_offset;
 	(*(stringpatches + n_stringpatches)).what = string_offset;
 	++n_stringpatches;
 }
-#endif
 
 int
 main(int argc, char **argv)
@@ -535,6 +570,9 @@
 			case 's':
 				insmod_setsyslog("insmod");
 				break;
+			case 'V':
+				printf("Version 1.3.69-HACKER_TOOL\n");
+				break;
 #ifdef HACKER_TOOL
 			case 'Z': /* resolve over zSystem map */
 				++argv; --argc;
@@ -553,6 +591,9 @@
 			case 'p': /* silent poll mode */
 				silent_poll_mode = 1;
 				break;
+			case 'i': /* ignore missing underscores in ksyms */
+				ign_underscore = 1;
+				break;
 #endif
 			}
 			++p;
@@ -564,7 +605,7 @@
 	if (argc < 2) {
 #ifdef HACKER_TOOL
 		fputs("Usage:\n"
-		      "insmod [-f] [-x] [-o name] [-msvwl] [-z | -Z mapfile] module [[sym=value]...]\n"
+		      "insmod [-f] [-x] [-o name] [-msvwipl] [-z | -Z mapfile] module [[sym=value]...]\n"
 		      "\n"
 		      "  module     Filename of a loadable kernel module (*.o)\n"
 		      "  -o name    Set internal modulname to name\n"
@@ -581,6 +622,7 @@
 		      "  -l         Together with -z, -Z, also take local symbols from map\n"
 		      "             (But note, local symbols can be multiple defined, last one is taken)\n"
 		      "  -p         silent poll mode, just check if the module matches the kernel\n"
+		      "  -i         ignore missing underscores in ksyms when resolving\n"
 		      , stderr);
 #else
 		fputs("Usage: insmod [-f] [-x] [-o name] [-m] [-s] [-v] module "
@@ -722,7 +764,13 @@
 	else if ((header.e_ident[0] == 0x7f) &&
 		 (strncmp(&header.e_ident[1], "ELF",3) == 0) &&
 		 (header.e_type == ET_REL) &&
+#ifdef __i386__
 		 ((header.e_machine == 3) || (header.e_machine == 6))
+#endif
+#ifdef __mc68000__
+		 header.e_machine == EM_68K
+#endif
+/* Sorry SPARC */
 		) {
 			char *errstr;
 
@@ -790,7 +838,10 @@
 	case 3: /* versioned_kernel,   versioned_module */
 #ifdef HACKER_TOOL
 		if (use_zSystem) check_version(force_load);
+		else
 #endif
+		if (force_load)
+			check_version(force_load);
 		tabcomp = strncmp;
 		break;
 
@@ -818,7 +869,22 @@
 			continue;
 		}
 
+#ifdef HACKER_TOOL
+		/* Here is the kludge to solve the problem when an ELF module
+		   had been loaded into an AOUT kernel and had called
+		   register_symtab for his exported symbols.
+		 */
+		if (defsym(tabcomp, ksym->name + 
+		  (elf_kernel ? 0
+			      : ( !ign_underscore ? 1
+						    : ((ksym->name[0]=='_') ? 1
+									    : 0
+						      ) 
+				)
+		  ), 
+#else
 		if (defsym(tabcomp, ksym->name + (elf_kernel?0:1),
+#endif
 			ksym->value, N_ABS | N_EXT,
 		/* this is safe since curr_module was initialized properly */
 			(curr_module->name[1]) ?  TRANSIENT : RESIDENT)) {
@@ -890,6 +956,7 @@
 			}
 			else { /* I'm not sure I understand this... */
 				sp->u.e.st_info = (STB_GLOBAL << 4)| STT_OBJECT;
+				sp->u.e.st_shndx = SHN_ABS;
 				len = (sp->u.e.st_size)?(sp->u.e.st_size):4;
 			}
  			symvalue(sp) = bss_offset;
@@ -900,7 +967,7 @@
 				if (v && (strncmp(v, "_R", 2) == 0) &&
 					(strlen(v) == 10))
 					*v = '\0';
-				insmod_error ("%s: wrong version",
+				insmod_error ("%s: wrong version or undefined",
 					symname(sp));
 				if (v && !(*v))
 					*v = '_';
@@ -960,13 +1027,14 @@
 			do {
 				++val;
 				if (*val < '0' || '9' < *val) {
-#ifdef PATCH_STRINGS
+				      /*
+				       * Textseg may change during calls to 
+				       * push_string() so we store the offset
+				       *
+				       * Timo Kokkonen <timo@cs.ualberta.ca>
+				       */
 					if (*val != ',')
-						push_string(val, patchme);
-#else
-					insmod_error ("Symbol '%s' has an illegal value: %s", param, val);
-					exit(2);
-#endif
+				     		push_string(val, symvalue(change));
 				}
 				else { /* numerical */
 					if (val[0] == '0') {
@@ -1020,19 +1088,30 @@
 	else
 		relocate_elf(fp, textseg - otextseg);
 
-#ifdef PATCH_STRINGS
-	{
-		struct strpatch *p = stringpatches;
+	/*
+	 * Patch in any new strings from the command line
+	 */
+	while (n_stringpatches > 0) {
+		/*
+		 * Now we have to calculate the "absolute" address of the
+		 * string and update the "pointer" in the module image...
+		 *
+		 * Timo Kokkonen <timo@cs.ualberta.ca>
+		 */
+		*((int *)(textseg + stringpatches->where)) =
+			  addr + stringpatches->what; /* kernel address */
+		++stringpatches;
+		--n_stringpatches;
+	}
+	if (stringpatches)
+		free(stringpatches);
+	stringpatches = (struct strpatch *)0;
+	n_stringpatches = 0;
 
-		while (--n_stringpatches >= 0) {
-			*(p->where) = (int)addr + p->what;
-			++p;
-		}
 
-		free(stringpatches);
-		n_stringpatches = 0;
-	}
-#endif
+	/*
+	 * Handle module "administrativia"
+	 */
 	init_func += addr;
 	cleanup_func += addr;
 
@@ -1125,9 +1204,7 @@
 		delete_module(modname);
 		exit(1);
 	}
-#ifdef DEBUG_DISASM
-dis(textseg, codesize);
-#endif
+
 	/*
 	 * Print a loadmap so that kernel panics can be identified.
 	 * Load map option conceived by Derek Atkins <warlord@MIT.EDU>
@@ -1205,15 +1282,15 @@
 		sp->u.n.n_type = type;
 	}
 	else { /* elf */
-		if ((ELF32_ST_BIND(sp->u.e.st_info) != STB_GLOBAL) ||
-		    (ELF32_ST_TYPE(sp->u.e.st_info) != STT_NOTYPE))
+		if ((ELF32_ST_BIND(sp->u.e.st_info) == STB_LOCAL) ||
+		    (sp->u.e.st_shndx != SHN_UNDEF))
 			return 0; /* symbol not used */
 		/* hack follows... */
 		if (type & N_ABS)
 			sp->u.e.st_info = (STB_GLOBAL << 4);
 		else
 			sp->u.e.st_info = (STB_LOCAL << 4);
-		sp->u.e.st_info |= STT_OBJECT; /* or whatever */
+		sp->u.e.st_shndx = SHN_ABS; /* or whatever */
 	}
 
 	symother(sp) |= source;
diff -ur dosemu-0.60.4-clean/syscallmgr/load_aout.c dosemu/syscallmgr/load_aout.c
--- dosemu-0.60.4-clean/syscallmgr/load_aout.c	Sat Nov  4 18:46:53 1995
+++ dosemu/syscallmgr/load_aout.c	Tue Mar  5 01:56:24 1996
@@ -120,12 +120,9 @@
 		if (pos < 0 || pos >= len)
 			return "Bad nlist entry";
 		/* look up name and add sp to binary tree */
-#ifdef HACKER_TOOL
-			/* may be ASM label without underscore */
-		if (name[0] != '_') findsym(name, sp, strncmp); 
-		else
-#endif
-		findsym(name + 1, sp, strncmp); /* Ignore leading '_' */
+		if (*name == '_') /* Ignore leading '_' */
+			++name;
+		findsym(name, sp, strncmp);
 		if ((sp->u.n.n_type & N_EXT) && (sp->u.n.n_type != N_EXT))
 			sp->u.n.n_other = DEF_BY_MODULE; /* abuse: mark extdef */
 		else {
diff -ur dosemu-0.60.4-clean/syscallmgr/load_elf.c dosemu/syscallmgr/load_elf.c
--- dosemu-0.60.4-clean/syscallmgr/load_elf.c	Sat Nov  4 18:46:53 1995
+++ dosemu/syscallmgr/load_elf.c	Tue Mar  5 01:56:24 1996
@@ -9,6 +9,10 @@
  * Fixes for 1.2.8 from H.J.Lu <hjl@nynexst.com>
  * Many ELF and other fixes from:
  * 	James Bottomley <J.E.J.Bottomley@damtp.cambridge.ac.uk>
+ * mc68000 additions:
+ *	Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+ *
+ * More fixes (ELF SHN_UNDEF et al) by  Andreas Schwab in February 1996
  */
 #include "insmod.h"
 
@@ -25,6 +29,7 @@
 static void
 build_got(void)
 {
+#ifdef __i386__
 	Elf32_Ehdr *epnt = &header;
 	Elf32_Shdr *spnt;
 	Elf32_Rel *rpnt;
@@ -72,21 +77,28 @@
 		sp = (struct symbol *)(*next_got);
 		sp->u.e.st_other &= ~GOTTEN;
 	}
+#endif
 }
 
 static void
-elf_relocate(unsigned int loadaddr, Elf32_Rel *rpnt, int n_rel)
+elf_relocate(unsigned int loadaddr, void *secpnt, int n_rel)
 {
 	struct symbol *sp = NULL;
 	unsigned int *reloc_addr;
 	unsigned int symbol_addr;
 	unsigned int real_reloc_addr;
-	int *gp;
 	int i;
-	int g;
 	int reloc_type;
 	int symtab_index;
+#ifdef __i386__
+	int *gp;
+	int g;
 	int got_addr = (int)got - (int)textseg + addr;
+	Elf32_Rel *rpnt = (Elf32_Rel *) secpnt;
+#endif
+#ifdef __mc68000__
+	Elf32_Rela *rpnt = (Elf32_Rela *) secpnt;
+#endif
 
 #ifdef DEBUG
 	insmod_debug ("loadaddr = 0x%08x", loadaddr);
@@ -117,7 +129,9 @@
 			/* kludge done at loading:
 			 * st_value = offset from image start!
 			 */
-			if (sp->u.e.st_shndx && secref[sp->u.e.st_shndx]) {
+			if (sp->u.e.st_shndx &&
+			    sp->u.e.st_shndx < SHN_LORESERVE &&
+			    secref[sp->u.e.st_shndx]) {
 				symbol_addr = (unsigned int)sp->u.e.st_value +
 						addr;
 			}
@@ -139,6 +153,7 @@
 			symbol_addr, reloc_type);
 #endif
 		switch(reloc_type) {
+#ifdef __i386__
 		case R_386_32:
 			*reloc_addr += symbol_addr;
 			break;
@@ -178,6 +193,39 @@
 		case R_386_GOTOFF:
 			*reloc_addr += symbol_addr - got_addr;
 			break;
+#endif
+#ifdef __mc68000__
+		case R_68K_NONE:
+			break;
+
+		case R_68K_8:
+			*(char *) reloc_addr = symbol_addr + rpnt->r_addend;
+			break;
+		case R_68K_16:
+			*(short *) reloc_addr = symbol_addr + rpnt->r_addend;
+			break;
+		case R_68K_32:
+			*reloc_addr = symbol_addr + rpnt->r_addend;
+			break;
+
+		case R_68K_PC8:
+			*(char *) reloc_addr = (symbol_addr + rpnt->r_addend
+						- real_reloc_addr);
+			break;
+		case R_68K_PC16:
+			*(short *) reloc_addr = (symbol_addr + rpnt->r_addend
+						 - real_reloc_addr);
+			break;
+		case R_68K_PC32:
+			*reloc_addr = (symbol_addr + rpnt->r_addend
+				       - real_reloc_addr);
+			break;
+
+		case R_68K_RELATIVE:
+			*reloc_addr += ((int) loadaddr - (int) textseg + addr
+					+ rpnt->r_addend);
+			break;
+#endif
 
 		default:
 			insmod_error ("Unable to handle reloc type %d",
@@ -192,7 +240,6 @@
 {
 	Elf32_Ehdr *epnt = &header;
 	Elf32_Shdr *spnt;
-	Elf32_Rel *rpnt;
 	int *next_got;
 	unsigned int loadaddr;
 	int i;
@@ -213,12 +260,20 @@
 	memset(secref[bss_seg], bss_size, 0);
 
 	for (spnt = sections, i = 0; i < epnt->e_shnum; ++i, ++spnt) {
+#ifdef __i386__
 		if (spnt->sh_type == SHT_REL) {
 			loadaddr = (unsigned int)secref[spnt->sh_info];
-			rpnt = (Elf32_Rel *)secref[i];
 			n_rel= sections[i].sh_size / sections[i].sh_entsize;
-			elf_relocate(loadaddr, rpnt, n_rel);
+			elf_relocate(loadaddr, (void *) secref[i], n_rel);
 		}
+#endif
+#ifdef __mc68000__
+		if (spnt->sh_type == SHT_RELA) {
+			loadaddr = (unsigned int)secref[spnt->sh_info];
+			n_rel= sections[i].sh_size / sections[i].sh_entsize;
+			elf_relocate(loadaddr, (void *) secref[i], n_rel);
+		}
+#endif
 	}
 
 	/* fix up got */
@@ -227,7 +282,9 @@
 		int symbol_addr;
 
 		sp = (struct symbol *)(*next_got);
-		if (sp->u.e.st_shndx && secref[sp->u.e.st_shndx]) {
+		if (sp->u.e.st_shndx &&
+		    sp->u.e.st_shndx < SHN_LORESERVE &&
+		    secref[sp->u.e.st_shndx]) {
 			symbol_addr = (unsigned int)sp->u.e.st_value + addr;
 			}
 		else {
@@ -238,10 +295,6 @@
 		}
 		*next_got = symbol_addr;
 	}
-
-#ifdef DEBUG_DISASM
-	dis(textseg, codesize);
-#endif
 }
 
 char *
@@ -355,6 +408,7 @@
 			break;
 
 		case SHT_REL:
+#ifdef __i386__
 			secref[i] = (char *)ckalloc(spnt->sh_size);
 
 			fseek(fp, spnt->sh_offset, SEEK_SET);
@@ -362,12 +416,27 @@
 			if (feof(fp) || ferror(fp))
 				return "Error reading ELF REL section";
 			break;
+#else
+			return "can't handle section REL";
+#endif
+
+		case SHT_RELA:
+#ifdef __mc68000__
+			secref[i] = (char *)ckalloc(spnt->sh_size);
+
+			fseek(fp, spnt->sh_offset, SEEK_SET);
+			fread(secref[i], spnt->sh_size, 1, fp);
+			if (feof(fp) || ferror(fp))
+				return "Error reading ELF RELA section";
+			break;
+#else
+			return "can't handle section RELA";
+#endif
 
-		case SHT_RELA: return "can't handle section RELA";
 		case SHT_HASH: return "can't handle section HASH";
 		case SHT_DYNAMIC: return "can't handle section DYNAMIC";
 		case SHT_SHLIB: return "can't handle section SHLIB";
-		case SHT_DYNSYM: return "can't handle section DYMSYM";
+		case SHT_DYNSYM: return "can't handle section DYNSYM";
 		case SHT_NUM: return "can't handle section NUM";
 		default: return "can't handle section > 12";
 		}
@@ -393,10 +462,13 @@
 	}
 
 	for (n = nsymbols, sp = symtab ; --n >= 0 ; sp++) {
-		/* look up name and add sp to binary tree */
+		/* Hmmm... */
+		if ((sp->u.e.st_info == 0) && (sp->u.e.st_shndx != SHN_UNDEF))
+			sp->u.e.st_info = STT_OBJECT; /* as good as any... */
+		/* look up name and add sp to splay tree */
 		findsym(stringtab + sp->u.e.st_name, sp, strncmp);
-		if ((ELF32_ST_BIND(sp->u.e.st_info) == STB_GLOBAL) &&
-			(ELF32_ST_TYPE(sp->u.e.st_info) != STT_NOTYPE))
+		if ((ELF32_ST_BIND(sp->u.e.st_info) != STB_LOCAL) &&
+		    (sp->u.e.st_shndx != SHN_UNDEF))
 			symother(sp) = DEF_BY_MODULE; /* abuse: mark extdef */
 		else {
 			symother(sp) = 0; /* abuse: mark extref */
@@ -406,8 +478,9 @@
 		 * the start of the newly build image.
 		 * I rely on the secref mapping to be correct...
 		 */
-		if ( (sp->u.e.st_shndx < header.e_shnum) && /* always >= 0 ! */
-			secref[sp->u.e.st_shndx]) {
+		if ((sp->u.e.st_shndx != SHN_UNDEF) &&
+		    (sp->u.e.st_shndx < header.e_shnum) && /* always >= 0 ! */
+		    secref[sp->u.e.st_shndx]) {
 
 			(unsigned int)sp->u.e.st_value +=
 				(int)(secref[sp->u.e.st_shndx]) -
@@ -460,30 +533,3 @@
 
 	return (char *)0;
 }
-
-
-#ifdef DEBUG_DISASM
-void print_address(unsigned int addr, FILE * outfile){
-	fprintf(outfile,"0x%8.8x", addr);
-}
-
-/* Needed by the i386 disassembler */
-void db_task_printsym(unsigned int addr){
-  print_address(addr, stderr);
-}
-
-void
-dis(int addr, int len)
-{
-	int lbytes;
-
-	  while(len > 0) {
-	    fprintf(stderr,"0x%8.8x  ", addr);
-	    lbytes =  db_disasm((unsigned int) addr, 0, 0) -
-	      ((unsigned int) addr);
-	    addr += lbytes;
-	    len -= lbytes;
-	    fprintf(stderr,"\n");
-	  }
-}
-#endif
diff -ur dosemu-0.60.4-clean/syscallmgr/syscallmgr.c dosemu/syscallmgr/syscallmgr.c
--- dosemu-0.60.4-clean/syscallmgr/syscallmgr.c	Sat Nov 11 01:55:40 1995
+++ dosemu/syscallmgr/syscallmgr.c	Thu Jan 25 02:02:14 1996
@@ -186,7 +186,7 @@
 
   save_flags(flags);
   cli();
-  for (i=NR_syscalls-1; !sys_call_table[i]; i--);
+  for (i=NR_syscalls-1; (!sys_call_table[i]) && (i > (NR_syscalls-40)); i--);
   restore_flags(flags);
   return i+1; 
 
diff -ur dosemu-0.60.4-clean/video/screen.h dosemu/video/screen.h
--- dosemu-0.60.4-clean/video/screen.h	Sat Nov  4 18:46:55 1995
+++ dosemu/video/screen.h	Mon Apr 22 00:20:25 1996
@@ -1,5 +1,6 @@
 #include <X11/X.h>
 #include <X11/Xlib.h>
+#include <X11/Xatom.h>
 
 typedef struct _win_info
 {
diff -ur dosemu-0.60.4-clean/video/terminal.c dosemu/video/terminal.c
--- dosemu-0.60.4-clean/video/terminal.c	Sat Nov  4 18:46:55 1995
+++ dosemu/video/terminal.c	Mon Apr 22 00:20:25 1996
@@ -160,7 +160,7 @@
 terminal_initialize()
 {
    SLtt_Char_Type sltt_attr, fg, bg, attr, color_sltt_attr, bw_sltt_attr;
-   int is_color = config.term_color, i;
+   int is_color = config.term_color;
    int rotate[8];
    
    v_printf("VID: terminal_initialize() called \n");
@@ -354,7 +354,8 @@
      }
    help_showing = 0;
    
-   if ((DOSemu_Terminal_Scroll == 0) && (cursor_row < SLtt_Screen_Rows)
+   if (((DOSemu_Terminal_Scroll == 0) && 
+	(cursor_row < SLtt_Screen_Rows))
        || (DOSemu_Terminal_Scroll == -1))
      {
 	imin = 0;
diff -ur dosemu-0.60.4-clean/video/vc.c dosemu/video/vc.c
--- dosemu-0.60.4-clean/video/vc.c	Sun Nov  5 15:51:36 1995
+++ dosemu/video/vc.c	Mon Apr 22 00:52:55 1996
@@ -155,9 +155,12 @@
 static void SIGACQUIRE_call (void);
 
 void dump_video_regs (void);
+
+#ifdef WANT_DUMP_VIDEO
 static void dump_video ();
+#endif
+
 void dump_video_linux ();
-static u_char video_type = PLAINVGA;
 
 
 static int  color_text;
@@ -212,7 +215,6 @@
 {
   if (mice->intdrv)
     {
-      static int old_mice_flags;
       mice->fd = DOS_SYSCALL (open (mice->dev, O_RDWR | O_NONBLOCK));
       if (mice->fd > 0)
 	add_to_io_select(mice->fd, mice->add_to_io_select);
@@ -279,7 +281,7 @@
     {
       v_printf ("Acquiring vt, restoring dosemu_regs\n");
       get_perm ();
-#if 0
+#ifdef WANT_DUMP_VIDEO
       dump_video ();
 #endif
       restore_vga_state (&dosemu_regs);
@@ -300,7 +302,7 @@
       v_printf ("Storing dosemu_regs, Releasing vt mode=%02x\n", *(u_char *) 0x449);
       dosemu_regs.video_mode = *(u_char *) 0x449;
       save_vga_state (&dosemu_regs);
-#if 0
+#ifdef WANT_DUMP_VIDEO
       dump_video ();
 #endif
       if (linux_regs.mem != (u_char) NULL)
@@ -335,9 +337,9 @@
 
       if (config.console_video)
 	{
-	  unsigned short pos;
 
 #if 0 /* 94/01/12 Why was this here :-( ? */
+	  unsigned short pos;
 
 	  /* Read the cursor position from the 6845 registers. */
 	  /* Must have bios_video_port initialized */
@@ -1082,6 +1084,7 @@
 
 
 
+#ifdef WANT_DUMP_VIDEO
 /* Generally I will request a video mode change switch quickly, and have the
    actuall registers printed out,as well as the dump of what dump_video
    received and fix the differences */
@@ -1123,6 +1126,7 @@
     v_printf ("0x%04X,", dosemu_regs.xregs16[i]);
   v_printf ("0x%04X\n", dosemu_regs.xregs16[MAX_X_REGS16]);
 }
+#endif
 
 /* Dump what's in the linux_regs */
 void
diff -ur dosemu-0.60.4-clean/video/vga.c dosemu/video/vga.c
--- dosemu-0.60.4-clean/video/vga.c	Sat Nov  4 18:46:55 1995
+++ dosemu/video/vga.c	Mon Apr 22 00:54:02 1996
@@ -4,9 +4,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#if 0
-#include <linux/string.h>
-#endif
+#include <string.h>
 
 #include "bios.h"
 #include "emu.h" 
@@ -252,7 +250,7 @@
 /*      memcpy((caddr_t) (mem + position), (caddr_t) GRAPH_BASE, p[plane]); */
       MEMCPY_2UNIX((caddr_t) (mem + position), (caddr_t) GRAPH_BASE, p[plane]);
       v_printf("READ Bank=%d, plane=0x%02x, *mem=0x%x, GRAPH_BASE=%08x, mem=0x%x\n",
-	 banks, plane, *(int *)(mem + position), *(int *) GRAPH_BASE, (caddr_t) (mem + position));
+	 banks, plane, *(int *)(mem + position), *(int *) GRAPH_BASE, (mem + position));
       position = position + p[plane];
     }
   }
diff -ur dosemu-0.60.4-clean/video/video.c dosemu/video/video.c
--- dosemu-0.60.4-clean/video/video.c	Sat Nov  4 18:46:55 1995
+++ dosemu/video/video.c	Mon Apr 22 00:20:25 1996
@@ -134,7 +134,7 @@
   scr_state.virt_address = PAGE_ADDR(0);
 }
 
-void video_close() {
+void video_close(void) {
   v_printf("VID: video_close() called\n");
   if (Video && Video->close) {
     Video->close();
@@ -267,7 +267,6 @@
 void
 gettermcap(int i)
 {
-  char *garb;
   struct winsize ws;		/* buffer for TIOCSWINSZ */
 
   li = LI;
diff -ur dosemu-0.60.4-clean/x2dos.c dosemu/x2dos.c
--- dosemu-0.60.4-clean/x2dos.c	Sat Nov  4 18:46:56 1995
+++ dosemu/x2dos.c	Mon Apr 22 00:21:39 1996
@@ -3,6 +3,9 @@
 #include <stdlib.h>
 #include <fcntl.h>
 #include <signal.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/types.h>
 
 #include <X11/Intrinsic.h> /* Include standard Toolkit Header file.
        We do no need "StringDefs.h" */
@@ -55,7 +58,7 @@
 
 char *progname;
 
-main( int argc, char * argv[] )
+void main( int argc, char * argv[] )
 {
 
   char * args[6];
