Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Xiaobo07
rt-thread
提交
61038885
R
rt-thread
项目概览
Xiaobo07
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
2
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
61038885
编写于
2月 24, 2018
作者:
B
Bernard Xiong
提交者:
GitHub
2月 24, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1230 from emlslxl/code_style
fix code style
上级
ef0d5ed3
2340408e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
68 addition
and
67 deletion
+68
-67
src/kservice.c
src/kservice.c
+5
-5
src/mem.c
src/mem.c
+11
-11
src/signal.c
src/signal.c
+52
-51
未找到文件。
src/kservice.c
浏览文件 @
61038885
...
...
@@ -221,19 +221,19 @@ void *rt_memcpy(void *dst, const void *src, rt_ubase_t count)
#ifdef RT_USING_TINY_SIZE
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
;
return
dst
;
#else
#define UNALIGNED(X, Y) \
...
...
src/mem.c
浏览文件 @
61038885
...
...
@@ -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
;
...
...
src/signal.c
浏览文件 @
61038885
...
...
@@ -31,7 +31,7 @@
#ifdef RT_USING_SIGNALS
#ifndef RT_SIG_INFO_MAX
#define RT_SIG_INFO_MAX
32
#define RT_SIG_INFO_MAX
32
#endif
// #define DBG_ENABLE
...
...
@@ -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
();
...
...
@@ -68,8 +68,8 @@ static void _signal_entry(void* parameter)
/* handle signal */
rt_thread_handle_sig
(
RT_FALSE
);
/* never come back... */
rt_hw_interrupt_disable
();
/* never come back... */
rt_hw_interrupt_disable
();
/* return to thread */
tid
->
sp
=
tid
->
sig_ret
;
tid
->
sig_ret
=
RT_NULL
;
...
...
@@ -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
)
...
...
@@ -92,8 +92,8 @@ static void _signal_deliver(rt_thread_t tid)
{
/* resume thread to handle signal */
rt_thread_resume
(
tid
);
/* add signal state */
tid
->
stat
|=
RT_THREAD_STAT_SIGNAL
;
/* add signal state */
tid
->
stat
|=
RT_THREAD_STAT_SIGNAL
;
rt_hw_interrupt_enable
(
level
);
...
...
@@ -104,8 +104,8 @@ static void _signal_deliver(rt_thread_t tid)
{
if
(
tid
==
rt_thread_self
())
{
/* add signal state */
tid
->
stat
|=
RT_THREAD_STAT_SIGNAL
;
/* add signal state */
tid
->
stat
|=
RT_THREAD_STAT_SIGNAL
;
rt_hw_interrupt_enable
(
level
);
/* do signal action in self thread context */
...
...
@@ -116,8 +116,8 @@ 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
,
(
void
*
)((
char
*
)
tid
->
sig_ret
-
32
),
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
);
dbg_log
(
DBG_LOG
,
"signal stack pointer @ 0x%08x
\n
"
,
tid
->
sp
);
...
...
@@ -137,7 +137,7 @@ rt_sighandler_t rt_signal_install(int signo, rt_sighandler_t handler)
rt_sighandler_t
old
;
rt_thread_t
tid
=
rt_thread_self
();
if
(
!
sig_valid
(
signo
))
return
SIG_ERR
;
if
(
!
sig_valid
(
signo
))
return
SIG_ERR
;
rt_enter_critical
();
if
(
tid
->
sig_vectors
==
RT_NULL
)
...
...
@@ -185,7 +185,7 @@ void rt_signal_unmask(int signo)
rt_hw_interrupt_enable
(
level
);
_signal_deliver
(
tid
);
}
else
else
{
rt_hw_interrupt_enable
(
level
);
}
...
...
@@ -193,34 +193,34 @@ void rt_signal_unmask(int signo)
void
rt_thread_handle_sig
(
rt_bool_t
clean_state
)
{
rt_base_t
level
;
rt_base_t
level
;
rt_thread_t
tid
=
rt_thread_self
();
struct
siginfo_node
*
si_node
;
level
=
rt_hw_interrupt_disable
();
level
=
rt_hw_interrupt_disable
();
while
(
tid
->
sig_pending
&
tid
->
sig_mask
)
{
int
signo
,
error
;
rt_sighandler_t
handler
;
si_node
=
(
struct
siginfo_node
*
)
tid
->
si_list
;
if
(
!
si_node
)
break
;
si_node
=
(
struct
siginfo_node
*
)
tid
->
si_list
;
if
(
!
si_node
)
break
;
/* remove this sig info node from list */
/* remove this sig info node from list */
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
];
rt_hw_interrupt_enable
(
level
);
rt_hw_interrupt_enable
(
level
);
dbg_log
(
DBG_LOG
,
"handle signal: %d, handler 0x%08x
\n
"
,
signo
,
handler
);
if
(
handler
)
handler
(
signo
);
level
=
rt_hw_interrupt_disable
();
level
=
rt_hw_interrupt_disable
();
tid
->
sig_pending
&=
~
sig_mask
(
signo
);
error
=
si_node
->
si
.
si_errno
;
...
...
@@ -229,10 +229,10 @@ void rt_thread_handle_sig(rt_bool_t clean_state)
tid
->
error
=
error
;
}
/* whether clean signal status */
if
(
clean_state
==
RT_TRUE
)
tid
->
stat
&=
~
RT_THREAD_STAT_SIGNAL
;
/* whether clean signal status */
if
(
clean_state
==
RT_TRUE
)
tid
->
stat
&=
~
RT_THREAD_STAT_SIGNAL
;
rt_hw_interrupt_enable
(
level
);
rt_hw_interrupt_enable
(
level
);
}
void
rt_thread_alloc_sig
(
rt_thread_t
tid
)
...
...
@@ -261,9 +261,9 @@ 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
;
tid
->
sig_vectors
=
RT_NULL
;
rt_hw_interrupt_enable
(
level
);
...
...
@@ -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
);
...
...
@@ -292,8 +293,8 @@ void rt_thread_free_sig(rt_thread_t tid)
int
rt_thread_kill
(
rt_thread_t
tid
,
int
sig
)
{
siginfo_t
si
;
rt_base_t
level
;
struct
siginfo_node
*
si_node
;
rt_base_t
level
;
struct
siginfo_node
*
si_node
;
RT_ASSERT
(
tid
!=
RT_NULL
);
if
(
!
sig_valid
(
sig
))
return
-
RT_EINVAL
;
...
...
@@ -304,56 +305,56 @@ int rt_thread_kill(rt_thread_t tid, int sig)
si
.
si_code
=
SI_USER
;
si
.
si_value
.
sival_ptr
=
RT_NULL
;
level
=
rt_hw_interrupt_disable
();
level
=
rt_hw_interrupt_disable
();
if
(
tid
->
sig_pending
&
sig_mask
(
sig
))
{
/* whether already emits this signal? */
struct
rt_slist_node
*
node
;
struct
siginfo_node
*
entry
;
node
=
(
struct
rt_slist_node
*
)
tid
->
si_list
;
rt_hw_interrupt_enable
(
level
);
node
=
(
struct
rt_slist_node
*
)
tid
->
si_list
;
rt_hw_interrupt_enable
(
level
);
/* update sig infor */
rt_enter_critical
();
/* update sig infor */
rt_enter_critical
();
for
(;
(
node
)
!=
RT_NULL
;
node
=
node
->
next
)
{
entry
=
rt_slist_entry
(
node
,
struct
siginfo_node
,
list
);
if
(
entry
->
si
.
si_signo
==
sig
)
{
memcpy
(
&
(
entry
->
si
),
&
si
,
sizeof
(
siginfo_t
));
rt_exit_critical
();
rt_exit_critical
();
return
0
;
}
}
rt_exit_critical
();
rt_exit_critical
();
/* disable interrupt to protect tcb */
level
=
rt_hw_interrupt_disable
();
/* disable interrupt to protect tcb */
level
=
rt_hw_interrupt_disable
();
}
else
{
/* a new signal */
tid
->
sig_pending
|=
sig_mask
(
sig
);
}
else
{
/* a new signal */
tid
->
sig_pending
|=
sig_mask
(
sig
);
}
rt_hw_interrupt_enable
(
level
);
si_node
=
(
struct
siginfo_node
*
)
rt_mp_alloc
(
_rt_siginfo_pool
,
0
);
rt_hw_interrupt_enable
(
level
);
si_node
=
(
struct
siginfo_node
*
)
rt_mp_alloc
(
_rt_siginfo_pool
,
0
);
if
(
si_node
)
{
rt_slist_init
(
&
(
si_node
->
list
));
memcpy
(
&
(
si_node
->
si
),
&
si
,
sizeof
(
siginfo_t
));
level
=
rt_hw_interrupt_disable
();
level
=
rt_hw_interrupt_disable
();
if
(
!
tid
->
si_list
)
tid
->
si_list
=
si_node
;
else
else
{
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_hw_interrupt_enable
(
level
);
rt_hw_interrupt_enable
(
level
);
}
else
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录