From 7fc5e3ea5acf17d3cd0274eabf80c69f7e0d49d5 Mon Sep 17 00:00:00 2001 From: batt Date: Thu, 10 Sep 2009 10:23:27 +0000 Subject: [PATCH] Fix warnings; add ASSERT. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2922 38d2e660-2303-0410-9eaa-f027e97ec537 --- bertos/kern/proc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bertos/kern/proc.c b/bertos/kern/proc.c index 437145ed..267ace6c 100644 --- a/bertos/kern/proc.c +++ b/bertos/kern/proc.c @@ -203,7 +203,7 @@ struct Process *proc_new_with_name(UNUSED_ARG(const char *, name), void (*entry) proc = (Process *)stack_base; proc->stack = stack_base + PROC_SIZE_WORDS; // On some architecture stack should be aligned, so we do it. - proc->stack = (void *)proc->stack + (sizeof(cpu_aligned_stack_t) - ((long)proc->stack % sizeof(cpu_aligned_stack_t))); + proc->stack = (cpu_stack_t *)((uintptr_t)proc->stack + (sizeof(cpu_aligned_stack_t) - ((uintptr_t)proc->stack % sizeof(cpu_aligned_stack_t)))); if (CPU_SP_ON_EMPTY_SLOT) proc->stack++; } @@ -211,10 +211,12 @@ struct Process *proc_new_with_name(UNUSED_ARG(const char *, name), void (*entry) { proc = (Process *)(stack_base + stack_size / sizeof(cpu_stack_t) - PROC_SIZE_WORDS); // On some architecture stack should be aligned, so we do it. - proc->stack = (void *)proc - ((long)proc % sizeof(cpu_aligned_stack_t)); + proc->stack = (cpu_stack_t *)((uintptr_t)proc - ((uintptr_t)proc % sizeof(cpu_aligned_stack_t))); if (CPU_SP_ON_EMPTY_SLOT) proc->stack--; } + /* Ensure stack is aligned */ + ASSERT((uintptr_t)proc->stack % sizeof(cpu_aligned_stack_t) == 0); stack_size -= PROC_SIZE_WORDS * sizeof(cpu_stack_t); proc_init_struct(proc); -- 2.25.1