From 375c014f7a9fa37536c952e5bfb225e5c4ded5c6 Mon Sep 17 00:00:00 2001 From: q66 Date: Wed, 10 Jan 2018 02:57:29 +0100 Subject: [PATCH] vtable translation unit for thread pool + warns --- build.cc | 1 + gen_unicode.cc | 8 ++++---- ostd/platform.hh | 3 +++ ostd/thread_pool.hh | 2 +- src/thread_pool.cc | 16 ++++++++++++++++ 5 files changed, 25 insertions(+), 5 deletions(-) create mode 100644 src/thread_pool.cc diff --git a/build.cc b/build.cc index f843677..724f61e 100644 --- a/build.cc +++ b/build.cc @@ -28,6 +28,7 @@ namespace fs = ostd::filesystem; #include "src/io.cc" #include "src/process.cc" #include "src/filesystem.cc" +#include "src/thread_pool.cc" #include "src/channel.cc" #include "src/string.cc" #include "src/argparse.cc" diff --git a/gen_unicode.cc b/gen_unicode.cc index 713c837..2ae352c 100644 --- a/gen_unicode.cc +++ b/gen_unicode.cc @@ -31,7 +31,7 @@ inline code_t hex_to_code(string_range hs) { if (!std::isxdigit(c |= 32)) { throw std::runtime_error{"malformed code point"}; } - ret = ret * 16 + (c - ((c > '9') ? ('a' - 10) : '0')); + ret = ret * 16 + code_t(c - ((c > '9') ? ('a' - 10) : '0')); } return ret; } @@ -62,7 +62,7 @@ struct parse_state { bits[n] = line; break; } - bits[n++] = line.slice(0, sc.data() - line.data()); + bits[n++] = line.slice(0, std::size_t(sc.data() - line.data())); sc.pop_front(); line = sc; } @@ -145,8 +145,8 @@ struct parse_state { ](std::size_t i, std::size_t offs) { int off = (!int(offs) * 2) - 1; return match_pair(i, 2) && (cases.empty() || ( - (cases[i + 1] == (codes[i + 1] + off)) && - (cases[i ] == (codes[i ] + off)) + (cases[i + 1] == code_t(std::int32_t(codes[i + 1]) + off)) && + (cases[i ] == code_t(std::int32_t(codes[i ]) + off)) )); }; diff --git a/ostd/platform.hh b/ostd/platform.hh index 95b7317..2b06b8c 100644 --- a/ostd/platform.hh +++ b/ostd/platform.hh @@ -209,6 +209,9 @@ # endif # define OSTD_LOCAL #else +# if defined(OSTD_BUILD_LIB) || defined(OSTD_BUILD_DLL) +/* -Wunused-macros */ +# endif # if __GNUC__ >= 4 # define OSTD_EXPORT __attribute__((visibility("default"))) # define OSTD_LOCAL __attribute__((visibility("hidden"))) diff --git a/ostd/thread_pool.hh b/ostd/thread_pool.hh index 9ef69d2..617f1dc 100644 --- a/ostd/thread_pool.hh +++ b/ostd/thread_pool.hh @@ -36,7 +36,7 @@ namespace ostd { namespace detail { struct tpool_func_base { tpool_func_base() {} - virtual ~tpool_func_base() {} + virtual ~tpool_func_base(); virtual void clone(tpool_func_base *func) = 0; virtual void call() = 0; }; diff --git a/src/thread_pool.cc b/src/thread_pool.cc new file mode 100644 index 0000000..fc55fd3 --- /dev/null +++ b/src/thread_pool.cc @@ -0,0 +1,16 @@ +/* Thread pool implementation bits. + * + * This file is part of libostd. See COPYING.md for futher information. + */ + +#include "ostd/thread_pool.hh" +#include "ostd/channel.hh" + +namespace ostd { +namespace detail { + +/* place the vtable here */ +tpool_func_base::~tpool_func_base() {} + +} /* namespace detail */ +} /* namespace ostd */