[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

MiNT-Library Patches



Hello,

uff.. I removed the __mint variable from about 50 files of the
library, but there are files still left ...

Maybe somebody else could finish the job, I got stuck on things like
ACCESS modes in open.c.

I could not check most of the changes, but they all passed gcc !

If it is possible please check them.

There is also a diff for buffindf.c to avoid things like c:\\foo .

Here are the diffs .....

Dirk




diff -u src.orig/abort.c src/abort.c
--- src.orig/abort.c	Fri Dec  8 17:18:57 1995
+++ src/abort.c	Fri Dec  8 17:18:36 1995
@@ -4,21 +4,18 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <mintbind.h>
+#include <errno.h>
 #include "lib.h"
 
 #ifndef SIGABRT
 #define SIGABRT SIGIOT
 #endif
 
-extern int __mint;
-
 __EXITING
 abort()
 {
 #ifdef __MINT__
-	if (__mint)
-        {
-		(void) Pkill(Pgetpid(), SIGABRT);
+	if (Pkill(Pgetpid(), SIGABRT) != -EINVAL) {
 		/* process still alive, maybe SIGABRT was blocked */
 		(void) Psigsetmask(Psigblock(0) & ~(sigmask(SIGABRT)));
 		/* process still alive, maybe SIGABRT was ignored */
diff -u src.orig/alarm.c src/alarm.c
--- src.orig/alarm.c	Fri Dec  8 17:18:57 1995
+++ src/alarm.c	Fri Dec  8 17:18:36 1995
@@ -7,21 +7,24 @@
 #include <limits.h>
 #include <unistd.h>
 
-extern int __mint;
-
 unsigned int
 alarm(secs)
 	unsigned secs;
 {
 	long r;
+	static short have_talarm = 1;
 
-	if (__mint == 0)
-		return 0;
+	if (have_talarm) {
 #ifndef __MSHORT__
-	if (secs > ((unsigned int) (LONG_MAX/1000)))
-		secs = ((unsigned int) (LONG_MAX/1000));
+		if (secs > ((unsigned int) (LONG_MAX/1000)))
+			secs = ((unsigned int) (LONG_MAX/1000));
 #endif
-	r = Talarm((long) secs);
+		r = Talarm((long) secs);
+		if (r == -EINVAL)
+			have_talarm = 0;
+		else
+			return (unsigned int) r;
+	}			
+	return 0;
 
-	return (unsigned int) r;
 }
diff -u src.orig/buffindf.c src/buffindf.c
--- src.orig/buffindf.c	Fri Dec  8 17:18:58 1995
+++ src/buffindf.c	Fri Dec  8 17:18:36 1995
@@ -120,7 +120,8 @@
               }
               if (c)
                       fpath++;
-              *s++ = DIRSEP1;
+              if (*s != DIRSEP1)
+                  *s++ = DIRSEP1;
               t = fname;
               while ((*s++ = *t++) != 0)
                       ;
diff -u src.orig/console.c src/console.c
--- src.orig/console.c	Fri Dec  8 17:18:59 1995
+++ src/console.c	Fri Dec  8 17:18:37 1995
@@ -8,21 +8,21 @@
 #include <osbind.h>
 #include <mintbind.h>
 #include <support.h>
+#include <errno.h>
 
 #define CTRL(x) (x & 0x1f)
 #define CBUFSIZ 80
 
-extern int __mint;
-
 int
 _console_read_byte(fd)
 	int fd;
 {
 	short f;
+	int retvalue;
+
+	if ((retvalue = (int)Fgetchar(fd, 0)) != -EINVAL)
+		return retvalue;
 
-	if (__mint) {
-		return (int)Fgetchar(fd, 0);
-	}
 	if (fd == 0)
 		return (int)Crawcin();
 	if (fd == 2)
diff -u src.orig/do_lock.c src/do_lock.c
--- src.orig/do_lock.c	Fri Dec  8 17:19:00 1995
+++ src/do_lock.c	Fri Dec  8 17:18:37 1995
@@ -10,6 +10,8 @@
 #include <file.h>
 #include "lib.h"
 
+extern int __mint;
+
 int
 _do_lock(fd, cmd, size, whence)
 	int fd;
@@ -20,12 +22,7 @@
 	struct flock lock;
 	int fcmd;
 	long r;
-	extern int __mint;
 
-	if (!__mint) {
-		errno = EINVAL;
-		return -1;
-	}
 	lock.l_whence = whence;
 	lock.l_start = 0;
 	lock.l_len = size;
diff -u src.orig/dup.c src/dup.c
--- src.orig/dup.c	Fri Dec  8 17:19:00 1995
+++ src/dup.c	Fri Dec  8 17:18:37 1995
@@ -10,8 +10,6 @@
 #include <unistd.h>
 #include "lib.h"
 
-extern int __mint;
-
 int
 dup(handle)
 	int handle;
@@ -19,9 +17,7 @@
 	register int rv;
 	long flags;
 
-	if (__mint)
-		rv = (int)Fcntl(handle, (long)0, F_DUPFD);
-	else
+	if ((rv = (int)Fcntl(handle, (long)0, F_DUPFD)) == -EINVAL);
 		rv = (int)Fdup(handle);
 
 	if (rv < (__SMALLEST_VALID_HANDLE)) {
@@ -34,10 +30,9 @@
 			__open_stat[__OPEN_INDEX(rv)] =
 				__open_stat[__OPEN_INDEX(handle)];
 		}
-		if (__mint) {
-			flags = (long)Fcntl(rv, (long)0, F_GETFD);
+		
+		if ((flags = (long)Fcntl(rv, (long)0, F_GETFD)) != -EINVAL)
 			(void)Fcntl(rv, flags & ~FD_CLOEXEC, F_SETFD);
-		}
 	}
 	return(rv);
 }
diff -u src.orig/dup2.c src/dup2.c
--- src.orig/dup2.c	Fri Dec  8 17:19:00 1995
+++ src/dup2.c	Fri Dec  8 17:18:37 1995
@@ -10,8 +10,6 @@
 #include <unistd.h>
 #include "lib.h"
 
-extern int __mint;
-
 int
 dup2(handle1, handle2)
 	int handle1, handle2;
@@ -28,10 +26,9 @@
 		if (__OPEN_INDEX(handle2) < __NHANDLES)
 			__open_stat[__OPEN_INDEX(handle2)] =
 				__open_stat[__OPEN_INDEX(handle1)];
-		if (__mint) {
-			flags = (long)Fcntl(handle2, (long)0, F_GETFD);
+		
+		if ((flags = (long)Fcntl(handle2, (long)0, F_GETFD)) != -EINVAL)
 			(void)Fcntl(handle2, flags & ~FD_CLOEXEC, F_SETFD);
-		}
 	}
 	return (rv < 0) ? -1 : handle2;
 }
diff -u src.orig/enoent.c src/enoent.c
--- src.orig/enoent.c	Fri Dec  8 17:19:00 1995
+++ src/enoent.c	Fri Dec  8 17:18:37 1995
@@ -4,8 +4,6 @@
 #include <mintbind.h>
 #include "lib.h"
 
-extern int __mint;
-
 /*
 Given a pathname for which some system call returned EPATH, this function
 decides if UNIX would have returned ENOENT instead.
@@ -18,21 +16,22 @@
 {
   register char *s;
   struct stat st;
-  long oldmask;
+  long oldmask, xattr;
 
-  if (__mint < 9)
-  {
-    return 0; /* don't bother... */
-  }
   for (s = path; *s; s++)
     /* nop */;
   oldmask = Psigblock(~0L);
+
   for ( ; s != path; s--)
   {
     if (*s == '\\')
     {
       *s = '\0';
-      if ((Fxattr(0, path, &st) == 0) && ((st.st_mode & S_IFMT) != S_IFDIR))
+      if ((xattr = Fxattr(0, path, &st)) == -EINVAL) {
+         (void) Psigsetmask(oldmask);
+         return 0;
+      }   
+      if ((xattr == 0) && ((st.st_mode & S_IFMT) != S_IFDIR))
       {
         *s = '\\';
         (void) Psigsetmask(oldmask);
diff -u src.orig/fcntl.c src/fcntl.c
--- src.orig/fcntl.c	Fri Dec  8 17:19:01 1995
+++ src/fcntl.c	Fri Dec  8 17:18:38 1995
@@ -9,8 +9,6 @@
 #include <stdarg.h>
 #include <unistd.h>
 
-extern int __mint;	/* MiNT version */
-
 #ifdef __STDC__
 int fcntl (int f, int cmd, ...)
 #else
@@ -24,13 +22,9 @@
 
 	va_start(argp, cmd);
 
-	if (__mint) {
-		r = Fcntl(f, va_arg(argp, void *), cmd);
-		if (r == -ELOCKED)
-			r = -EACCES;
-	}
-	else
-		r = -EINVAL;
+	r = Fcntl(f, va_arg(argp, void *), cmd);
+	if (r == -ELOCKED)
+		r = -EACCES;
 	if (r < 0) {
 		errno = (int) -r;
 		r = -1L;
diff -u src.orig/fstat.c src/fstat.c
--- src.orig/fstat.c	Fri Dec  8 17:19:02 1995
+++ src/fstat.c	Fri Dec  8 17:18:39 1995
@@ -12,8 +12,6 @@
 #include <ioctl.h>	/* for FSTAT */
 #include "lib.h"
 
-extern int __mint;
-
 extern ino_t __inode;
 
 __EXTERN int _do_stat __PROTO((const char *_path, struct stat *st, int lflag));
@@ -37,8 +35,7 @@
 	_DOSTIME timeptr;
 	short magic;
 
-	if (__mint >= 9) {		/* use FSTAT Fcntl */
-		r = Fcntl(fd, (long)st, FSTAT);
+	if ((r = Fcntl(fd, (long)st, FSTAT)) != -EINVAL) {
 		if (r) {
 			errno = (int) -r;
 			return -1;
diff -u src.orig/getcwd.c src/getcwd.c
--- src.orig/getcwd.c	Fri Dec  8 17:19:03 1995
+++ src/getcwd.c	Fri Dec  8 17:18:40 1995
@@ -14,7 +14,6 @@
 This routine is in the public domain.
 ********************************************************************/
 
-extern int __mint;
 extern char _rootdir;	/* in main.c: user's preferred root directory */
 
 char *getcwd(buf, size)
@@ -37,14 +36,15 @@
 	_path[1] = ':';
 	_path[2] = '\0';
 	path = _path + 2;
-	if (__mint >= 96) {
-		if ((r = (int) Dgetcwd(path, 0, size - 2)) != 0) {
+
+	r = (int) Dgetcwd(path, 0, size - 2);
+
+	if (r != 0 && r != -EINVAL) {
 			if (buf_malloced)
 				free(buf);
 			errno = -r;
 			return NULL;
-		}
-	} else {
+	} else if (r == -EINVAL) {
 		(void)Dgetpath(path, 0);
 	}
 
diff -u src.orig/getdtabl.c src/getdtabl.c
--- src.orig/getdtabl.c	Fri Dec  8 17:19:03 1995
+++ src/getdtabl.c	Fri Dec  8 17:18:40 1995
@@ -2,14 +2,16 @@
 #include <mintbind.h>
 #include <support.h>
 #include <unistd.h>
-
-extern int __mint;
+#include <errno.h>
 
 int
 getdtablesize()
 {
-	if (__mint < 7)
-		return FOPEN_MAX;
+	int r;
 
-	return (int)Sysconf(_SC_OPEN_MAX);
+	r = (int)Sysconf(_SC_OPEN_MAX);
+
+	if (r == -EINVAL)
+		return FOPEN_MAX;
+	return r;	
 }
diff -u src.orig/getegid.c src/getegid.c
--- src.orig/getegid.c	Fri Dec  8 17:19:03 1995
+++ src/getegid.c	Fri Dec  8 17:18:41 1995
@@ -1,12 +1,21 @@
 #include <types.h>
 #include <unistd.h>
 #include <mintbind.h>
-
-extern int __mint;
+#include <errno.h>
 
 gid_t
 getegid()
 {
-  return __mint >= 95 ? Pgetegid() : getgid();
+	long r;
+  	static short have_getegid = 1;
+
+  	if (have_getegid) {
+		r = Pgetegid();
+                if (r == -EINVAL)
+ 			have_getegid = 0;
+		else
+			return (gid_t)r;
+	}
+	return getgid();	     
 }
 
diff -u src.orig/geteuid.c src/geteuid.c
--- src.orig/geteuid.c	Fri Dec  8 17:19:03 1995
+++ src/geteuid.c	Fri Dec  8 17:18:41 1995
@@ -1,11 +1,20 @@
 #include <types.h>
 #include <unistd.h>
 #include <mintbind.h>
-
-extern int __mint;
+#include <errno.h>
 
 uid_t
 geteuid()
 {
-  return __mint >= 95 ? Pgeteuid() : getuid();
+	long r;
+  	static short have_geteuid = 1;
+
+  	if (have_geteuid) {
+		r = Pgeteuid();
+                if (r == -EINVAL)
+ 			have_geteuid = 0;
+		else
+			return (uid_t)r;
+	}
+	return getuid();
 }
diff -u src.orig/getgroup.c src/getgroup.c
--- src.orig/getgroup.c	Fri Dec  8 17:19:03 1995
+++ src/getgroup.c	Fri Dec  8 17:18:42 1995
@@ -27,8 +27,6 @@
 #include <stdlib.h> /* for calloc() */
 #endif
 
-extern int __mint;
-
 int
 getgroups(gsetlen, grpset)
   int     gsetlen;
@@ -39,24 +37,22 @@
   struct passwd   *userpw;
   int             i;
   gid_t           currgid;
+  long r;
 
-  if (!__mint)
-    return 0;
-
-  if (__mint >= 0x10b)
-    {
-      long r;
+  r = Pgetgroups (gsetlen, grpset);
 
-      r = Pgetgroups (gsetlen, grpset);
+  if (r != EINVAL) {
       if (r < 0)
 	{
 	  errno = -r;
 	  return -1;
 	}
       return r;
-    }
+   }
 
-  currgid = getgid();
+  currgid = (gid_t)Pgetgid();
+  if (currgid == (gid_t)(-EINVAL)) return 0;
+  
   if (gsetlen) {
     if (gsetlen < 0 || !grpset) {
       errno = EINVAL;
diff -u src.orig/getloadavg.c src/getloadavg.c
--- src.orig/getloadavg.c	Fri Dec  8 17:19:03 1995
+++ src/getloadavg.c	Fri Dec  8 17:18:42 1995
@@ -8,8 +8,6 @@
 #include <errno.h>
 #include <mintbind.h>
 
-extern int __mint;
-
 int
 getloadavg (loadavg, nelem)
      double *loadavg;
@@ -17,12 +15,6 @@
 {
   long uptime, avenrun[3], r;
   int i;
-
-  if (!__mint)
-    {
-      errno = EINVAL;
-      return -1;
-    }
 
   r = Suptime (&uptime, avenrun);
   if (r < 0)
diff -u src.orig/getpid.c src/getpid.c
--- src.orig/getpid.c	Fri Dec  8 17:19:04 1995
+++ src/getpid.c	Fri Dec  8 17:18:43 1995
@@ -4,10 +4,18 @@
 #include <mintbind.h>
 #include <errno.h>
 
-extern int __mint;
-
 int
 getpid()
 {
-  return __mint ? Pgetpid() : (int) ( ((long)_base) >> 8 );
+  	int r;
+  	static short have_getpid = 1;
+  
+  	if (have_getpid) {
+  		r = (int)Pgetpid();
+		if (r == -EINVAL)
+			have_getpid = 0;
+		else
+			return r;
+	}
+	return ((int) ( ((long)_base) >> 8 ));
 }
diff -u src.orig/getrusag.c src/getrusag.c
--- src.orig/getrusag.c	Fri Dec  8 17:19:04 1995
+++ src/getrusag.c	Fri Dec  8 17:18:44 1995
@@ -7,7 +7,6 @@
 #include <resource.h>
 #include <errno.h>
 
-extern int __mint;
 extern long _childtime;
 
 __EXTERN void _bzero __PROTO((void *, unsigned long));
@@ -48,13 +47,13 @@
 	long usage[8];
 
 	_bzero(data, (unsigned long) (sizeof (struct rusage)));
-	if (__mint) {
-		r = Prusage(usage);
-		if (r < 0) {
-			errno = (int) -r;
-			return -1;
-		}
-	} else {
+	
+	r = Prusage(usage);
+
+	if (r < 0 && r != -EINVAL) {
+		errno = (int) -r;
+		return -1;
+	} else if (r == -EINVAL) {
 		usage[0] = usage[2] = usage[4] = 0;
 		usage[1] = _clock() - _childtime;
 		usage[3] = _childtime;
diff -u src.orig/isatty.c src/isatty.c
--- src.orig/isatty.c	Fri Dec  8 17:19:06 1995
+++ src/isatty.c	Fri Dec  8 17:18:46 1995
@@ -6,6 +6,7 @@
 #include <stdio.h>
 #include <unistd.h>
 #include <mintbind.h>
+#include <errno.h>
 #include "lib.h"
 
 struct __open_file __open_stat[__NHANDLES];
@@ -17,16 +18,16 @@
   int rc;
   long oldloc;
   int handle = __OPEN_INDEX(fd);
-  extern int __mint;
+  long dummy;
 
   if (handle < __NHANDLES)
 	if (__open_stat[handle].status != FH_UNKNOWN)
 		return(__open_stat[handle].status == FH_ISATTY);
-  if (__mint) {
-	/* save 1 or 2 system calls (isatty gets called on every open...) */
-	long dummy;
-	rc = (Fcntl(fd, &dummy, TIOCGPGRP) == 0);
-  } else {
+  
+ /* save 1 or 2 system calls (isatty gets called on every open...) */
+	
+  rc = Fcntl(fd, &dummy, TIOCGPGRP);
+  if (rc == -EINVAL) {
     oldloc = Fseek(0L, fd, SEEK_CUR);	/* save current location */
     if (Fseek(1L, fd, SEEK_CUR) != 0) {	/* try to seek ahead one byte */
       /* got either a file position or an error (usually EBADARG indicating
diff -u src.orig/killpg.c src/killpg.c
--- src.orig/killpg.c	Fri Dec  8 17:19:06 1995
+++ src/killpg.c	Fri Dec  8 17:18:46 1995
@@ -7,8 +7,6 @@
 #include <unistd.h>
 #include <mintbind.h>
 
-extern int __mint;
-
 /* vector of signal handlers (for TOS) */
 extern __Sigfunc _sig_handler[];	/* in signal.c */
 
@@ -26,22 +24,13 @@
 {
 	long r;
 
-#if 0
-	if (__mint == 0) {
-		if (pgrp == 0 || pgrp == getpgrp())
-			return kill(getpid(), sig);
-		errno = EINVAL;
-		return -1;
-	}
-#endif
 	if (pgrp < 0) {
 		errno = ERANGE;
 		return -1;
 	}
 	r = Pkill(-pgrp, sig);
-	if (__mint < 7) {	/* compensate for a bug in MiNT 0.6 */
-		(void)Syield();
-	}
+	/* (void)Syield(); */
+
 	if (r == -EINVAL)
 	{
 		_have_pkill = 0;
diff -u src.orig/link.c src/link.c
--- src.orig/link.c	Fri Dec  8 17:19:07 1995
+++ src/link.c	Fri Dec  8 17:18:46 1995
@@ -7,8 +7,6 @@
 #include <stat.h>
 #include "lib.h"
 
-extern int __mint;
-
 /*
  * if MiNT is not active, we try to fail gracefully
  */
@@ -20,15 +18,11 @@
 	long r;
 	char old[MAXPATHLEN], new[MAXPATHLEN];
 
-	if (__mint < 9) {
-		errno = EXDEV;
-		return -1;
-	}
 	_unx2dos(_old, old, sizeof (old));
 	_unx2dos(_new, new, sizeof (new));
 
 	r = Flink(old, new);
-	if (r < 0) {
+	if (r < 0 && r != -EINVAL) {
 		struct stat sb;
 
 		if ((r == -EPATH)) {
@@ -39,5 +33,9 @@
 		errno = (int) -r;
 		return -1;
 	}
+	else if (r == -EINVAL) {
+		errno = EXDEV;
+		return -1;
+	}	
 	return 0;
 }
diff -u src.orig/main.c src/main.c
--- src.orig/main.c	Fri Dec  8 17:19:07 1995
+++ src/main.c	Fri Dec  8 17:18:47 1995
@@ -17,6 +17,7 @@
 
 int	errno;
 int	__mint;		/* 0 for TOS, MiNT version number otherwise */
+int	_pdomain;       /* errorcode of Pdomain call */
 
 char	_rootdir;	/* user's preferred root directory */
 
@@ -103,8 +104,8 @@
  * check for MiNT
  */
 	(void)Supexec(getMiNT);
-	if (__mint && _app)
-		(void)Pdomain(1);	/* set MiNT domain */
+	if (_app)
+		_pdomain = Pdomain(1);	/* set MiNT domain */
 
 /*
  * initialize UNIXMODE stuff. Note that this library supports only
diff -u src.orig/mkdir.c src/mkdir.c
--- src.orig/mkdir.c	Fri Dec  8 17:19:08 1995
+++ src/mkdir.c	Fri Dec  8 17:18:47 1995
@@ -13,14 +13,13 @@
 #include "lib.h"
 
 extern int errno;
-extern int __mint;
 
 int mkdir(_path, mode)
 	const char *_path;
 	mode_t mode;
 {
 	struct stat statbuf;
-	int rv;
+	int rv, umask;
 	char path[PATH_MAX];
 
 	_unx2dos(_path, path, sizeof (path));
@@ -43,8 +42,8 @@
 		errno = -rv;
 		return -1;
 	}
-	if (__mint >= 9) {
-		int umask = Pumask (0);
+	
+	if ((umask = Pumask (0)) != -EINVAL) {
 		(void) Pumask (umask);
 		(void)Fchmod(path, mode & ~umask);
 	}
diff -u src.orig/mkfifo.c src/mkfifo.c
--- src.orig/mkfifo.c	Fri Dec  8 17:19:08 1995
+++ src/mkfifo.c	Fri Dec  8 17:18:47 1995
@@ -18,12 +18,7 @@
 	unsigned short x;
 	long r;
 	int i;
-	extern int __mint;
 
-	if (__mint < 9) {
-		errno = EINVAL;
-		return -1;
-	}
 	/* create symlink to /pipe/n$ mode id (see open.c)
 	   for id code pid&0x7fff and time>>1 in base-36, this just fits
 	   in pipefs' limit of 14 chars...  */
@@ -38,7 +33,7 @@
 	*s++ = ((FMODE & 0xf0) >> 4) + '@';
 	*s++ = (FMODE & 0xf) + '@';
 #endif
-	x = 36 * 36 * 36 - 1 - (Pgetpid () & 0x7fff);
+	x = 36 * 36 * 36 - 1 - (getpid () & 0x7fff);
 	c = x % 36;
 	if (c > 9)
 		c += 'a' - '9' - 1;
@@ -73,6 +68,10 @@
 	}
 	*s = 0;
 	r = Fsymlink(linkf, path);
+	if (r == -EINVAL) {
+		errno = EINVAL;
+		return -1;
+	}
 	if (r) {
 		struct stat sb;
 
diff -u src.orig/mktemp.c src/mktemp.c
--- src.orig/mktemp.c	Fri Dec  8 17:19:08 1995
+++ src/mktemp.c	Fri Dec  8 17:18:47 1995
@@ -11,8 +11,6 @@
 #include <errno.h>
 #include "lib.h"
 
-extern int __mint;		/* 0 for TOS, MiNT version number otherwise */
-
 #define TEN_MUL(X)	((((X) << 2) + (X)) << 1)
 
 char * mktemp(pattern)
@@ -21,7 +19,7 @@
   char * p, * q;
   long tempnum, nx;
   static int startat = 0;
-  int save_errno;
+  int save_errno, pid;
 
   assert((pattern != NULL));
 
@@ -31,11 +29,14 @@
   if((nx = p - q) == 0)  /* # of X's */
 	return NULL;
 
+  pid = Pgetpid();
+
   /* if MiNT is active and there's room, put in the pid */
   /* we need 5 X's for this: up to 3 for the pid, and up to 2 for the
      extra number */
-  if (__mint && nx > 4 && startat < 256) {
-	(void) _itoa(getpid(), q, 10);
+  
+  if ((pid != -EINVAL) && nx > 4 && startat < 256) {
+	(void) _itoa(pid, q, 10);
 	while (*q) q++;
 	/* be sure to generate each name only once */
 	if (startat < 16) *q++ = '0';
diff -u src.orig/nice.c src/nice.c
--- src.orig/nice.c	Fri Dec  8 17:19:08 1995
+++ src/nice.c	Fri Dec  8 17:18:47 1995
@@ -8,16 +8,20 @@
 #include <mintbind.h>
 #include <support.h>
 
-extern long __mint;
-
 int
 nice(p)
 	int p;
 {
-	if (__mint)
-		return Pnice(p);
-	else {
-		errno = EINVAL;
-		return -1;
+	int r;
+	static short have_pnice = 1;
+
+	if (have_pnice) {
+		r = Pnice(p);
+		if (r == -EINVAL)
+			have_pnice = 0;	
+		else 
+			return r;
 	}
+	errno = EINVAL;
+	return -1;
 }
diff -u src.orig/pause.c src/pause.c
--- src.orig/pause.c	Fri Dec  8 17:19:09 1995
+++ src/pause.c	Fri Dec  8 17:18:48 1995
@@ -5,16 +5,14 @@
 #include <errno.h>
 #include <unistd.h>
 
-extern int __mint;
-
 int
 pause()
 {
-	if (__mint)
-		(void)Pause();
-	/* do nothing for TOS */
-	errno = EINTR;
-	return -1;
+	if (Pause() == -EINVAL) {
+		/* do nothing for TOS */
+		errno = EINTR;
+		return -1;
+	}
 }
 
 /* Public domain sigpause() - AGK */
@@ -24,19 +22,16 @@
 	long mask;
 {
 	long oldmask;
-
-	if (__mint == 0) {
-	/* for TOS, we just toggle the signal mask -- maybe
-	 * there's a pending signal that we can receive.
-         */
-		oldmask = sigsetmask(mask);
-		sigsetmask(oldmask);
-	}
-	else if (__mint <= 94) {
-		oldmask = Psigsetmask(mask);
-		(void)Pause();
-		(void)Psigsetmask(oldmask);
+	
+	if (Psigpause(mask) == -EINVAL) {
+		if ((oldmask = Psigsetmask(mask)) == -EINVAL) {
+			oldmask = sigsetmask(mask);
+			sigsetmask(oldmask);
+		}
+		else {	
+			(void)Pause();
+			(void)Psigsetmask(oldmask);
+		}
 	}
-	else
-		(void)Psigpause(mask);
+	
 }
diff -u src.orig/pgrp.c src/pgrp.c
--- src.orig/pgrp.c	Fri Dec  8 17:19:09 1995
+++ src/pgrp.c	Fri Dec  8 17:18:48 1995
@@ -11,86 +11,104 @@
 #include <fcntl.h>
 #include "lib.h"
 
-extern int __mint;
+static short have_pgrp = 1;
 
 pid_t
 getpgrp()
 {
-  return __mint ? Pgetpgrp() : 0;
+	int r;
+	
+	if (have_pgrp) {
+		r = Pgetpgrp();
+		if (r == -EINVAL)
+			have_pgrp = 0;
+		else
+			return (pid_t)r;
+	}
+	return 0;
 }
 
 int
-_bsd_setpgrp(pid, grp)
-  int pid, grp;
+setpgrp()
 {
-  int r = 0;
-
-  if (__mint) {
-    r = Psetpgrp(pid, grp);
-    if (r < 0) {
-      errno = -r;
-      r = -1;
-    }
-  }
-  return r;
+	int r;
+	
+	if (have_pgrp) {
+		r = Psetpgrp(0, 0);
+		if (r == -EINVAL)
+			have_pgrp = 0;
+		else
+			return r;
+	}
+	return 0;
 }
 
 int
-setpgrp()
+_bsd_setpgrp(pid, grp)
+  int pid, grp;
 {
-  return __mint ? Psetpgrp(0, 0) : 0;
+  	int r = 0;
+	
+	if (have_pgrp) {
+		r = Psetpgrp(pid, grp);
+		if (r == -EINVAL) {
+			if (grp != -1) have_pgrp = 0;
+			r = 0;
+		} 
+		else if (r < 0) {
+			errno = -r;
+      			r = -1;
+		}	
+	}
+	return r;
 }
 
 int
 _bsd_getpgrp(pid)
   int pid;
 {
-  if (__mint >= 0x103) return _bsd_setpgrp(pid, -1);
-  return 0;
+  	return _bsd_setpgrp(pid, -1);
 }
 
 int
 setpgid(pid, pgid)
   pid_t pid, pgid;
 {
-  int r = 0;
-
-  if (__mint) {
-    r = Psetpgrp((int) pid, (int) pgid);
-    if (r < 0) {
-      errno = -r;
-      r = -1;
-    }
-  }
-  return r;
+	return (_bsd_setpgrp((int) pid, (int) pgid));
 }
 
 pid_t
 setsid()
 {
-  long prc_pgrp;
-  int tty_fd;
-  int rc;
-
-  if (!__mint) {
-    errno = EINVAL;
-    return (pid_t) -1;
-  }
-  prc_pgrp = Pgetpgrp();
-  if (prc_pgrp != Pgetpid()) {
-    if (isatty(-1)) {
-      tty_fd = open("/dev/tty", O_RDWR | O_NOCTTY);
-      if (tty_fd < __SMALLEST_VALID_HANDLE) {
-        return (pid_t) -1;
-      }
-      if (ioctl(tty_fd, TIOCNOTTY, 0) < 0) return -1;
-      (void) close(tty_fd);
-    }
-  }
-  rc = (int) Psetpgrp(0, 0);
-  if (rc < 0) {
-    errno = -rc;
-    rc = -1;
-  }
-  return (pid_t) rc;
+  	long prc_pgrp;
+  	int tty_fd;
+  	int rc = -1;
+
+	if (have_pgrp) {
+		prc_pgrp = Pgetpgrp();
+		if (prc_pgrp == -EINVAL) {
+			have_pgrp = 0;
+			errno = EINVAL;
+		}
+		else {	
+  			if (prc_pgrp != Pgetpid()) {
+    				if (isatty(-1)) {
+      					tty_fd = open("/dev/tty", O_RDWR | O_NOCTTY);
+      					if (tty_fd < __SMALLEST_VALID_HANDLE)
+        					return (pid_t) -1;
+      					if (ioctl(tty_fd, TIOCNOTTY, 0) < 0) return -1;
+      					(void) close(tty_fd);
+    				}
+			}
+			rc = (int) Psetpgrp(0, 0);
+  			if (rc < 0) {
+   				errno = -rc;
+				rc = -1;
+  			}
+		}
+	}
+	else
+		errno = EINVAL;
+	
+  	return (pid_t) rc;
 }
diff -u src.orig/rename.c src/rename.c
--- src.orig/rename.c	Fri Dec  8 17:19:10 1995
+++ src/rename.c	Fri Dec  8 17:18:49 1995
@@ -9,20 +9,20 @@
 #include <mintbind.h>
 #include "lib.h"
 
-extern int __mint;
-
 int rename(_oldname, _newname)
 	const char *_oldname, *_newname;
 {
 	char oldname[PATH_MAX], newname[PATH_MAX];
 	int rval, r;
+	long xattr;
 	struct stat oldstat;
 	struct stat newstat;
 
 	_unx2dos(_oldname, oldname, sizeof (oldname));
 	_unx2dos(_newname, newname, sizeof (newname));
-
-	if (__mint
+	
+	if (((xattr = Fxattr(1, newname, &newstat)) != -EINVAL)
+            && (xattr == 0)	
 	    && (Fxattr(1, newname, &newstat) == 0)
 	    && (Fxattr(1, oldname, &oldstat) == 0)
 	    && (newstat.st_dev == oldstat.st_dev)
@@ -64,7 +64,7 @@
 	  }
 
 	if (rval < 0) {
-		if ((rval == -EPATH) && __mint >= 9 &&
+		if ((rval == -EPATH) && (xattr != -EINVAL) &&
 		    (_enoent(Fxattr(1, oldname, &oldstat) ? oldname : newname)))
 			rval = -ENOENT;
 		errno = -rval;
diff -u src.orig/rmdir.c src/rmdir.c
--- src.orig/rmdir.c	Fri Dec  8 17:19:11 1995
+++ src/rmdir.c	Fri Dec  8 17:18:49 1995
@@ -7,8 +7,6 @@
 #include <unistd.h>
 #include "lib.h"
 
-extern int __mint;
-
 int rmdir(_path)
 	const char *_path;
 {
@@ -23,7 +21,7 @@
 		if ((r == -EPATH)) {
 			if (_enoent(path))
 				r = -ENOENT;
-		} else if ((r == -EACCESS) && __mint >= 9 &&
+		} else if ((r == -EACCESS) &&
 		    (((d = Dopendir(path, 0)) & 0xff000000L) != 0xff000000L)) {
 			char *name;
 			int  rd;
diff -u src.orig/seekdir.c src/seekdir.c
--- src.orig/seekdir.c	Fri Dec  8 17:19:11 1995
+++ src/seekdir.c	Fri Dec  8 17:18:49 1995
@@ -11,8 +11,6 @@
 #include <dirent.h>
 #include "lib.h"
 
-extern int __mint;
-
 /* not POSIX */
 
 void
diff -u src.orig/setegid.c src/setegid.c
--- src.orig/setegid.c	Fri Dec  8 17:19:11 1995
+++ src/setegid.c	Fri Dec  8 17:18:49 1995
@@ -4,24 +4,24 @@
 #include <mintbind.h>
 #include <errno.h>
 
-extern int __mint;
-
 int
 setegid(x)
   int x;
 {
-  long r;
+  	long r;
+	static short have_setegid = 1;
 
-  if (__mint) {
-    if (__mint >= 0x10B) {
-      r = Psetegid(x);
-      if (r < 0) {
-	errno = (int) -r;
-	return -1;
-      }
-    } else {
-      return (setgid (x));
-    }
-  }
-  return 0;
+  	if (have_setegid) {
+		r = Psetegid(x);
+                if (r == -EINVAL)
+ 			have_setegid = 0;
+		else if (r < 0) {
+			errno = (int) -r;
+			return -1; 
+		}
+		else
+			return 0;
+			
+	}
+	return setgid(x);
 }
diff -u src.orig/seteuid.c src/seteuid.c
--- src.orig/seteuid.c	Fri Dec  8 17:19:11 1995
+++ src/seteuid.c	Fri Dec  8 17:18:49 1995
@@ -4,24 +4,24 @@
 #include <mintbind.h>
 #include <errno.h>
 
-extern int __mint;
-
 int
 seteuid(x)
   int x;
 {
-  long r;
+	long r;
+	static short have_seteuid = 1;
 
-  if (__mint) {
-    if (__mint >= 0x10B) {
-      r = Pseteuid(x);
-      if (r < 0) {
-	errno = (int) -r;
-	return -1;
-      }
-    } else {
-      return (setuid (x));
-    }
-  }
-  return 0;
+  	if (have_seteuid) {
+		r = Pseteuid(x);
+                if (r == -EINVAL)
+ 			have_seteuid = 0;
+		else if (r < 0) {
+			errno = (int) -r;
+			return -1; 
+		}
+		else
+			return 0;
+			
+	}
+	return setuid(x);
 }
diff -u src.orig/setgid.c src/setgid.c
--- src.orig/setgid.c	Fri Dec  8 17:19:11 1995
+++ src/setgid.c	Fri Dec  8 17:18:50 1995
@@ -4,24 +4,28 @@
 #include <mintbind.h>
 #include <errno.h>
 
-extern int __mint;
 extern gid_t __gid;
 
 int
 setgid(x)
   int x;
 {
-  long r;
+  	long r;
+	static short have_setgid = 1;
 
-  if (__mint) {
-    r = Psetgid(x);
-    if (r < 0) {
-      errno = (int) -r;
-      return -1;
-    }
-    return 0;
-  }
-  __gid = x;
-  return 0;
+	if (have_setgid) {
+		r = Psetgid(x);
+                if (r == -EINVAL) {
+			__gid = x;
+ 			have_setgid = 0;
+		}
+		else if (r < 0) {
+			errno = (int) -r;
+			return -1; 
+		}
+		return 0;		
+	}	
+	__gid = x;
+	return 0;
 }
 
diff -u src.orig/setregid.c src/setregid.c
--- src.orig/setregid.c	Fri Dec  8 17:19:12 1995
+++ src/setregid.c	Fri Dec  8 17:18:50 1995
@@ -4,25 +4,26 @@
 #include <mintbind.h>
 #include <errno.h>
 
-extern int __mint;
-
 int
 setregid(rgid,egid)
   int rgid, egid;
+
 {
-  long r;
+	long r;
+	static short have_setregid = 1;
 
-  if (__mint) {
-    if (__mint >= 0x10B) {
-      r = Psetregid(rgid, egid);
-      if (r < 0) {
-	errno = (int) -r;
-	return -1;
-      }
-    } else {
-      return (setgid (egid));
-    }
-  }
-  return 0;
+  	if (have_setregid) {
+		r = Psetregid(rgid, egid);
+                if (r == -EINVAL)
+ 			have_setregid = 0;
+		else if (r < 0) {
+			errno = (int) -r;
+			return -1; 
+		}
+		else
+			return 0;
+			
+	}
+	return setgid(egid);
 }
 
diff -u src.orig/setreuid.c src/setreuid.c
--- src.orig/setreuid.c	Fri Dec  8 17:19:12 1995
+++ src/setreuid.c	Fri Dec  8 17:18:50 1995
@@ -4,25 +4,25 @@
 #include <mintbind.h>
 #include <errno.h>
 
-extern int __mint;
-
 int
 setreuid(ruid,euid)
   int ruid, euid;
 {
-  long r;
+	long r;
+	static short have_setreuid = 1;
 
-  if (__mint) {
-    if (__mint >= 0x10B) {
-      r = Psetreuid(ruid, euid);
-      if (r < 0) {
-	errno = (int) -r;
-	return -1;
-      }
-    } else {
-      return (setuid (euid));
-    }
-  }
-  return 0;
+  	if (have_setreuid) {
+		r = Psetreuid(ruid, euid);
+                if (r == -EINVAL)
+ 			have_setreuid = 0;
+		else if (r < 0) {
+			errno = (int) -r;
+			return -1; 
+		}
+		else
+			return 0;
+			
+	}
+	return setuid(euid);
 }
 
diff -u src.orig/setrlimi.c src/setrlimi.c
--- src.orig/setrlimi.c	Fri Dec  8 17:19:12 1995
+++ src/setrlimi.c	Fri Dec  8 17:18:50 1995
@@ -7,8 +7,6 @@
 #include <mintbind.h>
 #include <errno.h>
 
-extern int __mint;
-
 int
 setrlimit(kind, rl)
 	int kind;
@@ -17,12 +15,7 @@
 	unsigned long limit;
 	long r;
 	int mode;
-
-	if (!__mint) {
-		errno = EINVAL;
-		return -1;
-	}
-
+	
 	limit = rl->rlim_cur;
 
 	if (limit >= RLIM_INFINITY)
@@ -42,6 +35,7 @@
 		return -1;
 	}
 	r = Psetlimit(mode, limit);
+		
 	if (r < 0) {
 		errno = (int) -r;
 		return -1;
@@ -57,11 +51,7 @@
 	long limit;
 	int mode;
 
-	if (!__mint) {
-		errno = EINVAL;
-		return -1;
-	}
-
+	
 	switch(kind) {
 	case RLIMIT_CPU:
 		mode = 1;
@@ -77,10 +67,12 @@
 		return -1;
 	}
 	limit = Psetlimit(mode, -1L);
+		
 	if (limit < 0) {
 		errno = (int ) -limit;
 		return -1;
 	}
+
 	if (limit == 0)
 		limit = RLIM_INFINITY;
 
diff -u src.orig/setuid.c src/setuid.c
--- src.orig/setuid.c	Fri Dec  8 17:19:12 1995
+++ src/setuid.c	Fri Dec  8 17:18:50 1995
@@ -4,23 +4,27 @@
 #include <mintbind.h>
 #include <errno.h>
 
-extern int __mint;
 extern uid_t __uid;
 
 int
 setuid(x)
   int x;
 {
-  long r;
+  	long r;
+	static short have_setuid = 1;
 
-  if (__mint) {
-    r = Psetuid(x);
-    if (r < 0) {
-      errno = (int) -r;
-      return -1;
-    }
-    return 0;
-  }
-  __uid = x;
-  return 0;
+	if (have_setuid) {
+		r = Psetuid(x);
+                if (r == -EINVAL) {
+			__uid = x;
+ 			have_setuid = 0;
+		}
+		else if (r < 0) {
+			errno = (int) -r;
+			return -1; 
+		}
+		return 0;		
+	}	
+	__uid = x;
+	return 0;
 }
diff -u src.orig/sigactio.c src/sigactio.c
--- src.orig/sigactio.c	Fri Dec  8 17:19:12 1995
+++ src/sigactio.c	Fri Dec  8 17:18:50 1995
@@ -4,6 +4,7 @@
 #include <osbind.h>
 #include <mintbind.h>
 #include <signal.h>
+#include <stddef.h>
 
 /* vector of signal handlers (for TOS, or for MiNT with -mshort) */
 extern __Sigfunc _sig_handler[__NSIG];
@@ -22,10 +23,15 @@
 	struct sigaction *oact;
 {
 	long r;
-	extern int __mint;
 	__Sigfunc oldfunc;
+	static short have_psigaction = 1;
 
-	if (__mint >= 95) {
+	if (have_psigaction) {
+		if (Psigaction(-1,NULL,NULL) == -EINVAL)
+			have_psigaction = 0;
+	}
+		
+	if (have_psigaction) {
 		struct ksigact {
 			__KerSigfunc	sa_handler;	/* pointer to signal handler */
 			long		sa_mask;	/* additional signals masked during delivery */
diff -u src.orig/sigblock.c src/sigblock.c
--- src.orig/sigblock.c	Fri Dec  8 17:19:12 1995
+++ src/sigblock.c	Fri Dec  8 17:18:50 1995
@@ -5,7 +5,6 @@
 #include <mintbind.h>
 #include <unistd.h>
 
-extern int __mint;
 extern long _sigpending, _sigmask;
 
 static void checksigs __PROTO((void));
@@ -37,9 +36,10 @@
 	long mask;
 {
 	register long omask;
+	long r;
 
-	if (__mint)
-		return Psigsetmask(mask);
+	if ((r = Psigsetmask(mask)) != -EINVAL)
+		return r;
 
 	omask = _sigmask;
 	_sigmask = mask;
@@ -56,9 +56,10 @@
 	long mask;
 {
 	register long omask;
+	long r;
 
-	if (__mint)
-		return Psigblock(mask);
+	if ((r = Psigblock(mask)) != -EINVAL)
+		return r;
 
 	omask = _sigmask;
 	_sigmask |= mask;
diff -u src.orig/signal.c src/signal.c
--- src.orig/signal.c	Fri Dec  8 17:19:12 1995
+++ src/signal.c	Fri Dec  8 17:18:50 1995
@@ -15,7 +15,6 @@
 /* vector giving an indication of which signals are currently pending (for TOS) */
 extern long _sigpending;
 
-
 #ifdef __MSHORT__
 /* trampoline code: for any caught signal, converts the 32 bit signal
  * number MiNT passed us into a 16 bit one, and jumps to the handler
@@ -45,19 +44,9 @@
 	__Sigfunc func;
 {
 	long old;
-	extern int __mint;
 	__Sigfunc oldfunc;
-
-	if (__mint == 0) {
-		if (sig < 0 || sig >= NSIG) {
-			errno = ERANGE;
-			return SIG_ERR;
-		}
-		oldfunc = _sig_handler[sig];
-		_sig_handler[sig] = func;
-		return oldfunc;
-	}
-
+	static short have_psignal = 1;
+	
 #ifdef __MSHORT__
 /* NOTE: MiNT passes 32 bit numbers for signals, so we want our
  * own signal dispatcher to switch these to 16 bit ints
@@ -68,18 +57,33 @@
 	}
 	oldfunc = _sig_handler[sig];
 	_sig_handler[sig] = func;
-	if (func != SIG_DFL && func != SIG_IGN) {
+	if (func != SIG_DFL && func != SIG_IGN)
 		func = (__Sigfunc) _trampoline;
-	}
 #endif
-	old = Psignal((short)sig, (long)func);
-	if (old < 0) {
-		errno = (int) -old;
+	if (have_psignal) {
+		old = Psignal((short)sig, (long)func);
+		if (old == -EINVAL)
+			have_psignal = 0;
+		else if (old < 0) {
+			errno = (int) -old;
+			return SIG_ERR;
+		}
+		else {
+			func = (__Sigfunc) old;
+#ifdef __MSHORT__
+			if (func == (__Sigfunc) _trampoline) func = oldfunc;
+#endif
+			return func;
+		}
+	}
+	
+#ifndef __MSHORT__ 
+	if (sig < 0 || sig >= NSIG) {
+		errno = ERANGE;
 		return SIG_ERR;
 	}
-	func = (__Sigfunc) old;
-#ifdef __MSHORT__
-	if (func == (__Sigfunc) _trampoline) func = oldfunc;
+	oldfunc = _sig_handler[sig];
+	_sig_handler[sig] = func;
 #endif
-	return func;
+	return oldfunc;
 }
diff -u src.orig/symlink.c src/symlink.c
--- src.orig/symlink.c	Fri Dec  8 17:19:16 1995
+++ src/symlink.c	Fri Dec  8 17:18:53 1995
@@ -8,7 +8,6 @@
 #include <stat.h>
 #include "lib.h"
 
-extern int __mint;
 
 /*
  * If MiNT 0.9 or later is active, use the kernel routines for these;
@@ -24,25 +23,21 @@
 	char path[PATH_MAX];
 	long r;
 
-	if (__mint >= 9) {
-		_unx2dos(old, linkname, sizeof (linkname));
-		_unx2dos(new, path, sizeof (path));
-		r = Fsymlink(linkname, path);
-		if (r) {
-			struct stat sb;
-
-			if ((r == -EPATH)) {
-				if (_enoent(path))
-					r = -ENOENT;
-			} else if ((r == -EACCESS) && (!Fxattr(1, path, &sb)))
-				r = -EEXIST;
-			errno = (int) -r;
-			return -1;
-		}
-		return (int) r;
+	_unx2dos(old, linkname, sizeof (linkname));
+	_unx2dos(new, path, sizeof (path));
+	r = Fsymlink(linkname, path);
+	if (r) {
+		struct stat sb;
+
+		if ((r == -EPATH)) {
+			if (_enoent(path))
+				r = -ENOENT;
+		} else if ((r == -EACCESS) && (!Fxattr(1, path, &sb)))
+			r = -EEXIST;
+		errno = (int) -r;
+		return -1;
 	}
-	errno = EINVAL;
-	return -1;
+	return (int) r;
 }
 
 int
@@ -55,10 +50,6 @@
 	char filename[PATH_MAX];
 	char linkto[PATH_MAX+1];
 
-	if (__mint < 9) {
-		errno = EINVAL;
-		return -1;
-	}
 	_unx2dos(unxname, filename, sizeof (filename));
 	r = Freadlink(PATH_MAX, linkto, filename);
 	if (r < 0) {
diff -u src.orig/sysconf.c src/sysconf.c
--- src.orig/sysconf.c	Fri Dec  8 17:19:17 1995
+++ src/sysconf.c	Fri Dec  8 17:18:53 1995
@@ -16,16 +16,16 @@
 #endif
 #include "lib.h"
 
-extern int __mint;
-
 #define UNLIMITED	(0x7fffffffL)
 
 long
 sysconf(var)
 	int var;
 {
-	if(__mint)
-		return Sysconf(var);
+	long r;
+
+	if ((r = Sysconf(var)) != -EINVAL)
+		return (r);
 
 	switch(var) {
 	case _SC_LAST:
@@ -53,13 +53,14 @@
 	long r;
 	char path[PATH_MAX];
 
-	if(__mint) {
-		_unx2dos (_path, path, sizeof (path));
-		r = Dpathconf(path, var);
+	_unx2dos (_path, path, sizeof (path));
+
+	if ((r = Dpathconf(path, var)) != -EINVAL) {
 		if (var == _PC_NO_TRUNC)
 			return r ? -1 : 0;
 		return r;
 	}
+
 	switch(var) {
 	case _PC_LAST:
 		return 4;
diff -u src.orig/tcdrain.c src/tcdrain.c
--- src.orig/tcdrain.c	Fri Dec  8 17:19:17 1995
+++ src/tcdrain.c	Fri Dec  8 17:18:53 1995
@@ -9,8 +9,6 @@
 #include <mintbind.h>
 #include <termios.h>
 
-extern int __mint;
-
 int
 tcdrain(fd)
   int fd;
@@ -18,11 +16,6 @@
   long outq;
   long r;
 
-  if (__mint < 0x10a)
-  {
-    errno = -EINVAL;
-    return -1;
-  }
   do
   {
     r = Fcntl((short) fd, &outq, TIOCOUTQ);
diff -u src.orig/telldir.c src/telldir.c
--- src.orig/telldir.c	Fri Dec  8 17:19:18 1995
+++ src/telldir.c	Fri Dec  8 17:18:54 1995
@@ -11,8 +11,6 @@
 #include <dirent.h>
 #include "lib.h"
 
-extern int __mint;
-
 /* not POSIX */
 
 off_t
diff -u src.orig/thread.c src/thread.c
--- src.orig/thread.c	Fri Dec  8 17:19:18 1995
+++ src/thread.c	Fri Dec  8 17:18:54 1995
@@ -41,7 +41,6 @@
 })
 #endif /* __MBASE__ */
 
-extern int __mint;
 extern long _childtime;			/* in main.c */
 extern long _sigpending, _sigmask;	/* in signal.c */
 extern __Sigfunc _sig_handler[NSIG];	/* ditto */
@@ -109,9 +108,7 @@
 	b->p_bbase = (char *) mbasep();
 #endif /* __MBASE__ */
  
-	if (__mint)
-		pid = Pexec(104, 0L, b, 0L);
-	else {
+	if ((pid = Pexec(104, 0L, b, 0L)) == -EINVAL) {
 	/* save the signal masks and signal handlers, the child may change
            them */
 		savpending = _sigpending;
diff -u src.orig/times.c src/times.c
--- src.orig/times.c	Fri Dec  8 17:19:19 1995
+++ src/times.c	Fri Dec  8 17:18:54 1995
@@ -7,7 +7,6 @@
 #include <mintbind.h>
 #include <errno.h>
 
-extern int __mint;
 extern long _childtime;
 
 /* macro to convert milliseconds into CLK_TCKs */
@@ -21,8 +20,7 @@
 
 	real_time = _clock();
 
-	if (__mint) {
-		r = Prusage(usage);
+	if ((r = Prusage(usage)) != -EINVAL) {
 		if (r >= 0 && buffer) {
 			buffer->tms_cutime = CVRT(usage[3]);
 			buffer->tms_cstime = CVRT(usage[2]);
diff -u src.orig/truncate.c src/truncate.c
--- src.orig/truncate.c	Fri Dec  8 17:19:20 1995
+++ src/truncate.c	Fri Dec  8 17:18:54 1995
@@ -24,8 +24,6 @@
 #endif
 #include "lib.h"
 
-extern int __mint;
-
 int
 truncate (_filename, length)
      const char *_filename;
@@ -36,23 +34,23 @@
 
   (void) _unx2dos (_filename, filename, sizeof (filename));
   res = -EINVAL;
-  if (__mint > 92)
-    {
-      res = (int) Dcntl(FTRUNCATE, (long) filename, (long) &length);
-      if (res == 0)
+  
+  res = (int) Dcntl(FTRUNCATE, (long) filename, (long) &length);
+
+  if (res == 0)
 	return res;
-      if (res != -EINVAL)
-        {
-	  if (res < 0)
-	    {
-	      if ((res == -EPATH) && (_enoent(filename)))
-		res = -ENOENT;
-	      errno = (int) -res;
-	      return -1;
-	    }
-	  return 0;
-	}
-    }
+  if (res != -EINVAL)
+  {
+     if (res < 0)
+     {
+	if ((res == -EPATH) && (_enoent(filename)))
+	   res = -ENOENT;
+	errno = (int) -res;
+	return -1;
+     }
+     return 0;
+   }
+
   fh = (int)Fopen (filename, 2);
   if (fh < 0)
     {
@@ -61,9 +59,10 @@
       errno = -fh;
       return -1;
     }
-  if (__mint > 90)
-    res = (int) Fcntl (fh, (long) &length, FTRUNCATE);
+
+  res = (int) Fcntl (fh, (long) &length, FTRUNCATE);
   Fclose (fh);
+
   if (res == -EINVAL && length == 0)
     {
       res = (int)Fcreate (filename, 0);
@@ -85,12 +84,9 @@
 {
   int res;
 
-  if (__mint > 90)
-    res = (int) Fcntl (fd, (long) &length, FTRUNCATE);
-  else
-    res = -EINVAL;
+  res = (int) Fcntl (fd, (long) &length, FTRUNCATE);
 
-  if (res < 0)
+    if (res < 0)
     {
       errno = -res;
       return -1;
diff -u src.orig/utime.c src/utime.c
--- src.orig/utime.c	Fri Dec  8 17:19:21 1995
+++ src/utime.c	Fri Dec  8 17:18:55 1995
@@ -27,8 +27,6 @@
 #endif
 #include "lib.h"
 
-extern int __mint;
-
 time_t _dostime __PROTO((time_t t));
 
 /* convert a Unix time into a DOS time. The longword returned contains
@@ -55,6 +53,7 @@
       const struct utimbuf *tset;
 {
 	int fh;
+	long ret;
 	unsigned long actime, modtime;
 	unsigned long dtime;	/* dos time equivalent */
 	
@@ -80,12 +79,12 @@
 	settime.modtime = (unsigned short) ((modtime >> 16) & 0xFFFF);
 	settime.moddate = (unsigned short) (modtime & 0xFFFF);
 	res = -EINVAL;
-	if (__mint > 92) {
-		if (tset)
-			res = Dcntl(FUTIME, (long) filename, (long) &settime);
-		else
-			res = Dcntl(FUTIME, (long) filename, (long) 0);
-	}
+	
+	if (tset)
+		res = Dcntl(FUTIME, (long) filename, (long) &settime);
+	else
+		res = Dcntl(FUTIME, (long) filename, (long) 0);
+
 	if (res != -EINVAL) {
 		if (res < 0) {
 			if ((res == -EPATH) && (_enoent(filename)))
@@ -101,7 +100,7 @@
 		/* Kludge:  on dos filesystems return success for dirs
 		   even though we failed */
 		if ((fh == -ENOENT) &&
-		    (!__mint || Dpathconf(filename, 5) == 2) &&
+		    (((ret = Dpathconf(filename, 5)) == 2) || (ret == -EINVAL)) &&
 		    (Fattrib(filename, 0, 0) == FA_DIR))
 			return 0;
 #endif
@@ -111,12 +110,11 @@
 		return -1;
 	}
 
-	if (__mint > 90) {
-		if (tset)
-			res = Fcntl(fh, (long)&settime, FUTIME);
-		else
-			res = Fcntl(fh, (long)0, FUTIME);
-	}
+	if (tset)
+		res = Fcntl(fh, (long)&settime, FUTIME);
+	else
+		res = Fcntl(fh, (long)0, FUTIME);
+
 	if (res == -EINVAL)
 	      {
 		dtime = modtime;
diff -u src.orig/wait.c src/wait.c
--- src.orig/wait.c	Fri Dec  8 17:19:22 1995
+++ src/wait.c	Fri Dec  8 17:18:55 1995
@@ -17,24 +17,25 @@
 {
 	long r;
 	int exit_status, sig_term, pid;
-	extern int __mint;
+
 #ifdef _EXPERIMENTAL_WAIT_MACROS
 	int *status = _status.__wi;
 #else	
 	int *status = _status;
 #endif
 
-	if (__mint == 0) {	/* wait is faked by vfork() */
+	r = Pwaitpid(-1, 0, 0L);
+
+	if (r == -EINVAL) {
 		r = __waitval;
 		__waitval = -ENOENT;
 	}
-	else
-		r = Pwaitpid(-1, 0, 0L);
-
+	
 	if (r < 0) {
 		errno = (int) -r;
 		return -1;
 	}
+
 	pid = (int) ((r & 0xffff0000L) >> 16);
 	exit_status = (int) (r & 0x000000ffL);
 	sig_term = (int) ((r & 0x00007f00L) >> 8);
diff -u src.orig/wait3.c src/wait3.c
--- src.orig/wait3.c	Fri Dec  8 17:19:22 1995
+++ src/wait3.c	Fri Dec  8 17:18:55 1995
@@ -10,8 +10,6 @@
 #include <errno.h>
 #include <signal.h>
 
-extern int __mint;
-
 extern long __waitval;		/* in thread.c */
 extern long __waittime;		/* ditto */
 
@@ -29,17 +27,20 @@
 	long r, rsc[8];
 	int exit_status, sig_term, pid;
 
-	if (__mint == 0) {
+	r = Pwaitpid(-1, mode, rsc);
+
+	if (r == -EINVAL) {
 		r = __waitval;
 		__waitval = -ENOENT;
 		rsc[0] = __waittime;
 		rsc[1] = rsc[4] = 0;
-	} else
-		r = Pwaitpid(-1, mode, rsc);
+	}
+	
 	if (r < 0) {
 		errno = (int) -r;
 		return -1;
 	}
+
 	pid = (int) ((r & 0xffff0000L) >> 16);
 	if (pid) {
 	  if (status)
diff -u src.orig/wait4.c src/wait4.c
--- src.orig/wait4.c	Fri Dec  8 17:19:22 1995
+++ src/wait4.c	Fri Dec  8 17:18:55 1995
@@ -9,8 +9,6 @@
 #include <errno.h>
 #include <signal.h>
 
-extern int __mint;
-
 extern long __waitval;		/* in thread.c */
 extern long __waittime;		/* ditto */
 
@@ -29,15 +27,15 @@
   long r, rsc[8];
   int exit_status, sig_term;
 
-  if (__mint == 0)
-    {
+  r = Pwaitpid (pid, options, rsc);
+
+  if (r == -EINVAL) {
       r = __waitval;
       __waitval = -ENOENT;
       rsc[0] = __waittime;
       rsc[1] = rsc[4] = 0;
-    }
-  else
-    r = Pwaitpid (pid, options, rsc);
+  }
+
   if (r < 0)
     {
       errno = (int) -r;
diff -u src.orig/waitpid.c src/waitpid.c
--- src.orig/waitpid.c	Fri Dec  8 17:19:22 1995
+++ src/waitpid.c	Fri Dec  8 17:18:55 1995
@@ -9,8 +9,6 @@
 #include <errno.h>
 #include <signal.h>
 
-extern int __mint;
-
 extern long __waitval;		/* in thread.c */
 
 pid_t
@@ -29,11 +27,14 @@
 #endif	
 
 	statwait = (union wait *) status;
-	if (__mint == 0) {
+	
+	r = Pwaitpid(pid, options, 0L);
+
+	if (r == -EINVAL) {
 		r = __waitval;
 		__waitval = -ENOENT;
-	} else
-		r = Pwaitpid(pid, options, 0L);
+	}
+	
 	if (r < 0) {
 		errno = (int) -r;
 		return -1;