TS-1856 Remove the countof() template from SPDY plugin, and make it compile properly with ink_defs.h included.
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/1250c7cf Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/1250c7cf Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/1250c7cf Branch: refs/heads/sphinx-docs Commit: 1250c7cf8018a3e7695c5790f3bb23ca094ec2c2 Parents: cec4cf1 Author: Leif Hedstrom <[email protected]> Authored: Fri Apr 26 14:58:23 2013 -0600 Committer: Leif Hedstrom <[email protected]> Committed: Fri Apr 26 14:58:23 2013 -0600 ---------------------------------------------------------------------- lib/ts/ink_defs.h | 4 ++-- plugins/experimental/lua/lapi.cc | 6 ++++-- plugins/experimental/lua/lconfig.cc | 6 ++++-- plugins/experimental/lua/lutil.cc | 6 ++++-- plugins/experimental/lua/lutil.h | 8 -------- plugins/experimental/lua/remap.cc | 6 ++++-- plugins/experimental/lua/state.cc | 6 ++++-- plugins/experimental/spdy/lib/base/logging.h | 4 ---- 8 files changed, 22 insertions(+), 24 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1250c7cf/lib/ts/ink_defs.h ---------------------------------------------------------------------- diff --git a/lib/ts/ink_defs.h b/lib/ts/ink_defs.h index 7aa4c10..fb71b37 100644 --- a/lib/ts/ink_defs.h +++ b/lib/ts/ink_defs.h @@ -86,14 +86,14 @@ #define NULL_PTR static_cast<void*>(0) // Determine the element count for an array. -#define COUNTOF(x) ((unsigned)(sizeof(x)/sizeof((x)[0]))) - #ifdef __cplusplus template<typename T, unsigned N> static inline unsigned countof(const T (&)[N]) { return N; } +#else +# define countof(x) ((unsigned)(sizeof(x)/sizeof((x)[0]))) #endif #define SOCKOPT_ON ((char*)&on) http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1250c7cf/plugins/experimental/lua/lapi.cc ---------------------------------------------------------------------- diff --git a/plugins/experimental/lua/lapi.cc b/plugins/experimental/lua/lapi.cc index 52274a2..c284429 100644 --- a/plugins/experimental/lua/lapi.cc +++ b/plugins/experimental/lua/lapi.cc @@ -16,8 +16,10 @@ limitations under the License. */ -#include <ts/ts.h> -#include <ts/remap.h> +#include "ts/ts.h" +#include "ts/remap.h" +#include "ink_defs.h" + #include <string.h> #include "lapi.h" #include "lutil.h" http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1250c7cf/plugins/experimental/lua/lconfig.cc ---------------------------------------------------------------------- diff --git a/plugins/experimental/lua/lconfig.cc b/plugins/experimental/lua/lconfig.cc index 69b1571..292829a 100644 --- a/plugins/experimental/lua/lconfig.cc +++ b/plugins/experimental/lua/lconfig.cc @@ -16,8 +16,10 @@ limitations under the License. */ -#include <ts/ts.h> -#include <ts/remap.h> +#include "ts/ts.h" +#include "ts/remap.h" +#include "ink_defs.h" + #include "lapi.h" #include "lutil.h" http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1250c7cf/plugins/experimental/lua/lutil.cc ---------------------------------------------------------------------- diff --git a/plugins/experimental/lua/lutil.cc b/plugins/experimental/lua/lutil.cc index dfe1783..6971fb7 100644 --- a/plugins/experimental/lua/lutil.cc +++ b/plugins/experimental/lua/lutil.cc @@ -16,8 +16,10 @@ limitations under the License. */ -#include <ts/ts.h> -#include <ts/remap.h> +#include "ts/ts.h" +#include "ts/remap.h" +#include "ink_defs.h" + #include "lapi.h" #include "lutil.h" #include <pthread.h> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1250c7cf/plugins/experimental/lua/lutil.h ---------------------------------------------------------------------- diff --git a/plugins/experimental/lua/lutil.h b/plugins/experimental/lua/lutil.h index 1e2e8e2..4f20424 100644 --- a/plugins/experimental/lua/lutil.h +++ b/plugins/experimental/lua/lutil.h @@ -28,9 +28,6 @@ // Global argument index for TSHttpSsnArgGet and TSHttpTxnArgGet. extern int LuaHttpArgIndex; -#define unlikely(x) __builtin_expect(!!(x), 0) -#define likely(x) __builtin_expect(!!(x), 1) - #define LuaLogDebug(fmt, ...) do { \ if (unlikely(TSIsDebugTagSet("lua"))) { \ TSDebug("lua", "%s: " fmt, __func__, ##__VA_ARGS__); \ @@ -84,9 +81,4 @@ void LuaSetConstantField(lua_State * lua, const char * name, const char * value) lua_State * LuaNewState(); lua_State * LuaPluginNewState(void); -template <typename T, unsigned N> unsigned -countof(const T (&)[N]) { - return N; -} - #endif // LUA_LUTIL_H_ http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1250c7cf/plugins/experimental/lua/remap.cc ---------------------------------------------------------------------- diff --git a/plugins/experimental/lua/remap.cc b/plugins/experimental/lua/remap.cc index 1911c64..76590d8 100644 --- a/plugins/experimental/lua/remap.cc +++ b/plugins/experimental/lua/remap.cc @@ -16,8 +16,10 @@ limitations under the License. */ -#include <ts/ts.h> -#include <ts/remap.h> +#include "ts/ts.h" +#include "ts/remap.h" +#include "ink_defs.h" + #include "lapi.h" #include "lutil.h" #include "state.h" http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1250c7cf/plugins/experimental/lua/state.cc ---------------------------------------------------------------------- diff --git a/plugins/experimental/lua/state.cc b/plugins/experimental/lua/state.cc index a40ce51..596322d 100644 --- a/plugins/experimental/lua/state.cc +++ b/plugins/experimental/lua/state.cc @@ -16,8 +16,10 @@ limitations under the License. */ -#include <ts/ts.h> -#include <ts/remap.h> +#include "ts/ts.h" +#include "ts/remap.h" +#include "ink_defs.h" + #include "state.h" #include "hook.h" #include "lutil.h" http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1250c7cf/plugins/experimental/spdy/lib/base/logging.h ---------------------------------------------------------------------- diff --git a/plugins/experimental/spdy/lib/base/logging.h b/plugins/experimental/spdy/lib/base/logging.h index 0c8541f..a4c065a 100644 --- a/plugins/experimental/spdy/lib/base/logging.h +++ b/plugins/experimental/spdy/lib/base/logging.h @@ -34,10 +34,6 @@ void TSError(const char *, ...) int TSIsDebugTagSet(const char*); } -template <typename T, unsigned N> unsigned countof(const T(&)[N]) { - return N; -} - template <typename T> std::string stringof(const T&); #define cstringof(x) stringof(x).c_str()
