/usr/local/bin/diff -EBbu ./configure.orig ./configure
--- ./configure.orig	2011-03-12 03:50:18.000000000 -0600
+++ ./configure	2012-06-26 06:49:17.000000000 -0500
@@ -26352,7 +26352,7 @@
 else
 
         dirfd_save_CFLAGS=$CFLAGS
-        for ac_expr in d_fd dd_fd; do
+        for ac_expr in d_fd dd_fd dd1; do
 
           CFLAGS="$CFLAGS -DDIR_FD_MEMBER_NAME=$ac_expr"
           cat >conftest.$ac_ext <<_ACEOF
/usr/local/bin/diff -EBbu ./gnu/argp-help.c.orig ./gnu/argp-help.c
--- ./gnu/argp-help.c.orig	2011-03-12 03:14:26.000000000 -0600
+++ ./gnu/argp-help.c	2011-06-16 02:01:23.000000000 -0500
@@ -52,6 +52,8 @@
 #include "argp-fmtstream.h"
 #include "argp-namefrob.h"
 
+# include <strings.h> /* for strcasecmp(), needed in C99 mode */

 #ifndef SIZE_MAX
 # define SIZE_MAX ((size_t) -1)
 #endif
/usr/local/bin/diff -EBbu ./gnu/dirfd.c.orig ./gnu/dirfd.c
--- ./gnu/dirfd.c.orig	2011-03-12 03:14:28.000000000 -0600
+++ ./gnu/dirfd.c	2012-06-25 02:55:09.000000000 -0500
@@ -24,11 +24,18 @@
 #include <dirent.h>
 #include <errno.h>
 
+#ifdef __TANDEM
+# include <unistd.h> /* for _gl_fnum2dt(), needed in C99 mode */
+#endif
+
 int
 dirfd (DIR *dir_p)
 {
   int fd = DIR_TO_FD (dir_p);
   if (fd == -1)
     errno = ENOTSUP;
+#ifdef __TANDEM
+  fd = _gl_fnum2fd(fd);
+#endif
   return fd;
 }
/usr/local/bin/diff -EBbu ./gnu/fchdir.c.orig ./gnu/fchdir.c
--- ./gnu/fchdir.c.orig	2011-03-12 03:14:28.000000000 -0600
+++ ./gnu/fchdir.c	2012-06-26 09:18:07.000000000 -0500
@@ -44,6 +44,13 @@
 # endif
 #endif
 
+#ifdef __TANDEM
+# define BOOL_NOFNUM 'n'
+# define BOOL_FNUM   'y'
+# define NOFNUM      -1
+# define NOFD        -1
+#endif
+
 /* This replacement assumes that a directory is not renamed while opened
    through a file descriptor.
 
@@ -57,10 +64,17 @@
 typedef struct
 {
   char *name;       /* Absolute name of the directory, or NULL.  */
+#ifdef __TANDEM
+  char fnum;        /* 'y' or 'n', actually a bool */
+#endif
   /* FIXME - add a DIR* member to make dirfd possible on mingw?  */
 } dir_info_t;
 static dir_info_t *dirs;
 static size_t dirs_allocated;
+#ifdef __TANDEM
+static int *fnum2fdmap;
+static size_t fds_allocated;
+#endif
 
 /* Try to ensure dirs has enough room for a slot at index fd; free any
    contents already in that slot.  Return false and set errno to
@@ -89,8 +103,40 @@
       dirs = new_dirs;
       dirs_allocated = new_allocated;
     }
+#ifdef __TANDEM
+  dirs[fd].fnum = BOOL_NOFNUM;
+#endif
+  return true;
+}
+
+#ifdef __TANDEM
+static bool
+ensure_fd_slot (short fnum)
+{
+  if (fnum < fds_allocated)
+     fnum2fdmap[fnum] = NOFD;
+  else
+  {
+      size_t new_allocated;
+      int *new;
+
+      new_allocated = 2 * fds_allocated + 1;
+      if (new_allocated <= fnum)
+        new_allocated = fnum + 1;
+      new =
+        (fnum2fdmap != NULL
+         ? realloc (fnum2fdmap, new_allocated * sizeof *new)
+         : malloc (new_allocated * sizeof *new));
+      if (new == NULL)
+        return false;
+      memset (new + fds_allocated, NOFD,
+              (new_allocated - fds_allocated) * sizeof *new);
+      fnum2fdmap = new;
+      fds_allocated = new_allocated;
+  }  
   return true;
 }
+#endif
 
 /* Return the canonical name of DIR in malloc'd storage.  */
 static char *
@@ -137,6 +184,9 @@
     {
       free (dirs[fd].name);
       dirs[fd].name = NULL;
+#ifdef __TANDEM
+      dirs[fd].fnum = BOOL_NOFNUM;
+#endif
     }
 }
 
@@ -152,7 +202,11 @@
 
   assert (0 <= fd);
   if (REPLACE_OPEN_DIRECTORY
+#ifdef __TANDEM
+      || (stat (filename, &statbuf) == 0 && S_ISDIR (statbuf.st_mode)))
+#else
       || (fstat (fd, &statbuf) == 0 && S_ISDIR (statbuf.st_mode)))
+#endif
     {
       if (!ensure_dirs_slot (fd)
           || (dirs[fd].name = get_name (filename)) == NULL)
@@ -162,6 +216,9 @@
           errno = saved_errno;
           return -1;
         }
+#ifdef __TANDEM
+      dirs[fd].fnum = BOOL_NOFNUM;
+#endif
     }
   return fd;
 }
@@ -186,12 +243,18 @@
           errno = saved_errno;
           newfd = -1;
         }
+#ifdef __TANDEM
+      dirs[newfd].fnum = BOOL_NOFNUM;
+#endif
     }
   else if (newfd < dirs_allocated)
     {
       /* Duplicated a non-directory; ensure newfd is cleared.  */
       free (dirs[newfd].name);
       dirs[newfd].name = NULL;
+#ifdef __TANDEM
+      dirs[newfd].fnum = BOOL_NOFNUM;
+#endif
     }
   return newfd;
 }
@@ -215,7 +278,7 @@
   return NULL;
 }
 
-#if REPLACE_OPEN_DIRECTORY
+#if __TANDEM || REPLACE_OPEN_DIRECTORY
 /* Return stat information about FD in STATBUF.  Needed when
    rpl_open() used a dummy file to work around an open() that can't
    normally visit directories.  */
@@ -237,10 +300,20 @@
 #undef closedir
 {
   int fd = dirfd (dp);
+#ifdef __TANDEM
+  short fnum = DIR_TO_FD(dp);
+#endif
   int retval = closedir (dp);
 
   if (retval >= 0)
+#ifdef __TANDEM
+  {
+    close (fd);
+    _gl_unregister_fnum (fnum);
+  }
+#else
     _gl_unregister_fd (fd);
+#endif
   return retval;
 }
 
@@ -253,11 +326,28 @@
   dp = opendir (filename);
   if (dp != NULL)
     {
+#ifdef __TANDEM
+      /* On NonStop a opendir will not associate a fd with a open directory
+       * So open the same directory using open(2) & get a valid fd.
+       */ 
+      int fd = open(filename, O_RDONLY);
+      if (fd < 0)
+        {
+          /* Clean up to before exit */
+          closedir(dp);
+          return NULL;
+      }
+      if (0 <= fd && _gl_register_fnum (fd, DIR_TO_FD (dp)) != DIR_TO_FD(dp))
+#else
       int fd = dirfd (dp);
       if (0 <= fd && _gl_register_fd (fd, filename) != fd)
+#endif
         {
           int saved_errno = errno;
           closedir (dp);
+#ifdef __TANDEM
+          close(fd);
+#endif
           errno = saved_errno;
           return NULL;
         }
@@ -278,6 +368,35 @@
   return newfd;
 }
 
+#ifdef __TANDEM
+short _gl_register_fnum (int fd, short fnum)
+{
+  if (!ensure_fd_slot (fnum))
+    {
+      int saved_errno = errno;
+      close (fd);
+      errno = saved_errno;
+      return -1;
+    }
+  fnum2fdmap[fnum] = fd;
+  dirs[fd].fnum = BOOL_FNUM;
+  return fnum;
+}
+ 
+void _gl_unregister_fnum(short fnum)
+{
+  if (fnum >= 0 && fnum < fds_allocated)
+    fnum2fdmap[fnum] = NOFD;
+}
+
+int _gl_fnum2fd (int fnum_or_fd)
+{
+  int ret;
+  (dirs[fnum_or_fd].fnum == BOOL_NOFNUM)? (ret = fnum_or_fd) : (ret = fnum2fdmap[fnum_or_fd]);
+  return ret;
+}
+#endif
+
 
 /* Implement fchdir() in terms of chdir().  */
 
/usr/local/bin/diff -EBbu ./gnu/open.c.orig ./gnu/open.c
--- ./gnu/open.c.orig	2011-03-12 03:14:31.000000000 -0600
+++ ./gnu/open.c	2012-06-26 08:25:35.000000000 -0500
@@ -104,6 +104,14 @@
 #endif
 
   fd = orig_open (filename, flags, mode);
+#ifdef __TANDEM
+	/* On NonStop open(2) can open an OSS directory, but not /G & /E
+	 * directory, hence we do a dummy open here and override fstat() in 
+	 * fchdir.c to hide the fact that we have a dummy.
+	 */ 
+  if (fd < 0 && errno == EISDIR)
+     fd = open ("/dev/null", flags, mode);
+#endif
 
 #if REPLACE_FCHDIR
   /* Implementing fchdir and fdopendir requires the ability to open a
/usr/local/bin/diff -EBbu ./gnu/regex.c.orig ./gnu/regex.c
--- ./gnu/regex.c.orig	2011-03-12 03:14:32.000000000 -0600
+++ ./gnu/regex.c	2011-06-17 04:07:16.000000000 -0500
@@ -26,6 +26,8 @@
 # error "This is C code, use a C compiler"
 #endif
 
+#include <strings.h> /* for strcasecmp(), needed in C99 mode */
+
 #ifdef _LIBC
 /* We have to keep the namespace clean.  */
 # define regfree(preg) __regfree (preg)
/usr/local/bin/diff -EBbu ./gnu/unistd.in.h.orig ./gnu/unistd.in.h
--- ./gnu/unistd.in.h.orig	2011-03-12 03:14:34.000000000 -0600
+++ ./gnu/unistd.in.h	2012-06-26 09:19:21.000000000 -0500
@@ -438,6 +438,13 @@
 _GL_EXTERN_C void _gl_unregister_fd (int fd);
 _GL_EXTERN_C int _gl_register_dup (int oldfd, int newfd);
 _GL_EXTERN_C const char *_gl_directory_name (int fd);
+#ifdef __TANDEM
+_GL_EXTERN_C short _gl_register_fnum (int fd, short fnum)
+     _GL_ARG_NONNULL ((2));
+_GL_EXTERN_C int _gl_fnum2fd (int fnum_or_fd)
+     _GL_ARG_NONNULL ((1));
+_GL_EXTERN_C void _gl_unregister_fnum(short fnum);
+#endif
 
 # else
 #  if !@HAVE_DECL_FCHDIR@
/usr/local/bin/diff -EBbu ./gnu/unlinkdir.c.orig ./gnu/unlinkdir.c
--- ./gnu/unlinkdir.c.orig	2011-03-12 03:14:34.000000000 -0600
+++ ./gnu/unlinkdir.c	2012-06-26 08:46:41.000000000 -0500
@@ -45,8 +45,12 @@
       cannot = (priv_set_ismember (PRIV_SYS_LINKDIR) == 0);
 # else
       /* In traditional Unix, only root can unlink directories.  */
+#  ifdef __TANDEM /* super user's UID is 65535 here */
+      cannot = (geteuid () != 65535);
+#  else
       cannot = (geteuid () != 0);
+#  endif
 # endif
       initialized = true;
     }
/usr/local/bin/diff -EBbu ./src/extract.c.orig ./src/extract.c
--- ./src/extract.c.orig	2010-11-27 04:33:22.000000000 -0600
+++ ./src/extract.c	2011-06-16 01:55:46.000000000 -0500
@@ -150,7 +150,11 @@
 void
 extr_init (void)
 {
+#ifdef __TANDEM
+  we_are_root = geteuid () == 65535;
+#else
   we_are_root = geteuid () == 0;
+#endif
   same_permissions_option += we_are_root;
   same_owner_option += we_are_root;
 
/usr/local/bin/diff -EBbu ./tests/genfile.c.orig ./tests/genfile.c
--- ./tests/genfile.c.orig	2010-10-24 13:06:45.000000000 -0500
+++ ./tests/genfile.c	2011-06-16 01:55:46.000000000 -0500
@@ -610,9 +610,17 @@
       else if (strcmp (p, "size") == 0)
 	printf ("%s", umaxtostr (st.st_size, buf));
       else if (strcmp (p, "blksize") == 0)
+#ifdef __TANDEM
+	printf ("*****Nothing to print on NonStop for st_blksize****\n");
+#else
 	printf ("%s", umaxtostr (st.st_blksize, buf));
+#endif
       else if (strcmp (p, "blocks") == 0)
+#ifdef __TANDEM
+	printf ("*****Nothing to print on NonStop for st_blocks****\n");
+#else
 	printf ("%s", umaxtostr (st.st_blocks, buf));
+#endif
       else if (strcmp (p, "atime") == 0)
 	printf ("%lu", (unsigned long) st.st_atime);
       else if (strcmp (p, "atimeH") == 0)
