未验证 提交 0dc972be 编写于 作者: B Bernard Xiong 提交者: GitHub

Merge pull request #4707 from armink/fix_ulog

[ulog] Add output locker enabled API
......@@ -77,6 +77,7 @@
struct rt_ulog
{
rt_bool_t init_ok;
rt_bool_t output_lock_enabled;
struct rt_semaphore output_locker;
/* all backends */
rt_slist_t backend_list;
......@@ -186,6 +187,9 @@ size_t ulog_ultoa(char *s, unsigned long int n)
static void output_unlock(void)
{
if (!ulog.output_lock_enabled)
return;
/* is in thread context */
if (rt_interrupt_get_nest() == 0)
{
......@@ -201,6 +205,9 @@ static void output_unlock(void)
static void output_lock(void)
{
if (!ulog.output_lock_enabled)
return;
/* is in thread context */
if (rt_interrupt_get_nest() == 0)
{
......@@ -214,6 +221,11 @@ static void output_lock(void)
}
}
void ulog_output_lock_enabled(rt_bool_t enabled)
{
ulog.output_lock_enabled = enabled;
}
static char *get_log_buf(void)
{
/* is in thread context */
......@@ -1392,6 +1404,7 @@ int ulog_init(void)
return 0;
rt_sem_init(&ulog.output_locker, "ulog lock", 1, RT_IPC_FLAG_FIFO);
ulog.output_lock_enabled = RT_TRUE;
rt_slist_init(&ulog.backend_list);
#ifdef ULOG_USING_FILTER
......
......@@ -25,6 +25,7 @@ extern "C" {
*/
int ulog_init(void);
int ulog_async_init(void);
void ulog_output_lock_enabled(rt_bool_t enabled);
void ulog_deinit(void);
/*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册