AC_INIT([libmemcached],[0.30],[http://tangent.org/552/libmemcached.html])
AC_CONFIG_SRCDIR([libmemcached/memcached.c])
AC_CONFIG_AUX_DIR(config)
-AM_CONFIG_HEADER(libmemcached/libmemcached_config.h)
+AM_CONFIG_HEADER([config.h])
AC_CONFIG_MACRO_DIR([m4])
#shared library versioning
AC_SUBST(LD_VERSION_SCRIPT)
AC_SUBST(LD_UTIL_VERSION_SCRIPT)
+gl_VISIBILITY
+
# Build optimized or debug version ?
# First check for gcc and g++
if test "$GCC" = "yes"
DTRACEFLAGS = @DTRACEFLAGS@
noinst_HEADERS = libmemcached_probes.h \
- libmemcached_config.h \
- memcached_io.h \
+ memcached_io.h \
memcached_internal.h \
common.h \
memcached/protocol_binary.h @DTRACE_HEADER@
lib_LTLIBRARIES = libmemcached.la
-libmemcached_la_CFLAGS= ${AM_CFLAGS} ${NO_CONVERSION}
+libmemcached_la_CFLAGS= ${AM_CFLAGS} ${NO_CONVERSION} -DBUILDING_LIBMEMCACHED
libmemcached_la_SOURCES = crc.c \
memcached.c \
memcached_auto.c \
libmemcached_la_SOURCES += byteorder.c
endif
-DEFS += -DMEMCACHED_INTERNAL
libmemcached_la_DEPENDENCIES = @DTRACE_OBJ@
libmemcached_la_LIBADD = @DTRACE_OBJ@ $(LIBM)
libmemcached_la_LDFLAGS = -version-info $(MEMCACHED_LIBRARY_VERSION) $(LD_VERSION_SCRIPT) $(LIBM)
Common include file for libmemached
*/
-#ifndef __COMMON_H__
-#define __COMMON_H__
+#ifndef LIBMEMCACHED_COMMON_H
+#define LIBMEMCACHED_COMMON_H
-#include "libmemcached/libmemcached_config.h"
+#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/un.h>
#include <netinet/tcp.h>
-
-
-#include "libmemcached/memcached.h"
-#include "libmemcached/memcached_io.h"
-
-#include "libmemcached/memcached/protocol_binary.h"
-
#ifdef TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#endif
+#include "libmemcached/memcached.h"
+#include "libmemcached/memcached_watchpoint.h"
+
+#if defined(BUILDING_LIBMEMCACHED)
+/* These are private not to be installed headers */
+#include "libmemcached/memcached_io.h"
+#include "libmemcached/memcached_internal.h"
+#include "libmemcached/libmemcached_probes.h"
+#include "libmemcached/memcached/protocol_binary.h"
+
+/* string value */
+struct memcached_continuum_item_st {
+ uint32_t index;
+ uint32_t value;
+};
+
+#endif
+
+
+
#if !defined(__GNUC__) || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
#define unlikely(x) if(__builtin_expect((x), 0))
#endif
-#include "libmemcached_probes.h"
#define MEMCACHED_BLOCK_SIZE 1024
#define MEMCACHED_DEFAULT_COMMAND_SIZE 350
MEM_AUTO_EJECT_HOSTS= (1 << 16)
} memcached_flags;
+#if defined(BUILDING_LIBMEMCACHED)
/* Hashing algo */
void md5_signature(const unsigned char *key, unsigned int length, unsigned char *result);
uint32_t hash_crc32(const char *data,
return MEMCACHED_SUCCESS;
}
+#endif /* BUILDING_LIBMEMCACHED */
-#endif /* __COMMON_H__ */
+#endif /* !defined(LIBMEMCACHED_COMMON_H) && defined(BUILDING_LIBMEMCACHED) */
#include <sys/types.h>
#include <netinet/in.h>
-#ifdef MEMCACHED_INTERNAL
-#include <libmemcached/libmemcached_config.h>
-#endif
#include <libmemcached/memcached_configure.h>
#include <libmemcached/memcached_constants.h>
#include <libmemcached/memcached_types.h>
-#include <libmemcached/memcached_watchpoint.h>
#include <libmemcached/memcached_get.h>
#include <libmemcached/memcached_server.h>
#include <libmemcached/memcached_string.h>
extern "C" {
#endif
-/* These are Private and should not be used by applications */
#define MEMCACHED_VERSION_STRING_LENGTH 24
-
-/* string value */
-struct memcached_continuum_item_st {
- uint32_t index;
- uint32_t value;
-};
-
#define LIBMEMCACHED_VERSION_STRING "0.30"
struct memcached_analysis_st {
#include <libmemcached/memcached_storage.h>
-#ifdef MEMCACHED_INTERNAL
-#include <libmemcached/memcached_internal.h>
-#endif
-
#endif /* __MEMCACHED_H__ */
* Author: Trond Norbye <trond.norbye@sun.com>
*/
-#ifndef PROTOCOL_BINARY_H
-#define PROTOCOL_BINARY_H
+#ifndef LIBMEMCACHED_MEMCACHED_PROTOCOL_BINARY_H
+#define LIBMEMCACHED_MEMCACHED_PROTOCOL_BINARY_H
+
+#if defined(BUILDING_LIBMEMCACHED)
#include <stdint.h>
#ifdef __cplusplus
}
#endif
-#endif /* PROTOCOL_BINARY_H */
+
+#endif /* BUILDING_LIBMEMCACHED */
+#endif /* LIBMEMCACHED_MEMCACHED_PROTOCOL_BINARY_H */
#include "common.h"
-void libmemcached_free(memcached_st *ptr __attribute__((unused)), void *mem)
+void libmemcached_free(memcached_st *ptr, void *mem)
{
+ (void) ptr;
free(mem);
}
-void *libmemcached_malloc(memcached_st *ptr __attribute__((unused)),
- size_t size)
+void *libmemcached_malloc(memcached_st *ptr, size_t size)
{
+ (void) ptr;
return malloc(size);
}
-void *libmemcached_realloc(memcached_st *ptr __attribute__((unused)),
- void *mem, size_t size)
+void *libmemcached_realloc(memcached_st *ptr, void *mem, size_t size)
{
+ (void) ptr;
return realloc(mem, size);
}
-void *libmemcached_calloc(memcached_st *ptr __attribute__((unused)),
- size_t nelem, size_t size)
+void *libmemcached_calloc(memcached_st *ptr, size_t nelem, size_t size)
{
if (ptr->call_malloc != libmemcached_malloc)
{
* Author: Trond Norbye
*/
-#if !defined(MEMCACHED_INTERNAL_H) && defined(MEMCACHED_INTERNAL)
-#define MEMCACHED_INTERNAL_H
+#ifndef LIBMEMCACHED_MEMCACHED_INTERNAL_H
+#define LIBMEMCACHED_MEMCACHED_INTERNAL_H
+
+#if defined(BUILDING_LIBMEMCACHED)
#ifdef __cplusplus
extern "C" {
#endif
-void libmemcached_free(memcached_st *ptr __attribute__((unused)), void *mem);
-void *libmemcached_malloc(memcached_st *ptr __attribute__((unused)),
- const size_t size);
-void *libmemcached_realloc(memcached_st *ptr __attribute__((unused)),
- void *mem, const size_t size);
-void *libmemcached_calloc(memcached_st *ptr __attribute__((unused)),
- size_t nelem, size_t size);
+void libmemcached_free(memcached_st *ptr, void *mem);
+void *libmemcached_malloc(memcached_st *ptr, const size_t size);
+void *libmemcached_realloc(memcached_st *ptr, void *mem, const size_t size);
+void *libmemcached_calloc(memcached_st *ptr, size_t nelem, size_t size);
+
#ifdef __cplusplus
}
#endif
-#endif /* MEMCACHED_INTERNAL_H */
+#endif /* BUILDING_LIBMEMCACHED */
+#endif /* LIBMEMCACHED_MEMCACHED_INTERNAL_H */
-/* Server IO, Not public! */
-#include "libmemcached/memcached.h"
+/*
+ * Summary: Server IO, Not public!
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Brian Aker
+ */
+
+#ifndef LIBMEMCACHED_MEMCACHED_IO_H
+#define LIBMEMCACHED_MEMCACHED_IO_H
-#ifndef __MEMCACHED_IO_H__
-#define __MEMCACHED_IO_H__
+#if defined(BUILDING_LIBMEMCACHED)
+
+#include "libmemcached/memcached.h"
#define MAX_UDP_DATAGRAM_LENGTH 1400
#define UDP_DATAGRAM_HEADER_LENGTH 8
memcached_server_st *memcached_io_get_readable_server(memcached_st *memc);
-#endif /* __MEMCACHED_IO_H__ */
+#endif /* BUILDING_LIBMEMCACHED */
+#endif /* LIBMEMCACHED_MEMCACHED_IO_H */
* Author: Brian Aker
*/
-#ifndef __MEMCACHED_WATCHPOINT_H__
-#define __MEMCACHED_WATCHPOINT_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
+#ifndef LIBMEMCACHED_MEMCACHED_WATCHPOINT_H
+#define LIBMEMCACHED_MEMCACHED_WATCHPOINT_H
/* Some personal debugging functions */
-#if defined(MEMCACHED_INTERNAL) && defined(DEBUG)
+#if defined(DEBUG)
+
#include <assert.h>
#define WATCHPOINT fprintf(stderr, "\nWATCHPOINT %s:%d (%s)\n", __FILE__, __LINE__,__func__);fflush(stdout);
#define WATCHPOINT_ASSERT_PRINT(A,B,C)
#define WATCHPOINT_ASSERT(A)
-#endif /* MEMCACHED_INTERNAL && DEBUG */
-
-#ifdef __cplusplus
-}
-#endif
+#endif /* DEBUG */
-#endif /* __MEMCACHED_WATCHPOINT_H__ */
+#endif /* LIBMEMCACHED_MEMCACHED_WATCHPOINT_H */
--- /dev/null
+/*
+ * Summary: interface for memcached server
+ * Description: visibitliy macros for libmemcached
+ *
+ * Use and distribution licensed under the BSD license. See
+ * the COPYING file in this directory for full text.
+ *
+ * Author: Monty Taylor
+ */
+
+/**
+ * @file
+ * @brief Visibility control macros
+ */
+
+#ifndef __LIBMEMCACHED_VISIBILITY_H
+#define __LIBMEMCACHED_VISIBILITY_H
+
+/**
+ *
+ * LIBMEMCACHED_API is used for the public API symbols. It either DLL imports or
+ * DLL exports (or does nothing for static build).
+ *
+ * LIBMEMCACHED_LOCAL is used for non-api symbols.
+ */
+
+#if defined(BUILDING_LIBMEMCACHED)
+# if defined(HAVE_VISIBILITY)
+# define LIBMEMCACHED_API __attribute__ ((visibility("default")))
+# define LIBMEMCACHED_LOCAL __attribute__ ((visibility("hidden")))
+# elif defined(_MSC_VER)
+# define LIBMEMCACHED_API extern __declspec(dllexport)
+# define LIBMEMCACHED_LOCAL
+# endif /* defined(HAVE_VISIBILITY) */
+#else /* defined(BUILDING_LIBMEMCACHED) */
+# if defined(_MSC_VER)
+# define LIBMEMCACHED_API extern __declspec(dllimport)
+# define LIBMEMCACHED_LOCAL
+# else
+# define LIBMEMCACHED_API
+# define LIBMEMCACHED_LOCAL
+# endif /* defined(_MSC_VER) */
+#endif /* defined(BUILDING_LIBMEMCACHED) */
+
+#endif /* __LIBMEMCACHED_VISIBILITY_H */
-#include "libmemcached/common.h"
+#include "config.h"
#include "libmemcached/memcached_pool.h"
+
+#include <errno.h>
#include <pthread.h>
struct memcached_pool_st
--- /dev/null
+# visibility.m4 serial 2 (gettext-0.18)
+dnl Copyright (C) 2005, 2008 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Bruno Haible.
+
+dnl Tests whether the compiler supports the command-line option
+dnl -fvisibility=hidden and the function and variable attributes
+dnl __attribute__((__visibility__("hidden"))) and
+dnl __attribute__((__visibility__("default"))).
+dnl Does *not* test for __visibility__("protected") - which has tricky
+dnl semantics (see the 'vismain' test in glibc) and does not exist e.g. on
+dnl MacOS X.
+dnl Does *not* test for __visibility__("internal") - which has processor
+dnl dependent semantics.
+dnl Does *not* test for #pragma GCC visibility push(hidden) - which is
+dnl "really only recommended for legacy code".
+dnl Set the variable CFLAG_VISIBILITY.
+dnl Defines and sets the variable HAVE_VISIBILITY.
+
+AC_DEFUN([gl_VISIBILITY],
+[
+ AC_REQUIRE([AC_PROG_CC])
+ CFLAG_VISIBILITY=
+ HAVE_VISIBILITY=0
+ if test -n "$GCC"; then
+ AC_MSG_CHECKING([for simple visibility declarations])
+ AC_CACHE_VAL([gl_cv_cc_visibility], [
+ gl_save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -fvisibility=hidden"
+ AC_TRY_COMPILE(
+ [extern __attribute__((__visibility__("hidden"))) int hiddenvar;
+ extern __attribute__((__visibility__("default"))) int exportedvar;
+ extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void);
+ extern __attribute__((__visibility__("default"))) int exportedfunc (void);],
+ [],
+ [gl_cv_cc_visibility=yes],
+ [gl_cv_cc_visibility=no])
+ CFLAGS="$gl_save_CFLAGS"])
+ AC_MSG_RESULT([$gl_cv_cc_visibility])
+ if test $gl_cv_cc_visibility = yes; then
+ CFLAG_VISIBILITY="-fvisibility=hidden"
+ HAVE_VISIBILITY=1
+ fi
+ fi
+ AC_SUBST([CFLAG_VISIBILITY])
+ AC_SUBST([HAVE_VISIBILITY])
+ AC_DEFINE_UNQUOTED([HAVE_VISIBILITY], [$HAVE_VISIBILITY],
+ [Define to 1 or 0, depending whether the compiler supports simple visibility declarations.])
+])
/*
Sample test application.
*/
+
+/* TODO: I'm torn about this. The file seems like a functional test, which
+ * should use only the exported API of the library. On the other hand,
+ * something needs to test some of the internals - so we're going to turn on
+ * internal symbols here... but I'd like to come up with another way to test
+ * the internals
+ */
+#define BUILDING_LIBMEMCACHED 1
#include "libmemcached/common.h"
#include <assert.h>
assert(results);
assert(results->cas);
assert(rc == MEMCACHED_SUCCESS);
- WATCHPOINT_ASSERT(memcached_result_cas(results));
+ assert(memcached_result_cas(results));
assert(!memcmp(value, "we the people", strlen("we the people")));
assert(strlen("we the people") == value_length);
results= memcached_fetch_result(memc, &results_obj, &rc);
assert(results);
assert(rc == MEMCACHED_SUCCESS);
- WATCHPOINT_ASSERT(memcached_result_cas(results));
+ assert(memcached_result_cas(results));
assert(!memcmp(value, memcached_result_value(results), value_length));
assert(strlen(memcached_result_value(results)) == value_length);
assert(rc == MEMCACHED_SUCCESS);
errors++;
else
{
- WATCHPOINT_ERROR(rc);
- assert(0);
+ assert(rc);
}
continue;
#define TEST_PORT_BASE MEMCACHED_DEFAULT_PORT+10
-#include "libmemcached/libmemcached_config.h"
+#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#endif
#include <libmemcached/memcached.h>
-#include "../libmemcached/common.h"
+#include <stdio.h>
typedef struct world_st world_st;
typedef struct collection_st collection_st;