You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by am...@apache.org on 2022/10/17 23:25:41 UTC
[trafficserver] branch 10-Dev updated: libswoc: Clean up ts::MemSpan (#9144)
This is an automated email from the ASF dual-hosted git repository.
amc pushed a commit to branch 10-Dev
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/10-Dev by this push:
new 2a04747e8 libswoc: Clean up ts::MemSpan (#9144)
2a04747e8 is described below
commit 2a04747e81953e697d6059e16e778d2e0e36367e
Author: Alan M. Carroll <am...@apache.org>
AuthorDate: Mon Oct 17 18:25:36 2022 -0500
libswoc: Clean up ts::MemSpan (#9144)
---
build/libswoc.m4 | 4 +-
build/plugins.mk | 3 +-
include/records/I_RecCore.h | 2 +-
include/records/P_RecMessage.h | 2 +-
include/tscore/BufferWriter.h | 7 +-
include/tscore/MemArena.h | 22 +-
include/tscpp/util/MemSpan.h | 877 -----------------------
iocore/aio/Makefile.am | 7 +-
iocore/cache/Makefile.am | 3 +
iocore/dns/Makefile.am | 1 +
iocore/eventsystem/Makefile.am | 8 +-
iocore/hostdb/I_HostDBProcessor.h | 7 +-
iocore/hostdb/Makefile.am | 5 +-
iocore/net/Makefile.am | 22 +-
iocore/net/SSLCertLookup.cc | 2 +-
iocore/net/quic/Makefile.am | 4 +-
iocore/utils/Makefile.am | 2 +-
lib/swoc/Makefile.am | 2 +-
mgmt/Makefile.am | 1 +
mgmt/MgmtDefs.h | 4 +-
mgmt/api/Makefile.am | 1 +
mgmt/config/Makefile.am | 4 +-
mgmt/rpc/Makefile.am | 2 +-
mgmt/rpc/server/IPCSocketServer.cc | 2 +-
mgmt/rpc/server/IPCSocketServer.h | 4 +-
mgmt/utils/Makefile.am | 6 +-
proxy/Makefile.am | 1 +
proxy/hdrs/Makefile.am | 6 +-
proxy/http/Makefile.am | 3 +-
proxy/http/remap/Makefile.am | 3 +-
proxy/http2/Makefile.am | 3 +-
proxy/http3/Makefile.am | 4 +-
proxy/logging/LogConfig.cc | 2 +-
proxy/logging/LogConfig.h | 4 +-
proxy/logging/unit-tests/test_LogUtils.h | 4 +-
proxy/shared/Makefile.am | 1 +
src/records/Makefile.am | 4 +-
src/records/RecMessage.cc | 2 +-
src/shared/rpc/IPCSocketClient.cc | 4 +-
src/traffic_cache_tool/CacheDefs.h | 2 +-
src/traffic_cache_tool/CacheScan.cc | 6 +-
src/traffic_cache_tool/CacheScan.h | 2 +-
src/traffic_cache_tool/CacheTool.cc | 2 +-
src/traffic_cache_tool/Makefile.inc | 5 +-
src/traffic_crashlog/Makefile.inc | 1 +
src/traffic_ctl/Makefile.inc | 4 +-
src/traffic_layout/Makefile.inc | 5 +-
src/traffic_logcat/Makefile.inc | 4 +-
src/traffic_logstats/Makefile.inc | 4 +-
src/traffic_quic/Makefile.inc | 4 +-
src/traffic_server/Makefile.inc | 3 +
src/traffic_top/Makefile.inc | 5 +-
src/tscore/BufferWriterFormat.cc | 2 +
src/tscore/Makefile.am | 5 +-
src/tscore/MemArena.cc | 1 +
src/tscore/unit_tests/test_BufferWriterFormat.cc | 12 +-
src/tscore/unit_tests/test_MemArena.cc | 18 +-
src/tscpp/util/Makefile.am | 1 -
src/tscpp/util/unit_tests/test_MemSpan.cc | 91 ---
tools/Makefile.am | 2 +-
60 files changed, 151 insertions(+), 1073 deletions(-)
diff --git a/build/libswoc.m4 b/build/libswoc.m4
index 0858ec85c..65c1d61e4 100644
--- a/build/libswoc.m4
+++ b/build/libswoc.m4
@@ -55,7 +55,7 @@ if test "$has_libswoc" != "no"; then
saved_ldflags=$LDFLAGS
saved_cppflags=$CPPFLAGS
- SWOC_LIBS=-lswoc
+ SWOC_LIBS=-ltsswoc
if test "$libswoc_base_dir" != "/usr"; then
SWOC_INCLUDES=-I${swoc_include}
SWOC_LDFLAGS=-L${swoc_ldflags}
@@ -75,7 +75,7 @@ fi
[
has_libswoc=no
SWOC_INCLUDES=-I\${abs_top_srcdir}/lib/swoc/include
- SWOC_LIBS=-lswoc
+ SWOC_LIBS=-ltsswoc
SWOC_LDFLAGS=-L\${abs_top_builddir}/lib/swoc
])
diff --git a/build/plugins.mk b/build/plugins.mk
index 4556fc22e..bd00dd78f 100644
--- a/build/plugins.mk
+++ b/build/plugins.mk
@@ -30,7 +30,8 @@ TS_PLUGIN_CPPFLAGS = \
-I$(abs_top_srcdir)/include/cppapi/include \
-I$(abs_top_builddir)/lib/cppapi/include \
-I$(abs_top_srcdir)/include \
- -I$(abs_top_srcdir)/lib
+ -I$(abs_top_srcdir)/lib \
+ @SWOC_INCLUDES@
# Provide a default AM_CPPFLAGS. Automake handles this correctly, but libtool
# throws an error if we try to do the same with AM_LDFLAGS. Hence, we provide
diff --git a/include/records/I_RecCore.h b/include/records/I_RecCore.h
index 90b0a03df..378e47c63 100644
--- a/include/records/I_RecCore.h
+++ b/include/records/I_RecCore.h
@@ -28,7 +28,7 @@
#include "tscore/Diags.h"
#include "I_RecDefs.h"
-#include "tscpp/util/MemSpan.h"
+#include "swoc/MemSpan.h"
struct RecRecord;
diff --git a/include/records/P_RecMessage.h b/include/records/P_RecMessage.h
index 802c7b3c4..8f4947a3a 100644
--- a/include/records/P_RecMessage.h
+++ b/include/records/P_RecMessage.h
@@ -24,7 +24,7 @@
#pragma once
#include "P_RecDefs.h"
-#include "tscpp/util/MemSpan.h"
+#include "swoc/MemSpan.h"
//-------------------------------------------------------------------------
// Initialization
diff --git a/include/tscore/BufferWriter.h b/include/tscore/BufferWriter.h
index 85d0a74f8..0d1758ab2 100644
--- a/include/tscore/BufferWriter.h
+++ b/include/tscore/BufferWriter.h
@@ -31,8 +31,9 @@
#include <iosfwd>
#include <string_view>
+#include "swoc/MemSpan.h"
+
#include "tscpp/util/TextView.h"
-#include "tscpp/util/MemSpan.h"
#include "tscore/BufferWriterForward.h"
namespace ts
@@ -237,7 +238,7 @@ public:
FixedBufferWriter(FixedBufferWriter &&) = delete;
FixedBufferWriter &operator=(FixedBufferWriter &&) = delete;
- FixedBufferWriter(MemSpan<char> &span) : _buf(span.begin()), _capacity(static_cast<size_t>(span.size())) {}
+ FixedBufferWriter(swoc::MemSpan<char> &span) : _buf(span.begin()), _capacity(static_cast<size_t>(span.size())) {}
/// Write a single character @a c to the buffer.
FixedBufferWriter &
@@ -732,7 +733,7 @@ bwformat(BufferWriter &w, BWFSpec const &spec, const void *ptr)
}
// MemSpan
-BufferWriter &bwformat(BufferWriter &w, BWFSpec const &spec, MemSpan<void> const &span);
+BufferWriter &bwformat(BufferWriter &w, BWFSpec const &spec, swoc::MemSpan<void> const &span);
// -- Common formatters --
diff --git a/include/tscore/MemArena.h b/include/tscore/MemArena.h
index 0b868c81e..47318d454 100644
--- a/include/tscore/MemArena.h
+++ b/include/tscore/MemArena.h
@@ -27,7 +27,7 @@
#include <mutex>
#include <memory>
#include <utility>
-#include "tscpp/util/MemSpan.h"
+#include "swoc/MemSpan.h"
#include "tscore/Scalar.h"
#include "tscore/IntrusivePtr.h"
@@ -78,14 +78,14 @@ protected:
size_t remaining() const;
/// Span of unallocated storage.
- MemSpan<void> remnant();
+ swoc::MemSpan<void> remnant();
/** Allocate @a n bytes from this block.
*
* @param n Number of bytes to allocate.
* @return The span of memory allocated.
*/
- MemSpan<void> alloc(size_t n);
+ swoc::MemSpan<void> alloc(size_t n);
/** Check if the byte at address @a ptr is in this block.
*
@@ -127,9 +127,9 @@ public:
@a n bytes.
@param n number of bytes to allocate.
- @return a MemSpan of the allocated memory.
+ @return a swoc::MemSpan of the allocated memory.
*/
- MemSpan<void> alloc(size_t n);
+ swoc::MemSpan<void> alloc(size_t n);
/** Allocate and initialize a block of memory.
@@ -183,7 +183,7 @@ public:
size_t remaining() const;
/// @returns the remaining contiguous space in the active generation.
- MemSpan<void> remnant() const;
+ swoc::MemSpan<void> remnant() const;
/// @returns the total number of bytes allocated within the arena.
size_t allocated_size() const;
@@ -259,11 +259,11 @@ MemArena::Block::remaining() const
return size - allocated;
}
-inline MemSpan<void>
+inline swoc::MemSpan<void>
MemArena::Block::alloc(size_t n)
{
ink_assert(n <= this->remaining());
- MemSpan<void> zret = this->remnant().prefix(n);
+ swoc::MemSpan<void> zret = this->remnant().prefix(n);
allocated += n;
return zret;
}
@@ -277,7 +277,7 @@ MemArena::make(Args &&... args)
inline MemArena::MemArena(size_t n) : _reserve_hint(n) {}
-inline MemSpan<void>
+inline swoc::MemSpan<void>
MemArena::Block::remnant()
{
return {this->data() + allocated, this->remaining()};
@@ -301,10 +301,10 @@ MemArena::remaining() const
return _active ? _active->remaining() : 0;
}
-inline MemSpan<void>
+inline swoc::MemSpan<void>
MemArena::remnant() const
{
- return _active ? _active->remnant() : MemSpan<void>{};
+ return _active ? _active->remnant() : swoc::MemSpan<void>{};
}
inline size_t
diff --git a/include/tscpp/util/MemSpan.h b/include/tscpp/util/MemSpan.h
deleted file mode 100644
index c234265ce..000000000
--- a/include/tscpp/util/MemSpan.h
+++ /dev/null
@@ -1,877 +0,0 @@
-/** @file
-
- Spans of writable memory. This is similar but independently developed from @c std::span. The goal
- is to provide convenient handling for chunks of memory. These chunks can be treated as arrays of
- arbitrary types via template methods.
-*/
-
-/* Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- agreements. See the NOTICE file distributed with this work for additional information regarding
- copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with the License. You may obtain
- a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software distributed under the License
- is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- or implied. See the License for the specific language governing permissions and limitations under
- the License.
- */
-
-#pragma once
-#include <cstring>
-#include <iosfwd>
-#include <iostream>
-#include <cstddef>
-#include <string_view>
-#include <type_traits>
-#include <ratio>
-#include <exception>
-
-namespace ts
-{
-/** A span of contiguous piece of memory.
-
- A @c MemSpan does not own the memory to which it refers, it is simply a span of part of some
- (presumably) larger memory object. It acts as a pointer, not a container - copy and assignment
- change the span, not the memory to which the span refers.
-
- The purpose is that frequently code needs to work on a specific part of the memory. This can
- avoid copying or allocation by allocating all needed memory at once and then working with it via
- instances of this class.
-
- */
-template <typename T> class MemSpan
-{
- using self_type = MemSpan; ///< Self reference type.
-
-protected:
- T *_ptr = nullptr; ///< Pointer to base of memory chunk.
- size_t _count = 0; ///< Number of elements.
-
-public:
- using value_type = T;
-
- /// Default constructor (empty buffer).
- constexpr MemSpan() = default;
-
- /// Copy constructor.
- constexpr MemSpan(self_type const &that) = default;
-
- /** Construct from a first element @a start and a @a count of elements.
- *
- * @param start First element.
- * @param count Total number of elements.
- */
- constexpr MemSpan(value_type *start, size_t count);
-
- /** Construct from a half open range [start, last).
- *
- * @param start Start of range.
- * @param last Past end of range.
- */
- constexpr MemSpan(value_type *start, value_type *last);
-
- /** Construct to cover an array.
- *
- * @tparam N Number of elements in the array.
- * @param a The array.
- */
- template <size_t N> MemSpan(T (&a)[N]);
-
- /** Construct from nullptr.
- This implicitly makes the length 0.
- */
- constexpr MemSpan(std::nullptr_t);
-
- /** Equality.
-
- Compare the span contents.
-
- @return @c true if the contents of @a that are the same as the content of @a this,
- @c false otherwise.
- */
- bool operator==(self_type const &that) const;
-
- /** Identical.
-
- Check if the spans refer to the same span of memory.
- @return @c true if @a this and @a that refer to the same span, @c false if not.
- */
- bool is_same(self_type const &that) const;
-
- /** Inequality.
- @return @c true if @a that does not refer to the same span as @a this,
- @c false otherwise.
- */
- bool operator!=(self_type const &that) const;
-
- /// Assignment - the span is copied, not the content.
- self_type &operator=(self_type const &that) = default;
-
- /// Access element at index @a idx.
- T &operator[](size_t idx) const;
-
- /// Check for empty span.
- /// @return @c true if the span is empty (no contents), @c false otherwise.
- bool operator!() const;
-
- /// Check for non-empty span.
- /// @return @c true if the span contains bytes.
- explicit operator bool() const;
-
- /// Check for empty span (no content).
- /// @see operator bool
- bool empty() const;
-
- /// @name Accessors.
- //@{
- /// Pointer to the first element in the span.
- T *begin() const;
-
- /// Pointer to first element not in the span.
- T *end() const;
-
- /// Number of elements in the span
- size_t count() const;
-
- /// Number of bytes in the span.
- size_t size() const;
-
- /// Pointer to memory in the span.
- T *data() const;
-
- /** Make a copy of @a this span on the same memory but of type @a U.
- *
- * @tparam U Type for the created span.
- * @return A @c MemSpan which contains the same memory as instances of @a U.
- */
- template <typename U = void> MemSpan<U> rebind() const;
-
- /// Set the span.
- /// This is faster but equivalent to constructing a new span with the same
- /// arguments and assigning it.
- /// @return @c this.
- self_type &assign(T *ptr, ///< Buffer start.
- size_t count ///< # of elements.
- );
-
- /// Set the span.
- /// This is faster but equivalent to constructing a new span with the same
- /// arguments and assigning it.
- /// @return @c this.
- self_type &assign(T *first, ///< First valid element.
- T const *last ///< First invalid element.
- );
-
- /// Clear the span (become an empty span).
- self_type &clear();
-
- /// @return @c true if the byte at @a *p is in the span.
- bool contains(value_type const *p) const;
-
- /** Get the initial segment of @a count elements.
-
- @return An instance that contains the leading @a count elements of @a this.
- */
- self_type prefix(size_t count) const;
-
- /** Shrink the span by removing @a count leading elements.
- *
- * @param count The number of elements to remove.
- * @return @c *this
- */
- self_type &remove_prefix(size_t count);
-
- /** Get the trailing segment of @a count elements.
- *
- * @param count Number of elements to retrieve.
- * @return An instance that contains the trailing @a count elements of @a this.
- */
- self_type suffix(size_t count) const;
-
- /** Shrink the span by removing @a count trailing elements.
- *
- * @param count Number of elements to remove.
- * @return @c *this
- */
- self_type &remove_suffix(size_t count);
-
- /** Return a view of the memory.
- *
- * @return A @c string_view covering the span contents.
- */
- std::string_view view() const;
-
- template <typename U> friend class MemSpan;
-};
-
-/** Specialization for void pointers.
- *
- * Key differences:
- *
- * - No subscript operator.
- * - No array initialization.
- * - All other @c MemSpan types implicitly convert to this type.
- *
- * @internal I tried to be clever about the base template but there were too many differences
- * One major issue was the array initialization did not work at all if the @c void case didn't
- * exclude that. Once separate there are a number of useful tweaks available.
- */
-template <> class MemSpan<void>
-{
- using self_type = MemSpan; ///< Self reference type.
- template <typename U> friend class MemSpan;
-
-public:
- using value_type = void; /// Export base type.
-
-protected:
- value_type *_ptr = nullptr; ///< Pointer to base of memory chunk.
- size_t _size = 0; ///< Number of elements.
-
-public:
- /// Default constructor (empty buffer).
- constexpr MemSpan() = default;
-
- /// Copy constructor.
- constexpr MemSpan(self_type const &that) = default;
- MemSpan &operator=(const MemSpan &) = default;
-
- /** Cross type copy constructor.
- *
- * @tparam U Type for source span.
- * @param that Source span.
- *
- * This enables any @c MemSpan to be automatically converted to a void span, just as any pointer
- * can convert to a void pointer.
- */
- template <typename U> constexpr MemSpan(MemSpan<U> const &that);
-
- /** Construct from a pointer @a start and a size @a n bytes.
- *
- * @param start Start of the span.
- * @param n # of bytes in the span.
- */
- constexpr MemSpan(value_type *start, size_t n);
-
- /** Construct from a half open range of [start, last).
- *
- * @param start Start of the range.
- * @param last Past end of range.
- */
- MemSpan(value_type *start, value_type *last);
-
- /** Construct from nullptr.
- This implicitly makes the length 0.
- */
- constexpr MemSpan(std::nullptr_t);
-
- /** Equality.
-
- Compare the span contents.
-
- @return @c true if the contents of @a that are bytewise the same as the content of @a this,
- @c false otherwise.
- */
- bool operator==(self_type const &that) const;
-
- /** Identical.
-
- Check if the spans refer to the same span of memory.
-
- @return @c true if @a this and @a that refer to the same memory, @c false if not.
- */
- bool is_same(self_type const &that) const;
-
- /** Inequality.
- @return @c true if @a that does not refer to the same span as @a this,
- @c false otherwise.
- */
- bool operator!=(self_type const &that) const;
-
- /// Assignment - the span is copied, not the content.
- /// Any type of @c MemSpan can be assigned to @c MemSpan<void>.
- template <typename U> self_type &operator=(MemSpan<U> const &that);
-
- /// Check for empty span.
- /// @return @c true if the span is empty (no contents), @c false otherwise.
- bool operator!() const;
-
- /// Check for non-empty span.
- /// @return @c true if the span contains bytes.
- explicit operator bool() const;
-
- /// Check for empty span (no content).
- /// @see operator bool
- bool empty() const;
-
- /// Number of bytes in the span.
- size_t size() const;
-
- /// Pointer to memory in the span.
- value_type *data() const;
-
- /// Pointer to memory in the span.
- value_type *data_end() const;
-
- /** Create a new span for a different type @a V on the same memory.
- *
- * @tparam V Type for the created span.
- * @return A @c MemSpan which contains the same memory as instances of @a V.
- */
- template <typename U> MemSpan<U> rebind() const;
-
- /// Set the span.
- /// This is faster but equivalent to constructing a new span with the same
- /// arguments and assigning it.
- /// @return @c this.
- self_type &assign(value_type *ptr, ///< Buffer start.
- size_t n ///< # of bytes
- );
-
- /// Set the span.
- /// This is faster but equivalent to constructing a new span with the same
- /// arguments and assigning it.
- /// @return @c this.
- self_type &assign(value_type *first, ///< First valid element.
- value_type const *last ///< First invalid element.
- );
-
- /// Clear the span (become an empty span).
- self_type &clear();
-
- /// @return @c true if the byte at @a *ptr is in the span.
- bool contains(value_type const *ptr) const;
-
- /** Get the initial segment of @a n bytes.
-
- @return An instance that contains the leading @a n bytes of @a this.
- */
- self_type prefix(size_t n) const;
-
- /** Shrink the span by removing @a n leading bytes.
- *
- * @param count The number of elements to remove.
- * @return @c *this
- */
-
- self_type &remove_prefix(size_t count);
-
- /** Get the trailing segment of @a n bytes.
- *
- * @param n Number of bytes to retrieve.
- * @return An instance that contains the trailing @a count elements of @a this.
- */
- self_type suffix(size_t n) const;
-
- /** Shrink the span by removing @a n bytes.
- *
- * @param n Number of bytes to remove.
- * @return @c *this
- */
- self_type &remove_suffix(size_t n);
-
- /** Return a view of the memory.
- *
- * @return A @c string_view covering the span contents.
- */
- std::string_view view() const;
-};
-
-// -- Implementation --
-
-namespace detail
-{
- /// Support pointer distance calculations for all types, @b include @c <void*>.
- /// This is useful in templates.
- inline size_t
- ptr_distance(void const *first, void const *last)
- {
- return static_cast<const char *>(last) - static_cast<const char *>(first);
- }
-
- template <typename T>
- size_t
- ptr_distance(T const *first, T const *last)
- {
- return last - first;
- }
-
- /** Functor to convert span types.
- *
- * @tparam T Source span type.
- * @tparam U Destination span type.
- *
- * @internal More void handling. This can't go in @c MemSpan because template specialization is
- * invalid in class scope and this needs to be specialized for @c void.
- */
- template <typename T, typename U> struct is_span_compatible {
- /// @c true if the size of @a T is an integral multiple of the size of @a U or vice versa.
- static constexpr bool value = std::ratio<sizeof(T), sizeof(U)>::num == 1 || std::ratio<sizeof(U), sizeof(T)>::num == 1;
- /** Compute the new size in units of @c sizeof(U).
- *
- * @param size Size in bytes.
- * @return Size in units of @c sizeof(U).
- *
- * The critical part of this is the @c static_assert that guarantees the result is an integral
- * number of instances of @a U.
- */
- static size_t count(size_t size);
- };
-
- template <typename T, typename U>
- size_t
- is_span_compatible<T, U>::count(size_t size)
- {
- if (size % sizeof(U)) {
- throw std::invalid_argument("MemSpan rebind where span size is not a multiple of the element size");
- }
- return size / sizeof(U);
- }
-
- /// @cond INTERNAL_DETAIL
- // Must specialize for rebinding to @c void because @c sizeof doesn't work. Rebinding from @c void
- // is handled by the @c MemSpan<void>::rebind specialization and doesn't use this mechanism.
- template <typename T> struct is_span_compatible<T, void> {
- static constexpr bool value = true;
- static size_t count(size_t size);
- };
-
- template <typename T>
- size_t
- is_span_compatible<T, void>::count(size_t size)
- {
- return size;
- }
- /// @endcond
-
-} // namespace detail
-
-// --- Standard memory operations ---
-
-template <typename T>
-int
-memcmp(MemSpan<T> const &lhs, MemSpan<T> const &rhs)
-{
- int zret = 0;
- size_t n = lhs.size();
-
- // Seems a bit ugly but size comparisons must be done anyway to get the memcmp args.
- if (lhs.count() < rhs.count()) {
- zret = 1;
- } else if (lhs.count() > rhs.count()) {
- zret = -1;
- n = rhs.size();
- }
- // else the counts are equal therefore @a n and @a zret are already correct.
-
- int r = std::memcmp(lhs.data(), rhs.data(), n);
- if (0 != r) { // If we got a not-equal, override the size based result.
- zret = r;
- }
-
- return zret;
-}
-
-using std::memcmp;
-
-template <typename T>
-T *
-memcpy(MemSpan<T> &dst, MemSpan<T> const &src)
-{
- return static_cast<T *>(std::memcpy(dst.data(), src.data(), std::min(dst.size(), src.size())));
-}
-
-template <typename T>
-T *
-memcpy(MemSpan<T> &dst, T *src)
-{
- return static_cast<T *>(std::memcpy(dst.data(), src, dst.size()));
-}
-
-template <typename T>
-T *
-memcpy(T *dst, MemSpan<T> &src)
-{
- return static_cast<T *>(std::memcpy(dst, src.data(), src.size()));
-}
-
-inline char *
-memcpy(MemSpan<char> &span, std::string_view view)
-{
- return static_cast<char *>(std::memcpy(span.data(), view.data(), std::min(view.size(), view.size())));
-}
-
-inline void *
-memcpy(MemSpan<void> &span, std::string_view view)
-{
- return std::memcpy(span.data(), view.data(), std::min(view.size(), view.size()));
-}
-
-using std::memcpy;
-using std::memcpy;
-
-template <typename T>
-inline MemSpan<T> const &
-memset(MemSpan<T> const &dst, T const &t)
-{
- for (auto &e : dst) {
- e = t;
- }
- return dst;
-}
-
-inline MemSpan<char> const &
-memset(MemSpan<char> const &dst, char c)
-{
- std::memset(dst.data(), c, dst.size());
- return dst;
-}
-
-inline MemSpan<unsigned char> const &
-memset(MemSpan<unsigned char> const &dst, unsigned char c)
-{
- std::memset(dst.data(), c, dst.size());
- return dst;
-}
-
-inline MemSpan<void> const &
-memset(MemSpan<void> const &dst, char c)
-{
- std::memset(dst.data(), c, dst.size());
- return dst;
-}
-
-using std::memset;
-
-// --- MemSpan<T> ---
-
-template <typename T> constexpr MemSpan<T>::MemSpan(T *ptr, size_t count) : _ptr{ptr}, _count{count} {}
-
-template <typename T> constexpr MemSpan<T>::MemSpan(T *first, T *last) : _ptr{first}, _count{detail::ptr_distance(first, last)} {}
-
-template <typename T> template <size_t N> MemSpan<T>::MemSpan(T (&a)[N]) : _ptr{a}, _count{N} {}
-
-template <typename T> constexpr MemSpan<T>::MemSpan(std::nullptr_t) {}
-
-template <typename T>
-MemSpan<T> &
-MemSpan<T>::assign(T *ptr, size_t count)
-{
- _ptr = ptr;
- _count = count;
- return *this;
-}
-
-template <typename T>
-MemSpan<T> &
-MemSpan<T>::assign(T *first, T const *last)
-{
- _ptr = first;
- _count = detail::ptr_distance(first, last);
- return *this;
-}
-
-template <typename T>
-MemSpan<T> &
-MemSpan<T>::clear()
-{
- _ptr = nullptr;
- _count = 0;
- return *this;
-}
-
-template <typename T>
-bool
-MemSpan<T>::is_same(self_type const &that) const
-{
- return _ptr == that._ptr && _count == that._count;
-}
-
-template <typename T>
-bool
-MemSpan<T>::operator==(self_type const &that) const
-{
- return _count == that._count && (_ptr == that._ptr || 0 == memcmp(_ptr, that._ptr, this->size()));
-}
-
-template <typename T>
-bool
-MemSpan<T>::operator!=(self_type const &that) const
-{
- return !(*this == that);
-}
-
-template <typename T>
-bool
-MemSpan<T>::operator!() const
-{
- return _count == 0;
-}
-
-template <typename T> MemSpan<T>::operator bool() const
-{
- return _count != 0;
-}
-
-template <typename T>
-bool
-MemSpan<T>::empty() const
-{
- return _count == 0;
-}
-
-template <typename T>
-T *
-MemSpan<T>::begin() const
-{
- return _ptr;
-}
-
-template <typename T>
-T *
-MemSpan<T>::data() const
-{
- return _ptr;
-}
-
-template <typename T>
-T *
-MemSpan<T>::end() const
-{
- return _ptr + _count;
-}
-
-template <typename T>
-T &
-MemSpan<T>::operator[](size_t idx) const
-{
- return _ptr[idx];
-}
-
-template <typename T>
-size_t
-MemSpan<T>::count() const
-{
- return _count;
-}
-
-template <typename T>
-size_t
-MemSpan<T>::size() const
-{
- return _count * sizeof(T);
-}
-
-template <typename T>
-bool
-MemSpan<T>::contains(T const *ptr) const
-{
- return _ptr <= ptr && ptr < _ptr + _count;
-}
-
-template <typename T>
-auto
-MemSpan<T>::prefix(size_t count) const -> self_type
-{
- return {_ptr, std::min(count, _count)};
-}
-
-template <typename T>
-auto
-MemSpan<T>::remove_prefix(size_t count) -> self_type &
-{
- count = std::min(_count, count);
- _count -= count;
- _ptr += count;
- return *this;
-}
-
-template <typename T>
-auto
-MemSpan<T>::suffix(size_t count) const -> self_type
-{
- count = std::min(_count, count);
- return {(_ptr + _count) - count, count};
-}
-
-template <typename T>
-MemSpan<T> &
-MemSpan<T>::remove_suffix(size_t count)
-{
- _count -= std::min(count, _count);
- return *this;
-}
-
-template <typename T>
-template <typename U>
-MemSpan<U>
-MemSpan<T>::rebind() const
-{
- static_assert(detail::is_span_compatible<T, U>::value,
- "MemSpan only allows rebinding between types who sizes are integral multiples.");
- return {static_cast<U *>(static_cast<void *>(_ptr)), detail::is_span_compatible<T, U>::count(this->size())};
-}
-
-template <typename T>
-std::string_view
-MemSpan<T>::view() const
-{
- return {static_cast<const char *>(_ptr), this->size()};
-}
-
-// --- void specialization ---
-
-template <typename U> constexpr MemSpan<void>::MemSpan(MemSpan<U> const &that) : _ptr(that._ptr), _size(that.size()) {}
-
-inline constexpr MemSpan<void>::MemSpan(value_type *ptr, size_t n) : _ptr{ptr}, _size{n} {}
-
-inline MemSpan<void>::MemSpan(value_type *first, value_type *last) : _ptr{first}, _size{detail::ptr_distance(first, last)} {}
-
-inline constexpr MemSpan<void>::MemSpan(std::nullptr_t) {}
-
-inline MemSpan<void> &
-MemSpan<void>::assign(value_type *ptr, size_t n)
-{
- _ptr = ptr;
- _size = n;
- return *this;
-}
-
-inline MemSpan<void> &
-MemSpan<void>::assign(value_type *first, value_type const *last)
-{
- _ptr = first;
- _size = detail::ptr_distance(first, last);
- return *this;
-}
-
-inline MemSpan<void> &
-MemSpan<void>::clear()
-{
- _ptr = nullptr;
- _size = 0;
- return *this;
-}
-
-inline bool
-MemSpan<void>::is_same(self_type const &that) const
-{
- return _ptr == that._ptr && _size == that._size;
-}
-
-inline bool
-MemSpan<void>::operator==(self_type const &that) const
-{
- return _size == that._size && (_ptr == that._ptr || 0 == memcmp(_ptr, that._ptr, _size));
-}
-
-inline bool
-MemSpan<void>::operator!=(self_type const &that) const
-{
- return !(*this == that);
-}
-
-inline bool
-MemSpan<void>::operator!() const
-{
- return _size == 0;
-}
-
-inline MemSpan<void>::operator bool() const
-{
- return _size != 0;
-}
-
-inline bool
-MemSpan<void>::empty() const
-{
- return _size == 0;
-}
-
-inline void *
-MemSpan<void>::data() const
-{
- return _ptr;
-}
-
-inline void *
-MemSpan<void>::data_end() const
-{
- return static_cast<char *>(_ptr) + _size;
-}
-
-inline size_t
-MemSpan<void>::size() const
-{
- return _size;
-}
-
-template <typename U>
-auto
-MemSpan<void>::operator=(MemSpan<U> const &that) -> self_type &
-{
- _ptr = that._ptr;
- _size = that.size();
- return *this;
-}
-
-inline bool
-MemSpan<void>::contains(value_type const *ptr) const
-{
- return _ptr <= ptr && ptr < this->data_end();
-}
-
-inline MemSpan<void>
-MemSpan<void>::prefix(size_t n) const
-{
- return {_ptr, std::min(n, _size)};
-}
-
-inline MemSpan<void> &
-MemSpan<void>::remove_prefix(size_t n)
-{
- n = std::max(_size, n);
- _size -= n;
- _ptr = static_cast<char *>(_ptr) + n;
- return *this;
-}
-
-inline MemSpan<void>
-MemSpan<void>::suffix(size_t count) const
-{
- count = std::max(count, _size);
- return {static_cast<char *>(this->data_end()) - count, size_t(count)};
-}
-
-inline MemSpan<void> &
-MemSpan<void>::remove_suffix(size_t count)
-{
- _size -= std::max(count, _size);
- return *this;
-}
-
-template <typename U>
-MemSpan<U>
-MemSpan<void>::rebind() const
-{
- return {static_cast<U *>(_ptr), detail::is_span_compatible<void, U>::count(_size)};
-}
-
-// Specialize so that @c void -> @c void rebinding compiles and works as expected.
-template <>
-inline MemSpan<void>
-MemSpan<void>::rebind() const
-{
- return *this;
-}
-
-inline std::string_view
-MemSpan<void>::view() const
-{
- return {static_cast<char const *>(_ptr), _size};
-}
-
-} // namespace ts
diff --git a/iocore/aio/Makefile.am b/iocore/aio/Makefile.am
index b565c551f..41fc5ade4 100644
--- a/iocore/aio/Makefile.am
+++ b/iocore/aio/Makefile.am
@@ -20,6 +20,7 @@ AM_CPPFLAGS += \
-I$(abs_top_srcdir)/iocore/eventsystem \
-I$(abs_top_srcdir)/include \
-I$(abs_top_srcdir)/lib \
+ @SWOC_INCLUDES@
$(TS_INCLUDES)
TESTS = test_AIO.sample
@@ -35,7 +36,7 @@ libinkaio_a_SOURCES = \
test_AIO_LDFLAGS = \
@AM_LDFLAGS@ \
- @OPENSSL_LDFLAGS@
+ @OPENSSL_LDFLAGS@ @SWOC_LDFLAGS@
test_AIO_SOURCES = \
test_AIO.cc
@@ -49,7 +50,7 @@ test_AIO_CPPFLAGS = \
-I$(abs_top_srcdir)/proxy/logging \
-I$(abs_top_srcdir)/mgmt \
-I$(abs_top_srcdir)/mgmt/utils \
- @OPENSSL_INCLUDES@
+ @SWOC_INCLUDES@ @OPENSSL_INCLUDES@
test_AIO_LDADD = \
libinkaio.a \
@@ -59,7 +60,7 @@ test_AIO_LDADD = \
$(top_builddir)/src/tscore/libtscore.la \
$(top_builddir)/src/tscpp/util/libtscpputil.la \
$(top_builddir)/proxy/shared/libUglyLogStubs.a \
- @HWLOC_LIBS@
+ @SWOC_LIBS@ @HWLOC_LIBS@
include $(top_srcdir)/build/tidy.mk
diff --git a/iocore/cache/Makefile.am b/iocore/cache/Makefile.am
index 6a6f8e1a9..8d10def9b 100644
--- a/iocore/cache/Makefile.am
+++ b/iocore/cache/Makefile.am
@@ -27,6 +27,7 @@ AM_CPPFLAGS += \
-I$(abs_top_srcdir)/proxy/http/remap \
-I$(abs_top_srcdir)/mgmt \
-I$(abs_top_srcdir)/mgmt/utils \
+ @SWOC_INCLUDES@
$(TS_INCLUDES)
noinst_LIBRARIES = libinkcache.a
@@ -84,6 +85,7 @@ test_CPPFLAGS = \
-I$(abs_top_srcdir)/mgmt \
-I$(abs_top_srcdir)/mgmt/utils \
-I$(abs_top_srcdir)/tests/include \
+ @SWOC_INCLUDES@ \
$(TS_INCLUDES) \
@OPENSSL_INCLUDES@
@@ -107,6 +109,7 @@ test_LDADD = \
$(top_builddir)/src/records/librecords_p.a \
$(top_builddir)/lib/fastlz/libfastlz.a \
$(top_builddir)/iocore/eventsystem/libinkevent.a \
+ @SWOC_LIBS@ \
@HWLOC_LIBS@ \
@LIBPCRE@ \
@LIBRESOLV@ \
diff --git a/iocore/dns/Makefile.am b/iocore/dns/Makefile.am
index a7287d2b2..13231acdd 100644
--- a/iocore/dns/Makefile.am
+++ b/iocore/dns/Makefile.am
@@ -25,6 +25,7 @@ AM_CPPFLAGS += \
-I$(abs_top_srcdir)/proxy/hdrs \
-I$(abs_top_srcdir)/mgmt \
-I$(abs_top_srcdir)/mgmt/utils \
+ @SWOC_INCLUDES@ \
$(TS_INCLUDES)
noinst_LIBRARIES = libinkdns.a
diff --git a/iocore/eventsystem/Makefile.am b/iocore/eventsystem/Makefile.am
index 97ee20b3d..15265d5a6 100644
--- a/iocore/eventsystem/Makefile.am
+++ b/iocore/eventsystem/Makefile.am
@@ -19,7 +19,7 @@
AM_CPPFLAGS += \
-I$(abs_top_srcdir)/include \
-I$(abs_top_srcdir)/lib \
- $(TS_INCLUDES)
+ $(TS_INCLUDES) @SWOC_INCLUDES@
TESTS = $(check_PROGRAMS)
@@ -77,7 +77,7 @@ check_PROGRAMS = test_IOBuffer \
test_LD_FLAGS = \
@AM_LDFLAGS@ \
- @OPENSSL_LDFLAGS@
+ @OPENSSL_LDFLAGS@ @SWOC_LDFLAGS@
test_CPP_FLAGS = \
$(AM_CPPFLAGS) \
@@ -89,7 +89,7 @@ test_CPP_FLAGS = \
-I$(abs_top_srcdir)/mgmt \
-I$(abs_top_srcdir)/mgmt/utils \
-I$(abs_top_srcdir)/tests/include \
- @OPENSSL_INCLUDES@
+ @OPENSSL_INCLUDES@ @SWOC_INCLUDES@
test_LD_ADD = \
libinkevent.a \
@@ -99,7 +99,7 @@ test_LD_ADD = \
$(top_builddir)/src/tscore/libtscore.la \
$(top_builddir)/src/tscpp/util/libtscpputil.la \
$(top_builddir)/proxy/shared/libUglyLogStubs.a \
- @HWLOC_LIBS@
+ @HWLOC_LIBS@ @SWOC_LIBS@
test_EventSystem_SOURCES = unit_tests/test_EventSystem.cc
test_EventSystem_CPPFLAGS = $(test_CPP_FLAGS)
diff --git a/iocore/hostdb/I_HostDBProcessor.h b/iocore/hostdb/I_HostDBProcessor.h
index 62c7bc337..962ea3f77 100644
--- a/iocore/hostdb/I_HostDBProcessor.h
+++ b/iocore/hostdb/I_HostDBProcessor.h
@@ -33,6 +33,9 @@
#include "tscore/ink_inet.h"
#include "tscore/ink_resolver.h"
#include "tscore/HTTPVersion.h"
+
+#include "swoc/MemSpan.h"
+
#include "I_EventSystem.h"
#include "SRV.h"
@@ -389,7 +392,7 @@ public:
ts::TextView name_view() const;
/// Get the array of info instances.
- ts::MemSpan<HostDBInfo> rr_info();
+ swoc::MemSpan<HostDBInfo> rr_info();
/** Find a host record by IP address.
*
@@ -789,7 +792,7 @@ HostDBRecord::refresh_ip()
ip_timestamp = hostdb_current_timestamp;
}
-inline ts::MemSpan<HostDBInfo>
+inline swoc::MemSpan<HostDBInfo>
HostDBRecord::rr_info()
{
return {this->apply_offset<HostDBInfo>(rr_offset), rr_count};
diff --git a/iocore/hostdb/Makefile.am b/iocore/hostdb/Makefile.am
index 681c0988d..1dd35ca40 100644
--- a/iocore/hostdb/Makefile.am
+++ b/iocore/hostdb/Makefile.am
@@ -25,6 +25,7 @@ AM_CPPFLAGS += \
-I$(abs_top_srcdir)/proxy/http \
-I$(abs_top_srcdir)/mgmt \
-I$(abs_top_srcdir)/mgmt/utils \
+ @SWOC_INCLUDES@ \
$(TS_INCLUDES)
EXTRA_DIST = I_HostDB.h
@@ -57,7 +58,7 @@ test_RefCountCache_SOURCES = \
test_LD_FLAGS = \
@AM_LDFLAGS@ \
- @OPENSSL_LDFLAGS@
+ @SWOC_LDFLAGS@ @OPENSSL_LDFLAGS@
test_CPP_FLAGS = \
$(AM_CPPFLAGS) \
@@ -77,7 +78,7 @@ test_LD_ADD = \
$(top_builddir)/src/tscore/libtscore.la \
$(top_builddir)/src/tscpp/util/libtscpputil.la \
$(top_builddir)/proxy/shared/libUglyLogStubs.a \
- @HWLOC_LIBS@
+ @SWOC_LIBS@ @HWLOC_LIBS@
test_RefCountCache_CPPFLAGS = $(test_CPP_FLAGS)
diff --git a/iocore/net/Makefile.am b/iocore/net/Makefile.am
index de31a0c0e..dfe19ffcc 100644
--- a/iocore/net/Makefile.am
+++ b/iocore/net/Makefile.am
@@ -33,7 +33,8 @@ AM_CPPFLAGS += \
$(TS_INCLUDES) \
@OPENSSL_INCLUDES@ \
@BORINGOCSP_INCLUDES@ \
- @YAMLCPP_INCLUDES@
+ @YAMLCPP_INCLUDES@ \
+ @SWOC_INCLUDES@
TESTS = $(check_PROGRAMS)
@@ -43,7 +44,8 @@ noinst_LIBRARIES = libinknet.a
test_certlookup_LDFLAGS = \
@AM_LDFLAGS@ \
@OPENSSL_LDFLAGS@ \
- @YAMLCPP_LDFLAGS@
+ @YAMLCPP_LDFLAGS@ \
+ @SWOC_LDFLAGS@
test_certlookup_SOURCES = \
test_certlookup.cc \
@@ -54,7 +56,8 @@ test_certlookup_LDADD = \
$(top_builddir)/src/tscore/libtscore.la $(top_builddir)/src/tscpp/util/libtscpputil.la \
$(top_builddir)/iocore/eventsystem/libinkevent.a \
$(top_builddir)/proxy/ParentSelectionStrategy.o \
- @YAMLCPP_LIBS@
+ @YAMLCPP_LIBS@ \
+ @SWOC_LIBS@
test_UDPNet_CPPFLAGS = \
$(AM_CPPFLAGS) \
@@ -64,12 +67,14 @@ test_UDPNet_CPPFLAGS = \
-I$(abs_top_srcdir)/proxy/http \
-I$(abs_top_srcdir)/mgmt \
-I$(abs_top_srcdir)/mgmt/utils \
- @OPENSSL_INCLUDES@
+ @OPENSSL_INCLUDES@ \
+ @SWOC_INCLUDES@
test_UDPNet_LDFLAGS = \
@AM_LDFLAGS@ \
@OPENSSL_LDFLAGS@ \
- @YAMLCPP_LDFLAGS@
+ @YAMLCPP_LDFLAGS@ \
+ @SWOC_LDFLAGS@
test_UDPNet_LDADD = \
libinknet.a \
@@ -79,7 +84,7 @@ test_UDPNet_LDADD = \
$(top_builddir)/src/tscore/libtscore.la $(top_builddir)/src/tscpp/util/libtscpputil.la \
$(top_builddir)/proxy/hdrs/libhdrs.a \
$(top_builddir)/proxy/ParentSelectionStrategy.o \
- @HWLOC_LIBS@ @OPENSSL_LIBS@ @LIBPCRE@ @YAMLCPP_LIBS@
+ @HWLOC_LIBS@ @OPENSSL_LIBS@ @LIBPCRE@ @YAMLCPP_LIBS@ @SWOC_LIBS@
test_UDPNet_SOURCES = \
libinknet_stub.cc \
@@ -103,7 +108,8 @@ test_libinknet_CPPFLAGS = \
test_libinknet_LDFLAGS = \
@AM_LDFLAGS@ \
@OPENSSL_LDFLAGS@ \
- @YAMLCPP_LDFLAGS@
+ @YAMLCPP_LDFLAGS@ \
+ @SWOC_LDFLAGS@
test_libinknet_LDADD = \
libinknet.a \
@@ -114,7 +120,7 @@ test_libinknet_LDADD = \
$(top_builddir)/src/tscore/libtscore.la \
$(top_builddir)/src/tscpp/util/libtscpputil.la \
$(top_builddir)/proxy/ParentSelectionStrategy.o \
- @HWLOC_LIBS@ @OPENSSL_LIBS@ @LIBPCRE@ @YAMLCPP_LIBS@
+ @HWLOC_LIBS@ @OPENSSL_LIBS@ @LIBPCRE@ @YAMLCPP_LIBS@ @SWOC_LIBS@
libinknet_a_SOURCES = \
ALPNSupport.cc \
diff --git a/iocore/net/SSLCertLookup.cc b/iocore/net/SSLCertLookup.cc
index f0a951323..e2fd207a2 100644
--- a/iocore/net/SSLCertLookup.cc
+++ b/iocore/net/SSLCertLookup.cc
@@ -148,7 +148,7 @@ namespace
* @param dst Output buffer.
*/
inline void
-transform_lower(std::string_view src, ts::MemSpan<char> dst)
+transform_lower(std::string_view src, swoc::MemSpan<char> dst)
{
if (src.size() > dst.size() - 1) { // clip @a src, reserving space for the terminal nul.
src = std::string_view{src.data(), dst.size() - 1};
diff --git a/iocore/net/quic/Makefile.am b/iocore/net/quic/Makefile.am
index 56d80d253..5546fc855 100644
--- a/iocore/net/quic/Makefile.am
+++ b/iocore/net/quic/Makefile.am
@@ -29,7 +29,7 @@ AM_CPPFLAGS += \
-I$(abs_top_srcdir)/proxy/http3 \
-I$(abs_top_srcdir)/mgmt \
-I$(abs_top_srcdir)/mgmt/utils \
- $(TS_INCLUDES) \
+ $(TS_INCLUDES) @SWOC_INCLUDES@ \
@OPENSSL_INCLUDES@ @YAMLCPP_INCLUDES@
noinst_LIBRARIES = libquic.a
@@ -176,7 +176,7 @@ test_LDADD = \
$(top_builddir)/src/tscpp/util/libtscpputil.la \
$(top_builddir)/proxy/ParentSelectionStrategy.o \
$(top_builddir)/iocore/net/TLSKeyLogger.o \
- @HWLOC_LIBS@ @OPENSSL_LIBS@ @LIBPCRE@ @YAMLCPP_LIBS@
+ @HWLOC_LIBS@ @SWOC_LIBS@ @OPENSSL_LIBS@ @LIBPCRE@ @YAMLCPP_LIBS@
test_event_main_SOURCES = \
./test/event_processor_main.cc
diff --git a/iocore/utils/Makefile.am b/iocore/utils/Makefile.am
index fa2d39fb5..13115e35e 100644
--- a/iocore/utils/Makefile.am
+++ b/iocore/utils/Makefile.am
@@ -20,7 +20,7 @@ AM_CPPFLAGS += \
-I$(abs_top_srcdir)/include \
-I$(abs_top_srcdir)/lib \
-I$(abs_top_srcdir)/iocore/eventsystem \
- $(TS_INCLUDES)
+ @SWOC_INCLUDES@ $(TS_INCLUDES)
noinst_LIBRARIES = libinkutils.a
diff --git a/lib/swoc/Makefile.am b/lib/swoc/Makefile.am
index dff7cb9df..3d1700df8 100644
--- a/lib/swoc/Makefile.am
+++ b/lib/swoc/Makefile.am
@@ -18,7 +18,7 @@
include $(top_srcdir)/build/tidy.mk
-lib_LTLIBRARIES = libtsswoc.la
+noinst_LTLIBRARIES = libtsswoc.la
library_includedir=$(includedir)/swoc
diff --git a/mgmt/Makefile.am b/mgmt/Makefile.am
index 93a26fe57..c123a264a 100644
--- a/mgmt/Makefile.am
+++ b/mgmt/Makefile.am
@@ -32,6 +32,7 @@ AM_CPPFLAGS += \
-I$(abs_top_srcdir)/proxy \
-I$(abs_top_srcdir)/proxy/http \
-I$(abs_top_srcdir)/proxy/hdrs \
+ @SWOC_INCLUDES@ \
@YAMLCPP_INCLUDES@ \
$(TS_INCLUDES)
diff --git a/mgmt/MgmtDefs.h b/mgmt/MgmtDefs.h
index b62588ff2..41b76c25c 100644
--- a/mgmt/MgmtDefs.h
+++ b/mgmt/MgmtDefs.h
@@ -30,7 +30,7 @@
#include <string_view>
#include "tscore/ink_defs.h"
-#include "tscpp/util/MemSpan.h"
+#include "swoc/MemSpan.h"
#include "tscpp/util/TextView.h"
typedef int64_t MgmtIntCounter;
@@ -42,7 +42,7 @@ typedef char *MgmtString;
/// Management callback signature.
/// The memory span is the message payload for the callback.
/// This can be a lambda, which should be used if additional context information is needed.
-using MgmtCallback = std::function<void(ts::MemSpan<void>)>;
+using MgmtCallback = std::function<void(swoc::MemSpan<void>)>;
//-------------------------------------------------------------------------
// API conversion functions.
diff --git a/mgmt/api/Makefile.am b/mgmt/api/Makefile.am
index b87af924d..a90c8d94e 100644
--- a/mgmt/api/Makefile.am
+++ b/mgmt/api/Makefile.am
@@ -28,6 +28,7 @@ AM_CPPFLAGS += \
-I$(abs_top_srcdir)/mgmt \
-I$(abs_top_srcdir)/mgmt/utils \
-I$(abs_top_srcdir)/mgmt/api/include \
+ @SWOC_INCLUDES@ \
$(TS_INCLUDES) \
$(LIBUNWIND_CFLAGS)
diff --git a/mgmt/config/Makefile.am b/mgmt/config/Makefile.am
index 17e642d07..81d8ec623 100644
--- a/mgmt/config/Makefile.am
+++ b/mgmt/config/Makefile.am
@@ -30,8 +30,8 @@ AM_CPPFLAGS += \
-I$(abs_top_srcdir)/proxy/ \
-I$(abs_top_srcdir)/proxy/http \
-I$(abs_top_srcdir)/proxy/hdrs \
- $(TS_INCLUDES) \
- @YAMLCPP_INCLUDES@
+ $(TS_INCLUDES) @SWOC_INCLUDES@ \
+ @YAMLCPP_INCLUDES@
# ^^ all the proxy/* is to include the PluginCallbacks.
diff --git a/mgmt/rpc/Makefile.am b/mgmt/rpc/Makefile.am
index 2745ccfe2..c606100be 100644
--- a/mgmt/rpc/Makefile.am
+++ b/mgmt/rpc/Makefile.am
@@ -23,7 +23,7 @@ AM_CPPFLAGS += \
-I$(abs_top_srcdir)/include \
-I$(abs_top_srcdir)/lib/ \
-I$(abs_top_srcdir)/mgmt/ \
- $(TS_INCLUDES) \
+ $(TS_INCLUDES) @SWOC_INCLUDES@ \
@YAMLCPP_INCLUDES@
diff --git a/mgmt/rpc/server/IPCSocketServer.cc b/mgmt/rpc/server/IPCSocketServer.cc
index 6176d3a7f..df84a6dbe 100644
--- a/mgmt/rpc/server/IPCSocketServer.cc
+++ b/mgmt/rpc/server/IPCSocketServer.cc
@@ -339,7 +339,7 @@ IPCSocketServer::Client::close()
}
ssize_t
-IPCSocketServer::Client::read(ts::MemSpan<char> span) const
+IPCSocketServer::Client::read(swoc::MemSpan<char> span) const
{
return ::read(_fd, span.data(), span.size());
}
diff --git a/mgmt/rpc/server/IPCSocketServer.h b/mgmt/rpc/server/IPCSocketServer.h
index 1df85704d..3a76bf424 100644
--- a/mgmt/rpc/server/IPCSocketServer.h
+++ b/mgmt/rpc/server/IPCSocketServer.h
@@ -27,7 +27,7 @@
#include <string_view>
#include <memory>
-#include "tscpp/util/MemSpan.h"
+#include "swoc/MemSpan.h"
#include "tscore/BufferWriter.h"
#include "tscore/I_Layout.h"
@@ -66,7 +66,7 @@ class IPCSocketServer : public BaseCommInterface
void close();
/// Reads from the socket, this function calls the system read function.
/// @return the size of what was read by the read() function.
- ssize_t read(ts::MemSpan<char> span) const;
+ ssize_t read(swoc::MemSpan<char> span) const;
/// Function that reads all the data available in the socket, it will validate the data on every read if there is more than
/// a single chunk.
/// The size of the buffer to be read is not defined in this function, but rather passed in the @c bw parameter.
diff --git a/mgmt/utils/Makefile.am b/mgmt/utils/Makefile.am
index 30702ca7c..32e226e49 100644
--- a/mgmt/utils/Makefile.am
+++ b/mgmt/utils/Makefile.am
@@ -25,6 +25,7 @@ AM_CPPFLAGS += \
-I$(abs_top_srcdir)/proxy \
-I$(abs_top_srcdir)/include \
-I$(abs_top_srcdir)/lib \
+ @SWOC_INCLUDES@ \
$(TS_INCLUDES) \
@OPENSSL_INCLUDES@
@@ -54,14 +55,15 @@ test_mgmt_utils_CPPFLAGS = $(AM_CPPFLAGS) -I$(abs_top_srcdir)/tests/include
test_mgmt_utils_LDFLAGS = \
@AM_LDFLAGS@ \
- @OPENSSL_LDFLAGS@
+ @SWOC_LDFLAGS@ @OPENSSL_LDFLAGS@
test_mgmt_utils_SOURCES = \
unit_tests/unit_test_main.cc
test_mgmt_utils_LDADD = \
libutils_p.la \
- $(top_builddir)/src/tscore/libtscore.la
+ $(top_builddir)/src/tscore/libtscore.la \
+ @SWOC_LIBS@
include $(top_srcdir)/build/tidy.mk
diff --git a/proxy/Makefile.am b/proxy/Makefile.am
index 2c73d3100..cd06f2fe6 100644
--- a/proxy/Makefile.am
+++ b/proxy/Makefile.am
@@ -39,6 +39,7 @@ AM_CPPFLAGS += \
-I$(abs_srcdir)/hdrs \
-I$(abs_top_srcdir)/mgmt \
-I$(abs_top_srcdir)/mgmt/utils \
+ @SWOC_INCLUDES@ \
@YAMLCPP_INCLUDES@ \
$(TS_INCLUDES)
diff --git a/proxy/hdrs/Makefile.am b/proxy/hdrs/Makefile.am
index d815e0de5..1bc80ccb8 100644
--- a/proxy/hdrs/Makefile.am
+++ b/proxy/hdrs/Makefile.am
@@ -22,6 +22,7 @@ AM_CPPFLAGS += \
$(iocore_include_dirs) \
-I$(abs_top_srcdir)/include \
-I$(abs_top_srcdir)/lib \
+ @SWOC_INCLUDES@ \
$(TS_INCLUDES)
noinst_LIBRARIES = libhdrs.a
@@ -58,6 +59,7 @@ load_http_hdr_SOURCES = \
load_http_hdr.cc
load_http_hdr_LDADD = -L. -lhdrs \
+ @SWOC_LIBS@ \
$(top_builddir)/src/tscore/libtscore.la \
$(top_builddir)/src/tscpp/util/libtscpputil.la
@@ -88,7 +90,7 @@ test_proxy_hdrs_LDADD = \
$(top_builddir)/src/records/librecords_p.a \
$(top_builddir)/mgmt/libmgmt_p.la \
$(top_builddir)/proxy/shared/libUglyLogStubs.a \
- @HWLOC_LIBS@ \
+ @SWOC_LIBS@ @HWLOC_LIBS@ \
@LIBCAP@
test_hdr_heap_CPPFLAGS = $(AM_CPPFLAGS) \
@@ -107,7 +109,7 @@ test_hdr_heap_LDADD = -L. -lhdrs \
$(top_builddir)/src/records/librecords_p.a \
$(top_builddir)/mgmt/libmgmt_p.la \
$(top_builddir)/proxy/shared/libUglyLogStubs.a \
- @HWLOC_LIBS@ \
+ @SWOC_LIBS@ @HWLOC_LIBS@ \
@LIBCAP@
test_Huffmancode_LDADD = \
diff --git a/proxy/http/Makefile.am b/proxy/http/Makefile.am
index d93cabac7..dab3678f0 100644
--- a/proxy/http/Makefile.am
+++ b/proxy/http/Makefile.am
@@ -33,6 +33,7 @@ AM_CPPFLAGS += \
-I$(abs_top_srcdir)/proxy/logging \
-I$(abs_top_srcdir)/proxy/http2 \
-I$(abs_top_srcdir)/proxy/http3 \
+ @SWOC_INCLUDES@ \
$(TS_INCLUDES) \
@YAMLCPP_INCLUDES@
@@ -110,7 +111,7 @@ test_proxy_http_LDADD = \
$(top_builddir)/proxy/shared/libUglyLogStubs.a \
$(top_builddir)/mgmt/libmgmt_p.la \
$(top_builddir)/iocore/utils/libinkutils.a \
- @HWLOC_LIBS@ \
+ @SWOC_LIBS@ @HWLOC_LIBS@ \
@LIBCAP@
test_PreWarm_CPPFLAGS = \
diff --git a/proxy/http/remap/Makefile.am b/proxy/http/remap/Makefile.am
index daba213c0..31c9accd5 100644
--- a/proxy/http/remap/Makefile.am
+++ b/proxy/http/remap/Makefile.am
@@ -29,6 +29,7 @@ AM_CPPFLAGS += \
-I$(abs_top_srcdir)/proxy/hdrs \
-I$(abs_top_srcdir)/proxy/shared \
-I$(abs_top_srcdir)/proxy/http \
+ @SWOC_INCLUDES@ \
$(TS_INCLUDES) \
@YAMLCPP_INCLUDES@
@@ -74,7 +75,7 @@ COMMON_PLUGINDSO_LDADDS = \
$(top_builddir)/src/tscore/libtscore.la \
$(top_builddir)/mgmt/libmgmt_p.la \
$(top_builddir)/proxy/shared/libUglyLogStubs.a \
- @HWLOC_LIBS@
+ @SWOC_LIBS@ @HWLOC_LIBS@
clang-tidy-local: $(libhttp_remap_a_SOURCES)
$(CXX_Clang_Tidy)
diff --git a/proxy/http2/Makefile.am b/proxy/http2/Makefile.am
index faf6ab6c6..748306479 100644
--- a/proxy/http2/Makefile.am
+++ b/proxy/http2/Makefile.am
@@ -29,6 +29,7 @@ AM_CPPFLAGS += \
-I$(abs_top_srcdir)/proxy/hdrs \
-I$(abs_top_srcdir)/proxy/shared \
-I$(abs_top_srcdir)/proxy/http/remap \
+ @SWOC_INCLUDES@ \
$(TS_INCLUDES)
noinst_LIBRARIES = libhttp2.a
@@ -78,7 +79,7 @@ test_libhttp2_LDADD = \
$(top_builddir)/src/tscpp/util/libtscpputil.la \
$(top_builddir)/mgmt/libmgmt_p.la \
$(top_builddir)/proxy/shared/libUglyLogStubs.a \
- @HWLOC_LIBS@
+ @SWOC_LIBS@ @HWLOC_LIBS@
if OS_LINUX
test_libhttp2_LDFLAGS = $(AM_LDFLAGS)\
diff --git a/proxy/http3/Makefile.am b/proxy/http3/Makefile.am
index a83f2a719..98046b4df 100644
--- a/proxy/http3/Makefile.am
+++ b/proxy/http3/Makefile.am
@@ -30,7 +30,7 @@ AM_CPPFLAGS += \
-I$(abs_top_srcdir)/proxy/hdrs \
-I$(abs_top_srcdir)/proxy/shared \
-I$(abs_top_srcdir)/proxy/http/remap \
- $(TS_INCLUDES) \
+ $(TS_INCLUDES) @SWOC_INCLUDES@ \
@YAMLCPP_INCLUDES@
noinst_LIBRARIES = libhttp3.a
@@ -80,7 +80,7 @@ test_LDADD = \
$(top_builddir)/proxy/shared/libUglyLogStubs.a \
@LIBPCRE@ \
@OPENSSL_LIBS@ \
- @HWLOC_LIBS@
+ @HWLOC_LIBS@ @SWOC_LIBS@
test_libhttp3_CPPFLAGS = $(test_CPPFLAGS)
test_libhttp3_LDFLAGS = @AM_LDFLAGS@
diff --git a/proxy/logging/LogConfig.cc b/proxy/logging/LogConfig.cc
index 5650f35da..a083028dd 100644
--- a/proxy/logging/LogConfig.cc
+++ b/proxy/logging/LogConfig.cc
@@ -99,7 +99,7 @@ LogConfig::setup_default_values()
logbuffer_max_iobuf_index = BUFFER_SIZE_INDEX_32K;
}
-void LogConfig::reconfigure_mgmt_variables(ts::MemSpan<void>)
+void LogConfig::reconfigure_mgmt_variables(swoc::MemSpan<void>)
{
Note("received log reconfiguration event, rolling now");
Log::config->roll_log_files_now = true;
diff --git a/proxy/logging/LogConfig.h b/proxy/logging/LogConfig.h
index 873d07770..149c774a5 100644
--- a/proxy/logging/LogConfig.h
+++ b/proxy/logging/LogConfig.h
@@ -31,7 +31,7 @@
#include "ProxyConfig.h"
#include "LogObject.h"
#include "RolledLogDeleter.h"
-#include "tscpp/util/MemSpan.h"
+#include "swoc/MemSpan.h"
/* Instead of enumerating the stats in DynamicStats.h, each module needs
to enumerate its stats separately and register them with librecords
@@ -136,7 +136,7 @@ public:
void read_configuration_variables();
// CVR This is the mgmt callback function, hence all the strange arguments
- static void reconfigure_mgmt_variables(ts::MemSpan<void>);
+ static void reconfigure_mgmt_variables(swoc::MemSpan<void>);
int
get_max_space_mb() const
diff --git a/proxy/logging/unit-tests/test_LogUtils.h b/proxy/logging/unit-tests/test_LogUtils.h
index 952662d95..d5ad02e68 100644
--- a/proxy/logging/unit-tests/test_LogUtils.h
+++ b/proxy/logging/unit-tests/test_LogUtils.h
@@ -24,7 +24,7 @@
#pragma once
#include <cstring>
-#include <tscpp/util/MemSpan.h>
+#include <swoc/MemSpan.h>
struct MIMEField {
const char *tag, *value;
@@ -46,7 +46,7 @@ struct MIMEField {
class MIMEHdr
{
private:
- ts::MemSpan<MIMEField const> _fields;
+ swoc::MemSpan<MIMEField const> _fields;
public:
MIMEHdr(const MIMEField *first, int count) : _fields{first, size_t(count)} {}
diff --git a/proxy/shared/Makefile.am b/proxy/shared/Makefile.am
index 1d54d408f..2e5d7f45f 100644
--- a/proxy/shared/Makefile.am
+++ b/proxy/shared/Makefile.am
@@ -35,6 +35,7 @@ AM_CPPFLAGS += \
-I$(abs_top_srcdir)/proxy/http \
-I$(abs_top_srcdir)/proxy/hdrs \
-I$(abs_top_srcdir)/proxy/logging \
+ @SWOC_INCLUDES@ \
$(TS_INCLUDES)
libdiagsconfig_a_SOURCES = \
diff --git a/src/records/Makefile.am b/src/records/Makefile.am
index 0fcd449e2..91cd7b5d3 100644
--- a/src/records/Makefile.am
+++ b/src/records/Makefile.am
@@ -21,6 +21,7 @@ include $(top_srcdir)/build/tidy.mk
check_PROGRAMS = test_librecords test_librecords_on_eventsystem
AM_CPPFLAGS += \
+ -I$(abs_top_srcdir)/lib/swoc/include \
-I$(abs_top_srcdir)/iocore/eventsystem \
-I$(abs_top_srcdir)/iocore/utils \
-I$(abs_top_srcdir)/mgmt \
@@ -28,6 +29,7 @@ AM_CPPFLAGS += \
-I$(abs_top_srcdir)/mgmt/utils \
-I$(abs_top_srcdir)/include \
-I$(abs_top_srcdir)/lib \
+ @SWOC_INCLUDES@\
$(TS_INCLUDES)
noinst_LIBRARIES = librecords_p.a
@@ -75,7 +77,7 @@ test_librecords_LDADD = \
$(top_builddir)/src/tscpp/util/libtscpputil.la \
$(top_builddir)/src/tscore/libtscore.la \
$(top_builddir)/proxy/shared/libUglyLogStubs.a \
- @HWLOC_LIBS@ @LIBCAP@
+ @SWOC_LIBS@ @HWLOC_LIBS@ @LIBCAP@
test_librecords_on_eventsystem_CPPFLAGS = $(AM_CPPFLAGS)\
-I$(abs_top_srcdir)/tests/include
diff --git a/src/records/RecMessage.cc b/src/records/RecMessage.cc
index 60ca3e8a7..2c4ec43e6 100644
--- a/src/records/RecMessage.cc
+++ b/src/records/RecMessage.cc
@@ -31,7 +31,7 @@
#include "records/P_RecUtils.h"
#include "records/P_RecCore.h"
#include "tscore/I_Layout.h"
-#include "tscpp/util/MemSpan.h"
+#include "swoc/MemSpan.h"
static RecMessageRecvCb g_recv_cb = nullptr;
static void *g_recv_cookie = nullptr;
diff --git a/src/shared/rpc/IPCSocketClient.cc b/src/shared/rpc/IPCSocketClient.cc
index 7455b8e98..d39cf3a32 100644
--- a/src/shared/rpc/IPCSocketClient.cc
+++ b/src/shared/rpc/IPCSocketClient.cc
@@ -69,7 +69,7 @@ IPCSocketClient::read_all(ts::FixedBufferWriter &bw)
}
ReadStatus readStatus{ReadStatus::UNKNOWN};
while (bw.remaining()) {
- ts::MemSpan<char> span{bw.auxBuffer(), bw.remaining()};
+ swoc::MemSpan<char> span{bw.auxBuffer(), bw.remaining()};
const ssize_t ret = ::read(_sock, span.data(), span.size());
if (ret > 0) {
bw.fill(ret);
@@ -92,4 +92,4 @@ IPCSocketClient::read_all(ts::FixedBufferWriter &bw)
}
return readStatus;
}
-} // namespace shared::rpc
\ No newline at end of file
+} // namespace shared::rpc
diff --git a/src/traffic_cache_tool/CacheDefs.h b/src/traffic_cache_tool/CacheDefs.h
index 648aa5576..0e27a7cfd 100644
--- a/src/traffic_cache_tool/CacheDefs.h
+++ b/src/traffic_cache_tool/CacheDefs.h
@@ -351,7 +351,7 @@ using ts::StripeMeta;
using ts::CacheStripeDescriptor;
using ts::Errata;
using ts::CacheDirEntry;
-using ts::MemSpan;
+using swoc::MemSpan;
using ts::Doc;
constexpr int ESTIMATED_OBJECT_SIZE = 8000;
diff --git a/src/traffic_cache_tool/CacheScan.cc b/src/traffic_cache_tool/CacheScan.cc
index 34cb50c9f..bf05ed5cc 100644
--- a/src/traffic_cache_tool/CacheScan.cc
+++ b/src/traffic_cache_tool/CacheScan.cc
@@ -125,7 +125,7 @@ CacheScan::unmarshal(MIMEFieldBlockImpl *mf, intptr_t offset)
{
Errata zret;
HDR_UNMARSHAL_PTR(mf->m_next, MIMEFieldBlockImpl, offset);
- ts::MemSpan mf_mem(reinterpret_cast<char *>(mf), mf->m_length);
+ swoc::MemSpan mf_mem(reinterpret_cast<char *>(mf), mf->m_length);
for (uint32_t index = 0; index < mf->m_freetop; index++) {
MIMEField *field = &(mf->m_field_slots[index]);
@@ -344,7 +344,7 @@ CacheScan::unmarshal(char *buf, int len, RefCountObj *block_ref)
// check if the url looks valid
bool
-CacheScan::check_url(ts::MemSpan<char> &mem, URLImpl *url)
+CacheScan::check_url(swoc::MemSpan<char> &mem, URLImpl *url)
{
bool in_bound = false; // boolean to check if address in bound
if (!url->m_ptr_scheme) {
@@ -365,7 +365,7 @@ CacheScan::get_alternates(const char *buf, int length, bool search)
char *start = const_cast<char *>(buf);
RefCountObj *block_ref = nullptr;
- ts::MemSpan<char> doc_mem(const_cast<char *>(buf), length);
+ swoc::MemSpan<char> doc_mem(const_cast<char *>(buf), length);
while (length - (buf - start) > static_cast<int>(sizeof(HTTPCacheAlt))) {
HTTPCacheAlt *a = (HTTPCacheAlt *)buf;
diff --git a/src/traffic_cache_tool/CacheScan.h b/src/traffic_cache_tool/CacheScan.h
index c593b7009..6ab716a26 100644
--- a/src/traffic_cache_tool/CacheScan.h
+++ b/src/traffic_cache_tool/CacheScan.h
@@ -58,6 +58,6 @@ public:
Errata unmarshal(URLImpl *obj, intptr_t offset);
Errata unmarshal(MIMEFieldBlockImpl *mf, intptr_t offset);
Errata unmarshal(MIMEHdrImpl *obj, intptr_t offset);
- bool check_url(ts::MemSpan<char> &mem, URLImpl *url);
+ bool check_url(swoc::MemSpan<char> &mem, URLImpl *url);
};
} // namespace ct
diff --git a/src/traffic_cache_tool/CacheTool.cc b/src/traffic_cache_tool/CacheTool.cc
index 85ceced2a..5210ccec1 100644
--- a/src/traffic_cache_tool/CacheTool.cc
+++ b/src/traffic_cache_tool/CacheTool.cc
@@ -54,7 +54,7 @@ using ts::StripeMeta;
using ts::CacheStripeDescriptor;
using ts::Errata;
using ts::CacheDirEntry;
-using ts::MemSpan;
+using swoc::MemSpan;
using ts::Doc;
enum { SILENT = 0, NORMAL, VERBOSE } Verbosity = NORMAL;
diff --git a/src/traffic_cache_tool/Makefile.inc b/src/traffic_cache_tool/Makefile.inc
index 2d972e3b2..68bcb9546 100644
--- a/src/traffic_cache_tool/Makefile.inc
+++ b/src/traffic_cache_tool/Makefile.inc
@@ -23,6 +23,7 @@ traffic_cache_tool_traffic_cache_tool_CPPFLAGS = \
$(AM_CPPFLAGS) \
-I $(abs_top_srcdir)/include \
-I $(abs_top_srcdir)/lib \
+ @SWOC_INCLUDES@ \
-D__STDC_FORMAT_MACROS
traffic_cache_tool_traffic_cache_tool_SOURCES = \
@@ -32,6 +33,8 @@ traffic_cache_tool_traffic_cache_tool_SOURCES = \
traffic_cache_tool/CacheScan.h \
traffic_cache_tool/CacheScan.cc
+traffic_cache_tool_traffic_cache_tool_LDFLAGS = $(AM_LDFLAGS) @SWOC_LDFLAGS@
+
traffic_cache_tool_traffic_cache_tool_LDADD = \
$(top_builddir)/src/tscore/.libs/ArgParser.o \
$(top_builddir)/src/tscore/.libs/ink_assert.o \
@@ -54,4 +57,4 @@ traffic_cache_tool_traffic_cache_tool_LDADD = \
$(top_builddir)/src/tscore/.libs/ink_args.o \
$(top_builddir)/src/tscore/.libs/ParseRules.o \
$(top_builddir)/src/tscore/.libs/SourceLocation.o \
- @OPENSSL_LIBS@ @LIBPCRE@
+ @SWOC_LIBS@ @OPENSSL_LIBS@ @LIBPCRE@
diff --git a/src/traffic_crashlog/Makefile.inc b/src/traffic_crashlog/Makefile.inc
index f0cf492a8..a69054be1 100644
--- a/src/traffic_crashlog/Makefile.inc
+++ b/src/traffic_crashlog/Makefile.inc
@@ -25,6 +25,7 @@ traffic_crashlog_traffic_crashlog_CPPFLAGS = \
-I$(abs_top_srcdir)/mgmt \
-I$(abs_top_srcdir)/mgmt/utils \
-I$(abs_top_srcdir)/mgmt/api/include \
+ @SWOC_INCLUDES@ \
$(TS_INCLUDES)
traffic_crashlog_traffic_crashlog_LDFLAGS = \
diff --git a/src/traffic_ctl/Makefile.inc b/src/traffic_ctl/Makefile.inc
index f177465f5..4cc365e36 100644
--- a/src/traffic_ctl/Makefile.inc
+++ b/src/traffic_ctl/Makefile.inc
@@ -24,7 +24,7 @@ traffic_ctl_traffic_ctl_CPPFLAGS = \
$(TS_INCLUDES) \
-I$(abs_top_srcdir)/mgmt \
-I$(abs_top_srcdir)/include \
- @YAMLCPP_INCLUDES@
+ @SWOC_INCLUDES@ @YAMLCPP_INCLUDES@
traffic_ctl_traffic_ctl_SOURCES = \
traffic_ctl/traffic_ctl.cc \
@@ -34,4 +34,4 @@ traffic_ctl_traffic_ctl_SOURCES = \
traffic_ctl_traffic_ctl_LDADD = \
$(top_builddir)/src/tscore/libtscore.la \
- @HWLOC_LIBS@ @YAMLCPP_LIBS@
+ @HWLOC_LIBS@ @SWOC_LIBS@ @YAMLCPP_LIBS@
diff --git a/src/traffic_layout/Makefile.inc b/src/traffic_layout/Makefile.inc
index bc8952d55..5f636c5b1 100644
--- a/src/traffic_layout/Makefile.inc
+++ b/src/traffic_layout/Makefile.inc
@@ -24,12 +24,13 @@ traffic_layout_traffic_layout_CPPFLAGS = \
-I$(abs_top_srcdir)/lib \
-I$(abs_top_srcdir)/mgmt \
-I$(abs_top_srcdir)/mgmt/utils \
+ @SWOC_INCLUDES@ \
@YAMLCPP_INCLUDES@ \
$(TS_INCLUDES)
traffic_layout_traffic_layout_LDFLAGS = \
$(AM_LDFLAGS) \
- @YAMLCPP_LDFLAGS@ $(BROTLIENC_LIB)
+ @SWOC_LDFLAGS@ @YAMLCPP_LDFLAGS@ $(BROTLIENC_LIB)
traffic_layout_traffic_layout_SOURCES = \
traffic_layout/traffic_layout.cc \
@@ -47,4 +48,4 @@ traffic_layout_traffic_layout_LDADD = \
$(top_builddir)/iocore/eventsystem/libinkevent.a \
$(top_builddir)/src/tscore/libtscore.la \
$(top_builddir)/src/tscpp/util/libtscpputil.la \
- @HWLOC_LIBS@ @YAMLCPP_LIBS@ @LIBLZMA@
+ @SWOC_LIBS@ @HWLOC_LIBS@ @YAMLCPP_LIBS@ @LIBLZMA@
diff --git a/src/traffic_logcat/Makefile.inc b/src/traffic_logcat/Makefile.inc
index 748961cf9..581e28078 100644
--- a/src/traffic_logcat/Makefile.inc
+++ b/src/traffic_logcat/Makefile.inc
@@ -29,7 +29,7 @@ traffic_logcat_traffic_logcat_CPPFLAGS = \
-I$(abs_top_srcdir)/proxy/shared \
-I$(abs_top_srcdir)/mgmt \
-I$(abs_top_srcdir)/mgmt/utils \
- $(TS_INCLUDES)
+ @SWOC_INCLUDES@ $(TS_INCLUDES)
traffic_logcat_traffic_logcat_LDFLAGS = \
$(AM_LDFLAGS) \
@@ -50,6 +50,6 @@ traffic_logcat_traffic_logcat_LDADD = \
$(top_builddir)/src/tscpp/util/libtscpputil.la
traffic_logcat_traffic_logcat_LDADD += \
- @HWLOC_LIBS@ \
+ @SWOC_LIBS@ @HWLOC_LIBS@ \
@YAMLCPP_LIBS@ \
@LIBPROFILER@ -lm
diff --git a/src/traffic_logstats/Makefile.inc b/src/traffic_logstats/Makefile.inc
index 242f7ecc4..1d0c1e981 100644
--- a/src/traffic_logstats/Makefile.inc
+++ b/src/traffic_logstats/Makefile.inc
@@ -29,11 +29,12 @@ traffic_logstats_traffic_logstats_CPPFLAGS = \
-I$(abs_top_srcdir)/proxy/shared \
-I$(abs_top_srcdir)/mgmt \
-I$(abs_top_srcdir)/mgmt/utils \
+ @SWOC_INCLUDES@ \
$(TS_INCLUDES)
traffic_logstats_traffic_logstats_LDFLAGS = \
$(AM_LDFLAGS) \
- @YAMLCPP_LDFLAGS@
+ @SWOC_LDFLAGS@ @YAMLCPP_LDFLAGS@
TESTS += \
traffic_logstats/tests/test_logstats_json \
@@ -54,6 +55,7 @@ traffic_logstats_traffic_logstats_LDADD = \
$(top_builddir)/src/tscpp/util/libtscpputil.la
traffic_logstats_traffic_logstats_LDADD += \
+ @SWOC_LIBS@ \
@HWLOC_LIBS@ \
@YAMLCPP_LIBS@ \
@LIBPROFILER@ -lm
diff --git a/src/traffic_quic/Makefile.inc b/src/traffic_quic/Makefile.inc
index a9be9607f..09145e67d 100644
--- a/src/traffic_quic/Makefile.inc
+++ b/src/traffic_quic/Makefile.inc
@@ -32,11 +32,12 @@ traffic_quic_traffic_quic_CPPFLAGS = \
-I$(abs_top_srcdir)/proxy/http3 \
-I$(abs_top_srcdir)/proxy/logging \
-I$(abs_top_srcdir)/proxy/shared \
- $(TS_INCLUDES) \
+ $(TS_INCLUDES) @SWOC_INCLUDES@ \
@OPENSSL_INCLUDES@ @YAMLCPP_INCLUDES@
traffic_quic_traffic_quic_LDFLAGS = \
$(AM_LDFLAGS) \
+ @SWOC_LIBS@ \
@OPENSSL_LDFLAGS@ \
@BORINGOCSP_LDFLAGS@
@@ -59,6 +60,7 @@ traffic_quic_traffic_quic_LDADD = \
$(top_builddir)/proxy/libproxy.a \
$(top_builddir)/proxy/hdrs/libhdrs.a \
@HWLOC_LIBS@ \
+ @SWOC_LIBS@ \
@YAMLCPP_LIBS@ \
@OPENSSL_LIBS@ \
@BORINGOCSP_LIBS@ \
diff --git a/src/traffic_server/Makefile.inc b/src/traffic_server/Makefile.inc
index 746ae1657..42199a126 100644
--- a/src/traffic_server/Makefile.inc
+++ b/src/traffic_server/Makefile.inc
@@ -34,6 +34,7 @@ traffic_server_traffic_server_CPPFLAGS = \
-I$(abs_top_srcdir)/proxy/shared \
-I$(abs_top_srcdir)/mgmt \
-I$(abs_top_srcdir)/mgmt/utils \
+ @SWOC_INCLUDES@ \
$(TS_INCLUDES) \
@OPENSSL_INCLUDES@ \
@BORINGOCSP_INCLUDES@ \
@@ -41,6 +42,7 @@ traffic_server_traffic_server_CPPFLAGS = \
traffic_server_traffic_server_LDFLAGS = \
$(AM_LDFLAGS) \
+ @SWOC_LDFLAGS@ \
@YAMLCPP_LDFLAGS@ \
@BORINGOCSP_LDFLAGS@
@@ -95,6 +97,7 @@ traffic_server_traffic_server_LDADD = \
@LIBZ@ \
@LIBLZMA@ \
@LIBPROFILER@ \
+ @SWOC_LIBS@ \
@OPENSSL_LIBS@ \
@YAMLCPP_LIBS@ \
@BORINGOCSP_LIBS@ \
diff --git a/src/traffic_top/Makefile.inc b/src/traffic_top/Makefile.inc
index 0f54cd2d4..b9eca9b59 100644
--- a/src/traffic_top/Makefile.inc
+++ b/src/traffic_top/Makefile.inc
@@ -24,6 +24,7 @@ traffic_top_traffic_top_CPPFLAGS = \
$(AM_CPPFLAGS) \
-I$(abs_top_srcdir)/include \
$(TS_INCLUDES) \
+ @SWOC_INCLUDES@ \
@CURL_CFLAGS@ \
@CURSES_CFLAGS@ \
@YAMLCPP_INCLUDES@
@@ -32,7 +33,7 @@ traffic_top_traffic_top_LDFLAGS = \
$(AM_LDFLAGS) \
@CURSES_LDFLAGS@ \
@OPENSSL_LDFLAGS@ \
- @YAMLCPP_LIBS@
+ @SWOC_LIBS@ @YAMLCPP_LIBS@
traffic_top_traffic_top_SOURCES = \
@@ -46,5 +47,5 @@ traffic_top_traffic_top_LDADD = \
@CURL_LIBS@ \
@CURSES_LIBS@ \
@HWLOC_LIBS@ \
- @YAMLCPP_LIBS@
+ @SWOC_LIBS@ @YAMLCPP_LIBS@
endif
diff --git a/src/tscore/BufferWriterFormat.cc b/src/tscore/BufferWriterFormat.cc
index b15faf6d8..9c4eb3a5a 100644
--- a/src/tscore/BufferWriterFormat.cc
+++ b/src/tscore/BufferWriterFormat.cc
@@ -69,6 +69,8 @@ tv_to_positive_decimal(ts::TextView src, ts::TextView *out)
namespace ts
{
+template <typename T> using MemSpan = swoc::MemSpan<T>;
+
const BWFSpec BWFSpec::DEFAULT;
const BWFSpec::Property BWFSpec::_prop;
diff --git a/src/tscore/Makefile.am b/src/tscore/Makefile.am
index e96104f7f..89a1048f6 100644
--- a/src/tscore/Makefile.am
+++ b/src/tscore/Makefile.am
@@ -37,13 +37,14 @@ AM_CPPFLAGS += \
$(iocore_include_dirs) \
-I$(abs_top_srcdir)/include \
-I$(abs_top_srcdir)/lib \
- $(TS_INCLUDES) \
+ $(TS_INCLUDES) @SWOC_INCLUDES@ \
@YAMLCPP_INCLUDES@
-libtscore_la_LDFLAGS = @AM_LDFLAGS@ -no-undefined -version-info @TS_LIBTOOL_VERSION@ @YAMLCPP_LDFLAGS@
+libtscore_la_LDFLAGS = @AM_LDFLAGS@ -no-undefined -version-info @TS_LIBTOOL_VERSION@ @SWOC_LDFLAGS@ @YAMLCPP_LDFLAGS@
libtscore_la_LIBADD = \
$(top_builddir)/src/tscpp/util/libtscpputil.la \
@HWLOC_LIBS@ \
+ @SWOC_LIBS@ \
@LIBOBJS@ \
@LIBPCRE@ \
@OPENSSL_LIBS@ \
diff --git a/src/tscore/MemArena.cc b/src/tscore/MemArena.cc
index 877cb97d5..8927a4424 100644
--- a/src/tscore/MemArena.cc
+++ b/src/tscore/MemArena.cc
@@ -29,6 +29,7 @@
#include "tscore/ink_assert.h"
using namespace ts;
+template <typename T> using MemSpan = swoc::MemSpan<T>;
void
MemArena::Block::operator delete(void *ptr)
diff --git a/src/tscore/unit_tests/test_BufferWriterFormat.cc b/src/tscore/unit_tests/test_BufferWriterFormat.cc
index 76d97080e..26bec8bdd 100644
--- a/src/tscore/unit_tests/test_BufferWriterFormat.cc
+++ b/src/tscore/unit_tests/test_BufferWriterFormat.cc
@@ -28,7 +28,7 @@
#include <netinet/in.h>
#include "tscore/BufferWriter.h"
#include "tscore/bwf_std_format.h"
-#include "tscpp/util/MemSpan.h"
+#include "swoc/MemSpan.h"
#include "tscore/ink_config.h"
#if TS_ENABLE_FIPS == 0
#include "tscore/MD5.h"
@@ -182,22 +182,22 @@ TEST_CASE("BWFormat numerics", "[bwprint][bwformat]")
bw.print("{}", char_ptr);
REQUIRE(bw.view() == "good");
- ts::MemSpan span{ptr, 0x200};
+ swoc::MemSpan span{ptr, 0x200};
bw.reduce(0);
bw.print("{}", span);
REQUIRE(bw.view() == "0x200@0xbadd0956");
bw.reduce(0);
- bw.print("{:x}", ts::MemSpan(char_ptr, 4));
+ bw.print("{:x}", swoc::MemSpan(char_ptr, 4));
REQUIRE(bw.view() == "676f6f64");
bw.reduce(0);
- bw.print("{:#x}", ts::MemSpan(char_ptr, 4));
+ bw.print("{:#x}", swoc::MemSpan(char_ptr, 4));
REQUIRE(bw.view() == "0x676f6f64");
bw.reduce(0);
- bw.print("{:x}", ts::MemSpan<void>(char_ptr, 4));
+ bw.print("{:x}", swoc::MemSpan<void>(char_ptr, 4));
REQUIRE(bw.view() == "676f6f64");
bw.reduce(0);
- bw.print("{:#x}", ts::MemSpan<void>(char_ptr, 4));
+ bw.print("{:#x}", swoc::MemSpan<void>(char_ptr, 4));
REQUIRE(bw.view() == "0x676f6f64");
std::string_view sv{"abc123"};
diff --git a/src/tscore/unit_tests/test_MemArena.cc b/src/tscore/unit_tests/test_MemArena.cc
index 16a6276fb..d704be5bb 100644
--- a/src/tscore/unit_tests/test_MemArena.cc
+++ b/src/tscore/unit_tests/test_MemArena.cc
@@ -25,7 +25,7 @@
#include <string_view>
#include "tscore/MemArena.h"
-using ts::MemSpan;
+using swoc::MemSpan;
using ts::MemArena;
using namespace std::literals;
@@ -129,7 +129,7 @@ TEST_CASE("MemArena helper", "[libts][MemArena]")
ts::MemArena arena{256};
REQUIRE(arena.size() == 0);
- ts::MemSpan<char> s = arena.alloc(56).rebind<char>();
+ swoc::MemSpan<char> s = arena.alloc(56).rebind<char>();
REQUIRE(arena.size() == 56);
void *ptr = s.begin();
@@ -141,8 +141,8 @@ TEST_CASE("MemArena helper", "[libts][MemArena]")
arena.freeze(128);
REQUIRE(arena.contains((char *)ptr));
REQUIRE(arena.contains((char *)ptr + 100));
- ts::MemSpan<char> s2 = arena.alloc(10).rebind<char>();
- void *ptr2 = s2.begin();
+ swoc::MemSpan<char> s2 = arena.alloc(10).rebind<char>();
+ void *ptr2 = s2.begin();
REQUIRE(arena.contains((char *)ptr));
REQUIRE(arena.contains((char *)ptr2));
REQUIRE(arena.allocated_size() == 56 + 10);
@@ -183,10 +183,10 @@ TEST_CASE("MemArena helper", "[libts][MemArena]")
TEST_CASE("MemArena large alloc", "[libts][MemArena]")
{
ts::MemArena arena;
- ts::MemSpan s = arena.alloc(4000);
+ swoc::MemSpan s = arena.alloc(4000);
REQUIRE(s.size() == 4000);
- ts::MemSpan<void> s_a[10];
+ swoc::MemSpan<void> s_a[10];
s_a[0] = arena.alloc(100);
s_a[1] = arena.alloc(200);
s_a[2] = arena.alloc(300);
@@ -210,9 +210,9 @@ TEST_CASE("MemArena large alloc", "[libts][MemArena]")
TEST_CASE("MemArena block allocation", "[libts][MemArena]")
{
ts::MemArena arena{64};
- ts::MemSpan<char> s = arena.alloc(32).rebind<char>();
- ts::MemSpan<char> s2 = arena.alloc(16).rebind<char>();
- ts::MemSpan<char> s3 = arena.alloc(16).rebind<char>();
+ swoc::MemSpan<char> s = arena.alloc(32).rebind<char>();
+ swoc::MemSpan<char> s2 = arena.alloc(16).rebind<char>();
+ swoc::MemSpan<char> s3 = arena.alloc(16).rebind<char>();
REQUIRE(s.size() == 32);
REQUIRE(arena.allocated_size() == 64);
diff --git a/src/tscpp/util/Makefile.am b/src/tscpp/util/Makefile.am
index b7ddf5295..7683843c3 100644
--- a/src/tscpp/util/Makefile.am
+++ b/src/tscpp/util/Makefile.am
@@ -39,7 +39,6 @@ test_tscpputil_LDADD = libtscpputil.la
test_tscpputil_SOURCES = \
unit_tests/unit_test_main.cc \
unit_tests/test_LocalBuffer.cc \
- unit_tests/test_MemSpan.cc \
unit_tests/test_PostScript.cc \
unit_tests/test_Strerror.cc \
unit_tests/test_TextView.cc \
diff --git a/src/tscpp/util/unit_tests/test_MemSpan.cc b/src/tscpp/util/unit_tests/test_MemSpan.cc
deleted file mode 100644
index 7149e689f..000000000
--- a/src/tscpp/util/unit_tests/test_MemSpan.cc
+++ /dev/null
@@ -1,91 +0,0 @@
-/** @file
-
- MemSpan unit tests.
-
- @section license License
-
- Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- agreements. See the NOTICE file distributed with this work for additional information regarding
- copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with the License. You may
- obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software distributed under the
- License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- express or implied. See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-#include <iostream>
-#include "tscpp/util/MemSpan.h"
-#include "catch.hpp"
-
-using ts::MemSpan;
-
-TEST_CASE("MemSpan", "[libswoc][MemSpan]")
-{
- int32_t idx[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
- char buff[1024];
-
- MemSpan<char> span(buff, sizeof(buff));
- MemSpan<char> left = span.prefix(512);
- REQUIRE(left.size() == 512);
- REQUIRE(span.size() == 1024);
- span.remove_prefix(512);
- REQUIRE(span.size() == 512);
- REQUIRE(left.end() == span.begin());
-
- left.assign(buff, sizeof(buff));
- span = left.suffix(768);
- left.remove_suffix(768);
- REQUIRE(left.end() == span.begin());
- REQUIRE(left.size() + span.size() == 1024);
-
- MemSpan<int32_t> idx_span(idx);
- REQUIRE(idx_span.count() == 11);
- REQUIRE(idx_span.size() == sizeof(idx));
- REQUIRE(idx_span.data() == idx);
-
- auto sp2 = idx_span.rebind<int16_t>();
- REQUIRE(sp2.size() == idx_span.size());
- REQUIRE(sp2.count() == 2 * idx_span.count());
- REQUIRE(sp2[0] == 0);
- REQUIRE(sp2[1] == 0);
- // exactly one of { le, be } must be true.
- bool le = sp2[2] == 1 && sp2[3] == 0;
- bool be = sp2[2] == 0 && sp2[3] == 1;
- REQUIRE(le != be);
- auto idx2 = sp2.rebind<int32_t>(); // still the same if converted back to original?
- REQUIRE(idx_span.is_same(idx2));
-
- // Verify attempts to rebind on non-integral sized arrays fails.
- span.assign(buff, 1022);
- REQUIRE(span.size() == 1022);
- REQUIRE(span.count() == 1022);
- auto vs = span.rebind<void>();
- REQUIRE_THROWS_AS(span.rebind<uint32_t>(), std::invalid_argument);
- REQUIRE_THROWS_AS(vs.rebind<uint32_t>(), std::invalid_argument);
-
- // Check for defaulting to a void rebind.
- vs = span.rebind();
- REQUIRE(vs.size() == 1022);
-
- // Check for assignment to void.
- vs = span;
- REQUIRE(vs.size() == 1022);
-
- // Test array constructors.
- MemSpan<char> a{buff};
- REQUIRE(a.size() == sizeof(buff));
- REQUIRE(a.data() == buff);
- float floats[] = {1.1, 2.2, 3.3, 4.4, 5.5};
- MemSpan<float> fspan{floats};
- REQUIRE(fspan.count() == 5);
- REQUIRE(fspan[3] == 4.4f);
- MemSpan<float> f2span{floats, floats + 5};
- REQUIRE(fspan.data() == f2span.data());
- REQUIRE(fspan.count() == f2span.count());
- REQUIRE(fspan.is_same(f2span));
-};
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 135bed0a2..bb6a1f430 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -26,7 +26,7 @@ AM_CPPFLAGS += \
$(iocore_include_dirs) \
-I$(abs_top_srcdir)/include \
-I$(abs_top_srcdir)/include/wccp \
- $(TS_INCLUDES)
+ $(TS_INCLUDES) @SWOC_INCLUDES@
if BUILD_TEST_TOOLS
bin_PROGRAMS = jtest/jtest