public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org>
To: cygwin-cvs@sourceware.org
Subject: [newlib-cygwin] Cygwin: drop macro and code for CYGWIN_VERSION_CHECK_FOR_OLD_O_NONBLOCK
Date: Wed,  3 Aug 2022 14:05:50 +0000 (GMT)	[thread overview]
Message-ID: <20220803140550.10FAD38582A7@sourceware.org> (raw)

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)


                 reply	other threads:[~2022-08-03 14:05 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220803140550.10FAD38582A7@sourceware.org \
    --to=corinna@sourceware.org \
    --cc=cygwin-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).