This is the mail archive of the
cygwin-cvs@cygwin.com
mailing list for the Cygwin project.
[newlib-cygwin] Cygwin: inline get_socket_flags()
- From: Corinna Vinschen <corinna at sourceware dot org>
- To: cygwin-cvs at sourceware dot org
- Date: 21 Feb 2018 21:00:38 -0000
- Subject: [newlib-cygwin] Cygwin: inline get_socket_flags()
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=a5dfbc69407d5a60f5b0c4d92ada6d022f23bee1
commit a5dfbc69407d5a60f5b0c4d92ada6d022f23bee1
Author: Corinna Vinschen <corinna@vinschen.de>
Date: Wed Feb 21 22:00:04 2018 +0100
Cygwin: inline get_socket_flags()
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diff:
---
winsup/cygwin/fhandler.h | 13 +++++++++++--
winsup/cygwin/fhandler_socket.cc | 11 -----------
winsup/cygwin/include/cygwin/_socketflags.h | 20 ++++++++++++++++++++
winsup/cygwin/include/cygwin/socket.h | 9 ++-------
4 files changed, 33 insertions(+), 20 deletions(-)
diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
index d912e1c..c50667c 100644
--- a/winsup/cygwin/fhandler.h
+++ b/winsup/cygwin/fhandler.h
@@ -10,6 +10,8 @@ details. */
#include "pinfo.h"
#include "tty.h"
+#include <cygwin/_socketflags.h>
+
/* fcntl flags used only internaly. */
#define O_NOSYMLINK 0x080000
#define O_DIROPEN 0x100000
@@ -488,8 +490,15 @@ class fhandler_socket: public fhandler_base
int addr_family;
int type;
virtual int af_local_connect () = 0;
- int get_socket_flags ();
-
+ inline int get_socket_flags ()
+ {
+ int ret = 0;
+ if (is_nonblocking ())
+ ret |= SOCK_NONBLOCK;
+ if (close_on_exec ())
+ ret |= SOCK_CLOEXEC;
+ return ret;
+ }
wsa_event *wsock_events;
HANDLE wsock_mtx;
HANDLE wsock_evt;
diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc
index 371cc39..aafc09c 100644
--- a/winsup/cygwin/fhandler_socket.cc
+++ b/winsup/cygwin/fhandler_socket.cc
@@ -721,17 +721,6 @@ fhandler_socket::link (const char *newpath)
}
int
-fhandler_socket::get_socket_flags ()
-{
- int ret = 0;
- if (is_nonblocking ())
- ret |= SOCK_NONBLOCK;
- if (close_on_exec ())
- ret |= SOCK_CLOEXEC;
- return ret;
-}
-
-int
fhandler_socket::shutdown (int how)
{
int res = ::shutdown (get_socket (), how);
diff --git a/winsup/cygwin/include/cygwin/_socketflags.h b/winsup/cygwin/include/cygwin/_socketflags.h
new file mode 100644
index 0000000..07a5e8b
--- /dev/null
+++ b/winsup/cygwin/include/cygwin/_socketflags.h
@@ -0,0 +1,20 @@
+/* cygwin/_socketflags.h
+
+This file is part of Cygwin.
+
+This software is a copyrighted work licensed under the terms of the
+Cygwin license. Please consult the file "CYGWIN_LICENSE" for
+details. */
+
+#ifndef _CYGWIN__SOCKETFLAGS_H
+#define _CYGWIN__SOCKETFLAGS_H
+
+/* GNU extension flags. Or them to the type parameter in calls to
+ socket(2) to mark socket as nonblocking and/or close-on-exec. */
+#define SOCK_NONBLOCK 0x01000000
+#define SOCK_CLOEXEC 0x02000000
+#ifdef __INSIDE_CYGWIN__
+#define _SOCK_FLAG_MASK 0xff000000 /* Bits left for more extensions */
+#endif
+
+#endif /* _CYGWIN__SOCKETFLAGS_H */
diff --git a/winsup/cygwin/include/cygwin/socket.h b/winsup/cygwin/include/cygwin/socket.h
index 87cee07..b1ab5c2 100644
--- a/winsup/cygwin/include/cygwin/socket.h
+++ b/winsup/cygwin/include/cygwin/socket.h
@@ -130,13 +130,8 @@ struct OLD_msghdr
#define SOCK_RDM 4 /* reliably-delivered message */
#define SOCK_SEQPACKET 5 /* sequential packet socket */
-/* GNU extension flags. Or them to the type parameter in calls to
- socket(2) to mark socket as nonblocking and/or close-on-exec. */
-#define SOCK_NONBLOCK 0x01000000
-#define SOCK_CLOEXEC 0x02000000
-#ifdef __INSIDE_CYGWIN__
-#define _SOCK_FLAG_MASK 0xff000000 /* Bits left for more extensions */
-#endif
+/* defines SOCK_NONBLOCK / SOCK_CLOEXEC */
+#include <cygwin/_socketflags.h>
/* Supported address families. */
/*