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 2015/05/18 17:37:13 UTC
[1/2] trafficserver git commit: TS-3568 We can now assume
unordered_map is always available,
just need to detect the appropriate compiler flags
Repository: trafficserver
Updated Branches:
refs/heads/master cea8e28de -> 8f297be45
TS-3568 We can now assume unordered_map is always available, just need to detect the appropriate compiler flags
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/4c0f407d
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/4c0f407d
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/4c0f407d
Branch: refs/heads/master
Commit: 4c0f407d2a76a90c832852d0e240182ccd9d3eaf
Parents: cea8e28
Author: Leif Hedstrom <zw...@apache.org>
Authored: Wed May 13 23:14:18 2015 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon May 18 09:07:38 2015 -0600
----------------------------------------------------------------------
build/ax_cxx_compile_stdcxx_11.m4 | 79 +++++++++++---------
configure.ac | 38 +---------
.../background_fetch/background_fetch.cc | 11 +--
.../experimental/cache_promote/cache_promote.cc | 30 +++-----
proxy/logstats.cc | 27 +------
5 files changed, 61 insertions(+), 124 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4c0f407d/build/ax_cxx_compile_stdcxx_11.m4
----------------------------------------------------------------------
diff --git a/build/ax_cxx_compile_stdcxx_11.m4 b/build/ax_cxx_compile_stdcxx_11.m4
index e4ba5f5..d8a1aee 100644
--- a/build/ax_cxx_compile_stdcxx_11.m4
+++ b/build/ax_cxx_compile_stdcxx_11.m4
@@ -4,60 +4,54 @@
#
# SYNOPSIS
#
-# AX_CXX_COMPILE_STDCXX_11([ext|noext],[action-if-success],[action-if-failure])
+# AX_CXX_COMPILE_STDCXX_11([ext|noext],[mandatory|optional])
#
# DESCRIPTION
#
# Check for baseline language coverage in the compiler for the C++11
# standard; if necessary, add switches to CXXFLAGS to enable support.
-# Errors out if no mode that supports C++11 baseline syntax can be found.
-# The argument, if specified, indicates whether you insist on an extended
-# mode (e.g. -std=gnu++11) or a strict conformance mode (e.g. -std=c++11).
-# If neither is specified, you get whatever works, with preference for an
-# extended mode.
+#
+# The first argument, if specified, indicates whether you insist on an
+# extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g.
+# -std=c++11). If neither is specified, you get whatever works, with
+# preference for an extended mode.
+#
+# The second argument, if specified 'mandatory' or if left unspecified,
+# indicates that baseline C++11 support is required and that the macro
+# should error out if no mode with that support is found. If specified
+# 'optional', then configuration proceeds regardless, after defining
+# HAVE_CXX11 if and only if a supporting mode is found.
#
# LICENSE
#
# Copyright (c) 2008 Benjamin Kosnik <bk...@redhat.com>
# Copyright (c) 2012 Zack Weinberg <za...@panix.com>
+# Copyright (c) 2013 Roy Stogner <ro...@ices.utexas.edu>
+# Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov <so...@google.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. This file is offered as-is, without any
# warranty.
-#serial 1
-
-m4_define([_AX_CXX_COMPILE_STDCXX_11_testbody], [
- template <typename T>
- struct check
- {
- static_assert(sizeof(int) <= sizeof(T), "not big enough");
- };
-
-
- struct in_class_initialization {
- int i = 0;
- };
-
- typedef check<check<bool>> right_angle_brackets;
+#serial 11
- int a;
- decltype(a) b;
-
- typedef check<int> check_type;
- check_type c;
- check_type&& cr = static_cast<check_type&&>(c);
-
- void * null_pointer_keyword = nullptr;
-])
+# ATS: Modified to simply check for unordered map, which is the main
+# feature we need right now from C++0x
+m4_define([_AX_CXX_COMPILE_STDCXX_11_testbody], [[
+ #include <unordered_map>
+]])
AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [dnl
m4_if([$1], [], [],
[$1], [ext], [],
[$1], [noext], [],
[m4_fatal([invalid argument `$1' to AX_CXX_COMPILE_STDCXX_11])])dnl
- AC_LANG_ASSERT([C++])dnl
+ m4_if([$2], [], [ax_cxx_compile_cxx11_required=true],
+ [$2], [mandatory], [ax_cxx_compile_cxx11_required=true],
+ [$2], [optional], [ax_cxx_compile_cxx11_required=false],
+ [m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX_11])])
+ AC_LANG_PUSH([C++])dnl
ac_success=no
AC_CACHE_CHECK(whether $CXX supports C++11 features by default,
ax_cv_cxx_compile_cxx11,
@@ -90,7 +84,9 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [dnl
m4_if([$1], [ext], [], [dnl
if test x$ac_success = xno; then
- for switch in -std=c++11 -std=c++0x; do
+ dnl HP's aCC needs +std=c++11 according to:
+ dnl http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/PDF_Release_Notes/769149-001.pdf
+ for switch in -std=c++11 -std=c++0x +std=c++11; do
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch])
AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch,
$cachevar,
@@ -107,10 +103,21 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [dnl
fi
done
fi])
-
- if test x$ac_success = xno ; then
- m4_if([$3], [], [true], [$3])
+ AC_LANG_POP([C++])
+ if test x$ax_cxx_compile_cxx11_required = xtrue; then
+ if test x$ac_success = xno; then
+ AC_MSG_ERROR([*** A compiler with support for C++11 language features is required.])
+ fi
else
- m4_if([$2], [], [true], [$2])
+ if test x$ac_success = xno; then
+ HAVE_CXX11=0
+ AC_MSG_NOTICE([No compiler with C++11 support was found])
+ else
+ HAVE_CXX11=1
+ AC_DEFINE(HAVE_CXX11,1,
+ [define if the compiler supports basic C++11 syntax])
+ fi
+
+ AC_SUBST(HAVE_CXX11)
fi
])
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4c0f407d/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index fa43eba..e7094c3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -588,44 +588,12 @@ AX_COMPILER_VENDOR
CFLAGS="${_ts_saved_CFLAGS}"
CXXFLAGS="${_ts_saved_CXXFLAGS}"
-# AX_CXX_COMPILE_STDCXX_11 requires the current language to be C++.
+# These tests requires C++
AC_LANG_PUSH([C++])
-AX_CXX_COMPILE_STDCXX_11( [noext], [enable_cxx_11_support=yes], [
- enable_cxx_11_support=no
- AC_MSG_NOTICE([disabling features that depend on C++11 support])
-])
-
-AM_CONDITIONAL([BUILD_HAVE_CXX_11], [ test "x${enable_cxx_11_support}" = "xyes" ])
-if test "x${enable_cxx_11_support}" = "xyes" ; then
- AC_DEFINE(HAVE_CXX_11, 1, [Whether the compiler support C++11])
-fi
-
-# While we are in C++ mode, check for the GNU hash_map extension.
-AC_CHECK_HEADERS([unordered_map unordered_set], [], [],
-[[#ifdef HAVE_UNORDERED_MAP
-#include <unordered_map>
-#endif
-]])
-
-AC_MSG_CHECKING([for <ext/hash_map>])
-AC_COMPILE_IFELSE([
- AC_LANG_PROGRAM([
- #include <string>
- #include <ext/hash_map>
- ], [
- __gnu_cxx::hash_map<std::string, std::string> map;
- ])],
- [ have_gnu_cxx_hash_map=yes ],
- [ have_gnu_cxx_hash_map=no ]
-)
-
-AC_MSG_RESULT([$have_gnu_cxx_hash_map])
-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
+AX_CXX_COMPILE_STDCXX_11([noext],[mandatory])
-# And check for std::shared_ptr vs std::tr1::shared_ptr
+# And check for std::shared_ptr vs std::tr1::shared_ptr. For the CPPLIB
AC_MSG_CHECKING([for std::shared_ptr])
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4c0f407d/plugins/experimental/background_fetch/background_fetch.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/background_fetch/background_fetch.cc b/plugins/experimental/background_fetch/background_fetch.cc
index d154e39..63f8c59 100644
--- a/plugins/experimental/background_fetch/background_fetch.cc
+++ b/plugins/experimental/background_fetch/background_fetch.cc
@@ -28,6 +28,7 @@
#include <getopt.h>
#include <string>
+#include <unordered_map>
#include "ts/ts.h"
#include "ts/remap.h"
@@ -35,14 +36,6 @@
#include "rules.h"
#include "configs.h"
-// Some wonkiness around compiler version and the unordered map (hash)
-#if HAVE_UNORDERED_MAP
-#include <unordered_map>
-typedef std::unordered_map<std::string, bool> OutstandingRequests;
-#else
-#include <map>
-typedef std::map<std::string, bool> OutstandingRequests;
-#endif
// Global config, if we don't have a remap specific config.
static BgFetchConfig *gConfig;
@@ -52,6 +45,8 @@ static BgFetchConfig *gConfig;
// Hold the global ackground fetch state. This is currently shared across all
// configurations, as a singleton. ToDo: Would it ever make sense to do this
// per remap rule? Probably not.
+typedef std::unordered_map<std::string, bool> OutstandingRequests;
+
class BgFetchState
{
public:
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4c0f407d/plugins/experimental/cache_promote/cache_promote.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/cache_promote/cache_promote.cc b/plugins/experimental/cache_promote/cache_promote.cc
index fbf2cc8..6b05882 100644
--- a/plugins/experimental/cache_promote/cache_promote.cc
+++ b/plugins/experimental/cache_promote/cache_promote.cc
@@ -16,8 +16,6 @@
limitations under the License.
*/
-#include <ts/ts.h>
-#include <ts/remap.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
@@ -27,14 +25,13 @@
#include <openssl/sha.h>
#include <string>
+#include <unordered_map>
#include <list>
-// TODO: We should eliminate this when we have unordered_map on all supported platforms
-#if HAVE_UNORDERED_MAP
-#include <unordered_map>
-#else
-#include <map>
-#endif
+#include "ts/ts.h"
+#include "ts/remap.h"
+#include "ink_config.h"
+
static const char *PLUGIN_NAME = "cache_promote";
@@ -182,18 +179,10 @@ struct LRUHashHasher {
typedef std::pair<LRUHash, unsigned> LRUEntry;
typedef std::list<LRUEntry> LRUList;
+typedef std::unordered_map<const LRUHash *, LRUList::iterator, LRUHashHasher, LRUHashHasher> LRUMap;
static LRUEntry NULL_LRU_ENTRY; // Used to create an "empty" new LRUEntry
-// TODO: We should eliminate this when we have unordered_map on all supported platforms.
-#if HAVE_UNORDERED_MAP
-#include <unordered_map>
-typedef std::unordered_map<const LRUHash *, LRUList::iterator, LRUHashHasher, LRUHashHasher> LRUMap;
-#else
-#include <map>
-typedef std::map<LRUHash *, LRUList::iterator> LRUMap;
-#endif
-
class LRUPolicy : public PromotionPolicy
{
public:
@@ -230,9 +219,6 @@ public:
// This doesn't have to be perfect, since this is just chance sampling.
// coverity[dont_call]
srand48((long)time(NULL) ^ (long)getpid() ^ (long)getppid());
-#if HAVE_UNORDERED_MAP
- _map.reserve(_buckets);
-#endif
return true;
}
@@ -263,6 +249,7 @@ public:
ret = true;
} else {
// It's still not promoted, make sure it's moved to the front of the list
+ TSDebug(PLUGIN_NAME, "still not promoted, got %d hits so far", map_it->second->second);
_list.splice(_list.begin(), _list, map_it->second);
}
} else {
@@ -491,10 +478,11 @@ TSRemapStatus
TSRemapDoRemap(void *ih, TSHttpTxn rh, TSRemapRequestInfo * /* ATS_UNUSED rri */)
{
if (NULL == ih) {
- TSDebug(PLUGIN_NAME, "No ACLs configured, this is probably a plugin bug");
+ TSDebug(PLUGIN_NAME, "No promotion rules configured, this is probably a plugin bug");
} else {
TSCont contp = static_cast<TSCont>(ih);
+ TSDebug(PLUGIN_NAME, "scheduling a TS_HTTP_CACHE_LOOKUP_COMPLETE_HOOK hook");
TSHttpTxnHookAdd(rh, TS_HTTP_CACHE_LOOKUP_COMPLETE_HOOK, contp);
}
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4c0f407d/proxy/logstats.cc
----------------------------------------------------------------------
diff --git a/proxy/logstats.cc b/proxy/logstats.cc
index 5cf9d05..7c24eb3 100644
--- a/proxy/logstats.cc
+++ b/proxy/logstats.cc
@@ -51,6 +51,9 @@
#include <list>
#include <functional>
#include <fcntl.h>
+#include <unordered_map>
+#include <unordered_set>
+
#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE 600
@@ -316,10 +319,6 @@ struct hash_fnv32 {
};
typedef std::list<UrlStats> LruStack;
-
-#if HAVE_CXX_11 && HAVE_UNORDERED_MAP && HAVE_UNORDERED_SET
-#include <unordered_map>
-#include <unordered_set>
typedef std::unordered_map<const char *, OriginStats *, hash_fnv32, eqstr> OriginStorage;
typedef std::unordered_set<const char *, hash_fnv32, eqstr> OriginSet;
typedef std::unordered_map<const char *, LruStack::iterator, hash_fnv32, eqstr> LruHash;
@@ -332,26 +331,6 @@ rehash(T &container, N size)
container.rehash(size);
}
-#elif HAVE_GNU_CXX_HASH_MAP
-#define _BACKWARD_BACKWARD_WARNING_H // needed for gcc 4.3
-#include <ext/hash_map>
-#include <ext/hash_set>
-typedef __gnu_cxx::hash_map<const char *, OriginStats *, hash_fnv32, eqstr> OriginStorage;
-typedef __gnu_cxx::hash_set<const char *, hash_fnv32, eqstr> OriginSet;
-typedef __gnu_cxx::hash_map<const char *, LruStack::iterator, hash_fnv32, eqstr> LruHash;
-
-// Resize a hash-based container.
-template <class T, class N>
-void
-rehash(T &container, N size)
-{
- container.resize(size);
-}
-
-#undef _BACKWARD_BACKWARD_WARNING_H
-#else
-#error no supported hash container
-#endif
// LRU class for the URL data
void update_elapsed(ElapsedStats &stat, const int elapsed, const StatsCounter &counter);
[2/2] trafficserver git commit: Added TS-3568
Posted by zw...@apache.org.
Added TS-3568
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/8f297be4
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/8f297be4
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/8f297be4
Branch: refs/heads/master
Commit: 8f297be455bed0aa5fbf6b59106fe580f3278a21
Parents: 4c0f407
Author: Leif Hedstrom <zw...@apache.org>
Authored: Mon May 18 09:32:23 2015 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon May 18 09:32:23 2015 -0600
----------------------------------------------------------------------
CHANGES | 5 +++++
1 file changed, 5 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/8f297be4/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 248ac9b..86254e0 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,11 @@
-*- coding: utf-8 -*-
Changes with Apache Traffic Server 6.0.0
+ *) [TS-3568] We can now assume unordered_map is always available, just need
+ to detect the appropriate compiler flags. This modifies the AC module too
+ only check for unordered_map though, since otherwise we'd never get the
+ appropriate flags for various older platforms.
+
*) [TS-3601] cache_promote: Eliminate unnecessary mutex for txn handler.
*) [TS-3578] Rearrange ProxyClientSession so VC is available in close