File: setsockopt.m4

package info (click to toggle)
libmemcached 1.0.8-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 7,912 kB
  • sloc: cpp: 39,309; ansic: 18,449; sh: 11,864; python: 603; yacc: 437; lex: 195; makefile: 116
file content (73 lines) | stat: -rw-r--r-- 2,159 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
dnl ---------------------------------------------------------------------------
dnl Macro: SETSOCKOPT_SANITY
dnl ---------------------------------------------------------------------------
AC_DEFUN([SETSOCKOPT_SANITY],[
  AC_CACHE_CHECK([for working SO_SNDTIMEO], [ac_cv_have_so_sndtimeo],
  AC_LANG_PUSH([C])
  AC_RUN_IFELSE([ 
    AC_LANG_PROGRAM([[
#include <sys/types.h>
#include <sys/socket.h>
#include <time.h>
#include <sys/time.h>
#include <errno.h>
   ]],[[
     int sock = socket(AF_INET, SOCK_STREAM, 0);
     struct timeval waittime;
   
     waittime.tv_sec= 0;
     waittime.tv_usec= 500;
   
     if (setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, 
                    &waittime, (socklen_t)sizeof(struct timeval)) == -1) {
       if (errno == ENOPROTOOPT) {
         return 1;
       }
     }
     return 0;
   ]])],
   [ac_cv_have_so_sndtimeo=yes],
   [ac_cv_have_so_sndtimeo=no],
   [ac_cv_have_so_sndtimeo=yes])

   AS_IF([test "x$ac_cv_have_so_sndtimeo" = "xyes"], [
          AC_DEFINE(HAVE_SNDTIMEO, 1, [Define to 1 if you have a working SO_SNDTIMEO])])
   AC_LANG_POP
   )

  AC_CACHE_CHECK([for working SO_RCVTIMEO], [ac_cv_have_so_rcvtimeo],
  AC_LANG_PUSH([C])
  AC_RUN_IFELSE([ 
    AC_LANG_PROGRAM([[
#include <sys/types.h>
#include <sys/socket.h>
#include <time.h>
#include <sys/time.h>
#include <errno.h>
   ]],[[
     int sock = socket(AF_INET, SOCK_STREAM, 0);
     struct timeval waittime;
   
     waittime.tv_sec= 0;
     waittime.tv_usec= 500;
   
     if (setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, 
                    &waittime, (socklen_t)sizeof(struct timeval)) == -1) {
       if (errno == ENOPROTOOPT) {
         return 1;
       }
     }
     return 0;
   ]])],
   [ac_cv_have_so_rcvtimeo=yes],
   [ac_cv_have_so_rcvtimeo=no],
   [ac_cv_have_so_rcvtimeo=yes])

   AS_IF([test "x$ac_cv_have_so_rcvtimeo" = "xyes"], [
          AC_DEFINE(HAVE_RCVTIMEO, 1, [Define to 1 if you have a working SO_RCVTIMEO])])
   AC_LANG_POP
   )
])
dnl ---------------------------------------------------------------------------
dnl End Macro: SETSOCKOPT_SANITY
dnl ---------------------------------------------------------------------------