This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Disabling top level fixincludes
- From: Zack Weinberg <zack at codesourcery dot com>
- To: bkorb at veritas dot com
- Cc: GCC-patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 12 Oct 2004 16:01:52 -0700
- Subject: Re: Disabling top level fixincludes
- References: <416C4366.DA4A6C3E@veritas.com>
Bruce Korb <bkorb@veritas.com> writes:
...
> and then simply replace all:
>
> fcntl (stdout_pair.write_fd, F_DUPFD, STDOUT_FILENO);
>
> type invocations with:
>
> dup2 (stdout_pair.write_fd, STDOUT_FILENO);
>
> because the latter should always work. Better still, macro-ize
> the silly thing:
>
> #define DUP_FD( _ofd, _nfd ) \
> dup2 ( (_ofd), (_nfd) )
>
> and if some platform needs the fcntl, another #define gets added
> and the code remains unchanged.
Even better, leave the dup2 in the code alone, and - only if someone
complains - put
#if !defined HAVE_DUP2 && defined HAVE_FCNTL_DUPFD
#define dup2(ofd, nfd) fcntl(ofd, F_DUPFD, nfd)
#endif
in an appropriate header, plus appropriate configure goo. (This is
preferable to DUP_FD because people already know what dup2() does,
whereas for DUP_FD we have to go look up the macro definition.)
zw