Cygwin: drop macro and code for CYGWIN_VERSION_CHECK_FOR_OLD_O_NONBLOCK
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
parent
7de1be0472
commit
c2743614bf
|
@ -1360,17 +1360,12 @@ int fhandler_base::fcntl (int cmd, intptr_t arg)
|
|||
break;
|
||||
case F_SETFL:
|
||||
{
|
||||
/* Only O_APPEND, O_ASYNC and O_NONBLOCK/O_NDELAY are allowed.
|
||||
/* Only O_APPEND, O_ASYNC and O_NONBLOCK are allowed.
|
||||
Each other flag will be ignored.
|
||||
Since O_ASYNC isn't defined in fcntl.h it's currently
|
||||
ignored as well. */
|
||||
const int allowed_flags = O_APPEND | O_NONBLOCK_MASK;
|
||||
const int allowed_flags = O_APPEND | O_NONBLOCK;
|
||||
int new_flags = arg & allowed_flags;
|
||||
/* Carefully test for the O_NONBLOCK or deprecated OLD_O_NDELAY flag.
|
||||
Set only the flag that has been passed in. If both are set, just
|
||||
record O_NONBLOCK. */
|
||||
if ((new_flags & OLD_O_NDELAY) && (new_flags & O_NONBLOCK))
|
||||
new_flags &= ~OLD_O_NDELAY;
|
||||
set_flags ((get_flags () & ~allowed_flags) | new_flags);
|
||||
}
|
||||
res = 0;
|
||||
|
@ -1573,15 +1568,15 @@ fhandler_base::fixup_after_exec ()
|
|||
bool
|
||||
fhandler_base::is_nonblocking ()
|
||||
{
|
||||
return (openflags & O_NONBLOCK_MASK) != 0;
|
||||
return (openflags & O_NONBLOCK) != 0;
|
||||
}
|
||||
|
||||
void
|
||||
fhandler_base::set_nonblocking (int yes)
|
||||
{
|
||||
int current = openflags & O_NONBLOCK_MASK;
|
||||
int current = openflags & O_NONBLOCK;
|
||||
int new_flags = yes ? (!current ? O_NONBLOCK : current) : 0;
|
||||
openflags = (openflags & ~O_NONBLOCK_MASK) | new_flags;
|
||||
openflags = (openflags & ~O_NONBLOCK) | new_flags;
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -15,15 +15,6 @@ details. */
|
|||
#include <cygwin/_ucred.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
/* newlib used to define O_NDELAY differently from O_NONBLOCK. Now it
|
||||
properly defines both to be the same. Unfortunately, we have to
|
||||
behave properly the old version, too, to accommodate older executables. */
|
||||
#define OLD_O_NDELAY (CYGWIN_VERSION_CHECK_FOR_OLD_O_NONBLOCK ? 4 : 0)
|
||||
|
||||
/* Care for the old O_NDELAY flag. If one of the flags is set,
|
||||
both flags are set. */
|
||||
#define O_NONBLOCK_MASK (O_NONBLOCK | OLD_O_NDELAY)
|
||||
|
||||
/* It appears that 64K is the block size used for buffered I/O on NT.
|
||||
Using this blocksize in read/write calls in the application results
|
||||
in a much better performance than using smaller values. */
|
||||
|
|
|
@ -246,17 +246,12 @@ fhandler_socket::fcntl (int cmd, intptr_t arg)
|
|||
{
|
||||
case F_SETFL:
|
||||
{
|
||||
/* Carefully test for the O_NONBLOCK or deprecated OLD_O_NDELAY flag.
|
||||
Set only the flag that has been passed in. If both are set, just
|
||||
record O_NONBLOCK. */
|
||||
int new_flags = arg & O_NONBLOCK_MASK;
|
||||
if ((new_flags & OLD_O_NDELAY) && (new_flags & O_NONBLOCK))
|
||||
new_flags = O_NONBLOCK;
|
||||
current = get_flags () & O_NONBLOCK_MASK;
|
||||
int new_flags = arg & O_NONBLOCK;
|
||||
current = get_flags () & O_NONBLOCK;
|
||||
request = new_flags ? 1 : 0;
|
||||
if (!!current != !!new_flags && (res = ioctl (FIONBIO, &request)))
|
||||
break;
|
||||
set_flags ((get_flags () & ~O_NONBLOCK_MASK) | new_flags);
|
||||
set_flags ((get_flags () & ~O_NONBLOCK) | new_flags);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -2289,10 +2289,8 @@ fhandler_socket_unix::fcntl (int cmd, intptr_t arg)
|
|||
case F_SETFL:
|
||||
{
|
||||
const bool was_nonblocking = is_nonblocking ();
|
||||
const int allowed_flags = O_APPEND | O_NONBLOCK_MASK;
|
||||
const int allowed_flags = O_APPEND | O_NONBLOCK;
|
||||
int new_flags = arg & allowed_flags;
|
||||
if ((new_flags & OLD_O_NDELAY) && (new_flags & O_NONBLOCK))
|
||||
new_flags &= ~OLD_O_NDELAY;
|
||||
set_flags ((get_flags () & ~allowed_flags) | new_flags);
|
||||
const bool now_nonblocking = is_nonblocking ();
|
||||
if (was_nonblocking != now_nonblocking)
|
||||
|
|
|
@ -34,9 +34,6 @@ details. */
|
|||
#define CYGWIN_VERSION_USER_API_VERSION_COMBINED \
|
||||
CYGWIN_VERSION_PER_PROCESS_API_VERSION_COMBINED (user_data)
|
||||
|
||||
#define CYGWIN_VERSION_CHECK_FOR_OLD_O_NONBLOCK \
|
||||
(CYGWIN_VERSION_USER_API_VERSION_COMBINED <= 28)
|
||||
|
||||
#define CYGWIN_VERSION_CHECK_FOR_USING_BIG_TYPES \
|
||||
(CYGWIN_VERSION_USER_API_VERSION_COMBINED >= 79)
|
||||
|
||||
|
|
Loading…
Reference in New Issue