From 15e71bd1a1a850ad80fbd631b80a3ede07f14b48 Mon Sep 17 00:00:00 2001 From: zhangyi Date: Mon, 1 Jul 2019 17:28:02 +0800 Subject: [PATCH] add IPC_CONSTEXPR_; add variable_wrapper instead of fixed_alloc_policy --- build/ipc/ipc.pro | 1 - src/ipc.cpp | 16 +++---- src/memory/detail.h | 72 -------------------------------- src/memory/resource.h | 5 +-- src/memory/wrapper.h | 68 +++++++++++++++++++++++++++--- src/platform/detail.h | 18 ++++---- src/platform/tls_pointer_win.cpp | 20 +++++---- test/test_mem.cpp | 4 +- 8 files changed, 94 insertions(+), 110 deletions(-) delete mode 100644 src/memory/detail.h diff --git a/build/ipc/ipc.pro b/build/ipc/ipc.pro index 233de62..534e272 100644 --- a/build/ipc/ipc.pro +++ b/build/ipc/ipc.pro @@ -22,7 +22,6 @@ HEADERS += \ ../../include/tls_pointer.h \ ../../include/pool_alloc.h \ ../../include/buffer.h \ - ../../src/memory/detail.h \ ../../src/memory/alloc.h \ ../../src/memory/wrapper.h \ ../../src/memory/resource.h \ diff --git a/src/ipc.cpp b/src/ipc.cpp index 00c27ce..3a8da8b 100644 --- a/src/ipc.cpp +++ b/src/ipc.cpp @@ -91,13 +91,15 @@ struct conn_info_head { shm::handle acc_h_; /* - thread_local may have some bugs. - See: https://sourceforge.net/p/mingw-w64/bugs/727/ - https://sourceforge.net/p/mingw-w64/bugs/527/ - https://github.com/Alexpux/MINGW-packages/issues/2519 - https://github.com/ChaiScript/ChaiScript/issues/402 - https://developercommunity.visualstudio.com/content/problem/124121/thread-local-variables-fail-to-be-initialized-when.html - https://software.intel.com/en-us/forums/intel-c-compiler/topic/684827 + * thread_local may have some bugs. + * + * + * - https://sourceforge.net/p/mingw-w64/bugs/727/ + * - https://sourceforge.net/p/mingw-w64/bugs/527/ + * - https://github.com/Alexpux/MINGW-packages/issues/2519 + * - https://github.com/ChaiScript/ChaiScript/issues/402 + * - https://developercommunity.visualstudio.com/content/problem/124121/thread-local-variables-fail-to-be-initialized-when.html + * - https://software.intel.com/en-us/forums/intel-c-compiler/topic/684827 */ tls::pointer> recv_cache_; diff --git a/src/memory/detail.h b/src/memory/detail.h deleted file mode 100644 index a654f6b..0000000 --- a/src/memory/detail.h +++ /dev/null @@ -1,72 +0,0 @@ -#pragma once - -#include - -#include "memory/alloc.h" -#include "platform/detail.h" - -namespace ipc { -namespace mem { -namespace detail { - -enum : std::size_t { - base_size = sizeof(void*) -}; - -#if __cplusplus >= 201703L -constexpr std::size_t classify(std::size_t size) { - constexpr std::size_t mapping[] = { -#else /*__cplusplus < 201703L*/ -inline std::size_t classify(std::size_t size) { - static const std::size_t mapping[] = { -#endif/*__cplusplus < 201703L*/ - /* 1 */ - 0 , 1 , 2 , 3 , - /* 2 */ - 5 , 5 , 7 , 7 , - 9 , 9 , 11, 11, - 13, 13, 15, 15, - /* 4 */ - 19, 19, 19, 19, - 23, 23, 23, 23, - 27, 27, 27, 27, - 31, 31, 31, 31 - }; - size = (size - 1) / base_size; -#if __cplusplus >= 201703L - return (size < std::size(mapping)) ? mapping[size] : 32; -#else /*__cplusplus < 201703L*/ - return (size < (sizeof(mapping) / sizeof(mapping[0]))) ? mapping[size] : 32; -#endif/*__cplusplus < 201703L*/ -} - -template