Merge in trunk
authorBrian Aker <brian@tangent.org>
Sun, 29 Jan 2012 12:39:51 +0000 (04:39 -0800)
committerBrian Aker <brian@tangent.org>
Sun, 29 Jan 2012 12:39:51 +0000 (04:39 -0800)
20 files changed:
clients/memcapable.cc
config/autorun.sh
configure.ac
example/memcached_light.c
libmemcached-1.0/memcached.h
libmemcached/close_socket.hpp [deleted file]
libmemcached/common.h
libmemcached/connect.cc
libmemcached/include.am
libmemcached/io.cc
libmemcached/socket.hpp [new file with mode: 0644]
libmemcachedprotocol/cache.c
libmemcachedprotocol/common.h
libtest/memcached.cc
m4/ax_tls.m4 [deleted file]
m4/bottom.m4
m4/eagain.m4 [deleted file]
m4/have_cstdint.m4 [new file with mode: 0644]
m4/pkg.m4
m4/socket_send_flags.m4

index 8bce153a555e44ffa9136d5c8e30f7a6194025bb..9bd310c524dd563c482ecaa3f7a200c8c8de3637 100644 (file)
@@ -34,7 +34,7 @@
 #include <unistd.h>
 
 #include <libmemcached-1.0/memcached.h>
-#include <libmemcached/close_socket.hpp>
+#include <libmemcached/socket.hpp>
 #include <libmemcached/memcached/protocol_binary.h>
 #include <libmemcached/byteorder.h>
 #include <clients/utilities.h>
index febee48a52db13c6e04812f7fcbcc3f8121fd047..62ad34d1d6aa68be6ed4cfb4097680c277a3fd04 100755 (executable)
@@ -1,2 +1,28 @@
 #!/bin/sh
+#  Copyright (C) 2011 Brian Aker
+#  All rights reserved.
+# 
+#  Redistribution and use in source and binary forms, with or without
+#  modification, are permitted provided that the following conditions are met:
+# 
+#  1. Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+#  2. Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in the
+#     documentation and/or other materials provided with the distribution.
+#  3. The name of the author may not be used to endorse or promote products
+#     derived from this software without specific prior written permission.
+# 
+#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+#  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+#  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+#  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+#  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+#  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+#  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+#  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+#  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+#  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+#  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
 autoreconf --install --force --verbose -Wall
index aa79d138301a81d382de1673bb545da0e6236e94..a7f4a30634d616e9aebc2eacee4fb4222a7cbf23 100644 (file)
@@ -85,6 +85,7 @@ case "$target_os" in
 
 dnl Specialty checks
 AX_PTHREAD
+AX_CXX_CSTDINT
 CONFIG_EXTRA
 DETECT_BYTEORDER
 ENABLE_UTILLIB
@@ -134,7 +135,6 @@ AC_CHECK_HEADERS([cxxabi.h],
 
 AX_COMPILER_VENDOR
 AC_CXX_HEADER_STDCXX_98
-AX_TLS
 
 AC_FUNC_ALLOCA
 AC_FUNC_ERROR_AT_LINE
@@ -203,7 +203,6 @@ AS_IF(test "x$ac_cv_header_winsock2_h" = "xyes",
        AM_CFLAGS="$AM_CFLAGS $NO_WERROR"
        AM_CXXFLAGS="$AM_CXXFLAGS $NO_WERROR"
       ])
-DETECT_EAGAIN
 SOCKET_SEND_FLAGS
 
 AC_CONFIG_FILES([
index 1827437857bdfd144705223bb5581f3a5e0d22bc..c064e5199efff18a16635bbc07f477d6e9e78743 100644 (file)
@@ -35,7 +35,7 @@
 #include <event.h>
 
 #include <libmemcachedprotocol-0.0/handler.h>
-#include <libmemcached/close_socket.hpp>
+#include <libmemcached/socket.hpp>
 #include <example/byteorder.h>
 #include "example/storage.h"
 #include "example/memcached_light.h"
index fba30674192dbc3c251c2892117817a046968055..b1279e5cd1151c22f20efdc6366c93811fc02e95 100644 (file)
 #pragma once
 
 #include <inttypes.h>
+
+#ifdef __cplusplus
+#include <cstddef>
+#include <cstdlib>
+#else
+#include <stddef.h>
 #include <stdlib.h>
+#endif
+
 #include <sys/types.h>
 
 
diff --git a/libmemcached/close_socket.hpp b/libmemcached/close_socket.hpp
deleted file mode 100644 (file)
index 0d18857..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
- * 
- *  LibMemcached
- *
- *  Copyright (C) 2011 Data Differential, http://datadifferential.com/
- *  Copyright (C) 2006-2009 Brian Aker
- *  All rights reserved.
- *
- *  Redistribution and use in source and binary forms, with or without
- *  modification, are permitted provided that the following conditions are
- *  met:
- *
- *      * Redistributions of source code must retain the above copyright
- *  notice, this list of conditions and the following disclaimer.
- *
- *      * Redistributions in binary form must reproduce the above
- *  copyright notice, this list of conditions and the following disclaimer
- *  in the documentation and/or other materials provided with the
- *  distribution.
- *
- *      * The names of its contributors may not be used to endorse or
- *  promote products derived from this software without specific prior
- *  written permission.
- *
- *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#pragma once
-
-
-/* To hide the platform differences between MS Windows and Unix, I am
- * going to use the Microsoft way and #define the Microsoft-specific
- * functions to the unix way. Microsoft use a separate subsystem for sockets,
- * but Unix normally just use a filedescriptor on the same functions. It is
- * a lot easier to map back to the unix way with macros than going the other
- * way without side effect ;-)
- */
-#ifdef WIN32
-#include "win32/wrappers.h"
-#define get_socket_errno() WSAGetLastError()
-#else
-#define INVALID_SOCKET -1
-#define SOCKET_ERROR -1
-#define closesocket(a) close(a)
-#define get_socket_errno() errno
-#endif
-
-#ifdef __cplusplus
-static inline void memcached_close_socket(int& socket_fd)
-{
-  closesocket(socket_fd);
-  socket_fd= INVALID_SOCKET;
-}
-#endif
-
-#ifndef HAVE_MSG_NOSIGNAL
-#define MSG_NOSIGNAL 0
-#endif
-
-#ifndef HAVE_MSG_DONTWAIT
-#define MSG_DONTWAIT 0
-#endif
-
-#ifndef HAVE_MSG_MORE
-#define MSG_MORE 0
-#endif
-
-
index 53481880d7cc5281b414c57016a060d7fe236c57..d239d264c06a67d2eb57da17c6f0aef9ebacd581 100644 (file)
@@ -107,7 +107,7 @@ memcached_return_t memcached_server_execute(memcached_st *ptr,
 #include <libmemcached/io.hpp>
 #include <libmemcached/udp.hpp>
 #include <libmemcached/do.hpp>
-#include <libmemcached/close_socket.hpp>
+#include <libmemcached/socket.hpp>
 #include <libmemcached/connect.hpp>
 #include <libmemcached/allocators.hpp>
 #include <libmemcached/hash.hpp>
index 1c7da46547ad910aaf44d18d8e7373f6b0d08221..8434ba8b3a5f675ab0314c887aaee3db4d2c7705 100644 (file)
@@ -479,7 +479,10 @@ static memcached_return_t network_connect(memcached_server_st *server)
       timeout_error_occured= true;
       break;
 
+    case EAGAIN:
+#if EWOULDBLOCK != EAGAIN
     case EWOULDBLOCK:
+#endif
     case EINPROGRESS: // nonblocking mode - first return
     case EALREADY: // nonblocking mode - subsequent returns
       {
index a10b92a5aa5363fcaeb67b252824d98c37834ba2..24d9598215ce303ab4bf10a0e1353a231013540e 100644 (file)
@@ -20,7 +20,6 @@ noinst_HEADERS+= \
                 libmemcached/assert.hpp \
                 libmemcached/backtrace.hpp \
                 libmemcached/byteorder.h \
-                libmemcached/close_socket.hpp \
                 libmemcached/common.h \
                 libmemcached/connect.hpp \
                 libmemcached/continuum.hpp \
@@ -41,6 +40,7 @@ noinst_HEADERS+= \
                 libmemcached/response.h \
                 libmemcached/server.hpp \
                 libmemcached/server_instance.h \
+                libmemcached/socket.hpp \
                 libmemcached/string.hpp \
                 libmemcached/udp.hpp \
                 libmemcached/virtual_bucket.h \
index 8b297a7acaed71215d0c9624f632f91c4909bf7f..fbfb8555e975cb6d164b3b6ba1f5ac4cc7ca6a79 100644 (file)
@@ -81,10 +81,10 @@ static bool repack_input_buffer(memcached_server_write_instance_st ptr)
           case EINTR:
             continue;
 
+#if EWOULDBLOCK != EAGAIN
           case EWOULDBLOCK:
-#ifdef USE_EAGAIN
-          case EAGAIN:
 #endif
+          case EAGAIN:
 #ifdef TARGET_OS_LINUX
           case ERESTART:
 #endif
@@ -327,10 +327,11 @@ static bool io_flush(memcached_server_write_instance_st ptr,
       {
       case ENOBUFS:
         continue;
+
+#if EWOULDBLOCK != EAGAIN
       case EWOULDBLOCK:
-#ifdef USE_EAGAIN
-      case EAGAIN:
 #endif
+      case EAGAIN:
         {
           /*
            * We may be blocked on write because the input buffer
@@ -416,10 +417,10 @@ memcached_return_t memcached_io_read(memcached_server_write_instance_st ptr,
             continue;
 
           case ETIMEDOUT: // OSX
+#if EWOULDBLOCK != EAGAIN
           case EWOULDBLOCK:
-#ifdef USE_EAGAIN
-          case EAGAIN:
 #endif
+          case EAGAIN:
 #ifdef TARGET_OS_LINUX
           case ERESTART:
 #endif
@@ -524,10 +525,10 @@ memcached_return_t memcached_io_slurp(memcached_server_write_instance_st ptr)
         continue;
 
       case ETIMEDOUT: // OSX
+#if EWOULDBLOCK != EAGAIN
       case EWOULDBLOCK:
-#ifdef USE_EAGAIN
-      case EAGAIN:
 #endif
+      case EAGAIN:
 #ifdef TARGET_OS_LINUX
       case ERESTART:
 #endif
diff --git a/libmemcached/socket.hpp b/libmemcached/socket.hpp
new file mode 100644 (file)
index 0000000..0d18857
--- /dev/null
@@ -0,0 +1,79 @@
+/*  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ * 
+ *  LibMemcached
+ *
+ *  Copyright (C) 2011 Data Differential, http://datadifferential.com/
+ *  Copyright (C) 2006-2009 Brian Aker
+ *  All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are
+ *  met:
+ *
+ *      * Redistributions of source code must retain the above copyright
+ *  notice, this list of conditions and the following disclaimer.
+ *
+ *      * Redistributions in binary form must reproduce the above
+ *  copyright notice, this list of conditions and the following disclaimer
+ *  in the documentation and/or other materials provided with the
+ *  distribution.
+ *
+ *      * The names of its contributors may not be used to endorse or
+ *  promote products derived from this software without specific prior
+ *  written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#pragma once
+
+
+/* To hide the platform differences between MS Windows and Unix, I am
+ * going to use the Microsoft way and #define the Microsoft-specific
+ * functions to the unix way. Microsoft use a separate subsystem for sockets,
+ * but Unix normally just use a filedescriptor on the same functions. It is
+ * a lot easier to map back to the unix way with macros than going the other
+ * way without side effect ;-)
+ */
+#ifdef WIN32
+#include "win32/wrappers.h"
+#define get_socket_errno() WSAGetLastError()
+#else
+#define INVALID_SOCKET -1
+#define SOCKET_ERROR -1
+#define closesocket(a) close(a)
+#define get_socket_errno() errno
+#endif
+
+#ifdef __cplusplus
+static inline void memcached_close_socket(int& socket_fd)
+{
+  closesocket(socket_fd);
+  socket_fd= INVALID_SOCKET;
+}
+#endif
+
+#ifndef HAVE_MSG_NOSIGNAL
+#define MSG_NOSIGNAL 0
+#endif
+
+#ifndef HAVE_MSG_DONTWAIT
+#define MSG_DONTWAIT 0
+#endif
+
+#ifndef HAVE_MSG_MORE
+#define MSG_MORE 0
+#endif
+
+
index ed669f4fc8ac82511717eab73ea249a66cee3faf..6240be7d1ede1ab182c1c57a04e7ee1ec9694e1c 100644 (file)
@@ -35,6 +35,8 @@
  */
 
 /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
+#include "config.h"
+
 #include <stdlib.h>
 #include <string.h>
 #include <inttypes.h>
index 2e3e7c6d2072691daa0b3eecdb9fd81728128870..ea94a8d7e281ff71c0a23f2a304c8658f56a7232 100644 (file)
 #pragma once
 
 #include "config.h"
-#if !defined(__cplusplus)
-# include <stdbool.h>
-#endif
 #include <assert.h>
 
 #include <libmemcachedprotocol-0.0/handler.h>
 #include <libmemcachedprotocol/cache.h>
 #include <libmemcached/byteorder.h>
-#include <libmemcached/close_socket.hpp>
+#include <libmemcached/socket.hpp>
 
 /*
  * I don't really need the following two functions as function pointers
index 05f43975c2c9134a2f41f86ee92fedbcecaa2583..fc7a37c693bafa2a1af53405d017a89b4c315a81 100644 (file)
@@ -98,7 +98,12 @@ public:
     memcached_return_t rc= MEMCACHED_SUCCESS;
     if (has_socket())
     {
-      local_pid= libmemcached_util_getpid(socket().c_str(), 0, &rc);
+      if (socket().empty())
+      {
+        return -1;
+      }
+
+      local_pid= libmemcached_util_getpid(socket().c_str(), port(), &rc);
     }
     else
     {
diff --git a/m4/ax_tls.m4 b/m4/ax_tls.m4
deleted file mode 100644 (file)
index 033e3b1..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-# ===========================================================================
-#          http://www.gnu.org/software/autoconf-archive/ax_tls.html
-# ===========================================================================
-#
-# SYNOPSIS
-#
-#   AX_TLS([action-if-found], [action-if-not-found])
-#
-# DESCRIPTION
-#
-#   Provides a test for the compiler support of thread local storage (TLS)
-#   extensions. Defines TLS if it is found. Currently knows about GCC/ICC
-#   and MSVC. I think SunPro uses the same as GCC, and Borland apparently
-#   supports either.
-#
-# LICENSE
-#
-#   Copyright (c) 2008 Alan Woodland <ajw05@aber.ac.uk>
-#   Copyright (c) 2010 Diego Elio Petteno` <flameeyes@gmail.com>
-#
-#   This program is free software: you can redistribute it and/or modify it
-#   under the terms of the GNU General Public License as published by the
-#   Free Software Foundation, either version 3 of the License, or (at your
-#   option) any later version.
-#
-#   This program is distributed in the hope that it will be useful, but
-#   WITHOUT ANY WARRANTY; without even the implied warranty of
-#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
-#   Public License for more details.
-#
-#   You should have received a copy of the GNU General Public License along
-#   with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-#   As a special exception, the respective Autoconf Macro's copyright owner
-#   gives unlimited permission to copy, distribute and modify the configure
-#   scripts that are the output of Autoconf when processing the Macro. You
-#   need not follow the terms of the GNU General Public License when using
-#   or distributing such scripts, even though portions of the text of the
-#   Macro appear in them. The GNU General Public License (GPL) does govern
-#   all other use of the material that constitutes the Autoconf Macro.
-#
-#   This special exception to the GPL applies to versions of the Autoconf
-#   Macro released by the Autoconf Archive. When you make and distribute a
-#   modified version of the Autoconf Macro, you may extend this special
-#   exception to the GPL to apply to your modified version as well.
-
-#serial 10
-
-AC_DEFUN([AX_TLS], [
-  AC_MSG_CHECKING(for thread local storage (TLS) class)
-  AC_CACHE_VAL(ac_cv_tls, [
-    ax_tls_keywords="__thread __declspec(thread) none"
-    for ax_tls_keyword in $ax_tls_keywords; do
-       AS_CASE([$ax_tls_keyword],
-          [none], [ac_cv_tls=none ; break],
-          [AC_TRY_COMPILE(
-              [#include <stdlib.h>
-               static void
-               foo(void) {
-               static ] $ax_tls_keyword [ int bar;
-               exit(1);
-               }],
-               [],
-               [ac_cv_tls=$ax_tls_keyword ; break],
-               ac_cv_tls=none
-           )])
-    done
-  ])
-  AC_MSG_RESULT($ac_cv_tls)
-
-  AS_IF([test "$ac_cv_tls" != "none"],
-    AC_DEFINE_UNQUOTED([TLS], $ac_cv_tls, [If the compiler supports a TLS storage class define it to that here])
-      m4_ifnblank([$1], [$1]),
-    m4_ifnblank([$2], [$2])
-  )
-])
index 55591be4fe117b8267897223af5ad1c9b1662d06..289c299413493626f8c28203b43c286a2efff528 100644 (file)
@@ -1,5 +1,15 @@
 AC_DEFUN([CONFIG_EXTRA], [
 
+AH_TOP([
+#pragma once
+
+/* _SYS_FEATURE_TESTS_H is Solaris, _FEATURES_H is GCC */
+#if defined( _SYS_FEATURE_TESTS_H) || defined(_FEATURES_H)
+#error "You should include config.h as your first include file"
+#endif
+
+])
+
 AH_BOTTOM([
 
 #if defined(__cplusplus) 
@@ -17,39 +27,4 @@ typedef unsigned long int ulong;
 
 ])
 
-AH_BOTTOM([
-#ifdef WIN32
-#define _WIN32_WINNT 0x0501
-#endif
-
-/* To hide the platform differences between MS Windows and Unix, I am
- * going to use the Microsoft way and #define the Microsoft-specific
- * functions to the unix way. Microsoft use a separate subsystem for sockets,
- * but Unix normally just use a filedescriptor on the same functions. It is
- * a lot easier to map back to the unix way with macros than going the other
- * way without side effect ;-)
- */
-#ifdef WIN32
-#include "win32/wrappers.h"
-#define get_socket_errno() WSAGetLastError()
-#else
-#define INVALID_SOCKET -1
-#define SOCKET_ERROR -1
-#define closesocket(a) close(a)
-#define get_socket_errno() errno
-#endif
-
-#ifndef HAVE_MSG_NOSIGNAL
-#define MSG_NOSIGNAL 0
-#endif
-
-#ifndef HAVE_MSG_DONTWAIT
-#define MSG_DONTWAIT 0
-#endif
-
-#ifndef HAVE_MSG_MORE
-#define MSG_MORE 0
-#endif
-
-])
 ])dnl CONFIG_EXTRA
diff --git a/m4/eagain.m4 b/m4/eagain.m4
deleted file mode 100644 (file)
index cd9e431..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# 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$av_cv_eagain_ewouldblock" = "xno"],[
-          AC_DEFINE([USE_EAGAIN], [1], [Define to true if you need to test for eagain])])
-])
diff --git a/m4/have_cstdint.m4 b/m4/have_cstdint.m4
new file mode 100644 (file)
index 0000000..ef08435
--- /dev/null
@@ -0,0 +1,89 @@
+# ===========================================================================
+#     http://tangent.org/
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_CXX_CSTDINT
+#
+# DESCRIPTION
+#
+#  Example:
+#
+# LICENSE
+#
+#   Copyright (c) 2012 Brian Aker` <brian@tangent.org>
+#
+#   This program is free software: you can redistribute it and/or modify it
+#   under the terms of the GNU General Public License as published by the
+#   Free Software Foundation, either version 3 of the License, or (at your
+#   option) any later version.
+#
+#   This program is distributed in the hope that it will be useful, but
+#   WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+#   Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License along
+#   with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+#   As a special exception, the respective Autoconf Macro's copyright owner
+#   gives unlimited permission to copy, distribute and modify the configure
+#   scripts that are the output of Autoconf when processing the Macro. You
+#   need not follow the terms of the GNU General Public License when using
+#   or distributing such scripts, even though portions of the text of the
+#   Macro appear in them. The GNU General Public License (GPL) does govern
+#   all other use of the material that constitutes the Autoconf Macro.
+#
+#   This special exception to the GPL applies to versions of the Autoconf
+#   Macro released by the Autoconf Archive. When you make and distribute a
+#   modified version of the Autoconf Macro, you may extend this special
+#   exception to the GPL to apply to your modified version as well.
+
+#serial 1
+
+
+AC_DEFUN([AX_CXX_CSTDINT],
+    [
+    AC_REQUIRE([AC_PROG_CXX])
+    AC_REQUIRE([AC_PROG_CXXCPP])
+
+    AC_MSG_CHECKING(the location of cstdint)
+    AC_LANG_PUSH([C++])
+    save_CXXFLAGS="${CXXFLAGS}"
+    CXXFLAGS="${CXX_STANDARD} ${CXXFLAGS}"
+    ac_cv_cxx_cstdint=""
+
+    AC_LANG_PUSH([C++])
+#    AC_CACHE_CHECK([for location of cstdint], [ac_cv_cxx_cstdint],
+#      [
+# Look for cstdint
+      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <cstdint>], [ uint32_t t ])],
+        [ac_cv_cxx_cstdint="<cstdint>"],
+        [
+# Look for tr1/cstdint
+        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <tr1/cstdint>], [ uint32_t t ])],
+          [ac_cv_cxx_cstdint="<tr1/cstdint>"],
+          [
+# Look for boost/cstdint.hpp
+          AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <boost/cstdint.hpp>], [ uint32_t t ])],
+            [ac_cv_cxx_cstdint="<boost/cstdint.hpp>"])
+
+          ])
+        ])
+#      ])
+
+  AC_LANG_POP()
+
+  CXXFLAGS="${save_CXXFLAGS}"
+  if test -n "$ac_cv_cxx_cstdint"; then
+    AC_MSG_RESULT([$ac_cv_cxx_cstdint])
+  else
+    ac_cv_cxx_cstdint="<stdint.h>"
+    AC_MSG_WARN([Could not find a cstdint header.])
+    AC_MSG_RESULT([$ac_cv_cxx_cstdint])
+  fi
+
+  AC_DEFINE_UNQUOTED(CSTDINT_H,$ac_cv_cxx_cstdint, [the location of <cstdint>])
+
+  ])
index 0048a3fa0547ad4d0cb04bd961609b5a44c01697..73973f74898b6738ff31f916c61ee1bce2daa427 100644 (file)
--- a/m4/pkg.m4
+++ b/m4/pkg.m4
@@ -1,4 +1,5 @@
 # pkg.m4 - Macros to locate and utilise pkg-config.            -*- Autoconf -*-
+# serial 1 (pkg-config-0.24)
 # 
 # Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
 #
 AC_DEFUN([PKG_PROG_PKG_CONFIG],
 [m4_pattern_forbid([^_?PKG_[A-Z_]+$])
 m4_pattern_allow([^PKG_CONFIG(_PATH)?$])
-AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl
+AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
+AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
+AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
+
 if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
        AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
 fi
@@ -39,7 +43,6 @@ if test -n "$PKG_CONFIG"; then
                AC_MSG_RESULT([no])
                PKG_CONFIG=""
        fi
-               
 fi[]dnl
 ])# PKG_PROG_PKG_CONFIG
 
@@ -48,34 +51,31 @@ fi[]dnl
 # Check to see whether a particular set of modules exists.  Similar
 # to PKG_CHECK_MODULES(), but does not set variables or print errors.
 #
-#
-# Similar to PKG_CHECK_MODULES, make sure that the first instance of
-# this or PKG_CHECK_MODULES is called, or make sure to call
-# PKG_CHECK_EXISTS manually
+# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+# only at the first occurence in configure.ac, so if the first place
+# it's called might be skipped (such as if it is within an "if", you
+# have to call PKG_CHECK_EXISTS manually
 # --------------------------------------------------------------
 AC_DEFUN([PKG_CHECK_EXISTS],
 [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
 if test -n "$PKG_CONFIG" && \
     AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
-  m4_ifval([$2], [$2], [:])
+  m4_default([$2], [:])
 m4_ifvaln([$3], [else
   $3])dnl
 fi])
 
-
 # _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
 # ---------------------------------------------
 m4_define([_PKG_CONFIG],
-[if test -n "$PKG_CONFIG"; then
-    if test -n "$$1"; then
-        pkg_cv_[]$1="$$1"
-    else
-        PKG_CHECK_EXISTS([$3],
-                         [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`],
-                        [pkg_failed=yes])
-    fi
-else
-       pkg_failed=untried
+[if test -n "$$1"; then
+    pkg_cv_[]$1="$$1"
+ elif test -n "$PKG_CONFIG"; then
+    PKG_CHECK_EXISTS([$3],
+                     [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`],
+                    [pkg_failed=yes])
+ else
+    pkg_failed=untried
 fi[]dnl
 ])# _PKG_CONFIG
 
@@ -117,16 +117,17 @@ and $1[]_LIBS to avoid the need to call pkg-config.
 See the pkg-config man page for more details.])
 
 if test $pkg_failed = yes; then
+       AC_MSG_RESULT([no])
         _PKG_SHORT_ERRORS_SUPPORTED
         if test $_pkg_short_errors_supported = yes; then
-               $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "$2"`
+               $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "$2" 2>&1`
         else 
-               $1[]_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
+               $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors "$2" 2>&1`
         fi
        # Put the nasty error message in config.log where it belongs
        echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
 
-       ifelse([$4], , [AC_MSG_ERROR(dnl
+       m4_default([$4], [AC_MSG_ERROR(
 [Package requirements ($2) were not met:
 
 $$1_PKG_ERRORS
@@ -134,24 +135,23 @@ $$1_PKG_ERRORS
 Consider adjusting the PKG_CONFIG_PATH environment variable if you
 installed software in a non-standard prefix.
 
-_PKG_TEXT
-])],
-               [AC_MSG_RESULT([no])
-                $4])
+_PKG_TEXT])
+        ])
 elif test $pkg_failed = untried; then
-       ifelse([$4], , [AC_MSG_FAILURE(dnl
+       AC_MSG_RESULT([no])
+       m4_default([$4], [AC_MSG_FAILURE(
 [The pkg-config script could not be found or is too old.  Make sure it
 is in your PATH or set the PKG_CONFIG environment variable to the full
 path to pkg-config.
 
 _PKG_TEXT
 
-To get pkg-config, see <http://pkg-config.freedesktop.org/>.])],
-               [$4])
+To get pkg-config, see <http://pkg-config.freedesktop.org/>.])
+        ])
 else
        $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
        $1[]_LIBS=$pkg_cv_[]$1[]_LIBS
         AC_MSG_RESULT([yes])
-       ifelse([$3], , :, [$3])
+       $3
 fi[]dnl
 ])# PKG_CHECK_MODULES
index 290bc4a2b97311280da54f83fb054a772a602b58..8b569eef50f903817816d725da989fd52cd299ef 100644 (file)
@@ -1,3 +1,4 @@
+dnl  Copyright (C) 2012 Data Differential LLC
 dnl  Copyright (C) 2011 Trond Norbye
 dnl This file is free software; Trond Norbye
 dnl gives unlimited permission to copy and/or distribute it,
@@ -12,53 +13,32 @@ AC_DEFUN([SOCKET_SEND_FLAGS],
     AC_LANG_PUSH([C])
     save_CFLAGS="$CFLAGS"
     CFLAGS="$CFLAGS -I${srcdir}"
-    AC_TRY_LINK([
-#include <sys/socket.h>
-                   ], [
-int flags= MSG_NOSIGNAL;
-                   ],
-                   [ ac_cv_msg_nosignal=yes ],
-                   [ ac_cv_msg_nosignal=no ])
-   CFLAGS="$save_CFLAGS"
-   AC_LANG_POP
+
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/socket.h>], [ int flags= MSG_NOSIGNAL ])], [ac_cv_msg_nosignal="yes"])
+    AC_LANG_POP
   ])
 
   AC_CACHE_CHECK([for MSG_DONTWAIT], [ac_cv_msg_dontwait], [
     AC_LANG_PUSH([C])
     save_CFLAGS="$CFLAGS"
     CFLAGS="$CFLAGS -I${srcdir}"
-    AC_TRY_LINK([
-#include <sys/socket.h>
-                   ], [
-int flags= MSG_DONTWAIT;
-                   ],
-                   [ ac_cv_msg_dontwait=yes ],
-                   [ ac_cv_msg_dontwait=no ])
-   CFLAGS="$save_CFLAGS"
-   AC_LANG_POP
+
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/socket.h>], [ int flags= MSG_DONTWAIT ])], [ac_cv_msg_dontwait="yes"])
+    AC_LANG_POP
   ])
 
   AC_CACHE_CHECK([for MSG_MORE], [ac_cv_msg_more], [
     AC_LANG_PUSH([C])
     save_CFLAGS="$CFLAGS"
     CFLAGS="$CFLAGS -I${srcdir}"
-    AC_TRY_LINK([
-#include <sys/socket.h>
-                   ], [
-int flags= MSG_MORE;
-                   ],
-                   [ ac_cv_msg_more=yes ],
-                   [ ac_cv_msg_more=no ])
-   CFLAGS="$save_CFLAGS"
-   AC_LANG_POP
+
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <netdb.h>], [ int flags= MSG_MORE ])], [ac_cv_msg_more="yes"])
+    AC_LANG_POP
   ])
 
-  AS_IF([test "x$ac_cv_msg_nosignal" = "xyes"],[
-        AC_DEFINE(HAVE_MSG_NOSIGNAL, 1, [Define to 1 if you have a MSG_NOSIGNAL])])
-  AS_IF([test "x$ac_cv_msg_dontwait" = "xyes"],[
-        AC_DEFINE(HAVE_MSG_DONTWAIT, 1, [Define to 1 if you have a MSG_DONTWAIT])])
-  AS_IF([test "x$ac_cv_msg_more" = "xyes"],[
-        AC_DEFINE(HAVE_MSG_MORE, 1, [Define to 1 if you have a HAVE_MSG_MORE])])
+  AS_IF([test "x$ac_cv_msg_nosignal" = "xyes"],[ AC_DEFINE(HAVE_MSG_NOSIGNAL, 1, [Define to 1 if you have a MSG_NOSIGNAL])])
+  AS_IF([test "x$ac_cv_msg_dontwait" = "xyes"],[ AC_DEFINE(HAVE_MSG_DONTWAIT, 1, [Define to 1 if you have a MSG_DONTWAIT])])
+  AS_IF([test "x$ac_cv_msg_more" = "xyes"],[ AC_DEFINE(HAVE_MSG_MORE, 1, [Define to 1 if you have a MSG_MORE])])
 ])
 
 dnl ---------------------------------------------------------------------------