Merge lp:~tangent-org/libmemcached/1.0-build/ Build: jenkins-Libmemcached-187
[m6w6/libmemcached] / m4 / setsockopt.m4
1 dnl ---------------------------------------------------------------------------
2 dnl Macro: SETSOCKOPT_SANITY
3 dnl ---------------------------------------------------------------------------
4 AC_DEFUN([SETSOCKOPT_SANITY],[
5 AC_CACHE_CHECK([for working SO_SNDTIMEO], [ac_cv_have_so_sndtimeo],
6 AC_LANG_PUSH([C])
7 AC_RUN_IFELSE([
8 AC_LANG_PROGRAM([[
9 #include <sys/types.h>
10 #include <sys/socket.h>
11 #include <time.h>
12 #include <sys/time.h>
13 #include <errno.h>
14 ]],[[
15 int sock = socket(AF_INET, SOCK_STREAM, 0);
16 struct timeval waittime;
17
18 waittime.tv_sec= 0;
19 waittime.tv_usec= 500;
20
21 if (setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO,
22 &waittime, (socklen_t)sizeof(struct timeval)) == -1) {
23 if (errno == ENOPROTOOPT) {
24 return 1;
25 }
26 }
27 return 0;
28 ]])],
29 [ac_cv_have_so_sndtimeo=yes],
30 [ac_cv_have_so_sndtimeo=no],
31 [ac_cv_have_so_sndtimeo=yes])
32
33 AS_IF([test "x$ac_cv_have_so_sndtimeo" = "xyes"], [
34 AC_DEFINE(HAVE_SNDTIMEO, 1, [Define to 1 if you have a working SO_SNDTIMEO])])
35 AC_LANG_POP
36 )
37
38 AC_CACHE_CHECK([for working SO_RCVTIMEO], [ac_cv_have_so_rcvtimeo],
39 AC_LANG_PUSH([C])
40 AC_RUN_IFELSE([
41 AC_LANG_PROGRAM([[
42 #include <sys/types.h>
43 #include <sys/socket.h>
44 #include <time.h>
45 #include <sys/time.h>
46 #include <errno.h>
47 ]],[[
48 int sock = socket(AF_INET, SOCK_STREAM, 0);
49 struct timeval waittime;
50
51 waittime.tv_sec= 0;
52 waittime.tv_usec= 500;
53
54 if (setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO,
55 &waittime, (socklen_t)sizeof(struct timeval)) == -1) {
56 if (errno == ENOPROTOOPT) {
57 return 1;
58 }
59 }
60 return 0;
61 ]])],
62 [ac_cv_have_so_rcvtimeo=yes],
63 [ac_cv_have_so_rcvtimeo=no],
64 [ac_cv_have_so_rcvtimeo=yes])
65
66 AS_IF([test "x$ac_cv_have_so_rcvtimeo" = "xyes"], [
67 AC_DEFINE(HAVE_RCVTIMEO, 1, [Define to 1 if you have a working SO_RCVTIMEO])])
68 AC_LANG_POP
69 )
70 ])
71 dnl ---------------------------------------------------------------------------
72 dnl End Macro: SETSOCKOPT_SANITY
73 dnl ---------------------------------------------------------------------------