fix code style

This commit is contained in:
emlslxl 2018-02-24 16:10:44 +08:00
parent ef0d5ed3cd
commit 2340408e3c
3 changed files with 67 additions and 66 deletions

View File

@ -222,15 +222,15 @@ void *rt_memcpy(void *dst, const void *src, rt_ubase_t count)
char *tmp = (char *)dst, *s = (char *)src; char *tmp = (char *)dst, *s = (char *)src;
rt_ubase_t len; rt_ubase_t len;
if(tmp <= s || tmp > (s + count)) if (tmp <= s || tmp > (s + count))
{ {
while (count--) while (count--)
*tmp ++ = *s ++; *tmp ++ = *s ++;
} }
else else
{ {
for(len = count; len > 0; len --) for (len = count; len > 0; len --)
tmp[len -1] = s[len - 1]; tmp[len - 1] = s[len - 1];
} }
return dst; return dst;

View File

@ -237,9 +237,9 @@ void rt_system_heap_init(void *begin_addr, void *end_addr)
mem->next = mem_size_aligned + SIZEOF_STRUCT_MEM; mem->next = mem_size_aligned + SIZEOF_STRUCT_MEM;
mem->prev = 0; mem->prev = 0;
mem->used = 0; mem->used = 0;
#ifdef RT_USING_MEMTRACE #ifdef RT_USING_MEMTRACE
rt_mem_setname(mem, "INIT"); rt_mem_setname(mem, "INIT");
#endif #endif
/* initialize the end of the heap */ /* initialize the end of the heap */
heap_end = (struct heap_mem *)&heap_ptr[mem->next]; heap_end = (struct heap_mem *)&heap_ptr[mem->next];
@ -247,9 +247,9 @@ void rt_system_heap_init(void *begin_addr, void *end_addr)
heap_end->used = 1; heap_end->used = 1;
heap_end->next = mem_size_aligned + SIZEOF_STRUCT_MEM; heap_end->next = mem_size_aligned + SIZEOF_STRUCT_MEM;
heap_end->prev = mem_size_aligned + SIZEOF_STRUCT_MEM; heap_end->prev = mem_size_aligned + SIZEOF_STRUCT_MEM;
#ifdef RT_USING_MEMTRACE #ifdef RT_USING_MEMTRACE
rt_mem_setname(heap_end, "INIT"); rt_mem_setname(heap_end, "INIT");
#endif #endif
rt_sem_init(&heap_sem, "heap", 1, RT_IPC_FLAG_FIFO); rt_sem_init(&heap_sem, "heap", 1, RT_IPC_FLAG_FIFO);
@ -335,9 +335,9 @@ void *rt_malloc(rt_size_t size)
mem2->used = 0; mem2->used = 0;
mem2->next = mem->next; mem2->next = mem->next;
mem2->prev = ptr; mem2->prev = ptr;
#ifdef RT_USING_MEMTRACE #ifdef RT_USING_MEMTRACE
rt_mem_setname(mem2, " "); rt_mem_setname(mem2, " ");
#endif #endif
/* and insert it between mem and mem->next */ /* and insert it between mem and mem->next */
mem->next = ptr2; mem->next = ptr2;
@ -371,12 +371,12 @@ void *rt_malloc(rt_size_t size)
} }
/* set memory block magic */ /* set memory block magic */
mem->magic = HEAP_MAGIC; mem->magic = HEAP_MAGIC;
#ifdef RT_USING_MEMTRACE #ifdef RT_USING_MEMTRACE
if (rt_thread_self()) if (rt_thread_self())
rt_mem_setname(mem, rt_thread_self()->name); rt_mem_setname(mem, rt_thread_self()->name);
else else
rt_mem_setname(mem, "NONE"); rt_mem_setname(mem, "NONE");
#endif #endif
if (mem == lfree) if (mem == lfree)
{ {
@ -642,7 +642,7 @@ int memcheck(void)
rt_uint32_t level; rt_uint32_t level;
struct heap_mem *mem; struct heap_mem *mem;
level = rt_hw_interrupt_disable(); level = rt_hw_interrupt_disable();
for (mem = (struct heap_mem*)heap_ptr; mem != heap_end; mem = (struct heap_mem*)&heap_ptr[mem->next]) for (mem = (struct heap_mem *)heap_ptr; mem != heap_end; mem = (struct heap_mem *)&heap_ptr[mem->next])
{ {
position = (rt_uint32_t)mem - (rt_uint32_t)heap_ptr; position = (rt_uint32_t)mem - (rt_uint32_t)heap_ptr;
if (position < 0) goto __exit; if (position < 0) goto __exit;
@ -665,7 +665,7 @@ __exit:
} }
MSH_CMD_EXPORT(memcheck, check memory data); MSH_CMD_EXPORT(memcheck, check memory data);
int memtrace(int argc, char** argv) int memtrace(int argc, char **argv)
{ {
struct heap_mem *mem; struct heap_mem *mem;
@ -677,7 +677,7 @@ int memtrace(int argc, char** argv)
rt_kprintf("heap_end: 0x%08x\n", heap_end); rt_kprintf("heap_end: 0x%08x\n", heap_end);
rt_kprintf("\n--memory item information --\n"); rt_kprintf("\n--memory item information --\n");
for (mem = (struct heap_mem*)heap_ptr; mem != heap_end; mem = (struct heap_mem*)&heap_ptr[mem->next]) for (mem = (struct heap_mem *)heap_ptr; mem != heap_end; mem = (struct heap_mem *)&heap_ptr[mem->next])
{ {
int position = (rt_uint32_t)mem - (rt_uint32_t)heap_ptr; int position = (rt_uint32_t)mem - (rt_uint32_t)heap_ptr;
int size; int size;

View File

@ -59,7 +59,7 @@ static void _signal_default_handler(int signo)
return ; return ;
} }
static void _signal_entry(void* parameter) static void _signal_entry(void *parameter)
{ {
rt_thread_t tid = rt_thread_self(); rt_thread_t tid = rt_thread_self();
@ -77,7 +77,7 @@ static void _signal_entry(void* parameter)
dbg_log(DBG_LOG, "switch back to: 0x%08x\n", tid->sp); dbg_log(DBG_LOG, "switch back to: 0x%08x\n", tid->sp);
tid->stat &= ~RT_THREAD_STAT_SIGNAL; tid->stat &= ~RT_THREAD_STAT_SIGNAL;
rt_hw_context_switch_to((rt_uint32_t)&(tid->sp)); rt_hw_context_switch_to((rt_uint32_t) & (tid->sp));
} }
static void _signal_deliver(rt_thread_t tid) static void _signal_deliver(rt_thread_t tid)
@ -116,7 +116,7 @@ static void _signal_deliver(rt_thread_t tid)
tid->stat |= RT_THREAD_STAT_SIGNAL; tid->stat |= RT_THREAD_STAT_SIGNAL;
/* point to the signal handle entry */ /* point to the signal handle entry */
tid->sig_ret = tid->sp; tid->sig_ret = tid->sp;
tid->sp = rt_hw_stack_init((void*)_signal_entry, RT_NULL, tid->sp = rt_hw_stack_init((void *)_signal_entry, RT_NULL,
(void *)((char *)tid->sig_ret - 32), RT_NULL); (void *)((char *)tid->sig_ret - 32), RT_NULL);
rt_hw_interrupt_enable(level); rt_hw_interrupt_enable(level);
@ -211,7 +211,7 @@ void rt_thread_handle_sig(rt_bool_t clean_state)
if (si_node->list.next == RT_NULL) if (si_node->list.next == RT_NULL)
tid->si_list = RT_NULL; tid->si_list = RT_NULL;
else else
tid->si_list = (void*)rt_slist_entry(si_node->list.next, struct siginfo_node, list); tid->si_list = (void *)rt_slist_entry(si_node->list.next, struct siginfo_node, list);
signo = si_node->si.si_signo; signo = si_node->si.si_signo;
handler = tid->sig_vectors[signo]; handler = tid->sig_vectors[signo];
@ -261,7 +261,7 @@ void rt_thread_free_sig(rt_thread_t tid)
rt_sighandler_t *sig_vectors; rt_sighandler_t *sig_vectors;
level = rt_hw_interrupt_disable(); level = rt_hw_interrupt_disable();
si_list = (struct siginfo_node*)tid->si_list; si_list = (struct siginfo_node *)tid->si_list;
tid->si_list = RT_NULL; tid->si_list = RT_NULL;
sig_vectors = tid->sig_vectors; sig_vectors = tid->sig_vectors;
@ -275,7 +275,8 @@ void rt_thread_free_sig(rt_thread_t tid)
dbg_log(DBG_LOG, "free signal info list\n"); dbg_log(DBG_LOG, "free signal info list\n");
node = &(si_list->list); node = &(si_list->list);
do { do
{
si_node = rt_slist_entry(node, struct siginfo_node, list); si_node = rt_slist_entry(node, struct siginfo_node, list);
rt_mp_free(si_node); rt_mp_free(si_node);
@ -338,7 +339,7 @@ int rt_thread_kill(rt_thread_t tid, int sig)
} }
rt_hw_interrupt_enable(level); rt_hw_interrupt_enable(level);
si_node = (struct siginfo_node*) rt_mp_alloc(_rt_siginfo_pool, 0); si_node = (struct siginfo_node *) rt_mp_alloc(_rt_siginfo_pool, 0);
if (si_node) if (si_node)
{ {
rt_slist_init(&(si_node->list)); rt_slist_init(&(si_node->list));
@ -350,7 +351,7 @@ int rt_thread_kill(rt_thread_t tid, int sig)
{ {
struct siginfo_node *si_list; struct siginfo_node *si_list;
si_list = (struct siginfo_node*)tid->si_list; si_list = (struct siginfo_node *)tid->si_list;
rt_slist_append(&(si_list->list), &(si_node->list)); rt_slist_append(&(si_list->list), &(si_node->list));
} }
rt_hw_interrupt_enable(level); rt_hw_interrupt_enable(level);