Re: [PATCH 0/4] Cross compiling sharutils

Bruce Korb <[email protected]> Wed, 20 May 2015 20:51:16 -0700
Newsgroups gmane.comp.gnu.utils.bugs
Organization FSF
Message-ID <[email protected]>
On 05/19/15 19:56, Eli Zaretskii wrote:
>> Date: Tue, 19 May 2015 19:57:25 -0600
>> From: Eric Blake <[email protected]>
>> Cc: bug-gnu-utils <[email protected]>
>>
>> That is, the few platforms where O_BINARY is non-zero probably already
>> support "rb" as a mode for popen (are there any besides Cygwin and mingw?).
>
> DJGPP.

That answers the question, "Does popen support "rb" as an open mode?"
The other question is:  "Is O_BINARY non-zero on DJGPP, too?"  I would expect.

Actually, since we're also dealing with glibc, which is perfect in every way
and has no need of facilitating cross platform development, O_BINARY
is not defined:

> $ cc -o tmp tmp.c
> tmp.c: In function 'main':
> tmp.c:7:54: error: 'O_BINARY' undeclared (first use in this function)
>      printf("O_BINARY has the value %1$u (0x%1$X)\n", O_BINARY);

so it is actually necessary to add kludges for a platform that doesn't define it.

> #if defined(O_BINARY) && (O_BINARY != 0)
> # define READ_BINARY_MODE  "rb"
> #else
> # define READ_BINARY_MODE "r"
> #endif

It seems one or two other projects have stubbed their toes, too:

$ grep -w O_BINARY $list
/usr/include/mysql/my_global.h:#ifndef O_BINARY
/usr/include/mysql/my_global.h:#define O_BINARY 0       /* Flag to my_open for binary files */
/usr/include/mysql/my_global.h:#define FILE_BINARY      O_BINARY /* Flag to my_fopen for binary streams */
/usr/include/X11/Xw32defs.h:#  define O_BINARY    _O_BINARY
/usr/include/ImageMagick-6/magick/studio.h:#if !defined(O_BINARY)
/usr/include/ImageMagick-6/magick/studio.h:#define O_BINARY  0x00
/usr/include/kde_file.h:#ifndef O_BINARY
/usr/include/kde_file.h:#define O_BINARY 0 /* for open() */
/usr/include/jasper/jas_stream.h:#ifndef O_BINARY
/usr/include/jasper/jas_stream.h:#define O_BINARY       0