This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix file descriptor existence of MinGW.


On Wed, Aug 07, 2019 at 10:45:08AM +0200, Martin Liška wrote:
> @@ -155,3 +156,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
> +fd_exists (int fd)
> +{
> +#if defined(_WIN32)
> +  HANDLE h = (HANDLE) _get_osfhandle (fd);
> +  return h != (HANDLE) -1;
> +#else
> +  return fcntl (fd, F_GETFD) >= 0;
> +#endif
> +}

Judging from gnulib
http://erislabs.net/gitweb/?p=gnulib.git;a=commitdiff_plain;h=021c8619190757f535c72ad5cdb1d624e19620d6
the #if condition for Windows should be probably different
and it would be worth to have a fallback for when F_GETFD isn't defined
e.g. through dup2 (fd, fd) < 0.

And for the libiberty changes you want Ian to review them.

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]