This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Final libgfortran mingw32 bootstrap fixes
- From: "Aaron W. LaFramboise" <aaronavay62 at aaronwl dot com>
- To: gcc-patches at gcc dot gnu dot org, fortran at gcc dot gnu dot org
- Date: Thu, 14 Oct 2004 04:33:19 -0500
- Subject: Final libgfortran mingw32 bootstrap fixes
This is the last of the changes that need to be made to allow
libgfortran to successfully bootstrap on Windows. There are still some
other important things that need to be fixed, though, according to the
regression test results.
This patch fixes two things. First, the S_IRGRP, S_IWGRP, S_IROTH, and
S_IWOTH macros are not defined on MinGW, so this patch defines them if
they are not defined already.
Secondly, MinGW doesn't have mkstemp(), but it does have mktemp(), which
is used together with open() to synthesize the correct functionality.
There might be a security issue here, but I'm fairly confident this is
the right way to do this, as its consistant with a usual mkstemp()
implementation. I also fixed two typos: the comment had a typo and was
inaccurate, and the temp file name misspelled "fortran."
Tested by bootstrapping on i686-pc-mingw32.
Aaron W. LaFramboise
2004-10-14 Aaron W. LaFramboise <aaronavay62@aaronwl.com>
* config.h.in: Regenerate.
* configure: Regenerate.
* configure.ac (AC_CHECK_FUNCS): Add mkstemp.
* io/unix.c (S_IRGRP): Define if undefined.
(S_IWGRP): Same.
(S_IROTH): Same.
(S_IWOTH): Same.
(tempfile): Use mktemp if mkstemp missing, fix typos.
Index: gcc/libgfortran/io/unix.c
===================================================================
RCS file: /cvsroot/gcc/gcc/libgfortran/io/unix.c,v
retrieving revision 1.11
diff -c -3 -p -r1.11 unix.c
*** gcc/libgfortran/io/unix.c 7 Oct 2004 21:30:50 -0000 1.11
--- gcc/libgfortran/io/unix.c 14 Oct 2004 08:51:57 -0000
*************** Boston, MA 02111-1307, USA. */
*** 53,58 ****
--- 54,75 ----
#define PROT_WRITE 2
#endif
+ #ifndef S_IRGRP
+ #define S_IRGRP 0
+ #endif
+
+ #ifndef S_IWGRP
+ #define S_IWGRP 0
+ #endif
+
+ #ifndef S_IROTH
+ #define S_IROTH 0
+ #endif
+
+ #ifndef S_IWOTH
+ #define S_IWOTH 0
+ #endif
+
/* This implementation of stream I/O is based on the paper:
*
* "Exploiting the advantages of mapped files for stream I/O",
*************** unpack_filename (char *cstring, const ch
*** 920,927 ****
/* tempfile()-- Generate a temporary filename for a scratch file and
* open it. mkstemp() opens the file for reading and writing, but the
* library mode prevents anything that is not allowed. The descriptor
! * is returns, which is less than zero on error. The template is
! * pointed to by ioparm.file, which is copied into the unit structure
* and freed later. */
static int
--- 937,944 ----
/* tempfile()-- Generate a temporary filename for a scratch file and
* open it. mkstemp() opens the file for reading and writing, but the
* library mode prevents anything that is not allowed. The descriptor
! * is returned, which is -1 on error. The template is pointed to by
! * ioparm.file, which is copied into the unit structure
* and freed later. */
static int
*************** tempfile (void)
*** 939,948 ****
template = get_mem (strlen (tempdir) + 20);
! st_sprintf (template, "%s/gfortantmpXXXXXX", tempdir);
fd = mkstemp (template);
if (fd < 0)
free_mem (template);
else
--- 956,978 ----
template = get_mem (strlen (tempdir) + 20);
! st_sprintf (template, "%s/gfortrantmpXXXXXX", tempdir);
!
! #ifdef HAVE_MKSTEMP
fd = mkstemp (template);
+ #else /* HAVE_MKSTEMP */
+
+ if (mktemp (template))
+ do
+ fd = open (template, O_CREAT | O_EXCL, S_IREAD | S_IWRITE);
+ while (!(fd == -1 && errno == EEXIST) && mktemp (template));
+ else
+ fd = -1;
+
+ #endif /* HAVE_MKSTEMP */
+
if (fd < 0)
free_mem (template);
else