public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin] Cygwin: drop macro and code for CYGWIN_VERSION_CHECK_FOR_OLD_O_NONBLOCK
@ 2022-08-03 14:05 Corinna Vinschen
  0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2022-08-03 14:05 UTC (permalink / raw)
  To: cygwin-cvs

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=c2743614bf2421b0594da33fb41845792d0e703b

commit c2743614bf2421b0594da33fb41845792d0e703b
Author: Corinna Vinschen <corinna@vinschen.de>
Date:   Wed Aug 3 15:48:56 2022 +0200

    Cygwin: drop macro and code for CYGWIN_VERSION_CHECK_FOR_OLD_O_NONBLOCK
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/cygwin/fhandler.cc              | 15 +++++----------
 winsup/cygwin/fhandler.h               |  9 ---------
 winsup/cygwin/fhandler_socket.cc       | 11 +++--------
 winsup/cygwin/fhandler_socket_unix.cc  |  4 +---
 winsup/cygwin/include/cygwin/version.h |  3 ---
 5 files changed, 9 insertions(+), 33 deletions(-)

diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index 9d6d01858..72d35391f 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -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
diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
index e4f1a2d94..aad7f4c37 100644
--- a/winsup/cygwin/fhandler.h
+++ b/winsup/cygwin/fhandler.h
@@ -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. */
diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc
index 57a75df34..49ad5b3e0 100644
--- a/winsup/cygwin/fhandler_socket.cc
+++ b/winsup/cygwin/fhandler_socket.cc
@@ -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:
diff --git a/winsup/cygwin/fhandler_socket_unix.cc b/winsup/cygwin/fhandler_socket_unix.cc
index b63f50c64..524f18d81 100644
--- a/winsup/cygwin/fhandler_socket_unix.cc
+++ b/winsup/cygwin/fhandler_socket_unix.cc
@@ -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)
diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h
index 8b9cbd7f3..0d55d8292 100644
--- a/winsup/cygwin/include/cygwin/version.h
+++ b/winsup/cygwin/include/cygwin/version.h
@@ -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)


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-08-03 14:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-03 14:05 [newlib-cygwin] Cygwin: drop macro and code for CYGWIN_VERSION_CHECK_FOR_OLD_O_NONBLOCK Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).