delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2015/05/16/05:26:45

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)" <djgpp AT delorie DOT com>
Subject: Re: dlopen.c OPENFLAGS
In-reply-to: <CAA2C=vARRSgaB0wcN2ya0CAa++KCD5JC9d9GPawQsT6h33QNJg@mail.gmail.com>
X-012-Sender: halo1 AT inter DOT net DOT il
To: djgpp AT delorie DOT com
Message-id: <83zj54g9fb.fsf@gnu.org>
References: <CAA2C=vARRSgaB0wcN2ya0CAa++KCD5JC9d9GPawQsT6h33QNJg AT mail DOT gmail DOT com>
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

> Date: Sat, 16 May 2015 12:12:14 +0300
> From: "Ozkan Sezer (sezeroz AT gmail DOT com)" <djgpp AT delorie 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 <io.h>
>  #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.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019