summaryrefslogtreecommitdiff
path: root/libgfortran
diff options
context:
space:
mode:
authorpbrook <pbrook@138bc75d-0d04-0410-961f-82ee72b054a4>2004-10-30 16:23:23 +0000
committerpbrook <pbrook@138bc75d-0d04-0410-961f-82ee72b054a4>2004-10-30 16:23:23 +0000
commit7dfba97b8cb0044be9a61a60466a312425a3ea01 (patch)
tree24b152304828e4f1535ef2adecf1093feef88872 /libgfortran
parent91e6f54a8b4fc8646c729e5d1f44cd6037dc78f5 (diff)
downloadgcc-7dfba97b8cb0044be9a61a60466a312425a3ea01.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@89893 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran')
-rw-r--r--libgfortran/ChangeLog11
-rw-r--r--libgfortran/config.h.in5
-rwxr-xr-xlibgfortran/configure3
-rw-r--r--libgfortran/configure.ac2
-rw-r--r--libgfortran/io/unix.c37
5 files changed, 52 insertions, 6 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index 559840af639..d584434ff9f 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,5 +1,16 @@
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.
+
+2004-10-30 Aaron W. LaFramboise <aaronavay62@aaronwl.com>
+
* intrinsics/system.c ("libgfortran.h"): Move after system headers.
2004-10-30 Canqun Yang <canqun@nudt.edu.cn>
diff --git a/libgfortran/config.h.in b/libgfortran/config.h.in
index a40e297f060..ecb9a6c896f 100644
--- a/libgfortran/config.h.in
+++ b/libgfortran/config.h.in
@@ -105,6 +105,9 @@
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
+/* Define to 1 if you have the `mkstemp' function. */
+#undef HAVE_MKSTEMP
+
/* Define to 1 if you have a working `mmap' system call. */
#undef HAVE_MMAP
@@ -115,7 +118,7 @@
#undef HAVE_NEXTAFTERF
/* libm includes powf */
-# undef HAVE_POWF
+#undef HAVE_POWF
/* libm includes round */
#undef HAVE_ROUND
diff --git a/libgfortran/configure b/libgfortran/configure
index 4e5900cbcc6..c13ccdcf625 100755
--- a/libgfortran/configure
+++ b/libgfortran/configure
@@ -6753,7 +6753,8 @@ fi
# Check for library functions.
-for ac_func in getrusage times
+
+for ac_func in getrusage times mkstemp
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_func" >&5
diff --git a/libgfortran/configure.ac b/libgfortran/configure.ac
index f7a8b99c89f..598070d1ec3 100644
--- a/libgfortran/configure.ac
+++ b/libgfortran/configure.ac
@@ -159,7 +159,7 @@ AC_CHECK_HEADER([complex.h],[AC_DEFINE([HAVE_COMPLEX_H], [1], [complex.h exists]
AC_CHECK_LIB([m],[csin],[need_math="no"],[need_math="yes"])
# Check for library functions.
-AC_CHECK_FUNCS(getrusage times)
+AC_CHECK_FUNCS(getrusage times mkstemp)
# Check libc for getgid, getpid, getuid
AC_CHECK_LIB([c],[getgid],[AC_DEFINE([HAVE_GETGID],[1],[libc includes getgid])])
diff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c
index 03dc66f58d0..45d8cfd633f 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