Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d783041

Browse files
committed
Port getaddrinfo to MSVC++.
1 parent 1bdd0f2 commit d783041

3 files changed

Lines changed: 15 additions & 15 deletions

File tree

Modules/addrinfo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ struct addrinfo {
105105
*/
106106
#define _SS_MAXSIZE 128
107107
#ifdef HAVE_LONG_LONG
108-
#define _SS_ALIGNSIZE (sizeof(long long))
108+
#define _SS_ALIGNSIZE (sizeof(LONG_LONG))
109109
#else
110110
#define _SS_ALIGNSIZE (sizeof(double))
111111
#endif
@@ -122,7 +122,7 @@ struct sockaddr_storage {
122122
#endif
123123
char __ss_pad1[_SS_PAD1SIZE];
124124
#ifdef HAVE_LONG_LONG
125-
long long __ss_align; /* force desired structure storage alignment */
125+
LONG_LONG __ss_align; /* force desired structure storage alignment */
126126
#else
127127
double __ss_align; /* force desired structure storage alignment */
128128
#endif

Modules/getaddrinfo.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,17 @@ static struct gai_afd {
117117
#define PTON_MAX 4
118118
#endif
119119

120+
#ifndef IN_MULTICAST
121+
#define IN_MULTICAST(i) (((i) & 0xf0000000U) == 0xe0000000U)
122+
#endif
123+
124+
#ifndef IN_EXPERIMENTAL
125+
#define IN_EXPERIMENTAL(i) (((i) & 0xe0000000U) == 0xe0000000U)
126+
#endif
127+
128+
#ifndef IN_LOOPBACKNET
129+
#define IN_LOOPBACKNET 127
130+
#endif
120131

121132
static int get_name Py_PROTO((const char *, struct gai_afd *,
122133
struct addrinfo **, char *, struct addrinfo *,
@@ -527,7 +538,8 @@ get_addr(hostname, af, res, pai, port0)
527538
struct gai_afd *gai_afd;
528539
int i, error = 0, h_error;
529540
char *ap;
530-
#ifndef INET6
541+
#if !defined(INET6) && !defined(MS_WIN32)
542+
/* In winsock.h, h_errno is #defined as a function call. */
531543
extern int h_errno;
532544
#endif
533545

Modules/socketmodule.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -195,12 +195,7 @@ Socket methods:
195195
#include <GUSI.h>
196196
#endif
197197

198-
/* XXX 24-Jun-2000 Tim: I have no idea what the code inside this block is
199-
trying to do, and don't have time to look. Looks like Unix-specific code
200-
in those files, though, which will never compile on Windows. */
201-
#ifndef MS_WINDOWS
202198
#include "addrinfo.h"
203-
#endif /* ifndef MS_WINDOWS hack */
204199

205200
#ifdef USE_SSL
206201
#include "openssl/rsa.h"
@@ -211,11 +206,6 @@ Socket methods:
211206
#include "openssl/err.h"
212207
#endif /* USE_SSL */
213208

214-
/* XXX 24-Jun-2000 Tim: I have no idea what the code inside this block is
215-
trying to do, and don't have time to look. Looks like Unix-specific code
216-
in those files, though, which will never compile on Windows. */
217-
#ifndef MS_WINDOWS
218-
219209
#ifndef HAVE_INET_PTON
220210
int inet_pton (int af, char *src, void *dst);
221211
char *inet_ntop(int af, void *src, char *dst, socklen_t size);
@@ -229,8 +219,6 @@ char *inet_ntop(int af, void *src, char *dst, socklen_t size);
229219
#include "getnameinfo.c"
230220
#endif
231221

232-
#endif /* ifndef MS_WINDOWS hack */
233-
234222
#if defined(MS_WINDOWS) || defined(__BEOS__)
235223
/* BeOS suffers from the same socket dichotomy as Win32... - [cjh] */
236224
/* seem to be a few differences in the API */

0 commit comments

Comments
 (0)