Skip to content

Commit a631f58

Browse files
committed
Undefine addrinfo.h constants if the system header defined them.
Fixes #486099.
1 parent 2998a55 commit a631f58

1 file changed

Lines changed: 35 additions & 4 deletions

File tree

Modules/addrinfo.h

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,29 @@
3232
/*
3333
* Error return codes from getaddrinfo()
3434
*/
35-
#ifndef EAI_ADDRFAMILY
35+
#ifdef EAI_ADDRFAMILY
36+
/* If this is defined, there is a conflicting implementation
37+
in the C library, which can't be used for some reason.
38+
Make sure it won't interfere with this emulation. */
39+
40+
#undef EAI_ADDRFAMILY
41+
#undef EAI_AGAIN
42+
#undef EAI_BADFLAGS
43+
#undef EAI_FAIL
44+
#undef EAI_FAMILY
45+
#undef EAI_MEMORY
46+
#undef EAI_NODATA
47+
#undef EAI_NONAME
48+
#undef EAI_SERVICE
49+
#undef EAI_SOCKTYPE
50+
#undef EAI_SYSTEM
51+
#undef EAI_BADHINTS
52+
#undef EAI_PROTOCOL
53+
#undef EAI_MAX
54+
#undef getaddrinfo
55+
#define getaddrinfo fake_getaddrinfo
56+
#endif
57+
3658
#define EAI_ADDRFAMILY 1 /* address family for hostname not supported */
3759
#define EAI_AGAIN 2 /* temporary failure in name resolution */
3860
#define EAI_BADFLAGS 3 /* invalid value for ai_flags */
@@ -47,12 +69,22 @@
4769
#define EAI_BADHINTS 12
4870
#define EAI_PROTOCOL 13
4971
#define EAI_MAX 14
50-
#endif
5172

5273
/*
5374
* Flag values for getaddrinfo()
5475
*/
55-
#ifndef AI_PASSIVE
76+
#ifdef AI_PASSIVE
77+
#undef AI_PASSIVE
78+
#undef AI_CANONNAME
79+
#undef AI_NUMERICHOST
80+
#undef AI_MASK
81+
#undef AI_ALL
82+
#undef AI_V4MAPPED_CFG
83+
#undef AI_ADDRCONFIG
84+
#undef AI_V4MAPPED
85+
#undef AI_DEFAULT
86+
#endif
87+
5688
#define AI_PASSIVE 0x00000001 /* get address to use bind() */
5789
#define AI_CANONNAME 0x00000002 /* fill ai_canonname */
5890
#define AI_NUMERICHOST 0x00000004 /* prevent name resolution */
@@ -65,7 +97,6 @@
6597
#define AI_V4MAPPED 0x00000800 /* accept IPv4-mapped IPv6 address */
6698
/* special recommended flags for getipnodebyname */
6799
#define AI_DEFAULT (AI_V4MAPPED_CFG | AI_ADDRCONFIG)
68-
#endif
69100

70101
#endif /* HAVE_GETADDRINFO */
71102

0 commit comments

Comments
 (0)