Skip to content

Commit 2384453

Browse files
authored
Use preprocessor to check for AI_V4MAPPED, AI_ALL and AI_IDN (#13513)
The preprocessor macros defined in some header can be checked, using Autoconf's AC_COMPILE_IFELSE, or with simpler AC_CHECK_DECL(S), or even better and simpler directly in the C code.
1 parent 718a8b4 commit 2384453

File tree

4 files changed

+9
-48
lines changed

4 files changed

+9
-48
lines changed

ext/sockets/config.m4

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -11,45 +11,6 @@ if test "$PHP_SOCKETS" != "no"; then
1111
dnl Check for field ss_family in sockaddr_storage (missing in AIX until 5.3)
1212
AC_CHECK_MEMBERS([struct sockaddr_storage.ss_family],,,[#include <sys/socket.h>])
1313

14-
dnl Check for AI_V4MAPPED flag
15-
AC_CACHE_CHECK([if getaddrinfo supports AI_V4MAPPED],[ac_cv_gai_ai_v4mapped],
16-
[
17-
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
18-
#include <netdb.h>
19-
]], [[int flag = AI_V4MAPPED;]])],
20-
[ac_cv_gai_ai_v4mapped=yes], [ac_cv_gai_ai_v4mapped=no])
21-
])
22-
23-
if test "$ac_cv_gai_ai_v4mapped" = yes; then
24-
AC_DEFINE(HAVE_AI_V4MAPPED,1,[Whether you have AI_V4MAPPED])
25-
fi
26-
27-
dnl Check for AI_ALL flag
28-
AC_CACHE_CHECK([if getaddrinfo supports AI_ALL],[ac_cv_gai_ai_all],
29-
[
30-
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
31-
#include <netdb.h>
32-
]], [[int flag = AI_ALL;]])],
33-
[ac_cv_gai_ai_all=yes], [ac_cv_gai_ai_all=no])
34-
])
35-
36-
if test "$ac_cv_gai_ai_all" = yes; then
37-
AC_DEFINE(HAVE_AI_ALL,1,[Whether you have AI_ALL])
38-
fi
39-
40-
dnl Check for AI_IDN flag
41-
AC_CACHE_CHECK([if getaddrinfo supports AI_IDN],[ac_cv_gai_ai_idn],
42-
[
43-
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
44-
#include <netdb.h>
45-
]], [[int flag = AI_IDN;]])],
46-
[ac_cv_gai_ai_idn=yes], [ac_cv_gai_ai_idn=no])
47-
])
48-
49-
if test "$ac_cv_gai_ai_idn" = yes; then
50-
AC_DEFINE(HAVE_AI_IDN,1,[Whether you have AI_IDN])
51-
fi
52-
5314
dnl Check for struct ucred. Checking the header is not enough (DragonFlyBSD).
5415
AC_CHECK_TYPES([struct ucred],,,
5516
[#ifndef _GNU_SOURCE

ext/sockets/sockaddr_conv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ int php_set_inet6_addr(struct sockaddr_in6 *sin6, char *string, php_socket *php_
2929

3030
memset(&hints, 0, sizeof(struct addrinfo));
3131
hints.ai_family = AF_INET6;
32-
#if HAVE_AI_V4MAPPED
32+
#ifdef AI_V4MAPPED
3333
hints.ai_flags = AI_V4MAPPED | AI_ADDRCONFIG;
3434
#else
3535
hints.ai_flags = AI_ADDRCONFIG;

ext/sockets/sockets.stub.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1591,14 +1591,14 @@
15911591
* @cvalue AI_NUMERICHOST
15921592
*/
15931593
const AI_NUMERICHOST = UNKNOWN;
1594-
#if HAVE_AI_V4MAPPED
1594+
#ifdef AI_V4MAPPED
15951595
/**
15961596
* @var int
15971597
* @cvalue AI_V4MAPPED
15981598
*/
15991599
const AI_V4MAPPED = UNKNOWN;
16001600
#endif
1601-
#if HAVE_AI_ALL
1601+
#ifdef AI_ALL
16021602
/**
16031603
* @var int
16041604
* @cvalue AI_ALL
@@ -1610,7 +1610,7 @@
16101610
* @cvalue AI_ADDRCONFIG
16111611
*/
16121612
const AI_ADDRCONFIG = UNKNOWN;
1613-
#if HAVE_AI_IDN
1613+
#ifdef AI_IDN
16141614
/**
16151615
* @var int
16161616
* @cvalue AI_IDN

ext/sockets/sockets_arginfo.h

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)