shithub: mc

Download patch

ref: fb8cbb2339df748749c588b20f787e2973c2fd36
parent: de496a920339b8285ca2e9225b1abff7af54698a
author: Michael Forney <mforney@mforney.org>
date: Sat Jun 24 19:06:58 EDT 2017

Rename Solsock to Solsocket and make it type sockproto

This constant is used as a protocol level in getsockopt/setsockopt as well as
msghdr. Valid values for level include the same constants used as the protocol
argument of socket (IPPROTO_*), so it needs to have the same type so the
constants can be used in both functions.

The rename is for consistency with the C API.

--- a/lib/std/listen+posixy.myr
+++ b/lib/std/listen+posixy.myr
@@ -74,7 +74,7 @@
 		-> `Err "failed to create socket"
 	;;
 	yes = 1
-	if sys.setsockopt(sock, sys.Solsock, sys.Soreuseaddr, (&yes : void#), sizeof(int)) < 0
+	if sys.setsockopt(sock, sys.Solsocket, sys.Soreuseaddr, (&yes : void#), sizeof(int)) < 0
 		-> `Err "failed to set sock opts"
 	;;
 	if sys.bind(sock, sa, sz) < 0
@@ -99,7 +99,7 @@
 		-> `Err "failed to create socket"
 	;;
 	yes = 1
-	if sys.setsockopt(sock, sys.Solsock, sys.Soreuseaddr, (&yes : void#), sizeof(int)) < 0
+	if sys.setsockopt(sock, sys.Solsocket, sys.Soreuseaddr, (&yes : void#), sizeof(int)) < 0
 		-> `Err "failed to set sock opts"
 	;;
 	sys.unlink(path)
--- a/lib/sys/sys+freebsd-x64.myr
+++ b/lib/sys/sys+freebsd-x64.myr
@@ -249,7 +249,6 @@
 	const Sockraw		: socktype = 3
 	const Sockrdm		: socktype = 4
 	const Sockseqpacket	: socktype = 5
-	const Solsock	: socktype =	0xffff
 
 	/* socket options */
 	const Sodebug	: sockopt = 0x0001		/* turn on debugging info recording */
@@ -269,6 +268,9 @@
 	const Sonooffload	: sockopt = 0x4000	/* socket cannot be offloaded */
 	const Sonoddp		: sockopt = 0x8000	/* disable direct data placement */
 
+	/* socket option levels */
+	const Solsocket		: sockproto = 0xffff
+
 	/* network protocols */
 	const Ipproto_ip	: sockproto = 0
 	const Ipproto_icmp	: sockproto = 1
@@ -866,8 +868,8 @@
 	const accept	: (sock : fd, addr : sockaddr#, len : size# -> fd)
 	const listen	: (sock : fd, backlog : int	-> int)
 	const bind	: (sock : fd, addr : sockaddr#, len : size -> int)
-	const setsockopt	: (sock : fd, lev : socktype, opt : sockopt, val : void#, len : size -> int)
-	const getsockopt	: (sock : fd, lev : socktype, opt : sockopt, val : void#, len : size# -> int)
+	const setsockopt	: (sock : fd, lev : sockproto, opt : sockopt, val : void#, len : size -> int)
+	const getsockopt	: (sock : fd, lev : sockproto, opt : sockopt, val : void#, len : size# -> int)
 
 	/* memory mapping */
 	const munmap	: (addr:byte#, len:size -> int64)
--- a/lib/sys/sys+linux-x64.myr
+++ b/lib/sys/sys+linux-x64.myr
@@ -237,7 +237,6 @@
 	const Sockseqpacket	: socktype = 5	/* sequenced, reliable packets */
 	const Sockdccp		: socktype = 6	/* data congestion control protocol */
 	const Sockpack		: socktype = 10	/* linux specific packet */
-	const Solsock	: socktype =	1
 
 	/* socket options */
 	const Sodebug		: sockopt = 1
@@ -264,6 +263,9 @@
 	const Sorcvtimeo	: sockopt = 20
 	const Sosndtimeo	: sockopt = 21
 
+	/* socket option levels */
+	const Solsocket		: sockproto = 1
+
 	/* network protocols */
 	const Ipproto_ip	: sockproto = 0
 	const Ipproto_icmp	: sockproto = 1
@@ -771,8 +773,8 @@
 	const accept	: (sock : fd, addr : sockaddr#, len : size# -> fd)
 	const listen	: (sock : fd, backlog : int	-> int)
 	const bind	: (sock : fd, addr : sockaddr#, len : size -> int)
-	const setsockopt	: (sock : fd, lev : socktype, opt : sockopt, val : void#, len : size -> int)
-	const getsockopt	: (sock : fd, lev : socktype, opt : sockopt, val : void#, len : size# -> int)
+	const setsockopt	: (sock : fd, lev : sockproto, opt : sockopt, val : void#, len : size -> int)
+	const getsockopt	: (sock : fd, lev : sockproto, opt : sockopt, val : void#, len : size# -> int)
 
 	/* memory mapping */
 	const munmap	: (addr:byte#, len:size -> int64)
--- a/lib/sys/sys+netbsd-x64.myr
+++ b/lib/sys/sys+netbsd-x64.myr
@@ -241,7 +241,6 @@
 	const Sockraw		: socktype = 3
 	const Sockrdm		: socktype = 4
 	const Sockseqpacket	: socktype = 5
-	const Solsock	: socktype =	0xffff
 
 	/* socket options */
 	const Sodebug	: sockopt = 0x0001		/* turn on debugging info recording */
@@ -261,6 +260,9 @@
 	const Sonooffload	: sockopt = 0x4000	/* socket cannot be offloaded */
 	const Sonoddp		: sockopt = 0x8000	/* disable direct data placement */
 
+	/* socket option levels */
+	const Solsocket		: sockproto = 0xffff
+
 	/* network protocols */
 	const Ipproto_ip	: sockproto = 0
 	const Ipproto_icmp	: sockproto = 1
@@ -885,8 +887,8 @@
 	const accept	: (sock : fd, addr : sockaddr#, len : size# -> fd)
 	const listen	: (sock : fd, backlog : int	-> int)
 	const bind	: (sock : fd, addr : sockaddr#, len : size -> int)
-	const setsockopt	: (sock : fd, lev : socktype, opt : sockopt, val : void#, len : size -> int)
-	const getsockopt	: (sock : fd, lev : socktype, opt : sockopt, val : void#, len : size# -> int)
+	const setsockopt	: (sock : fd, lev : sockproto, opt : sockopt, val : void#, len : size -> int)
+	const getsockopt	: (sock : fd, lev : sockproto, opt : sockopt, val : void#, len : size# -> int)
 
 	/* memory mapping */
 	const munmap	: (addr:byte#, len:size -> int64)
--- a/lib/sys/sys+openbsd-x64.myr
+++ b/lib/sys/sys+openbsd-x64.myr
@@ -239,8 +239,8 @@
 	const Sockraw		: socktype = 3
 	const Sockrdm		: socktype = 4
 	const Sockseqpacket	: socktype = 5
-	const Solsock	: socktype =	0xffff
 
+	/* socket options */
 	const Sodebug		: sockopt = 0x0001	/* turn on debugging info recording */
 	const Soacceptconn	: sockopt = 0x0002	/* socket has had listen() */
 	const Soreuseaddr	: sockopt = 0x0004	/* allow local address reuse */
@@ -266,6 +266,9 @@
 	const Sopeercred	: sockopt = 0x1022	/* get connect-time credentials */
 	const Sosplice		: sockopt = 0x1023	/* splice data to other socket */
 
+	/* socket option levels */
+	const Solsocket		: sockproto = 0xffff
+
 	/* network protocols */
 	const Ipproto_ip	: sockproto = 0
 	const Ipproto_icmp	: sockproto = 1
@@ -603,8 +606,8 @@
 	const accept	: (sock : fd, addr : sockaddr#, len : size# -> fd)
 	const listen	: (sock : fd, backlog : int	-> int)
 	const bind	: (sock : fd, addr : sockaddr#, len : size -> int)
-	const setsockopt	: (sock : fd, lev : socktype, opt : sockopt, val : void#, len : size -> int)
-	const getsockopt	: (sock : fd, lev : socktype, opt : sockopt, val : void#, len : size# -> int)
+	const setsockopt	: (sock : fd, lev : sockproto, opt : sockopt, val : void#, len : size -> int)
+	const getsockopt	: (sock : fd, lev : sockproto, opt : sockopt, val : void#, len : size# -> int)
 
 	/* memory mapping */
 	const munmap	: (addr:byte#, len:size -> int64)
--- a/lib/sys/sys+osx-x64.myr
+++ b/lib/sys/sys+osx-x64.myr
@@ -283,7 +283,6 @@
 	const Sockraw		: socktype = 3
 	const Sockrdm		: socktype = 4
 	const Sockseqpacket	: socktype = 5
-	const Solsock	: socktype =	0xffff
 
 	/* socket options */
 	const Sodebug	: sockopt = 0x0001		/* turn on debugging info recording */
@@ -304,6 +303,9 @@
 	const Sowantmore	: sockopt = 0x4000	/* APPLE: Give hint when more data ready */
 	const Sowantoobflag	: sockopt = 0x8000	/* APPLE: Want OOB in MSG_FLAG on receive */
 
+	/* socket option levels */
+	const Solsocket		: sockproto = 0xffff
+
 	/* network protocols */
 	const Ipproto_ip	: sockproto = 0
 	const Ipproto_icmp	: sockproto = 1
@@ -797,8 +799,8 @@
 	const accept	: (sock : fd, addr : sockaddr#, len : size# -> fd)
 	const listen	: (sock : fd, backlog : int	-> int)
 	const bind	: (sock : fd, addr : sockaddr#, len : size -> int)
-	const setsockopt	: (sock : fd, lev : socktype, opt : sockopt, val : void#, len : size -> int)
-	const getsockopt	: (sock : fd, lev : socktype, opt : sockopt, val : void#, len : size# -> int)
+	const setsockopt	: (sock : fd, lev : sockproto, opt : sockopt, val : void#, len : size -> int)
+	const getsockopt	: (sock : fd, lev : sockproto, opt : sockopt, val : void#, len : size# -> int)
 
 	/* memory mapping */
 	const munmap	: (addr:byte#, len:size -> int64)