Merge Trond
authorBrian Aker <brian@gaz>
Mon, 2 Aug 2010 18:33:16 +0000 (11:33 -0700)
committerBrian Aker <brian@gaz>
Mon, 2 Aug 2010 18:33:16 +0000 (11:33 -0700)
.bzrignore
configure.ac
libmemcached/protocol/ascii_handler.c
m4/byteorder.m4
m4/eagain.m4 [new file with mode: 0644]
m4/protocol_binary.m4
m4/setsockopt.m4
win32/wrappers.h

index f428ca6793ba5c8f2ae714d0416e1e74148adfce..0579973b5a51dab19ceb5bba9c5fb5460061b21e 100644 (file)
@@ -1,3 +1,4 @@
+*.exe
 *.lo
 *.pop
 */*.l[oa]
index 0a2df059dc1e93bea10eb6c73e671c9353d061b4..a2faafd6d845a3b05d822b853364566fbf75dd67 100644 (file)
@@ -139,26 +139,11 @@ AC_CHECK_HEADERS_ONCE(winsock2.h poll.h sys/wait.h fnmatch.h)
 AM_CONDITIONAL(BUILD_POLL, test "x$ac_cv_header_poll_h" = "xno")
 AM_CONDITIONAL(BUILD_WIN32_WRAPPERS, test "x$ac_cv_header_winsock2_h" = "xyes")
 AS_IF(test "x$ac_cv_header_winsock2_h" = "xyes",
-      AM_LDFLAGS="$AM_LDFLAGS -lws2_32")
-
-#
-# Some platforms define EWOULDBLOCK == EAGAIN, causing our switch for error
-# codes to be illegal (POSIX.1-2001 allows both return codes from recv, so
-# we need to test both if they differ...)
-#
-AC_MSG_CHECKING([if EWOULDBLOCK == EAGAIN])
-AC_RUN_IFELSE(
-  [AC_LANG_PROGRAM([
-#include <errno.h>
-     ], [dnl
-   return EAGAIN == EWOULDBLOCK ? 0 : 1;
-     ])
-  ],[
-   AC_MSG_RESULT([yes])
-  ], [
-   AC_MSG_RESULT([no])
-   AC_DEFINE([USE_EAGAIN], [1], [Define to true if you need to test for eagain])
-  ])
+      [AM_LDFLAGS="$AM_LDFLAGS -lws2_32"
+       AM_CFLAGS="$AM_CFLAGS $NO_WERROR"
+       AM_CXXFLAGS="$AM_CXXFLAGS $NO_WERROR"
+      ])
+DETECT_EAGAIN
 
 AC_CONFIG_FILES([
   Makefile
index 6f5102b00badaf36c87a6b60c7ffe4b76163b49e..87a0edb1b971c7de14d9f756a183329d11a78635 100644 (file)
@@ -146,8 +146,8 @@ ascii_get_response_handler(const void *cookie,
 
   if (client->ascii_command == GETS_CMD)
   {
-    snprintf(dest, sizeof(buffer) - used, " %u %u %llu\r\n", flags,
-             bodylen, (unsigned long long)cas);
+    snprintf(dest, sizeof(buffer) - used, " %u %u %" PRIu64 "\r\n", flags,
+             bodylen, cas);
   }
   else
   {
@@ -440,8 +440,7 @@ static void process_arithmetic(memcached_protocol_client_st *client,
   if (rval == PROTOCOL_BINARY_RESPONSE_SUCCESS)
   {
     char buffer[80];
-    snprintf(buffer, sizeof(buffer), "%llu\r\n",
-             (unsigned long long)result);
+    snprintf(buffer, sizeof(buffer), "%"PRIu64"\r\n", result);
     spool_string(client, buffer);
   }
   else
index 4692bbd205c44a9fe3719e4a534169272b10de15..324317989470d443acb663e2344cb6bd9107ea1c 100644 (file)
@@ -1,25 +1,19 @@
 AC_DEFUN([DETECT_BYTEORDER],
 [
     AC_REQUIRE([AC_C_BIGENDIAN])
-    AC_CACHE_CHECK([for htonll],[av_cv_have_htonll],[
-
-    AC_RUN_IFELSE([
-       AC_LANG_PROGRAM([[
+    AC_CACHE_CHECK([for htonll], [ac_cv_have_htonll],
+        [AC_TRY_LINK([
 #include <sys/types.h>
 #include <netinet/in.h>
 #include <inttypes.h>
-       ]],[[
-          return htonll(0);
-       ]])            
-    ], [
-      ac_cv_have_htonll=yes
-    ],[
-      ac_cv_have_htonll=no
-    ])])
-
+                        ], [
+return htonll(0);
+                        ],
+                        [ ac_cv_have_htonll=yes ],
+                        [ ac_cv_have_htonll=no ])
+        ])
     AS_IF([test "x$ac_cv_have_htonll" = "xyes"],[
-      AC_DEFINE([HAVE_HTONLL], [1], [Have ntohll])])
+          AC_DEFINE([HAVE_HTONLL], [1], [Have ntohll])])
 
     AM_CONDITIONAL([BUILD_BYTEORDER],[test "x$ac_cv_have_htonll" = "xno"])
 ])
-
diff --git a/m4/eagain.m4 b/m4/eagain.m4
new file mode 100644 (file)
index 0000000..3ba8c23
--- /dev/null
@@ -0,0 +1,28 @@
+#
+# Some platforms define EWOULDBLOCK == EAGAIN, causing our switch for error
+# codes to be illegal (POSIX.1-2001 allows both return codes from recv, so
+# we need to test both if they differ...)
+#
+AC_DEFUN([DETECT_EAGAIN],
+[
+    AC_CACHE_CHECK([if EWOULDBLOCK == EAGAIN],[av_cv_eagain_ewouldblock],
+        [AC_TRY_COMPILE([
+#include <errno.h>
+                        ], [
+int error = EAGAIN;
+switch (error) 
+{
+  case EAGAIN:
+  case EWOULDBLOCK:
+       error = 1;
+       break;
+  default:
+       error = 0;
+}
+                        ],
+                        [ av_cv_eagain_ewouldblock=no ],
+                        [ av_cv_eagain_ewouldblock=yes ])
+        ])
+    AS_IF([test "x$ac_cv_eagain_ewouldblock" = "xyes"],[
+          AC_DEFINE([USE_EAGAIN], [1], [Define to true if you need to test for eagain])])
+])
index ba7acaf5f52d01ceaf2a113ba54dbd2860ba3956..5c00b5563ac3c0af118d1c720e7f4e87a0cb78fd 100644 (file)
@@ -1,22 +1,34 @@
 dnl ---------------------------------------------------------------------------
 dnl Macro: PROTOCOL_BINARY_TEST
 dnl ---------------------------------------------------------------------------
+
 AC_DEFUN([PROTOCOL_BINARY_TEST],
-  [AC_LANG_PUSH([C])
-   save_CFLAGS="$CFLAGS"
-   CFLAGS="$CFLAGS -I${srcdir}"
-   AC_RUN_IFELSE([
-      AC_LANG_PROGRAM([[
+[
+  AC_CACHE_CHECK([for supported struct padding], [ac_cv_supported_struct_padding], [
+    AC_LANG_PUSH([C])
+    save_CFLAGS="$CFLAGS"
+    CFLAGS="$CFLAGS -I${srcdir}"
+    AC_TRY_COMPILE([
 #include <inttypes.h>
 #include "libmemcached/memcached/protocol_binary.h"
-   ]],[[
+                   ], [
       protocol_binary_request_set request;
-      if (sizeof(request) != sizeof(request.bytes)) {
-         return 1;
+      int a = 1;
+      switch (a) {
+      case sizeof(request):
+      case sizeof(request.bytes):
+          break;
+      default:
+          a = 2;
       }
-   ]])],, AC_MSG_ERROR([Unsupported struct padding done by compiler.]))
+                   ],
+                   [ ac_cv_supported_struct_padding=no ],
+                   [ ac_cv_supported_struct_padding=yes ])
    CFLAGS="$save_CFLAGS"
    AC_LANG_POP
+  ])
+  AS_IF([test "x$ac_cv_supported_struct_padding" = "xno"],[
+        AC_MSG_ERROR([Unsupported struct padding done by compiler.])])
 ])
 
 dnl ---------------------------------------------------------------------------
index e37fe2ae7c0e9b0df3e3d2081af6dc1bea628ca7..58c61c0ab9fa4c6a0e63989a14b8229988be6786 100644 (file)
@@ -2,6 +2,7 @@ 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([[
@@ -25,8 +26,17 @@ AC_DEFUN([SETSOCKOPT_SANITY],[
      }
      return 0;
    ]])],
-   [AC_DEFINE(HAVE_SNDTIMEO, 1, [Define to 1 if you have a working SO_SNDTIMEO])]) 
+   [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>
@@ -34,7 +44,7 @@ AC_DEFUN([SETSOCKOPT_SANITY],[
 #include <time.h>
 #include <sys/time.h>
 #include <errno.h>
-    ]],[[
+   ]],[[
      int sock = socket(AF_INET, SOCK_STREAM, 0);
      struct timeval waittime;
    
@@ -48,9 +58,15 @@ AC_DEFUN([SETSOCKOPT_SANITY],[
        }
      }
      return 0;
-   ]])], [AC_DEFINE(HAVE_RCVTIMEO, 1, [Define to 1 if you have a working SO_RCVTIMEO])]) 
+   ]])],
+   [ac_cv_have_so_rcvtimeo=yes],
+   [ac_cv_have_so_rcvtimeo=no],
+   [ac_cv_have_so_rcvtimeo=yes])
 
-  AC_LANG_POP
+   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
index 20218fd58174d24b457c67d885156ddae05727ae..80b44651c4b29aa8162f8d48a3f982a442077c41 100644 (file)
@@ -12,6 +12,8 @@
 #ifndef WIN32_WRAPPERS_H
 #define WIN32_WRAPPERS_H 1
 
+#include <inttypes.h>
+
 /*
  * One of the Windows headers define interface as a macro, but that
  * is causing problems with the member named "interface" in some of the
  */
 #undef interface
 
+#undef malloc
+#undef realloc
+
+
 /*
  * WinSock use a separate range for error codes. Let's just map to the
  * WinSock ones.