Added a chXXXDispose() function to all objects in NIL.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@15215 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
Giovanni Di Sirio 2021-12-07 14:35:54 +00:00
parent a259221a21
commit 957db8ed26
7 changed files with 70 additions and 41 deletions

View File

@ -30,6 +30,8 @@
#ifndef CH_H
#define CH_H
#include <string.h>
#include "chtypes.h"
/*===========================================================================*/
@ -1226,16 +1228,25 @@ struct nil_os_instance {
/**
* @brief Initializes a threads queue object.
*
* @param[out] tqp pointer to the threads queue object
* @param[out] tqp pointer to a @p threads_queue_t structure
*
* @init
*/
#define chThdQueueObjectInit(tqp) ((tqp)->cnt = (cnt_t)0)
/**
* @brief Disposes a threads queue.
*
* @param[in] tqp pointer to a @p threads_queue_t structure
*
* @dispose
*/
#define chThdObjectDispose(tqp) ((void) tqp)
/**
* @brief Evaluates to @p true if the specified queue is empty.
*
* @param[out] tqp pointer to the threads queue object
* @param[out] tqp pointer to a @p threads_queue_t structure
* @return The queue status.
* @retval false if the queue is not empty.
* @retval true if the queue is empty.

View File

@ -119,7 +119,7 @@ typedef void (*evhandler_t)(eventid_t id);
* @note This function can be invoked before the kernel is initialized
* because it just prepares a @p event_source_t structure.
*
* @param[in] esp pointer to the @p event_source_t structure
* @param[in] esp pointer to an @p event_source_t structure
*
* @init
*/
@ -127,6 +127,15 @@ typedef void (*evhandler_t)(eventid_t id);
(esp)->next = (event_listener_t *)(esp); \
} while (0)
/**
* @brief Disposes an Event Source.
*
* @param[in] esp pointer to an @p event_source_t structure
*
* @dispose
*/
#define chEvtObjectDispose(esp) ((void) esp)
/**
* @brief Registers an Event Listener on an Event Source.
* @details Once a thread has registered as listener on an event source it
@ -134,8 +143,8 @@ typedef void (*evhandler_t)(eventid_t id);
* @note Multiple Event Listeners can specify the same bits to be ORed to
* different threads.
*
* @param[in] esp pointer to the @p event_source_t structure
* @param[out] elp pointer to the @p event_listener_t structure
* @param[in] esp pointer to an @p event_source_t structure
* @param[out] elp pointer to an @p event_listener_t structure
* @param[in] events the mask of events to be ORed to the thread when
* the event source is broadcasted
*
@ -149,8 +158,8 @@ typedef void (*evhandler_t)(eventid_t id);
* @note Multiple Event Listeners can use the same event identifier, the
* listener will share the callback function.
*
* @param[in] esp pointer to the @p event_source_t structure
* @param[out] elp pointer to the @p event_listener_t structure
* @param[in] esp pointer to an @p event_source_t structure
* @param[out] elp pointer to an @p event_listener_t structure
* @param[in] event numeric identifier assigned to the Event Listener.
* The value must range between zero and the size, in bit,
* of the @p eventmask_t type minus one.
@ -163,7 +172,7 @@ typedef void (*evhandler_t)(eventid_t id);
/**
* @brief Verifies if there is at least one @p event_listener_t registered.
*
* @param[in] esp pointer to the @p event_source_t structure
* @param[in] esp pointer to an @p event_source_t structure
* @return The event source status.
*
* @iclass
@ -174,7 +183,7 @@ typedef void (*evhandler_t)(eventid_t id);
* @brief Signals all the Event Listeners registered on the specified Event
* Source.
*
* @param[in] esp pointer to the @p event_source_t structure
* @param[in] esp pointer to an @p event_source_t structure
*
* @api
*/
@ -188,7 +197,7 @@ typedef void (*evhandler_t)(eventid_t id);
* interrupt handlers always reschedule on exit so an explicit
* reschedule must not be performed in ISRs.
*
* @param[in] esp pointer to the @p event_source_t structure
* @param[in] esp pointer to an @p event_source_t structure
*
* @iclass
*/

View File

@ -92,6 +92,15 @@
*/
#define chSemObjectInit(sp, n) ((sp)->cnt = (n))
/**
* @brief Disposes a semaphore.
*
* @param[in] sp pointer to a @p semaphore_t structure
*
* @dispose
*/
#define chSemObjectDispose(sp, n) ((void) sp)
/**
* @brief Performs a reset operation on the semaphore.
* @post After invoking this function all the threads waiting on the

View File

@ -987,7 +987,7 @@ void chThdSleepUntil(systime_t abstime) {
* @details The caller thread is enqueued and put to sleep until it is
* dequeued or the specified timeouts expires.
*
* @param[in] tqp pointer to the threads queue object
* @param[in] tqp pointer to a @p threads_queue_t structure
* @param[in] timeout the timeout in system ticks, the special values are
* handled as follow:
* - @a TIME_IMMEDIATE immediate timeout.
@ -1024,7 +1024,7 @@ msg_t chThdEnqueueTimeoutS(threads_queue_t *tqp, sysinterval_t timeout) {
* is empty.
* @pre The queue must contain at least an object.
*
* @param[in] tqp pointer to the threads queue object
* @param[in] tqp pointer to a @p threads_queue_t structure
* @param[in] msg the message code
*
* @iclass
@ -1046,7 +1046,7 @@ void chThdDoDequeueNextI(threads_queue_t *tqp, msg_t msg) {
* @brief Dequeues and wakes up one thread from the threads queue object,
* if any.
*
* @param[in] tqp pointer to the threads queue object
* @param[in] tqp pointer to a @p threads_queue_t structure
* @param[in] msg the message code
*
* @iclass
@ -1064,7 +1064,7 @@ void chThdDequeueNextI(threads_queue_t *tqp, msg_t msg) {
/**
* @brief Dequeues and wakes up all threads from the threads queue object.
*
* @param[in] tqp pointer to the threads queue object
* @param[in] tqp pointer to a @p threads_queue_t structure
* @param[in] msg the message code
*
* @iclass

View File

@ -60,8 +60,8 @@
* @note Multiple Event Listeners can specify the same bits to be ORed to
* different threads.
*
* @param[in] esp pointer to the @p event_source_t structure
* @param[in] elp pointer to the @p event_listener_t structure
* @param[in] esp pointer to an @p event_source_t structure
* @param[in] elp pointer to an @p event_listener_t structure
* @param[in] events events to be ORed to the thread when
* the event source is broadcasted
* @param[in] wflags mask of flags the listening thread is interested in
@ -93,8 +93,8 @@ void chEvtRegisterMaskWithFlags(event_source_t *esp,
* operations in inverse order of the register operations (elements
* are found on top of the list).
*
* @param[in] esp pointer to the @p event_source_t structure
* @param[in] elp pointer to the @p event_listener_t structure
* @param[in] esp pointer to an @p event_source_t structure
* @param[in] elp pointer to an @p event_listener_t structure
*
* @api
*/
@ -185,7 +185,7 @@ eventmask_t chEvtAddEvents(eventmask_t events) {
* interrupt handlers always reschedule on exit so an explicit
* reschedule must not be performed in ISRs.
*
* @param[in] esp pointer to the @p event_source_t structure
* @param[in] esp pointer to an @p event_source_t structure
* @param[in] flags the flags set to be added to the listener flags mask
*
* @iclass
@ -216,7 +216,7 @@ void chEvtBroadcastFlagsI(event_source_t *esp, eventflags_t flags) {
* @details The flags are returned and the @p event_listener_t flags mask is
* cleared.
*
* @param[in] elp pointer to the @p event_listener_t structure
* @param[in] elp pointer to an @p event_listener_t structure
* @return The flags added to the listener by the associated
* event source.
*
@ -283,7 +283,7 @@ void chEvtSignalI(thread_t *tp, eventmask_t events) {
* event flags specified by the threads themselves in the
* @p event_listener_t objects.
*
* @param[in] esp pointer to the @p event_source_t structure
* @param[in] esp pointer to an @p event_source_t structure
* @param[in] flags the flags set to be added to the listener flags mask
*
* @api
@ -301,7 +301,7 @@ void chEvtBroadcastFlags(event_source_t *esp, eventflags_t flags) {
* @details The flags are returned and the @p event_listener_t flags mask is
* cleared.
*
* @param[in] elp pointer to the @p event_listener_t structure
* @param[in] elp pointer to an @p event_listener_t structure
* @return The flags added to the listener by the associated
* event source.
*

View File

@ -172,8 +172,8 @@ extern "C" {
* @note Multiple Event Listeners can specify the same bits to be ORed to
* different threads.
*
* @param[in] esp pointer to the @p event_source_t structure
* @param[out] elp pointer to a @p event_listener_t structure
* @param[in] esp pointer to an @p event_source_t structure
* @param[out] elp pointer to an @p event_listener_t structure
* @param[in] events the mask of events to be ORed to the thread when
* the event source is broadcasted
*
@ -191,8 +191,8 @@ static inline void chEvtRegisterMask(event_source_t *esp,
* @note Multiple Event Listeners can use the same event identifier, the
* listener will share the callback function.
*
* @param[in] esp pointer to a @p event_source_t structure
* @param[out] elp pointer to a @p event_listener_t structure
* @param[in] esp pointer to an @p event_source_t structure
* @param[out] elp pointer to an @p event_listener_t structure
* @param[in] event numeric identifier assigned to the Event Listener.
* The value must range between zero and the size, in bit,
* of the @p eventmask_t type minus one.
@ -209,7 +209,7 @@ static inline void chEvtRegister(event_source_t *esp,
/**
* @brief Verifies if there is at least one @p event_listener_t registered.
*
* @param[in] esp pointer to the @p event_source_t structure
* @param[in] esp pointer to an @p event_source_t structure
* @return The event source status.
*
* @iclass
@ -223,7 +223,7 @@ static inline bool chEvtIsListeningI(event_source_t *esp) {
* @brief Signals all the Event Listeners registered on the specified Event
* Source.
*
* @param[in] esp pointer to the @p event_source_t structure
* @param[in] esp pointer to an @p event_source_t structure
*
* @api
*/
@ -240,7 +240,7 @@ static inline void chEvtBroadcast(event_source_t *esp) {
* interrupt handlers always reschedule on exit so an explicit
* reschedule must not be performed in ISRs.
*
* @param[in] esp pointer to the @p event_source_t structure
* @param[in] esp pointer to an @p event_source_t structure
*
* @iclass
*/

View File

@ -92,7 +92,7 @@
* @note This function can be invoked before the kernel is initialized
* because it just prepares a @p event_source_t structure.
*
* @param[in] esp pointer to the @p event_source_t structure
* @param[in] esp pointer to an @p event_source_t structure
*
* @init
*/
@ -114,7 +114,7 @@ void chEvtObjectInit(event_source_t *esp) {
* of @p NULL pointers rather than dereferencing previously valid
* pointers.
*
* @param[in] esp pointer to the @p event_source_t structure
* @param[in] esp pointer to an @p event_source_t structure
*
* @dispose
*/
@ -135,8 +135,8 @@ void chEvtObjectDispose(event_source_t *esp) {
* @note Multiple Event Listeners can specify the same bits to be ORed to
* different threads.
*
* @param[in] esp pointer to a @p event_source_t structure
* @param[in] elp pointer to a @p event_listener_t structure
* @param[in] esp pointer to an @p event_source_t structure
* @param[in] elp pointer to an @p event_listener_t structure
* @param[in] events events to be ORed to the thread when
* the event source is broadcasted
* @param[in] wflags mask of flags the listening thread is interested in
@ -167,8 +167,8 @@ void chEvtRegisterMaskWithFlagsI(event_source_t *esp,
* @note Multiple Event Listeners can specify the same bits to be ORed to
* different threads.
*
* @param[in] esp pointer to a @p event_source_t structure
* @param[in] elp pointer to a @p event_listener_t structure
* @param[in] esp pointer to an @p event_source_t structure
* @param[in] elp pointer to an @p event_listener_t structure
* @param[in] events events to be ORed to the thread when
* the event source is broadcasted
* @param[in] wflags mask of flags the listening thread is interested in
@ -193,8 +193,8 @@ void chEvtRegisterMaskWithFlags(event_source_t *esp,
* operations in inverse order of the register operations (elements
* are found on top of the list).
*
* @param[in] esp pointer to a @p event_source_t structure
* @param[in] elp pointer to a @p event_listener_t structure
* @param[in] esp pointer to an @p event_source_t structure
* @param[in] elp pointer to an @p event_listener_t structure
*
* @api
*/
@ -281,7 +281,7 @@ eventmask_t chEvtAddEvents(eventmask_t events) {
* @details The flags are returned and the @p event_listener_t flags mask is
* cleared.
*
* @param[in] elp pointer to a @p event_listener_t structure
* @param[in] elp pointer to an @p event_listener_t structure
* @return The flags added to the listener by the associated
* event source.
*
@ -304,7 +304,7 @@ eventflags_t chEvtGetAndClearFlagsI(event_listener_t *elp) {
* @details The flags are returned and the @p event_listener_t flags mask is
* cleared.
*
* @param[in] elp pointer to a @p event_listener_t structure
* @param[in] elp pointer to an @p event_listener_t structure
* @return The flags added to the listener by the associated
* event source.
*
@ -381,7 +381,7 @@ void chEvtSignal(thread_t *tp, eventmask_t events) {
* interrupt handlers always reschedule on exit so an explicit
* reschedule must not be performed in ISRs.
*
* @param[in] esp pointer to the @p event_source_t structure
* @param[in] esp pointer to an @p event_source_t structure
* @param[in] flags the flags set to be added to the listener flags mask
*
* @iclass
@ -415,7 +415,7 @@ void chEvtBroadcastFlagsI(event_source_t *esp, eventflags_t flags) {
* event flags specified by the threads themselves in the
* @p event_listener_t objects.
*
* @param[in] esp pointer to the @p event_source_t structure
* @param[in] esp pointer to an @p event_source_t structure
* @param[in] flags the flags set to be added to the listener flags mask
*
* @api