You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2014/02/04 00:05:52 UTC
git commit: TS-2551 Add a configure check for shared_ptr,
and fall back on tr1
Updated Branches:
refs/heads/master fda8cee39 -> 5ce808d1a
TS-2551 Add a configure check for shared_ptr, and fall back on tr1
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/5ce808d1
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/5ce808d1
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/5ce808d1
Branch: refs/heads/master
Commit: 5ce808d1acac7b50901058c53401577b21ebeef9
Parents: fda8cee
Author: Leif Hedstrom <zw...@apache.org>
Authored: Mon Feb 3 16:05:45 2014 -0700
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Feb 3 16:05:45 2014 -0700
----------------------------------------------------------------------
configure.ac | 18 ++++++++++++++++++
.../examples/async_http_fetch/AsyncHttpFetch.cc | 2 +-
.../examples/stat_example/StatExample.cc | 4 +---
lib/atscppapi/src/include/atscppapi/shared_ptr.h | 14 ++++++++++++--
4 files changed, 32 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/5ce808d1/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index 5d916bb..8458c04 100644
--- a/configure.ac
+++ b/configure.ac
@@ -588,6 +588,24 @@ if test "x${have_gnu_cxx_hash_map}" = "xyes" ; then
AC_DEFINE(HAVE_GNU_CXX_HASH_MAP, 1, [whether __gnu_cxx::hash_map is available])
fi
+# And check for std::shared_ptr vs std::tr1::shared_ptr
+TS_FLAG_HEADERS([unordered_map unordered_set])
+AC_MSG_CHECKING([for std::shared_ptr])
+AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([
+ #include <memory>
+ using std::shared_ptr;
+ ], [
+ ])],
+ [ have_std_shared_ptr=yes ],
+ [ have_std_shared_ptr=no ]
+)
+
+AC_MSG_RESULT([$have_std_shared_ptr])
+if test "x${have_std_shared_ptr}" = "xyes" ; then
+ AC_DEFINE(HAVE_STD_SHARED_PTR, 1, [whether std::shared_ptr is available])
+fi
+
AC_LANG_POP()
dnl AC_PROG_SED is only available from version 2.6 (released in 2003). CentosOS
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/5ce808d1/lib/atscppapi/examples/async_http_fetch/AsyncHttpFetch.cc
----------------------------------------------------------------------
diff --git a/lib/atscppapi/examples/async_http_fetch/AsyncHttpFetch.cc b/lib/atscppapi/examples/async_http_fetch/AsyncHttpFetch.cc
index e156309..c0b8079 100644
--- a/lib/atscppapi/examples/async_http_fetch/AsyncHttpFetch.cc
+++ b/lib/atscppapi/examples/async_http_fetch/AsyncHttpFetch.cc
@@ -104,7 +104,7 @@ private:
const void *body;
size_t body_size;
async_http_fetch.getResponseBody(body, body_size);
- TS_DEBUG(TAG, "Response body is [%.*s]", static_cast<int>(body_size), body);
+ TS_DEBUG(TAG, "Response body is [%.*s]", static_cast<int>(body_size), static_cast<const char*>(body));
} else {
TS_ERROR(TAG, "Fetch did not complete successfully; Result %d",
static_cast<int>(async_http_fetch.getResult()));
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/5ce808d1/lib/atscppapi/examples/stat_example/StatExample.cc
----------------------------------------------------------------------
diff --git a/lib/atscppapi/examples/stat_example/StatExample.cc b/lib/atscppapi/examples/stat_example/StatExample.cc
index 1f4233e..7208526 100644
--- a/lib/atscppapi/examples/stat_example/StatExample.cc
+++ b/lib/atscppapi/examples/stat_example/StatExample.cc
@@ -23,8 +23,6 @@
#include <atscppapi/PluginInit.h>
#include <cstring>
-#include <inttypes.h>
-
using namespace atscppapi;
using std::string;
@@ -56,7 +54,7 @@ public:
virtual void handleReadRequestHeadersPostRemap(Transaction &transaction) {
TS_DEBUG(TAG, "Received a request, incrementing the counter.");
stat.increment();
- TS_DEBUG(TAG, "Stat '%s' value = %" PRId64, STAT_NAME.c_str(), stat.get());
+ TS_DEBUG(TAG, "Stat '%s' value = %lld", STAT_NAME.c_str(), static_cast<long long>(stat.get()));
transaction.resume();
}
};
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/5ce808d1/lib/atscppapi/src/include/atscppapi/shared_ptr.h
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/include/atscppapi/shared_ptr.h b/lib/atscppapi/src/include/atscppapi/shared_ptr.h
index 5a826db..6fa9571 100644
--- a/lib/atscppapi/src/include/atscppapi/shared_ptr.h
+++ b/lib/atscppapi/src/include/atscppapi/shared_ptr.h
@@ -25,7 +25,13 @@
#ifndef ASTCPPAPI_SHARED_PTR_H_
#define ASTCPPAPI_SHARED_PTR_H_
-#include <memory>
+#include "ink_autoconf.h"
+
+#if HAVE_STD_SHARED_PTR
+# include <memory>
+#else
+# include <tr1/memory>
+#endif
namespace atscppapi {
@@ -34,7 +40,11 @@ namespace atscppapi {
* \todo Consider adding a simple macro to check if c++0x/11 is enabled
* and if so change it to std::shared_ptr and #include <memory>s
*/
-using std::shared_ptr;
+#if HAVE_STD_SHARED_PTR
+ using std::shared_ptr;
+#else
+ using std::tr1::shared_ptr;
+#endif
} /* atscppapi */