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 ce009fb40 libswoc - replace string_view_util with libswoc version. (#9203) ce009fb40 is described below commit ce009fb40fe1507454e83d30b0e7caf4de919c6a Author: Alan M. Carroll <a...@apache.org> AuthorDate: Fri Nov 18 12:39:22 2022 -0600 libswoc - replace string_view_util with libswoc version. (#9203) * libswoc - replace string_view_util with libswoc version. * Possible linking fix. --- include/tscpp/util/Makefile.am | 1 - include/tscpp/util/TextView.h | 2 +- lib/Makefile.am | 3 +- lib/swoc/Makefile.am | 22 +++++++------- lib/swoc/include/swoc/TextView.h | 2 +- .../swoc/include/swoc}/string_view_util.h | 34 +++++++--------------- lib/swoc/src/Errata.cc | 2 +- .../util => lib/swoc/src}/string_view_util.cc | 30 +++++-------------- proxy/http/remap/Makefile.am | 3 ++ proxy/http2/Makefile.am | 8 +++-- src/traffic_cache_tool/Makefile.inc | 1 - src/tscore/Makefile.am | 15 +++++----- src/tscpp/util/Makefile.am | 10 +++---- 13 files changed, 54 insertions(+), 79 deletions(-) diff --git a/include/tscpp/util/Makefile.am b/include/tscpp/util/Makefile.am index a1d18fd19..185f6c5df 100644 --- a/include/tscpp/util/Makefile.am +++ b/include/tscpp/util/Makefile.am @@ -23,6 +23,5 @@ library_include_HEADERS = \ LocalBuffer.h \ PostScript.h \ Strerror.h \ - string_view_util.h \ TextView.h \ TsSharedMutex.h diff --git a/include/tscpp/util/TextView.h b/include/tscpp/util/TextView.h index dae73abee..77ede1928 100644 --- a/include/tscpp/util/TextView.h +++ b/include/tscpp/util/TextView.h @@ -34,7 +34,7 @@ #include <string_view> #include <limits> -#include "tscpp/util/string_view_util.h" +#include "swoc/string_view_util.h" namespace ts { diff --git a/lib/Makefile.am b/lib/Makefile.am index 592ffa9e9..e966b9ff8 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -44,10 +44,9 @@ all-local:: swoc clean-local:: $(MAKE) -C swoc clean -endif -if EXPORT_SWOC_HEADERS install-data-local:: $(MAKE) -C swoc install + endif diff --git a/lib/swoc/Makefile.am b/lib/swoc/Makefile.am index 70442b7ec..b928917f5 100644 --- a/lib/swoc/Makefile.am +++ b/lib/swoc/Makefile.am @@ -16,19 +16,17 @@ # See the License for the specific language governing permissions and # limitations under the License. -include $(top_srcdir)/build/tidy.mk - -noinst_LTLIBRARIES = libtsswoc.la +lib_LTLIBRARIES = libtsswoc.la library_includedir=$(includedir)/swoc -AM_CPPFLAGS += -I$(abs_top_srcdir)/include -I$(abs_top_srcdir)/lib/swoc/include - -libtsswoc_la_LDFLAGS = @AM_LDFLAGS@ -no-undefined -version-info @TS_LIBTOOL_VERSION@ +AM_CPPFLAGS += @SWOC_INCLUDES@ +libtsswoc_la_LDFLAGS = @AM_LDFLAGS@ -no-undefined -release 1.4.0 libtsswoc_la_SOURCES = \ - src/ArenaWriter.cc src/bw_format.cc src/bw_ip_format.cc src/Errata.cc src/MemArena.cc src/RBTree.cc src/swoc_file.cc src/swoc_ip.cc src/TextView.cc + src/ArenaWriter.cc src/bw_format.cc src/bw_ip_format.cc src/Errata.cc src/MemArena.cc src/RBTree.cc src/swoc_file.cc src/swoc_ip.cc src/TextView.cc src/string_view_util.cc +if EXPORT_SWOC_HEADERS library_include_HEADERS = \ include/swoc/ArenaWriter.h \ include/swoc/BufferWriter.h \ @@ -41,22 +39,24 @@ library_include_HEADERS = \ include/swoc/Errata.h \ include/swoc/IntrusiveDList.h \ include/swoc/IntrusiveHashMap.h \ + include/swoc/IPAddr.h \ + include/swoc/IPEndpoint.h \ + include/swoc/IPRange.h \ + include/swoc/IPSrv.h \ include/swoc/Lexicon.h \ include/swoc/MemArena.h \ include/swoc/MemSpan.h \ include/swoc/RBTree.h \ include/swoc/Scalar.h \ include/swoc/swoc_file.h \ - include/swoc/IPEndpoint.h \ - include/swoc/IPAddr.h \ - include/swoc/IPSrv.h \ - include/swoc/IPRange.h \ include/swoc/swoc_ip.h \ include/swoc/swoc_meta.h \ include/swoc/swoc_version.h\ + include/swoc/string_view_util.h \ include/swoc/TextView.h \ include/swoc/Vectray.h \ include/swoc/HashFNV.h +endif clean-local: diff --git a/lib/swoc/include/swoc/TextView.h b/lib/swoc/include/swoc/TextView.h index 4d7dba981..e1537416f 100644 --- a/lib/swoc/include/swoc/TextView.h +++ b/lib/swoc/include/swoc/TextView.h @@ -20,7 +20,7 @@ #include <limits> #include "swoc/swoc_version.h" -#include "tscpp/util/string_view_util.h" +#include "swoc/string_view_util.h" namespace swoc { inline namespace SWOC_VERSION_NS { diff --git a/include/tscpp/util/string_view_util.h b/lib/swoc/include/swoc/string_view_util.h similarity index 68% rename from include/tscpp/util/string_view_util.h rename to lib/swoc/include/swoc/string_view_util.h index 5be1cd4a2..c47712b3f 100644 --- a/include/tscpp/util/string_view_util.h +++ b/lib/swoc/include/swoc/string_view_util.h @@ -1,27 +1,17 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright Apache Software Foundation 2019 /** @file - Utility overloads for @c std::string_view - - @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. - */ + Additional handy utilities for @c string_view and hence also @c TextView. +*/ #pragma once +#include <bitset> +#include <iosfwd> +#include <memory.h> +#include <string> #include <string_view> -#include <string.h> -#include <strings.h> +#include <limits> /** Compare views with ordering, ignoring case. * @@ -70,8 +60,7 @@ int memcmp(const std::string_view &lhs, const std::string_view &rhs); * @see memcmp */ inline int -strcmp(const std::string_view &lhs, const std::string_view &rhs) -{ +strcmp(const std::string_view &lhs, const std::string_view &rhs) { return memcmp(lhs, rhs); } @@ -93,7 +82,6 @@ strcmp(const std::string_view &lhs, const std::string_view &rhs) * */ inline void * -memcpy(void *dst, const std::string_view &src) -{ +memcpy(void *dst, const std::string_view &src) { return memcpy(dst, src.data(), src.size()); } diff --git a/lib/swoc/src/Errata.cc b/lib/swoc/src/Errata.cc index d7fa508b3..403300931 100644 --- a/lib/swoc/src/Errata.cc +++ b/lib/swoc/src/Errata.cc @@ -42,7 +42,7 @@ Errata::Severity Errata::FAILURE_SEVERITY(2); Errata::Severity Errata::FILTER_SEVERITY(0); /// Default set of severity names. -std::array<swoc::TextView, 4> Severity_Names{{"Info", "Warning", "Error"}}; +std::array<swoc::TextView, 3> Severity_Names{{"Info", "Warning", "Error"}}; swoc::MemSpan<TextView const> Errata::SEVERITY_NAMES{Severity_Names.data(), Severity_Names.size()}; diff --git a/src/tscpp/util/string_view_util.cc b/lib/swoc/src/string_view_util.cc similarity index 52% rename from src/tscpp/util/string_view_util.cc rename to lib/swoc/src/string_view_util.cc index 5cc213b5a..3c483ca75 100644 --- a/src/tscpp/util/string_view_util.cc +++ b/lib/swoc/src/string_view_util.cc @@ -1,29 +1,14 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright Apache Software Foundation 2019 /** @file - Utilities for @c std::string_view - - @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. + Additional handy utilities for @c string_view and hence also @c TextView. */ -#include "tscpp/util/string_view_util.h" + +#include "swoc/string_view_util.h" int -memcmp(std::string_view const &lhs, std::string_view const &rhs) -{ +memcmp(std::string_view const &lhs, std::string_view const &rhs) { int zret = 0; size_t n = rhs.size(); @@ -42,8 +27,7 @@ memcmp(std::string_view const &lhs, std::string_view const &rhs) } int -strcasecmp(const std::string_view &lhs, const std::string_view &rhs) -{ +strcasecmp(const std::string_view &lhs, const std::string_view &rhs) { int zret = 0; size_t n = rhs.size(); diff --git a/proxy/http/remap/Makefile.am b/proxy/http/remap/Makefile.am index 31c9accd5..68f494543 100644 --- a/proxy/http/remap/Makefile.am +++ b/proxy/http/remap/Makefile.am @@ -142,6 +142,7 @@ test_NextHopStrategyFactory_LDADD = \ $(top_builddir)/mgmt/libmgmt_p.la \ $(top_builddir)/iocore/utils/libinkutils.a \ $(top_builddir)/src/tscpp/util/libtscpputil.la \ + @SWOC_LIBS@ \ @YAMLCPP_LIBS@ \ @HWLOC_LIBS@ @@ -173,6 +174,7 @@ test_NextHopRoundRobin_LDADD = \ $(top_builddir)/mgmt/libmgmt_p.la \ $(top_builddir)/iocore/utils/libinkutils.a \ $(top_builddir)/src/tscpp/util/libtscpputil.la \ + @SWOC_LIBS@ \ @YAMLCPP_LIBS@ \ @HWLOC_LIBS@ @@ -204,6 +206,7 @@ test_NextHopConsistentHash_LDADD = \ $(top_builddir)/mgmt/libmgmt_p.la \ $(top_builddir)/iocore/utils/libinkutils.a \ $(top_builddir)/src/tscpp/util/libtscpputil.la \ + @SWOC_LIBS@ \ @YAMLCPP_LIBS@ \ @HWLOC_LIBS@ diff --git a/proxy/http2/Makefile.am b/proxy/http2/Makefile.am index 748306479..c0444d010 100644 --- a/proxy/http2/Makefile.am +++ b/proxy/http2/Makefile.am @@ -100,7 +100,8 @@ test_libhttp2_SOURCES = \ test_Http2DependencyTree_LDADD = \ $(top_builddir)/src/tscore/libtscore.la \ - $(top_builddir)/src/tscpp/util/libtscpputil.la + $(top_builddir)/src/tscpp/util/libtscpputil.la \ + @SWOC_LIBS@ test_Http2DependencyTree_CPPFLAGS = $(AM_CPPFLAGS)\ -I$(abs_top_srcdir)/tests/include @@ -112,7 +113,8 @@ test_Http2DependencyTree_SOURCES = \ test_Http2FrequencyCounter_LDADD = \ $(top_builddir)/iocore/eventsystem/libinkevent.a \ $(top_builddir)/src/tscore/libtscore.la \ - $(top_builddir)/src/tscpp/util/libtscpputil.la + $(top_builddir)/src/tscpp/util/libtscpputil.la \ + @SWOC_LIBS@ test_Http2FrequencyCounter_CPPFLAGS = $(AM_CPPFLAGS)\ -I$(abs_top_srcdir)/tests/include @@ -130,7 +132,7 @@ test_HPACK_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@ test_HPACK_SOURCES = \ test_HPACK.cc \ diff --git a/src/traffic_cache_tool/Makefile.inc b/src/traffic_cache_tool/Makefile.inc index 68bcb9546..71dc559e0 100644 --- a/src/traffic_cache_tool/Makefile.inc +++ b/src/traffic_cache_tool/Makefile.inc @@ -48,7 +48,6 @@ traffic_cache_tool_traffic_cache_tool_LDADD = \ $(top_builddir)/src/tscore/.libs/ts_file.o \ $(top_builddir)/src/tscore/.libs/Errata.o \ $(top_builddir)/src/tscpp/util/.libs/TextView.o \ - $(top_builddir)/src/tscpp/util/.libs/string_view_util.o \ $(top_builddir)/src/tscore/.libs/Regex.o \ $(top_builddir)/src/tscore/.libs/CryptoHash.o \ $(top_builddir)/src/tscore/.libs/MMH.o \ diff --git a/src/tscore/Makefile.am b/src/tscore/Makefile.am index 563f87f3a..202a86b76 100644 --- a/src/tscore/Makefile.am +++ b/src/tscore/Makefile.am @@ -35,21 +35,22 @@ lib_LTLIBRARIES = libtscore.la AM_CPPFLAGS += \ $(iocore_include_dirs) \ + @SWOC_INCLUDES@ \ -I$(abs_top_srcdir)/include \ -I$(abs_top_srcdir)/lib \ - $(TS_INCLUDES) @SWOC_INCLUDES@ \ + $(TS_INCLUDES) \ @YAMLCPP_INCLUDES@ 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@ \ @LIBRESOLV@ \ @LIBCAP@ \ + @HWLOC_LIBS@ \ @YAMLCPP_LIBS@ \ -lc @@ -150,23 +151,23 @@ ParseRulesCType: CompileParseRules LSAN_OPTIONS='detect_leaks=0' ./CompileParseRules test_atomic_SOURCES = test_atomic.cc -test_atomic_LDADD = libtscore.la $(top_builddir)/src/tscpp/util/libtscpputil.la @LIBPCRE@ +test_atomic_LDADD = libtscore.la $(top_builddir)/src/tscpp/util/libtscpputil.la @SWOC_LIBSS@ @LIBPCRE@ test_freelist_SOURCES = test_freelist.cc -test_freelist_LDADD = libtscore.la $(top_builddir)/src/tscpp/util/libtscpputil.la @LIBPCRE@ +test_freelist_LDADD = libtscore.la $(top_builddir)/src/tscpp/util/libtscpputil.la @SWOC_LIBS@ @LIBPCRE@ test_geometry_SOURCES = test_geometry.cc -test_geometry_LDADD = libtscore.la $(top_builddir)/src/tscpp/util/libtscpputil.la @LIBPCRE@ +test_geometry_LDADD = libtscore.la $(top_builddir)/src/tscpp/util/libtscpputil.la @SWOC_LIBS@ @LIBPCRE@ -lstdc++ test_X509HostnameValidator_CPPFLAGS = $(AM_CPPFLAGS) -I$(abs_top_srcdir)/tests/include -test_X509HostnameValidator_LDADD = libtscore.la $(top_builddir)/src/tscpp/util/libtscpputil.la @LIBPCRE@ @OPENSSL_LIBS@ +test_X509HostnameValidator_LDADD = libtscore.la $(top_builddir)/src/tscpp/util/libtscpputil.la @SWOC_LIBS@ @LIBPCRE@ @OPENSSL_LIBS@ test_X509HostnameValidator_SOURCES = unit_tests/test_X509HostnameValidator.cc test_tscore_CPPFLAGS = $(AM_CPPFLAGS)\ -I$(abs_top_srcdir)/tests/include test_tscore_CXXFLAGS = -Wno-array-bounds $(AM_CXXFLAGS) -test_tscore_LDADD = libtscore.la $(top_builddir)/src/tscpp/util/libtscpputil.la $(top_builddir)/iocore/eventsystem/libinkevent.a @OPENSSL_LIBS@ +test_tscore_LDADD = libtscore.la $(top_builddir)/src/tscpp/util/libtscpputil.la $(top_builddir)/iocore/eventsystem/libinkevent.a @SWOC_LIBS@ @OPENSSL_LIBS@ test_tscore_SOURCES = \ unit_tests/unit_test_main.cc \ unit_tests/test_AcidPtr.cc \ diff --git a/src/tscpp/util/Makefile.am b/src/tscpp/util/Makefile.am index 7683843c3..5e9aa2e34 100644 --- a/src/tscpp/util/Makefile.am +++ b/src/tscpp/util/Makefile.am @@ -24,18 +24,18 @@ TESTS = $(check_PROGRAMS) lib_LTLIBRARIES = libtscpputil.la -AM_CPPFLAGS += -I$(abs_top_srcdir)/include +AM_CPPFLAGS += -I$(abs_top_srcdir)/include @SWOC_INCLUDES@ -libtscpputil_la_LDFLAGS = @AM_LDFLAGS@ -no-undefined -version-info @TS_LIBTOOL_VERSION@ +libtscpputil_la_LDFLAGS = @AM_LDFLAGS@ -no-undefined -version-info @TS_LIBTOOL_VERSION@ @SWOC_LDFLAGS@ libtscpputil_la_SOURCES = \ - TextView.cc string_view_util.cc + TextView.cc test_tscpputil_CPPFLAGS = $(AM_CPPFLAGS)\ - -I$(abs_top_srcdir)/tests/include + -I$(abs_top_srcdir)/tests/include @SWOC_INCLUDES@ test_tscpputil_CXXFLAGS = -Wno-array-bounds $(AM_CXXFLAGS) -test_tscpputil_LDADD = libtscpputil.la +test_tscpputil_LDADD = libtscpputil.la @SWOC_LIBS@ test_tscpputil_SOURCES = \ unit_tests/unit_test_main.cc \ unit_tests/test_LocalBuffer.cc \