浏览代码

New variable dispatch method.

jcsyshc 2 年之前
父节点
当前提交
700cd232f5

+ 0 - 2
src/algorithm/five_dof_offset_calculator.hpp

@@ -8,8 +8,6 @@
 #include "utility/simple_tristate_obj.hpp"
 #include "utility/variable_helper.hpp"
 
-#include "utility/assert_utility.h"
-
 namespace sophiar {
 
     // Fix origin and Z-axis only

+ 0 - 2
src/algorithm/tcp_offset_to_flange_calculator.hpp

@@ -8,8 +8,6 @@
 #include "utility/simple_tristate_obj.hpp"
 #include "utility/variable_helper.hpp"
 
-#include "utility/assert_utility.h"
-
 namespace sophiar {
 
     // Change offset in TCP to offset in flange

+ 0 - 2
src/algorithm/transform_tree.cpp

@@ -18,8 +18,6 @@
 #include <vector>
 #include <utility>
 
-#include "utility/assert_utility.h"
-
 DEFAULT_TRISTATE_OBJ_DEF(transform_tree)
 
 namespace sophiar {

+ 0 - 2
src/algorithm/transform_utility.hpp

@@ -8,8 +8,6 @@
 #include "utility/simple_tristate_obj.hpp"
 #include "utility/variable_helper.hpp"
 
-#include "utility/assert_utility.h"
-
 namespace sophiar {
 
     inline coro_worker::pointer make_transform_inverter_func(const nlohmann::json &config) {

+ 0 - 2
src/controller/simple_offset_to_pose_controller.hpp

@@ -8,8 +8,6 @@
 #include "utility/simple_tristate_obj.hpp"
 #include "utility/variable_helper.hpp"
 
-#include "utility/assert_utility.h"
-
 namespace sophiar {
 
     // Imply to offset to pose

+ 82 - 36
src/core/basic_obj_types.hpp

@@ -9,8 +9,6 @@
 
 #include <array>
 
-#include "utility/assert_utility.h"
-
 namespace sophiar {
 
     template<typename T>
@@ -53,26 +51,6 @@ namespace sophiar {
             return std::move(tmp_obj.value);
         }
 
-        template<typename WriterType>
-        static void raw_pointer_write_to(WriterType &writer, void *raw_ptr) {
-            auto &real_ptr = *static_cast<typename this_type::pointer *>(raw_ptr);
-            if (real_ptr == nullptr) [[unlikely]] return;
-            real_ptr->write_to(writer);
-        }
-
-        template<typename ReaderType>
-        static void raw_pointer_fill_from(ReaderType &reader, void *raw_ptr) {
-            auto &real_ptr = *static_cast<typename this_type::pointer *>(raw_ptr);
-            if (reader.empty()) [[unlikely]] {
-                real_ptr = nullptr;
-                return;
-            }
-            if (real_ptr == nullptr) [[unlikely]] {
-                real_ptr = this_type::new_instance();
-            }
-            real_ptr->fill_from(reader);
-        }
-
         static constexpr size_t binary_length() {
             return sizeof(T);
         }
@@ -83,20 +61,12 @@ namespace sophiar {
     using array_obj = small_obj_wrapper<std::array<double, Length>>;
 
     using bool_obj = small_obj_wrapper<bool>;       // 0
-//    using u8int_obj = small_obj_wrapper<uint8_t>;   // 1
-//    using u16int_obj = small_obj_wrapper<uint16_t>; // 2
-//    using u32int_obj = small_obj_wrapper<uint32_t>; // 3
-    using u64int_obj = small_obj_wrapper<uint64_t>; // 4
-//    using i8int_obj = small_obj_wrapper<int8_t>;    // 5
-//    using i16int_obj = small_obj_wrapper<int16_t>;  // 6
-//    using i32int_obj = small_obj_wrapper<int32_t>;  // 7
-//    using i64int_obj = small_obj_wrapper<int64_t>;  // 8
-//    using float_obj = small_obj_wrapper<float>;     // 9
-    using double_obj = small_obj_wrapper<double>;   // 10
-    using scalarxyz_obj = small_obj_wrapper<Eigen::Vector3d>;   // 11
-    using transform_obj = small_obj_wrapper<Eigen::Isometry3d>; // 12
-    using array6_obj = array_obj<6>; // 13
-    using array7_obj = array_obj<7>; // 14
+    using u64int_obj = small_obj_wrapper<uint64_t>; // 1
+    using double_obj = small_obj_wrapper<double>;   // 2
+    using scalarxyz_obj = small_obj_wrapper<Eigen::Vector3d>;   // 3
+    using transform_obj = small_obj_wrapper<Eigen::Isometry3d>; // 4
+    using array6_obj = array_obj<6>; // 5
+    using array7_obj = array_obj<7>; // 6
 
     // specialization
 
@@ -236,6 +206,82 @@ namespace sophiar {
         fill_from(provider);
     }
 
+    // dispatch functions
+
+    constexpr auto bool_var_type_index = 0;
+    constexpr auto u64int_var_type_index = 1;
+    constexpr auto double_var_type_index = 2;
+    constexpr auto scalarxyz_var_type_index = 3;
+    constexpr auto transform_var_type_index = 4;
+    constexpr auto array6_var_type_index = 5;
+    constexpr auto array7_var_type_index = 6;
+
+#define LOOP_BASIC_VAR_TYPE(COMMAND) \
+        switch (var_type_index) { \
+            case bool_var_type_index: { \
+                auto &real_ptr = *static_cast<bool_obj::pointer *>(raw_ptr); \
+                COMMAND \
+            } \
+            case u64int_var_type_index: { \
+                auto &real_ptr = *static_cast<u64int_obj::pointer *>(raw_ptr); \
+                COMMAND \
+            } \
+            case double_var_type_index: { \
+                auto &real_ptr = *static_cast<double_obj::pointer *>(raw_ptr); \
+                COMMAND \
+            } \
+            case scalarxyz_var_type_index: { \
+                auto &real_ptr = *static_cast<scalarxyz_obj::pointer *>(raw_ptr); \
+                COMMAND \
+            } \
+            case transform_var_type_index: { \
+                auto &real_ptr = *static_cast<transform_obj::pointer *>(raw_ptr); \
+                COMMAND \
+            } \
+            case array6_var_type_index: { \
+                auto &real_ptr = *static_cast<array6_obj::pointer *>(raw_ptr); \
+                COMMAND \
+            } \
+            case array7_var_type_index: { \
+                auto &real_ptr = *static_cast<array7_obj::pointer *>(raw_ptr); \
+                COMMAND \
+            } \
+            default: { \
+                assert(false); \
+                __builtin_unreachable(); \
+            } \
+        }
+
+    inline bool raw_pointer_is_valid(void *raw_ptr, int var_type_index) {
+        LOOP_BASIC_VAR_TYPE({ return real_ptr != nullptr; })
+    }
+
+    template<typename WriterType>
+    inline void raw_pointer_write_to(WriterType &writer, void *raw_ptr, int var_type_index) {
+        LOOP_BASIC_VAR_TYPE(
+                {
+                    if (real_ptr == nullptr) [[unlikely]] return;
+                    real_ptr->write_to(writer);
+                    return;
+                })
+    }
+
+    template<typename ReaderType>
+    inline void raw_pointer_fill_from(ReaderType &reader, void *raw_ptr, int var_type_index) {
+        LOOP_BASIC_VAR_TYPE(
+                {
+                    if (reader.empty()) [[unlikely]] {
+                        real_ptr = nullptr;
+                        return;
+                    }
+                    if (real_ptr == nullptr) [[unlikely]] {
+                        real_ptr = real_ptr->new_instance();
+                    }
+                    real_ptr->fill_from(reader);
+                    return;
+                })
+    }
+
 }
 
 #endif //SOPHIAR2_BASIC_OBJ_TYPES_HPP

+ 9 - 22
src/core/external_variable_io.cpp

@@ -1,4 +1,5 @@
 #include "external_variable_io.h"
+#include "core/basic_obj_types.hpp"
 #include "core/global_defs.h"
 #include "core/sophiar_pool.h"
 #include "utility/config_utility.hpp"
@@ -94,16 +95,6 @@ namespace sophiar {
             return global_sophiar_pool->update_variable_timestamp_impl(var_index, ts);
         }
 
-        template<typename WriterType>
-        static auto require_raw_pointer_writer(std::type_index var_type) {
-            return global_sophiar_pool->require_raw_pointer_writer<WriterType>(var_type);
-        }
-
-        template<typename ReaderType>
-        static auto require_raw_pointer_reader(std::type_index var_type) {
-            return global_sophiar_pool->require_raw_pointer_reader<ReaderType>(var_type);
-        }
-
     };
 
     external_variable_io::external_variable_io()
@@ -119,14 +110,12 @@ namespace sophiar {
 
     struct external_variable_io::impl::binary_in_client {
 
-        using reader_type = versatile_reader<sophiar_endian>;
-        using reader_func_type = void (*)(reader_type &, void *);
-
         struct variable_io_info {
+            variable_type_index_type var_type_index;
             void *placeholder;
-            reader_func_type reader_func;
         };
 
+        using reader_type = versatile_reader<sophiar_endian>;
         using info_pool_type = std::unordered_map<variable_index_type, variable_io_info>;
 
         tcp::socket s;
@@ -140,8 +129,8 @@ namespace sophiar {
                 assert(!info_pool.contains(info.var_index));
                 info_pool.emplace(info.var_index,
                                   variable_io_info{
+                                          .var_type_index = info.var_type_index,
                                           .placeholder = info.placeholder,
-                                          .reader_func = require_raw_pointer_reader<reader_type>(info.type)
                                   });
             }
         }
@@ -165,7 +154,7 @@ namespace sophiar {
 
                 assert(info_pool.contains(var_index));
                 auto &info = info_pool[var_index];
-                info.reader_func(val_reader, info.placeholder);
+                raw_pointer_fill_from(val_reader, info.placeholder, info.var_type_index);
                 update_variable_timestamp(var_index, ts);
             }
 
@@ -176,16 +165,14 @@ namespace sophiar {
 
     struct external_variable_io::impl::binary_out_client {
 
-        using writer_type = dynamic_memory_writer<sophiar_endian>;
-        using writer_func_type = void (*)(writer_type &, void *);
-
         struct variable_io_info {
+            variable_type_index_type var_type_index;
             variable_index_type var_index;
             void *placeholder;
-            writer_func_type writer_func;
             timestamp_type last_update_ts;
         };
 
+        using writer_type = dynamic_memory_writer<sophiar_endian>;
         using info_pool_type = dynamic_vector<variable_io_info>;
 
         tcp::socket s;
@@ -207,9 +194,9 @@ namespace sophiar {
                 signal_group->add_watcher(REQUIRE_VARIABLE_WATCHER(info.var_index));
                 info_pool.push_back(
                         {
+                                .var_type_index = info.var_type_index,
                                 .var_index = info.var_index,
                                 .placeholder = info.placeholder,
-                                .writer_func = require_raw_pointer_writer<writer_type>(info.type),
                                 .last_update_ts = 0
                         });
             }
@@ -234,7 +221,7 @@ namespace sophiar {
                 writer << info.var_index;
                 auto size_offset = buf->size();
                 buf->increase_size(variable_size_type_offset);
-                info.writer_func(writer, info.placeholder);
+                raw_pointer_write_to(writer, info.placeholder, info.var_type_index);
                 auto length = buf->size() - size_offset - variable_size_type_offset;
                 assert(length <= std::numeric_limits<variable_size_type>::max());
                 write_binary_value<sophiar_endian>(buf->data() + size_offset,

+ 0 - 2
src/core/sophiar_manager.h

@@ -19,8 +19,6 @@
 #include <typeindex>
 #include <typeinfo>
 
-#include "utility/assert_utility.h"
-
 namespace sophiar {
 
     class sophiar_obj;

+ 13 - 66
src/core/sophiar_pool.cpp

@@ -8,23 +8,18 @@
 #include <vector>
 #include <unordered_map>
 
-#include "utility/assert_utility.h"
-
 namespace sophiar {
 
     struct sophiar_pool::impl {
 
         struct variable_type_info {
-            using creator_func_type = void *(*)(const nlohmann::json &);
-
-            size_t binary_length;
             std::type_index type = typeid(void);
+            variable_type_index_type type_index;
             std::string type_name;
 
             // function list
+            using creator_func_type = void *(*)(const nlohmann::json &);
             creator_func_type creator_func;
-            std::unordered_map<std::type_index, void *> writer_func_pool;
-            std::unordered_map<std::type_index, void *> reader_func_pool;
         };
 
         struct variable_info_impl {
@@ -34,7 +29,6 @@ namespace sophiar {
             timestamp_type last_update_ts;
         };
 
-        using variable_type_index_type = uint16_t;
         string_map<variable_type_index_type> variable_type_name_index_map; // typename -> index
         std::unordered_map<std::type_index, variable_type_index_type> variable_type_index_index_map; // type_index -> index
         std::vector<variable_type_info> variable_type_info_pool;
@@ -69,39 +63,10 @@ namespace sophiar {
             variable_type_index_index_map[type] = var_type_index;
 
             auto &type_info = variable_type_info_pool[var_type_index];
-            type_info.binary_length = SmallObjType::binary_length();
             type_info.type = type;
+            type_info.type_index = var_type_index;
             type_info.type_name = type_name;
             type_info.creator_func = create_variable_pointer<SmallObjType>;
-
-            // create IO functions
-#define REGISTER_WRITER_FUNC(writer_type) { \
-            const std::type_index writer_type_index = typeid(writer_type); \
-            type_info.writer_func_pool[writer_type_index] =                \
-                (void *) &SmallObjType::template raw_pointer_write_to<writer_type>; }
-
-            using writer_big_extern = versatile_writer<boost::endian::order::big>;
-            using writer_little_extern = versatile_writer<boost::endian::order::little>;
-            using writer_big_dynamic = dynamic_memory_writer<boost::endian::order::big>;
-            using writer_little_dynamic = dynamic_memory_writer<boost::endian::order::little>;
-
-            REGISTER_WRITER_FUNC(writer_big_extern)
-            REGISTER_WRITER_FUNC(writer_little_extern)
-            REGISTER_WRITER_FUNC(writer_big_dynamic)
-            REGISTER_WRITER_FUNC(writer_little_dynamic)
-#undef REGISTER_WRITER_FUNC
-
-#define REGISTER_READER_FUNC(reader_type) { \
-            const std::type_index reader_type_index = typeid(reader_type); \
-            type_info.reader_func_pool[reader_type_index] =                \
-                (void *) &SmallObjType::template raw_pointer_fill_from<reader_type>; }
-
-            using reader_big_extern = versatile_reader<boost::endian::order::big>;
-            using reader_little_extern = versatile_reader<boost::endian::order::little>;
-
-            REGISTER_READER_FUNC(reader_big_extern)
-            REGISTER_READER_FUNC(reader_little_extern)
-#undef REGISTER_READER_FUNC
         }
 
         void register_basic_variable_types() {
@@ -109,21 +74,22 @@ namespace sophiar {
             register_variable_type<var_type>(#var_type)
 
             REGISTER_TYPE(bool_obj);
-//            REGISTER_TYPE(u8int_obj);
-//            REGISTER_TYPE(u16int_obj);
-//            REGISTER_TYPE(u32int_obj);
             REGISTER_TYPE(u64int_obj);
-//            REGISTER_TYPE(i8int_obj);
-//            REGISTER_TYPE(i16int_obj);
-//            REGISTER_TYPE(i32int_obj);
-//            REGISTER_TYPE(i64int_obj);
-//            REGISTER_TYPE(float_obj);
             REGISTER_TYPE(double_obj);
             REGISTER_TYPE(scalarxyz_obj);
             REGISTER_TYPE(transform_obj);
             REGISTER_TYPE(array6_obj);
             REGISTER_TYPE(array7_obj);
 #undef REGISTER_TYPE
+
+            // check registered variable type index
+            assert(variable_type_index_index_map.at(typeid(bool_obj)) == bool_var_type_index);
+            assert(variable_type_index_index_map.at(typeid(u64int_obj)) == u64int_var_type_index);
+            assert(variable_type_index_index_map.at(typeid(double_obj)) == double_var_type_index);
+            assert(variable_type_index_index_map.at(typeid(scalarxyz_obj)) == scalarxyz_var_type_index);
+            assert(variable_type_index_index_map.at(typeid(transform_obj)) == transform_var_type_index);
+            assert(variable_type_index_index_map.at(typeid(array6_obj)) == array6_var_type_index);
+            assert(variable_type_index_index_map.at(typeid(array7_obj)) == array7_var_type_index);
         }
 
         void register_variable(std::string_view name,
@@ -186,9 +152,8 @@ namespace sophiar {
         assert(pimpl->variable_pool.contains(var_name));
         const auto &info = pimpl->variable_pool[var_name];
         variable_info ret{
+                .var_type_index = info.type_info->type_index,
                 .var_index = pimpl->variable_pool.to_index_by_name(var_name),
-                .type = info.type_info->type,
-                .binary_length = info.type_info->binary_length,
                 .placeholder = info.placeholder
         };
         return ret;
@@ -223,24 +188,6 @@ namespace sophiar {
         info.update_signal->try_notify_all(ts);
     }
 
-    void *sophiar_pool::require_raw_pointer_writer_impl(std::type_index writer_type,
-                                                        std::type_index var_type) {
-        assert(pimpl->variable_type_index_index_map.contains(var_type));
-        auto var_type_index = pimpl->variable_type_index_index_map[var_type];
-        auto &info = pimpl->variable_type_info_pool[var_type_index];
-        assert(info.writer_func_pool.contains(writer_type));
-        return info.writer_func_pool[writer_type];
-    }
-
-    void *sophiar_pool::require_raw_pointer_reader_impl(std::type_index reader_type,
-                                                        std::type_index var_type) {
-        assert(pimpl->variable_type_index_index_map.contains(var_type));
-        auto var_type_index = pimpl->variable_type_index_index_map[var_type];
-        auto &info = pimpl->variable_type_info_pool[var_type_index];
-        assert(info.reader_func_pool.contains(reader_type));
-        return info.reader_func_pool[reader_type];
-    }
-
     void sophiar_pool::load_config(const nlohmann::json &config) {
         pimpl->load_config(config);
     }

+ 2 - 26
src/core/sophiar_pool.h

@@ -14,6 +14,7 @@
 
 namespace sophiar {
 
+    using variable_type_index_type = uint8_t;
     using variable_index_type = uint16_t;
     static constexpr auto invalid_variable_index = ~(variable_index_type) 0;
 
@@ -83,38 +84,13 @@ namespace sophiar {
 
         // for friend classes
         struct variable_info {
+            variable_type_index_type var_type_index;
             variable_index_type var_index;
-            std::type_index type;
-            size_t binary_length;
             void *placeholder;
         };
 
         variable_info query_variable_information(std::string_view var_name);
 
-        template<typename WriterType>
-        auto require_raw_pointer_writer(std::type_index var_type) {
-            using RealWriterType = std::remove_cvref_t<WriterType>;
-            using WriterFuncType = void (*)(RealWriterType &, void *);
-            auto func_ptr = require_raw_pointer_writer_impl(typeid(RealWriterType), var_type);
-            assert(func_ptr != nullptr);
-            return (WriterFuncType) func_ptr;
-        }
-
-        template<typename ReaderType>
-        auto require_raw_pointer_reader(std::type_index var_type) {
-            using RealReaderType = std::remove_cvref_t<ReaderType>;
-            using ReaderFuncType = void (*)(RealReaderType &, void *);
-            auto func_ptr = require_raw_pointer_reader_impl(typeid(RealReaderType), var_type);
-            assert(func_ptr != nullptr);
-            return (ReaderFuncType) func_ptr;
-        }
-
-        void *require_raw_pointer_writer_impl(std::type_index writer_type,
-                                              std::type_index var_type);
-
-        void *require_raw_pointer_reader_impl(std::type_index reader_type,
-                                              std::type_index var_type);
-
         friend class external_variable_io;
 
     };

+ 0 - 2
src/core/tristate_obj.cpp

@@ -8,8 +8,6 @@
 
 #include <boost/asio/experimental/awaitable_operators.hpp>
 
-#include "utility/assert_utility.h"
-
 namespace sophiar {
 
     name_translator<uint8_t> *state_name_translator;

+ 0 - 2
src/main.cpp

@@ -8,8 +8,6 @@
 
 #include <spdlog/spdlog.h>
 
-#include "utility/assert_utility.h"
-
 using namespace sophiar;
 
 int main(int argc, char *argv[]) {

+ 0 - 2
src/robot/fracture_robot/fracture_robot_interface.cpp

@@ -14,8 +14,6 @@
 
 #include <spdlog/spdlog.h>
 
-#include "utility/assert_utility.h"
-
 DEFAULT_TRISTATE_OBJ_DEF(fracture_robot_interface)
 
 namespace sophiar {

+ 0 - 2
src/robot/kuka/kuka_interface.cpp

@@ -24,8 +24,6 @@
 #include <unordered_map>
 #include <string_view>
 
-#include "utility/assert_utility.h"
-
 DEFAULT_TRISTATE_OBJ_DEF(kuka_interface);
 
 namespace sophiar {

+ 0 - 2
src/robot/ur/ur_interface.cpp

@@ -30,8 +30,6 @@
 #include <string_view>
 #include <vector>
 
-#include "utility/assert_utility.h"
-
 DEFAULT_TRISTATE_OBJ_DEF(ur_interface)
 
 namespace sophiar {

+ 0 - 2
src/sensor/ndi/ndi_interface.cpp

@@ -42,8 +42,6 @@
 #include <vector>
 #include <unordered_map>
 
-#include "utility/assert_utility.h"
-
 DEFAULT_TRISTATE_OBJ_DEF(ndi_interface)
 
 namespace sophiar {

+ 0 - 2
src/sensor/optoforce/optoforce_daq.cpp

@@ -13,8 +13,6 @@
 
 #include <numeric>
 
-#include "utility/assert_utility.h"
-
 DEFAULT_TRISTATE_OBJ_DEF(optoforce_daq)
 
 namespace sophiar {

+ 0 - 172
src/third_party/debugbreak.h

@@ -1,172 +0,0 @@
-/* Copyright (c) 2011-2021, Scott Tsai
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef DEBUG_BREAK_H
-#define DEBUG_BREAK_H
-
-#ifdef _MSC_VER
-
-#define debug_break __debugbreak
-
-#else
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define DEBUG_BREAK_USE_TRAP_INSTRUCTION 1
-#define DEBUG_BREAK_USE_BULTIN_TRAP      2
-#define DEBUG_BREAK_USE_SIGTRAP          3
-
-#if defined(__i386__) || defined(__x86_64__)
-#define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION
-__inline__ static void trap_instruction(void) {
-    __asm__ volatile("int $0x03");
-}
-#elif defined(__thumb__)
-#define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION
-/* FIXME: handle __THUMB_INTERWORK__ */
-__attribute__((always_inline))
-__inline__ static void trap_instruction(void)
-{
-    /* See 'arm-linux-tdep.c' in GDB source.
-     * Both instruction sequences below work. */
-#if 1
-    /* 'eabi_linux_thumb_le_breakpoint' */
-    __asm__ volatile(".inst 0xde01");
-#else
-    /* 'eabi_linux_thumb2_le_breakpoint' */
-    __asm__ volatile(".inst.w 0xf7f0a000");
-#endif
-
-    /* Known problem:
-     * After a breakpoint hit, can't 'stepi', 'step', or 'continue' in GDB.
-     * 'step' would keep getting stuck on the same instruction.
-     *
-     * Workaround: use the new GDB commands 'debugbreak-step' and
-     * 'debugbreak-continue' that become available
-     * after you source the script from GDB:
-     *
-     * $ gdb -x debugbreak-gdb.py <... USUAL ARGUMENTS ...>
-     *
-     * 'debugbreak-step' would jump over the breakpoint instruction with
-     * roughly equivalent of:
-     * (gdb) set $instruction_len = 2
-     * (gdb) tbreak *($pc + $instruction_len)
-     * (gdb) jump   *($pc + $instruction_len)
-     */
-}
-#elif defined(__arm__) && !defined(__thumb__)
-#define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION
-__attribute__((always_inline))
-__inline__ static void trap_instruction(void)
-{
-    /* See 'arm-linux-tdep.c' in GDB source,
-     * 'eabi_linux_arm_le_breakpoint' */
-    __asm__ volatile(".inst 0xe7f001f0");
-    /* Known problem:
-     * Same problem and workaround as Thumb mode */
-}
-#elif defined(__aarch64__) && defined(__APPLE__)
-#define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_BULTIN_DEBUGTRAP
-#elif defined(__aarch64__)
-#define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION
-__attribute__((always_inline))
-__inline__ static void trap_instruction(void)
-{
-    /* See 'aarch64-tdep.c' in GDB source,
-     * 'aarch64_default_breakpoint' */
-    __asm__ volatile(".inst 0xd4200000");
-}
-#elif defined(__powerpc__)
-    /* PPC 32 or 64-bit, big or little endian */
-#define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION
-__attribute__((always_inline))
-__inline__ static void trap_instruction(void)
-{
-    /* See 'rs6000-tdep.c' in GDB source,
-     * 'rs6000_breakpoint' */
-    __asm__ volatile(".4byte 0x7d821008");
-
-    /* Known problem:
-     * After a breakpoint hit, can't 'stepi', 'step', or 'continue' in GDB.
-     * 'step' stuck on the same instruction ("twge r2,r2").
-     *
-     * The workaround is the same as ARM Thumb mode: use debugbreak-gdb.py
-     * or manually jump over the instruction. */
-}
-#elif defined(__riscv)
-    /* RISC-V 32 or 64-bit, whether the "C" extension
-     * for compressed, 16-bit instructions are supported or not */
-#define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION
-__attribute__((always_inline))
-__inline__ static void trap_instruction(void)
-{
-    /* See 'riscv-tdep.c' in GDB source,
-     * 'riscv_sw_breakpoint_from_kind' */
-    __asm__ volatile(".4byte 0x00100073");
-}
-#else
-#define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_SIGTRAP
-#endif
-
-
-#ifndef DEBUG_BREAK_IMPL
-#error "debugbreak.h is not supported on this target"
-#elif DEBUG_BREAK_IMPL == DEBUG_BREAK_USE_TRAP_INSTRUCTION
-__attribute__((always_inline))
-__inline__ static void debug_break(void) {
-    trap_instruction();
-}
-#elif DEBUG_BREAK_IMPL == DEBUG_BREAK_USE_BULTIN_DEBUGTRAP
-__attribute__((always_inline))
-__inline__ static void debug_break(void)
-{
-    __builtin_debugtrap();
-}
-#elif DEBUG_BREAK_IMPL == DEBUG_BREAK_USE_BULTIN_TRAP
-__attribute__((always_inline))
-__inline__ static void debug_break(void)
-{
-    __builtin_trap();
-}
-#elif DEBUG_BREAK_IMPL == DEBUG_BREAK_USE_SIGTRAP
-#include <signal.h>
-__attribute__((always_inline))
-__inline__ static void debug_break(void)
-{
-    raise(SIGTRAP);
-}
-#else
-#error "invalid DEBUG_BREAK_IMPL value"
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* ifdef _MSC_VER */
-
-#endif /* ifndef DEBUG_BREAK_H */

+ 0 - 28
src/utility/assert_utility.h

@@ -1,28 +0,0 @@
-#include <boost/predef.h>
-#include <cassert>
-#include "third_party/debugbreak.h"
-
-#undef assert
-
-#ifdef NDEBUG
-    #define assert(_Expression) ((void)0)
-#else /* !defined (NDEBUG) */
-    #ifdef BOOST_OS_WINDOWS_AVAILABLE
-        #if defined(_UNICODE) || defined(UNICODE)
-            #define assert(_Expression) \
-                (void) \
-                ((!!(_Expression)) || \
-                (debug_break(),_wassert(_CRT_WIDE(#_Expression),_CRT_WIDE(__FILE__),__LINE__),0))
-        #else /* not unicode */
-            #define assert(_Expression) \
-                (void) \
-                ((!!(_Expression)) || \
-                (debug_break(),_assert(#_Expression,__FILE__,__LINE__),0))
-        #endif /* _UNICODE||UNICODE */
-    #else /* BOOST_OS_WINDOWS_AVAILABLE */
-        #define assert(_Expression) \
-            (void) \
-            ((!!(_Expression)) || \
-            (debug_break(),__assert(#_Expression,__FILE__,__LINE__),0))
-    #endif /* BOOST_OS_WINDOWS_AVAILABLE */
-#endif /* !defined (NDEBUG) */

+ 0 - 2
src/utility/coro_signal2.hpp

@@ -22,8 +22,6 @@
 
 #endif
 
-#include "utility/assert_utility.h"
-
 namespace sophiar {
 
     class coro_signal2;

+ 0 - 2
src/utility/coro_unique_lock.hpp

@@ -3,8 +3,6 @@
 
 #include "utility/coro_signal2.hpp"
 
-#include "utility/assert_utility.h"
-
 namespace sophiar {
 
     class coro_unique_lock : private boost::noncopyable {

+ 0 - 2
src/utility/debug_utility.hpp

@@ -15,8 +15,6 @@
 
 #include <iostream>
 
-#include "utility/assert_utility.h"
-
 #define DEBUG_PRINT(msg) \
     std::cout << fmt::format("F:{} L:{} T:{} {}", \
                              __FILE__, __LINE__, current_timestamp(), msg) \

+ 0 - 2
src/utility/name_translator.hpp

@@ -6,8 +6,6 @@
 #include <string>
 #include <unordered_map>
 
-#include "utility/assert_utility.h"
-
 namespace sophiar {
 
     template<typename IndexType>

+ 0 - 2
src/utility/named_vector.hpp

@@ -6,8 +6,6 @@
 #include <climits>
 #include <vector>
 
-#include "utility/assert_utility.h"
-
 namespace sophiar {
 
     template<typename IndexType, typename ElemType = bool>

+ 0 - 2
src/utility/string_map.hpp

@@ -6,8 +6,6 @@
 #include <type_traits>
 #include <unordered_map>
 
-#include "utility/assert_utility.h"
-
 namespace sophiar {
 
     template<typename T>

+ 0 - 2
src/utility/versatile_buffer2.hpp

@@ -19,8 +19,6 @@
 #include <string_view>
 #include <type_traits>
 
-#include "utility/assert_utility.h"
-
 namespace sophiar {
 
     template<size_t Length>