From 60072702326e9af963b362d75cf08f58dd11d962 Mon Sep 17 00:00:00 2001 From: Dan Zhang Date: Thu, 11 Apr 2019 18:57:57 -0400 Subject: [PATCH 1/3] Implement http2_macros.h Signed-off-by: Dan Zhang --- .../quiche/platform/http2_macros_impl.h | 21 +++++++++++++----- .../quiche/platform/http2_platform_test.cc | 22 ++++++++++++------- 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/source/extensions/quic_listeners/quiche/platform/http2_macros_impl.h b/source/extensions/quic_listeners/quiche/platform/http2_macros_impl.h index 3d7df5563e9f1..59109e44c4055 100644 --- a/source/extensions/quic_listeners/quiche/platform/http2_macros_impl.h +++ b/source/extensions/quic_listeners/quiche/platform/http2_macros_impl.h @@ -1,15 +1,26 @@ #pragma once -#include "absl/base/macros.h" - // NOLINT(namespace-envoy) // This file is part of the QUICHE platform implementation, and is not to be // consumed or referenced directly by other Envoy code. It serves purely as a // porting layer for QUICHE. +#include + +#include "extensions/quic_listeners/quiche/platform/quic_logging_impl.h" + +#include "absl/base/macros.h" + #define HTTP2_FALLTHROUGH_IMPL ABSL_FALLTHROUGH_INTENDED -#define HTTP2_DIE_IF_NULL_IMPL(ptr) ABSL_DIE_IF_NULL(ptr) +#define HTTP2_DIE_IF_NULL_IMPL(ptr) dieIfNull(ptr) +#define HTTP2_UNREACHABLE_IMPL() DCHECK(false) + +namespace http2 { + +template T dieIfNull(T&& ptr) { + CHECK(ptr != nullptr); + return std::forward(ptr); +} -// TODO: implement -#define HTTP2_UNREACHABLE_IMPL() 0 +} // namespace http2 diff --git a/test/extensions/quic_listeners/quiche/platform/http2_platform_test.cc b/test/extensions/quic_listeners/quiche/platform/http2_platform_test.cc index 10b9b38787e1e..0cd37a1512624 100644 --- a/test/extensions/quic_listeners/quiche/platform/http2_platform_test.cc +++ b/test/extensions/quic_listeners/quiche/platform/http2_platform_test.cc @@ -1,3 +1,9 @@ +// NOLINT(namespace-envoy) + +// This file is part of the QUICHE platform implementation, and is not to be +// consumed or referenced directly by other Envoy code. It serves purely as a +// porting layer for QUICHE. + #include #include "test/test_common/logging.h" @@ -8,6 +14,7 @@ #include "quiche/http2/platform/api/http2_containers.h" #include "quiche/http2/platform/api/http2_estimate_memory_usage.h" #include "quiche/http2/platform/api/http2_logging.h" +#include "quiche/http2/platform/api/http2_macros.h" #include "quiche/http2/platform/api/http2_optional.h" #include "quiche/http2/platform/api/http2_ptr_util.h" #include "quiche/http2/platform/api/http2_string.h" @@ -19,10 +26,7 @@ // minimal, and serve primarily to verify the APIs compile and link without // issue. -namespace Envoy { -namespace Extensions { -namespace QuicListeners { -namespace Quiche { +namespace http2 { namespace { TEST(Http2PlatformTest, Http2Arraysize) { @@ -96,8 +100,10 @@ TEST(Http2PlatformTest, Http2StringPiece) { EXPECT_EQ('b', sp[0]); } +TEST(Http2PlatformTest, Http2Macro) { + EXPECT_DEBUG_DEATH(HTTP2_UNREACHABLE(), ""); + EXPECT_DEATH(HTTP2_DIE_IF_NULL(nullptr), ""); +} + } // namespace -} // namespace Quiche -} // namespace QuicListeners -} // namespace Extensions -} // namespace Envoy +} // namespace http2 From 4b903662ee1c1fd7e3c781c53fef875b819f21d6 Mon Sep 17 00:00:00 2001 From: Dan Zhang Date: Thu, 11 Apr 2019 19:06:41 -0400 Subject: [PATCH 2/3] add (ptr) Signed-off-by: Dan Zhang --- .../quic_listeners/quiche/platform/http2_macros_impl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/extensions/quic_listeners/quiche/platform/http2_macros_impl.h b/source/extensions/quic_listeners/quiche/platform/http2_macros_impl.h index 59109e44c4055..78270dac29a5e 100644 --- a/source/extensions/quic_listeners/quiche/platform/http2_macros_impl.h +++ b/source/extensions/quic_listeners/quiche/platform/http2_macros_impl.h @@ -19,7 +19,7 @@ namespace http2 { template T dieIfNull(T&& ptr) { - CHECK(ptr != nullptr); + CHECK((ptr) != nullptr); return std::forward(ptr); } From ef27a7ff71c5c3ddd43d1db42c70d71f512ed3e3 Mon Sep 17 00:00:00 2001 From: Dan Zhang Date: Fri, 12 Apr 2019 13:57:17 -0400 Subject: [PATCH 3/3] add inline Signed-off-by: Dan Zhang --- .../quic_listeners/quiche/platform/http2_macros_impl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/extensions/quic_listeners/quiche/platform/http2_macros_impl.h b/source/extensions/quic_listeners/quiche/platform/http2_macros_impl.h index 78270dac29a5e..4f99f2d2f42b8 100644 --- a/source/extensions/quic_listeners/quiche/platform/http2_macros_impl.h +++ b/source/extensions/quic_listeners/quiche/platform/http2_macros_impl.h @@ -18,7 +18,7 @@ namespace http2 { -template T dieIfNull(T&& ptr) { +template inline T dieIfNull(T&& ptr) { CHECK((ptr) != nullptr); return std::forward(ptr); }