diff mbox

[v2,6/6] linux_user: consolidate sock_type

Message ID 20170925231924.31303-7-carenas@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Carlo Marcelo Arenas Belón Sept. 25, 2017, 11:19 p.m. UTC
remove unnecessary sock_type enum and other unused surrounding code to
allow for per arch sockbits to mirror better linux headers for maintenance

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
---
 linux-user/alpha/sockbits.h | 36 ----------------------------
 linux-user/hppa/sockbits.h  | 30 -----------------------
 linux-user/mips/sockbits.h  | 35 ---------------------------
 linux-user/socket.h         | 58 ++++++++++++++++++++++-----------------------
 linux-user/sparc/sockbits.h | 35 ---------------------------
 5 files changed, 29 insertions(+), 165 deletions(-)

Comments

Laurent Vivier Oct. 11, 2017, 1:23 p.m. UTC | #1
Le 26/09/2017 à 01:19, Carlo Marcelo Arenas Belón a écrit :
> remove unnecessary sock_type enum and other unused surrounding code to
> allow for per arch sockbits to mirror better linux headers for maintenance
> 
> Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
> ---
>  linux-user/alpha/sockbits.h | 36 ----------------------------
>  linux-user/hppa/sockbits.h  | 30 -----------------------
>  linux-user/mips/sockbits.h  | 35 ---------------------------
>  linux-user/socket.h         | 58 ++++++++++++++++++++++-----------------------
>  linux-user/sparc/sockbits.h | 35 ---------------------------
>  5 files changed, 29 insertions(+), 165 deletions(-)

I think it's not a good idea to mix again what we have just unmixed.

Thanks,
Laurent
Carlo Marcelo Arenas Belón Oct. 17, 2017, 5:36 p.m. UTC | #2
On Wed, Oct 11, 2017 at 6:23 AM, Laurent Vivier <laurent@vivier.eu> wrote:
> Le 26/09/2017 à 01:19, Carlo Marcelo Arenas Belón a écrit :
>> remove unnecessary sock_type enum and other unused surrounding code to
>> allow for per arch sockbits to mirror better linux headers for maintenance
>>
>> Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
>> ---
>>  linux-user/alpha/sockbits.h | 36 ----------------------------
>>  linux-user/hppa/sockbits.h  | 30 -----------------------
>>  linux-user/mips/sockbits.h  | 35 ---------------------------
>>  linux-user/socket.h         | 58 ++++++++++++++++++++++-----------------------
>>  linux-user/sparc/sockbits.h | 35 ---------------------------
>>  5 files changed, 29 insertions(+), 165 deletions(-)
>
> I think it's not a good idea to mix again what we have just unmixed.

do you object to the fact it was done in 2 steps (first moving out
from socket.h and then added it back as a single block)?  it was done
that way to reuse as much as possible the code that was already
reviewed.

the end result is the important part, though; and it is a sockbits.h
for those 4 architectures (and a socket.h for the rest) that could be
automatically generated or compared with the corresponding linux
headers and therefore hopefully be easier to maintain going forward.

since we are going to redo the series anyway, could we get some
discussion/agreement on the design of it?, have to admit I am a little
surprised by all the patches flying by the list but not many
conversations, and being new to qemu linux-user I think I could have
benefited from it to avoid some of the mistakes made.

Carlo
diff mbox

Patch

diff --git a/linux-user/alpha/sockbits.h b/linux-user/alpha/sockbits.h
index 768579a1f7..defdb806ea 100644
--- a/linux-user/alpha/sockbits.h
+++ b/linux-user/alpha/sockbits.h
@@ -66,39 +66,3 @@ 
 #define TARGET_SCM_TIMESTAMPING_PKTINFO         58
 #define TARGET_SO_PEERGROUPS                    59
 #define TARGET_SO_ZEROCOPY                      60
-
-/** sock_type - Socket types
- *
- * Please notice that for binary compat reasons ALPHA has to
- * override the enum sock_type in include/linux/net.h, so
- * we define ARCH_HAS_SOCKET_TYPES here.
- *
- * @SOCK_STREAM - stream (connection) socket
- * @SOCK_DGRAM - datagram (conn.less) socket
- * @SOCK_RAW - raw socket
- * @SOCK_RDM - reliably-delivered message
- * @SOCK_SEQPACKET - sequential packet socket
- * @SOCK_DCCP - Datagram Congestion Control Protocol socket
- * @SOCK_PACKET - linux specific way of getting packets at the dev level.
- *                For writing rarp and other similar things on the user
- *                level.
- * @SOCK_CLOEXEC - sets the close-on-exec (FD_CLOEXEC) flag.
- * @SOCK_NONBLOCK - sets the O_NONBLOCK file status flag.
- */
-
-enum sock_type {
-    TARGET_SOCK_STREAM      = 1,
-    TARGET_SOCK_DGRAM       = 2,
-    TARGET_SOCK_RAW         = 3,
-    TARGET_SOCK_RDM         = 4,
-    TARGET_SOCK_SEQPACKET   = 5,
-    TARGET_SOCK_DCCP        = 6,
-    TARGET_SOCK_PACKET      = 10,
-    TARGET_SOCK_CLOEXEC     = 010000000,
-    TARGET_SOCK_NONBLOCK    = 0x40000000,
-};
-
-#define TARGET_SOCK_MAX (TARGET_SOCK_PACKET + 1)
-#define TARGET_SOCK_TYPE_MASK 0xf  /* Covers up to TARGET_SOCK_MAX - 1. */
-
-#define ARCH_HAS_SOCKET_TYPES 1
diff --git a/linux-user/hppa/sockbits.h b/linux-user/hppa/sockbits.h
index 3dab31a76a..32f81357d6 100644
--- a/linux-user/hppa/sockbits.h
+++ b/linux-user/hppa/sockbits.h
@@ -71,33 +71,3 @@ 
 #define TARGET_SO_PEERGROUPS                    0x4034
 #define TARGET_SO_ZEROCOPY                      0x4035
 
-/** sock_type - Socket types - default values
- *
- * @SOCK_STREAM - stream (connection) socket
- * @SOCK_DGRAM - datagram (conn.less) socket
- * @SOCK_RAW - raw socket
- * @SOCK_RDM - reliably-delivered message
- * @SOCK_SEQPACKET - sequential packet socket
- * @SOCK_DCCP - Datagram Congestion Control Protocol socket
- * @SOCK_PACKET - linux specific way of getting packets at the dev level.
- *                For writing rarp and other similar things on the user
- *                level.
- * @SOCK_CLOEXEC - sets the close-on-exec (FD_CLOEXEC) flag.
- * @SOCK_NONBLOCK - sets the O_NONBLOCK file status flag.
- */
-enum sock_type {
-    TARGET_SOCK_STREAM    = 1,
-    TARGET_SOCK_DGRAM     = 2,
-    TARGET_SOCK_RAW       = 3,
-    TARGET_SOCK_RDM       = 4,
-    TARGET_SOCK_SEQPACKET = 5,
-    TARGET_SOCK_DCCP      = 6,
-    TARGET_SOCK_PACKET    = 10,
-    TARGET_SOCK_CLOEXEC   = 010000000,
-    TARGET_SOCK_NONBLOCK  = 0x40000000,
-};
-
-#define TARGET_SOCK_MAX (TARGET_SOCK_PACKET + 1)
-#define TARGET_SOCK_TYPE_MASK 0xf  /* Covers up to TARGET_SOCK_MAX - 1. */
-
-#define ARCH_HAS_SOCKET_TYPES 1
diff --git a/linux-user/mips/sockbits.h b/linux-user/mips/sockbits.h
index 6d8ea8aba2..fa8062391d 100644
--- a/linux-user/mips/sockbits.h
+++ b/linux-user/mips/sockbits.h
@@ -70,38 +70,3 @@ 
 #define TARGET_SCM_TIMESTAMPING_PKTINFO         58
 #define TARGET_SO_PEERGROUPS                    59
 #define TARGET_SO_ZEROCOPY                      60
-
-/** sock_type - Socket types
- *
- * Please notice that for binary compat reasons MIPS has to
- * override the enum sock_type in include/linux/net.h, so
- * we define ARCH_HAS_SOCKET_TYPES here.
- *
- * @SOCK_DGRAM - datagram (conn.less) socket
- * @SOCK_STREAM - stream (connection) socket
- * @SOCK_RAW - raw socket
- * @SOCK_RDM - reliably-delivered message
- * @SOCK_SEQPACKET - sequential packet socket
- * @SOCK_DCCP - Datagram Congestion Control Protocol socket
- * @SOCK_PACKET - linux specific way of getting packets at the dev level.
- *                For writing rarp and other similar things on the user
- *                level.
- * @SOCK_CLOEXEC - sets the close-on-exec (FD_CLOEXEC) flag.
- * @SOCK_NONBLOCK - sets the O_NONBLOCK file status flag.
- */
-enum sock_type {
-    TARGET_SOCK_DGRAM       = 1,
-    TARGET_SOCK_STREAM      = 2,
-    TARGET_SOCK_RAW         = 3,
-    TARGET_SOCK_RDM         = 4,
-    TARGET_SOCK_SEQPACKET   = 5,
-    TARGET_SOCK_DCCP        = 6,
-    TARGET_SOCK_PACKET      = 10,
-    TARGET_SOCK_CLOEXEC     = 02000000,
-    TARGET_SOCK_NONBLOCK    = 0x0080,
-};
-
-#define TARGET_SOCK_MAX (TARGET_SOCK_PACKET + 1)
-#define TARGET_SOCK_TYPE_MASK 0xf  /* Covers up to TARGET_SOCK_MAX - 1. */
-
-#define ARCH_HAS_SOCKET_TYPES 1
diff --git a/linux-user/socket.h b/linux-user/socket.h
index 6f49255b5f..8f21843d14 100644
--- a/linux-user/socket.h
+++ b/linux-user/socket.h
@@ -103,34 +103,34 @@ 
 
 #endif
 
-#ifndef ARCH_HAS_SOCKET_TYPES
-    /** sock_type - Socket types - default values
-     *
-     * @SOCK_STREAM - stream (connection) socket
-     * @SOCK_DGRAM - datagram (conn.less) socket
-     * @SOCK_RAW - raw socket
-     * @SOCK_RDM - reliably-delivered message
-     * @SOCK_SEQPACKET - sequential packet socket
-     * @SOCK_DCCP - Datagram Congestion Control Protocol socket
-     * @SOCK_PACKET - linux specific way of getting packets at the dev level.
-     *                For writing rarp and other similar things on the user
-     *                level.
-     * @SOCK_CLOEXEC - sets the close-on-exec (FD_CLOEXEC) flag.
-     * @SOCK_NONBLOCK - sets the O_NONBLOCK file status flag.
-     */
-    enum sock_type {
-           TARGET_SOCK_STREAM      = 1,
-           TARGET_SOCK_DGRAM       = 2,
-           TARGET_SOCK_RAW         = 3,
-           TARGET_SOCK_RDM         = 4,
-           TARGET_SOCK_SEQPACKET   = 5,
-           TARGET_SOCK_DCCP        = 6,
-           TARGET_SOCK_PACKET      = 10,
-           TARGET_SOCK_CLOEXEC     = 02000000,
-           TARGET_SOCK_NONBLOCK    = 04000,
-    };
-
-    #define TARGET_SOCK_MAX (TARGET_SOCK_PACKET + 1)
-    #define TARGET_SOCK_TYPE_MASK  0xf  /* Covers up to TARGET_SOCK_MAX - 1. */
+#if defined(TARGET_MIPS)
+    #define TARGET_SOCK_DGRAM  1
+    #define TARGET_SOCK_STREAM 2
+#else
+    #define TARGET_SOCK_STREAM 1
+    #define TARGET_SOCK_DGRAM  2
+#endif
 
+#define TARGET_SOCK_RAW        3
+#define TARGET_SOCK_RDM        4
+#define TARGET_SOCK_SEQPACKET  5
+#define TARGET_SOCK_DCCP       6
+#define TARGET_SOCK_PACKET     10
+
+#if defined(TARGET_ALPHA) || defined(TARGET_HPPA)
+    #define TARGET_SOCK_CLOEXEC  010000000
+#else
+    #define TARGET_SOCK_CLOEXEC  02000000 /* 0x400000 */
 #endif
+
+#if defined(TARGET_MIPS)
+    #define TARGET_SOCK_NONBLOCK 0x0080
+#elif defined(TARGET_SPARC)
+    #define TARGET_SOCK_NONBLOCK 0x4000
+#elif defined(TARGET_ALPHA) || defined(TARGET_HPPA)
+    #define TARGET_SOCK_NONBLOCK 0x40000000
+#else
+    #define TARGET_SOCK_NONBLOCK 04000
+#endif
+
+#define TARGET_SOCK_TYPE_MASK  0xf
diff --git a/linux-user/sparc/sockbits.h b/linux-user/sparc/sockbits.h
index d51ae5f84f..70bee083bb 100644
--- a/linux-user/sparc/sockbits.h
+++ b/linux-user/sparc/sockbits.h
@@ -67,38 +67,3 @@ 
 #define TARGET_SO_SECURITY_ENCRYPTION_TRANSPORT  0x5002
 #define TARGET_SO_SECURITY_ENCRYPTION_NETWORK    0x5004
 
-/** sock_type - Socket types
- *
- * Please notice that for binary compat reasons SPARC has to
- * override the enum sock_type in include/linux/net.h, so
- * we define ARCH_HAS_SOCKET_TYPES here.
- *
- * @SOCK_STREAM - stream (connection) socket
- * @SOCK_DGRAM - datagram (conn.less) socket
- * @SOCK_RAW - raw socket
- * @SOCK_RDM - reliably-delivered message
- * @SOCK_SEQPACKET - sequential packet socket
- * @SOCK_DCCP - Datagram Congestion Control Protocol socket
- * @SOCK_PACKET - linux specific way of getting packets at the dev level.
- *                For writing rarp and other similar things on the user
- *                level.
- * @SOCK_CLOEXEC - sets the close-on-exec (FD_CLOEXEC) flag.
- * @SOCK_NONBLOCK - sets the O_NONBLOCK file status flag.
- */
-
-enum sock_type {
-    TARGET_SOCK_STREAM      = 1,
-    TARGET_SOCK_DGRAM       = 2,
-    TARGET_SOCK_RAW         = 3,
-    TARGET_SOCK_RDM         = 4,
-    TARGET_SOCK_SEQPACKET   = 5,
-    TARGET_SOCK_DCCP        = 6,
-    TARGET_SOCK_PACKET      = 10,
-    TARGET_SOCK_CLOEXEC     = 0x400000,
-    TARGET_SOCK_NONBLOCK    = 0x4000,
-};
-
-#define TARGET_SOCK_MAX (TARGET_SOCK_PACKET + 1)
-#define TARGET_SOCK_TYPE_MASK 0xf  /* Covers up to TARGET_SOCK_MAX - 1. */
-
-#define ARCH_HAS_SOCKET_TYPES 1