[adtools] [Patch] MSYS/MinGW Build Support

  • From: Trevor Scroggins <trevor.scroggins@xxxxxxxxx>
  • To: adtools@xxxxxxxxxxxxx
  • Date: Tue, 6 Jul 2010 15:50:02 -0700

All,

The adtools trunk (revision 356 for me) will not build under
MSYS/MinGW due to differences in printf() [1] and stat() [2] in
Windows' msvcrt.dll. The following patches resolve the issues and were
back-ported (an overstatement) from later versions of GCC.

I haven't validated the genmodes.c changes under AmigaOS, but assuming
clib2, newlib, et al provide a "standard" printf(), there should't be
any issues. Later versions of GCC include these changes.

Regards,

Trev

1. http://gcc.gnu.org/viewcvs?view=revision&revision=125494
2. http://gcc.gnu.org/viewcvs?view=revision&revision=125590

Index: gcc/gcc/genmodes.c
===================================================================
--- gcc/gcc/genmodes.c  (revision 356)
+++ gcc/gcc/genmodes.c  (working copy)
@@ -785,8 +785,7 @@
 /* Output routines.  */

 #define tagged_printf(FMT, ARG, TAG) do {              \
-  int count_;                                          \
-  printf ("  " FMT ",%n", ARG, &count_);               \
+  int count_ = printf ("  " FMT ",", ARG);             \
   printf ("%*s/* %s */\n", 27 - count_, "", TAG);      \
 } while (0)

@@ -820,8 +819,7 @@
   for (c = 0; c < MAX_MODE_CLASS; c++)
     for (m = modes[c]; m; m = m->next)
       {
-       int count_;
-       printf ("  %smode,%n", m->name, &count_);
+       int count_ = printf ("  %smode,", m->name);
        printf ("%*s/* %s:%d */\n", 27 - count_, "",
                 trim_filename (m->file), m->line);
       }
Index: gcc/libcpp/files.c
===================================================================
--- gcc/libcpp/files.c  (revision 356)
+++ gcc/libcpp/files.c  (working copy)
@@ -226,6 +226,22 @@
       close (file->fd);
       file->fd = -1;
     }
+#if defined(_WIN32) && !defined(__CYGWIN__)
+  else if (errno == EACCES)
+    {
+      /* On most UNIX systems, open succeeds on a directory.  Above,
+         we check if we have opened a directory and if so, set errno
+         to ENOENT.  However, on Windows, opening a directory
+         fails with EACCES.  We want to return ENOENT in that
+         case too.  */
+      if (stat (file->path, &file->st) == 0
+          && S_ISDIR (file->st.st_mode))
+        errno = ENOENT;
+      else
+       /* The call to stat may have reset errno.  */
+       errno = EACCES;
+    }
+#endif
   else if (errno == ENOTDIR)
     errno = ENOENT;
-- 
______________________________________________________________________________
Amiga Development tools ML - //www.freelists.org/list/adtools
Homepage...................: http://www.sourceforge.net/projects/adtools
Listserver help............: mailto:adtools-request@xxxxxxxxxxxxx?Subject=HELP

Other related posts: