aboutsummaryrefslogtreecommitdiff
path: root/libgfortran/io/unix.c
diff options
context:
space:
mode:
authorAaron W. LaFramboise <aaronavay62@aaronwl.com>2004-10-30 10:23:23 -0600
committerPaul Brook <pbrook@gcc.gnu.org>2004-10-30 16:23:23 +0000
commit41724e6a1387d9135026dae1a25f912d6f6d8372 (patch)
tree24b152304828e4f1535ef2adecf1093feef88872 /libgfortran/io/unix.c
parent47289a4e33c86f8462ed2143259a045b594e6e4f (diff)
downloadgcc-41724e6a1387d9135026dae1a25f912d6f6d8372.zip
gcc-41724e6a1387d9135026dae1a25f912d6f6d8372.tar.gz
gcc-41724e6a1387d9135026dae1a25f912d6f6d8372.tar.bz2
config.h.in: Regenerate.
2004-10-30 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. From-SVN: r89893
Diffstat (limited to 'libgfortran/io/unix.c')
-rw-r--r--libgfortran/io/unix.c37
1 files changed, 34 insertions, 3 deletions
diff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c
index 03dc66f..45d8cfd 100644
--- a/libgfortran/io/unix.c
+++ b/libgfortran/io/unix.c
@@ -54,6 +54,24 @@ Boston, MA 02111-1307, USA. */
#define PROT_WRITE 2
#endif
+/* These flags aren't defined on all targets (mingw32), so provide them
+ here. */
+#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",
@@ -921,8 +939,8 @@ unpack_filename (char *cstring, const char *fstring, int len)
/* 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
+ * 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
@@ -940,10 +958,23 @@ tempfile (void)
template = get_mem (strlen (tempdir) + 20);
- st_sprintf (template, "%s/gfortantmpXXXXXX", tempdir);
+ 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