Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(11)

Delta Between Two Patch Sets: Modules/socketmodule.h

Issue 3871: cross and native build of python for mingw32 with distutils
Left Patch Set: Created 9 years, 5 months ago
Right Patch Set: Created 7 years, 2 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « Modules/socketmodule.c ('k') | Modules/_winapi.c » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* Socket module header file */ 1 /* Socket module header file */
2 2
3 /* Includes needed for the sockaddr_* symbols below */ 3 /* Includes needed for the sockaddr_* symbols below */
4 #ifndef MS_WINDOWS 4 #ifndef MS_WINDOWS
5 #ifdef __VMS 5 #ifdef __VMS
6 # include <socket.h> 6 # include <socket.h>
7 # else 7 # else
8 # include <sys/socket.h> 8 # include <sys/socket.h>
9 # endif 9 # endif
10 # include <netinet/in.h> 10 # include <netinet/in.h>
11 # if !(defined(__CYGWIN__) || (defined(PYOS_OS2) && defined(PYCC_VACPP))) 11 # if !(defined(__CYGWIN__) || (defined(PYOS_OS2) && defined(PYCC_VACPP)))
12 # include <netinet/tcp.h> 12 # include <netinet/tcp.h>
13 # endif 13 # endif
14 14
15 #else /* MS_WINDOWS */ 15 #else /* MS_WINDOWS */
16 #ifdef socklen_t
17 /* Configure script define to int on windows for GCC compiler.
18 Avoid GCC 4.4+ error (two or more data types in declaration specifiers)
19 as undef it first.
20 */
21 # undef socklen_t
22 #endif
16 # include <winsock2.h> 23 # include <winsock2.h>
17 # include <ws2tcpip.h> 24 # include <ws2tcpip.h>
18 /* VC6 is shipped with old platform headers, and does not have MSTcpIP.h 25 /* VC6 is shipped with old platform headers, and does not have MSTcpIP.h
19 * Separate SDKs have all the functions we want, but older ones don't have 26 * Separate SDKs have all the functions we want, but older ones don't have
20 * any version information. 27 * any version information.
21 * I use SIO_GET_MULTICAST_FILTER to detect a decent SDK. 28 * I use SIO_GET_MULTICAST_FILTER to detect a decent SDK.
22 */ 29 */
23 # if defined(SIO_GET_MULTICAST_FILTER) 30 # ifdef SIO_GET_MULTICAST_FILTER
24 # include <MSTcpIP.h> /* for SIO_RCVALL */ 31 # include <mstcpip.h> /* for SIO_RCVALL */
25 # define HAVE_ADDRINFO
26 # define HAVE_SOCKADDR_STORAGE
27 # define HAVE_GETADDRINFO
28 # define HAVE_GETNAMEINFO
29 # define ENABLE_IPV6
30 # elif defined(__MINGW32__)
31 #ifndef SIO_RCVALL
32 #define SIO_RCVALL _WSAIOW(IOC_VENDOR,1)
33 #endif
34 #ifndef SIO_KEEPALIVE_VALS
35 #define SIO_KEEPALIVE_VALS _WSAIOW(IOC_VENDOR,4)
36 #endif
37 /* Argument structure for SIO_KEEPALIVE_VALS */
38 struct tcp_keepalive {
39 u_long onoff;
40 u_long keepalivetime;
41 u_long keepaliveinterval;
42 };
43 #ifndef RCVALL_OFF
44 #define RCVALL_OFF 0
45 #endif
46 #ifndef RCVALL_ON
47 #define RCVALL_ON 1
48 #endif
49 #ifndef RCVALL_SOCKETLEVELONLY
50 #define RCVALL_SOCKETLEVELONLY 2
51 #endif
52 # define HAVE_ADDRINFO 32 # define HAVE_ADDRINFO
53 # define HAVE_SOCKADDR_STORAGE 33 # define HAVE_SOCKADDR_STORAGE
54 # define HAVE_GETADDRINFO 34 # define HAVE_GETADDRINFO
55 # define HAVE_GETNAMEINFO 35 # define HAVE_GETNAMEINFO
56 # define ENABLE_IPV6 36 # define ENABLE_IPV6
57 # else 37 # else
58 typedef int socklen_t; 38 typedef int socklen_t;
59 # endif /* IPPROTO_IPV6 */ 39 # endif /* IPPROTO_IPV6 */
60 #endif /* MS_WINDOWS */ 40 #endif /* MS_WINDOWS */
61 41
(...skipping 17 matching lines...) Expand all
79 #include <bluetooth/rfcomm.h> 59 #include <bluetooth/rfcomm.h>
80 #include <bluetooth/l2cap.h> 60 #include <bluetooth/l2cap.h>
81 #include <bluetooth/sco.h> 61 #include <bluetooth/sco.h>
82 #include <bluetooth/hci.h> 62 #include <bluetooth/hci.h>
83 #endif 63 #endif
84 64
85 #ifdef HAVE_BLUETOOTH_H 65 #ifdef HAVE_BLUETOOTH_H
86 #include <bluetooth.h> 66 #include <bluetooth.h>
87 #endif 67 #endif
88 68
69 #ifdef HAVE_NET_IF_H
70 # include <net/if.h>
71 #endif
72
89 #ifdef HAVE_NETPACKET_PACKET_H 73 #ifdef HAVE_NETPACKET_PACKET_H
90 # include <sys/ioctl.h> 74 # include <sys/ioctl.h>
91 # include <net/if.h>
92 # include <netpacket/packet.h> 75 # include <netpacket/packet.h>
93 #endif 76 #endif
94 77
95 #ifdef HAVE_LINUX_TIPC_H 78 #ifdef HAVE_LINUX_TIPC_H
96 # include <linux/tipc.h> 79 # include <linux/tipc.h>
80 #endif
81
82 #ifdef HAVE_LINUX_CAN_H
83 #include <linux/can.h>
84 #endif
85
86 #ifdef HAVE_LINUX_CAN_RAW_H
87 #include <linux/can/raw.h>
88 #endif
89
90 #ifdef HAVE_SYS_SYS_DOMAIN_H
91 #include <sys/sys_domain.h>
92 #endif
93 #ifdef HAVE_SYS_KERN_CONTROL_H
94 #include <sys/kern_control.h>
97 #endif 95 #endif
98 96
99 #ifndef Py__SOCKET_H 97 #ifndef Py__SOCKET_H
100 #define Py__SOCKET_H 98 #define Py__SOCKET_H
101 #ifdef __cplusplus 99 #ifdef __cplusplus
102 extern "C" { 100 extern "C" {
103 #endif 101 #endif
104 102
105 /* Python module and C API name */ 103 /* Python module and C API name */
106 #define PySocket_MODULE_NAME "_socket" 104 #define PySocket_MODULE_NAME "_socket"
107 #define PySocket_CAPI_NAME "CAPI" 105 #define PySocket_CAPI_NAME "CAPI"
108 #define PySocket_CAPSULE_NAME PySocket_MODULE_NAME "." PySocket_CAPI_NAME 106 #define PySocket_CAPSULE_NAME PySocket_MODULE_NAME "." PySocket_CAPI_NAME
109 107
110 /* Abstract the socket file descriptor type */ 108 /* Abstract the socket file descriptor type */
111 #ifdef MS_WINDOWS 109 #ifdef MS_WINDOWS
112 typedef SOCKET SOCKET_T; 110 typedef SOCKET SOCKET_T;
113 # ifdef MS_WIN64 111 # ifdef MS_WIN64
114 # define SIZEOF_SOCKET_T 8 112 # define SIZEOF_SOCKET_T 8
115 # else 113 # else
116 # define SIZEOF_SOCKET_T 4 114 # define SIZEOF_SOCKET_T 4
117 # endif 115 # endif
118 #else 116 #else
119 typedef int SOCKET_T; 117 typedef int SOCKET_T;
120 # define SIZEOF_SOCKET_T SIZEOF_INT 118 # define SIZEOF_SOCKET_T SIZEOF_INT
121 #endif 119 #endif
122 120
121 #if SIZEOF_SOCKET_T <= SIZEOF_LONG
122 #define PyLong_FromSocket_t(fd) PyLong_FromLong((SOCKET_T)(fd))
123 #define PyLong_AsSocket_t(fd) (SOCKET_T)PyLong_AsLong(fd)
124 #else
125 #define PyLong_FromSocket_t(fd) PyLong_FromLongLong((SOCKET_T)(fd))
126 #define PyLong_AsSocket_t(fd) (SOCKET_T)PyLong_AsLongLong(fd)
127 #endif
128
123 /* Socket address */ 129 /* Socket address */
124 typedef union sock_addr { 130 typedef union sock_addr {
125 struct sockaddr_in in; 131 struct sockaddr_in in;
132 struct sockaddr sa;
126 #ifdef AF_UNIX 133 #ifdef AF_UNIX
127 struct sockaddr_un un; 134 struct sockaddr_un un;
128 #endif 135 #endif
129 #ifdef AF_NETLINK 136 #ifdef AF_NETLINK
130 struct sockaddr_nl nl; 137 struct sockaddr_nl nl;
131 #endif 138 #endif
132 #ifdef ENABLE_IPV6 139 #ifdef ENABLE_IPV6
133 struct sockaddr_in6 in6; 140 struct sockaddr_in6 in6;
134 struct sockaddr_storage storage; 141 struct sockaddr_storage storage;
135 #endif 142 #endif
136 #ifdef HAVE_BLUETOOTH_BLUETOOTH_H 143 #ifdef HAVE_BLUETOOTH_BLUETOOTH_H
137 struct sockaddr_l2 bt_l2; 144 struct sockaddr_l2 bt_l2;
138 struct sockaddr_rc bt_rc; 145 struct sockaddr_rc bt_rc;
139 struct sockaddr_sco bt_sco; 146 struct sockaddr_sco bt_sco;
140 struct sockaddr_hci bt_hci; 147 struct sockaddr_hci bt_hci;
141 #endif 148 #endif
142 #ifdef HAVE_NETPACKET_PACKET_H 149 #ifdef HAVE_NETPACKET_PACKET_H
143 struct sockaddr_ll ll; 150 struct sockaddr_ll ll;
151 #endif
152 #ifdef HAVE_LINUX_CAN_H
153 struct sockaddr_can can;
154 #endif
155 #ifdef HAVE_SYS_KERN_CONTROL_H
156 struct sockaddr_ctl ctl;
144 #endif 157 #endif
145 } sock_addr_t; 158 } sock_addr_t;
146 159
147 /* The object holding a socket. It holds some extra information, 160 /* The object holding a socket. It holds some extra information,
148 like the address family, which is used to decode socket address 161 like the address family, which is used to decode socket address
149 arguments properly. */ 162 arguments properly. */
150 163
151 typedef struct { 164 typedef struct {
152 PyObject_HEAD 165 PyObject_HEAD
153 SOCKET_T sock_fd; /* Socket file descriptor */ 166 SOCKET_T sock_fd; /* Socket file descriptor */
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 this way. Currently, only the type object is exported, 221 this way. Currently, only the type object is exported,
209 other candidates would be socket constructors and socket 222 other candidates would be socket constructors and socket
210 access functions. 223 access functions.
211 224
212 */ 225 */
213 226
214 /* C API for usage by other Python modules */ 227 /* C API for usage by other Python modules */
215 typedef struct { 228 typedef struct {
216 PyTypeObject *Sock_Type; 229 PyTypeObject *Sock_Type;
217 PyObject *error; 230 PyObject *error;
231 PyObject *timeout_error;
218 } PySocketModule_APIObject; 232 } PySocketModule_APIObject;
219 233
220 #define PySocketModule_ImportModuleAndAPI() PyCapsule_Import(PySocket_CAPSULE_NA ME, 1) 234 #define PySocketModule_ImportModuleAndAPI() PyCapsule_Import(PySocket_CAPSULE_NA ME, 1)
221 235
222 #ifdef __cplusplus 236 #ifdef __cplusplus
223 } 237 }
224 #endif 238 #endif
225 #endif /* !Py__SOCKET_H */ 239 #endif /* !Py__SOCKET_H */
LEFTRIGHT

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+