6936ab407d7124a65d88609fc37c4acac24f5959
[m6w6/libmemcached] / m4 / check_sock_cloexec.m4
1 # Author?
2 # AX_CHECK_SOCK_CLOEXEC([action-if-found], [action-if-not-found])
3 #
4
5 #serial 1
6
7 AC_DEFUN([AX_CHECK_SOCK_CLOEXEC], [
8 AC_CACHE_CHECK([whether SOCK_CLOEXEC is supported], [ax_cv_sock_cloexec], [
9 AC_LANG_PUSH([C])
10 AC_RUN_IFELSE([
11 AC_LANG_PROGRAM([
12
13 /* SOCK_CLOEXEC test */
14 #include <sys/types.h>
15 #include <sys/socket.h>
16
17 ], [
18 int s= socket(PF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0);
19 return (s == -1);
20 ])],
21 [ax_cv_sock_cloexec=yes],
22 [ax_cv_sock_cloexec=no])
23 ])
24
25 AS_IF([test x"ax_cv_sock_cloexec" = xyes], [AC_MSG_RESULT([yes]) ; $1], AC_MSG_RESULT([no]) ; $2)
26 ])