Replace xmalloc/xfree with vector in jit.c
[deliverable/binutils-gdb.git] / libiberty / lrealpath.c
index 7f66dc2b1bd26c41821d409a95f93e216677923d..ac914a7a4f403b09c90416c8e1fa3c6b52c1b48a 100644 (file)
@@ -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
+}
This page took 0.024821 seconds and 4 git commands to generate.