diff options
author | NIIBE Yutaka <gniibe@fsij.org> | 2013-06-19 15:42:06 +0900 |
---|---|---|
committer | NIIBE Yutaka <gniibe@fsij.org> | 2013-06-19 15:42:06 +0900 |
commit | d2819d14dbf70c09ef3b938849445105f11e189d (patch) | |
tree | 384abf4beea5be42764ee6c0de9c36847c81ff74 | |
parent | 21d60dbec0c25bbac948779f3be9d5dc5708389f (diff) |
add CHOPSTX_THREAD_SIZE
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | chopstx.c | 5 | ||||
-rw-r--r-- | chopstx.h | 2 | ||||
-rw-r--r-- | entry.c | 6 |
4 files changed, 14 insertions, 1 deletions
@@ -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. @@ -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); @@ -130,3 +130,5 @@ void chopstx_cleanup_pop (int execute); void chopstx_wakeup_usec_wait (chopstx_t thd); + +#define CHOPSTX_THREAD_SIZE 60 @@ -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" |