From cfa77b13a4ade17fcb2ece403f6d8f1bea734161 Mon Sep 17 00:00:00 2001 From: Ben Dyer Date: Fri, 21 Aug 2015 15:57:04 +1000 Subject: [PATCH] Add UAVCAN_NO_GLOBAL_DATA_TYPE_REGISTRY flag to allow the global data type registry to be disabled --- libuavcan/include/uavcan/build_config.hpp | 7 +++++++ .../include/uavcan/node/global_data_type_registry.hpp | 2 ++ 2 files changed, 9 insertions(+) diff --git a/libuavcan/include/uavcan/build_config.hpp b/libuavcan/include/uavcan/build_config.hpp index 6b8768c3e5..7fa799def8 100644 --- a/libuavcan/include/uavcan/build_config.hpp +++ b/libuavcan/include/uavcan/build_config.hpp @@ -100,6 +100,13 @@ # define UAVCAN_TINY 0 #endif +/** + * Disable the global data type registry, which can save some space on embedded systems. + */ +#ifndef UAVCAN_NO_GLOBAL_DATA_TYPE_REGISTRY +# define UAVCAN_NO_GLOBAL_DATA_TYPE_REGISTRY 1 +#endif + /** * toString() methods will be disabled by default, unless the library is built for a general-purpose target like Linux. * It is not recommended to enable toString() on embedded targets as code size will explode. diff --git a/libuavcan/include/uavcan/node/global_data_type_registry.hpp b/libuavcan/include/uavcan/node/global_data_type_registry.hpp index cedf0d9724..fb8d43c39b 100644 --- a/libuavcan/include/uavcan/node/global_data_type_registry.hpp +++ b/libuavcan/include/uavcan/node/global_data_type_registry.hpp @@ -187,6 +187,7 @@ struct UAVCAN_EXPORT DefaultDataTypeRegistrator { DefaultDataTypeRegistrator() { +#if !UAVCAN_NO_GLOBAL_DATA_TYPE_REGISTRY const GlobalDataTypeRegistry::RegistrationResult res = GlobalDataTypeRegistry::instance().registerDataType(Type::DefaultDataTypeID); @@ -194,6 +195,7 @@ struct UAVCAN_EXPORT DefaultDataTypeRegistrator { handleFatalError("Type reg failed"); } +#endif } };