diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2009-02-07 12:42:29 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2009-02-07 12:42:29 +0000 |
commit | b08638d7c8e46b3a207705a2e55fdfe4b78cfb3e (patch) | |
tree | f9e60d830d48036b3012822a4eedb909c3c4ce25 /src/include | |
parent | 37c2720510cf319159d19398533169711d092f6b (diff) | |
download | ChibiOS-b08638d7c8e46b3a207705a2e55fdfe4b78cfb3e.tar.gz ChibiOS-b08638d7c8e46b3a207705a2e55fdfe4b78cfb3e.tar.bz2 ChibiOS-b08638d7c8e46b3a207705a2e55fdfe4b78cfb3e.zip |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@735 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/ch.h | 20 | ||||
-rw-r--r-- | src/include/condvars.h | 6 | ||||
-rw-r--r-- | src/include/debug.h | 11 | ||||
-rw-r--r-- | src/include/events.h | 8 | ||||
-rw-r--r-- | src/include/inline.h | 2 | ||||
-rw-r--r-- | src/include/lists.h | 4 | ||||
-rw-r--r-- | src/include/mempools.h | 2 | ||||
-rw-r--r-- | src/include/messages.h | 4 | ||||
-rw-r--r-- | src/include/mutexes.h | 2 | ||||
-rw-r--r-- | src/include/queues.h | 8 | ||||
-rw-r--r-- | src/include/scheduler.h | 6 | ||||
-rw-r--r-- | src/include/semaphores.h | 6 | ||||
-rw-r--r-- | src/include/serial.h | 4 | ||||
-rw-r--r-- | src/include/sys.h | 24 | ||||
-rw-r--r-- | src/include/threads.h | 30 |
15 files changed, 71 insertions, 66 deletions
diff --git a/src/include/ch.h b/src/include/ch.h index 374941e3e..8303d90f6 100644 --- a/src/include/ch.h +++ b/src/include/ch.h @@ -52,6 +52,16 @@ */
#define CH_KERNEL_PATCH 0
+/*
+ * Common values.
+ */
+#ifndef FALSE
+#define FALSE 0
+#endif
+#ifndef TRUE
+#define TRUE (!FALSE)
+#endif
+
#include <chconf.h>
#include <chtypes.h>
#include "lists.h"
@@ -72,16 +82,6 @@ #include "serial.h"
#include "debug.h"
-/*
- * Common values.
- */
-#ifndef FALSE
-#define FALSE 0
-#endif
-#ifndef TRUE
-#define TRUE (!FALSE)
-#endif
-
#endif /* _CH_H_ */
/** @} */
diff --git a/src/include/condvars.h b/src/include/condvars.h index a311ba526..90c78eccf 100644 --- a/src/include/condvars.h +++ b/src/include/condvars.h @@ -31,7 +31,7 @@ #ifndef _CONDVARS_H_
#define _CONDVARS_H_
-#if defined(CH_USE_CONDVARS) && defined(CH_USE_MUTEXES)
+#if CH_USE_CONDVARS && CH_USE_MUTEXES
/**
* @brief CondVar structure.
@@ -50,7 +50,7 @@ extern "C" { void chCondBroadcastI(CondVar *cp);
msg_t chCondWait(CondVar *cp);
msg_t chCondWaitS(CondVar *cp);
-#ifdef CH_USE_CONDVARS_TIMEOUT
+#if CH_USE_CONDVARS_TIMEOUT
msg_t chCondWaitTimeout(CondVar *cp, systime_t time);
msg_t chCondWaitTimeoutS(CondVar *cp, systime_t time);
#endif
@@ -58,7 +58,7 @@ extern "C" { }
#endif
-#endif /* defined(CH_USE_CONDVARS) && defined(CH_USE_MUTEXES) */
+#endif /* CH_USE_CONDVARS && CH_USE_MUTEXES */
#endif /* _CONDVARS_H_ */
diff --git a/src/include/debug.h b/src/include/debug.h index a6b4ca7c1..37400d967 100644 --- a/src/include/debug.h +++ b/src/include/debug.h @@ -27,16 +27,21 @@ #ifndef _DEBUG_H_
#define _DEBUG_H_
-#ifdef CH_USE_DEBUG
+#if CH_USE_DEBUG
+/**
+ * @brief Trace buffer entries. + */
#ifndef TRACE_BUFFER_SIZE
#define TRACE_BUFFER_SIZE 64
#endif
/**
- * Fill value for threads working area in debug mode.
+ * @brief Fill value for threads working area in debug mode.
*/
+#ifndef MEM_FILL_PATTERN
#define MEM_FILL_PATTERN 0x55
+#endif
/**
* @brief Trace buffer record. @@ -91,7 +96,7 @@ extern "C" { #endif /* CH_USE_DEBUG */
-#ifdef CH_USE_TRACE
+#if CH_USE_TRACE
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/src/include/events.h b/src/include/events.h index 5def8f065..ada7812d1 100644 --- a/src/include/events.h +++ b/src/include/events.h @@ -27,7 +27,7 @@ #ifndef _EVENTS_H_
#define _EVENTS_H_
-#ifdef CH_USE_EVENTS
+#if CH_USE_EVENTS
/** All events allowed mask.*/
#define ALL_EVENTS -1
@@ -89,12 +89,12 @@ extern "C" { void chEvtBroadcast(EventSource *esp);
void chEvtBroadcastI(EventSource *esp);
void chEvtDispatch(const evhandler_t handlers[], eventmask_t mask);
-#if defined(CH_OPTIMIZE_SPEED) || !defined(CH_USE_EVENTS_TIMEOUT)
+#if CH_OPTIMIZE_SPEED || !CH_USE_EVENTS_TIMEOUT
eventmask_t chEvtWaitOne(eventmask_t ewmask);
eventmask_t chEvtWaitAny(eventmask_t ewmask);
eventmask_t chEvtWaitAll(eventmask_t ewmask);
#endif
-#ifdef CH_USE_EVENTS_TIMEOUT
+#if CH_USE_EVENTS_TIMEOUT
eventmask_t chEvtWaitOneTimeout(eventmask_t ewmask, systime_t time);
eventmask_t chEvtWaitAnyTimeout(eventmask_t ewmask, systime_t time);
eventmask_t chEvtWaitAllTimeout(eventmask_t ewmask, systime_t time);
@@ -116,7 +116,7 @@ extern "C" { */
#define chEvtRegister(esp, elp, eid) chEvtRegisterMask(esp, elp, EVENT_MASK(eid))
-#if !defined(CH_OPTIMIZE_SPEED) && defined(CH_USE_EVENTS_TIMEOUT)
+#if !CH_OPTIMIZE_SPEED && CH_USE_EVENTS_TIMEOUT
#define chEvtWaitOne(ewmask) chEvtWaitOneTimeout(ewmask, TIME_INFINITE)
#define chEvtWaitAny(ewmask) chEvtWaitAnyTimeout(ewmask, TIME_INFINITE)
#define chEvtWaitAll(ewmask) chEvtWaitAllTimeout(ewmask, TIME_INFINITE)
diff --git a/src/include/inline.h b/src/include/inline.h index 6f99ff329..0da909f8f 100644 --- a/src/include/inline.h +++ b/src/include/inline.h @@ -32,7 +32,7 @@ * Note: static inlined functions do not duplicate the code in every module
* this is true for GCC, not sure about other compilers.
*/
-#ifdef CH_OPTIMIZE_SPEED
+#if CH_OPTIMIZE_SPEED
static INLINE void prio_insert(Thread *tp, ThreadsQueue *tqp) {
Thread *cp = tqp->p_next;
diff --git a/src/include/lists.h b/src/include/lists.h index a86d8175e..b858a7c69 100644 --- a/src/include/lists.h +++ b/src/include/lists.h @@ -63,7 +63,7 @@ typedef struct { */
#define list_init(tlp) ((tlp)->p_next = (Thread *)(tlp))
-#ifndef CH_OPTIMIZE_SPEED
+#if !CH_OPTIMIZE_SPEED
#ifdef __cplusplus
extern "C" {
@@ -79,7 +79,7 @@ extern "C" { }
#endif
-#endif /* CH_OPTIMIZE_SPEED */
+#endif /* !CH_OPTIMIZE_SPEED */
#endif /* _LISTS_H_ */
diff --git a/src/include/mempools.h b/src/include/mempools.h index 7bf67c77a..537ca3425 100644 --- a/src/include/mempools.h +++ b/src/include/mempools.h @@ -27,7 +27,7 @@ #ifndef _MEMPOOLS_H_
#define _MEMPOOLS_H_
-#ifdef CH_USE_MEMPOOLS
+#if CH_USE_MEMPOOLS
/**
* @brief Memory pool free object header. diff --git a/src/include/messages.h b/src/include/messages.h index c74febaf5..1c4876b81 100644 --- a/src/include/messages.h +++ b/src/include/messages.h @@ -27,7 +27,7 @@ #ifndef _MESSAGES_H_
#define _MESSAGES_H_
-#ifdef CH_USE_MESSAGES
+#if CH_USE_MESSAGES
/**
* Evaluates to TRUE if the thread has pending messages.
@@ -49,7 +49,7 @@ extern "C" { msg_t chMsgGet(void);
void chMsgRelease(msg_t msg);
-#if defined(CH_USE_EVENTS) && defined(CH_USE_MESSAGES_EVENT)
+#if CH_USE_EVENTS && CH_USE_MESSAGES_EVENT
msg_t chMsgSendWithEvent(Thread *tp, msg_t msg, eventmask_t mask);
#endif
#ifdef __cplusplus
diff --git a/src/include/mutexes.h b/src/include/mutexes.h index d3e987ddf..16b59f695 100644 --- a/src/include/mutexes.h +++ b/src/include/mutexes.h @@ -27,7 +27,7 @@ #ifndef _MUTEXES_H_
#define _MUTEXES_H_
-#ifdef CH_USE_MUTEXES
+#if CH_USE_MUTEXES
/**
* @brief Mutex structure.
diff --git a/src/include/queues.h b/src/include/queues.h index 418ff73a8..36495f1a7 100644 --- a/src/include/queues.h +++ b/src/include/queues.h @@ -41,7 +41,7 @@ typedef void (*qnotify_t)(void); /** Returned by the queue functions if the queue is full. */ #define Q_FULL -4 -#ifdef CH_USE_QUEUES +#if CH_USE_QUEUES /** * @brief I/O queue structure. * @details This structure is used by both Input and Output Queues, @@ -94,7 +94,7 @@ extern "C" { msg_t chIQPutI(Queue *qp, uint8_t b); msg_t chIQGet(Queue *qp); size_t chIQRead(Queue *qp, uint8_t *buffer, size_t n); -#ifdef CH_USE_QUEUES_TIMEOUT +#if CH_USE_QUEUES_TIMEOUT msg_t chIQGetTimeout(Queue *qp, systime_t time); #endif @@ -112,7 +112,7 @@ extern "C" { #endif #endif /* CH_USE_QUEUES */ -#ifdef CH_USE_QUEUES_HALFDUPLEX +#if CH_USE_QUEUES_HALFDUPLEX /** * @brief Half duplex queue structure. */ @@ -163,7 +163,7 @@ extern "C" { void chHDQPutTransmit(HalfDuplexQueue *qp, uint8_t b); msg_t chHDQGetTransmitI(HalfDuplexQueue *qp); msg_t chHDQPutReceiveI(HalfDuplexQueue *qp, uint8_t b); -#ifdef CH_USE_QUEUES_TIMEOUT +#if CH_USE_QUEUES_TIMEOUT msg_t chHDQGetReceiveTimeout(HalfDuplexQueue *qp, systime_t time); #endif #ifdef __cplusplus diff --git a/src/include/scheduler.h b/src/include/scheduler.h index 25df4a3bd..612ee8c55 100644 --- a/src/include/scheduler.h +++ b/src/include/scheduler.h @@ -61,10 +61,10 @@ typedef struct { tprio_t r_prio; /**< This field must be initialized to zero.*/ /* End of the fields shared with the Thread structure. */ -#ifdef CH_USE_ROUNDROBIN +#if CH_USE_ROUNDROBIN cnt_t r_preempt; /**< Round robin counter.*/ #endif -#ifndef CH_CURRP_REGISTER_CACHE +#if !CH_CURRP_REGISTER_CACHE Thread *r_current; /**< The currently running thread.*/ #endif } ReadyList; @@ -89,7 +89,7 @@ extern "C" { } #endif -#ifdef CH_CURRP_REGISTER_CACHE +#if CH_CURRP_REGISTER_CACHE register Thread *currp asm(CH_CURRP_REGISTER_CACHE); #else #define currp rlist.r_current diff --git a/src/include/semaphores.h b/src/include/semaphores.h index bb25b4609..25f11b06b 100644 --- a/src/include/semaphores.h +++ b/src/include/semaphores.h @@ -27,7 +27,7 @@ #ifndef _SEMAPHORES_H_
#define _SEMAPHORES_H_
-#ifdef CH_USE_SEMAPHORES
+#if CH_USE_SEMAPHORES
/**
* @brief Semaphore structure.
@@ -46,13 +46,13 @@ extern "C" { void chSemResetI(Semaphore *sp, cnt_t n);
msg_t chSemWait(Semaphore *sp);
msg_t chSemWaitS(Semaphore *sp);
-#ifdef CH_USE_SEMAPHORES_TIMEOUT
+#if CH_USE_SEMAPHORES_TIMEOUT
msg_t chSemWaitTimeout(Semaphore *sp, systime_t time);
msg_t chSemWaitTimeoutS(Semaphore *sp, systime_t time);
#endif
void chSemSignal(Semaphore *sp);
void chSemSignalI(Semaphore *sp);
-#ifdef CH_USE_SEMSW
+#if CH_USE_SEMSW
msg_t chSemSignalWait(Semaphore *sps, Semaphore *spw);
#endif
#ifdef __cplusplus
diff --git a/src/include/serial.h b/src/include/serial.h index 6a6299cf3..ebb3392bb 100644 --- a/src/include/serial.h +++ b/src/include/serial.h @@ -45,7 +45,7 @@ /** Serial Driver condition flags type.*/
typedef uint16_t dflags_t;
-#ifdef CH_USE_SERIAL_FULLDUPLEX
+#if CH_USE_SERIAL_FULLDUPLEX
/**
* @brief Full Duplex Serial Driver main structure.
@@ -110,7 +110,7 @@ extern "C" { #endif /* CH_USE_SERIAL_FULLDUPLEX */
-#ifdef CH_USE_SERIAL_HALFDUPLEX
+#if CH_USE_SERIAL_HALFDUPLEX
/**
* @brief Full Duplex Serial Driver main structure.
diff --git a/src/include/sys.h b/src/include/sys.h index f559b5f52..ccc71ae7f 100644 --- a/src/include/sys.h +++ b/src/include/sys.h @@ -96,16 +96,16 @@ * a better idea to use the semaphores or mutexes instead.
* @see CH_USE_NESTED_LOCKS
*/
-#if defined(CH_USE_NESTED_LOCKS) || defined(__DOXYGEN__)
-#if defined(CH_OPTIMIZE_SPEED) || defined(__DOXYGEN__)
+#if CH_USE_NESTED_LOCKS || defined(__DOXYGEN__)
+#if CH_OPTIMIZE_SPEED || defined(__DOXYGEN__)
#define chSysLock() { \
if (currp->p_locks++ == 0) \
- port_lock(); \
+ port_lock(); \
}
-#endif /* defined(CH_OPTIMIZE_SPEED) */
-#else /* !defined(CH_USE_NESTED_LOCKS) */
+#endif /* CH_OPTIMIZE_SPEED */
+#else /* !CH_USE_NESTED_LOCKS */
#define chSysLock() port_lock()
-#endif /* !defined(CH_USE_NESTED_LOCKS) */
+#endif /* !CH_USE_NESTED_LOCKS */
/**
* @brief Leaves the kernel lock mode.
@@ -114,16 +114,16 @@ * a better idea to use the semaphores or mutexes instead.
* @see CH_USE_NESTED_LOCKS
*/
-#if defined(CH_USE_NESTED_LOCKS) || defined(__DOXYGEN__)
-#if defined(CH_OPTIMIZE_SPEED) || defined(__DOXYGEN__)
+#if CH_USE_NESTED_LOCKS || defined(__DOXYGEN__)
+#if CH_OPTIMIZE_SPEED || defined(__DOXYGEN__)
#define chSysUnlock() { \
if (--currp->p_locks == 0) \
- port_unlock(); \
+ port_unlock(); \
}
-#endif /* defined(CH_OPTIMIZE_SPEED) */
-#else /* !defined(CH_USE_NESTED_LOCKS) */
+#endif /* CH_OPTIMIZE_SPEED */
+#else /* !CH_USE_NESTED_LOCKS */
#define chSysUnlock() port_unlock()
-#endif /* !defined(CH_USE_NESTED_LOCKS) */
+#endif /* !CH_USE_NESTED_LOCKS */
/**
* @brief Enters the kernel lock mode from within an interrupt handler.
diff --git a/src/include/threads.h b/src/include/threads.h index c3f89d99b..3c279bf3c 100644 --- a/src/include/threads.h +++ b/src/include/threads.h @@ -47,7 +47,7 @@ struct Thread { tstate_t p_state; /**< Current thread state.*/ tmode_t p_flags; /**< Various flags.*/ struct context p_ctx; /**< Processor context.*/ -#ifdef CH_USE_NESTED_LOCKS +#if CH_USE_NESTED_LOCKS cnt_t p_locks; /**< Number of nested locks.*/ #endif /* @@ -59,27 +59,27 @@ struct Thread { msg_t p_rdymsg; /**< Thread wakeup code.*/ msg_t p_exitcode; /**< The thread exit code (@p PREXIT state).*/ -#ifdef CH_USE_SEMAPHORES +#if CH_USE_SEMAPHORES Semaphore *p_wtsemp; /**< Semaphore where the thread is waiting on (@p PRWTSEM state).*/ #endif -#ifdef CH_USE_MUTEXES +#if CH_USE_MUTEXES Mutex *p_wtmtxp; /**< Mutex where the thread is waiting on (@p PRWTMTX state).*/ #endif -#ifdef CH_USE_CONDVARS +#if CH_USE_CONDVARS CondVar *p_wtcondp; /**< CondVar where the thread is waiting on (@p PRWTCOND state).*/ #endif -#ifdef CH_USE_MESSAGES +#if CH_USE_MESSAGES Thread *p_wtthdp; /**< Destination thread for message send @p PRSNDMSG state).*/ #endif -#ifdef CH_USE_EVENTS +#if CH_USE_EVENTS eventmask_t p_ewmask; /**< Enabled events mask (@p PRWTOREVT or @p PRWTANDEVT states).*/ #endif -#ifdef CH_USE_TRACE +#if CH_USE_TRACE void *p_wtobjp; /**< Generic kernel object pointer used for opaque access.*/ #endif @@ -87,23 +87,23 @@ struct Thread { /* * Start of the optional fields. */ -#ifdef CH_USE_WAITEXIT +#if CH_USE_WAITEXIT Thread *p_waiting; /**< Thread waiting for termination.*/ #endif -#ifdef CH_USE_MESSAGES +#if CH_USE_MESSAGES ThreadsQueue p_msgqueue; /**< Message queue.*/ msg_t p_msg; /**< The message.*/ #endif -#ifdef CH_USE_EVENTS +#if CH_USE_EVENTS eventmask_t p_epending; /**< Pending events mask.*/ #endif -#ifdef CH_USE_MUTEXES +#if CH_USE_MUTEXES Mutex *p_mtxlist; /**< List of the mutexes owned by this thread, @p NULL terminated.*/ tprio_t p_realprio; /**< Thread's own, non-inherited, priority.*/ #endif -#if defined(CH_USE_DYNAMIC) && defined(CH_USE_MEMPOOLS) +#if CH_USE_DYNAMIC && CH_USE_MEMPOOLS void *p_mpool; /**< Memory Pool where the thread workspace is returned.*/ #endif @@ -164,11 +164,11 @@ extern "C" { tprio_t prio, tfunc_t pf, void *arg); Thread *chThdCreateStatic(void *workspace, size_t wsize, tprio_t prio, tfunc_t pf, void *arg); -#if defined(CH_USE_DYNAMIC) && defined(CH_USE_WAITEXIT) && defined(CH_USE_HEAP) +#if CH_USE_DYNAMIC && CH_USE_WAITEXIT && CH_USE_HEAP Thread *chThdCreateFromHeap(size_t wsize, tprio_t prio, tfunc_t pf, void *arg); #endif -#if defined(CH_USE_DYNAMIC) && defined(CH_USE_WAITEXIT) && defined(CH_USE_MEMPOOLS) +#if CH_USE_DYNAMIC && CH_USE_WAITEXIT && CH_USE_MEMPOOLS Thread *chThdCreateFromMemoryPool(MemoryPool *mp, tprio_t prio, tfunc_t pf, void *arg); #endif @@ -178,7 +178,7 @@ extern "C" { void chThdSleep(systime_t time); void chThdSleepUntil(systime_t time); void chThdExit(msg_t msg); -#ifdef CH_USE_WAITEXIT +#if CH_USE_WAITEXIT msg_t chThdWait(Thread *tp); #endif #ifdef __cplusplus |