aboutsummaryrefslogtreecommitdiff
path: root/libiberty/lrealpath.c
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2019-08-08 09:50:28 +0200
committerMartin Liska <marxin@gcc.gnu.org>2019-08-08 07:50:28 +0000
commit0fddb1847019ceb570c6e0aea0ea779f1f9988cf (patch)
tree8b7110505306ba08d399f18bc2af2f9037284603 /libiberty/lrealpath.c
parentfe8e21fd730f01815bf6533289d2b3e33033a250 (diff)
downloadgcc-0fddb1847019ceb570c6e0aea0ea779f1f9988cf.zip
gcc-0fddb1847019ceb570c6e0aea0ea779f1f9988cf.tar.gz
gcc-0fddb1847019ceb570c6e0aea0ea779f1f9988cf.tar.bz2
Fix file descriptor existence of MinGW.
2019-08-08 Martin Liska <mliska@suse.cz> PR bootstrap/91352 * gcc.c (driver::detect_jobserver): Use is_valid_fd. * lto-wrapper.c (jobserver_active_p): Likewise. 2019-08-08 Martin Liska <mliska@suse.cz> PR bootstrap/91352 * libiberty.h (is_valid_fd): New function. 2019-08-08 Martin Liska <mliska@suse.cz> PR bootstrap/91352 * lrealpath.c (is_valid_fd): New function. From-SVN: r274208
Diffstat (limited to 'libiberty/lrealpath.c')
-rw-r--r--libiberty/lrealpath.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/libiberty/lrealpath.c b/libiberty/lrealpath.c
index 7f66dc2..ac914a7 100644
--- a/libiberty/lrealpath.c
+++ b/libiberty/lrealpath.c
@@ -49,6 +49,9 @@ components will be simplified. The returned value will be allocated using
#ifdef HAVE_STRING_H
#include <string.h>
#endif
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
/* On GNU libc systems the declaration is only visible with _GNU_SOURCE. */
#if defined(HAVE_CANONICALIZE_FILE_NAME) \
@@ -155,3 +158,16 @@ lrealpath (const char *filename)
/* This system is a lost cause, just duplicate the filename. */
return strdup (filename);
}
+
+/* Return true when FD file descriptor exists. */
+
+int
+is_valid_fd (int fd)
+{
+#if defined(_WIN32)
+ HANDLE h = (HANDLE) _get_osfhandle (fd);
+ return h != (HANDLE) -1;
+#else
+ return fcntl (fd, F_GETFD) >= 0;
+#endif
+}