summaryrefslogtreecommitdiff
path: root/acinclude.m4
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2006-07-02 23:09:46 +0000
committerYang Tse <yangsita@gmail.com>2006-07-02 23:09:46 +0000
commit054c5cf04b2dd04055dd766b0cbd2b982753456a (patch)
tree2bce3093e1d75b3ed12a93250116036926949176 /acinclude.m4
parentbdf1485cf9cc994350fe89a3d6a78b95af46794f (diff)
downloadc-ares-054c5cf04b2dd04055dd766b0cbd2b982753456a.tar.gz
c-ares-054c5cf04b2dd04055dd766b0cbd2b982753456a.tar.bz2
c-ares-054c5cf04b2dd04055dd766b0cbd2b982753456a.zip
Make CURL_CHECK_NI_WITHSCOPEID actually try to compile NI_WITHSCOPEID when cross-compiling.
Diffstat (limited to 'acinclude.m4')
-rw-r--r--acinclude.m473
1 files changed, 73 insertions, 0 deletions
diff --git a/acinclude.m4 b/acinclude.m4
index 96e0a17..dba89de 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -401,6 +401,79 @@ AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
]) # AC_DEFUN
+dnl CURL_CHECK_NI_WITHSCOPEID
+dnl -------------------------------------------------
+dnl Check for working NI_WITHSCOPEID in getnameinfo()
+
+AC_DEFUN([CURL_CHECK_NI_WITHSCOPEID], [
+ AC_CACHE_CHECK([for working NI_WITHSCOPEID],
+ [ac_cv_working_ni_withscopeid], [
+ AC_RUN_IFELSE([
+ AC_LANG_PROGRAM([
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.h>
+ ],[
+#ifdef NI_WITHSCOPEID
+ struct sockaddr_storage ss;
+ int sslen = sizeof(ss);
+ int rc;
+ char hbuf[NI_MAXHOST];
+ int fd = socket(AF_INET6, SOCK_STREAM, 0);
+ if(fd < 0) {
+ perror("socket()");
+ return 1; /* Error creating socket */
+ }
+ rc = getsockname(fd, (struct sockaddr *)&ss, &sslen);
+ if(rc) {
+ perror("getsockname()");
+ return 2; /* Error retrieving socket name */
+ }
+ rc = getnameinfo((struct sockaddr *)&ss, sslen, hbuf, sizeof(hbuf),
+ NULL, 0,
+ NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID);
+ if(rc) {
+ printf("rc = %s\n", gai_strerror(rc));
+ return 3; /* Error translating socket address */
+ }
+ return 0; /* Ok, NI_WITHSCOPEID works */
+#else
+ return 4; /* Error, NI_WITHSCOPEID not defined */
+#endif
+ ]) # AC_LANG_PROGRAM
+ ],[
+ # Exit code == 0. Program worked.
+ ac_cv_working_ni_withscopeid="yes"
+ ],[
+ # Exit code != 0. Program failed.
+ ac_cv_working_ni_withscopeid="no"
+ ],[
+ # Program is not run when cross-compiling. So we assume
+ # NI_WITHSCOPEID will work if we are able to compile it.
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.h>
+ ],[
+ unsigned int dummy= NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
+ ])
+ ],[
+ ac_cv_working_ni_withscopeid="yes"
+ ],[
+ ac_cv_working_ni_withscopeid="no"
+ ]) # AC_COMPILE_IFELSE
+ ]) # AC_RUN_IFELSE
+ ]) # AC_CACHE_CHECK
+ if test "x$ac_cv_working_ni_withscopeid" = "xyes"; then
+ AC_DEFINE(HAVE_NI_WITHSCOPEID, 1,
+ [Define to 1 if NI_WITHSCOPEID exists and works.])
+ fi
+]) # AC_DEFUN
+
+
dnl CURL_CHECK_NONBLOCKING_SOCKET
dnl -------------------------------------------------
dnl Check for how to set a socket to non-blocking state. There seems to exist