aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2013-07-19 13:17:42 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2013-07-19 13:17:42 +0000
commitd58064a533743df77e52f9d76385a9e0ea1d0227 (patch)
tree2e76847d1640e8c9f27a0c2fc0bf8ce60ba4b0b4
parent84e044f176cee7c6946b24c36c90f63534b5b369 (diff)
downloadChibiOS-d58064a533743df77e52f9d76385a9e0ea1d0227.tar.gz
ChibiOS-d58064a533743df77e52f9d76385a9e0ea1d0227.tar.bz2
ChibiOS-d58064a533743df77e52f9d76385a9e0ea1d0227.zip
Still work in progress.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@5996 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r--os/kernel/include/chbsem.h147
-rw-r--r--os/kernel/include/chcond.h76
-rw-r--r--os/kernel/include/chdynamic.h28
-rw-r--r--os/kernel/include/chevents.h161
-rw-r--r--os/kernel/include/chmboxes.h8
-rw-r--r--os/kernel/include/chsem.h98
-rw-r--r--os/kernel/include/chvt.h52
-rw-r--r--os/kernel/src/chcond.c98
-rw-r--r--os/kernel/src/chdynamic.c24
-rw-r--r--os/kernel/src/chevents.c25
-rw-r--r--os/kernel/src/chschd.c4
-rw-r--r--os/kernel/src/chsem.c46
-rw-r--r--os/kernel/src/chvt.c12
-rw-r--r--test/test.c2
-rw-r--r--test/testbmk.c12
-rw-r--r--test/testsem.c4
16 files changed, 530 insertions, 267 deletions
diff --git a/os/kernel/include/chbsem.h b/os/kernel/include/chbsem.h
index 0cc6f8a95..fd9b0d3e2 100644
--- a/os/kernel/include/chbsem.h
+++ b/os/kernel/include/chbsem.h
@@ -53,14 +53,34 @@
#if CH_USE_SEMAPHORES || defined(__DOXYGEN__)
+/*===========================================================================*/
+/* Module constants. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module pre-compile time settings. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Derived constants and error checks. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module data structures and types. */
+/*===========================================================================*/
+
/**
- * @extends Semaphore
+ * @extends semaphore_t
*
* @brief Binary semaphore type.
*/
typedef struct {
- Semaphore bs_sem;
-} BinarySemaphore;
+ semaphore_t bs_sem;
+} binary_semaphore_t;
+
+/*===========================================================================*/
+/* Module macros. */
+/*===========================================================================*/
/**
* @brief Data part of a static semaphore initializer.
@@ -82,16 +102,20 @@ typedef struct {
* @param[in] taken the semaphore initial state
*/
#define BSEMAPHORE_DECL(name, taken) \
- BinarySemaphore name = _BSEMAPHORE_DATA(name, taken)
+ binary_semaphore_t name = _BSEMAPHORE_DATA(name, taken)
+
+/*===========================================================================*/
+/* External declarations. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module inline functions. */
+/*===========================================================================*/
-/**
- * @name Macro Functions
- * @{
- */
/**
* @brief Initializes a binary semaphore.
*
- * @param[out] bsp pointer to a @p BinarySemaphore structure
+ * @param[out] bsp pointer to a @p binary_semaphore_t structure
* @param[in] taken initial state of the binary semaphore:
* - @a FALSE, the initial state is not taken.
* - @a TRUE, the initial state is taken.
@@ -99,12 +123,15 @@ typedef struct {
*
* @init
*/
-#define chBSemInit(bsp, taken) chSemInit(&(bsp)->bs_sem, (taken) ? 0 : 1)
+static inline void chBSemInit(binary_semaphore_t *bsp, bool taken) {
+
+ chSemInit(&bsp->bs_sem, taken ? 0 : 1);
+}
/**
* @brief Wait operation on the binary semaphore.
*
- * @param[in] bsp pointer to a @p BinarySemaphore structure
+ * @param[in] bsp pointer to a @p binary_semaphore_t structure
* @return A message specifying how the invoking thread has been
* released from the semaphore.
* @retval RDY_OK if the binary semaphore has been successfully taken.
@@ -113,12 +140,15 @@ typedef struct {
*
* @api
*/
-#define chBSemWait(bsp) chSemWait(&(bsp)->bs_sem)
+static inline msg_t chBSemWait(binary_semaphore_t *bsp) {
+
+ return chSemWait(&bsp->bs_sem);
+}
/**
* @brief Wait operation on the binary semaphore.
*
- * @param[in] bsp pointer to a @p BinarySemaphore structure
+ * @param[in] bsp pointer to a @p binary_semaphore_t structure
* @return A message specifying how the invoking thread has been
* released from the semaphore.
* @retval RDY_OK if the binary semaphore has been successfully taken.
@@ -127,12 +157,17 @@ typedef struct {
*
* @sclass
*/
-#define chBSemWaitS(bsp) chSemWaitS(&(bsp)->bs_sem)
+static inline msg_t chBSemWaitS(binary_semaphore_t *bsp) {
+
+ chDbgCheckClassS();
+
+ return chSemWaitS(&bsp->bs_sem);
+}
/**
* @brief Wait operation on the binary semaphore.
*
- * @param[in] bsp pointer to a @p BinarySemaphore structure
+ * @param[in] bsp pointer to a @p binary_semaphore_t structure
* @param[in] time the number of ticks before the operation timeouts,
* the following special values are allowed:
* - @a TIME_IMMEDIATE immediate timeout.
@@ -146,14 +181,20 @@ typedef struct {
* @retval RDY_TIMEOUT if the binary semaphore has not been signaled or reset
* within the specified timeout.
*
- * @api
+ * @sclass
*/
-#define chBSemWaitTimeout(bsp, time) chSemWaitTimeout(&(bsp)->bs_sem, (time))
+static inline msg_t chBSemWaitTimeoutS(binary_semaphore_t *bsp,
+ systime_t time) {
+
+ chDbgCheckClassS();
+
+ return chSemWaitTimeoutS(&bsp->bs_sem, time);
+}
/**
* @brief Wait operation on the binary semaphore.
*
- * @param[in] bsp pointer to a @p BinarySemaphore structure
+ * @param[in] bsp pointer to a @p binary_semaphore_t structure
* @param[in] time the number of ticks before the operation timeouts,
* the following special values are allowed:
* - @a TIME_IMMEDIATE immediate timeout.
@@ -167,82 +208,102 @@ typedef struct {
* @retval RDY_TIMEOUT if the binary semaphore has not been signaled or reset
* within the specified timeout.
*
- * @sclass
+ * @api
*/
-#define chBSemWaitTimeoutS(bsp, time) chSemWaitTimeoutS(&(bsp)->bs_sem, (time))
+static inline msg_t chBSemWaitTimeout(binary_semaphore_t *bsp,
+ systime_t time) {
+
+ return chSemWaitTimeout(&bsp->bs_sem, time);
+}
/**
* @brief Reset operation on the binary semaphore.
* @note The released threads can recognize they were waked up by a reset
* rather than a signal because the @p bsemWait() will return
* @p RDY_RESET instead of @p RDY_OK.
+ * @note This function does not reschedule.
*
- * @param[in] bsp pointer to a @p BinarySemaphore structure
+ * @param[in] bsp pointer to a @p binary_semaphore_t structure
* @param[in] taken new state of the binary semaphore
* - @a FALSE, the new state is not taken.
* - @a TRUE, the new state is taken.
* .
*
- * @api
+ * @iclass
*/
-#define chBSemReset(bsp, taken) chSemReset(&(bsp)->bs_sem, (taken) ? 0 : 1)
+static inline void chBSemResetI(binary_semaphore_t *bsp, bool taken) {
+
+ chDbgCheckClassI();
+
+ chSemResetI(&bsp->bs_sem, taken ? 0 : 1);
+}
/**
* @brief Reset operation on the binary semaphore.
* @note The released threads can recognize they were waked up by a reset
* rather than a signal because the @p bsemWait() will return
* @p RDY_RESET instead of @p RDY_OK.
- * @note This function does not reschedule.
*
- * @param[in] bsp pointer to a @p BinarySemaphore structure
+ * @param[in] bsp pointer to a @p binary_semaphore_t structure
* @param[in] taken new state of the binary semaphore
* - @a FALSE, the new state is not taken.
* - @a TRUE, the new state is taken.
* .
*
- * @iclass
+ * @api
*/
-#define chBSemResetI(bsp, taken) chSemResetI(&(bsp)->bs_sem, (taken) ? 0 : 1)
+static inline void chBSemReset(binary_semaphore_t *bsp, bool taken) {
+
+ chSemReset(&bsp->bs_sem, taken ? 0 : 1);
+}
/**
* @brief Performs a signal operation on a binary semaphore.
+ * @note This function does not reschedule.
*
- * @param[in] bsp pointer to a @p BinarySemaphore structure
+ * @param[in] bsp pointer to a @p binary_semaphore_t structure
*
- * @api
+ * @iclass
*/
-#define chBSemSignal(bsp) { \
- chSysLock(); \
- chBSemSignalI((bsp)); \
- chSchRescheduleS(); \
- chSysUnlock(); \
+static inline void chBSemSignalI(binary_semaphore_t *bsp) {
+
+ chDbgCheckClassI();
+
+ if (bsp->bs_sem.s_cnt < 1)
+ chSemSignalI(&bsp->bs_sem);
}
/**
* @brief Performs a signal operation on a binary semaphore.
- * @note This function does not reschedule.
*
- * @param[in] bsp pointer to a @p BinarySemaphore structure
+ * @param[in] bsp pointer to a @p binary_semaphore_t structure
*
- * @iclass
+ * @api
*/
-#define chBSemSignalI(bsp) { \
- if ((bsp)->bs_sem.s_cnt < 1) \
- chSemSignalI(&(bsp)->bs_sem); \
+static inline void chBSemSignal(binary_semaphore_t *bsp) {
+
+ chSysLock();
+ chBSemSignalI(bsp);
+ chSchRescheduleS();
+ chSysUnlock();
}
/**
* @brief Returns the binary semaphore current state.
*
- * @param[in] bsp pointer to a @p BinarySemaphore structure
+ * @param[in] bsp pointer to a @p binary_semaphore_t structure
* @return The binary semaphore current state.
* @retval FALSE if the binary semaphore is not taken.
* @retval TRUE if the binary semaphore is taken.
*
* @iclass
*/
-#define chBSemGetStateI(bsp) ((bsp)->bs_sem.s_cnt > 0 ? FALSE : TRUE)
-/** @} */
+static inline bool chBSemGetStateI(binary_semaphore_t *bsp) {
+
+ chDbgCheckClassI();
+
+ return bsp->bs_sem.s_cnt > 0 ? FALSE : TRUE;
+}
#endif /* CH_USE_SEMAPHORES */
diff --git a/os/kernel/include/chcond.h b/os/kernel/include/chcond.h
index 202f4125c..d692310b6 100644
--- a/os/kernel/include/chcond.h
+++ b/os/kernel/include/chcond.h
@@ -34,37 +34,37 @@
#if CH_USE_CONDVARS || defined(__DOXYGEN__)
-/*
- * Module dependencies check.
- */
+/*===========================================================================*/
+/* Module constants. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module pre-compile time settings. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Derived constants and error checks. */
+/*===========================================================================*/
+
#if !CH_USE_MUTEXES
#error "CH_USE_CONDVARS requires CH_USE_MUTEXES"
#endif
+/*===========================================================================*/
+/* Module data structures and types. */
+/*===========================================================================*/
+
/**
- * @brief CondVar structure.
+ * @brief condition_variable_t structure.
*/
-typedef struct CondVar {
- threads_queue_t c_queue; /**< @brief CondVar threads queue.*/
-} CondVar;
+typedef struct condition_variable {
+ threads_queue_t c_queue; /**< @brief Condition variable
+ threads queue. */
+} condition_variable_t;
-#ifdef __cplusplus
-extern "C" {
-#endif
- void chCondInit(CondVar *cp);
- void chCondSignal(CondVar *cp);
- void chCondSignalI(CondVar *cp);
- void chCondBroadcast(CondVar *cp);
- void chCondBroadcastI(CondVar *cp);
- msg_t chCondWait(CondVar *cp);
- msg_t chCondWaitS(CondVar *cp);
-#if CH_USE_CONDVARS_TIMEOUT
- msg_t chCondWaitTimeout(CondVar *cp, systime_t time);
- msg_t chCondWaitTimeoutS(CondVar *cp, systime_t time);
-#endif
-#ifdef __cplusplus
-}
-#endif
+/*===========================================================================*/
+/* Module macros. */
+/*===========================================================================*/
/**
* @brief Data part of a static condition variable initializer.
@@ -82,7 +82,33 @@ extern "C" {
*
* @param[in] name the name of the condition variable
*/
-#define CONDVAR_DECL(name) CondVar name = _CONDVAR_DATA(name)
+#define CONDVAR_DECL(name) condition_variable_t name = _CONDVAR_DATA(name)
+
+/*===========================================================================*/
+/* External declarations. */
+/*===========================================================================*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+ void chCondInit(condition_variable_t *cp);
+ void chCondSignal(condition_variable_t *cp);
+ void chCondSignalI(condition_variable_t *cp);
+ void chCondBroadcast(condition_variable_t *cp);
+ void chCondBroadcastI(condition_variable_t *cp);
+ msg_t chCondWait(condition_variable_t *cp);
+ msg_t chCondWaitS(condition_variable_t *cp);
+#if CH_USE_CONDVARS_TIMEOUT
+ msg_t chCondWaitTimeout(condition_variable_t *cp, systime_t time);
+ msg_t chCondWaitTimeoutS(condition_variable_t *cp, systime_t time);
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+/*===========================================================================*/
+/* Module inline functions. */
+/*===========================================================================*/
#endif /* CH_USE_CONDVARS */
diff --git a/os/kernel/include/chdynamic.h b/os/kernel/include/chdynamic.h
index d28909aca..a8ba91a86 100644
--- a/os/kernel/include/chdynamic.h
+++ b/os/kernel/include/chdynamic.h
@@ -31,6 +31,18 @@
#if CH_USE_DYNAMIC || defined(__DOXYGEN__)
+/*===========================================================================*/
+/* Module constants. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module pre-compile time settings. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Derived constants and error checks. */
+/*===========================================================================*/
+
/*
* Module dependencies check.
*/
@@ -41,6 +53,18 @@
#error "CH_USE_DYNAMIC requires CH_USE_HEAP and/or CH_USE_MEMPOOLS"
#endif
+/*===========================================================================*/
+/* Module data structures and types. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module macros. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* External declarations. */
+/*===========================================================================*/
+
/*
* Dynamic threads APIs.
*/
@@ -61,6 +85,10 @@ extern "C" {
}
#endif
+/*===========================================================================*/
+/* Module inline functions. */
+/*===========================================================================*/
+
#endif /* CH_USE_DYNAMIC */
#endif /* _CHDYNAMIC_H_ */
diff --git a/os/kernel/include/chevents.h b/os/kernel/include/chevents.h
index 87996353b..2cedea7b9 100644
--- a/os/kernel/include/chevents.h
+++ b/os/kernel/include/chevents.h
@@ -34,6 +34,22 @@
#if CH_USE_EVENTS || defined(__DOXYGEN__)
+/*===========================================================================*/
+/* Module constants. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module pre-compile time settings. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Derived constants and error checks. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module data structures and types. */
+/*===========================================================================*/
+
typedef struct EventListener EventListener;
/**
@@ -66,6 +82,20 @@ typedef struct EventSource {
*/
typedef void (*evhandler_t)(eventid_t);
+/*===========================================================================*/
+/* Module macros. */
+/*===========================================================================*/
+
+/**
+ * @brief All events allowed mask.
+ */
+#define ALL_EVENTS ((eventmask_t)-1)
+
+/**
+ * @brief Returns an event mask from an event identifier.
+ */
+#define EVENT_MASK(eid) ((eventmask_t)(1 << (eid)))
+
/**
* @brief Data part of a static event source initializer.
* @details This macro should be used when statically initializing an event
@@ -83,20 +113,64 @@ typedef void (*evhandler_t)(eventid_t);
*/
#define EVENTSOURCE_DECL(name) EventSource name = _EVENTSOURCE_DATA(name)
-/**
- * @brief All events allowed mask.
- */
-#define ALL_EVENTS ((eventmask_t)-1)
+/*===========================================================================*/
+/* External declarations. */
+/*===========================================================================*/
-/**
- * @brief Returns an event mask from an event identifier.
- */
-#define EVENT_MASK(eid) ((eventmask_t)(1 << (eid)))
+#ifdef __cplusplus
+extern "C" {
+#endif
+ void chEvtRegisterMask(EventSource *esp,
+ EventListener *elp,
+ eventmask_t mask);
+ void chEvtUnregister(EventSource *esp, EventListener *elp);
+ eventmask_t chEvtGetAndClearEvents(eventmask_t mask);
+ eventmask_t chEvtAddEvents(eventmask_t mask);
+ flagsmask_t chEvtGetAndClearFlags(EventListener *elp);
+ flagsmask_t chEvtGetAndClearFlagsI(EventListener *elp);
+ void chEvtSignal(thread_t *tp, eventmask_t mask);
+ void chEvtSignalI(thread_t *tp, eventmask_t mask);
+ void chEvtBroadcastFlags(EventSource *esp, flagsmask_t flags);
+ void chEvtBroadcastFlagsI(EventSource *esp, flagsmask_t flags);
+ void chEvtDispatch(const evhandler_t *handlers, eventmask_t mask);
+#if CH_OPTIMIZE_SPEED || !CH_USE_EVENTS_TIMEOUT
+ eventmask_t chEvtWaitOne(eventmask_t mask);
+ eventmask_t chEvtWaitAny(eventmask_t mask);
+ eventmask_t chEvtWaitAll(eventmask_t mask);
+#endif
+#if CH_USE_EVENTS_TIMEOUT
+ eventmask_t chEvtWaitOneTimeout(eventmask_t mask, systime_t time);
+ eventmask_t chEvtWaitAnyTimeout(eventmask_t mask, systime_t time);
+ eventmask_t chEvtWaitAllTimeout(eventmask_t mask, systime_t time);
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+#if !CH_OPTIMIZE_SPEED && CH_USE_EVENTS_TIMEOUT
+#define chEvtWaitOne(mask) chEvtWaitOneTimeout(mask, TIME_INFINITE)
+#define chEvtWaitAny(mask) chEvtWaitAnyTimeout(mask, TIME_INFINITE)
+#define chEvtWaitAll(mask) chEvtWaitAllTimeout(mask, TIME_INFINITE)
+#endif
+
+/*===========================================================================*/
+/* Module inline functions. */
+/*===========================================================================*/
/**
- * @name Macro Functions
- * @{
+ * @brief Initializes an Event Source.
+ * @note This function can be invoked before the kernel is initialized
+ * because it just prepares a @p EventSource structure.
+ *
+ * @param[in] esp pointer to the @p EventSource structure
+ *
+ * @init
*/
+static inline void chEvtInit(EventSource *esp) {
+
+ esp->es_next = (EventListener *)(void *)esp;
+}
+
/**
* @brief Registers an Event Listener on an Event Source.
* @note Multiple Event Listeners can use the same event identifier, the
@@ -112,20 +186,12 @@ typedef void (*evhandler_t)(eventid_t);
*
* @api
*/
-#define chEvtRegister(esp, elp, eid) \
- chEvtRegisterMask(esp, elp, EVENT_MASK(eid))
+static inline void chEvtRegister(EventSource *esp,
+ EventListener *elp,
+ eventid_t eid) {
-/**
- * @brief Initializes an Event Source.
- * @note This function can be invoked before the kernel is initialized
- * because it just prepares a @p EventSource structure.
- *
- * @param[in] esp pointer to the @p EventSource structure
- *
- * @init
- */
-#define chEvtInit(esp) \
- ((esp)->es_next = (EventListener *)(void *)(esp))
+ chEvtRegisterMask(esp, elp, EVENT_MASK(eid));
+}
/**
* @brief Verifies if there is at least one @p EventListener registered.
@@ -134,8 +200,10 @@ typedef void (*evhandler_t)(eventid_t);
*
* @iclass
*/
-#define chEvtIsListeningI(esp) \
- ((void *)(esp) != (void *)(esp)->es_next)
+static inline bool chEvtIsListeningI(EventSource *esp) {
+
+ return (bool)((void *)esp != (void *)esp->es_next);
+}
/**
* @brief Signals all the Event Listeners registered on the specified Event
@@ -145,7 +213,10 @@ typedef void (*evhandler_t)(eventid_t);
*
* @api
*/
-#define chEvtBroadcast(esp) chEvtBroadcastFlags(esp, 0)
+static inline void chEvtBroadcast(EventSource *esp) {
+
+ chEvtBroadcastFlags(esp, 0);
+}
/**
* @brief Signals all the Event Listeners registered on the specified Event
@@ -159,44 +230,10 @@ typedef void (*evhandler_t)(eventid_t);
*
* @iclass
*/
-#define chEvtBroadcastI(esp) chEvtBroadcastFlagsI(esp, 0)
-/** @} */
+static inline void chEvtBroadcastI(EventSource *esp) {
-#ifdef __cplusplus
-extern "C" {
-#endif
- void chEvtRegisterMask(EventSource *esp,
- EventListener *elp,
- eventmask_t mask);
- void chEvtUnregister(EventSource *esp, EventListener *elp);
- eventmask_t chEvtGetAndClearEvents(eventmask_t mask);
- eventmask_t chEvtAddEvents(eventmask_t mask);
- flagsmask_t chEvtGetAndClearFlags(EventListener *elp);
- flagsmask_t chEvtGetAndClearFlagsI(EventListener *elp);
- void chEvtSignal(thread_t *tp, eventmask_t mask);
- void chEvtSignalI(thread_t *tp, eventmask_t mask);
- void chEvtBroadcastFlags(EventSource *esp, flagsmask_t flags);
- void chEvtBroadcastFlagsI(EventSource *esp, flagsmask_t flags);
- void chEvtDispatch(const evhandler_t *handlers, eventmask_t mask);
-#if CH_OPTIMIZE_SPEED || !CH_USE_EVENTS_TIMEOUT
- eventmask_t chEvtWaitOne(eventmask_t mask);
- eventmask_t chEvtWaitAny(eventmask_t mask);
- eventmask_t chEvtWaitAll(eventmask_t mask);
-#endif
-#if CH_USE_EVENTS_TIMEOUT
- eventmask_t chEvtWaitOneTimeout(eventmask_t mask, systime_t time);
- eventmask_t chEvtWaitAnyTimeout(eventmask_t mask, systime_t time);
- eventmask_t chEvtWaitAllTimeout(eventmask_t mask, systime_t time);
-#endif
-#ifdef __cplusplus
+ chEvtBroadcastFlagsI(esp, 0);
}
-#endif
-
-#if !CH_OPTIMIZE_SPEED && CH_USE_EVENTS_TIMEOUT
-#define chEvtWaitOne(mask) chEvtWaitOneTimeout(mask, TIME_INFINITE)
-#define chEvtWaitAny(mask) chEvtWaitAnyTimeout(mask, TIME_INFINITE)
-#define chEvtWaitAll(mask) chEvtWaitAllTimeout(mask, TIME_INFINITE)
-#endif
#endif /* CH_USE_EVENTS */
diff --git a/os/kernel/include/chmboxes.h b/os/kernel/include/chmboxes.h
index 85192e804..388ef07a6 100644
--- a/os/kernel/include/chmboxes.h
+++ b/os/kernel/include/chmboxes.h
@@ -48,10 +48,10 @@ typedef struct {
after the buffer. */
msg_t *mb_wrptr; /**< @brief Write pointer. */
msg_t *mb_rdptr; /**< @brief Read pointer. */
- Semaphore mb_fullsem; /**< @brief Full counter
- @p Semaphore. */
- Semaphore mb_emptysem; /**< @brief Empty counter
- @p Semaphore. */
+ semaphore_t mb_fullsem; /**< @brief Full counter
+ @p semaphore_t. */
+ semaphore_t mb_emptysem; /**< @brief Empty counter
+ @p semaphore_t. */
} Mailbox;
#ifdef __cplusplus
diff --git a/os/kernel/include/chsem.h b/os/kernel/include/chsem.h
index 649287e7d..78cf8ac37 100644
--- a/os/kernel/include/chsem.h
+++ b/os/kernel/include/chsem.h
@@ -31,34 +31,34 @@
#if CH_USE_SEMAPHORES || defined(__DOXYGEN__)
+/*===========================================================================*/
+/* Module constants. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module pre-compile time settings. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Derived constants and error checks. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module data structures and types. */
+/*===========================================================================*/
+
/**
* @brief Semaphore structure.
*/
-typedef struct Semaphore {
+typedef struct semaphore {
threads_queue_t s_queue; /**< @brief Queue of the threads sleeping
on this semaphore. */
cnt_t s_cnt; /**< @brief The semaphore counter. */
-} Semaphore;
+} semaphore_t;
-#ifdef __cplusplus
-extern "C" {
-#endif
- void chSemInit(Semaphore *sp, cnt_t n);
- void chSemReset(Semaphore *sp, cnt_t n);
- void chSemResetI(Semaphore *sp, cnt_t n);
- msg_t chSemWait(Semaphore *sp);
- msg_t chSemWaitS(Semaphore *sp);
- msg_t chSemWaitTimeout(Semaphore *sp, systime_t time);
- msg_t chSemWaitTimeoutS(Semaphore *sp, systime_t time);
- void chSemSignal(Semaphore *sp);
- void chSemSignalI(Semaphore *sp);
- void chSemAddCounterI(Semaphore *sp, cnt_t n);
-#if CH_USE_SEMSW
- msg_t chSemSignalWait(Semaphore *sps, Semaphore *spw);
-#endif
-#ifdef __cplusplus
-}
-#endif
+/*===========================================================================*/
+/* Module macros. */
+/*===========================================================================*/
/**
* @brief Data part of a static semaphore initializer.
@@ -80,19 +80,48 @@ extern "C" {
* @param[in] n the counter initial value, this value must be
* non-negative
*/
-#define SEMAPHORE_DECL(name, n) Semaphore name = _SEMAPHORE_DATA(name, n)
+#define SEMAPHORE_DECL(name, n) semaphore_t name = _SEMAPHORE_DATA(name, n)
+
+/*===========================================================================*/
+/* External declarations. */
+/*===========================================================================*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+ void chSemInit(semaphore_t *sp, cnt_t n);
+ void chSemReset(semaphore_t *sp, cnt_t n);
+ void chSemResetI(semaphore_t *sp, cnt_t n);
+ msg_t chSemWait(semaphore_t *sp);
+ msg_t chSemWaitS(semaphore_t *sp);
+ msg_t chSemWaitTimeout(semaphore_t *sp, systime_t time);
+ msg_t chSemWaitTimeoutS(semaphore_t *sp, systime_t time);
+ void chSemSignal(semaphore_t *sp);
+ void chSemSignalI(semaphore_t *sp);
+ void chSemAddCounterI(semaphore_t *sp, cnt_t n);
+#if CH_USE_SEMSW
+ msg_t chSemSignalWait(semaphore_t *sps, semaphore_t *spw);
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+/*===========================================================================*/
+/* Module inline functions. */
+/*===========================================================================*/
-/**
- * @name Macro Functions
- * @{
- */
/**
* @brief Decreases the semaphore counter.
* @details This macro can be used when the counter is known to be positive.
*
* @iclass
*/
-#define chSemFastWaitI(sp) ((sp)->s_cnt--)
+static inline void chSemFastWaitI(semaphore_t *sp) {
+
+ chDbgCheckClassI();
+
+ sp->s_cnt--;
+}
/**
* @brief Increases the semaphore counter.
@@ -101,15 +130,24 @@ extern "C" {
*
* @iclass
*/
-#define chSemFastSignalI(sp) ((sp)->s_cnt++)
+static inline void chSemFastSignalI(semaphore_t *sp) {
+
+ chDbgCheckClassI();
+
+ sp->s_cnt++;
+}
/**
* @brief Returns the semaphore counter current value.
*
* @iclass
*/
-#define chSemGetCounterI(sp) ((sp)->s_cnt)
-/** @} */
+static inline cnt_t chSemGetCounterI(semaphore_t *sp) {
+
+ chDbgCheckClassI();
+
+ return sp->s_cnt;
+}
#endif /* CH_USE_SEMAPHORES */
diff --git a/os/kernel/include/chvt.h b/os/kernel/include/chvt.h
index 92e77abf2..d87f6d110 100644
--- a/os/kernel/include/chvt.h
+++ b/os/kernel/include/chvt.h
@@ -53,7 +53,7 @@ typedef void (*vtfunc_t)(void *);
/**
* @brief Virtual Timer structure type.
*/
-typedef struct VirtualTimer VirtualTimer;
+typedef struct virtual_timer virtual_timer_t;
/**
* @brief Virtual timers list header.
@@ -62,22 +62,22 @@ typedef struct VirtualTimer VirtualTimer;
* timer is often used in the code.
*/
typedef struct {
- VirtualTimer *vt_next; /**< @brief Next timer in the delta
+ virtual_timer_t *vt_next; /**< @brief Next timer in the delta
list. */
- VirtualTimer *vt_prev; /**< @brief Last timer in the delta
+ virtual_timer_t *vt_prev; /**< @brief Last timer in the delta
list. */
systime_t vt_time; /**< @brief Must be initialized to -1. */
volatile systime_t vt_systime; /**< @brief System Time counter. */
-} VTList;
+} virtual_timers_list_t;
/**
- * @extends VTList
+ * @extends virtual_timers_list_t
*
* @brief Virtual Timer descriptor structure.
*/
-struct VirtualTimer {
- VirtualTimer *vt_next; /**< @brief Next timer in the list. */
- VirtualTimer *vt_prev; /**< @brief Previous timer in the list. */
+struct virtual_timer {
+ virtual_timer_t *vt_next; /**< @brief Next timer in the list. */
+ virtual_timer_t *vt_prev; /**< @brief Previous timer in the list. */
systime_t vt_time; /**< @brief Time delta before timeout. */
vtfunc_t vt_func; /**< @brief Timer callback function
pointer. */
@@ -137,7 +137,7 @@ struct VirtualTimer {
/* External declarations. */
/*===========================================================================*/
-extern VTList vtlist;
+extern virtual_timers_list_t vtlist;
/*
* Virtual Timers APIs.
@@ -147,9 +147,9 @@ extern "C" {
#endif
void _vt_init(void);
bool chVTIsTimeWithin(systime_t time, systime_t start, systime_t end);
- void chVTDoSetI(VirtualTimer *vtp, systime_t delay,
+ void chVTDoSetI(virtual_timer_t *vtp, systime_t delay,
vtfunc_t vtfunc, void *par);
- void chVTDoResetI(VirtualTimer *vtp);
+ void chVTDoResetI(virtual_timer_t *vtp);
#ifdef __cplusplus
}
#endif
@@ -159,17 +159,17 @@ extern "C" {
/*===========================================================================*/
/**
- * @brief Initializes a @p VirtualTimer object.
+ * @brief Initializes a @p virtual_timer_t object.
* @note Initializing a timer object is not strictly required because
* the function @p chVTSetI() initializes the object too. This
* function is only useful if you need to perform a @p chVTIsArmed()
* check before calling @p chVTSetI().
*
- * @param[out] vtp the @p VirtualTimer structure pointer
+ * @param[out] vtp the @p virtual_timer_t structure pointer
*
* @init
*/
-static inline void chVTObjectInit(VirtualTimer *vtp) {
+static inline void chVTObjectInit(virtual_timer_t *vtp) {
vtp->vt_func = NULL;
}
@@ -251,12 +251,12 @@ static inline bool chVTIsSystemTimeWithin(systime_t start, systime_t end) {
* @pre The timer must have been initialized using @p chVTObjectInit()
* or @p chVTSetI() (or @p chVTSetI() variants).
*
- * @param[in] vtp the @p VirtualTimer structure pointer
+ * @param[in] vtp the @p virtual_timer_t structure pointer
* @return true if the timer is armed.
*
* @iclass
*/
-static inline bool chVTIsArmedI(VirtualTimer *vtp) {
+static inline bool chVTIsArmedI(virtual_timer_t *vtp) {
chDbgCheckClassI();
@@ -267,11 +267,11 @@ static inline bool chVTIsArmedI(VirtualTimer *vtp) {
* @brief Disables a Virtual Timer.
* @note The timer is first checked and disabled only if armed.
*
- * @param[in] vtp the @p VirtualTimer structure pointer
+ * @param[in] vtp the @p virtual_timer_t structure pointer
*
* @iclass
*/
-static inline void chVTResetI(VirtualTimer *vtp) {
+static inline void chVTResetI(virtual_timer_t *vtp) {
if (chVTIsArmedI(vtp))
chVTDoResetI(vtp);
@@ -281,11 +281,11 @@ static inline void chVTResetI(VirtualTimer *vtp) {
* @brief Disables a Virtual Timer.
* @note The timer is first checked and disabled only if armed.
*
- * @param[in] vtp the @p VirtualTimer structure pointer
+ * @param[in] vtp the @p virtual_timer_t structure pointer
*
* @api
*/
-static inline void chVTReset(VirtualTimer *vtp) {
+static inline void chVTReset(virtual_timer_t *vtp) {
chSysLock();
chVTResetI(vtp);
@@ -297,7 +297,7 @@ static inline void chVTReset(VirtualTimer *vtp) {
* @details If the virtual timer was already enabled then it is re-enabled
* using the new parameters.
*
- * @param[in] vtp the @p VirtualTimer structure pointer
+ * @param[in] vtp the @p virtual_timer_t structure pointer
* @param[in] delay the number of ticks before the operation timeouts.
* @param[in] vtfunc the timer callback function. After invoking the
* callback the timer is disabled and the structure can
@@ -307,7 +307,7 @@ static inline void chVTReset(VirtualTimer *vtp) {
*
* @iclass
*/
-static inline void chVTSetI(VirtualTimer *vtp, systime_t delay,
+static inline void chVTSetI(virtual_timer_t *vtp, systime_t delay,
vtfunc_t vtfunc, void *par) {
chVTResetI(vtp);
@@ -319,7 +319,7 @@ static inline void chVTSetI(VirtualTimer *vtp, systime_t delay,
* @details If the virtual timer was already enabled then it is re-enabled
* using the new parameters.
*
- * @param[in] vtp the @p VirtualTimer structure pointer
+ * @param[in] vtp the @p virtual_timer_t structure pointer
* @param[in] delay the number of ticks before the operation timeouts.
* @param[in] vtfunc the timer callback function. After invoking the
* callback the timer is disabled and the structure can
@@ -329,7 +329,7 @@ static inline void chVTSetI(VirtualTimer *vtp, systime_t delay,
*
* @api
*/
-static inline void chVTSet(VirtualTimer *vtp, systime_t delay,
+static inline void chVTSet(virtual_timer_t *vtp, systime_t delay,
vtfunc_t vtfunc, void *par) {
chSysLock();
@@ -351,8 +351,8 @@ static inline void chVTDoTickI(void) {
chDbgCheckClassI();
vtlist.vt_systime++;
- if (&vtlist != (VTList *)vtlist.vt_next) {
- VirtualTimer *vtp;
+ if (&vtlist != (virtual_timers_list_t *)vtlist.vt_next) {
+ virtual_timer_t *vtp;
--vtlist.vt_next->vt_time;
while (!(vtp = vtlist.vt_next)->vt_time) {
diff --git a/os/kernel/src/chcond.c b/os/kernel/src/chcond.c
index 99a641122..5903e062f 100644
--- a/os/kernel/src/chcond.c
+++ b/os/kernel/src/chcond.c
@@ -25,14 +25,14 @@
* @file chcond.c
* @brief Condition Variables code.
*
- * @addtogroup condvars Condition Variables
+ * @addtogroup condition variables Condition Variables
* @details This module implements the Condition Variables mechanism. Condition
- * variables are an extensions to the Mutex subsystem and cannot
+ * variables are an extensions to the mutex subsystem and cannot
* work alone.
* <h2>Operation mode</h2>
* The condition variable is a synchronization object meant to be
- * used inside a zone protected by a @p Mutex. Mutexes and CondVars
- * together can implement a Monitor construct.
+ * used inside a zone protected by a mutex. Mutexes and condition
+ * variables together can implement a Monitor construct.
* @pre In order to use the condition variable APIs the @p CH_USE_CONDVARS
* option must be enabled in @p chconf.h.
* @{
@@ -40,16 +40,40 @@
#include "ch.h"
-#if (CH_USE_CONDVARS && CH_USE_MUTEXES) || defined(__DOXYGEN__)
+#if CH_USE_CONDVARS || defined(__DOXYGEN__)
+
+/*===========================================================================*/
+/* Module local definitions. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module exported variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module local types. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module local variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module local functions. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module exported functions. */
+/*===========================================================================*/
/**
- * @brief Initializes s @p CondVar structure.
+ * @brief Initializes s @p condition_variable_t structure.
*
- * @param[out] cp pointer to a @p CondVar structure
+ * @param[out] cp pointer to a @p condition_variable_t structure
*
* @init
*/
-void chCondInit(CondVar *cp) {
+void chCondInit(condition_variable_t *cp) {
chDbgCheck(cp != NULL, "chCondInit");
@@ -59,11 +83,11 @@ void chCondInit(CondVar *cp) {
/**
* @brief Signals one thread that is waiting on the condition variable.
*
- * @param[in] cp pointer to the @p CondVar structure
+ * @param[in] cp pointer to the @p condition_variable_t structure
*
* @api
*/
-void chCondSignal(CondVar *cp) {
+void chCondSignal(condition_variable_t *cp) {
chDbgCheck(cp != NULL, "chCondSignal");
@@ -80,11 +104,11 @@ void chCondSignal(CondVar *cp) {
* interrupt handlers always reschedule on exit so an explicit
* reschedule must not be performed in ISRs.
*
- * @param[in] cp pointer to the @p CondVar structure
+ * @param[in] cp pointer to the @p condition_variable_t structure
*
* @iclass
*/
-void chCondSignalI(CondVar *cp) {
+void chCondSignalI(condition_variable_t *cp) {
chDbgCheckClassI();
chDbgCheck(cp != NULL, "chCondSignalI");
@@ -96,11 +120,11 @@ void chCondSignalI(CondVar *cp) {
/**
* @brief Signals all threads that are waiting on the condition variable.
*
- * @param[in] cp pointer to the @p CondVar structure
+ * @param[in] cp pointer to the @p condition_variable_t structure
*
* @api
*/
-void chCondBroadcast(CondVar *cp) {
+void chCondBroadcast(condition_variable_t *cp) {
chSysLock();
chCondBroadcastI(cp);
@@ -115,11 +139,11 @@ void chCondBroadcast(CondVar *cp) {
* interrupt handlers always reschedule on exit so an explicit
* reschedule must not be performed in ISRs.
*
- * @param[in] cp pointer to the @p CondVar structure
+ * @param[in] cp pointer to the @p condition_variable_t structure
*
* @iclass
*/
-void chCondBroadcastI(CondVar *cp) {
+void chCondBroadcastI(condition_variable_t *cp) {
chDbgCheckClassI();
chDbgCheck(cp != NULL, "chCondBroadcastI");
@@ -138,17 +162,17 @@ void chCondBroadcastI(CondVar *cp) {
* is performed atomically.
* @pre The invoking thread <b>must</b> have at least one owned mutex.
*
- * @param[in] cp pointer to the @p CondVar structure
+ * @param[in] cp pointer to the @p condition_variable_t structure
* @return A message specifying how the invoking thread has been
* released from the condition variable.
- * @retval RDY_OK if the condvar has been signaled using
+ * @retval RDY_OK if the condition variable has been signaled using
* @p chCondSignal().
- * @retval RDY_RESET if the condvar has been signaled using
+ * @retval RDY_RESET if the condition variable has been signaled using
* @p chCondBroadcast().
*
* @api
*/
-msg_t chCondWait(CondVar *cp) {
+msg_t chCondWait(condition_variable_t *cp) {
msg_t msg;
chSysLock();
@@ -164,17 +188,17 @@ msg_t chCondWait(CondVar *cp) {
* is performed atomically.
* @pre The invoking thread <b>must</b> have at least one owned mutex.
*
- * @param[in] cp pointer to the @p CondVar structure
+ * @param[in] cp pointer to the @p condition_variable_t structure
* @return A message specifying how the invoking thread has been
* released from the condition variable.
- * @retval RDY_OK if the condvar has been signaled using
+ * @retval RDY_OK if the condition variable has been signaled using
* @p chCondSignal().
- * @retval RDY_RESET if the condvar has been signaled using
+ * @retval RDY_RESET if the condition variable has been signaled using
* @p chCondBroadcast().
*
* @sclass
*/
-msg_t chCondWaitS(CondVar *cp) {
+msg_t chCondWaitS(condition_variable_t *cp) {
thread_t *ctp = currp;
Mutex *mp;
msg_t msg;
@@ -206,7 +230,7 @@ msg_t chCondWaitS(CondVar *cp) {
* @post Exiting the function because a timeout does not re-acquire the
* mutex, the mutex ownership is lost.
*
- * @param[in] cp pointer to the @p CondVar structure
+ * @param[in] cp pointer to the @p condition_variable_t structure
* @param[in] time the number of ticks before the operation timeouts, the
* special values are handled as follow:
* - @a TIME_INFINITE no timeout.
@@ -214,16 +238,16 @@ msg_t chCondWaitS(CondVar *cp) {
* .
* @return A message specifying how the invoking thread has been
* released from the condition variable.
- * @retval RDY_OK if the condvar has been signaled using
+ * @retval RDY_OK if the condition variable has been signaled using
* @p chCondSignal().
- * @retval RDY_RESET if the condvar has been signaled using
+ * @retval RDY_RESET if the condition variable has been signaled using
* @p chCondBroadcast().
- * @retval RDY_TIMEOUT if the condvar has not been signaled within the
- * specified timeout.
+ * @retval RDY_TIMEOUT if the condition variable has not been signaled within
+ * the specified timeout.
*
* @api
*/
-msg_t chCondWaitTimeout(CondVar *cp, systime_t time) {
+msg_t chCondWaitTimeout(condition_variable_t *cp, systime_t time) {
msg_t msg;
chSysLock();
@@ -243,7 +267,7 @@ msg_t chCondWaitTimeout(CondVar *cp, systime_t time) {
* @post Exiting the function because a timeout does not re-acquire the
* mutex, the mutex ownership is lost.
*
- * @param[in] cp pointer to the @p CondVar structure
+ * @param[in] cp pointer to the @p condition_variable_t structure
* @param[in] time the number of ticks before the operation timeouts, the
* special values are handled as follow:
* - @a TIME_INFINITE no timeout.
@@ -251,16 +275,16 @@ msg_t chCondWaitTimeout(CondVar *cp, systime_t time) {
* .
* @return A message specifying how the invoking thread has been
* released from the condition variable.
- * @retval RDY_OK if the condvar has been signaled using
+ * @retval RDY_OK if the condition variable has been signaled using
* @p chCondSignal().
- * @retval RDY_RESET if the condvar has been signaled using
+ * @retval RDY_RESET if the condition variable has been signaled using
* @p chCondBroadcast().
- * @retval RDY_TIMEOUT if the condvar has not been signaled within the
- * specified timeout.
+ * @retval RDY_TIMEOUT if the condition variable has not been signaled within
+ * the specified timeout.
*
* @sclass
*/
-msg_t chCondWaitTimeoutS(CondVar *cp, systime_t time) {
+msg_t chCondWaitTimeoutS(condition_variable_t *cp, systime_t time) {
Mutex *mp;
msg_t msg;
@@ -280,6 +304,6 @@ msg_t chCondWaitTimeoutS(CondVar *cp, systime_t time) {
}
#endif /* CH_USE_CONDVARS_TIMEOUT */
-#endif /* CH_USE_CONDVARS && CH_USE_MUTEXES */
+#endif /* CH_USE_CONDVARS */
/** @} */
diff --git a/os/kernel/src/chdynamic.c b/os/kernel/src/chdynamic.c
index 3d856a526..76d4ba561 100644
--- a/os/kernel/src/chdynamic.c
+++ b/os/kernel/src/chdynamic.c
@@ -31,6 +31,30 @@
#if CH_USE_DYNAMIC || defined(__DOXYGEN__)
+/*===========================================================================*/
+/* Module local definitions. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module exported variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module local types. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module local variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module local functions. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module exported functions. */
+/*===========================================================================*/
+
/**
* @brief Adds a reference to a thread object.
* @pre The configuration option @p CH_USE_DYNAMIC must be enabled in order
diff --git a/os/kernel/src/chevents.c b/os/kernel/src/chevents.c
index 0ff5bef73..5685f285f 100644
--- a/os/kernel/src/chevents.c
+++ b/os/kernel/src/chevents.c
@@ -61,6 +61,31 @@
#include "ch.h"
#if CH_USE_EVENTS || defined(__DOXYGEN__)
+
+/*===========================================================================*/
+/* Module local definitions. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module exported variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module local types. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module local variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module local functions. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module exported functions. */
+/*===========================================================================*/
+
/**
* @brief Registers an Event Listener on an Event Source.
* @details Once a thread has registered as listener on an event source it
diff --git a/os/kernel/src/chschd.c b/os/kernel/src/chschd.c
index b957a8152..b99afbbb9 100644
--- a/os/kernel/src/chschd.c
+++ b/os/kernel/src/chschd.c
@@ -153,7 +153,7 @@ static void wakeup(void *p) {
(CH_USE_CONDVARS && CH_USE_CONDVARS_TIMEOUT)
#if CH_USE_SEMAPHORES
case THD_STATE_WTSEM:
- chSemFastSignalI((Semaphore *)tp->p_u.wtobjp);
+ chSemFastSignalI((semaphore_t *)tp->p_u.wtobjp);
/* Falls into, intentional. */
#endif
#if CH_USE_QUEUES
@@ -197,7 +197,7 @@ msg_t chSchGoSleepTimeoutS(tstate_t newstate, systime_t time) {
chDbgCheckClassS();
if (TIME_INFINITE != time) {
- VirtualTimer vt;
+ virtual_timer_t vt;
chVTDoSetI(&vt, time, wakeup, currp);
chSchGoSleepS(newstate);
diff --git a/os/kernel/src/chsem.c b/os/kernel/src/chsem.c
index 04e208e58..73d156c02 100644
--- a/os/kernel/src/chsem.c
+++ b/os/kernel/src/chsem.c
@@ -70,13 +70,13 @@
/**
* @brief Initializes a semaphore with the specified counter value.
*
- * @param[out] sp pointer to a @p Semaphore structure
+ * @param[out] sp pointer to a @p semaphore_t structure
* @param[in] n initial value of the semaphore counter. Must be
* non-negative.
*
* @init
*/
-void chSemInit(Semaphore *sp, cnt_t n) {
+void chSemInit(semaphore_t *sp, cnt_t n) {
chDbgCheck((sp != NULL) && (n >= 0), "chSemInit");
@@ -93,13 +93,13 @@ void chSemInit(Semaphore *sp, cnt_t n) {
* rather than a signal because the @p chSemWait() will return
* @p RDY_RESET instead of @p RDY_OK.
*
- * @param[in] sp pointer to a @p Semaphore structure
+ * @param[in] sp pointer to a @p semaphore_t structure
* @param[in] n the new value of the semaphore counter. The value must
* be non-negative.
*
* @api
*/
-void chSemReset(Semaphore *sp, cnt_t n) {
+void chSemReset(semaphore_t *sp, cnt_t n) {
chSysLock();
chSemResetI(sp, n);
@@ -120,13 +120,13 @@ void chSemReset(Semaphore *sp, cnt_t n) {
* rather than a signal because the @p chSemWait() will return
* @p RDY_RESET instead of @p RDY_OK.
*
- * @param[in] sp pointer to a @p Semaphore structure
+ * @param[in] sp pointer to a @p semaphore_t structure
* @param[in] n the new value of the semaphore counter. The value must
* be non-negative.
*
* @iclass
*/
-void chSemResetI(Semaphore *sp, cnt_t n) {
+void chSemResetI(semaphore_t *sp, cnt_t n) {
cnt_t cnt;
chDbgCheckClassI();
@@ -145,7 +145,7 @@ void chSemResetI(Semaphore *sp, cnt_t n) {
/**
* @brief Performs a wait operation on a semaphore.
*
- * @param[in] sp pointer to a @p Semaphore structure
+ * @param[in] sp pointer to a @p semaphore_t structure
* @return A message specifying how the invoking thread has been
* released from the semaphore.
* @retval RDY_OK if the thread has not stopped on the semaphore or the
@@ -154,7 +154,7 @@ void chSemResetI(Semaphore *sp, cnt_t n) {
*
* @api
*/
-msg_t chSemWait(Semaphore *sp) {
+msg_t chSemWait(semaphore_t *sp) {
msg_t msg;
chSysLock();
@@ -166,7 +166,7 @@ msg_t chSemWait(Semaphore *sp) {
/**
* @brief Performs a wait operation on a semaphore.
*
- * @param[in] sp pointer to a @p Semaphore structure
+ * @param[in] sp pointer to a @p semaphore_t structure
* @return A message specifying how the invoking thread has been
* released from the semaphore.
* @retval RDY_OK if the thread has not stopped on the semaphore or the
@@ -175,7 +175,7 @@ msg_t chSemWait(Semaphore *sp) {
*
* @sclass
*/
-msg_t chSemWaitS(Semaphore *sp) {
+msg_t chSemWaitS(semaphore_t *sp) {
chDbgCheckClassS();
chDbgCheck(sp != NULL, "chSemWaitS");
@@ -196,7 +196,7 @@ msg_t chSemWaitS(Semaphore *sp) {
/**
* @brief Performs a wait operation on a semaphore with timeout specification.
*
- * @param[in] sp pointer to a @p Semaphore structure
+ * @param[in] sp pointer to a @p semaphore_t structure
* @param[in] time the number of ticks before the operation timeouts,
* the following special values are allowed:
* - @a TIME_IMMEDIATE immediate timeout.
@@ -212,7 +212,7 @@ msg_t chSemWaitS(Semaphore *sp) {
*
* @api
*/
-msg_t chSemWaitTimeout(Semaphore *sp, systime_t time) {
+msg_t chSemWaitTimeout(semaphore_t *sp, systime_t time) {
msg_t msg;
chSysLock();
@@ -224,7 +224,7 @@ msg_t chSemWaitTimeout(Semaphore *sp, systime_t time) {
/**
* @brief Performs a wait operation on a semaphore with timeout specification.
*
- * @param[in] sp pointer to a @p Semaphore structure
+ * @param[in] sp pointer to a @p semaphore_t structure
* @param[in] time the number of ticks before the operation timeouts,
* the following special values are allowed:
* - @a TIME_IMMEDIATE immediate timeout.
@@ -240,7 +240,7 @@ msg_t chSemWaitTimeout(Semaphore *sp, systime_t time) {
*
* @sclass
*/
-msg_t chSemWaitTimeoutS(Semaphore *sp, systime_t time) {
+msg_t chSemWaitTimeoutS(semaphore_t *sp, systime_t time) {
chDbgCheckClassS();
chDbgCheck(sp != NULL, "chSemWaitTimeoutS");
@@ -264,11 +264,11 @@ msg_t chSemWaitTimeoutS(Semaphore *sp, systime_t time) {
/**
* @brief Performs a signal operation on a semaphore.
*
- * @param[in] sp pointer to a @p Semaphore structure
+ * @param[in] sp pointer to a @p semaphore_t structure
*
* @api
*/
-void chSemSignal(Semaphore *sp) {
+void chSemSignal(semaphore_t *sp) {
chDbgCheck(sp != NULL, "chSemSignal");
chDbgAssert(((sp->s_cnt >= 0) && queue_isempty(&sp->s_queue)) ||
@@ -289,11 +289,11 @@ void chSemSignal(Semaphore *sp) {
* interrupt handlers always reschedule on exit so an explicit
* reschedule must not be performed in ISRs.
*
- * @param[in] sp pointer to a @p Semaphore structure
+ * @param[in] sp pointer to a @p semaphore_t structure
*
* @iclass
*/
-void chSemSignalI(Semaphore *sp) {
+void chSemSignalI(semaphore_t *sp) {
chDbgCheckClassI();
chDbgCheck(sp != NULL, "chSemSignalI");
@@ -318,13 +318,13 @@ void chSemSignalI(Semaphore *sp) {
* interrupt handlers always reschedule on exit so an explicit
* reschedule must not be performed in ISRs.
*
- * @param[in] sp pointer to a @p Semaphore structure
+ * @param[in] sp pointer to a @p semaphore_t structure
* @param[in] n value to be added to the semaphore counter. The value
* must be positive.
*
* @iclass
*/
-void chSemAddCounterI(Semaphore *sp, cnt_t n) {
+void chSemAddCounterI(semaphore_t *sp, cnt_t n) {
chDbgCheckClassI();
chDbgCheck((sp != NULL) && (n > 0), "chSemAddCounterI");
@@ -346,8 +346,8 @@ void chSemAddCounterI(Semaphore *sp, cnt_t n) {
* @pre The configuration option @p CH_USE_SEMSW must be enabled in order
* to use this function.
*
- * @param[in] sps pointer to a @p Semaphore structure to be signaled
- * @param[in] spw pointer to a @p Semaphore structure to wait on
+ * @param[in] sps pointer to a @p semaphore_t structure to be signaled
+ * @param[in] spw pointer to a @p semaphore_t structure to wait on
* @return A message specifying how the invoking thread has been
* released from the semaphore.
* @retval RDY_OK if the thread has not stopped on the semaphore or the
@@ -356,7 +356,7 @@ void chSemAddCounterI(Semaphore *sp, cnt_t n) {
*
* @api
*/
-msg_t chSemSignalWait(Semaphore *sps, Semaphore *spw) {
+msg_t chSemSignalWait(semaphore_t *sps, semaphore_t *spw) {
msg_t msg;
chDbgCheck((sps != NULL) && (spw != NULL), "chSemSignalWait");
diff --git a/os/kernel/src/chvt.c b/os/kernel/src/chvt.c
index e93b2244c..3bccd1ac8 100644
--- a/os/kernel/src/chvt.c
+++ b/os/kernel/src/chvt.c
@@ -40,7 +40,7 @@
/**
* @brief Virtual timers delta list header.
*/
-VTList vtlist;
+virtual_timers_list_t vtlist;
/*===========================================================================*/
/* Module local types. */
@@ -99,7 +99,7 @@ bool chVTIsTimeWithin(systime_t time, systime_t start, systime_t end) {
* @pre The timer must not be already armed before calling this function.
* @note The callback function is invoked from interrupt context.
*
- * @param[out] vtp the @p VirtualTimer structure pointer
+ * @param[out] vtp the @p virtual_timer_t structure pointer
* @param[in] delay the number of ticks before the operation timeouts, the
* special values are handled as follow:
* - @a TIME_INFINITE is allowed but interpreted as a
@@ -114,9 +114,9 @@ bool chVTIsTimeWithin(systime_t time, systime_t start, systime_t end) {
*
* @iclass
*/
-void chVTDoSetI(VirtualTimer *vtp, systime_t delay,
+void chVTDoSetI(virtual_timer_t *vtp, systime_t delay,
vtfunc_t vtfunc, void *par) {
- VirtualTimer *p;
+ virtual_timer_t *p;
chDbgCheckClassI();
chDbgCheck((vtp != NULL) && (vtfunc != NULL) && (delay != TIME_IMMEDIATE),
@@ -141,11 +141,11 @@ void chVTDoSetI(VirtualTimer *vtp, systime_t delay,
* @brief Disables a Virtual Timer.
* @pre The timer must be in armed state before calling this function.
*
- * @param[in] vtp the @p VirtualTimer structure pointer
+ * @param[in] vtp the @p virtual_timer_t structure pointer
*
* @iclass
*/
-void chVTDoResetI(VirtualTimer *vtp) {
+void chVTDoResetI(virtual_timer_t *vtp) {
chDbgCheckClassI();
chDbgCheck(vtp != NULL, "chVTDoResetI");
diff --git a/test/test.c b/test/test.c
index 86e53499b..f88b402a7 100644
--- a/test/test.c
+++ b/test/test.c
@@ -257,7 +257,7 @@ systime_t test_wait_tick(void) {
*/
bool_t test_timer_done;
-static VirtualTimer vt;
+static virtual_timer_t vt;
static void tmr(void *p) {
(void)p;
diff --git a/test/testbmk.c b/test/testbmk.c
index e2f0df833..957f634ac 100644
--- a/test/testbmk.c
+++ b/test/testbmk.c
@@ -56,7 +56,7 @@
* @brief Kernel Benchmarks header file
*/
-static Semaphore sem1;
+static semaphore_t sem1;
#if CH_USE_MUTEXES || defined(__DOXYGEN__)
static Mutex mtx1;
#endif
@@ -500,7 +500,7 @@ ROMCONST struct testcase testbmk9 = {
static void tmo(void *param) {(void)param;}
static void bmk10_execute(void) {
- static VirtualTimer vt1, vt2;
+ static virtual_timer_t vt1, vt2;
uint32_t n = 0;
test_wait_tick();
@@ -633,7 +633,7 @@ ROMCONST struct testcase testbmk12 = {
static void bmk13_execute(void) {
test_print("--- System: ");
- test_printn(sizeof(ready_list_t) + sizeof(VTList) +
+ test_printn(sizeof(ready_list_t) + sizeof(virtual_timers_list_t) +
PORT_IDLE_THREAD_STACK_SIZE +
(sizeof(thread_t) + sizeof(struct intctx) +
sizeof(struct extctx) +
@@ -643,10 +643,10 @@ static void bmk13_execute(void) {
test_printn(sizeof(thread_t));
test_println(" bytes");
test_print("--- Timer : ");
- test_printn(sizeof(VirtualTimer));
+ test_printn(sizeof(virtual_timer_t));
test_println(" bytes");
test_print("--- Semaph: ");
- test_printn(sizeof(Semaphore));
+ test_printn(sizeof(semaphore_t));
test_println(" bytes");
#if CH_USE_EVENTS || defined(__DOXYGEN__)
test_print("--- EventS: ");
@@ -663,7 +663,7 @@ static void bmk13_execute(void) {
#endif
#if CH_USE_CONDVARS || defined(__DOXYGEN__)
test_print("--- CondV.: ");
- test_printn(sizeof(CondVar));
+ test_printn(sizeof(condition_variable_t));
test_println(" bytes");
#endif
#if CH_USE_QUEUES || defined(__DOXYGEN__)
diff --git a/test/testsem.c b/test/testsem.c
index 3de2e68fb..f4ca03c1a 100644
--- a/test/testsem.c
+++ b/test/testsem.c
@@ -244,12 +244,12 @@ ROMCONST struct testcase testsem3 = {
*/
static msg_t thread4(void *p) {
- chBSemSignal((BinarySemaphore *)p);
+ chBSemSignal((binary_semaphore_t *)p);
return 0;
}
static void sem4_execute(void) {
- BinarySemaphore bsem;
+ binary_semaphore_t bsem;
/* Creates a taken binary semaphore.*/
chBSemInit(&bsem, TRUE);