diff --git a/demos/STM32/RT-STM32L4R9-DISCOVERY-RAM_SB_HOST_DYNAMIC/debug/RT-STM32L4R9-DISCOVERY-RAM_SB_HOST_DYNAMIC (SB1)(build-ch.elf)(OpenOCD, Flash and Run).launch b/demos/STM32/RT-STM32L4R9-DISCOVERY-RAM_SB_HOST_DYNAMIC/debug/RT-STM32L4R9-DISCOVERY-RAM_SB_HOST_DYNAMIC (SB1)(build-ch.elf)(OpenOCD, Flash and Run).launch index 9806cd16b..90cbc6ed5 100644 --- a/demos/STM32/RT-STM32L4R9-DISCOVERY-RAM_SB_HOST_DYNAMIC/debug/RT-STM32L4R9-DISCOVERY-RAM_SB_HOST_DYNAMIC (SB1)(build-ch.elf)(OpenOCD, Flash and Run).launch +++ b/demos/STM32/RT-STM32L4R9-DISCOVERY-RAM_SB_HOST_DYNAMIC/debug/RT-STM32L4R9-DISCOVERY-RAM_SB_HOST_DYNAMIC (SB1)(build-ch.elf)(OpenOCD, Flash and Run).launch @@ -11,12 +11,13 @@ + - + @@ -34,6 +35,7 @@ + diff --git a/demos/STM32/RT-STM32L4R9-DISCOVERY-RAM_SB_HOST_DYNAMIC/debug/RT-STM32L4R9-DISCOVERY-RAM_SB_HOST_DYNAMIC (SB1)(build-ch.elf)(OpenOCD, Just Run).launch b/demos/STM32/RT-STM32L4R9-DISCOVERY-RAM_SB_HOST_DYNAMIC/debug/RT-STM32L4R9-DISCOVERY-RAM_SB_HOST_DYNAMIC (SB1)(build-ch.elf)(OpenOCD, Just Run).launch index e6112b7ce..9d40a5cfd 100644 --- a/demos/STM32/RT-STM32L4R9-DISCOVERY-RAM_SB_HOST_DYNAMIC/debug/RT-STM32L4R9-DISCOVERY-RAM_SB_HOST_DYNAMIC (SB1)(build-ch.elf)(OpenOCD, Just Run).launch +++ b/demos/STM32/RT-STM32L4R9-DISCOVERY-RAM_SB_HOST_DYNAMIC/debug/RT-STM32L4R9-DISCOVERY-RAM_SB_HOST_DYNAMIC (SB1)(build-ch.elf)(OpenOCD, Just Run).launch @@ -11,12 +11,13 @@ + - + @@ -34,6 +35,7 @@ + diff --git a/os/common/utils/include/oop_base_object.h b/os/common/utils/include/oop_base_object.h deleted file mode 100644 index 94a9b0c03..000000000 --- a/os/common/utils/include/oop_base_object.h +++ /dev/null @@ -1,172 +0,0 @@ -/* - ChibiOS - Copyright (C) 2006..2021 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -/** - * @file oop_base_object.h - * @brief Base object. - * @details This header defines a base class that is the root class of - * the ChibiOS Object Model. - * - * @addtogroup OOP_BASE_OBJECT - * @details ChibiOS uses concepts of Object Oriented Programming even if - * it is written in C. Things like simple inheritance, multiple - * inheritance and interfaces are used through the system. - * This module defines a "base object" class that is the ancestor - * of all classes in the system.
- * Class types are denoted by a "_c" suffix, classes contain a - * virtual methods table and data encapsulated into a normal C - * structure.
- * Interfaces are denoted by a "_i" suffix, interfaces just have - * a virtual methods table as single member of their C structure.
- * The first field of a VMT is the offset between the container - * object and the VMT pointer.
- * Multiple inheritance is implemented by composing a class - * structure with the structures of implemented classes or - * interfaces.
- * Example: - * - * // Defining a counter interface. - * typedef struct { - * const struct __counter_interface_vmt *vmt; - * } counter_interface_i; - * - * // Defining a beans interface. - * typedef struct { - * const struct __beans_interface_vmt *vmt; - * } beans_interface_i; - * - * // Definition of a class myclass_c implementing interfaces - * // counter_interface_i and beans_interface_i. - * typedef struct { - * const struct __myclass_vmt *vmt; - * // Fields of myclass. - * counter_interface_i counter; - * beans_interface_i beans; - * } myclass_c; - * - * @{ - */ - -#ifndef OOP_BASE_OBJECT_H -#define OOP_BASE_OBJECT_H - -#include "ccportab.h" -#include "osal.h" - -/** - * @brief Type of a base object class. - * @details This class represents a generic object including a virtual - * methods table (VMT). - * @note This class is compatible with the legacy HAL @p BaseObject class. - */ -typedef struct base_object base_object_c; - -/** - * @brief @p base_object_c specific methods. - * @note This object defines no methods. - */ -#define __base_object_methods \ - /* Instance offset, used for multiple inheritance, normally zero. It - represents the offset between the current object and the container - object*/ \ - size_t instance_offset; - -/** - * @brief @p base_object_c specific data. - * @note This object defines no data. - */ -#define __base_object_data - -/** - * @brief @p base_object_c virtual methods table. - */ -struct __base_object_vmt { - __base_object_methods -}; - -/** - * @brief Structure representing a base object class. - */ -struct base_object { - /** - * @brief Virtual Methods Table. - */ - const struct __base_object_vmt *vmt; - __base_object_data -}; - -/** - * @name Methods implementations - * @{ - */ -/** - * @brief Object creation implementation. - * - * @param[in] ip Pointer to a @p base_object_c structure to be - * initialized. - * @param[in] vmt VMT pointer for the new object. - * @return A new reference to the object. - */ -CC_FORCE_INLINE -static inline void *__base_object_objinit_impl(void *ip, const void *vmt) { - base_object_c *objp = (base_object_c *)ip; - - objp->vmt = (struct __base_object_vmt *)vmt; - - return ip; -} - -/** - * @brief Object finalization implementation. - * - * @param[in] ip Pointer to a @p base_object_c structure to be - * disposed. - */ -CC_FORCE_INLINE -static inline void __base_object_dispose_impl(void *ip) { - - (void) ip; - - /* Nothing.*/ -} -/** @} */ - -/** - * @name OOP Utility macros - * @{ - */ -/** - * @brief Returns the object instance pointer starting from an interface - * pointer. - * @details Because multiple inheritance, an object can be composed by - * multiple interfaces and/or classes (its ancestors).
- * This function returns the pointer to the base object starting - * from a pointer to any of its composing classes or interfaces.
- * This is done by leveraging the offset field into each VMT table. - * - * @param[in] c The class type of the object. - * @param[in] ip A pointer to one of the object composing classes or - * interfaces. - * @return A pointer to an object of type @p type implementing - * the interface @p ip. - */ -#define oopGetInstance(c, ip) \ - (c)(((size_t)(ip)) - (ip)->vmt->instance_offset) -/** @} */ - -#endif /* OOP_BASE_OBJECT_H */ - -/** @} */ diff --git a/os/common/utils/include/oop_referenced_object.h b/os/common/utils/include/oop_referenced_object.h deleted file mode 100644 index 4f31a8312..000000000 --- a/os/common/utils/include/oop_referenced_object.h +++ /dev/null @@ -1,186 +0,0 @@ -/* - ChibiOS - Copyright (C) 2006..2021 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -/** - * @file oop_referenced_object.h - * @brief Base class for objects with a reference counter. - * @details This header defines a base class for classes requiring a - * a reference counter and a disposing mechanism. - * - * @addtogroup OOP_REFERENCED_OBJECT - * @details Base class for objects that implement a reference counter and - * are disposed when the number of references reaches zero. - * This class extends @p base_object_c class. - * @{ - */ - -#ifndef OOP_REFERENCED_OBJECT_H -#define OOP_REFERENCED_OBJECT_H - -#include "oop_base_object.h" - -/** - * @brief Type of a referenced object class. - */ -typedef struct referenced_object referenced_object_c; - -/** - * @brief @p referenced_object_c specific methods. - * @note This object defines no methods. - */ -#define __referenced_object_methods \ - __base_object_methods \ - void *(*addref)(void *ip); \ - unsigned (*release)(void *ip); - -/** - * @brief @p referenced_object_c specific data. - */ -#define __referenced_object_data \ - __base_object_data \ - unsigned references; - - -/** - * @brief @p referenced_object_c virtual methods table. - */ -struct __referenced_object_vmt { \ - __referenced_object_methods \ -}; - -/** - * @brief Structure representing a referenced object class. - */ -struct referenced_object { - /** - * @brief Virtual Methods Table. - */ - const struct __referenced_object_vmt *vmt; - __referenced_object_data -}; - -/** - * @name Methods implementations - * @{ - */ -/** - * @brief Object creation implementation. - * - * @param[in] ip Pointer to a @p referenced_object_c structure to be - * initialized. - * @param[in] vmt VMT pointer for the new object. - * @return A new reference to the object. - */ -CC_FORCE_INLINE -static inline void *__referenced_object_objinit_impl(void *ip, const void *vmt) { - referenced_object_c *objp = (referenced_object_c *)ip; - - __base_object_objinit_impl(ip, vmt); - objp->references = 1U; - - return ip; -} - -/** - * @brief Object finalization implementation. - * - * @param[in] ip Pointer to a @p referenced_object_c structure to be - * disposed. - */ -CC_FORCE_INLINE -static inline void __referenced_object_dispose_impl(void *ip) { - - __base_object_dispose_impl(ip); - /* Nothing.*/ -} - -/** - * @brief New reference creation implementation. - * - * @param[in] ip A reference to the object. - * @return A new reference to the object. - */ -CC_FORCE_INLINE -static inline void *__referenced_object_addref_impl(void *ip) { - referenced_object_c *objp = (referenced_object_c *)ip; - - objp->references++; - - return ip; -} - -/** - * @brief References get implementation. - * - * @param[in] ip A reference to the object. - * @return Remaining references. - */ -CC_FORCE_INLINE -static inline unsigned __referenced_object_getref_impl(void *ip) { - referenced_object_c *objp = (referenced_object_c *)ip; - - return objp->references; -} - -/** - * @brief Reference release implementation. - * - * @param[in] ip A reference to the object. - * @return The number of references left. - */ -CC_FORCE_INLINE -static inline unsigned __referenced_object_release_impl(void *ip) { - referenced_object_c *objp = (referenced_object_c *)ip; - - osalDbgAssert(objp->references > 0U, "zero references"); - - if (--objp->references == 0U) { - __referenced_object_dispose_impl(ip); - } - - return objp->references; -} -/** @} */ - -/** - * @brief New reference creation. - * - * @param[in] ip A reference to the object. - * @return A new reference to the object. - */ -CC_FORCE_INLINE -static inline referenced_object_c *roAddRef(void *ip) { - referenced_object_c *objp = (referenced_object_c *)ip; - - return objp->vmt->addref(ip); -} - -/** - * @brief Reference release. - * - * @param[in] ip A reference to the object. - * @return The number of references left. - */ -CC_FORCE_INLINE -static inline unsigned roRelease(void *ip) { - referenced_object_c *objp = (referenced_object_c *)ip; - - return objp->vmt->release(ip); -} - -#endif /* OOP_REFERENCED_OBJECT_H */ - -/** @} */ diff --git a/os/common/utils/include/oop_synchronized_object.h b/os/common/utils/include/oop_synchronized_object.h deleted file mode 100644 index 4558c7719..000000000 --- a/os/common/utils/include/oop_synchronized_object.h +++ /dev/null @@ -1,162 +0,0 @@ -/* - ChibiOS - Copyright (C) 2006..2021 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -/** - * @file oop_synchronized_object.h - * @brief Base class for objects supporting synchronization. - * @details This header defines a base class for classes requiring a - * synchronization mechanism. - * - * @addtogroup OOP_SYNCHRONIZED_OBJECT - * @details Base class for objects that require a synchronization mechanism. - * This class extends @p base_object_c class. - * @{ - */ - -#ifndef OOP_SYNCHRONIZED_OBJECT_H -#define OOP_SYNCHRONIZED_OBJECT_H - -#include "osal.h" -#include "oop_synchronized_object.h" - -/** - * @brief Type of a synchronized object class. - */ -typedef struct synchronized_object synchronized_object_c; - -/** - * @brief @p synchronized_object_c specific methods. - * @note This object defines no methods. - */ -#define __synchronized_object_methods \ - __base_object_methods - -/** - * @brief @p synchronized_object_c specific data. - */ -#define __synchronized_object_data \ - __base_object_data \ - mutex_t mutex; - - -/** - * @brief @p synchronized_object_c virtual methods table. - */ -struct __synchronized_object_vmt { \ - __synchronized_object_methods \ -}; - -/** - * @brief Structure representing a synchronized object class. - */ -struct synchronized_object { - /** - * @brief Virtual Methods Table. - */ - const struct __synchronized_object_vmt *vmt; - __synchronized_object_data -}; - -/** - * @name Methods implementations - * @{ - */ -/** - * @brief Object creation implementation. - * - * @param[in] ip Pointer to a @p synchronized_object_c structure to be - * initialized. - * @param[in] vmt VMT pointer for the new object. - * @return A new reference to the object. - */ -CC_FORCE_INLINE -static inline void *__synchronized_object_objinit_impl(void *ip, const void *vmt) { - synchronized_object_c *objp = (synchronized_object_c *)ip; - - __base_object_objinit_impl(ip, vmt); - osalMutexObjectInit(&objp->mutex); - - return ip; -} - -/** - * @brief Object finalization implementation. - * - * @param[in] ip Pointer to a @p synchronized_object_c structure to be - * disposed. - */ -CC_FORCE_INLINE -static inline void __synchronized_object_dispose_impl(void *ip) { - - __base_object_dispose_impl(ip); - /* Nothing.*/ - /* TODO add RT objects disposing when available.*/ -} - -/** - * @brief Object lock implementation. - * - * @param[in] ip Pointer to a @p synchronized_object_c structure to be - * locked. - */ -CC_FORCE_INLINE -static inline void __synchronized_object_lock_impl(void *ip) { - synchronized_object_c *objp = (synchronized_object_c *)ip; - - osalMutexLock(&objp->mutex); -} - -/** - * @brief Object unlock implementation. - * - * @param[in] ip Pointer to a @p synchronized_object_c structure to be - * unlocked. - */ -CC_FORCE_INLINE -static inline void __synchronized_object_unlock_impl(void *ip) { - synchronized_object_c *objp = (synchronized_object_c *)ip; - - osalMutexUnlock(&objp->mutex); -} -/** @} */ - -/** - * @brief Object lock. - * - * @param[in] ip Pointer to a @p synchronized_object_c structure to be - * locked. - */ -CC_FORCE_INLINE -static inline void soLock(synchronized_object_c *sop) { - - __synchronized_object_lock_impl(sop); -} - -/** - * @brief Object unlock. - * - * @param[in] ip Pointer to a @p synchronized_object_c structure to be - * unlocked. - */ -CC_FORCE_INLINE -static inline void soUnlock(synchronized_object_c *sop) { - - __synchronized_object_unlock_impl(sop); -} - -#endif /* OOP_SYNCHRONIZED_OBJECT_H */ - -/** @} */ diff --git a/os/common/utils/src/paths.c b/os/common/utils/src/paths.c index ab76049c4..0391baca3 100644 --- a/os/common/utils/src/paths.c +++ b/os/common/utils/src/paths.c @@ -192,8 +192,8 @@ size_t path_add_separator(char *dst, size_t size) { size_t path_add_extension(char *dst, const char *ext, size_t size) { size_t dn, en; - dn = strnlen(dst, size - 1U); - en = strnlen(ext, size - 1U); + dn = strlen(dst); + en = strlen(ext); if ((dn < en) || (strcmp(dst + dn - en, ext) != 0)) { if (dn + en >= size) { return 0U; diff --git a/os/vfs/src/vfspaths.c b/os/vfs/src/vfspaths.c index 3f2ffa5f5..dcd0680ac 100644 --- a/os/vfs/src/vfspaths.c +++ b/os/vfs/src/vfspaths.c @@ -188,8 +188,8 @@ size_t vfs_path_add_separator(char *dst, size_t size) { size_t vfs_path_add_extension(char *dst, const char *ext, size_t size) { size_t dn, en; - dn = strnlen(dst, size - 1U); - en = strnlen(ext, size - 1U); + dn = strlen(dst); + en = strlen(ext); if ((dn < en) || (strcmp(dst + dn - en, ext) != 0)) { if (dn + en >= size) { return 0U;