Skip to content

Commit

Permalink
ext/sockets: make AI_IDN usage optional
Browse files Browse the repository at this point in the history
AI_IDN is not supported by all C libraries (uClibc, musl), so make it
optional, like AI_ALL.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
  • Loading branch information
tpetazzoni authored and nikic committed Mar 11, 2018
1 parent d34ab3a commit 8489ece
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions ext/sockets/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,19 @@ if test "$PHP_SOCKETS" != "no"; then
AC_DEFINE(HAVE_AI_ALL,1,[Whether you have AI_ALL])
fi

dnl Check for AI_IDN flag
AC_CACHE_CHECK([if getaddrinfo supports AI_IDN],[ac_cv_gai_ai_idn],
[
AC_TRY_COMPILE([
#include <netdb.h>
], [int flag = AI_IDN;],
ac_cv_gai_ai_idn=yes, ac_cv_gai_ai_idn=no)
])

if test "$ac_cv_gai_ai_idn" = yes; then
AC_DEFINE(HAVE_AI_IDN,1,[Whether you have AI_IDN])
fi

PHP_NEW_EXTENSION([sockets], [sockets.c multicast.c conversions.c sockaddr_conv.c sendrecvmsg.c], [$ext_shared],, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
PHP_INSTALL_HEADERS([ext/sockets/], [php_sockets.h])
fi
2 changes: 1 addition & 1 deletion ext/sockets/sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ static PHP_MINIT_FUNCTION(sockets)
REGISTER_LONG_CONSTANT("AI_ALL", AI_ALL, CONST_CS | CONST_PERSISTENT);
#endif
REGISTER_LONG_CONSTANT("AI_ADDRCONFIG", AI_ADDRCONFIG, CONST_CS | CONST_PERSISTENT);
#ifdef __USE_GNU
#if HAVE_AI_IDN
REGISTER_LONG_CONSTANT("AI_IDN", AI_IDN, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("AI_CANONIDN", AI_CANONIDN, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("AI_IDN_ALLOW_UNASSIGNED", AI_IDN_ALLOW_UNASSIGNED, CONST_CS | CONST_PERSISTENT);
Expand Down

0 comments on commit 8489ece

Please sign in to comment.