aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2012-08-22 16:33:49 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2012-08-22 16:33:49 +0000
commit03cba7d3085ad61c55902c790099c691938eee55 (patch)
tree810591ca56f5ef5b9362e096c72d4fae395e9292
parentd51331c78ad8c4c5ad4769d6271cb0e06c11beb1 (diff)
downloadChibiOS-03cba7d3085ad61c55902c790099c691938eee55.tar.gz
ChibiOS-03cba7d3085ad61c55902c790099c691938eee55.tar.bz2
ChibiOS-03cba7d3085ad61c55902c790099c691938eee55.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4615 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r--os/kernel/include/chregistry.h3
-rw-r--r--os/kernel/include/chsys.h4
-rw-r--r--os/kernel/src/chregistry.c27
-rw-r--r--os/kernel/src/chsys.c8
4 files changed, 18 insertions, 24 deletions
diff --git a/os/kernel/include/chregistry.h b/os/kernel/include/chregistry.h
index ad12c5dd6..dc9fe4225 100644
--- a/os/kernel/include/chregistry.h
+++ b/os/kernel/include/chregistry.h
@@ -40,7 +40,8 @@ typedef struct {
uint8_t ch_reserved5; /**< @brief Reserved field. */
uint16_t ch_version; /**< @brief Encoded ChibiOS/RT version. */
uint8_t ch_ptrsize; /**< @brief Size of a pointer. */
- uint8_t ch_timesize; /**< @brief Size of a systime_t. */
+ uint8_t ch_timesize; /**< @brief Size of a @p systime_t. */
+ uint8_t ch_threadsize; /**< @brief Size of a @p Thread struct. */
uint8_t cf_off_prio; /**< @brief Offset of @p p_prio field. */
uint8_t cf_off_ctx; /**< @brief Offset of @p p_ctx field. */
uint8_t cf_off_newer; /**< @brief Offset of @p p_newer field. */
diff --git a/os/kernel/include/chsys.h b/os/kernel/include/chsys.h
index 9e623cbd1..b8784719b 100644
--- a/os/kernel/include/chsys.h
+++ b/os/kernel/include/chsys.h
@@ -233,10 +233,6 @@
#define CH_FAST_IRQ_HANDLER(id) PORT_FAST_IRQ_HANDLER(id)
/** @} */
-#if !defined(__DOXYGEN__)
-extern Thread _mainthread;
-#endif
-
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/os/kernel/src/chregistry.c b/os/kernel/src/chregistry.c
index 4a383a379..2e63a13f6 100644
--- a/os/kernel/src/chregistry.c
+++ b/os/kernel/src/chregistry.c
@@ -50,8 +50,8 @@
#if CH_USE_REGISTRY || defined(__DOXYGEN__)
-#define THD_OFFSET(field) (uint8_t)((size_t)&_mainthread.field - \
- (size_t)&_mainthread)
+#define offsetof(st, m) \
+ ((size_t)((char *)&((st *)0)->m - (char *)0))
/*
* OS signature in ROM plus debug-related information.
@@ -65,29 +65,30 @@ ROMCONST chroot_t ch_root = {
(CH_KERNEL_PATCH) << 0),
(uint8_t)sizeof (void *),
(uint8_t)sizeof (systime_t),
- THD_OFFSET(p_prio),
- THD_OFFSET(p_ctx),
- THD_OFFSET(p_newer),
- THD_OFFSET(p_older),
- THD_OFFSET(p_name),
+ (uint8_t)sizeof (Thread),
+ (uint8_t)offsetof(Thread, p_prio),
+ (uint8_t)offsetof(Thread, p_ctx),
+ (uint8_t)offsetof(Thread, p_newer),
+ (uint8_t)offsetof(Thread, p_older),
+ (uint8_t)offsetof(Thread, p_name),
#if CH_DBG_ENABLE_STACK_CHECK
- THD_OFFSET(p_stklimit),
+ (uint8_t)offsetof(Thread, p_stklimit),
#else
(uint8_t)0,
#endif
- THD_OFFSET(p_state),
- THD_OFFSET(p_flags),
+ (uint8_t)offsetof(Thread, p_state),
+ (uint8_t)offsetof(Thread, p_flags),
#if CH_USE_DYNAMIC
- THD_OFFSET(p_refs),
+ (uint8_t)offsetof(Thread, p_refs),
#else
(uint8_t)0,
#endif
#if CH_TIME_QUANTUM > 0
- THD_OFFSET(p_preempt),
+ (uint8_t)offsetof(Thread, p_preempt),
#else
(uint8_t)0,
#endif
- THD_OFFSET(p_time)
+ (uint8_t)offsetof(Thread, p_time)
};
/**
diff --git a/os/kernel/src/chsys.c b/os/kernel/src/chsys.c
index 5bc86807b..9a7be60ee 100644
--- a/os/kernel/src/chsys.c
+++ b/os/kernel/src/chsys.c
@@ -42,11 +42,6 @@
WORKING_AREA(_idle_thread_wa, PORT_IDLE_THREAD_STACK_SIZE);
/**
- * @brief Main thread structure.
- */
-Thread _mainthread;
-
-/**
* @brief This function implements the idle thread infinite loop.
* @details The function puts the processor in the lowest power mode capable
* to serve interrupts.<br>
@@ -80,6 +75,7 @@ void _idle_thread(void *p) {
* @special
*/
void chSysInit(void) {
+ static Thread mainthread;
#if CH_DBG_ENABLE_STACK_CHECK
extern stkalign_t __main_thread_stack_base__;
#endif
@@ -98,7 +94,7 @@ void chSysInit(void) {
#endif
/* Now this instructions flow becomes the main thread.*/
- setcurrp(_thread_init(&_mainthread, NORMALPRIO));
+ setcurrp(_thread_init(&mainthread, NORMALPRIO));
currp->p_state = THD_STATE_CURRENT;
#if CH_DBG_ENABLE_STACK_CHECK
/* This is a special case because the main thread Thread structure is not