upd: LIBIMP_ => LIBIMP

This commit is contained in:
mutouyun 2022-11-27 16:41:52 +08:00
parent f00ff5539d
commit 44fe8ce8da
24 changed files with 50 additions and 49 deletions

View File

@ -88,7 +88,7 @@ struct producer<trans::unicast, relation::single> {
template <typename T, typename C, typename U, template <typename T, typename C, typename U,
typename = is_context<C>, typename = is_context<C>,
typename = is_convertible<C, context_impl>> typename = is_convertible<C, context_impl>>
static bool enqueue(::LIBIMP_::span<element<T>> elems, C &ctx, U &&src) noexcept { static bool enqueue(::LIBIMP::span<element<T>> elems, C &ctx, U &&src) noexcept {
auto w_idx = ctx.w_idx; auto w_idx = ctx.w_idx;
auto w_cur = trunc_index(ctx, w_idx); auto w_cur = trunc_index(ctx, w_idx);
auto &elem = elems[w_cur]; auto &elem = elems[w_cur];
@ -119,7 +119,7 @@ struct producer<trans::unicast, relation::multi> {
template <typename T, typename C, typename U, template <typename T, typename C, typename U,
typename = is_context<C>, typename = is_context<C>,
typename = is_convertible<C, context_impl>> typename = is_convertible<C, context_impl>>
static bool enqueue(::LIBIMP_::span<element<T>> elems, C &ctx, U &&src) noexcept { static bool enqueue(::LIBIMP::span<element<T>> elems, C &ctx, U &&src) noexcept {
auto w_idx = ctx.w_idx.load(std::memory_order_acquire); auto w_idx = ctx.w_idx.load(std::memory_order_acquire);
for (;;) { for (;;) {
auto w_cur = trunc_index(ctx, w_idx); auto w_cur = trunc_index(ctx, w_idx);
@ -154,7 +154,7 @@ struct consumer<trans::unicast, relation::single> {
template <typename T, typename C, typename U, template <typename T, typename C, typename U,
typename = is_context<C>, typename = is_context<C>,
typename = is_convertible<C, context_impl>> typename = is_convertible<C, context_impl>>
static bool dequeue(::LIBIMP_::span<element<T>> elems, C &ctx, U &des) noexcept { static bool dequeue(::LIBIMP::span<element<T>> elems, C &ctx, U &des) noexcept {
auto r_idx = ctx.r_idx; auto r_idx = ctx.r_idx;
auto r_cur = trunc_index(ctx, r_idx); auto r_cur = trunc_index(ctx, r_idx);
auto &elem = elems[r_cur]; auto &elem = elems[r_cur];
@ -184,7 +184,7 @@ struct consumer<trans::unicast, relation::multi> {
template <typename T, typename C, typename U, template <typename T, typename C, typename U,
typename = is_context<C>, typename = is_context<C>,
typename = is_convertible<C, context_impl>> typename = is_convertible<C, context_impl>>
static bool dequeue(::LIBIMP_::span<element<T>> elems, C &ctx, U &des) noexcept { static bool dequeue(::LIBIMP::span<element<T>> elems, C &ctx, U &des) noexcept {
auto r_idx = ctx.r_idx.load(std::memory_order_acquire); auto r_idx = ctx.r_idx.load(std::memory_order_acquire);
for (;;) { for (;;) {
auto r_cur = trunc_index(ctx, r_idx); auto r_cur = trunc_index(ctx, r_idx);
@ -250,7 +250,7 @@ struct prod_cons : producer<TransModT, ProdModT>
: circ_size(cs) {} : circ_size(cs) {}
template <typename T> template <typename T>
constexpr context(::LIBIMP_::span<element<T>> elems) noexcept constexpr context(::LIBIMP::span<element<T>> elems) noexcept
: circ_size(static_cast<index_t>(elems.size())) {} : circ_size(static_cast<index_t>(elems.size())) {}
constexpr bool valid() const noexcept { constexpr bool valid() const noexcept {

View File

@ -11,8 +11,8 @@
#include "libimp/detect_plat.h" #include "libimp/detect_plat.h"
#define LIBCONCUR_ concur #define LIBCONCUR concur
#define LIBCONCUR_NAMESPACE_BEG_ namespace LIBCONCUR_ { #define LIBCONCUR_NAMESPACE_BEG_ namespace LIBCONCUR {
#define LIBCONCUR_NAMESPACE_END_ } #define LIBCONCUR_NAMESPACE_END_ }
LIBCONCUR_NAMESPACE_BEG_ LIBCONCUR_NAMESPACE_BEG_

View File

@ -158,12 +158,12 @@ U *byte_cast(byte const *p) noexcept {
LIBIMP_NAMESPACE_END_ LIBIMP_NAMESPACE_END_
template <> template <>
struct fmt::formatter<::LIBIMP_::byte> { struct fmt::formatter<::LIBIMP::byte> {
constexpr auto parse(format_parse_context& ctx) const { constexpr auto parse(format_parse_context& ctx) const {
return ctx.end(); return ctx.end();
} }
template <typename FormatContext> template <typename FormatContext>
auto format(::LIBIMP_::byte b, FormatContext &ctx) { auto format(::LIBIMP::byte b, FormatContext &ctx) {
return format_to(ctx.out(), "{:#04x}", static_cast<std::uint8_t>(b)); return format_to(ctx.out(), "{:#04x}", static_cast<std::uint8_t>(b));
} }
}; };

View File

@ -9,8 +9,8 @@
#include <cstddef> #include <cstddef>
#include <cstdint> #include <cstdint>
#define LIBIMP_ imp #define LIBIMP imp
#define LIBIMP_NAMESPACE_BEG_ namespace LIBIMP_ { #define LIBIMP_NAMESPACE_BEG_ namespace LIBIMP {
#define LIBIMP_NAMESPACE_END_ } #define LIBIMP_NAMESPACE_END_ }
LIBIMP_NAMESPACE_BEG_ LIBIMP_NAMESPACE_BEG_

View File

@ -1,7 +1,7 @@
/** /**
* @file libimp/generic.h * @file libimp/generic.h
* @author mutouyun (orz@orzz.org) * @author mutouyun (orz@orzz.org)
* @brief Tools for generic programming * @brief Tools for generic programming.
* @date 2022-03-01 * @date 2022-03-01
*/ */
#pragma once #pragma once

View File

@ -1,7 +1,7 @@
/** /**
* @file libimp/log.h * @file libimp/log.h
* @author mutouyun (orz@orzz.org) * @author mutouyun (orz@orzz.org)
* @brief Simple log output component * @brief Simple log output component.
* @date 2022-05-22 * @date 2022-05-22
*/ */
#pragma once #pragma once
@ -198,4 +198,4 @@ public:
} // namespace log } // namespace log
LIBIMP_NAMESPACE_END_ LIBIMP_NAMESPACE_END_
#define LIBIMP_LOG_(...) ::LIBIMP_::log::grip log {__func__, __VA_ARGS__} #define LIBIMP_LOG_(...) ::LIBIMP::log::grip log {__func__, __VA_ARGS__}

View File

@ -160,22 +160,22 @@ public:
LIBIMP_NAMESPACE_END_ LIBIMP_NAMESPACE_END_
template <typename T, typename D> template <typename T, typename D>
struct fmt::formatter<::LIBIMP_::result<T, D>> { struct fmt::formatter<::LIBIMP::result<T, D>> {
constexpr auto parse(format_parse_context& ctx) const { constexpr auto parse(format_parse_context& ctx) const {
return ctx.end(); return ctx.end();
} }
template <typename FormatContext> template <typename FormatContext>
auto format(::LIBIMP_::result<T, D> r, FormatContext &ctx) { auto format(::LIBIMP::result<T, D> r, FormatContext &ctx) {
return format_to(::LIBIMP_::result<T, D>::default_traits_t::format(r, return format_to(::LIBIMP::result<T, D>::default_traits_t::format(r,
format_to(ctx.out(), "[{}, value = ", r ? "succ" : "fail")), "]"); format_to(ctx.out(), "[{}, value = ", r ? "succ" : "fail")), "]");
} }
}; };
template <> template <>
struct fmt::formatter<::LIBIMP_::result_code> struct fmt::formatter<::LIBIMP::result_code>
: formatter<::LIBIMP_::result<::LIBIMP_::result_type>> { : formatter<::LIBIMP::result<::LIBIMP::result_type>> {
template <typename FormatContext> template <typename FormatContext>
auto format(::LIBIMP_::result_code r, FormatContext &ctx) { auto format(::LIBIMP::result_code r, FormatContext &ctx) {
return format_to(ctx.out(), "[{}, value = {}]", (r ? "succ" : "fail"), *r); return format_to(ctx.out(), "[{}, value = {}]", (r ? "succ" : "fail"), *r);
} }
}; };

View File

@ -281,12 +281,12 @@ inline auto make_span(std::string const &str) noexcept -> span<char const> {
LIBIMP_NAMESPACE_END_ LIBIMP_NAMESPACE_END_
template <typename T> template <typename T>
struct fmt::formatter<::LIBIMP_::span<T>> { struct fmt::formatter<::LIBIMP::span<T>> {
constexpr auto parse(format_parse_context& ctx) const { constexpr auto parse(format_parse_context& ctx) const {
return ctx.end(); return ctx.end();
} }
template <typename FormatContext> template <typename FormatContext>
auto format(::LIBIMP_::span<T> s, FormatContext &ctx) { auto format(::LIBIMP::span<T> s, FormatContext &ctx) {
if (s.empty()) { if (s.empty()) {
return format_to(ctx.out(), ""); return format_to(ctx.out(), "");
} }

View File

@ -67,10 +67,10 @@ LIBIMP_EXPORT result<std::int64_t> conf(info) noexcept;
LIBIMP_NAMESPACE_END_ LIBIMP_NAMESPACE_END_
template <> template <>
struct fmt::formatter<::LIBIMP_::sys::error> struct fmt::formatter<::LIBIMP::sys::error>
: formatter<std::string> { : formatter<std::string> {
template <typename FormatContext> template <typename FormatContext>
auto format(::LIBIMP_::sys::error r, FormatContext &ctx) { auto format(::LIBIMP::sys::error r, FormatContext &ctx) {
return format_to(ctx.out(), ::LIBIMP_::sys::error_msg(r.code())); return format_to(ctx.out(), ::LIBIMP::sys::error_msg(r.code()));
} }
}; };

View File

@ -9,8 +9,8 @@
#include <cstddef> #include <cstddef>
#include <cstdint> #include <cstdint>
#define LIBIPC_ ipc #define LIBIPC ipc
#define LIBIPC_NAMESPACE_BEG_ namespace LIBIPC_ { #define LIBIPC_NAMESPACE_BEG_ namespace LIBIPC {
#define LIBIPC_NAMESPACE_END_ } #define LIBIPC_NAMESPACE_END_ }
LIBIPC_NAMESPACE_BEG_ LIBIPC_NAMESPACE_BEG_

View File

@ -20,12 +20,12 @@ struct shm_handle;
using shm_t = shm_handle *; using shm_t = shm_handle *;
/// @brief Create a new shared memory handle with a name of the shared memory file. /// @brief Create a new shared memory handle with a name of the shared memory file.
LIBIMP_EXPORT ::LIBIMP_::result<shm_t> shm_open(std::string name, LIBIMP_EXPORT ::LIBIMP::result<shm_t> shm_open(std::string name,
std::size_t size = 0, std::size_t size = 0,
mode::type = mode::create | mode::open) noexcept; mode::type = mode::create | mode::open) noexcept;
/// @brief Close the shared memory handle. /// @brief Close the shared memory handle.
LIBIMP_EXPORT ::LIBIMP_::result_code shm_close(shm_t) noexcept; LIBIMP_EXPORT ::LIBIMP::result_code shm_close(shm_t) noexcept;
/// @brief Gets a memory pointer based on the shared memory handle. /// @brief Gets a memory pointer based on the shared memory handle.
/// @return nullptr on failure. /// @return nullptr on failure.
@ -37,7 +37,7 @@ LIBIMP_EXPORT std::size_t shm_size(shm_t) noexcept;
/// @brief Sets the memory size based on the shared memory handle. /// @brief Sets the memory size based on the shared memory handle.
/// @remark [TBD] /// @remark [TBD]
LIBIMP_EXPORT ::LIBIMP_::result_code shm_size(shm_t, std::size_t) noexcept; LIBIMP_EXPORT ::LIBIMP::result_code shm_size(shm_t, std::size_t) noexcept;
/// @brief Gets the name of the shared memory file based on the shared memory handle. /// @brief Gets the name of the shared memory file based on the shared memory handle.
/// @return empty string on failure. /// @return empty string on failure.

View File

@ -85,7 +85,7 @@ class LIBIMP_EXPORT allocator {
}; };
using void_holder_type = holder_memory_resource<void>; using void_holder_type = holder_memory_resource<void>;
alignas(void_holder_type) std::array<::LIBIMP_::byte, sizeof(void_holder_type)> holder_; alignas(void_holder_type) std::array<::LIBIMP::byte, sizeof(void_holder_type)> holder_;
holder_base & get_holder() noexcept; holder_base & get_holder() noexcept;
holder_base const &get_holder() const noexcept; holder_base const &get_holder() const noexcept;
@ -105,7 +105,7 @@ public:
template <typename T, typename = is_memory_resource<T>> template <typename T, typename = is_memory_resource<T>>
allocator(T *p_mr) : allocator() { allocator(T *p_mr) : allocator() {
if (p_mr == nullptr) return; if (p_mr == nullptr) return;
::LIBIMP_::construct<holder_memory_resource<T>>(holder_.data(), p_mr); ::LIBIMP::construct<holder_memory_resource<T>>(holder_.data(), p_mr);
} }
void swap(allocator &other) noexcept; void swap(allocator &other) noexcept;

View File

@ -6,8 +6,8 @@
*/ */
#pragma once #pragma once
#define LIBPMR_ pmr #define LIBPMR pmr
#define LIBPMR_NAMESPACE_BEG_ namespace LIBPMR_ { #define LIBPMR_NAMESPACE_BEG_ namespace LIBPMR {
#define LIBPMR_NAMESPACE_END_ } #define LIBPMR_NAMESPACE_END_ }
LIBPMR_NAMESPACE_BEG_ LIBPMR_NAMESPACE_BEG_

View File

@ -1,10 +1,10 @@
#include "libimp/codecvt.h"
#include <algorithm> #include <algorithm>
#include <type_traits> #include <type_traits>
#include <cstring> #include <cstring>
#include <cstdint> #include <cstdint>
#include "libimp/codecvt.h"
#include "libimp/log.h" #include "libimp/log.h"
#include "libimp/detect_plat.h" #include "libimp/detect_plat.h"

View File

@ -1,11 +1,10 @@
#include "libimp/log.h"
#include <utility> #include <utility>
#include <cstdio> #include <cstdio>
#include "fmt/chrono.h" #include "fmt/chrono.h"
#include "libimp/log.h"
LIBIMP_NAMESPACE_BEG_ LIBIMP_NAMESPACE_BEG_
namespace log { namespace log {

View File

@ -23,7 +23,7 @@
#include "def.h" #include "def.h"
LIBIPC_NAMESPACE_BEG_ LIBIPC_NAMESPACE_BEG_
using namespace ::LIBIMP_; using namespace ::LIBIMP;
struct shm_handle { struct shm_handle {
std::string file; std::string file;

View File

@ -27,7 +27,7 @@ inline LPSECURITY_ATTRIBUTES get_sa() {
bool succ_ = false; bool succ_ = false;
initiator() { initiator() {
using namespace ::LIBIMP_; using namespace ::LIBIMP;
log::grip log {"get_sa"}; log::grip log {"get_sa"};
if (!::InitializeSecurityDescriptor(&sd_, SECURITY_DESCRIPTOR_REVISION)) { if (!::InitializeSecurityDescriptor(&sd_, SECURITY_DESCRIPTOR_REVISION)) {
log.error("failed: InitializeSecurityDescriptor(SECURITY_DESCRIPTOR_REVISION). error = {}", sys::error()); log.error("failed: InitializeSecurityDescriptor(SECURITY_DESCRIPTOR_REVISION). error = {}", sys::error());

View File

@ -18,7 +18,7 @@
#include "to_tchar.h" #include "to_tchar.h"
LIBIPC_NAMESPACE_BEG_ LIBIPC_NAMESPACE_BEG_
using namespace ::LIBIMP_; using namespace ::LIBIMP;
struct shm_handle { struct shm_handle {
std::string file; std::string file;

View File

@ -15,7 +15,7 @@
#include "mmap_impl.h" #include "mmap_impl.h"
LIBIPC_NAMESPACE_BEG_ LIBIPC_NAMESPACE_BEG_
using namespace ::LIBIMP_; using namespace ::LIBIMP;
result<shm_t> shm_open(std::string name, std::size_t size, mode::type type) noexcept { result<shm_t> shm_open(std::string name, std::size_t size, mode::type type) noexcept {
LIBIMP_LOG_(); LIBIMP_LOG_();

View File

@ -19,7 +19,7 @@ using tstring = std::basic_string<TCHAR>;
inline tstring to_tstring(std::string const &str) { inline tstring to_tstring(std::string const &str) {
tstring des; tstring des;
::LIBIMP_::cvt_sstr(str, des); ::LIBIMP::cvt_sstr(str, des);
return des; return des;
} }

View File

@ -14,22 +14,22 @@ allocator::holder_base const &allocator::get_holder() const noexcept {
} }
allocator::allocator() noexcept { allocator::allocator() noexcept {
::LIBIMP_::construct<holder_null>(holder_.data()); ::LIBIMP::construct<holder_null>(holder_.data());
} }
allocator::~allocator() noexcept { allocator::~allocator() noexcept {
::LIBIMP_::destroy(&get_holder()); ::LIBIMP::destroy(&get_holder());
} }
allocator::allocator(allocator &&other) noexcept allocator::allocator(allocator &&other) noexcept
: allocator(other) /*copy*/ { : allocator(other) /*copy*/ {
::LIBIMP_::construct<holder_null>(other.holder_.data()); ::LIBIMP::construct<holder_null>(other.holder_.data());
} }
allocator &allocator::operator=(allocator &&other) & noexcept { allocator &allocator::operator=(allocator &&other) & noexcept {
if (this == &other) return *this; if (this == &other) return *this;
this->holder_ = other.holder_; this->holder_ = other.holder_;
::LIBIMP_::construct<holder_null>(other.holder_.data()); ::LIBIMP::construct<holder_null>(other.holder_.data());
return *this; return *this;
} }

View File

@ -13,7 +13,7 @@ namespace {
/** /**
* @brief Check that bytes is not 0 and that the alignment is a power of two. * @brief Check that bytes is not 0 and that the alignment is a power of two.
*/ */
bool verify_args(::LIBIMP_::log::grip &log, std::size_t bytes, std::size_t alignment) noexcept { bool verify_args(::LIBIMP::log::grip &log, std::size_t bytes, std::size_t alignment) noexcept {
if (bytes == 0) { if (bytes == 0) {
return false; return false;
} }

View File

@ -29,11 +29,13 @@ file(GLOB SRC_FILES
${LIBIPC_PROJECT_DIR}/test/imp/*.cpp ${LIBIPC_PROJECT_DIR}/test/imp/*.cpp
${LIBIPC_PROJECT_DIR}/test/pmr/*.cpp ${LIBIPC_PROJECT_DIR}/test/pmr/*.cpp
${LIBIPC_PROJECT_DIR}/test/concur/*.cpp ${LIBIPC_PROJECT_DIR}/test/concur/*.cpp
${LIBIPC_PROJECT_DIR}/test/*.cpp) ${LIBIPC_PROJECT_DIR}/test/ipc/*.cpp)
file(GLOB HEAD_FILES file(GLOB HEAD_FILES
${LIBIPC_PROJECT_DIR}/test/*.h) ${LIBIPC_PROJECT_DIR}/test/*.h)
add_executable(${PROJECT_NAME} ${SRC_FILES} ${HEAD_FILES}) add_executable(${PROJECT_NAME} ${SRC_FILES} ${HEAD_FILES})
target_link_libraries(${PROJECT_NAME} gtest_main imp pmr ipc) target_link_libraries(${PROJECT_NAME}
gtest_main
imp pmr ipc)