summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNIIBE Yutaka <gniibe@fsij.org>2013-06-19 15:42:06 +0900
committerNIIBE Yutaka <gniibe@fsij.org>2013-06-19 15:42:06 +0900
commitd2819d14dbf70c09ef3b938849445105f11e189d (patch)
tree384abf4beea5be42764ee6c0de9c36847c81ff74
parent21d60dbec0c25bbac948779f3be9d5dc5708389f (diff)
add CHOPSTX_THREAD_SIZE
-rw-r--r--ChangeLog2
-rw-r--r--chopstx.c5
-rw-r--r--chopstx.h2
-rw-r--r--entry.c6
4 files changed, 14 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 5655301..1c061d4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
2013-06-19 Niibe Yutaka <gniibe@fsij.org>
+ * chopstx.h (CHOPSTX_THREAD_SIZE): New.
+
* rules.mk (CSRC): Add eventflag.c.
* eventflag.h, eventflag.c: New.
diff --git a/chopstx.c b/chopstx.c
index faa727e..fdb0cf7 100644
--- a/chopstx.c
+++ b/chopstx.c
@@ -840,6 +840,8 @@ chx_mutex_unlock (chopstx_mutex_t *mutex)
typedef void *(voidfunc) (void *);
+extern void cause_link_time_error_unexpected_size_of_struct_chx_thread (void);
+
/**
* chopstx_create - Create a thread
* @flags_and_prio: Flags and priority
@@ -860,6 +862,9 @@ chopstx_create (uint32_t flags_and_prio,
struct chx_stack_regs *p;
chopstx_prio_t prio = (flags_and_prio & CHOPSTX_PRIO_MASK);
+ if (CHOPSTX_THREAD_SIZE != sizeof(struct chx_thread))
+ cause_link_time_error_unexpected_size_of_struct_chx_thread ();
+
if (stack_size < sizeof (struct chx_thread) + 8 * sizeof (uint32_t))
chx_fatal (CHOPSTX_ERR_THREAD_CREATE);
diff --git a/chopstx.h b/chopstx.h
index da65928..a7df3e8 100644
--- a/chopstx.h
+++ b/chopstx.h
@@ -130,3 +130,5 @@ void chopstx_cleanup_pop (int execute);
void chopstx_wakeup_usec_wait (chopstx_t thd);
+
+#define CHOPSTX_THREAD_SIZE 60
diff --git a/entry.c b/entry.c
index 56fee96..f5cd26f 100644
--- a/entry.c
+++ b/entry.c
@@ -28,6 +28,7 @@
#include <stdint.h>
#include <stdlib.h>
+#include <chopstx.h>
#ifdef HAVE_SYS_H
#define INLINE __attribute__ ((used))
@@ -246,6 +247,9 @@ static void none (void)
{
}
+#define C_S_SUB(arg0, arg1, arg2) arg0 #arg1 arg2
+#define COMPOSE_STATEMENT(arg0,arg1,arg2) C_S_SUB (arg0, arg1, arg2)
+
/*
* This routine only changes PSP and not MSP.
*/
@@ -276,7 +280,7 @@ void entry (void)
"3:\n\t"
/* Switch to PSP. */
"ldr r0, =__process0_stack_end__\n\t"
- "sub r0, #60\n\t" /* Size of struct chx_thread. */
+ COMPOSE_STATEMENT ("sub r0, #", CHOPSTX_THREAD_SIZE, "\n\t")
"msr PSP, r0\n\t" /* Process (main routine) stack. */
"mov r1, #2\n\t"
"msr CONTROL, r1\n\t"