More MISRA.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7716 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
b53489d0e4
commit
a380d9ad03
|
@ -1,6 +1,6 @@
|
|||
--i"c:\programmi\gnu tools arm embedded\4.7 2013q3\bin\../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/include/c++/4.7.4"
|
||||
--i"c:\programmi\gnu tools arm embedded\4.7 2013q3\bin\../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/include/c++/4.7.4/arm-none-eabi"
|
||||
--i"c:\programmi\gnu tools arm embedded\4.7 2013q3\bin\../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/include/c++/4.7.4/backward"
|
||||
--i"c:\programmi\gnu tools arm embedded\4.7 2013q3\bin\../lib/gcc/arm-none-eabi/4.7.4/include"
|
||||
--i"c:\programmi\gnu tools arm embedded\4.7 2013q3\bin\../lib/gcc/arm-none-eabi/4.7.4/include-fixed"
|
||||
--i"c:\programmi\gnu tools arm embedded\4.7 2013q3\bin\../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/include"
|
||||
--i"C:/ChibiStudio/tools/GNU Tools ARM Embedded/4.9 2014q4/arm-none-eabi/include"
|
||||
--i"C:/ChibiStudio/tools/GNU Tools ARM Embedded/4.9 2014q4/arm-none-eabi/include/c++/4.9.3"
|
||||
--i"C:/ChibiStudio/tools/GNU Tools ARM Embedded/4.9 2014q4/arm-none-eabi/include/c++/4.9.3/arm-none-eabi"
|
||||
--i"C:/ChibiStudio/tools/GNU Tools ARM Embedded/4.9 2014q4/arm-none-eabi/include/c++/4.9.3/backward"
|
||||
--i"C:/ChibiStudio/tools/GNU Tools ARM Embedded/4.9 2014q4/lib/gcc/arm-none-eabi/4.9.3/include"
|
||||
--i"C:/ChibiStudio/tools/GNU Tools ARM Embedded/4.9 2014q4/lib/gcc/arm-none-eabi/4.9.3/include-fixed"
|
||||
|
|
|
@ -8,14 +8,16 @@
|
|||
|
||||
/* Removing *advisory* directives and rules that would negatively impact
|
||||
code clarity or are very common.*/
|
||||
-e970 /* Dir-4.6 */
|
||||
-e9026 /* Dir-4.9 */
|
||||
-e818 /* Rule 8.13 */
|
||||
-e9078 /* Rule-11.4 */
|
||||
-e9079 /* Rule-11.5 */
|
||||
-e904 /* Rule-15.5 */
|
||||
-e9044 /* Rule-17.8 */
|
||||
-e9024 /* Rule-20.10 */
|
||||
-e970 /* Dir-4.6 */
|
||||
-e9026 /* Dir-4.9 */
|
||||
-e756 /* Rule-2.3 */
|
||||
-e755 /* Rule-2.5 */
|
||||
-e818 -e844 -e954 /* Rule 8.13 */
|
||||
-e9078 /* Rule-11.4 */
|
||||
-e9079 /* Rule-11.5 */
|
||||
-e904 /* Rule-15.5 */
|
||||
-e9044 /* Rule-17.8 */
|
||||
-e9024 /* Rule-20.10 */
|
||||
|
||||
/* Waiver Directive 4.10, PCLint is confused by the guard used in the CMSIS
|
||||
header files, the guard is present, suppressing the noise.*/
|
||||
|
@ -26,6 +28,10 @@
|
|||
license URL and cannot be removed.*/
|
||||
-e9059
|
||||
|
||||
/* Waiver Rule 8.7, the static analyzer has no visibility of functions called
|
||||
from asm modules.*/
|
||||
-e765
|
||||
|
||||
/* Waiver Rule 11.6, cast from integer to pointer is very commonly used
|
||||
when accessing peripherals where the numeric address of the registers
|
||||
block is cast to a structure pointer.*/
|
||||
|
|
|
@ -198,9 +198,12 @@ typedef io_queue_t output_queue_t;
|
|||
* @param[in] qp pointer to a @p io_queue_t structure.
|
||||
* @return The buffer size.
|
||||
*
|
||||
* @notapi
|
||||
* @xclass
|
||||
*/
|
||||
#define QSIZE(qp) ((size_t)((qp)->q_top - (qp)->q_buffer))
|
||||
#define chQSizeX(qp) \
|
||||
/*lint -save -e946 -e947 -e9033 [18.2, 18.3, 10.8] Perfectly safe.*/ \
|
||||
((size_t)((qp)->q_top - (qp)->q_buffer)) \
|
||||
/*lint -restore*/
|
||||
|
||||
/**
|
||||
* @brief Queue space.
|
||||
|
@ -284,10 +287,7 @@ static inline size_t chIQGetEmptyI(input_queue_t *iqp) {
|
|||
|
||||
chDbgCheckClassI();
|
||||
|
||||
/*lint -save -e946 -e947 -e9033 [18.2, 18.3, 10.8] Perfectly safe pointers
|
||||
arithmetic in QSIZE().*/
|
||||
return (size_t)(QSIZE(iqp) - chQSpaceI(iqp));
|
||||
/*lint -restore*/
|
||||
return (size_t)(chQSizeX(iqp) - chQSpaceI(iqp));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -354,10 +354,7 @@ static inline size_t chOQGetFullI(output_queue_t *oqp) {
|
|||
|
||||
chDbgCheckClassI();
|
||||
|
||||
/*lint -save -e946 -e947 -e9033 [18.2, 18.3, 10.8] Perfectly safe pointers
|
||||
arithmetic in QSIZE().*/
|
||||
return (size_t)(QSIZE(oqp) - chQSpaceI(oqp));
|
||||
/*lint -restore*/
|
||||
return (size_t)(chQSizeX(oqp) - chQSpaceI(oqp));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -114,9 +114,12 @@ typedef struct {
|
|||
* @param[in] tp thread to add to the registry
|
||||
*/
|
||||
#define REG_INSERT(tp) { \
|
||||
/*lint -save -e9087 -e740 [11.3, 1.3] Cast required by list handling.*/ \
|
||||
(tp)->p_newer = (thread_t *)&ch.rlist; \
|
||||
/*lint -restore*/ \
|
||||
(tp)->p_older = ch.rlist.r_older; \
|
||||
(tp)->p_older->p_newer = ch.rlist.r_older = (tp); \
|
||||
(tp)->p_older->p_newer = (tp); \
|
||||
ch.rlist.r_older = (tp); \
|
||||
}
|
||||
|
||||
/*===========================================================================*/
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
|
||||
#include "ch.h"
|
||||
|
||||
#if CH_CFG_USE_CONDVARS || defined(__DOXYGEN__)
|
||||
#if (CH_CFG_USE_CONDVARS == TRUE) || defined(__DOXYGEN__)
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module local definitions. */
|
||||
|
@ -116,7 +116,7 @@ void chCondSignalI(condition_variable_t *cp) {
|
|||
if (queue_notempty(&cp->c_queue)) {
|
||||
thread_t *tp = queue_fifo_remove(&cp->c_queue);
|
||||
tp->p_u.rdymsg = MSG_OK;
|
||||
chSchReadyI(tp);
|
||||
(void) chSchReadyI(tp);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -226,7 +226,7 @@ msg_t chCondWaitS(condition_variable_t *cp) {
|
|||
return msg;
|
||||
}
|
||||
|
||||
#if CH_CFG_USE_CONDVARS_TIMEOUT || defined(__DOXYGEN__)
|
||||
#if (CH_CFG_USE_CONDVARS_TIMEOUT == TRUE) || defined(__DOXYGEN__)
|
||||
/**
|
||||
* @brief Waits on the condition variable releasing the mutex lock.
|
||||
* @details Releases the currently owned mutex, waits on the condition
|
||||
|
@ -316,8 +316,8 @@ msg_t chCondWaitTimeoutS(condition_variable_t *cp, systime_t time) {
|
|||
|
||||
return msg;
|
||||
}
|
||||
#endif /* CH_CFG_USE_CONDVARS_TIMEOUT */
|
||||
#endif /* CH_CFG_USE_CONDVARS_TIMEOUT == TRUE */
|
||||
|
||||
#endif /* CH_CFG_USE_CONDVARS */
|
||||
#endif /* CH_CFG_USE_CONDVARS == TRUE */
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
#include "ch.h"
|
||||
|
||||
#if CH_CFG_USE_DYNAMIC || defined(__DOXYGEN__)
|
||||
#if (CH_CFG_USE_DYNAMIC == TRUE) || defined(__DOXYGEN__)
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module local definitions. */
|
||||
|
@ -101,27 +101,30 @@ void chThdRelease(thread_t *tp) {
|
|||
allocator. Of course static threads are not affected.*/
|
||||
if ((refs == 0U) && (tp->p_state == CH_STATE_FINAL)) {
|
||||
switch (tp->p_flags & CH_FLAG_MODE_MASK) {
|
||||
#if CH_CFG_USE_HEAP
|
||||
#if CH_CFG_USE_HEAP == TRUE
|
||||
case CH_FLAG_MODE_HEAP:
|
||||
#if CH_CFG_USE_REGISTRY
|
||||
#if CH_CFG_USE_REGISTRY == TRUE
|
||||
REG_REMOVE(tp);
|
||||
#endif
|
||||
chHeapFree(tp);
|
||||
break;
|
||||
#endif
|
||||
#if CH_CFG_USE_MEMPOOLS
|
||||
#if CH_CFG_USE_MEMPOOLS == TRUE
|
||||
case CH_FLAG_MODE_MEMPOOL:
|
||||
#if CH_CFG_USE_REGISTRY
|
||||
#if CH_CFG_USE_REGISTRY == TRUE
|
||||
REG_REMOVE(tp);
|
||||
#endif
|
||||
chPoolFree(tp->p_mpool, tp);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
chDbgAssert(false, "unexpected case");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if CH_CFG_USE_HEAP || defined(__DOXYGEN__)
|
||||
#if (CH_CFG_USE_HEAP == TRUE) || defined(__DOXYGEN__)
|
||||
/**
|
||||
* @brief Creates a new thread allocating the memory from the heap.
|
||||
* @pre The configuration options @p CH_CFG_USE_DYNAMIC and
|
||||
|
@ -154,7 +157,7 @@ thread_t *chThdCreateFromHeap(memory_heap_t *heapp, size_t size,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
#if CH_DBG_FILL_THREADS
|
||||
#if CH_DBG_FILL_THREADS == TRUE
|
||||
_thread_memfill((uint8_t *)wsp,
|
||||
(uint8_t *)wsp + sizeof(thread_t),
|
||||
CH_DBG_THREAD_FILL_VALUE);
|
||||
|
@ -171,9 +174,9 @@ thread_t *chThdCreateFromHeap(memory_heap_t *heapp, size_t size,
|
|||
|
||||
return tp;
|
||||
}
|
||||
#endif /* CH_CFG_USE_HEAP */
|
||||
#endif /* CH_CFG_USE_HEAP == TRUE */
|
||||
|
||||
#if CH_CFG_USE_MEMPOOLS || defined(__DOXYGEN__)
|
||||
#if (CH_CFG_USE_MEMPOOLS == TRUE) || defined(__DOXYGEN__)
|
||||
/**
|
||||
* @brief Creates a new thread allocating the memory from the specified
|
||||
* memory pool.
|
||||
|
@ -208,7 +211,7 @@ thread_t *chThdCreateFromMemoryPool(memory_pool_t *mp, tprio_t prio,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
#if CH_DBG_FILL_THREADS
|
||||
#if CH_DBG_FILL_THREADS == TRUE
|
||||
_thread_memfill((uint8_t *)wsp,
|
||||
(uint8_t *)wsp + sizeof(thread_t),
|
||||
CH_DBG_THREAD_FILL_VALUE);
|
||||
|
@ -226,8 +229,8 @@ thread_t *chThdCreateFromMemoryPool(memory_pool_t *mp, tprio_t prio,
|
|||
|
||||
return tp;
|
||||
}
|
||||
#endif /* CH_CFG_USE_MEMPOOLS */
|
||||
#endif /* CH_CFG_USE_MEMPOOLS == TRUE */
|
||||
|
||||
#endif /* CH_CFG_USE_DYNAMIC */
|
||||
#endif /* CH_CFG_USE_DYNAMIC == TRUE */
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
|
||||
#include "ch.h"
|
||||
|
||||
#if CH_CFG_USE_EVENTS || defined(__DOXYGEN__)
|
||||
#if (CH_CFG_USE_EVENTS == TRUE) || defined(__DOXYGEN__)
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module local definitions. */
|
||||
|
@ -135,9 +135,13 @@ void chEvtUnregister(event_source_t *esp, event_listener_t *elp) {
|
|||
|
||||
chDbgCheck((esp != NULL) && (elp != NULL));
|
||||
|
||||
/*lint -save -e9087 -e740 [11.3, 1.3] Cast required by list handling.*/
|
||||
p = (event_listener_t *)esp;
|
||||
/*lint -restore*/
|
||||
chSysLock();
|
||||
/*lint -save -e9087 -e740 [11.3, 1.3] Cast required by list handling.*/
|
||||
while (p->el_next != (event_listener_t *)esp) {
|
||||
/*lint -restore*/
|
||||
if (p->el_next == elp) {
|
||||
p->el_next = elp->el_next;
|
||||
break;
|
||||
|
@ -208,7 +212,9 @@ void chEvtBroadcastFlagsI(event_source_t *esp, eventflags_t flags) {
|
|||
chDbgCheck(esp != NULL);
|
||||
|
||||
elp = esp->es_next;
|
||||
/*lint -save -e9087 -e740 [11.3, 1.3] Cast required by list handling.*/
|
||||
while (elp != (event_listener_t *)esp) {
|
||||
/*list -restore*/
|
||||
elp->el_flags |= flags;
|
||||
/* When flags == 0 the thread will always be signaled because the
|
||||
source does not emit any flag.*/
|
||||
|
@ -283,7 +289,7 @@ void chEvtSignalI(thread_t *tp, eventmask_t events) {
|
|||
((tp->p_state == CH_STATE_WTANDEVT) &&
|
||||
((tp->p_epending & tp->p_u.ewmask) == tp->p_u.ewmask))) {
|
||||
tp->p_u.rdymsg = MSG_OK;
|
||||
chSchReadyI(tp);
|
||||
(void) chSchReadyI(tp);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -353,7 +359,9 @@ void chEvtDispatch(const evhandler_t *handlers, eventmask_t events) {
|
|||
}
|
||||
}
|
||||
|
||||
#if CH_CFG_OPTIMIZE_SPEED || !CH_CFG_USE_EVENTS_TIMEOUT || defined(__DOXYGEN__)
|
||||
#if (CH_CFG_OPTIMIZE_SPEED == TRUE) || \
|
||||
(CH_CFG_USE_EVENTS_TIMEOUT == FALSE) || \
|
||||
defined(__DOXYGEN__)
|
||||
/**
|
||||
* @brief Waits for exactly one of the specified events.
|
||||
* @details The function waits for one event among those specified in
|
||||
|
@ -441,7 +449,7 @@ eventmask_t chEvtWaitAll(eventmask_t events) {
|
|||
}
|
||||
#endif /* CH_CFG_OPTIMIZE_SPEED || !CH_CFG_USE_EVENTS_TIMEOUT */
|
||||
|
||||
#if CH_CFG_USE_EVENTS_TIMEOUT || defined(__DOXYGEN__)
|
||||
#if (CH_CFG_USE_EVENTS_TIMEOUT == TRUE) || defined(__DOXYGEN__)
|
||||
/**
|
||||
* @brief Waits for exactly one of the specified events.
|
||||
* @details The function waits for one event among those specified in
|
||||
|
@ -566,8 +574,8 @@ eventmask_t chEvtWaitAllTimeout(eventmask_t events, systime_t time) {
|
|||
|
||||
return events;
|
||||
}
|
||||
#endif /* CH_CFG_USE_EVENTS_TIMEOUT */
|
||||
#endif /* CH_CFG_USE_EVENTS_TIMEOUT == TRUE */
|
||||
|
||||
#endif /* CH_CFG_USE_EVENTS */
|
||||
#endif /* CH_CFG_USE_EVENTS == TRUE */
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
#include "ch.h"
|
||||
|
||||
#if CH_CFG_USE_HEAP || defined(__DOXYGEN__)
|
||||
#if (CH_CFG_USE_HEAP == TRUE) || defined(__DOXYGEN__)
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module local definitions. */
|
||||
|
@ -44,7 +44,7 @@
|
|||
/*
|
||||
* Defaults on the best synchronization mechanism available.
|
||||
*/
|
||||
#if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__)
|
||||
#if (CH_CFG_USE_MUTEXES == TRUE) || defined(__DOXYGEN__)
|
||||
#define H_LOCK(h) chMtxLock(&(h)->h_mtx)
|
||||
#define H_UNLOCK(h) chMtxUnlock(&(h)->h_mtx)
|
||||
#else
|
||||
|
@ -87,7 +87,7 @@ void _heap_init(void) {
|
|||
default_heap.h_provider = chCoreAlloc;
|
||||
default_heap.h_free.h.u.next = (union heap_header *)NULL;
|
||||
default_heap.h_free.h.size = 0;
|
||||
#if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__)
|
||||
#if (CH_CFG_USE_MUTEXES == TRUE) || defined(__DOXYGEN__)
|
||||
chMtxObjectInit(&default_heap.h_mtx);
|
||||
#else
|
||||
chSemObjectInit(&default_heap.h_sem, 1);
|
||||
|
@ -115,7 +115,7 @@ void chHeapObjectInit(memory_heap_t *heapp, void *buf, size_t size) {
|
|||
heapp->h_free.h.size = 0;
|
||||
hp->h.u.next = NULL;
|
||||
hp->h.size = size - sizeof(union heap_header);
|
||||
#if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__)
|
||||
#if (CH_CFG_USE_MUTEXES == TRUE) || defined(__DOXYGEN__)
|
||||
chMtxObjectInit(&heapp->h_mtx);
|
||||
#else
|
||||
chSemObjectInit(&heapp->h_sem, 1);
|
||||
|
@ -215,8 +215,11 @@ void chHeapFree(void *p) {
|
|||
while (true) {
|
||||
chDbgAssert((hp < qp) || (hp >= LIMIT(qp)), "within free block");
|
||||
|
||||
/*lint -save -e946 -e947 [18.2, 18.3] Normal pointers arithmetic, it
|
||||
is safe.*/
|
||||
if (((qp == &heapp->h_free) || (hp > qp)) &&
|
||||
((qp->h.u.next == NULL) || (hp < qp->h.u.next))) {
|
||||
/*lint -restore*/
|
||||
/* Insertion after qp.*/
|
||||
hp->h.u.next = qp->h.u.next;
|
||||
qp->h.u.next = hp;
|
||||
|
@ -274,6 +277,6 @@ size_t chHeapStatus(memory_heap_t *heapp, size_t *sizep) {
|
|||
return n;
|
||||
}
|
||||
|
||||
#endif /* CH_CFG_USE_HEAP */
|
||||
#endif /* CH_CFG_USE_HEAP == TRUE */
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
|
||||
#include "ch.h"
|
||||
|
||||
#if CH_CFG_USE_MAILBOXES || defined(__DOXYGEN__)
|
||||
#if (CH_CFG_USE_MAILBOXES == TRUE) || defined(__DOXYGEN__)
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module exported variables. */
|
||||
|
@ -124,8 +124,12 @@ void chMBResetI(mailbox_t *mbp) {
|
|||
chDbgCheckClassI();
|
||||
chDbgCheck(mbp != NULL);
|
||||
|
||||
mbp->mb_wrptr = mbp->mb_rdptr = mbp->mb_buffer;
|
||||
chSemResetI(&mbp->mb_emptysem, mbp->mb_top - mbp->mb_buffer);
|
||||
mbp->mb_wrptr = mbp->mb_buffer;
|
||||
mbp->mb_rdptr = mbp->mb_buffer;
|
||||
/*lint -save -e946 -e947 [18.2, 18.3] Normal pointers arithmetic, it
|
||||
is safe.*/
|
||||
chSemResetI(&mbp->mb_emptysem, (cnt_t)(mbp->mb_top - mbp->mb_buffer));
|
||||
/*lint -restore*/
|
||||
chSemResetI(&mbp->mb_fullsem, 0);
|
||||
}
|
||||
|
||||
|
@ -186,7 +190,9 @@ msg_t chMBPostS(mailbox_t *mbp, msg_t msg, systime_t time) {
|
|||
rdymsg = chSemWaitTimeoutS(&mbp->mb_emptysem, time);
|
||||
if (rdymsg == MSG_OK) {
|
||||
*mbp->mb_wrptr++ = msg;
|
||||
/*lint -save -e946 [18.2] Normal pointers arithmetic, it is safe.*/
|
||||
if (mbp->mb_wrptr >= mbp->mb_top) {
|
||||
/*lint -restore*/
|
||||
mbp->mb_wrptr = mbp->mb_buffer;
|
||||
}
|
||||
chSemSignalI(&mbp->mb_fullsem);
|
||||
|
@ -221,7 +227,9 @@ msg_t chMBPostI(mailbox_t *mbp, msg_t msg) {
|
|||
|
||||
chSemFastWaitI(&mbp->mb_emptysem);
|
||||
*mbp->mb_wrptr++ = msg;
|
||||
/*lint -save -e946 [18.2] Normal pointers arithmetic, it is safe.*/
|
||||
if (mbp->mb_wrptr >= mbp->mb_top) {
|
||||
/*lint -restore*/
|
||||
mbp->mb_wrptr = mbp->mb_buffer;
|
||||
}
|
||||
chSemSignalI(&mbp->mb_fullsem);
|
||||
|
@ -285,7 +293,9 @@ msg_t chMBPostAheadS(mailbox_t *mbp, msg_t msg, systime_t time) {
|
|||
|
||||
rdymsg = chSemWaitTimeoutS(&mbp->mb_emptysem, time);
|
||||
if (rdymsg == MSG_OK) {
|
||||
/*lint -save -e946 [18.2] Normal pointers arithmetic, it is safe.*/
|
||||
if (--mbp->mb_rdptr < mbp->mb_buffer) {
|
||||
/*lint -restore*/
|
||||
mbp->mb_rdptr = mbp->mb_top - 1;
|
||||
}
|
||||
*mbp->mb_rdptr = msg;
|
||||
|
@ -319,7 +329,9 @@ msg_t chMBPostAheadI(mailbox_t *mbp, msg_t msg) {
|
|||
return MSG_TIMEOUT;
|
||||
}
|
||||
chSemFastWaitI(&mbp->mb_emptysem);
|
||||
/*lint -save -e946 [18.2] Normal pointers arithmetic, it is safe.*/
|
||||
if (--mbp->mb_rdptr < mbp->mb_buffer) {
|
||||
/*lint -restore*/
|
||||
mbp->mb_rdptr = mbp->mb_top - 1;
|
||||
}
|
||||
*mbp->mb_rdptr = msg;
|
||||
|
@ -385,7 +397,9 @@ msg_t chMBFetchS(mailbox_t *mbp, msg_t *msgp, systime_t time) {
|
|||
rdymsg = chSemWaitTimeoutS(&mbp->mb_fullsem, time);
|
||||
if (rdymsg == MSG_OK) {
|
||||
*msgp = *mbp->mb_rdptr++;
|
||||
/*lint -save -e946 [18.2] Normal pointers arithmetic, it is safe.*/
|
||||
if (mbp->mb_rdptr >= mbp->mb_top) {
|
||||
/*lint -restore*/
|
||||
mbp->mb_rdptr = mbp->mb_buffer;
|
||||
}
|
||||
chSemSignalI(&mbp->mb_emptysem);
|
||||
|
@ -419,13 +433,15 @@ msg_t chMBFetchI(mailbox_t *mbp, msg_t *msgp) {
|
|||
}
|
||||
chSemFastWaitI(&mbp->mb_fullsem);
|
||||
*msgp = *mbp->mb_rdptr++;
|
||||
/*lint -save -e946 [18.2] Normal pointers arithmetic, it is safe.*/
|
||||
if (mbp->mb_rdptr >= mbp->mb_top) {
|
||||
/*lint -restore*/
|
||||
mbp->mb_rdptr = mbp->mb_buffer;
|
||||
}
|
||||
chSemSignalI(&mbp->mb_emptysem);
|
||||
|
||||
return MSG_OK;
|
||||
}
|
||||
#endif /* CH_CFG_USE_MAILBOXES */
|
||||
#endif /* CH_CFG_USE_MAILBOXES == TRUE */
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
|
||||
#include "ch.h"
|
||||
|
||||
#if CH_CFG_USE_MEMCORE || defined(__DOXYGEN__)
|
||||
#if (CH_CFG_USE_MEMCORE == TRUE) || defined(__DOXYGEN__)
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module exported variables. */
|
||||
|
@ -83,10 +83,12 @@ void _core_init(void) {
|
|||
nextmem = (uint8_t *)MEM_ALIGN_NEXT(__heap_base__);
|
||||
endmem = (uint8_t *)MEM_ALIGN_PREV(__heap_end__);
|
||||
#else
|
||||
static stkalign_t buffer[MEM_ALIGN_NEXT(CH_CFG_MEMCORE_SIZE)/MEM_ALIGN_SIZE];
|
||||
static stkalign_t buffer[MEM_ALIGN_NEXT(CH_CFG_MEMCORE_SIZE) /
|
||||
MEM_ALIGN_SIZE];
|
||||
|
||||
nextmem = (uint8_t *)&buffer[0];
|
||||
endmem = (uint8_t *)&buffer[MEM_ALIGN_NEXT(CH_CFG_MEMCORE_SIZE)/MEM_ALIGN_SIZE];
|
||||
endmem = (uint8_t *)&buffer[MEM_ALIGN_NEXT(CH_CFG_MEMCORE_SIZE) /
|
||||
MEM_ALIGN_SIZE];
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -130,7 +132,10 @@ void *chCoreAllocI(size_t size) {
|
|||
chDbgCheckClassI();
|
||||
|
||||
size = MEM_ALIGN_NEXT(size);
|
||||
/*lint -save -e946 -e947 [18.2, 18.3] Normal pointers arithmetic, it
|
||||
is safe.*/
|
||||
if ((size_t)(endmem - nextmem) < size) {
|
||||
/*lint -restore*/
|
||||
return NULL;
|
||||
}
|
||||
p = nextmem;
|
||||
|
@ -148,8 +153,11 @@ void *chCoreAllocI(size_t size) {
|
|||
*/
|
||||
size_t chCoreGetStatusX(void) {
|
||||
|
||||
/*lint -save -e946 -e947 [18.2, 18.3] Normal pointers arithmetic, it
|
||||
is safe.*/
|
||||
return (size_t)(endmem - nextmem);
|
||||
/*lint -restore*/
|
||||
}
|
||||
#endif /* CH_CFG_USE_MEMCORE */
|
||||
#endif /* CH_CFG_USE_MEMCORE == TRUE */
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
|
||||
#include "ch.h"
|
||||
|
||||
#if CH_CFG_USE_MESSAGES || defined(__DOXYGEN__)
|
||||
#if (CH_CFG_USE_MESSAGES == TRUE) || defined(__DOXYGEN__)
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module exported variables. */
|
||||
|
@ -63,7 +63,7 @@
|
|||
/* Module local functions. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#if CH_CFG_USE_MESSAGES_PRIORITY
|
||||
#if CH_CFG_USE_MESSAGES_PRIORITY == TRUE
|
||||
#define msg_insert(tp, qp) queue_prio_insert(tp, qp)
|
||||
#else
|
||||
#define msg_insert(tp, qp) queue_insert(tp, qp)
|
||||
|
@ -94,7 +94,7 @@ msg_t chMsgSend(thread_t *tp, msg_t msg) {
|
|||
ctp->p_u.wtobjp = &tp->p_msgqueue;
|
||||
msg_insert(ctp, &tp->p_msgqueue);
|
||||
if (tp->p_state == CH_STATE_WTMSG) {
|
||||
chSchReadyI(tp);
|
||||
(void) chSchReadyI(tp);
|
||||
}
|
||||
chSchGoSleepS(CH_STATE_SNDMSGQ);
|
||||
msg = ctp->p_u.rdymsg;
|
||||
|
@ -149,6 +149,6 @@ void chMsgRelease(thread_t *tp, msg_t msg) {
|
|||
chSysUnlock();
|
||||
}
|
||||
|
||||
#endif /* CH_CFG_USE_MESSAGES */
|
||||
#endif /* CH_CFG_USE_MESSAGES == TRUE */
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -71,7 +71,7 @@
|
|||
|
||||
#include "ch.h"
|
||||
|
||||
#if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__)
|
||||
#if (CH_CFG_USE_MUTEXES == TRUE) || defined(__DOXYGEN__)
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module exported variables. */
|
||||
|
@ -106,7 +106,7 @@ void chMtxObjectInit(mutex_t *mp) {
|
|||
|
||||
queue_init(&mp->m_queue);
|
||||
mp->m_owner = NULL;
|
||||
#if CH_CFG_USE_MUTEXES_RECURSIVE
|
||||
#if CH_CFG_USE_MUTEXES_RECURSIVE == TRUE
|
||||
mp->m_cnt = 0;
|
||||
#endif
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ void chMtxLockS(mutex_t *mp) {
|
|||
|
||||
/* Is the mutex already locked? */
|
||||
if (mp->m_owner != NULL) {
|
||||
#if CH_CFG_USE_MUTEXES_RECURSIVE
|
||||
#if CH_CFG_USE_MUTEXES_RECURSIVE == TRUE
|
||||
|
||||
chDbgAssert(mp->m_cnt >= 1, "counter is not positive");
|
||||
|
||||
|
@ -174,30 +174,35 @@ void chMtxLockS(mutex_t *mp) {
|
|||
(threads_queue_t *)tp->p_u.wtobjp);
|
||||
tp = ((mutex_t *)tp->p_u.wtobjp)->m_owner;
|
||||
continue;
|
||||
#if CH_CFG_USE_CONDVARS | \
|
||||
(CH_CFG_USE_SEMAPHORES && CH_CFG_USE_SEMAPHORES_PRIORITY) | \
|
||||
(CH_CFG_USE_MESSAGES && CH_CFG_USE_MESSAGES_PRIORITY)
|
||||
#if CH_CFG_USE_CONDVARS
|
||||
#if (CH_CFG_USE_CONDVARS == TRUE) | \
|
||||
((CH_CFG_USE_SEMAPHORES == TRUE) && \
|
||||
(CH_CFG_USE_SEMAPHORES_PRIORITY) == TRUE) | \
|
||||
((CH_CFG_USE_MESSAGES == TRUE) && (CH_CFG_USE_MESSAGES_PRIORITY == TRUE))
|
||||
#if CH_CFG_USE_CONDVARS == TRUE
|
||||
case CH_STATE_WTCOND:
|
||||
#endif
|
||||
#if CH_CFG_USE_SEMAPHORES && CH_CFG_USE_SEMAPHORES_PRIORITY
|
||||
#endif
|
||||
#if (CH_CFG_USE_SEMAPHORES == TRUE) && \
|
||||
(CH_CFG_USE_SEMAPHORES_PRIORITY == TRUE)
|
||||
case CH_STATE_WTSEM:
|
||||
#endif
|
||||
#if CH_CFG_USE_MESSAGES && CH_CFG_USE_MESSAGES_PRIORITY
|
||||
#endif
|
||||
#if (CH_CFG_USE_MESSAGES == TRUE) && (CH_CFG_USE_MESSAGES_PRIORITY == TRUE)
|
||||
case CH_STATE_SNDMSGQ:
|
||||
#endif
|
||||
#endif
|
||||
/* Re-enqueues tp with its new priority on the queue.*/
|
||||
queue_prio_insert(queue_dequeue(tp),
|
||||
(threads_queue_t *)tp->p_u.wtobjp);
|
||||
break;
|
||||
#endif
|
||||
#endif
|
||||
case CH_STATE_READY:
|
||||
#if CH_DBG_ENABLE_ASSERTS
|
||||
#if CH_DBG_ENABLE_ASSERTS == TRUE
|
||||
/* Prevents an assertion in chSchReadyI().*/
|
||||
tp->p_state = CH_STATE_CURRENT;
|
||||
#endif
|
||||
#endif
|
||||
/* Re-enqueues tp with its new priority on the ready list.*/
|
||||
chSchReadyI(queue_dequeue(tp));
|
||||
(void) chSchReadyI(queue_dequeue(tp));
|
||||
break;
|
||||
default:
|
||||
chDbgAssert(false, "unexpected state");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -212,13 +217,13 @@ void chMtxLockS(mutex_t *mp) {
|
|||
the mutex to this thread.*/
|
||||
chDbgAssert(mp->m_owner == ctp, "not owner");
|
||||
chDbgAssert(ctp->p_mtxlist == mp, "not owned");
|
||||
#if CH_CFG_USE_MUTEXES_RECURSIVE
|
||||
#if CH_CFG_USE_MUTEXES_RECURSIVE == TRUE
|
||||
chDbgAssert(mp->m_cnt == 1, "counter is not one");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
#if CH_CFG_USE_MUTEXES_RECURSIVE
|
||||
#if CH_CFG_USE_MUTEXES_RECURSIVE == TRUE
|
||||
chDbgAssert(mp->m_cnt == 0, "counter is not zero");
|
||||
|
||||
mp->m_cnt++;
|
||||
|
@ -280,7 +285,7 @@ bool chMtxTryLockS(mutex_t *mp) {
|
|||
chDbgCheck(mp != NULL);
|
||||
|
||||
if (mp->m_owner != NULL) {
|
||||
#if CH_CFG_USE_MUTEXES_RECURSIVE
|
||||
#if CH_CFG_USE_MUTEXES_RECURSIVE == TRUE
|
||||
|
||||
chDbgAssert(mp->m_cnt >= 1, "counter is not positive");
|
||||
|
||||
|
@ -291,7 +296,7 @@ bool chMtxTryLockS(mutex_t *mp) {
|
|||
#endif
|
||||
return false;
|
||||
}
|
||||
#if CH_CFG_USE_MUTEXES_RECURSIVE
|
||||
#if CH_CFG_USE_MUTEXES_RECURSIVE == TRUE
|
||||
|
||||
chDbgAssert(mp->m_cnt == 0, "counter is not zero");
|
||||
|
||||
|
@ -325,7 +330,7 @@ void chMtxUnlock(mutex_t *mp) {
|
|||
|
||||
chDbgAssert(ctp->p_mtxlist != NULL, "owned mutexes list empty");
|
||||
chDbgAssert(ctp->p_mtxlist->m_owner == ctp, "ownership failure");
|
||||
#if CH_CFG_USE_MUTEXES_RECURSIVE
|
||||
#if CH_CFG_USE_MUTEXES_RECURSIVE == TRUE
|
||||
chDbgAssert(mp->m_cnt >= 1, "counter is not positive");
|
||||
|
||||
if (--mp->m_cnt == 0) {
|
||||
|
@ -363,7 +368,7 @@ void chMtxUnlock(mutex_t *mp) {
|
|||
|
||||
/* Awakens the highest priority thread waiting for the unlocked mutex and
|
||||
assigns the mutex to it.*/
|
||||
#if CH_CFG_USE_MUTEXES_RECURSIVE
|
||||
#if CH_CFG_USE_MUTEXES_RECURSIVE == TRUE
|
||||
mp->m_cnt = 1;
|
||||
#endif
|
||||
tp = queue_fifo_remove(&mp->m_queue);
|
||||
|
@ -375,7 +380,7 @@ void chMtxUnlock(mutex_t *mp) {
|
|||
else {
|
||||
mp->m_owner = NULL;
|
||||
}
|
||||
#if CH_CFG_USE_MUTEXES_RECURSIVE
|
||||
#if CH_CFG_USE_MUTEXES_RECURSIVE == TRUE
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -405,7 +410,7 @@ void chMtxUnlockS(mutex_t *mp) {
|
|||
|
||||
chDbgAssert(ctp->p_mtxlist != NULL, "owned mutexes list empty");
|
||||
chDbgAssert(ctp->p_mtxlist->m_owner == ctp, "ownership failure");
|
||||
#if CH_CFG_USE_MUTEXES_RECURSIVE
|
||||
#if CH_CFG_USE_MUTEXES_RECURSIVE == TRUE
|
||||
chDbgAssert(mp->m_cnt >= 1, "counter is not positive");
|
||||
|
||||
if (--mp->m_cnt == 0) {
|
||||
|
@ -443,19 +448,19 @@ void chMtxUnlockS(mutex_t *mp) {
|
|||
|
||||
/* Awakens the highest priority thread waiting for the unlocked mutex and
|
||||
assigns the mutex to it.*/
|
||||
#if CH_CFG_USE_MUTEXES_RECURSIVE
|
||||
#if CH_CFG_USE_MUTEXES_RECURSIVE == TRUE
|
||||
mp->m_cnt = 1;
|
||||
#endif
|
||||
tp = queue_fifo_remove(&mp->m_queue);
|
||||
mp->m_owner = tp;
|
||||
mp->m_next = tp->p_mtxlist;
|
||||
tp->p_mtxlist = mp;
|
||||
chSchReadyI(tp);
|
||||
(void) chSchReadyI(tp);
|
||||
}
|
||||
else {
|
||||
mp->m_owner = NULL;
|
||||
}
|
||||
#if CH_CFG_USE_MUTEXES_RECURSIVE
|
||||
#if CH_CFG_USE_MUTEXES_RECURSIVE == TRUE
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -480,17 +485,17 @@ void chMtxUnlockAll(void) {
|
|||
mutex_t *mp = ctp->p_mtxlist;
|
||||
ctp->p_mtxlist = mp->m_next;
|
||||
if (chMtxQueueNotEmptyS(mp)) {
|
||||
#if CH_CFG_USE_MUTEXES_RECURSIVE
|
||||
#if CH_CFG_USE_MUTEXES_RECURSIVE == TRUE
|
||||
mp->m_cnt = 1;
|
||||
#endif
|
||||
thread_t *tp = queue_fifo_remove(&mp->m_queue);
|
||||
mp->m_owner = tp;
|
||||
mp->m_next = tp->p_mtxlist;
|
||||
tp->p_mtxlist = mp;
|
||||
chSchReadyI(tp);
|
||||
(void) chSchReadyI(tp);
|
||||
}
|
||||
else {
|
||||
#if CH_CFG_USE_MUTEXES_RECURSIVE
|
||||
#if CH_CFG_USE_MUTEXES_RECURSIVE == TRUE
|
||||
mp->m_cnt = 0;
|
||||
#endif
|
||||
mp->m_owner = NULL;
|
||||
|
@ -502,6 +507,6 @@ void chMtxUnlockAll(void) {
|
|||
chSysUnlock();
|
||||
}
|
||||
|
||||
#endif /* CH_CFG_USE_MUTEXES */
|
||||
#endif /* CH_CFG_USE_MUTEXES == TRUE */
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
|
||||
#include "ch.h"
|
||||
|
||||
#if CH_CFG_USE_QUEUES || defined(__DOXYGEN__)
|
||||
#if (CH_CFG_USE_QUEUES == TRUE) || defined(__DOXYGEN__)
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module local definitions. */
|
||||
|
@ -138,7 +138,9 @@ msg_t chIQPutI(input_queue_t *iqp, uint8_t b) {
|
|||
|
||||
iqp->q_counter++;
|
||||
*iqp->q_wrptr++ = b;
|
||||
/*lint -save -e946 [18.2] Normal pointers arithmetic, it is safe.*/
|
||||
if (iqp->q_wrptr >= iqp->q_top) {
|
||||
/*lint -restore*/
|
||||
iqp->q_wrptr = iqp->q_buffer;
|
||||
}
|
||||
|
||||
|
@ -185,7 +187,9 @@ msg_t chIQGetTimeout(input_queue_t *iqp, systime_t time) {
|
|||
|
||||
iqp->q_counter--;
|
||||
b = *iqp->q_rdptr++;
|
||||
/*lint -save -e946 [18.2] Normal pointers arithmetic, it is safe.*/
|
||||
if (iqp->q_rdptr >= iqp->q_top) {
|
||||
/*lint -restore*/
|
||||
iqp->q_rdptr = iqp->q_buffer;
|
||||
}
|
||||
chSysUnlock();
|
||||
|
@ -239,8 +243,11 @@ size_t chIQReadTimeout(input_queue_t *iqp, uint8_t *bp,
|
|||
|
||||
iqp->q_counter--;
|
||||
*bp++ = *iqp->q_rdptr++;
|
||||
if (iqp->q_rdptr >= iqp->q_top)
|
||||
/*lint -save -e946 [18.2] Normal pointers arithmetic, it is safe.*/
|
||||
if (iqp->q_rdptr >= iqp->q_top) {
|
||||
/*lint -restore*/
|
||||
iqp->q_rdptr = iqp->q_buffer;
|
||||
}
|
||||
|
||||
chSysUnlock(); /* Gives a preemption chance in a controlled point.*/
|
||||
r++;
|
||||
|
@ -295,7 +302,7 @@ void chOQResetI(output_queue_t *oqp) {
|
|||
chDbgCheckClassI();
|
||||
|
||||
oqp->q_rdptr = oqp->q_wrptr = oqp->q_buffer;
|
||||
oqp->q_counter = QSIZE(oqp);
|
||||
oqp->q_counter = chQSizeX(oqp);
|
||||
chThdDequeueAllI(&oqp->q_waiting, Q_RESET);
|
||||
}
|
||||
|
||||
|
@ -335,7 +342,9 @@ msg_t chOQPutTimeout(output_queue_t *oqp, uint8_t b, systime_t time) {
|
|||
|
||||
oqp->q_counter--;
|
||||
*oqp->q_wrptr++ = b;
|
||||
/*lint -save -e946 [18.2] Normal pointers arithmetic, it is safe.*/
|
||||
if (oqp->q_wrptr >= oqp->q_top) {
|
||||
/*lint -restore*/
|
||||
oqp->q_wrptr = oqp->q_buffer;
|
||||
}
|
||||
|
||||
|
@ -368,7 +377,9 @@ msg_t chOQGetI(output_queue_t *oqp) {
|
|||
|
||||
oqp->q_counter++;
|
||||
b = *oqp->q_rdptr++;
|
||||
/*lint -save -e946 [18.2] Normal pointers arithmetic, it is safe.*/
|
||||
if (oqp->q_rdptr >= oqp->q_top) {
|
||||
/*lint -restore*/
|
||||
oqp->q_rdptr = oqp->q_buffer;
|
||||
}
|
||||
|
||||
|
@ -418,7 +429,9 @@ size_t chOQWriteTimeout(output_queue_t *oqp, const uint8_t *bp,
|
|||
}
|
||||
oqp->q_counter--;
|
||||
*oqp->q_wrptr++ = *bp++;
|
||||
/*lint -save -e946 [18.2] Normal pointers arithmetic, it is safe.*/
|
||||
if (oqp->q_wrptr >= oqp->q_top) {
|
||||
/*lint -restore*/
|
||||
oqp->q_wrptr = oqp->q_buffer;
|
||||
}
|
||||
|
||||
|
@ -434,6 +447,6 @@ size_t chOQWriteTimeout(output_queue_t *oqp, const uint8_t *bp,
|
|||
chSysLock();
|
||||
}
|
||||
}
|
||||
#endif /* CH_CFG_USE_QUEUES */
|
||||
#endif /* CH_CFG_USE_QUEUES == TRUE */
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
*/
|
||||
#include "ch.h"
|
||||
|
||||
#if CH_CFG_USE_REGISTRY || defined(__DOXYGEN__)
|
||||
#if (CH_CFG_USE_REGISTRY == TRUE) || defined(__DOXYGEN__)
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module exported variables. */
|
||||
|
@ -65,7 +65,10 @@
|
|||
/*===========================================================================*/
|
||||
|
||||
#define _offsetof(st, m) \
|
||||
((size_t)((char *)&((st *)0)->m - (char *)0))
|
||||
/*lint -save -e946 -e947 -e9033 -e413 [18.2, 18.3, 10.8 1.3] Normal
|
||||
pointers arithmetic, it is safe.*/ \
|
||||
((size_t)((char *)&((st *)0)->m - (char *)0)) \
|
||||
/*lint -restore*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module exported functions. */
|
||||
|
@ -89,14 +92,14 @@ ROMCONST chdebug_t ch_debug = {
|
|||
(uint8_t)_offsetof(thread_t, p_newer),
|
||||
(uint8_t)_offsetof(thread_t, p_older),
|
||||
(uint8_t)_offsetof(thread_t, p_name),
|
||||
#if CH_DBG_ENABLE_STACK_CHECK
|
||||
#if CH_DBG_ENABLE_STACK_CHECK == TRUE
|
||||
(uint8_t)_offsetof(thread_t, p_stklimit),
|
||||
#else
|
||||
(uint8_t)0,
|
||||
#endif
|
||||
(uint8_t)_offsetof(thread_t, p_state),
|
||||
(uint8_t)_offsetof(thread_t, p_flags),
|
||||
#if CH_CFG_USE_DYNAMIC
|
||||
#if CH_CFG_USE_DYNAMIC == TRUE
|
||||
(uint8_t)_offsetof(thread_t, p_refs),
|
||||
#else
|
||||
(uint8_t)0,
|
||||
|
@ -106,7 +109,7 @@ ROMCONST chdebug_t ch_debug = {
|
|||
#else
|
||||
(uint8_t)0,
|
||||
#endif
|
||||
#if CH_DBG_THREADS_PROFILING
|
||||
#if CH_DBG_THREADS_PROFILING == TRUE
|
||||
(uint8_t)_offsetof(thread_t, p_time)
|
||||
#else
|
||||
(uint8_t)0
|
||||
|
@ -130,7 +133,7 @@ thread_t *chRegFirstThread(void) {
|
|||
|
||||
chSysLock();
|
||||
tp = ch.rlist.r_newer;
|
||||
#if CH_CFG_USE_DYNAMIC
|
||||
#if CH_CFG_USE_DYNAMIC == TRUE
|
||||
tp->p_refs++;
|
||||
#endif
|
||||
chSysUnlock();
|
||||
|
@ -154,23 +157,25 @@ thread_t *chRegNextThread(thread_t *tp) {
|
|||
|
||||
chSysLock();
|
||||
ntp = tp->p_newer;
|
||||
/*lint -save -e9087 -e740 [11.3, 1.3] Cast required by list handling.*/
|
||||
if (ntp == (thread_t *)&ch.rlist) {
|
||||
/*lint -restore*/
|
||||
ntp = NULL;
|
||||
}
|
||||
#if CH_CFG_USE_DYNAMIC
|
||||
#if CH_CFG_USE_DYNAMIC == TRUE
|
||||
else {
|
||||
chDbgAssert(ntp->p_refs < 255, "too many references");
|
||||
ntp->p_refs++;
|
||||
}
|
||||
#endif
|
||||
chSysUnlock();
|
||||
#if CH_CFG_USE_DYNAMIC
|
||||
#if CH_CFG_USE_DYNAMIC == TRUE
|
||||
chThdRelease(tp);
|
||||
#endif
|
||||
|
||||
return ntp;
|
||||
}
|
||||
|
||||
#endif /* CH_CFG_USE_REGISTRY */
|
||||
#endif /* CH_CFG_USE_REGISTRY == TRUE */
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
|
||||
#include "ch.h"
|
||||
|
||||
#if CH_CFG_USE_SEMAPHORES || defined(__DOXYGEN__)
|
||||
#if (CH_CFG_USE_SEMAPHORES == TRUE) || defined(__DOXYGEN__)
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module exported variables. */
|
||||
|
@ -75,7 +75,7 @@
|
|||
/* Module local functions. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#if CH_CFG_USE_SEMAPHORES_PRIORITY
|
||||
#if CH_CFG_USE_SEMAPHORES_PRIORITY == TRUE
|
||||
#define sem_insert(tp, qp) queue_prio_insert(tp, qp)
|
||||
#else
|
||||
#define sem_insert(tp, qp) queue_insert(tp, qp)
|
||||
|
@ -329,7 +329,7 @@ void chSemSignalI(semaphore_t *sp) {
|
|||
chSchReadyI().*/
|
||||
thread_t *tp = queue_fifo_remove(&sp->s_queue);
|
||||
tp->p_u.rdymsg = MSG_OK;
|
||||
chSchReadyI(tp);
|
||||
(void) chSchReadyI(tp);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -406,6 +406,6 @@ msg_t chSemSignalWait(semaphore_t *sps, semaphore_t *spw) {
|
|||
return msg;
|
||||
}
|
||||
|
||||
#endif /* CH_CFG_USE_SEMAPHORES */
|
||||
#endif /* CH_CFG_USE_SEMAPHORES == TRUE */
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -96,33 +96,33 @@ thread_t *_thread_init(thread_t *tp, tprio_t prio) {
|
|||
#if CH_CFG_TIME_QUANTUM > 0
|
||||
tp->p_preempt = CH_CFG_TIME_QUANTUM;
|
||||
#endif
|
||||
#if CH_CFG_USE_MUTEXES
|
||||
#if CH_CFG_USE_MUTEXES == TRUE
|
||||
tp->p_realprio = prio;
|
||||
tp->p_mtxlist = NULL;
|
||||
#endif
|
||||
#if CH_CFG_USE_EVENTS
|
||||
#if CH_CFG_USE_EVENTS == TRUE
|
||||
tp->p_epending = 0;
|
||||
#endif
|
||||
#if CH_DBG_THREADS_PROFILING
|
||||
#if CH_DBG_THREADS_PROFILING == TRUE
|
||||
tp->p_time = 0;
|
||||
#endif
|
||||
#if CH_CFG_USE_DYNAMIC
|
||||
#if CH_CFG_USE_DYNAMIC == TRUE
|
||||
tp->p_refs = 1;
|
||||
#endif
|
||||
#if CH_CFG_USE_REGISTRY
|
||||
#if CH_CFG_USE_REGISTRY == TRUE
|
||||
tp->p_name = NULL;
|
||||
REG_INSERT(tp);
|
||||
#endif
|
||||
#if CH_CFG_USE_WAITEXIT
|
||||
#if CH_CFG_USE_WAITEXIT == TRUE
|
||||
list_init(&tp->p_waiting);
|
||||
#endif
|
||||
#if CH_CFG_USE_MESSAGES
|
||||
#if CH_CFG_USE_MESSAGES == TRUE
|
||||
queue_init(&tp->p_msgqueue);
|
||||
#endif
|
||||
#if CH_DBG_ENABLE_STACK_CHECK
|
||||
#if CH_DBG_ENABLE_STACK_CHECK == TRUE
|
||||
tp->p_stklimit = (stkalign_t *)(tp + 1);
|
||||
#endif
|
||||
#if CH_DBG_STATISTICS || defined(__DOXYGEN__)
|
||||
#if CH_DBG_STATISTICS == TRUE
|
||||
chTMObjectInit(&tp->p_stats);
|
||||
chTMStartMeasurementX(&tp->p_stats);
|
||||
#endif
|
||||
|
@ -132,7 +132,7 @@ thread_t *_thread_init(thread_t *tp, tprio_t prio) {
|
|||
return tp;
|
||||
}
|
||||
|
||||
#if CH_DBG_FILL_THREADS || defined(__DOXYGEN__)
|
||||
#if (CH_DBG_FILL_THREADS == TRUE) || defined(__DOXYGEN__)
|
||||
/**
|
||||
* @brief Memory fill utility.
|
||||
*
|
||||
|
@ -209,7 +209,7 @@ thread_t *chThdCreateStatic(void *wsp, size_t size,
|
|||
tprio_t prio, tfunc_t pf, void *arg) {
|
||||
thread_t *tp;
|
||||
|
||||
#if CH_DBG_FILL_THREADS
|
||||
#if CH_DBG_FILL_THREADS == TRUE
|
||||
_thread_memfill((uint8_t *)wsp,
|
||||
(uint8_t *)wsp + sizeof(thread_t),
|
||||
CH_DBG_THREAD_FILL_VALUE);
|
||||
|
@ -261,7 +261,7 @@ tprio_t chThdSetPriority(tprio_t newprio) {
|
|||
chDbgCheck(newprio <= HIGHPRIO);
|
||||
|
||||
chSysLock();
|
||||
#if CH_CFG_USE_MUTEXES
|
||||
#if CH_CFG_USE_MUTEXES == TRUE
|
||||
oldprio = currp->p_realprio;
|
||||
if ((currp->p_prio == currp->p_realprio) || (newprio > currp->p_prio)) {
|
||||
currp->p_prio = newprio;
|
||||
|
@ -420,12 +420,12 @@ void chThdExitS(msg_t msg) {
|
|||
#if defined(CH_CFG_THREAD_EXIT_HOOK)
|
||||
CH_CFG_THREAD_EXIT_HOOK(tp);
|
||||
#endif
|
||||
#if CH_CFG_USE_WAITEXIT
|
||||
#if CH_CFG_USE_WAITEXIT == TRUE
|
||||
while (list_notempty(&tp->p_waiting)) {
|
||||
chSchReadyI(list_remove(&tp->p_waiting));
|
||||
(void) chSchReadyI(list_remove(&tp->p_waiting));
|
||||
}
|
||||
#endif
|
||||
#if CH_CFG_USE_REGISTRY
|
||||
#if CH_CFG_USE_REGISTRY == TRUE
|
||||
/* Static threads are immediately removed from the registry because
|
||||
there is no memory to recover.*/
|
||||
if ((tp->p_flags & CH_FLAG_MODE_MASK) == CH_FLAG_MODE_STATIC) {
|
||||
|
@ -438,7 +438,7 @@ void chThdExitS(msg_t msg) {
|
|||
chDbgAssert(false, "zombies apocalypse");
|
||||
}
|
||||
|
||||
#if CH_CFG_USE_WAITEXIT || defined(__DOXYGEN__)
|
||||
#if (CH_CFG_USE_WAITEXIT == TRUE) || defined(__DOXYGEN__)
|
||||
/**
|
||||
* @brief Blocks the execution of the invoking thread until the specified
|
||||
* thread terminates then the exit code is returned.
|
||||
|
@ -477,7 +477,7 @@ msg_t chThdWait(thread_t *tp) {
|
|||
|
||||
chSysLock();
|
||||
chDbgAssert(tp != currp, "waiting self");
|
||||
#if CH_CFG_USE_DYNAMIC
|
||||
#if CH_CFG_USE_DYNAMIC == TRUE
|
||||
chDbgAssert(tp->p_refs > 0, "not referenced");
|
||||
#endif
|
||||
if (tp->p_state != CH_STATE_FINAL) {
|
||||
|
@ -487,7 +487,7 @@ msg_t chThdWait(thread_t *tp) {
|
|||
msg = tp->p_u.exitcode;
|
||||
chSysUnlock();
|
||||
|
||||
#if CH_CFG_USE_DYNAMIC
|
||||
#if CH_CFG_USE_DYNAMIC == TRUE
|
||||
chThdRelease(tp);
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue