Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion include/tscore/BufferWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,6 @@ namespace bw_fmt
/// Global named argument table.
using GlobalSignature = void (*)(BufferWriter &, BWFSpec const &);
using GlobalTable = std::map<std::string_view, GlobalSignature>;
extern GlobalTable BWF_GLOBAL_TABLE;
extern GlobalSignature Global_Table_Find(std::string_view name);

/// Generic integral conversion.
Expand Down
28 changes: 2 additions & 26 deletions include/tscore/Extendible.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,7 @@ namespace details // internal stuff

//////////////////////////////////////////

bool &
areFieldsFinalized()
{
static bool finalized = false;
return finalized;
}
bool &areFieldsFinalized();

/////////////////////////////////////////////////////////////////////
/// ext::details::FieldDesc - type erased field descriptor, with type specific std::functions
Expand Down Expand Up @@ -729,7 +724,7 @@ viewFormat(T const &t, uintptr_t _base_addr = 0, int _full_size = ext::sizeOf<T>

namespace details
{
std::string
inline std::string
ltrim(std::string const &str, const std::string &chars = "\t\n\v\f\r ")
{
std::string r(str);
Expand Down Expand Up @@ -779,22 +774,3 @@ toString(T const &t)
return ss.str();
}
} // namespace ext

// C API
//

FieldPtr
ExtFieldPtr(DerivedPtr derived, ExtFieldContext field_context, int *size /*= nullptr*/)
{
using namespace ext;
using namespace ext::details;
ink_assert(field_context);
ink_assert(derived);
FieldDesc const &desc = *static_cast<FieldDesc const *>(field_context);
if (size) {
*size = desc.size;
}

Offest_t const *loc = (Offest_t const *)(uintptr_t(derived) + desc.ext_loc_offset);
return FieldPtr(uintptr_t(derived) + (*loc) + desc.field_offset);
}
3 changes: 1 addition & 2 deletions iocore/aio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#######################


add_library(aio)
add_library(aio STATIC)
target_sources(aio PRIVATE AIO.cc Inline.cc)
target_include_directories(aio PRIVATE ${CMAKE_SOURCE_DIR}/iocore/eventsystem ${CMAKE_SOURCE_DIR}/iocore/io_uring)

2 changes: 1 addition & 1 deletion iocore/cache/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ test_CPPFLAGS = \
@OPENSSL_INCLUDES@

test_LDADD = \
$(top_builddir)/src/tscpp/util/libtscpputil.la \
$(top_builddir)/iocore/cache/libinkcache.a \
$(top_builddir)/proxy/libproxy.a \
$(top_builddir)/proxy/http/libhttp.a \
$(top_builddir)/proxy/http/remap/libhttp_remap.a \
$(top_builddir)/src/tscpp/util/libtscpputil.la \
$(top_builddir)/proxy/libproxy.a \
$(top_builddir)/iocore/net/libinknet.a \
$(top_builddir)/iocore/dns/libinkdns.a \
Expand Down
67 changes: 0 additions & 67 deletions iocore/cache/test/stub.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,73 +107,6 @@ ConfigUpdateCbTable *global_config_cbs = nullptr;

HttpBodyFactory *body_factory = nullptr;

intmax_t
ts::svtoi(TextView src, TextView *out, int base)
{
intmax_t zret = 0;

if (out) {
out->clear();
}
if (!(0 <= base && base <= 36)) {
return 0;
}
if (src.ltrim_if(&isspace) && src) {
const char *start = src.data();
int8_t v;
bool neg = false;
if ('-' == *src) {
++src;
neg = true;
}
// If base is 0, it wasn't specified - check for standard base prefixes
if (0 == base) {
base = 10;
if ('0' == *src) {
++src;
base = 8;
if (src && ('x' == *src || 'X' == *src)) {
++src;
base = 16;
}
}
}

// For performance in common cases, use the templated conversion.
switch (base) {
case 8:
zret = svto_radix<8>(src);
break;
case 10:
zret = svto_radix<10>(src);
break;
case 16:
zret = svto_radix<16>(src);
break;
default:
while (src.size() && (0 <= (v = svtoi_convert[static_cast<unsigned char>(*src)])) && v < base) {
auto n = zret * base + v;
if (n < zret) {
zret = std::numeric_limits<uintmax_t>::max();
break; // overflow, stop parsing.
}
zret = n;
++src;
}
break;
}

if (out && (src.data() > (neg ? start + 1 : start))) {
out->assign(start, src.data());
}

if (neg) {
zret = -zret;
}
}
return zret;
}

void
HostStatus::setHostStatus(const std::string_view name, const TSHostStatus status, const unsigned int down_time,
const unsigned int reason)
Expand Down
3 changes: 0 additions & 3 deletions iocore/net/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,6 @@ target_include_directories(inknet PUBLIC
${OPENSSL_INCLUDE_DIRS}
${YAML_INCLUDE_DIRS}
)
if(TS_USE_POSIX_CAP)
target_link_libraries(inknet PUBLIC cap::cap)
endif()

# Fails to link because of circular dep with proxy (ParentSelection)
# add_executable(test_net unit_tests/test_ProxyProtocol.cc)
Expand Down
13 changes: 2 additions & 11 deletions src/records/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#
#######################

add_library(records_p SHARED
add_library(records_p STATIC
P_RecCore.cc
RecConfigParse.cc
RecCore.cc
Expand All @@ -42,13 +42,4 @@ target_include_directories(records_p
"${CMAKE_SOURCE_DIR}/iocore/utils"
)

target_link_libraries(records_p
PUBLIC
libswoc
#ts::inkevent cyclic dependency; I_RecProcess.h and P_RecProcess.h
ts::tscore
ts::tscpputil
yaml-cpp::yaml-cpp
)

install(TARGETS records_p)
target_link_libraries(records_p PUBLIC ts::tscore)
2 changes: 1 addition & 1 deletion src/traffic_server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ target_include_directories(traffic_server PRIVATE
)
target_link_libraries(traffic_server
PRIVATE
tscore
http
http_remap
http2
Expand All @@ -49,7 +50,6 @@ target_link_libraries(traffic_server
inkcache
fastlz
aio
tscore
tscpputil
proxy
inknet
Expand Down
26 changes: 17 additions & 9 deletions src/tscore/BufferWriterFormat.cc
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,13 @@ BWFSpec::BWFSpec(TextView fmt) : _name(fmt.take_prefix_at(':'))

namespace bw_fmt
{
GlobalTable BWF_GLOBAL_TABLE;
GlobalTable &
bwf_global_table()
{
static GlobalTable BWF_GLOBAL_TABLE;

return BWF_GLOBAL_TABLE;
}

void
Err_Bad_Arg_Index(BufferWriter &w, int i, size_t n)
Expand Down Expand Up @@ -726,8 +732,9 @@ bw_fmt::GlobalSignature
bw_fmt::Global_Table_Find(std::string_view name)
{
if (name.size()) {
auto spot = bw_fmt::BWF_GLOBAL_TABLE.find(name);
if (spot != bw_fmt::BWF_GLOBAL_TABLE.end()) {
auto &global_table = bw_fmt::bwf_global_table();
auto spot = global_table.find(name);
if (spot != global_table.end()) {
return spot->second;
}
}
Expand All @@ -749,7 +756,7 @@ FixedBufferWriter::operator>>(int fd) const
bool
bwf_register_global(std::string_view name, BWGlobalNameSignature formatter)
{
return ts::bw_fmt::BWF_GLOBAL_TABLE.emplace(name, formatter).second;
return ts::bw_fmt::bwf_global_table().emplace(name, formatter).second;
}

BufferWriter &
Expand Down Expand Up @@ -980,11 +987,12 @@ BWF_ThreadName(ts::BufferWriter &w, ts::BWFSpec const &spec)
}

static bool BW_INITIALIZED __attribute__((unused)) = []() -> bool {
ts::bw_fmt::BWF_GLOBAL_TABLE.emplace("now", &BWF_Now);
ts::bw_fmt::BWF_GLOBAL_TABLE.emplace("tick", &BWF_Tick);
ts::bw_fmt::BWF_GLOBAL_TABLE.emplace("timestamp", &BWF_Timestamp);
ts::bw_fmt::BWF_GLOBAL_TABLE.emplace("thread-id", &BWF_ThreadID);
ts::bw_fmt::BWF_GLOBAL_TABLE.emplace("thread-name", &BWF_ThreadName);
auto &global_table = ts::bw_fmt::bwf_global_table();
global_table.emplace("now", &BWF_Now);
global_table.emplace("tick", &BWF_Tick);
global_table.emplace("timestamp", &BWF_Timestamp);
global_table.emplace("thread-id", &BWF_ThreadID);
global_table.emplace("thread-name", &BWF_ThreadName);
return true;
}();

Expand Down
30 changes: 11 additions & 19 deletions src/tscore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ add_custom_command(

add_custom_target(ParseRules ALL DEPENDS ParseRulesCType ParseRulesCTypeToUpper ParseRulesCTypeToLower)

add_library(tscore SHARED
add_library(tscore STATIC
AcidPtr.cc
AcidPtr.cc
Arena.cc
Expand Down Expand Up @@ -111,30 +111,18 @@ else()
target_sources(tscore PRIVATE HKDF_openssl.cc)
endif()

if(TS_USE_POSIX_CAP)
target_link_libraries(tscore PUBLIC cap::cap)
endif()

add_dependencies(tscore ParseRules tscpputil)
target_include_directories(tscore PRIVATE
${CMAKE_CURRENT_BINARY_DIR}
${YAML_INCLUDE_DIRS}
)
target_link_libraries(tscore
PUBLIC
libswoc
${OPENSSL_LIBRARIES}
${PCRE_LIBRARIES}
resolv
tscpputil
PRIVATE
yaml-cpp::yaml-cpp
)
if(TS_USE_HWLOC)
target_link_libraries(tscore PUBLIC hwloc::hwloc)
endif()
if(TS_HAS_128BIT_CAS AND TS_NEEDS_MCX16_FOR_CAS)
target_compile_options(tscore PUBLIC "-mcx16")
endif()
if(TS_USE_POSIX_CAP)
target_link_libraries(tscore PUBLIC cap::cap)
endif()

add_executable(test_tscore
unit_tests/test_AcidPtr.cc
Expand Down Expand Up @@ -172,12 +160,16 @@ target_link_libraries(test_tscore
PRIVATE
libswoc
tscore
yaml-cpp::yaml-cpp
libswoc
${OPENSSL_LIBRARIES}
${PCRE_LIBRARIES}
resolv
tscpputil
)
if(TS_USE_HWLOC)
target_link_libraries(test_tscore PRIVATE hwloc::hwloc)
endif()
target_include_directories(test_tscore PRIVATE ${CMAKE_SOURCE_DIR}/include ${CATCH_INCLUDE_DIR})

add_test(NAME test_tscore COMMAND $<TARGET_FILE:test_tscore>)

install(TARGETS tscore)
25 changes: 25 additions & 0 deletions src/tscore/Extendible.cc
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,31 @@ namespace details
{
return cnt_constructed == cnt_destructed;
}

bool &
areFieldsFinalized()
{
static bool finalized = false;
return finalized;
}
} // namespace details

} // namespace ext
// C API
//

FieldPtr
ExtFieldPtr(DerivedPtr derived, ExtFieldContext field_context, int *size /*= nullptr*/)
{
using namespace ext;
using namespace ext::details;
ink_assert(field_context);
ink_assert(derived);
FieldDesc const &desc = *static_cast<FieldDesc const *>(field_context);
if (size) {
*size = desc.size;
}

Offest_t const *loc = (Offest_t const *)(uintptr_t(derived) + desc.ext_loc_offset);
return FieldPtr(uintptr_t(derived) + (*loc) + desc.field_offset);
}
3 changes: 1 addition & 2 deletions src/tscore/ink_mutex.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,11 @@ class x_pthread_mutexattr_t
pthread_mutexattr_t attr;
};

static x_pthread_mutexattr_t attr;

void
ink_mutex_init(ink_mutex *m)
{
int error;
static x_pthread_mutexattr_t attr;

error = pthread_mutex_init(m, &attr.attr);
if (unlikely(error != 0)) {
Expand Down
10 changes: 5 additions & 5 deletions src/tscpp/api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#
#######################

add_library(tscppapi STATIC
add_library(tscppapi SHARED
AsyncHttpFetch.cc
AsyncTimer.cc
CaseInsensitiveStringComparator.cc
Expand All @@ -42,8 +42,8 @@ add_library(tscppapi STATIC
utils_internal.cc
)
add_library(ts::tscppapi ALIAS tscppapi)

# server_push_preload plugin links directly to tscppapi
set_target_properties(tscppapi PROPERTIES POSITION_INDEPENDENT_CODE TRUE)

target_link_libraries(tscppapi
PUBLIC
libswoc
yaml-cpp::yaml-cpp)
install(TARGETS tscppapi)
Loading