commit
610388857e
|
@ -222,15 +222,15 @@ void *rt_memcpy(void *dst, const void *src, rt_ubase_t count)
|
|||
char *tmp = (char *)dst, *s = (char *)src;
|
||||
rt_ubase_t len;
|
||||
|
||||
if(tmp <= s || tmp > (s + count))
|
||||
if (tmp <= s || tmp > (s + count))
|
||||
{
|
||||
while (count--)
|
||||
*tmp ++ = *s ++;
|
||||
}
|
||||
else
|
||||
{
|
||||
for(len = count; len > 0; len --)
|
||||
tmp[len -1] = s[len - 1];
|
||||
for (len = count; len > 0; len --)
|
||||
tmp[len - 1] = s[len - 1];
|
||||
}
|
||||
|
||||
return dst;
|
||||
|
|
22
src/mem.c
22
src/mem.c
|
@ -237,9 +237,9 @@ void rt_system_heap_init(void *begin_addr, void *end_addr)
|
|||
mem->next = mem_size_aligned + SIZEOF_STRUCT_MEM;
|
||||
mem->prev = 0;
|
||||
mem->used = 0;
|
||||
#ifdef RT_USING_MEMTRACE
|
||||
#ifdef RT_USING_MEMTRACE
|
||||
rt_mem_setname(mem, "INIT");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* initialize the end of the heap */
|
||||
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->next = 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");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
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->next = mem->next;
|
||||
mem2->prev = ptr;
|
||||
#ifdef RT_USING_MEMTRACE
|
||||
#ifdef RT_USING_MEMTRACE
|
||||
rt_mem_setname(mem2, " ");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* and insert it between mem and mem->next */
|
||||
mem->next = ptr2;
|
||||
|
@ -371,12 +371,12 @@ void *rt_malloc(rt_size_t size)
|
|||
}
|
||||
/* set memory block magic */
|
||||
mem->magic = HEAP_MAGIC;
|
||||
#ifdef RT_USING_MEMTRACE
|
||||
#ifdef RT_USING_MEMTRACE
|
||||
if (rt_thread_self())
|
||||
rt_mem_setname(mem, rt_thread_self()->name);
|
||||
else
|
||||
rt_mem_setname(mem, "NONE");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (mem == lfree)
|
||||
{
|
||||
|
@ -642,7 +642,7 @@ int memcheck(void)
|
|||
rt_uint32_t level;
|
||||
struct heap_mem *mem;
|
||||
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;
|
||||
if (position < 0) goto __exit;
|
||||
|
@ -665,7 +665,7 @@ __exit:
|
|||
}
|
||||
MSH_CMD_EXPORT(memcheck, check memory data);
|
||||
|
||||
int memtrace(int argc, char** argv)
|
||||
int memtrace(int argc, char **argv)
|
||||
{
|
||||
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("\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 size;
|
||||
|
|
17
src/signal.c
17
src/signal.c
|
@ -59,7 +59,7 @@ static void _signal_default_handler(int signo)
|
|||
return ;
|
||||
}
|
||||
|
||||
static void _signal_entry(void* parameter)
|
||||
static void _signal_entry(void *parameter)
|
||||
{
|
||||
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);
|
||||
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)
|
||||
|
@ -116,7 +116,7 @@ static void _signal_deliver(rt_thread_t tid)
|
|||
tid->stat |= RT_THREAD_STAT_SIGNAL;
|
||||
/* point to the signal handle entry */
|
||||
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);
|
||||
|
||||
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)
|
||||
tid->si_list = RT_NULL;
|
||||
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;
|
||||
handler = tid->sig_vectors[signo];
|
||||
|
@ -261,7 +261,7 @@ void rt_thread_free_sig(rt_thread_t tid)
|
|||
rt_sighandler_t *sig_vectors;
|
||||
|
||||
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;
|
||||
|
||||
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");
|
||||
node = &(si_list->list);
|
||||
do {
|
||||
do
|
||||
{
|
||||
si_node = rt_slist_entry(node, struct siginfo_node, list);
|
||||
rt_mp_free(si_node);
|
||||
|
||||
|
@ -338,7 +339,7 @@ int rt_thread_kill(rt_thread_t tid, int sig)
|
|||
}
|
||||
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)
|
||||
{
|
||||
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;
|
||||
|
||||
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_hw_interrupt_enable(level);
|
||||
|
|
Loading…
Reference in New Issue