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: Disabling top level fixincludes


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


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