git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7846 35acf78f-673a-0410-8e92-d51de3d6d3f4

This commit is contained in:
Giovanni Di Sirio 2015-04-03 09:40:49 +00:00
parent b360a11a96
commit 030fe1d908
6 changed files with 39 additions and 39 deletions

View File

@ -121,8 +121,8 @@ typedef struct {
/*===========================================================================*/ /*===========================================================================*/
#if CH_DBG_SYSTEM_STATE_CHECK == TRUE #if CH_DBG_SYSTEM_STATE_CHECK == TRUE
#define _dbg_enter_lock() (ch.dbg.lock_cnt = 1) #define _dbg_enter_lock() (ch.dbg.lock_cnt = (cnt_t)1)
#define _dbg_leave_lock() (ch.dbg.lock_cnt = 0) #define _dbg_leave_lock() (ch.dbg.lock_cnt = (cnt_t)0)
#endif #endif
/* When the state checker feature is disabled then the following functions /* When the state checker feature is disabled then the following functions

View File

@ -38,10 +38,10 @@
* @name Masks of executable integrity checks. * @name Masks of executable integrity checks.
* @{ * @{
*/ */
#define CH_INTEGRITY_RLIST 1 #define CH_INTEGRITY_RLIST 1U
#define CH_INTEGRITY_VTLIST 2 #define CH_INTEGRITY_VTLIST 2U
#define CH_INTEGRITY_REGISTRY 4 #define CH_INTEGRITY_REGISTRY 4U
#define CH_INTEGRITY_PORT 8 #define CH_INTEGRITY_PORT 8U
/** @} */ /** @} */
/*===========================================================================*/ /*===========================================================================*/

View File

@ -113,7 +113,7 @@
*/ */
void _dbg_check_disable(void) { void _dbg_check_disable(void) {
if ((ch.dbg.isr_cnt != 0) || (ch.dbg.lock_cnt != 0)) { if ((ch.dbg.isr_cnt != (cnt_t)0) || (ch.dbg.lock_cnt != (cnt_t)0)) {
chSysHalt("SV#1"); chSysHalt("SV#1");
} }
} }
@ -125,7 +125,7 @@ void _dbg_check_disable(void) {
*/ */
void _dbg_check_suspend(void) { void _dbg_check_suspend(void) {
if ((ch.dbg.isr_cnt != 0) || (ch.dbg.lock_cnt != 0)) { if ((ch.dbg.isr_cnt != (cnt_t)0) || (ch.dbg.lock_cnt != (cnt_t)0)) {
chSysHalt("SV#2"); chSysHalt("SV#2");
} }
} }
@ -137,7 +137,7 @@ void _dbg_check_suspend(void) {
*/ */
void _dbg_check_enable(void) { void _dbg_check_enable(void) {
if ((ch.dbg.isr_cnt != 0) || (ch.dbg.lock_cnt != 0)) { if ((ch.dbg.isr_cnt != (cnt_t)0) || (ch.dbg.lock_cnt != (cnt_t)0)) {
chSysHalt("SV#3"); chSysHalt("SV#3");
} }
} }
@ -149,7 +149,7 @@ void _dbg_check_enable(void) {
*/ */
void _dbg_check_lock(void) { void _dbg_check_lock(void) {
if ((ch.dbg.isr_cnt != 0) || (ch.dbg.lock_cnt != 0)) { if ((ch.dbg.isr_cnt != (cnt_t)0) || (ch.dbg.lock_cnt != (cnt_t)0)) {
chSysHalt("SV#4"); chSysHalt("SV#4");
} }
_dbg_enter_lock(); _dbg_enter_lock();
@ -162,7 +162,7 @@ void _dbg_check_lock(void) {
*/ */
void _dbg_check_unlock(void) { void _dbg_check_unlock(void) {
if ((ch.dbg.isr_cnt != 0) || (ch.dbg.lock_cnt <= 0)) { if ((ch.dbg.isr_cnt != (cnt_t)0) || (ch.dbg.lock_cnt <= (cnt_t)0)) {
chSysHalt("SV#5"); chSysHalt("SV#5");
} }
_dbg_leave_lock(); _dbg_leave_lock();
@ -175,7 +175,7 @@ void _dbg_check_unlock(void) {
*/ */
void _dbg_check_lock_from_isr(void) { void _dbg_check_lock_from_isr(void) {
if ((ch.dbg.isr_cnt <= 0) || (ch.dbg.lock_cnt != 0)) { if ((ch.dbg.isr_cnt <= (cnt_t)0) || (ch.dbg.lock_cnt != (cnt_t)0)) {
chSysHalt("SV#6"); chSysHalt("SV#6");
} }
_dbg_enter_lock(); _dbg_enter_lock();
@ -188,7 +188,7 @@ void _dbg_check_lock_from_isr(void) {
*/ */
void _dbg_check_unlock_from_isr(void) { void _dbg_check_unlock_from_isr(void) {
if ((ch.dbg.isr_cnt <= 0) || (ch.dbg.lock_cnt <= 0)) { if ((ch.dbg.isr_cnt <= (cnt_t)0) || (ch.dbg.lock_cnt <= (cnt_t)0)) {
chSysHalt("SV#7"); chSysHalt("SV#7");
} }
_dbg_leave_lock(); _dbg_leave_lock();
@ -202,7 +202,7 @@ void _dbg_check_unlock_from_isr(void) {
void _dbg_check_enter_isr(void) { void _dbg_check_enter_isr(void) {
port_lock_from_isr(); port_lock_from_isr();
if ((ch.dbg.isr_cnt < 0) || (ch.dbg.lock_cnt != 0)) { if ((ch.dbg.isr_cnt < (cnt_t)0) || (ch.dbg.lock_cnt != (cnt_t)0)) {
chSysHalt("SV#8"); chSysHalt("SV#8");
} }
ch.dbg.isr_cnt++; ch.dbg.isr_cnt++;
@ -217,7 +217,7 @@ void _dbg_check_enter_isr(void) {
void _dbg_check_leave_isr(void) { void _dbg_check_leave_isr(void) {
port_lock_from_isr(); port_lock_from_isr();
if ((ch.dbg.isr_cnt <= 0) || (ch.dbg.lock_cnt != 0)) { if ((ch.dbg.isr_cnt <= (cnt_t)0) || (ch.dbg.lock_cnt != (cnt_t)0)) {
chSysHalt("SV#9"); chSysHalt("SV#9");
} }
ch.dbg.isr_cnt--; ch.dbg.isr_cnt--;
@ -234,7 +234,7 @@ void _dbg_check_leave_isr(void) {
*/ */
void chDbgCheckClassI(void) { void chDbgCheckClassI(void) {
if ((ch.dbg.isr_cnt < 0) || (ch.dbg.lock_cnt <= 0)) { if ((ch.dbg.isr_cnt < (cnt_t)0) || (ch.dbg.lock_cnt <= (cnt_t)0)) {
chSysHalt("SV#10"); chSysHalt("SV#10");
} }
} }
@ -249,7 +249,7 @@ void chDbgCheckClassI(void) {
*/ */
void chDbgCheckClassS(void) { void chDbgCheckClassS(void) {
if ((ch.dbg.isr_cnt != 0) || (ch.dbg.lock_cnt <= 0)) { if ((ch.dbg.isr_cnt != (cnt_t)0) || (ch.dbg.lock_cnt <= (cnt_t)0)) {
chSysHalt("SV#11"); chSysHalt("SV#11");
} }
} }

View File

@ -96,7 +96,7 @@ void _heap_init(void) {
#if (CH_CFG_USE_MUTEXES == TRUE) || defined(__DOXYGEN__) #if (CH_CFG_USE_MUTEXES == TRUE) || defined(__DOXYGEN__)
chMtxObjectInit(&default_heap.h_mtx); chMtxObjectInit(&default_heap.h_mtx);
#else #else
chSemObjectInit(&default_heap.h_sem, 1); chSemObjectInit(&default_heap.h_sem, (cnt_t)1);
#endif #endif
} }
@ -124,7 +124,7 @@ void chHeapObjectInit(memory_heap_t *heapp, void *buf, size_t size) {
#if (CH_CFG_USE_MUTEXES == TRUE) || defined(__DOXYGEN__) #if (CH_CFG_USE_MUTEXES == TRUE) || defined(__DOXYGEN__)
chMtxObjectInit(&heapp->h_mtx); chMtxObjectInit(&heapp->h_mtx);
#else #else
chSemObjectInit(&heapp->h_sem, 1); chSemObjectInit(&heapp->h_sem, (cnt_t)1);
#endif #endif
} }

View File

@ -107,7 +107,7 @@ void chMtxObjectInit(mutex_t *mp) {
queue_init(&mp->m_queue); queue_init(&mp->m_queue);
mp->m_owner = NULL; mp->m_owner = NULL;
#if CH_CFG_USE_MUTEXES_RECURSIVE == TRUE #if CH_CFG_USE_MUTEXES_RECURSIVE == TRUE
mp->m_cnt = 0; mp->m_cnt = (cnt_t)0;
#endif #endif
} }
@ -146,7 +146,7 @@ void chMtxLockS(mutex_t *mp) {
if (mp->m_owner != NULL) { if (mp->m_owner != NULL) {
#if CH_CFG_USE_MUTEXES_RECURSIVE == TRUE #if CH_CFG_USE_MUTEXES_RECURSIVE == TRUE
chDbgAssert(mp->m_cnt >= 1, "counter is not positive"); chDbgAssert(mp->m_cnt >= (cnt_t)1, "counter is not positive");
/* If the mutex is already owned by this thread, the counter is increased /* If the mutex is already owned by this thread, the counter is increased
and there is no need of more actions.*/ and there is no need of more actions.*/
@ -218,13 +218,13 @@ void chMtxLockS(mutex_t *mp) {
chDbgAssert(mp->m_owner == ctp, "not owner"); chDbgAssert(mp->m_owner == ctp, "not owner");
chDbgAssert(ctp->p_mtxlist == mp, "not owned"); chDbgAssert(ctp->p_mtxlist == mp, "not owned");
#if CH_CFG_USE_MUTEXES_RECURSIVE == TRUE #if CH_CFG_USE_MUTEXES_RECURSIVE == TRUE
chDbgAssert(mp->m_cnt == 1, "counter is not one"); chDbgAssert(mp->m_cnt == (cnt_t)1, "counter is not one");
} }
#endif #endif
} }
else { else {
#if CH_CFG_USE_MUTEXES_RECURSIVE == TRUE #if CH_CFG_USE_MUTEXES_RECURSIVE == TRUE
chDbgAssert(mp->m_cnt == 0, "counter is not zero"); chDbgAssert(mp->m_cnt == (cnt_t)0, "counter is not zero");
mp->m_cnt++; mp->m_cnt++;
#endif #endif
@ -287,7 +287,7 @@ bool chMtxTryLockS(mutex_t *mp) {
if (mp->m_owner != NULL) { if (mp->m_owner != NULL) {
#if CH_CFG_USE_MUTEXES_RECURSIVE == TRUE #if CH_CFG_USE_MUTEXES_RECURSIVE == TRUE
chDbgAssert(mp->m_cnt >= 1, "counter is not positive"); chDbgAssert(mp->m_cnt >= (cnt_t)1, "counter is not positive");
if (mp->m_owner == currp) { if (mp->m_owner == currp) {
mp->m_cnt++; mp->m_cnt++;
@ -298,7 +298,7 @@ bool chMtxTryLockS(mutex_t *mp) {
} }
#if CH_CFG_USE_MUTEXES_RECURSIVE == TRUE #if CH_CFG_USE_MUTEXES_RECURSIVE == TRUE
chDbgAssert(mp->m_cnt == 0, "counter is not zero"); chDbgAssert(mp->m_cnt == (cnt_t)0, "counter is not zero");
mp->m_cnt++; mp->m_cnt++;
#endif #endif
@ -331,9 +331,9 @@ void chMtxUnlock(mutex_t *mp) {
chDbgAssert(ctp->p_mtxlist != NULL, "owned mutexes list empty"); chDbgAssert(ctp->p_mtxlist != NULL, "owned mutexes list empty");
chDbgAssert(ctp->p_mtxlist->m_owner == ctp, "ownership failure"); chDbgAssert(ctp->p_mtxlist->m_owner == ctp, "ownership failure");
#if CH_CFG_USE_MUTEXES_RECURSIVE == TRUE #if CH_CFG_USE_MUTEXES_RECURSIVE == TRUE
chDbgAssert(mp->m_cnt >= 1, "counter is not positive"); chDbgAssert(mp->m_cnt >= (cnt_t)1, "counter is not positive");
if (--mp->m_cnt == 0) { if (--mp->m_cnt == (cnt_t)0) {
#endif #endif
chDbgAssert(ctp->p_mtxlist == mp, "not next in list"); chDbgAssert(ctp->p_mtxlist == mp, "not next in list");
@ -369,7 +369,7 @@ void chMtxUnlock(mutex_t *mp) {
/* Awakens the highest priority thread waiting for the unlocked mutex and /* Awakens the highest priority thread waiting for the unlocked mutex and
assigns the mutex to it.*/ assigns the mutex to it.*/
#if CH_CFG_USE_MUTEXES_RECURSIVE == TRUE #if CH_CFG_USE_MUTEXES_RECURSIVE == TRUE
mp->m_cnt = 1; mp->m_cnt = (cnt_t)1;
#endif #endif
tp = queue_fifo_remove(&mp->m_queue); tp = queue_fifo_remove(&mp->m_queue);
mp->m_owner = tp; mp->m_owner = tp;
@ -411,9 +411,9 @@ void chMtxUnlockS(mutex_t *mp) {
chDbgAssert(ctp->p_mtxlist != NULL, "owned mutexes list empty"); chDbgAssert(ctp->p_mtxlist != NULL, "owned mutexes list empty");
chDbgAssert(ctp->p_mtxlist->m_owner == ctp, "ownership failure"); chDbgAssert(ctp->p_mtxlist->m_owner == ctp, "ownership failure");
#if CH_CFG_USE_MUTEXES_RECURSIVE == TRUE #if CH_CFG_USE_MUTEXES_RECURSIVE == TRUE
chDbgAssert(mp->m_cnt >= 1, "counter is not positive"); chDbgAssert(mp->m_cnt >= (cnt_t)1, "counter is not positive");
if (--mp->m_cnt == 0) { if (--mp->m_cnt == (cnt_t)0) {
#endif #endif
chDbgAssert(ctp->p_mtxlist == mp, "not next in list"); chDbgAssert(ctp->p_mtxlist == mp, "not next in list");
@ -449,7 +449,7 @@ void chMtxUnlockS(mutex_t *mp) {
/* Awakens the highest priority thread waiting for the unlocked mutex and /* Awakens the highest priority thread waiting for the unlocked mutex and
assigns the mutex to it.*/ assigns the mutex to it.*/
#if CH_CFG_USE_MUTEXES_RECURSIVE == TRUE #if CH_CFG_USE_MUTEXES_RECURSIVE == TRUE
mp->m_cnt = 1; mp->m_cnt = (cnt_t)1;
#endif #endif
tp = queue_fifo_remove(&mp->m_queue); tp = queue_fifo_remove(&mp->m_queue);
mp->m_owner = tp; mp->m_owner = tp;
@ -486,7 +486,7 @@ void chMtxUnlockAll(void) {
ctp->p_mtxlist = mp->m_next; ctp->p_mtxlist = mp->m_next;
if (chMtxQueueNotEmptyS(mp)) { if (chMtxQueueNotEmptyS(mp)) {
#if CH_CFG_USE_MUTEXES_RECURSIVE == TRUE #if CH_CFG_USE_MUTEXES_RECURSIVE == TRUE
mp->m_cnt = 1; mp->m_cnt = (cnt_t)1;
#endif #endif
thread_t *tp = queue_fifo_remove(&mp->m_queue); thread_t *tp = queue_fifo_remove(&mp->m_queue);
mp->m_owner = tp; mp->m_owner = tp;
@ -496,7 +496,7 @@ void chMtxUnlockAll(void) {
} }
else { else {
#if CH_CFG_USE_MUTEXES_RECURSIVE == TRUE #if CH_CFG_USE_MUTEXES_RECURSIVE == TRUE
mp->m_cnt = 0; mp->m_cnt = (cnt_t)0;
#endif #endif
mp->m_owner = NULL; mp->m_owner = NULL;
} }

View File

@ -203,7 +203,7 @@ bool chSysIntegrityCheckI(unsigned testmask) {
thread_t *tp; thread_t *tp;
/* Scanning the ready list forward.*/ /* Scanning the ready list forward.*/
n = 0; n = (cnt_t)0;
tp = ch.rlist.r_queue.p_next; tp = ch.rlist.r_queue.p_next;
while (tp != (thread_t *)&ch.rlist.r_queue) { while (tp != (thread_t *)&ch.rlist.r_queue) {
n++; n++;
@ -218,7 +218,7 @@ bool chSysIntegrityCheckI(unsigned testmask) {
} }
/* The number of elements must match.*/ /* The number of elements must match.*/
if (n != 0) { if (n != (cnt_t)0) {
return true; return true;
} }
} }
@ -228,7 +228,7 @@ bool chSysIntegrityCheckI(unsigned testmask) {
virtual_timer_t * vtp; virtual_timer_t * vtp;
/* Scanning the timers list forward.*/ /* Scanning the timers list forward.*/
n = 0; n = (cnt_t)0;
vtp = ch.vtlist.vt_next; vtp = ch.vtlist.vt_next;
while (vtp != (virtual_timer_t *)&ch.vtlist) { while (vtp != (virtual_timer_t *)&ch.vtlist) {
n++; n++;
@ -243,7 +243,7 @@ bool chSysIntegrityCheckI(unsigned testmask) {
} }
/* The number of elements must match.*/ /* The number of elements must match.*/
if (n != 0) { if (n != (cnt_t)0) {
return true; return true;
} }
} }
@ -253,7 +253,7 @@ bool chSysIntegrityCheckI(unsigned testmask) {
thread_t *tp; thread_t *tp;
/* Scanning the ready list forward.*/ /* Scanning the ready list forward.*/
n = 0; n = (cnt_t)0;
tp = ch.rlist.r_newer; tp = ch.rlist.r_newer;
while (tp != (thread_t *)&ch.rlist) { while (tp != (thread_t *)&ch.rlist) {
n++; n++;
@ -268,7 +268,7 @@ bool chSysIntegrityCheckI(unsigned testmask) {
} }
/* The number of elements must match.*/ /* The number of elements must match.*/
if (n != 0) { if (n != (cnt_t)0) {
return true; return true;
} }
} }