From aaafc64fc6b893f50861a53f7e7a8c735827bf49 Mon Sep 17 00:00:00 2001 From: Brian Aker Date: Tue, 8 Jan 2013 04:08:21 -0500 Subject: [PATCH] Update local poll() implementation. --- Makefile.am | 1 - libmemcached/assert.hpp | 13 +++++++++++++ libmemcached/backtrace.hpp | 10 +++++++++- libmemcached/common.h | 10 +--------- libmemcached/include.am | 4 +++- poll/poll.c => libmemcached/poll.cc | 12 ++++++------ {poll => libmemcached}/poll.h | 13 ++++++++----- poll/include.am | 8 -------- 8 files changed, 40 insertions(+), 31 deletions(-) rename poll/poll.c => libmemcached/poll.cc (89%) rename {poll => libmemcached}/poll.h (69%) delete mode 100644 poll/include.am diff --git a/Makefile.am b/Makefile.am index f5c63863..7f6e0386 100644 --- a/Makefile.am +++ b/Makefile.am @@ -64,7 +64,6 @@ endif include libmemcachedinternal/include.am include libmemcachedinternal/util/include.am -include poll/include.am include rpm/include.am include support/include.am include tests/include.am diff --git a/libmemcached/assert.hpp b/libmemcached/assert.hpp index b7124c91..d66b096f 100644 --- a/libmemcached/assert.hpp +++ b/libmemcached/assert.hpp @@ -37,6 +37,12 @@ #pragma once +#ifdef __cplusplus +# include +#else +# include +#endif // __cplusplus + #ifdef NDEBUG # define assert_msg(__expr, __mesg) (void)(__expr); (void)(__mesg); # define assert_vmsg(__expr, __mesg, ...) (void)(__expr); (void)(__mesg); @@ -48,7 +54,14 @@ # include # endif +#ifdef __cplusplus # include +# include +#else +# include +# include +#endif + # include # define assert_msg(__expr, __mesg) \ diff --git a/libmemcached/backtrace.hpp b/libmemcached/backtrace.hpp index 330d02c4..a83d3ea1 100644 --- a/libmemcached/backtrace.hpp +++ b/libmemcached/backtrace.hpp @@ -2,7 +2,7 @@ * * libmcachedd client library. * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * Copyright (C) 2011-2013 Data Differential, http://datadifferential.com/ * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -37,4 +37,12 @@ #pragma once +#ifdef __cplusplus +extern "C" { +#endif + void custom_backtrace(void); + +#ifdef __cplusplus +} +#endif diff --git a/libmemcached/common.h b/libmemcached/common.h index cc71ac5f..97990588 100644 --- a/libmemcached/common.h +++ b/libmemcached/common.h @@ -119,15 +119,7 @@ #ifdef HAVE_POLL_H # include #else -# include "poll/poll.h" -#endif - -#ifndef POLLHUP -# define POLLHUP 0x0010 -#endif - -#ifndef POLLNVAL -# define POLLNVAL 0x0020 +# include "libmemcached/poll.h" #endif #ifdef __cplusplus diff --git a/libmemcached/include.am b/libmemcached/include.am index 4c826ba1..5ca9c27c 100644 --- a/libmemcached/include.am +++ b/libmemcached/include.am @@ -38,6 +38,7 @@ noinst_HEADERS+= libmemcached/memcached/vbucket.h noinst_HEADERS+= libmemcached/memory.h noinst_HEADERS+= libmemcached/namespace.h noinst_HEADERS+= libmemcached/options.hpp +noinst_HEADERS+= libmemcached/poll.h noinst_HEADERS+= libmemcached/response.h noinst_HEADERS+= libmemcached/result.h noinst_HEADERS+= libmemcached/sasl.hpp @@ -90,6 +91,7 @@ libmemcached_libmemcached_la_SOURCES+= libmemcached/encoding_key.cc libmemcached_libmemcached_la_SOURCES+= libmemcached/namespace.cc libmemcached_libmemcached_la_SOURCES+= libmemcached/options.cc libmemcached_libmemcached_la_SOURCES+= libmemcached/parse.cc +libmemcached_libmemcached_la_SOURCES+= libmemcached/poll.cc libmemcached_libmemcached_la_SOURCES+= libmemcached/purge.cc libmemcached_libmemcached_la_SOURCES+= libmemcached/quit.cc libmemcached_libmemcached_la_SOURCES+= libmemcached/quit.hpp @@ -104,9 +106,9 @@ libmemcached_libmemcached_la_SOURCES+= libmemcached/storage.cc libmemcached_libmemcached_la_SOURCES+= libmemcached/strerror.cc libmemcached_libmemcached_la_SOURCES+= libmemcached/string.cc libmemcached_libmemcached_la_SOURCES+= libmemcached/touch.cc +libmemcached_libmemcached_la_SOURCES+= libmemcached/udp.cc libmemcached_libmemcached_la_SOURCES+= libmemcached/verbosity.cc libmemcached_libmemcached_la_SOURCES+= libmemcached/version.cc -libmemcached_libmemcached_la_SOURCES+= libmemcached/udp.cc libmemcached_libmemcached_la_SOURCES+= libmemcached/virtual_bucket.c libmemcached/options.cc: libmemcached/csl/parser.h diff --git a/poll/poll.c b/libmemcached/poll.cc similarity index 89% rename from poll/poll.c rename to libmemcached/poll.cc index 28156d1f..abd15d4c 100644 --- a/poll/poll.c +++ b/libmemcached/poll.cc @@ -1,4 +1,5 @@ /* LibMemcached + * Copyright (C) 2013 Data Differential, http://datadifferential.com/ * Copyright (C) 2010 Brian Aker, Trond Norbye * All rights reserved. * @@ -8,18 +9,15 @@ * Summary: Implementation of poll by using select * */ -#include "mem_config.h" + +#include "libmemcached/common.h" #if defined(WIN32) || defined(__MINGW32__) -# include -# include -#endif +#include "libmemcached/poll.h" #include #include -#include "poll/poll.h" - int poll(struct pollfd fds[], nfds_t nfds, int tmo) { fd_set readfds, writefds, errorfds; @@ -83,3 +81,5 @@ int poll(struct pollfd fds[], nfds_t nfds, int tmo) return ret; } + +#endif // defined(WIN32) || defined(__MINGW32__) diff --git a/poll/poll.h b/libmemcached/poll.h similarity index 69% rename from poll/poll.h rename to libmemcached/poll.h index 82940ca5..8445f009 100644 --- a/poll/poll.h +++ b/libmemcached/poll.h @@ -1,4 +1,5 @@ /* LibMemcached + * Copyright (C) 2013 Data Differential, http://datadifferential.com/ * Copyright (C) 2010 Brian Aker, Trond Norbye * All rights reserved. * @@ -8,12 +9,12 @@ * Summary: Implementation of poll by using select * */ -#ifndef POLL_POLL_H -#define POLL_POLL_H 1 -#ifdef WIN32 +#pragma once + +#if defined(WIN32) || defined(__MINGW32__) + #include -#endif #ifdef __cplusplus extern "C" { @@ -35,6 +36,8 @@ typedef int nfds_t; #define POLLIN 0x0001 #define POLLOUT 0x0004 #define POLLERR 0x0008 +#define POLLHUP 0x010 /* Hung up. */ +#define POLLNVAL 0x020 /* Invalid polling request. */ int poll(struct pollfd fds[], nfds_t nfds, int tmo); @@ -42,4 +45,4 @@ int poll(struct pollfd fds[], nfds_t nfds, int tmo); } #endif -#endif +#endif // defined(WIN32) || defined(__MINGW32__) diff --git a/poll/include.am b/poll/include.am deleted file mode 100644 index 00105208..00000000 --- a/poll/include.am +++ /dev/null @@ -1,8 +0,0 @@ -# vim:ft=automake -# included from Top Level Makefile.am -# All paths should be given relative to the root -noinst_HEADERS+= poll/poll.h - -if BUILD_POLL -libmemcached_libmemcached_la_SOURCES += poll/poll.c -endif -- 2.30.2