Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use pandora build

  • Loading branch information...
commit 43620fe0906357b72afeee1c6a3d19e5e60c860a 1 parent 055ede6
@trondn trondn authored committed
Showing with 3,958 additions and 285 deletions.
  1. +37 −16 .gitignore
  2. +8 −1 Makefile.am
  3. +101 −0 config/autorun.sh
  4. +0 −107 config/bootstrap
  5. +666 −0 config/config.rpath
  6. +52 −0 config/version.pl
  7. +43 −95 configure.ac
  8. +56 −61 libmemc.c
  9. +103 −0 m4/ac_cxx_compile_stdcxx_0x.m4
  10. +67 −0 m4/ac_cxx_header_stdcxx_98.m4
  11. +276 −0 m4/acx_pthread.m4
  12. +110 −0 m4/lib-ld.m4
  13. +767 −0 m4/lib-link.m4
  14. +221 −0 m4/lib-prefix.m4
  15. +92 −0 m4/lt~obsolete.m4
  16. +60 −0 m4/pandora_64bit.m4
  17. +163 −0 m4/pandora_canonical.m4
  18. +37 −0 m4/pandora_check_compiler_version.m4
  19. +16 −0 m4/pandora_check_cxx_standard.m4
  20. +43 −0 m4/pandora_enable_dtrace.m4
  21. +39 −0 m4/pandora_ensure_gcc_version.m4
  22. +16 −0 m4/pandora_extensions.m4
  23. +62 −0 m4/pandora_have_better_malloc.m4
  24. +44 −0 m4/pandora_have_libmemcached.m4
  25. +40 −0 m4/pandora_have_libvbucket.m4
  26. +22 −0 m4/pandora_header_assert.m4
  27. +15 −0 m4/pandora_libtool.m4
  28. +79 −0 m4/pandora_optimize.m4
  29. +77 −0 m4/pandora_platform.m4
  30. +41 −0 m4/pandora_plugins.m4
  31. +78 −0 m4/pandora_pthread.m4
  32. +56 −0 m4/pandora_shared_ptr.m4
  33. +36 −0 m4/pandora_use_pipe.m4
  34. +56 −0 m4/pandora_vc_build.m4
  35. +343 −0 m4/pandora_warnings.m4
  36. +33 −0 m4/pandora_with_memcached.m4
  37. +2 −5 main.c
  38. +1 −0  metrics.c
View
53 .gitignore
@@ -1,18 +1,39 @@
+# Keep the entries sorted to reduce the risk for a merge conflict
+*.[ao]
+*.dirstamp
+*.gcda
+*.gcno
+*.gcov
+*.l[ao]
+*.pyc
+*.tcov
*~
-*.o
.deps/
-Makefile
-Makefile.in
-aclocal.m4
-autom4te.cache/
-compile
-config.h
-config.h.in
-config.log
-config.status
-configure
-depcomp
-install-sh
-memcachetest
-missing
-stamp-h1
+.libs/
+/INSTALL
+/Makefile
+/Makefile.in
+/aclocal.m4
+/autom4te.cache
+/config.h
+/config.h.in
+/config.log
+/config.status
+/config/compile
+/config/config.guess
+/config/config.sub
+/config/depcomp
+/config/install-sh
+/config/ltmain.sh
+/config/missing
+/config/mkinstalldirs
+/config/plugin.ac
+/configure
+/libtool
+/m4/libtool.m4
+/m4/ltoptions.m4
+/m4/ltsugar.m4
+/m4/ltversion.m4
+/m4/version.m4
+/memcachetest
+/stamp-h1
View
9 Makefile.am
@@ -1,5 +1,12 @@
+ACLOCAL_AMFLAGS = -I m4 --force
AUTOMAKE_OPTIONS = foreign
bin_PROGRAMS = memcachetest
-memcachetest_SOURCES = main.c libmemc.c libmemc.h boxmuller.c metrics.c metrics.h timer.c
+memcachetest_SOURCES = \
+ boxmuller.c \
+ libmemc.c libmemc.h \
+ main.c \
+ metrics.c metrics.h \
+ timer.c
+memcachetest_LDADD = $(LIBMEMCACHED)
View
101 config/autorun.sh
@@ -0,0 +1,101 @@
+#!/bin/sh
+
+LIBTOOLIZE_FLAGS="--automake --copy --force"
+AUTOMAKE_FLAGS="--add-missing --copy --force --foreign --warning=portability"
+ACLOCAL_FLAGS="-I m4"
+AUTOHEADER_FLAGS="--warnings=error"
+AUTOCONF_CLAGS="--warnings=error --force"
+
+
+ARGV0=$0
+ARGS="$@"
+
+die() { echo "$@"; exit 1; }
+
+run() {
+ echo "$ARGV0: running \`$@' $ARGS"
+ $@ $ARGS
+}
+
+# Try to locate a program by using which, and verify that the file is an
+# executable
+locate_binary() {
+ for f in $@
+ do
+ file=`which $f 2>/dev/null | grep -v '^no '`
+ if test -n "$file" -a -x "$file"; then
+ echo $file
+ return 0
+ fi
+ done
+
+ echo ""
+ return 1
+}
+
+if test -f config/pre_hook.sh
+then
+ . config/pre_hook.sh
+fi
+
+if [ -d .git ]
+then
+ perl config/version.pl || die "Failed to run config/version.pl"
+fi
+
+# Try to detect the supported binaries if the user didn't
+# override that by pushing the environment variable
+if test x$LIBTOOLIZE = x; then
+ LIBTOOLIZE=`locate_binary libtoolize glibtoolize`
+ if test x$LIBTOOLIZE = x; then
+ die "Did not find a supported libtoolize"
+ fi
+fi
+
+if test x$ACLOCAL = x; then
+ ACLOCAL=`locate_binary aclocal-1.11 aclocal-1.10 aclocal`
+ if test x$ACLOCAL = x; then
+ die "Did not find a supported aclocal"
+ fi
+fi
+
+if test x$AUTOMAKE = x; then
+ AUTOMAKE=`locate_binary automake-1.11 automake-1.10 automake`
+ if test x$AUTOMAKE = x; then
+ die "Did not find a supported automake"
+ fi
+fi
+
+if test x$AUTOCONF = x; then
+ AUTOCONF=`locate_binary autoconf`
+ if test x$AUTOCONF = x; then
+ die "Did not find a supported autoconf"
+ fi
+fi
+
+if test x$AUTOHEADER = x; then
+ AUTOHEADER=`locate_binary autoheader`
+ if test x$AUTOHEADER = x; then
+ die "Did not find a supported autoheader"
+ fi
+fi
+
+run $LIBTOOLIZE $LIBTOOLIZE_FLAGS || die "Can't execute libtoolize"
+run $ACLOCAL $ACLOCAL_FLAGS || die "Can't execute aclocal"
+run $AUTOHEADER $AUTOHEADER_FLAGS || die "Can't execute autoheader"
+run $AUTOMAKE $AUTOMAKE_FLAGS || die "Can't execute automake"
+run $AUTOCONF $AUTOCONF_FLAGS || die "Can't execute autoconf"
+
+if test -f config/post_hook.sh
+then
+ . config/post_hook.sh
+fi
+
+echo "---"
+echo "Configured with the following tools:"
+echo " * `$LIBTOOLIZE --version | head -1`"
+echo " * `$ACLOCAL --version | head -1`"
+echo " * `$AUTOHEADER --version | head -1`"
+echo " * `$AUTOMAKE --version | head -1`"
+echo " * `$AUTOCONF --version | head -1`"
+echo "---"
View
107 config/bootstrap
@@ -1,107 +0,0 @@
-#!/usr/bin/env bash
-# Taken from lighthttpd server (BSD). Thanks Jan!
-# then taken from libmemcached :)
-# Run this to generate all the initial makefiles, etc.
-
-die() { echo "$@"; exit 1; }
-
-# LIBTOOLIZE=${LIBTOOLIZE:-libtoolize}
-LIBTOOLIZE_FLAGS=" --automake --copy --force"
-# ACLOCAL=${ACLOCAL:-aclocal}
-#ACLOCAL_FLAGS="-I m4"
-# AUTOHEADER=${AUTOHEADER:-autoheader}
-# AUTOMAKE=${AUTOMAKE:-automake}
-AUTOMAKE_FLAGS="--add-missing --copy --force"
-# AUTOCONF=${AUTOCONF:-autoconf}
-
-ARGV0=$0
-ARGS="$@"
-
-
-run() {
- echo "$ARGV0: running \`$@' $ARGS"
- $@ $ARGS
-}
-
-## jump out if one of the programs returns 'false'
-set -e
-
-## We do not currently support glibtoolize
-if test x$LIBTOOLIZE = x; then
- if test \! "x`which glibtoolize 2> /dev/null | grep -v '^no'`" = x; then
- LIBTOOLIZE=glibtoolize
- elif test \! "x`which libtoolize-1.5 2> /dev/null | grep -v '^no'`" = x; then
- LIBTOOLIZE=libtoolize-1.5
- elif test \! "x`which libtoolize 2> /dev/null | grep -v '^no'`" = x; then
- LIBTOOLIZE=libtoolize
- else
- echo "libtoolize 1.5.x wasn't found, exiting"; exit 0
- fi
-fi
-
-## suse has aclocal and aclocal-1.9
-if test x$ACLOCAL = x; then
- if test \! "x`which aclocal-1.10 2> /dev/null | grep -v '^no'`" = x; then
- ACLOCAL=aclocal-1.10
- elif test \! "x`which aclocal-1.9 2> /dev/null | grep -v '^no'`" = x; then
- ACLOCAL=aclocal-1.9
- elif test \! "x`which aclocal19 2> /dev/null | grep -v '^no'`" = x; then
- ACLOCAL=aclocal19
- elif test \! "x`which aclocal 2> /dev/null | grep -v '^no'`" = x; then
- ACLOCAL=aclocal
- else
- echo "automake 1.9.x (aclocal) wasn't found, exiting"; exit 0
- fi
-fi
-
-if test x$AUTOMAKE = x; then
- if test \! "x`which automake-1.10 2> /dev/null | grep -v '^no'`" = x; then
- AUTOMAKE=automake-1.10
- elif test \! "x`which automake-1.9 2> /dev/null | grep -v '^no'`" = x; then
- AUTOMAKE=automake-1.9
- elif test \! "x`which automake19 2> /dev/null | grep -v '^no'`" = x; then
- AUTOMAKE=automake19
- elif test \! "x`which automake 2> /dev/null | grep -v '^no'`" = x; then
- AUTOMAKE=automake
- else
- echo "automake 1.9.x wasn't found, exiting"; exit 0
- fi
-fi
-
-
-## macosx has autoconf-2.59 and autoconf-2.60
-if test x$AUTOCONF = x; then
- if test \! "x`which autoconf-2.59 2> /dev/null | grep -v '^no'`" = x; then
- AUTOCONF=autoconf-2.59
- elif test \! "x`which autoconf259 2> /dev/null | grep -v '^no'`" = x; then
- AUTOCONF=autoconf259
- elif test \! "x`which autoconf 2> /dev/null | grep -v '^no'`" = x; then
- AUTOCONF=autoconf
- else
- echo "autoconf 2.59+ wasn't found, exiting"; exit 0
- fi
-fi
-
-if test x$AUTOHEADER = x; then
- if test \! "x`which autoheader-2.59 2> /dev/null | grep -v '^no'`" = x; then
- AUTOHEADER=autoheader-2.59
- elif test \! "x`which autoheader259 2> /dev/null | grep -v '^no'`" = x; then
- AUTOHEADER=autoheader259
- elif test \! "x`which autoheader 2> /dev/null | grep -v '^no'`" = x; then
- AUTOHEADER=autoheader
- else
- echo "autoconf 2.59+ (autoheader) wasn't found, exiting"; exit 0
- fi
-fi
-
-
-# --force means overwrite ltmain.sh script if it already exists
-# run $LIBTOOLIZE $LIBTOOLIZE_FLAGS || die "Can't execute libtoolize"
-
-run $ACLOCAL $ACLOCAL_FLAGS || die "Can't execute aclocal"
-run $AUTOHEADER || die "Can't execute autoheader"
-
-# --add-missing instructs automake to install missing auxiliary files
-# and --force to overwrite them if they already exist
-run $AUTOMAKE $AUTOMAKE_FLAGS || die "Can't execute automake"
-run $AUTOCONF || die "Can't execute autoconf"
View
666 config/config.rpath
@@ -0,0 +1,666 @@
+#! /bin/sh
+# Output a system dependent set of variables, describing how to set the
+# run time search path of shared libraries in an executable.
+#
+# Copyright 1996-2007 Free Software Foundation, Inc.
+# Taken from GNU libtool, 2001
+# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
+#
+# This file is free software; the Free Software Foundation gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
+#
+# The first argument passed to this file is the canonical host specification,
+# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
+# or
+# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
+# The environment variables CC, GCC, LDFLAGS, LD, with_gnu_ld
+# should be set by the caller.
+#
+# The set of defined variables is at the end of this script.
+
+# Known limitations:
+# - On IRIX 6.5 with CC="cc", the run time search patch must not be longer
+# than 256 bytes, otherwise the compiler driver will dump core. The only
+# known workaround is to choose shorter directory names for the build
+# directory and/or the installation directory.
+
+# All known linkers require a `.a' archive for static linking (except MSVC,
+# which needs '.lib').
+libext=a
+shrext=.so
+
+host="$1"
+host_cpu=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+host_vendor=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+host_os=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+
+# Code taken from libtool.m4's _LT_CC_BASENAME.
+
+for cc_temp in $CC""; do
+ case $cc_temp in
+ compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+ distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+ \-*) ;;
+ *) break;;
+ esac
+done
+cc_basename=`echo "$cc_temp" | sed -e 's%^.*/%%'`
+
+# Code taken from libtool.m4's AC_LIBTOOL_PROG_COMPILER_PIC.
+
+wl=
+if test "$GCC" = yes; then
+ wl='-Wl,'
+else
+ case "$host_os" in
+ aix*)
+ wl='-Wl,'
+ ;;
+ darwin*)
+ case $cc_basename in
+ xlc*)
+ wl='-Wl,'
+ ;;
+ esac
+ ;;
+ mingw* | cygwin* | pw32* | os2*)
+ ;;
+ hpux9* | hpux10* | hpux11*)
+ wl='-Wl,'
+ ;;
+ irix5* | irix6* | nonstopux*)
+ wl='-Wl,'
+ ;;
+ newsos6)
+ ;;
+ linux* | k*bsd*-gnu)
+ case $cc_basename in
+ icc* | ecc*)
+ wl='-Wl,'
+ ;;
+ pgcc | pgf77 | pgf90)
+ wl='-Wl,'
+ ;;
+ ccc*)
+ wl='-Wl,'
+ ;;
+ como)
+ wl='-lopt='
+ ;;
+ *)
+ case `$CC -V 2>&1 | sed 5q` in
+ *Sun\ C*)
+ wl='-Wl,'
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+ osf3* | osf4* | osf5*)
+ wl='-Wl,'
+ ;;
+ rdos*)
+ ;;
+ solaris*)
+ wl='-Wl,'
+ ;;
+ sunos4*)
+ wl='-Qoption ld '
+ ;;
+ sysv4 | sysv4.2uw2* | sysv4.3*)
+ wl='-Wl,'
+ ;;
+ sysv4*MP*)
+ ;;
+ sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+ wl='-Wl,'
+ ;;
+ unicos*)
+ wl='-Wl,'
+ ;;
+ uts4*)
+ ;;
+ esac
+fi
+
+# Code taken from libtool.m4's AC_LIBTOOL_PROG_LD_SHLIBS.
+
+hardcode_libdir_flag_spec=
+hardcode_libdir_separator=
+hardcode_direct=no
+hardcode_minus_L=no
+
+case "$host_os" in
+ cygwin* | mingw* | pw32*)
+ # FIXME: the MSVC++ port hasn't been tested in a loooong time
+ # When not using gcc, we currently assume that we are using
+ # Microsoft Visual C++.
+ if test "$GCC" != yes; then
+ with_gnu_ld=no
+ fi
+ ;;
+ interix*)
+ # we just hope/assume this is gcc and not c89 (= MSVC++)
+ with_gnu_ld=yes
+ ;;
+ openbsd*)
+ with_gnu_ld=no
+ ;;
+esac
+
+ld_shlibs=yes
+if test "$with_gnu_ld" = yes; then
+ # Set some defaults for GNU ld with shared library support. These
+ # are reset later if shared libraries are not supported. Putting them
+ # here allows them to be overridden if necessary.
+ # Unlike libtool, we use -rpath here, not --rpath, since the documented
+ # option of GNU ld is called -rpath, not --rpath.
+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+ case "$host_os" in
+ aix3* | aix4* | aix5*)
+ # On AIX/PPC, the GNU linker is very broken
+ if test "$host_cpu" != ia64; then
+ ld_shlibs=no
+ fi
+ ;;
+ amigaos*)
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_minus_L=yes
+ # Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports
+ # that the semantics of dynamic libraries on AmigaOS, at least up
+ # to version 4, is to share data among multiple programs linked
+ # with the same dynamic library. Since this doesn't match the
+ # behavior of shared libraries on other platforms, we cannot use
+ # them.
+ ld_shlibs=no
+ ;;
+ beos*)
+ if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+ :
+ else
+ ld_shlibs=no
+ fi
+ ;;
+ cygwin* | mingw* | pw32*)
+ # hardcode_libdir_flag_spec is actually meaningless, as there is
+ # no search path for DLLs.
+ hardcode_libdir_flag_spec='-L$libdir'
+ if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
+ :
+ else
+ ld_shlibs=no
+ fi
+ ;;
+ interix[3-9]*)
+ hardcode_direct=no
+ hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+ ;;
+ gnu* | linux* | k*bsd*-gnu)
+ if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+ :
+ else
+ ld_shlibs=no
+ fi
+ ;;
+ netbsd*)
+ ;;
+ solaris*)
+ if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
+ ld_shlibs=no
+ elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+ :
+ else
+ ld_shlibs=no
+ fi
+ ;;
+ sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
+ case `$LD -v 2>&1` in
+ *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
+ ld_shlibs=no
+ ;;
+ *)
+ if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+ hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`'
+ else
+ ld_shlibs=no
+ fi
+ ;;
+ esac
+ ;;
+ sunos4*)
+ hardcode_direct=yes
+ ;;
+ *)
+ if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+ :
+ else
+ ld_shlibs=no
+ fi
+ ;;
+ esac
+ if test "$ld_shlibs" = no; then
+ hardcode_libdir_flag_spec=
+ fi
+else
+ case "$host_os" in
+ aix3*)
+ # Note: this linker hardcodes the directories in LIBPATH if there
+ # are no directories specified by -L.
+ hardcode_minus_L=yes
+ if test "$GCC" = yes; then
+ # Neither direct hardcoding nor static linking is supported with a
+ # broken collect2.
+ hardcode_direct=unsupported
+ fi
+ ;;
+ aix4* | aix5*)
+ if test "$host_cpu" = ia64; then
+ # On IA64, the linker does run time linking by default, so we don't
+ # have to do anything special.
+ aix_use_runtimelinking=no
+ else
+ aix_use_runtimelinking=no
+ # Test if we are trying to use run time linking or normal
+ # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+ # need to do runtime linking.
+ case $host_os in aix4.[23]|aix4.[23].*|aix5*)
+ for ld_flag in $LDFLAGS; do
+ if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+ aix_use_runtimelinking=yes
+ break
+ fi
+ done
+ ;;
+ esac
+ fi
+ hardcode_direct=yes
+ hardcode_libdir_separator=':'
+ if test "$GCC" = yes; then
+ case $host_os in aix4.[012]|aix4.[012].*)
+ collect2name=`${CC} -print-prog-name=collect2`
+ if test -f "$collect2name" && \
+ strings "$collect2name" | grep resolve_lib_name >/dev/null
+ then
+ # We have reworked collect2
+ :
+ else
+ # We have old collect2
+ hardcode_direct=unsupported
+ hardcode_minus_L=yes
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_libdir_separator=
+ fi
+ ;;
+ esac
+ fi
+ # Begin _LT_AC_SYS_LIBPATH_AIX.
+ echo 'int main () { return 0; }' > conftest.c
+ ${CC} ${LDFLAGS} conftest.c -o conftest
+ aix_libpath=`dump -H conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
+}'`
+ if test -z "$aix_libpath"; then
+ aix_libpath=`dump -HX64 conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
+}'`
+ fi
+ if test -z "$aix_libpath"; then
+ aix_libpath="/usr/lib:/lib"
+ fi
+ rm -f conftest.c conftest
+ # End _LT_AC_SYS_LIBPATH_AIX.
+ if test "$aix_use_runtimelinking" = yes; then
+ hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
+ else
+ if test "$host_cpu" = ia64; then
+ hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
+ else
+ hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
+ fi
+ fi
+ ;;
+ amigaos*)
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_minus_L=yes
+ # see comment about different semantics on the GNU ld section
+ ld_shlibs=no
+ ;;
+ bsdi[45]*)
+ ;;
+ cygwin* | mingw* | pw32*)
+ # When not using gcc, we currently assume that we are using
+ # Microsoft Visual C++.
+ # hardcode_libdir_flag_spec is actually meaningless, as there is
+ # no search path for DLLs.
+ hardcode_libdir_flag_spec=' '
+ libext=lib
+ ;;
+ darwin* | rhapsody*)
+ hardcode_direct=no
+ if test "$GCC" = yes ; then
+ :
+ else
+ case $cc_basename in
+ xlc*)
+ ;;
+ *)
+ ld_shlibs=no
+ ;;
+ esac
+ fi
+ ;;
+ dgux*)
+ hardcode_libdir_flag_spec='-L$libdir'
+ ;;
+ freebsd1*)
+ ld_shlibs=no
+ ;;
+ freebsd2.2*)
+ hardcode_libdir_flag_spec='-R$libdir'
+ hardcode_direct=yes
+ ;;
+ freebsd2*)
+ hardcode_direct=yes
+ hardcode_minus_L=yes
+ ;;
+ freebsd* | dragonfly*)
+ hardcode_libdir_flag_spec='-R$libdir'
+ hardcode_direct=yes
+ ;;
+ hpux9*)
+ hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+ hardcode_libdir_separator=:
+ hardcode_direct=yes
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ hardcode_minus_L=yes
+ ;;
+ hpux10*)
+ if test "$with_gnu_ld" = no; then
+ hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+ hardcode_libdir_separator=:
+ hardcode_direct=yes
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ hardcode_minus_L=yes
+ fi
+ ;;
+ hpux11*)
+ if test "$with_gnu_ld" = no; then
+ hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+ hardcode_libdir_separator=:
+ case $host_cpu in
+ hppa*64*|ia64*)
+ hardcode_direct=no
+ ;;
+ *)
+ hardcode_direct=yes
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ hardcode_minus_L=yes
+ ;;
+ esac
+ fi
+ ;;
+ irix5* | irix6* | nonstopux*)
+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+ hardcode_libdir_separator=:
+ ;;
+ netbsd*)
+ hardcode_libdir_flag_spec='-R$libdir'
+ hardcode_direct=yes
+ ;;
+ newsos6)
+ hardcode_direct=yes
+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+ hardcode_libdir_separator=:
+ ;;
+ openbsd*)
+ if test -f /usr/libexec/ld.so; then
+ hardcode_direct=yes
+ if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+ else
+ case "$host_os" in
+ openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
+ hardcode_libdir_flag_spec='-R$libdir'
+ ;;
+ *)
+ hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+ ;;
+ esac
+ fi
+ else
+ ld_shlibs=no
+ fi
+ ;;
+ os2*)
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_minus_L=yes
+ ;;
+ osf3*)
+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+ hardcode_libdir_separator=:
+ ;;
+ osf4* | osf5*)
+ if test "$GCC" = yes; then
+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+ else
+ # Both cc and cxx compiler support -rpath directly
+ hardcode_libdir_flag_spec='-rpath $libdir'
+ fi
+ hardcode_libdir_separator=:
+ ;;
+ solaris*)
+ hardcode_libdir_flag_spec='-R$libdir'
+ ;;
+ sunos4*)
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_direct=yes
+ hardcode_minus_L=yes
+ ;;
+ sysv4)
+ case $host_vendor in
+ sni)
+ hardcode_direct=yes # is this really true???
+ ;;
+ siemens)
+ hardcode_direct=no
+ ;;
+ motorola)
+ hardcode_direct=no #Motorola manual says yes, but my tests say they lie
+ ;;
+ esac
+ ;;
+ sysv4.3*)
+ ;;
+ sysv4*MP*)
+ if test -d /usr/nec; then
+ ld_shlibs=yes
+ fi
+ ;;
+ sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
+ ;;
+ sysv5* | sco3.2v5* | sco5v6*)
+ hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
+ hardcode_libdir_separator=':'
+ ;;
+ uts4*)
+ hardcode_libdir_flag_spec='-L$libdir'
+ ;;
+ *)
+ ld_shlibs=no
+ ;;
+ esac
+fi
+
+# Check dynamic linker characteristics
+# Code taken from libtool.m4's AC_LIBTOOL_SYS_DYNAMIC_LINKER.
+# Unlike libtool.m4, here we don't care about _all_ names of the library, but
+# only about the one the linker finds when passed -lNAME. This is the last
+# element of library_names_spec in libtool.m4, or possibly two of them if the
+# linker has special search rules.
+library_names_spec= # the last element of library_names_spec in libtool.m4
+libname_spec='lib$name'
+case "$host_os" in
+ aix3*)
+ library_names_spec='$libname.a'
+ ;;
+ aix4* | aix5*)
+ library_names_spec='$libname$shrext'
+ ;;
+ amigaos*)
+ library_names_spec='$libname.a'
+ ;;
+ beos*)
+ library_names_spec='$libname$shrext'
+ ;;
+ bsdi[45]*)
+ library_names_spec='$libname$shrext'
+ ;;
+ cygwin* | mingw* | pw32*)
+ shrext=.dll
+ library_names_spec='$libname.dll.a $libname.lib'
+ ;;
+ darwin* | rhapsody*)
+ shrext=.dylib
+ library_names_spec='$libname$shrext'
+ ;;
+ dgux*)
+ library_names_spec='$libname$shrext'
+ ;;
+ freebsd1*)
+ ;;
+ freebsd* | dragonfly*)
+ case "$host_os" in
+ freebsd[123]*)
+ library_names_spec='$libname$shrext$versuffix' ;;
+ *)
+ library_names_spec='$libname$shrext' ;;
+ esac
+ ;;
+ gnu*)
+ library_names_spec='$libname$shrext'
+ ;;
+ hpux9* | hpux10* | hpux11*)
+ case $host_cpu in
+ ia64*)
+ shrext=.so
+ ;;
+ hppa*64*)
+ shrext=.sl
+ ;;
+ *)
+ shrext=.sl
+ ;;
+ esac
+ library_names_spec='$libname$shrext'
+ ;;
+ interix[3-9]*)
+ library_names_spec='$libname$shrext'
+ ;;
+ irix5* | irix6* | nonstopux*)
+ library_names_spec='$libname$shrext'
+ case "$host_os" in
+ irix5* | nonstopux*)
+ libsuff= shlibsuff=
+ ;;
+ *)
+ case $LD in
+ *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= ;;
+ *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 ;;
+ *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 ;;
+ *) libsuff= shlibsuff= ;;
+ esac
+ ;;
+ esac
+ ;;
+ linux*oldld* | linux*aout* | linux*coff*)
+ ;;
+ linux* | k*bsd*-gnu)
+ library_names_spec='$libname$shrext'
+ ;;
+ knetbsd*-gnu)
+ library_names_spec='$libname$shrext'
+ ;;
+ netbsd*)
+ library_names_spec='$libname$shrext'
+ ;;
+ newsos6)
+ library_names_spec='$libname$shrext'
+ ;;
+ nto-qnx*)
+ library_names_spec='$libname$shrext'
+ ;;
+ openbsd*)
+ library_names_spec='$libname$shrext$versuffix'
+ ;;
+ os2*)
+ libname_spec='$name'
+ shrext=.dll
+ library_names_spec='$libname.a'
+ ;;
+ osf3* | osf4* | osf5*)
+ library_names_spec='$libname$shrext'
+ ;;
+ rdos*)
+ ;;
+ solaris*)
+ library_names_spec='$libname$shrext'
+ ;;
+ sunos4*)
+ library_names_spec='$libname$shrext$versuffix'
+ ;;
+ sysv4 | sysv4.3*)
+ library_names_spec='$libname$shrext'
+ ;;
+ sysv4*MP*)
+ library_names_spec='$libname$shrext'
+ ;;
+ sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+ library_names_spec='$libname$shrext'
+ ;;
+ uts4*)
+ library_names_spec='$libname$shrext'
+ ;;
+esac
+
+sed_quote_subst='s/\(["`$\\]\)/\\\1/g'
+escaped_wl=`echo "X$wl" | sed -e 's/^X//' -e "$sed_quote_subst"`
+shlibext=`echo "$shrext" | sed -e 's,^\.,,'`
+escaped_libname_spec=`echo "X$libname_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
+escaped_library_names_spec=`echo "X$library_names_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
+escaped_hardcode_libdir_flag_spec=`echo "X$hardcode_libdir_flag_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
+
+LC_ALL=C sed -e 's/^\([a-zA-Z0-9_]*\)=/acl_cv_\1=/' <<EOF
+
+# How to pass a linker flag through the compiler.
+wl="$escaped_wl"
+
+# Static library suffix (normally "a").
+libext="$libext"
+
+# Shared library suffix (normally "so").
+shlibext="$shlibext"
+
+# Format of library name prefix.
+libname_spec="$escaped_libname_spec"
+
+# Library names that the linker finds when passed -lNAME.
+library_names_spec="$escaped_library_names_spec"
+
+# Flag to hardcode \$libdir into a binary during linking.
+# This must work even if \$libdir does not exist.
+hardcode_libdir_flag_spec="$escaped_hardcode_libdir_flag_spec"
+
+# Whether we need a single -rpath flag with a separated argument.
+hardcode_libdir_separator="$hardcode_libdir_separator"
+
+# Set to yes if using DIR/libNAME.so during linking hardcodes DIR into the
+# resulting binary.
+hardcode_direct="$hardcode_direct"
+
+# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
+# resulting binary.
+hardcode_minus_L="$hardcode_minus_L"
+
+EOF
View
52 config/version.pl
@@ -0,0 +1,52 @@
+#!/usr/bin/perl
+# If you think this is stupid/overkill, blame dormando
+
+use warnings;
+use strict;
+
+my $version = `git describe`;
+chomp $version;
+# Test the various versions.
+#my $version = 'foob';
+#my $version = '1.4.2-30-gf966dba';
+#my $version = '1.4.3-rc1';
+#my $version = '1.4.3';
+unless ($version =~ m/^\d+\.\d+\.\d+/) {
+ write_file('m4/version.m4', "m4_define([VERSION_NUMBER], [UNKNOWN])\n");
+ exit;
+}
+
+$version =~ s/-/_/g;
+write_file('m4/version.m4', "m4_define([VERSION_NUMBER], [$version])\n");
+my ($VERSION, $FULLVERSION, $RELEASE);
+
+if ($version =~ m/^(\d+\.\d+\.\d+)_rc(\d+)$/) {
+ $VERSION = $1;
+ $FULLVERSION = $version;
+ $RELEASE = '0.1.rc' . $2;
+} elsif ($version =~ m/^(\d+\.\d+\.\d+)_(.+)$/) {
+ $VERSION = $1;
+ $FULLVERSION = $version;
+ $RELEASE = '1.' . $2;
+} elsif ($version =~ m/^(\d+\.\d+\.\d+)$/) {
+ $VERSION = $1;
+ $FULLVERSION = $version;
+ $RELEASE = '1';
+}
+
+sub write_file {
+ my $file = shift;
+ my $data = shift;
+ open(my $fh, "> $file") or die "Can't open $file: $!";
+ print $fh $data;
+ close($fh);
+}
+
+sub read_file {
+ my $file = shift;
+ local $/ = undef;
+ open(my $fh, "< $file") or die "Can't open $file: $!";
+ my $data = <$fh>;
+ close($fh);
+ return $data;
+}
View
138 configure.ac
@@ -1,117 +1,65 @@
-AC_PREREQ(2.52)
-AC_INIT(memcachetest, 0.5.0, ingenthr@cep.net)
-AC_CONFIG_SRCDIR(main.c)
-AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
-AM_CONFIG_HEADER(config.h)
+AC_PREREQ(2.59)
+m4_include([m4/version.m4])
+AC_INIT(memcachetest, VERSION_NUMBER, ingenthr@cep.net)
+AC_CONFIG_SRCDIR([main.c])
+AC_CONFIG_AUX_DIR(config)
+AM_CONFIG_HEADER([config.h])
+AC_CONFIG_MACRO_DIR([m4])
+AC_DISABLE_STATIC
-AH_TOP([#ifndef CONFIG_H
-#define CONFIG_H
-])
-
-AC_PROG_CC
-AC_PROG_CC_C99
-AM_PROG_CC_C_O
-AC_PROG_INSTALL
-AC_C_CONST
-
-AC_ARG_ENABLE(64bit,
- [AS_HELP_STRING([--enable-64bit],[build 64bit version])])
-if test "x$enable_64bit" == "xyes"
-then
- org_cflags=$CFLAGS
- CFLAGS=-m64
- AC_RUN_IFELSE(
- [AC_LANG_PROGRAM([], [dnl
-return sizeof(void*) == 8 ? 0 : 1;
- ])
- ],[
- CFLAGS="-m64 $org_cflags"
- ],[
- AC_MSG_ERROR([Don't know how to build a 64-bit object.])
- ])
-fi
+PANDORA_CANONICAL_TARGET(less-warnings, warnings-always-on)
+PANDORA_HAVE_LIBMEMCACHED
+PANDORA_HAVE_LIBVBUCKET
-AC_ARG_WITH(libmemcached,
- AS_HELP_STRING(--with-libmemcached,[Add support for libmemcached]),
- [
- if test "x$withval" = "xno"
- then
- without_libmemcached=true
- else
- if test "x$withval" != "x"
- then
- CFLAGS="-I$withval/include $CFLAGS"
- CPPFLAGS="-I$withval/include $CPPFLAGS"
- # TODO: linux should have --rpath instead of -R
- # TODO: MacOS has -rpath
- #LDFLAGS="-L$withval/lib -rpath $withval/lib"
- LDFLAGS="-L$withval/lib -R$withval/lib"
- fi
- fi
- ]
-)
-
-AC_ARG_WITH(memcached,
- AS_HELP_STRING(--with-memcached,[Specify location of memcached installation]),
- [
- if test "x$withval" = "xno"
- then
- without_memcached=true
- else
- if test "x$withval" != "x"
- then
- CFLAGS="-I$withval/include $CFLAGS"
- CPPFLAGS="-I$withval/include $CPPFLAGS"
- fi
- fi
- ]
-)
+AH_TOP([
+#ifndef CONFIG_H
+#define CONFIG_H
-# Currently I only support GCC and Sun Studio
-if test "$GCC" = "yes"
-then
- CFLAGS="-Wall -O3 $CFLAGS"
-else
- CFLAGS="-Xa -xstrconst -mt -xunroll=2 -xprefetch=auto -xprefetch_level=3 $CFLAGS"
-fi
+#ifdef _SYS_FEATURE_TESTS_H
+#error "You should include config.h as your first include file"
+#endif
+])
AC_SEARCH_LIBS(socket, socket)
AC_SEARCH_LIBS(gethostbyname, nsl)
AC_SEARCH_LIBS(log, m)
AC_SEARCH_LIBS(sqrt, m)
AC_SEARCH_LIBS(pthread_create, pthread)
+AC_SEARCH_LIBS(clock_gettime, rt)
-AC_CHECK_HEADER(sys/mman.h, AC_DEFINE(HAVE_MMAN_H, 1, [Define if you have sys/mman.h]))
-AC_CHECK_FUNC(mmap, AC_DEFINE(HAVE_MMAP, 1, [Define if you have mmap]))
-AC_CHECK_FUNC(madvise, AC_DEFINE(HAVE_MADVISE, 1, [Define if you have madvise]))
-AC_CHECK_FUNC(gethrtime, AC_DEFINE(HAVE_GETHRTIME, 1, [Define if you have gethrtime]))
-AS_IF(test "x${ac_cv_func_gethrtime}" = "xno",
- [AC_CHECK_FUNC(clock_gettime, AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [Define if you have clock_gettime]))
- AS_IF(test "x${ac_cv_func_clock_gettime}" = "xno",
- [AC_CHECK_FUNC(gettimeofday, AC_DEFINE(HAVE_GETTIMEOFDAY, 1, [Define if you have gettimeofday]))])
- ])
+AC_CHECK_HEADERS_ONCE(sys/mman.h memcached/protocol_binary.h)
+AC_CHECK_FUNCS_ONCE(mmap posix_madvise gethrtime clock_gettime gettimeofday)
AH_BOTTOM(
+#ifdef HAVE_SYS_MMAN_H
+#include <sys/mman.h>
+#endif
+
#ifndef HAVE_GETHRTIME
#include <stdint.h>
typedef uint64_t hrtime_t;
extern hrtime_t gethrtime();
#endif
+#endif
)
-if test "$without_libmemcaced" != "true"
-then
- AC_CHECK_HEADER(libmemcached/memcached.h,
- AC_SEARCH_LIBS(memcached_create, memcached,
- AC_DEFINE(HAVE_LIBMEMCACHED, 1, [Define if you have libmemcached/memcached.h])))
-fi
-
-if test "$without_memcaced" != "true"
-then
- AC_CHECK_HEADER(memcached/protocol_binary.h,
- AC_DEFINE(HAVE_PROTOCOL_BINARY, 1, [Define if you have memcached/protocol_binary.h]))
-fi
+dnl ----------------------------------------------------------------------------
-AH_BOTTOM([#endif])
AC_CONFIG_FILES(Makefile)
AC_OUTPUT
+echo "---"
+echo "Configuration summary for $PACKAGE_NAME version $VERSION"
+echo ""
+echo " * Installation prefix: $prefix"
+echo " * System type: $host_vendor-$host_os"
+echo " * Host CPU: $host_cpu"
+echo " * C Compiler: $CC_VERSION"
+echo " * C++ Compiler: $CXX_VERSION"
+echo " * Assertions enabled: $ac_cv_assert"
+echo " * Debug enabled: $with_debug"
+echo " * Warnings as failure: $ac_cv_warnings_as_errors"
+echo " * Support for binary protocol $ac_cv_header_memcached_protocol_binary_h"
+echo " * Support for libmemcached $ac_cv_libmemcached"
+echo " * Support for libvbucket $ac_cv_libvbucket"
+echo ""
+echo "---"
View
117 libmemc.c
@@ -60,10 +60,10 @@ struct Memcache {
static struct Server* server_create(const char *name, in_port_t port);
static void server_destroy(struct Server *server);
-static int textual_store(struct Server* server, enum StoreCommand cmd,
+static int textual_store(struct Server* server, enum StoreCommand cmd,
const struct Item *item);
static int textual_get(struct Server* server, struct Item* item);
-static int binary_store(struct Server* server, enum StoreCommand cmd,
+static int binary_store(struct Server* server, enum StoreCommand cmd,
const struct Item *item);
static int binary_get(struct Server* server, struct Item* item);
static int libmemc_store(struct Memcache* handle, enum StoreCommand cmd, const struct Item *item);
@@ -92,23 +92,23 @@ void libmemc_destroy(struct Memcache* handle) {
int libmemc_add_server(struct Memcache *handle, const char *host, in_port_t port) {
struct Server** servers = calloc(handle->no_servers + 1, sizeof(struct Server));
struct Server** old = handle->servers;
-
+
if (servers == 0) {
return -1;
}
-
+
for (int ii = 0; ii < handle->no_servers; ++ii) {
servers[ii] = handle->servers[ii];
}
-
+
handle->servers = servers;
free(old);
-
+
struct Server *server = server_create(host, port);
if (server != NULL) {
handle->servers[handle->no_servers++] = server;
}
-
+
return 0;
}
@@ -117,11 +117,11 @@ int libmemc_add(struct Memcache *handle, const struct Item *item) {
}
int libmemc_set(struct Memcache *handle, const struct Item *item) {
- return libmemc_store(handle, set, item);
+ return libmemc_store(handle, set, item);
}
int libmemc_replace(struct Memcache *handle, const struct Item *item) {
- return libmemc_store(handle, replace, item);
+ return libmemc_store(handle, replace, item);
}
int libmemc_get(struct Memcache *handle, struct Item *item) {
@@ -156,7 +156,7 @@ static struct addrinfo *lookuphost(const char *hostname, in_port_t port)
hints.ai_family = AF_UNSPEC;
hints.ai_protocol = IPPROTO_TCP;
hints.ai_socktype = SOCK_STREAM;
-
+
(void)snprintf(service, NI_MAXSERV, "%d", port);
if ((error = getaddrinfo(hostname, service, &hints, &ai)) != 0) {
if (error != EAI_SYSTEM) {
@@ -173,7 +173,7 @@ int libmemc_connect_server(const char *hostname, in_port_t port)
{
struct addrinfo *ai = lookuphost(hostname, port);
int sock = -1;
- if (ai != NULL) {
+ if (ai != NULL) {
if ((sock = socket(ai->ai_family, ai->ai_socktype,
ai->ai_protocol)) != -1) {
if (connect(sock, ai->ai_addr, ai->ai_addrlen) == -1) {
@@ -185,7 +185,7 @@ int libmemc_connect_server(const char *hostname, in_port_t port)
} else {
fprintf(stderr, "Failed to create socket: %s\n", strerror(errno));
}
-
+
freeaddrinfo(ai);
}
return sock;
@@ -216,7 +216,7 @@ static struct Server *get_server(struct Memcache *handle, const char *key) {
}
}
-static int libmemc_store(struct Memcache* handle, enum StoreCommand cmd,
+static int libmemc_store(struct Memcache* handle, enum StoreCommand cmd,
const struct Item *item) {
struct Server* server = get_server(handle, item->key);
if (server == NULL) {
@@ -227,7 +227,7 @@ static int libmemc_store(struct Memcache* handle, enum StoreCommand cmd,
return -1;
}
}
-
+
if (handle->protocol == Binary) {
return binary_store(server, cmd, item);
} else {
@@ -258,7 +258,7 @@ struct Server* server_create(const char *name, in_port_t port) {
if (ai != NULL) {
ret = calloc(1, sizeof(struct Server));
if (ret != 0) {
- char buffer[1024];
+ char buffer[1024];
ret->sock = -1;
ret->errmsg = 0;
ret->addrinfo = ai;
@@ -273,7 +273,7 @@ struct Server* server_create(const char *name, in_port_t port) {
}
}
}
-
+
return ret;
}
@@ -287,7 +287,7 @@ static void server_disconnect(struct Server *server) {
static int server_connect(struct Server *server)
{
int flag = 1;
-
+
if ((server->sock = socket(server->addrinfo->ai_family,
server->addrinfo->ai_socktype,
server->addrinfo->ai_protocol)) == -1) {
@@ -301,7 +301,7 @@ static int server_connect(struct Server *server)
&flag, sizeof(flag)) == -1) {
perror("Failed to set TCP_NODELAY");
}
-
+
if (connect(server->sock, server->addrinfo->ai_addr,
server->addrinfo->ai_addrlen) == -1) {
char errmsg[1024];
@@ -310,7 +310,7 @@ static int server_connect(struct Server *server)
server_disconnect(server);
return -1;
}
-
+
return 0;
}
@@ -330,7 +330,7 @@ static int server_send(struct Server* server, const void *data, size_t size) {
offset += sent;
}
} while (offset < size);
-
+
return 0;
}
@@ -349,7 +349,7 @@ static int server_sendv(struct Server* server, struct iovec *iov, int iovcnt) {
for (int ii = 0; ii < iovcnt; ++ ii) {
size += iov[ii].iov_len;
}
-
+
do {
ssize_t sent = writev(server->sock, iov, iovcnt);
if (sent == -1) {
@@ -364,19 +364,14 @@ static int server_sendv(struct Server* server, struct iovec *iov, int iovcnt) {
if (sent == size) {
return 0;
}
-
+
for (int ii = 0; ii < iovcnt && sent > 0; ++ii) {
if (iov[ii].iov_len < sent) {
size -= iov[ii].iov_len;
sent -= iov[ii].iov_len;
iov[ii].iov_len = 0;
} else {
-#ifdef __sun
- iov[ii].iov_base += sent;
-#else
- // iov_base is a void pointer...
iov[ii].iov_base = ((char*)iov[ii].iov_base) + sent;
-#endif
iov[ii].iov_len -= sent;
size -= sent;
break;
@@ -410,13 +405,13 @@ static size_t server_receive(struct Server* server, char* data, size_t size, int
offset += nread;
}
} while (offset < size && !stop);
-
+
if (line && !stop) {
server->errmsg = strdup("Protocol error");
server_disconnect(server);
return -1;
}
-
+
return offset;
}
@@ -443,7 +438,7 @@ static int64_t swap64(int64_t in) {
/**
* Implementation of the Binary protocol
*/
-static int binary_get(struct Server* server, struct Item* item)
+static int binary_get(struct Server* server, struct Item* item)
{
#if HAVE_PROTOCOL_BINARY
uint16_t keylen = item->keylen;
@@ -455,7 +450,7 @@ static int binary_get(struct Server* server, struct Item* item)
request.message.header.request.keylen = htons(keylen);
request.message.header.request.datatype = PROTOCOL_BINARY_RAW_BYTES;
request.message.header.request.bodylen = htonl(bodylen);
-
+
struct iovec iovec[2];
iovec[0].iov_base = (void*)&request;
iovec[0].iov_len = sizeof(request);
@@ -469,7 +464,7 @@ static int binary_get(struct Server* server, struct Item* item)
sizeof(response.bytes), 0);
if (nread != sizeof(response)) {
server->errmsg = strdup("Protocol error");
- server_disconnect(server);
+ server_disconnect(server);
return -1;
}
@@ -487,11 +482,11 @@ static int binary_get(struct Server* server, struct Item* item)
item->data = malloc(item->size);
if (item->data == NULL) {
server->errmsg = strdup("failed to allocate memory\n");
- server_disconnect(server);
+ server_disconnect(server);
return -1;
}
}
-
+
if (response.message.header.response.extlen != 0) {
assert(response.message.header.response.extlen == 4);
uint32_t flags;
@@ -514,19 +509,19 @@ static int binary_get(struct Server* server, struct Item* item)
size_t nread = server_receive(server, item->data, item->size, 0);
assert(nread == item->size);
}
-
+
item->cas_id = swap64(response.message.header.response.cas);
} else {
char *buffer = malloc(bodylen + 1);
if (buffer == NULL) {
server->errmsg = strdup("failed to allocate memory\n");
- server_disconnect(server);
+ server_disconnect(server);
return -1;
}
buffer[bodylen] = '\0';
server_receive(server, buffer, bodylen, 0);
server->errmsg = buffer;
-
+
return -1;
}
@@ -535,9 +530,9 @@ static int binary_get(struct Server* server, struct Item* item)
return -1;
}
-static int binary_store(struct Server* server,
- enum StoreCommand cmd,
- const struct Item *item)
+static int binary_store(struct Server* server,
+ enum StoreCommand cmd,
+ const struct Item *item)
{
#if HAVE_PROTOCOL_BINARY
protocol_binary_request_set request = { .bytes = {0} };
@@ -564,7 +559,7 @@ static int binary_store(struct Server* server,
request.message.header.request.cas = swap64(item->cas_id);
request.message.body.flags = 0;
request.message.body.expiration = htonl(item->exptime);
-
+
struct iovec iovec[3];
iovec[0].iov_base = (void*)&request;
iovec[0].iov_len = sizeof(request);
@@ -580,21 +575,21 @@ static int binary_store(struct Server* server,
sizeof(response.bytes), 0);
if (nread != sizeof(response)) {
server->errmsg = strdup("Protocol error");
- server_disconnect(server);
+ server_disconnect(server);
return -1;
}
if (response.message.header.response.status == 0 &&
response.message.header.response.bodylen != 0) {
server->errmsg = strdup("Unexpected data returned\n");
- server_disconnect(server);
+ server_disconnect(server);
return -1;
} else if (response.message.header.response.bodylen != 0) {
uint32_t len = ntohl(response.message.header.response.bodylen);
char* buffer = malloc(len);
if (buffer == 0) {
server->errmsg = strdup("failed to allocate memory\n");
- server_disconnect(server);
+ server_disconnect(server);
return -1;
}
@@ -628,14 +623,14 @@ static int parse_value_line(char *header, uint32_t* flag, size_t* size, char** d
if (strstr(end, "\r\n") != end) {
return -1;
}
-
+
*data = end + 2;
return 0;
}
-static int textual_get(struct Server* server, struct Item* item) {
+static int textual_get(struct Server* server, struct Item* item) {
uint32_t flag;
-
+
struct iovec iovec[3];
iovec[0].iov_base = (char*)"get ";
iovec[0].iov_len = 4;
@@ -644,14 +639,14 @@ static int textual_get(struct Server* server, struct Item* item) {
iovec[2].iov_base = (char*)"\r\n";
iovec[2].iov_len = 2;
server_sendv(server, iovec, 3);
-
+
size_t nread = server_receive(server, server->buffer,server->buffersize, 1);
-
+
// Split the header line
if (strstr(server->buffer, "VALUE ") == server->buffer) {
size_t elemsize;
char *ptr;
-
+
if (parse_value_line(server->buffer + 6, &flag, &elemsize, &ptr) == -1){
server->errmsg = strdup("Protocol error");
server_disconnect(server);
@@ -662,14 +657,14 @@ static int textual_get(struct Server* server, struct Item* item) {
#endif
ptrdiff_t headsize = ptr - server->buffer;
size_t chunk = nread - headsize;
-
+
if (chunk < (elemsize + 7)) {
// I don't have all of the data.. keep on reading
server_receive(server, server->buffer + nread,
(elemsize - chunk) + 7, 0);
}
-
- void *result = ptr;
+
+ void *result = ptr;
if (elemsize > item->size) {
if (item->data != 0) {
free(item->data);
@@ -681,7 +676,7 @@ static int textual_get(struct Server* server, struct Item* item) {
return -1;
}
}
-
+
memcpy(item->data, result, item->size);
return 0;
} else if (strstr(server->buffer, "END") == server->buffer) {
@@ -691,17 +686,17 @@ static int textual_get(struct Server* server, struct Item* item) {
abort();
}
-static int textual_store(struct Server* server,
- enum StoreCommand cmd,
+static int textual_store(struct Server* server,
+ enum StoreCommand cmd,
const struct Item *item) {
static const char* const commands[] = { "add ", "set ", "replace " };
-
+
uint32_t flags = 0;
const void *dta = item->data;
- size_t size = item->size;
- ssize_t len = sprintf(server->buffer, " %d %ld %ld\r\n",
+ size_t size = item->size;
+ ssize_t len = sprintf(server->buffer, " %d %ld %ld\r\n",
flags, (long)item->exptime, (long)item->size);
-
+
struct iovec iovec[5];
iovec[0].iov_base = (char*)commands[cmd];
iovec[0].iov_len = strlen(commands[cmd]);
@@ -714,7 +709,7 @@ static int textual_store(struct Server* server,
iovec[4].iov_base = (char*)"\r\n";
iovec[4].iov_len = 2;
server_sendv(server, iovec, 5);
-
+
size_t offset = 0;
do {
len = recv(server->sock, (void*)(server->buffer + offset),
View
103 m4/ac_cxx_compile_stdcxx_0x.m4
@@ -0,0 +1,103 @@
+# ===========================================================================
+# http://autoconf-archive.cryp.to/ac_cxx_compile_stdcxx_0x.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AC_CXX_COMPILE_STDCXX_0X
+#
+# DESCRIPTION
+#
+# Check for baseline language coverage in the compiler for the C++0x
+# standard.
+#
+# LICENSE
+#
+# Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com>
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved.
+
+AC_DEFUN([AC_CXX_COMPILE_STDCXX_0X], [
+ AC_CACHE_CHECK(if g++ supports C++0x features without additional flags,
+ ac_cv_cxx_compile_cxx0x_native,
+ [AC_LANG_SAVE
+ AC_LANG_CPLUSPLUS
+ AC_TRY_COMPILE([
+ template <typename T>
+ struct check
+ {
+ static_assert(sizeof(int) <= sizeof(T), "not big enough");
+ };
+
+ typedef check<check<bool>> right_angle_brackets;
+
+ int a;
+ decltype(a) b;
+
+ typedef check<int> check_type;
+ check_type c;
+ check_type&& cr = c;],,
+ ac_cv_cxx_compile_cxx0x_native=yes, ac_cv_cxx_compile_cxx0x_native=no)
+ AC_LANG_RESTORE
+ ])
+
+ AC_CACHE_CHECK(if g++ supports C++0x features with -std=c++0x,
+ ac_cv_cxx_compile_cxx0x_cxx,
+ [AC_LANG_SAVE
+ AC_LANG_CPLUSPLUS
+ ac_save_CXXFLAGS="$CXXFLAGS"
+ CXXFLAGS="$CXXFLAGS -std=c++0x"
+ AC_TRY_COMPILE([
+ template <typename T>
+ struct check
+ {
+ static_assert(sizeof(int) <= sizeof(T), "not big enough");
+ };
+
+ typedef check<check<bool>> right_angle_brackets;
+
+ int a;
+ decltype(a) b;
+
+ typedef check<int> check_type;
+ check_type c;
+ check_type&& cr = c;],,
+ ac_cv_cxx_compile_cxx0x_cxx=yes, ac_cv_cxx_compile_cxx0x_cxx=no)
+ CXXFLAGS="$ac_save_CXXFLAGS"
+ AC_LANG_RESTORE
+ ])
+
+ AC_CACHE_CHECK(if g++ supports C++0x features with -std=gnu++0x,
+ ac_cv_cxx_compile_cxx0x_gxx,
+ [AC_LANG_SAVE
+ AC_LANG_CPLUSPLUS
+ ac_save_CXXFLAGS="$CXXFLAGS"
+ CXXFLAGS="$CXXFLAGS -std=gnu++0x"
+ AC_TRY_COMPILE([
+ template <typename T>
+ struct check
+ {
+ static_assert(sizeof(int) <= sizeof(T), "not big enough");
+ };
+
+ typedef check<check<bool>> right_angle_brackets;
+
+ int a;
+ decltype(a) b;
+
+ typedef check<int> check_type;
+ check_type c;
+ check_type&& cr = c;],,
+ ac_cv_cxx_compile_cxx0x_gxx=yes, ac_cv_cxx_compile_cxx0x_gxx=no)
+ CXXFLAGS="$ac_save_CXXFLAGS"
+ AC_LANG_RESTORE
+ ])
+
+ if test "$ac_cv_cxx_compile_cxx0x_native" = yes ||
+ test "$ac_cv_cxx_compile_cxx0x_cxx" = yes ||
+ test "$ac_cv_cxx_compile_cxx0x_gxx" = yes; then
+ AC_DEFINE(HAVE_STDCXX_0X,,[Define if g++ supports C++0x features. ])
+ fi
+])
View
67 m4/ac_cxx_header_stdcxx_98.m4
@@ -0,0 +1,67 @@
+dnl Copyright © 2008 Benjamin Kosnik <bkoz@redhat.com>
+
+dnl Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved.
+
+
+AC_DEFUN([AC_CXX_HEADER_STDCXX_98], [
+ AC_CACHE_CHECK(for ISO C++ 98 include files,
+ ac_cv_cxx_stdcxx_98,
+ [AC_LANG_PUSH(C++)
+ AC_TRY_COMPILE([
+ #include <cassert>
+ #include <cctype>
+ #include <cerrno>
+ #include <cfloat>
+ #include <ciso646>
+ #include <climits>
+ #include <clocale>
+ #include <cmath>
+ #include <csetjmp>
+ #include <csignal>
+ #include <cstdarg>
+ #include <cstddef>
+ #include <cstdio>
+ #include <cstdlib>
+ #include <cstring>
+ #include <ctime>
+
+ #include <algorithm>
+ #include <bitset>
+ #include <complex>
+ #include <deque>
+ #include <exception>
+ #include <fstream>
+ #include <functional>
+ #include <iomanip>
+ #include <ios>
+ #include <iosfwd>
+ #include <iostream>
+ #include <istream>
+ #include <iterator>
+ #include <limits>
+ #include <list>
+ #include <locale>
+ #include <map>
+ #include <memory>
+ #include <new>
+ #include <numeric>
+ #include <ostream>
+ #include <queue>
+ #include <set>
+ #include <sstream>
+ #include <stack>
+ #include <stdexcept>
+ #include <streambuf>
+ #include <string>
+ #include <typeinfo>
+ #include <utility>
+ #include <valarray>
+ #include <vector>
+ ],,
+ ac_cv_cxx_stdcxx_98=yes, ac_cv_cxx_stdcxx_98=no)
+ AC_LANG_POP()
+ ])
+ if test "$ac_cv_cxx_stdcxx_98" = yes; then
+ AC_DEFINE(STDCXX_98_HEADERS,,[Define if ISO C++ 1998 header files are present. ])
+ fi
+])
View
276 m4/acx_pthread.m4
@@ -0,0 +1,276 @@
+##### http://autoconf-archive.cryp.to/acx_pthread.html
+#
+# SYNOPSIS
+#
+# ACX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
+#
+# DESCRIPTION
+#
+# This macro figures out how to build C programs using POSIX threads.
+# It sets the PTHREAD_LIBS output variable to the threads library and
+# linker flags, and the PTHREAD_CFLAGS output variable to any special
+# C compiler flags that are needed. (The user can also force certain
+# compiler flags/libs to be tested by setting these environment
+# variables.)
+#
+# Also sets PTHREAD_CC to any special C compiler that is needed for
+# multi-threaded programs (defaults to the value of CC otherwise).
+# (This is necessary on AIX to use the special cc_r compiler alias.)
+#
+# NOTE: You are assumed to not only compile your program with these
+# flags, but also link it with them as well. e.g. you should link
+# with $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS
+# $LIBS
+#
+# If you are only building threads programs, you may wish to use
+# these variables in your default LIBS, CFLAGS, and CC:
+#
+# LIBS="$PTHREAD_LIBS $LIBS"
+# CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+# CC="$PTHREAD_CC"
+#
+# In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute
+# constant has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to
+# that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
+#
+# ACTION-IF-FOUND is a list of shell commands to run if a threads
+# library is found, and ACTION-IF-NOT-FOUND is a list of commands to
+# run it if it is not found. If ACTION-IF-FOUND is not specified, the
+# default action will define HAVE_PTHREAD.
+#
+# Please let the authors know if this macro fails on any platform, or
+# if you have any other suggestions or comments. This macro was based
+# on work by SGJ on autoconf scripts for FFTW (http://www.fftw.org/)
+# (with help from M. Frigo), as well as ac_pthread and hb_pthread
+# macros posted by Alejandro Forero Cuervo to the autoconf macro
+# repository. We are also grateful for the helpful feedback of
+# numerous users.
+#
+# LAST MODIFICATION
+#
+# 2006-05-29
+#
+# COPYLEFT
+#
+# Copyright (c) 2006 Steven G. Johnson <stevenj@alum.mit.edu>
+#
+# 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 2 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+#
+# 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 Macro 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.
+
+AC_DEFUN([ACX_PTHREAD], [
+AC_REQUIRE([AC_CANONICAL_HOST])
+AC_LANG_PUSH([C])
+acx_pthread_ok=no
+
+# We used to check for pthread.h first, but this fails if pthread.h
+# requires special compiler flags (e.g. on True64 or Sequent).
+# It gets checked for in the link test anyway.
+
+# First of all, check if the user has set any of the PTHREAD_LIBS,
+# etcetera environment variables, and if threads linking works using
+# them:
+if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+ save_LIBS="$LIBS"
+ LIBS="$PTHREAD_LIBS $LIBS"
+ AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
+ AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes)
+ AC_MSG_RESULT($acx_pthread_ok)
+ if test x"$acx_pthread_ok" = xno; then
+ PTHREAD_LIBS=""
+ PTHREAD_CFLAGS=""
+ fi
+ LIBS="$save_LIBS"
+ CFLAGS="$save_CFLAGS"
+fi
+
+# We must check for the threads library under a number of different
+# names; the ordering is very important because some systems
+# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
+# libraries is broken (non-POSIX).
+
+# Create a list of thread flags to try. Items starting with a "-" are
+# C compiler flags, and other items are library names, except for "none"
+# which indicates that we try without any flags at all, and "pthread-config"
+# which is a program returning the flags for the Pth emulation library.
+
+acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
+
+# The ordering *is* (sometimes) important. Some notes on the
+# individual items follow:
+
+# pthreads: AIX (must check this before -lpthread)
+# none: in case threads are in libc; should be tried before -Kthread and
+# other compiler flags to prevent continual compiler warnings
+# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
+# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
+# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
+# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
+# -pthreads: Solaris/gcc
+# -mthreads: Mingw32/gcc, Lynx/gcc
+# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
+# doesn't hurt to check since this sometimes defines pthreads too;
+# also defines -D_REENTRANT)
+# ... -mt is also the pthreads flag for HP/aCC
+# pthread: Linux, etcetera
+# --thread-safe: KAI C++
+# pthread-config: use pthread-config program (for GNU Pth library)
+
+case "${host_cpu}-${host_os}" in
+ *solaris*)
+
+ # On Solaris (at least, for some versions), libc contains stubbed
+ # (non-functional) versions of the pthreads routines, so link-based
+ # tests will erroneously succeed. (We need to link with -pthreads/-mt/
+ # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
+ # a function called by this macro, so we could check for that, but
+ # who knows whether they'll stub that too in a future libc.) So,
+ # we'll just look for -pthreads and -lpthread first:
+
+ acx_pthread_flags="-pthreads pthread -mt -pthread $acx_pthread_flags"
+ ;;
+esac
+
+if test x"$acx_pthread_ok" = xno; then
+for flag in $acx_pthread_flags; do
+
+ case $flag in
+ none)
+ AC_MSG_CHECKING([whether pthreads work without any flags])
+ ;;
+
+ -*)
+ AC_MSG_CHECKING([whether pthreads work with $flag])
+ PTHREAD_CFLAGS="$flag"
+ ;;
+
+ pthread-config)
+ AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no)
+ if test x"$acx_pthread_config" = xno; then continue; fi
+ PTHREAD_CFLAGS="`pthread-config --cflags`"
+ PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
+ ;;
+
+ *)
+ AC_MSG_CHECKING([for the pthreads library -l$flag])
+ PTHREAD_LIBS="-l$flag"
+ ;;
+ esac
+
+ save_LIBS="$LIBS"
+ save_CFLAGS="$CFLAGS"
+ LIBS="$PTHREAD_LIBS $LIBS"
+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+
+ # Check for various functions. We must include pthread.h,
+ # since some functions may be macros. (On the Sequent, we
+ # need a special flag -Kthread to make this header compile.)
+ # We check for pthread_join because it is in -lpthread on IRIX
+ # while pthread_create is in libc. We check for pthread_attr_init
+ # due to DEC craziness with -lpthreads. We check for
+ # pthread_cleanup_push because it is one of the few pthread
+ # functions on Solaris that doesn't have a non-functional libc stub.
+ # We try pthread_create on general principles.
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]], [[pthread_t th; pthread_join(th, 0);
+ pthread_attr_init(0); pthread_cleanup_push(0, 0);
+ pthread_create(0,0,0,0); pthread_cleanup_pop(0); ]])],[acx_pthread_ok=yes],[])
+
+ LIBS="$save_LIBS"
+ CFLAGS="$save_CFLAGS"
+
+ AC_MSG_RESULT($acx_pthread_ok)
+ if test "x$acx_pthread_ok" = xyes; then
+ break;
+ fi
+
+ PTHREAD_LIBS=""
+ PTHREAD_CFLAGS=""
+done
+fi
+
+# Various other checks:
+if test "x$acx_pthread_ok" = xyes; then
+ save_LIBS="$LIBS"
+ LIBS="$PTHREAD_LIBS $LIBS"
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+
+ # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
+ AC_MSG_CHECKING([for joinable pthread attribute])
+ attr_name=unknown
+ for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]], [[int attr=$attr; return attr;]])],[attr_name=$attr; break],[])
+ done
+ AC_MSG_RESULT($attr_name)
+ if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
+ AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name,
+ [Define to necessary symbol if this constant
+ uses a non-standard name on your system.])
+ fi
+
+ AC_MSG_CHECKING([if more special flags are required for pthreads])
+ flag=no
+ case "${host_cpu}-${host_os}" in
+ *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";;
+ *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";;
+ esac
+ AC_MSG_RESULT(${flag})
+ if test "x$flag" != xno; then
+ PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
+ fi
+
+ LIBS="$save_LIBS"
+ CFLAGS="$save_CFLAGS"
+
+ # More AIX lossage: must compile with xlc_r or cc_r
+ if test x"$GCC" != xyes; then
+ AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC})
+ else
+ PTHREAD_CC=$CC
+ fi
+else
+ PTHREAD_CC="$CC"
+fi
+
+AC_SUBST(PTHREAD_LIBS)
+AC_SUBST(PTHREAD_CFLAGS)
+AC_SUBST(PTHREAD_CC)
+
+# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
+if test x"$acx_pthread_ok" = xyes; then
+ ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])
+ :
+else
+ acx_pthread_ok=no
+ $2
+fi
+AC_LANG_POP([])
+])dnl ACX_PTHREAD
View
110 m4/lib-ld.m4
@@ -0,0 +1,110 @@
+# lib-ld.m4 serial 3 (gettext-0.13)
+dnl Copyright (C) 1996-2003 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 Subroutines of libtool.m4,
+dnl with replacements s/AC_/AC_LIB/ and s/lt_cv/acl_cv/ to avoid collision
+dnl with libtool.m4.
+
+dnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no.
+AC_DEFUN([AC_LIB_PROG_LD_GNU],
+[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], acl_cv_prog_gnu_ld,
+[# I'd rather use --version here, but apparently some GNU ld's only accept -v.
+case `$LD -v 2>&1 </dev/null` in
+*GNU* | *'with BFD'*)
+ acl_cv_prog_gnu_ld=yes ;;
+*)
+ acl_cv_prog_gnu_ld=no ;;
+esac])
+with_gnu_ld=$acl_cv_prog_gnu_ld
+])
+
+dnl From libtool-1.4. Sets the variable LD.
+AC_DEFUN([AC_LIB_PROG_LD],
+[AC_ARG_WITH(gnu-ld,
+[ --with-gnu-ld assume the C compiler uses GNU ld [default=no]],
+test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
+AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([AC_CANONICAL_HOST])dnl
+# Prepare PATH_SEPARATOR.
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+ echo "#! /bin/sh" >conf$$.sh
+ echo "exit 0" >>conf$$.sh
+ chmod +x conf$$.sh
+ if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
+ PATH_SEPARATOR=';'
+ else
+ PATH_SEPARATOR=:
+ fi
+ rm -f conf$$.sh
+fi
+ac_prog=ld
+if test "$GCC" = yes; then
+ # Check if gcc -print-prog-name=ld gives a path.
+ AC_MSG_CHECKING([for ld used by GCC])
+ case $host in
+ *-*-mingw*)
+ # gcc leaves a trailing carriage return which upsets mingw
+ ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+ *)
+ ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+ esac
+ case $ac_prog in
+ # Accept absolute paths.
+ [[\\/]* | [A-Za-z]:[\\/]*)]
+ [re_direlt='/[^/][^/]*/\.\./']
+ # Canonicalize the path of ld
+ ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
+ while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
+ ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
+ done
+ test -z "$LD" && LD="$ac_prog"
+ ;;
+ "")
+ # If it fails, then pretend we aren't using GCC.
+ ac_prog=ld
+ ;;
+ *)
+ # If it is relative, then search for the first ld in PATH.
+ with_gnu_ld=unknown
+ ;;
+ esac
+elif test "$with_gnu_ld" = yes; then
+ AC_MSG_CHECKING([for GNU ld])
+else
+ AC_MSG_CHECKING([for non-GNU ld])
+fi
+AC_CACHE_VAL(acl_cv_path_LD,
+[if test -z "$LD"; then
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
+ for ac_dir in $PATH; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+ acl_cv_path_LD="$ac_dir/$ac_prog"
+ # Check to see if the program is GNU ld. I'd rather use --version,
+ # but apparently some GNU ld's only accept -v.
+ # Break only if it was the GNU/non-GNU ld that we prefer.
+ case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in
+ *GNU* | *'with BFD'*)
+ test "$with_gnu_ld" != no && break ;;
+ *)
+ test "$with_gnu_ld" != yes && break ;;
+ esac
+ fi
+ done
+ IFS="$ac_save_ifs"
+else
+ acl_cv_path_LD="$LD" # Let the user override the test with a path.
+fi])
+LD="$acl_cv_path_LD"
+if test -n "$LD"; then
+ AC_MSG_RESULT($LD)
+else
+ AC_MSG_RESULT(no)
+fi
+test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
+AC_LIB_PROG_LD_GNU
+])
View
767 m4/lib-link.m4
@@ -0,0 +1,767 @@
+# lib-link.m4 serial 18 (gettext-0.18)
+dnl Copyright (C) 2001-2009 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.
+
+AC_PREREQ([2.54])
+
+dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and
+dnl the libraries corresponding to explicit and implicit dependencies.
+dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and
+dnl augments the CPPFLAGS variable.
+dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname
+dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
+AC_DEFUN([AC_LIB_LINKFLAGS],
+[
+ AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
+ AC_REQUIRE([AC_LIB_RPATH])
+ pushdef([Name],[translit([$1],[./-], [___])])
+ pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
+ [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
+ AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [
+ AC_LIB_LINKFLAGS_BODY([$1], [$2])
+ ac_cv_lib[]Name[]_libs="$LIB[]NAME"
+ ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME"
+ ac_cv_lib[]Name[]_cppflags="$INC[]NAME"
+ ac_cv_lib[]Name[]_prefix="$LIB[]NAME[]_PREFIX"
+ ])
+ LIB[]NAME="$ac_cv_lib[]Name[]_libs"
+ LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs"
+ INC[]NAME="$ac_cv_lib[]Name[]_cppflags"
+ LIB[]NAME[]_PREFIX="$ac_cv_lib[]Name[]_prefix"
+ AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
+ AC_SUBST([LIB]NAME)
+ AC_SUBST([LTLIB]NAME)
+ AC_SUBST([LIB]NAME[_PREFIX])
+ dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the
+ dnl results of this search when this library appears as a dependency.
+ HAVE_LIB[]NAME=yes
+ popdef([NAME])
+ popdef([Name])
+])
+
+dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode, [system])
+dnl searches for libname and the libraries corresponding to explicit and
+dnl implicit dependencies, together with the specified include files and
+dnl the ability to compile and link the specified testcode. If found, it
+dnl sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME} and
+dnl LTLIB${NAME} variables and augments the CPPFLAGS variable, and
+dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs
+dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty.
+dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname
+dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
+AC_DEFUN([AC_LIB_HAVE_LINKFLAGS],
+[
+ AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
+ AC_REQUIRE([AC_LIB_RPATH])
+ pushdef([Name],[translit([$1],[./-], [___])])
+ pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
+ [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
+
+ dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME
+ dnl accordingly.
+ AC_LIB_LINKFLAGS_BODY([$1], [$2], [$5])
+
+ dnl Add $INC[]NAME to CPPFLAGS before performing the following checks,
+ dnl because if the user has installed lib[]Name and not disabled its use
+ dnl via --without-lib[]Name-prefix, he wants to use it.
+ ac_save_CPPFLAGS="$CPPFLAGS"
+ AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
+
+ AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [
+ ac_save_LIBS="$LIBS"
+ LIBS="$LIBS $LIB[]NAME"
+ AC_TRY_LINK([$3], [$4], [ac_cv_lib[]Name=yes], [ac_cv_lib[]Name=no])
+ LIBS="$ac_save_LIBS"
+ ])
+ if test "$ac_cv_lib[]Name" = yes; then
+ HAVE_LIB[]NAME=yes
+ AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the $1 library.])
+ AC_MSG_CHECKING([how to link with lib[]$1])
+ AC_MSG_RESULT([$LIB[]NAME])
+ else
+ HAVE_LIB[]NAME=no
+ dnl If $LIB[]NAME didn't lead to a usable library, we don't need
+ dnl $INC[]NAME either.
+ CPPFLAGS="$ac_save_CPPFLAGS"
+ LIB[]NAME=
+ LTLIB[]NAME=
+ LIB[]NAME[]_PREFIX=
+ fi
+ AC_SUBST([HAVE_LIB]NAME)
+ AC_SUBST([LIB]NAME)
+ AC_SUBST([LTLIB]NAME)
+ AC_SUBST([LIB]NAME[_PREFIX])
+ popdef([NAME])
+ popdef([Name])
+])
+
+dnl Determine the platform dependent parameters needed to use rpath:
+dnl acl_libext,
+dnl acl_shlibext,
+dnl acl_hardcode_libdir_flag_spec,
+dnl acl_hardcode_libdir_separator,
+dnl acl_hardcode_direct,
+dnl acl_hardcode_minus_L.
+AC_DEFUN([AC_LIB_RPATH],
+[
+ dnl Tell automake >= 1.10 to complain if config.rpath is missing.
+ m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([config.rpath])])
+ AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS
+ AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld
+ AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host
+ AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir
+ AC_CACHE_CHECK([for shared library run path origin], [acl_cv_rpath], [
+ CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
+ ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
+ . ./conftest.sh
+ rm -f ./conftest.sh
+ acl_cv_rpath=done
+ ])
+ wl="$acl_cv_wl"
+ acl_libext="$acl_cv_libext"
+ acl_shlibext="$acl_cv_shlibext"
+ acl_libname_spec="$acl_cv_libname_spec"
+ acl_library_names_spec="$acl_cv_library_names_spec"
+ acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
+ acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
+ acl_hardcode_direct="$acl_cv_hardcode_direct"
+ acl_hardcode_minus_L="$acl_cv_hardcode_minus_L"
+ dnl Determine whether the user wants rpath handling at all.
+ AC_ARG_ENABLE([rpath],
+ [ --disable-rpath do not hardcode runtime library paths],
+ :, enable_rpath=yes)
+])
+
+dnl AC_LIB_FROMPACKAGE(name, package)
+dnl declares that libname comes from the given package. The configure file
+dnl will then not have a --with-libname-prefix option but a
+dnl --with-package-prefix option. Several libraries can come from the same
+dnl package. This declaration must occur before an AC_LIB_LINKFLAGS or similar
+dnl macro call that searches for libname.
+AC_DEFUN([AC_LIB_FROMPACKAGE],
+[
+ pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
+ [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
+ define([acl_frompackage_]NAME, [$2])
+ popdef([NAME])
+ pushdef([PACK],[$2])
+ pushdef([PACKUP],[translit(PACK,[abcdefghijklmnopqrstuvwxyz./-],
+ [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
+ define([acl_libsinpackage_]PACKUP,
+ m4_ifdef([acl_libsinpackage_]PACKUP, [acl_libsinpackage_]PACKUP[[, ]],)[lib$1])
+ popdef([PACKUP])
+ popdef([PACK])
+])
+
+dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies, system]) searches for
+dnl libname and the libraries corresponding to explicit and implicit
+dnl dependencies.
+dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables.
+dnl Also, sets the LIB${NAME}_PREFIX variable to nonempty if libname was found
+dnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
+dnl If system==system, -isystem is used instead of -I
+AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
+[
+ AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
+ pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
+ [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
+ pushdef([PACK],[m4_ifdef([acl_frompackage_]NAME, [acl_frompackage_]NAME, lib[$1])])
+ pushdef([PACKUP],[translit(PACK,[abcdefghijklmnopqrstuvwxyz./-],
+ [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
+ pushdef([PACKLIBS],[m4_ifdef([acl_frompackage_]NAME, [acl_libsinpackage_]PACKUP, lib[$1])])
+ dnl Autoconf >= 2.61 supports dots in --with options.
+ pushdef([P_A_C_K],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[translit(PACK,[.],[_])],PACK)])
+ dnl By default, look in $includedir and $libdir.
+ use_additional=yes
+ if test "x$GCC" = "xyes" -a "x$3" = "xsystem"
+ then
+ i_system="-isystem "
+ else
+ i_system="-I"
+ fi
+
+ AC_LIB_WITH_FINAL_PREFIX([
+ eval additional_includedir=\"$includedir\"
+ eval additional_libdir=\"$libdir\"
+ ])
+ AC_ARG_WITH(P_A_C_K[-prefix],
+[[ --with-]]P_A_C_K[[-prefix[=DIR] search for ]PACKLIBS[ in DIR/include and DIR/lib
+ --without-]]P_A_C_K[[-prefix don't search for ]PACKLIBS[ in includedir and libdir]],
+[
+ if test "X$withval" = "Xno"; then
+ use_additional=no
+ else
+ if test "X$withval" = "X"; then
+ AC_LIB_WITH_FINAL_PREFIX([
+ eval additional_includedir=\"$includedir\"
+ eval additional_libdir=\"$libdir\"
+ ])
+ else
+ additional_includedir="$withval/include"
+ additional_libdir="$withval/$acl_libdirstem"
+ if test "$acl_libdirstem2" != "$acl_libdirstem" \
+ && ! test -d "$withval/$acl_libdirstem"; then
+ additional_libdir="$withval/$acl_libdirstem2"
+ fi
+ fi
+ fi
+])
+ dnl Search the library and its dependencies in $additional_libdir and
+ dnl $LDFLAGS. Using breadth-first-seach.
+ LIB[]NAME=
+ LTLIB[]NAME=
+ INC[]NAME=
+ LIB[]NAME[]_PREFIX=
+ rpathdirs=
+ ltrpathdirs=
+ names_already_handled=
+ names_next_round='$1 $2'
+ while test -n "$names_next_round"; do
+ names_this_round="$names_next_round"
+ names_next_round=
+ for name in $names_this_round; do
+ already_handled=
+ for n in $names_already_handled; do
+ if test "$n" = "$name"; then
+ already_handled=yes
+ break
+ fi
+ done
+ if test -z "$already_handled"; then
+ names_already_handled="$names_already_handled $name"
+ dnl See if it was already located by an earlier AC_LIB_LINKFLAGS
+ dnl or AC_LIB_HAVE_LINKFLAGS call.
+ uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
+ eval value=\"\$HAVE_LIB$uppername\"
+ if test -n "$value"; then
+ if test "$value" = yes; then
+ eval value=\"\$LIB$uppername\"
+ test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value"
+ eval value=\"\$LTLIB$uppername\"
+ test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value"
+ else
+ dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined
+ dnl that this library doesn't exist. So just drop it.
+ :
+ fi
+ else
+ dnl Search the library lib$name in $additional_libdir and $LDFLAGS
+ dnl and the already constructed $LIBNAME/$LTLIBNAME.
+ found_dir=
+ found_la=
+ found_so=
+ found_a=
+ eval libname=\"$acl_libname_spec\" # typically: libname=lib$name
+ if test -n "$acl_shlibext"; then
+ shrext=".$acl_shlibext" # typically: shrext=.so
+ else
+ shrext=
+ fi
+ if test $use_additional = yes; then
+ dir="$additional_libdir"
+ dnl The same code as in the loop below:
+ dnl First look for a shared library.
+ if test -n "$acl_shlibext"; then
+ if test -f "$dir/$libname$shrext"; then
+ found_dir="$dir"
+ found_so="$dir/$libname$shrext"
+ else
+ if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
+ ver=`(cd "$dir" && \
+ for f in "$libname$shrext".*; do echo "$f"; done \
+ | sed -e "s,^$libname$shrext\\\\.,," \
+ | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
+ | sed 1q ) 2>/dev/null`
+ if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
+ found_dir="$dir"
+ found_so="$dir/$libname$shrext.$ver"