From: Brian Aker Date: Sun, 29 Jan 2012 12:39:16 +0000 (-0800) Subject: Fix m4 warnings, and fix a couple of issues around include files. X-Git-Tag: 1.0.5~83 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=2ec5c18ff3cf16293ba0f53f91ad0f3a9d800b91;p=awesomized%2Flibmemcached Fix m4 warnings, and fix a couple of issues around include files. --- diff --git a/clients/memcapable.cc b/clients/memcapable.cc index 8bce153a..9bd310c5 100644 --- a/clients/memcapable.cc +++ b/clients/memcapable.cc @@ -34,7 +34,7 @@ #include #include -#include +#include #include #include #include diff --git a/configure.ac b/configure.ac index 41474a8c..a7f4a306 100644 --- a/configure.ac +++ b/configure.ac @@ -135,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 @@ -204,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([ diff --git a/example/memcached_light.c b/example/memcached_light.c index 18274378..c064e519 100644 --- a/example/memcached_light.c +++ b/example/memcached_light.c @@ -35,7 +35,7 @@ #include #include -#include +#include #include #include "example/storage.h" #include "example/memcached_light.h" diff --git a/libmemcached/close_socket.hpp b/libmemcached/close_socket.hpp deleted file mode 100644 index 0d18857a..00000000 --- a/libmemcached/close_socket.hpp +++ /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 - - diff --git a/libmemcached/common.h b/libmemcached/common.h index 53481880..d239d264 100644 --- a/libmemcached/common.h +++ b/libmemcached/common.h @@ -107,7 +107,7 @@ memcached_return_t memcached_server_execute(memcached_st *ptr, #include #include #include -#include +#include #include #include #include diff --git a/libmemcached/connect.cc b/libmemcached/connect.cc index 1c7da465..8434ba8b 100644 --- a/libmemcached/connect.cc +++ b/libmemcached/connect.cc @@ -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 { diff --git a/libmemcached/include.am b/libmemcached/include.am index a10b92a5..24d95982 100644 --- a/libmemcached/include.am +++ b/libmemcached/include.am @@ -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 \ diff --git a/libmemcached/io.cc b/libmemcached/io.cc index 8b297a7a..fbfb8555 100644 --- a/libmemcached/io.cc +++ b/libmemcached/io.cc @@ -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 index 00000000..0d18857a --- /dev/null +++ b/libmemcached/socket.hpp @@ -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 + + diff --git a/libmemcachedprotocol/common.h b/libmemcachedprotocol/common.h index 2e3e7c6d..ea94a8d7 100644 --- a/libmemcachedprotocol/common.h +++ b/libmemcachedprotocol/common.h @@ -37,15 +37,12 @@ #pragma once #include "config.h" -#if !defined(__cplusplus) -# include -#endif #include #include #include #include -#include +#include /* * I don't really need the following two functions as function pointers diff --git a/libtest/memcached.cc b/libtest/memcached.cc index 05f43975..fc7a37c6 100644 --- a/libtest/memcached.cc +++ b/libtest/memcached.cc @@ -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 index 033e3b13..00000000 --- a/m4/ax_tls.m4 +++ /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 -# Copyright (c) 2010 Diego Elio Petteno` -# -# 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 . -# -# 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 - 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]) - ) -]) diff --git a/m4/bottom.m4 b/m4/bottom.m4 index a02e312f..289c2994 100644 --- a/m4/bottom.m4 +++ b/m4/bottom.m4 @@ -27,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 index cd9e4319..00000000 --- a/m4/eagain.m4 +++ /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 - ], [ -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/socket_send_flags.m4 b/m4/socket_send_flags.m4 index 290bc4a2..8b569eef 100644 --- a/m4/socket_send_flags.m4 +++ b/m4/socket_send_flags.m4 @@ -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 - ], [ -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 ], [ 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 - ], [ -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 ], [ 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 - ], [ -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 ], [ 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 ---------------------------------------------------------------------------