bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 0/4] Cross compiling sharutils


From: Filipe Brandenburger
Subject: Re: [PATCH 0/4] Cross compiling sharutils
Date: Wed, 20 May 2015 21:05:18 -0700

Hi Bruce,

Just a short update that I'm working on an updated revision of this patch.

My current plan is along the O_BINARY lines, in fact I noticed there's
already code in lib/system.h to check for that and define
FOPEN_READ_BINARY and FOPEN_WRITE_BINARY, so I'm planning to just
reuse that:

http://git.savannah.gnu.org/cgit/sharutils.git/tree/lib/system.h#n102

#if ! defined(O_BINARY) || (O_BINARY == 0)
# define  FOPEN_READ_BINARY   "r"
# define  FOPEN_WRITE_BINARY  "w"
#else
# define  FOPEN_READ_BINARY   "rb"
# define  FOPEN_WRITE_BINARY  "wb"
#endif

I got my hands on a Windows instance and installed cygwin on it, so
I'm currently running cygwin tests to ensure there's no regression.

On Wed, May 20, 2015 at 8:51 PM, Bruce Korb <address@hidden> wrote:
> On 05/19/15 19:56, Eli Zaretskii wrote:
>> From: Eric Blake <address@hidden>:
>>> 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.

I'm not really sure that's relevant. I looked into a mingw build
(actually cross compiling from Linux) and it stumbled on things like
#include <pwd.h> among many others, so I'm not convinced that windows
other than cygwin actually builds...

Though yeah, I think it's pretty safe to assume they'll have O_BINARY
defined to != 0 so I'm expecting if they ever worked, they will keep
working.

> 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.

That's actually handled by gnulib in binary-io.h (I believe indirectly
through fcntl.h in that directory) which is what I believe Eric
suggested in the original thread from 5 years ago.

http://git.savannah.gnu.org/cgit/gnulib.git/tree/lib/fcntl.in.h#n319

I tested with that on glibc and O_BINARY ? "rb" : "r" works when
#include "binary-io.h" is in place.

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

Seems like the snippet I just pasted above which already exists in the code :-)

Later tonight, I should have an updated patch, tested on both cygwin and glibc.

Cheers,
Filipe



reply via email to

[Prev in Thread] Current Thread [Next in Thread]