])])
AM_CONDITIONAL(WITH_HADOOPCLIENT, [test "$HAVE_JNI" = "1"])
+#libatomic-ops? You want it!
+AC_ARG_WITH([libatomic-ops],
+ [AS_HELP_STRING([--with-libatomic-ops],
+ [use libatomic-ops to build Ceph's atomic_t type])],
+ [],
+ [with_libatomic_ops=check])
+AS_IF([test "x$with_libatomic_ops" != xno],
+ [AC_CHECK_HEADER([atomic_ops.h],
+ [HAVE_ATOMIC_OPS=1],
+ [if test "x$with_libatomic_ops" != xcheck; then
+ AC_MSG_FAILURE(
+ [--with-libatomic-ops was given but atomic_ops.h not found])
+ fi
+ ])])
+AS_IF([test "$HAVE_ATOMIC_OPS" = "1"],
+ AC_DEFINE([HAVE_ATOMIC_OPS], [1], [Defined if you have atomic_ops]),
+ AC_MSG_FAILURE([]))
+AM_CONDITIONAL(WITH_LIBATOMIC, [test "$HAVE_ATOMIC_OPS" = "1"])
+
# newsyn? requires mpi.
#AC_ARG_WITH([newsyn],
# [AS_HELP_STRING([--with-newsyn], [build newsyn target requires mpi])],
INCLUDES =
LDADD =
+
AM_CXXFLAGS = -Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT -D_THREAD_SAFE -rdynamic
AM_CFLAGS = -Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT -D_THREAD_SAFE -rdynamic
AM_LDFLAGS =
+if WITH_LIBATOMIC
+AM_LDFLAGS += -latomic_ops
+endif
+
noinst_LIBRARIES = \
libcommon.a libcrush.a \
libmon.a libmds.a libosdc.a libosd.a libclient.a \
# include "acconfig.h"
#endif
+
+#ifdef HAVE_ATOMIC_OPS
+//libatomic_ops implementation
+#include <atomic_ops.h>
+namespace ceph {
+
+class atomic_t {
+ AO_t val;
+public:
+ atomic_t(AO_t i=0) : val(i) {}
+ void inc() {
+ AO_fetch_and_add1(&val);
+ }
+ AO_t dec() {
+ return AO_fetch_and_sub1_write(&val) - 1;
+ }
+ void add(AO_t add_me) {
+ AO_fetch_and_add(&val, add_me);
+ }
+ void sub(int sub_me) {
+ int sub = 0 - sub_me;
+ AO_fetch_and_add_write(&val, (AO_t)sub);
+ }
+ AO_t read() const {
+ return AO_load_full(&val);
+ }
+};
+}
+#else
/*
* crappy slow implementation that uses a pthreads spinlock.
*/
}
#endif
+#endif