X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f X-Recipient: djgpp AT delorie DOT com Date: Sat, 16 May 2015 12:26:32 +0300 From: "Eli Zaretskii (eliz AT gnu DOT org)" Subject: Re: dlopen.c OPENFLAGS In-reply-to: X-012-Sender: halo1 AT inter DOT net DOT il To: djgpp AT delorie DOT com Message-id: <83zj54g9fb.fsf@gnu.org> References: Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk > Date: Sat, 16 May 2015 12:12:14 +0300 > From: "Ozkan Sezer (sezeroz AT gmail DOT com)" > > Is the OPENFLAGS really correct in dlopen.c? I mean, is it not > supposed to be like the opposite, like: > > Index: src/libc/dxe/dlopen.c > =================================================================== > RCS file: /cvs/djgpp/djgpp/src/libc/dxe/dlopen.c,v > retrieving revision 1.4 > diff -U 6 -r1.4 dlopen.c > --- src/libc/dxe/dlopen.c 16 May 2015 05:39:20 -0000 1.4 > +++ src/libc/dxe/dlopen.c 16 May 2015 09:05:40 -0000 > @@ -18,21 +18,21 @@ > #ifdef __DJGPP__ > #include > #define ACCESS(f) (_chmod(f, 0) != -1) > #define OPEN _open > #define READ _read > #define CLOSE _close > -#define OPENFLAGS O_RDONLY > +#define OPENFLAGS O_RDONLY | O_BINARY No, it should be O_RDONLY, because we call '_open', not 'open', which interprets its 2nd argument as read/write access mode, and always opens the file in binary mode. If you add O_BINARY, the argument will be 4, which will be interpreted by _open to mean something about sharing, which is not what we want. I do agree that this trick is worth a comment that explains the above.