summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.clang-format18
-rw-r--r--src/thread.c142
-rw-r--r--tools/attachconfig.py8
3 files changed, 87 insertions, 81 deletions
diff --git a/.clang-format b/.clang-format
index ea0eac2783..559e7fa787 100644
--- a/.clang-format
+++ b/.clang-format
@@ -41,17 +41,17 @@ AlignConsecutiveShortCaseStatements:
AlignEscapedNewlines: Left
AlignOperands: Align
AlignTrailingComments:
- Kind: Leave
- OverEmptyLines: 1
+ Kind: Always
+ OverEmptyLines: 0
AllowAllArgumentsOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortEnumsOnASingleLine: false
-AllowShortFunctionsOnASingleLine: Inline
+AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
-AllowShortLambdasOnASingleLine: All
-AllowShortLoopsOnASingleLine: true
+AllowShortLambdasOnASingleLine: None
+AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
@@ -67,7 +67,7 @@ BraceWrapping:
AfterClass: true
AfterControlStatement: Always
AfterEnum: true
- AfterExternBlock: false
+ AfterExternBlock: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: true
@@ -75,8 +75,8 @@ BraceWrapping:
AfterUnion: true
BeforeCatch: true
BeforeElse: true
- BeforeLambdaBody: false
- BeforeWhile: false
+ BeforeLambdaBody: true
+ BeforeWhile: true
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
@@ -152,7 +152,7 @@ LambdaBodyIndentation: Signature
LineEnding: DeriveLF
MacroBlockBegin: ""
MacroBlockEnd: ""
-MaxEmptyLinesToKeep: 2
+MaxEmptyLinesToKeep: 1
NamespaceIndentation: All
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 2
diff --git a/src/thread.c b/src/thread.c
index 0c4a645eac..8a557a128d 100644
--- a/src/thread.c
+++ b/src/thread.c
@@ -41,13 +41,13 @@
#include <rtthread.h>
#include <stddef.h>
-#define DBG_TAG "kernel.thread"
-#define DBG_LVL DBG_INFO
+#define DBG_TAG "kernel.thread"
+#define DBG_LVL DBG_INFO
#include <rtdbg.h>
#if defined(RT_USING_HOOK) && defined(RT_HOOK_USING_FUNC_PTR)
static void (*rt_thread_suspend_hook)(rt_thread_t thread);
-static void (*rt_thread_resume_hook) (rt_thread_t thread);
+static void (*rt_thread_resume_hook)(rt_thread_t thread);
/**
* @brief This function sets a hook function when the system suspend a thread.
@@ -91,7 +91,7 @@ static void _thread_detach_from_mutex(rt_thread_t thread)
(rt_object_get_type(thread->pending_object) == RT_Object_Class_Mutex))
{
/* remove it from its waiting list */
- struct rt_mutex *mutex = (struct rt_mutex*)thread->pending_object;
+ struct rt_mutex *mutex = (struct rt_mutex *)thread->pending_object;
rt_mutex_drop_thread(mutex, thread);
thread->pending_object = RT_NULL;
}
@@ -111,7 +111,9 @@ static void _thread_detach_from_mutex(rt_thread_t thread)
#else
-static void _thread_detach_from_mutex(rt_thread_t thread) {}
+static void _thread_detach_from_mutex(rt_thread_t thread)
+{
+}
#endif
static void _thread_exit(void)
@@ -177,13 +179,13 @@ static void _thread_timeout(void *parameter)
}
static rt_err_t _thread_init(struct rt_thread *thread,
- const char *name,
+ const char *name,
void (*entry)(void *parameter),
- void *parameter,
- void *stack_start,
- rt_uint32_t stack_size,
- rt_uint8_t priority,
- rt_uint32_t tick)
+ void *parameter,
+ void *stack_start,
+ rt_uint32_t stack_size,
+ rt_uint8_t priority,
+ rt_uint32_t tick)
{
RT_UNUSED(name);
@@ -238,7 +240,7 @@ static rt_err_t _thread_init(struct rt_thread *thread,
#endif
/* initialize cleanup function and user data */
- thread->cleanup = 0;
+ thread->cleanup = 0;
thread->user_data = 0;
/* initialize thread timer */
@@ -251,14 +253,14 @@ static rt_err_t _thread_init(struct rt_thread *thread,
/* initialize signal */
#ifdef RT_USING_SIGNALS
- thread->sig_mask = 0x00;
+ thread->sig_mask = 0x00;
thread->sig_pending = 0x00;
#ifndef RT_USING_SMP
- thread->sig_ret = RT_NULL;
+ thread->sig_ret = RT_NULL;
#endif /* RT_USING_SMP */
thread->sig_vectors = RT_NULL;
- thread->si_list = RT_NULL;
+ thread->si_list = RT_NULL;
#endif /* RT_USING_SIGNALS */
#ifdef RT_USING_SMART
@@ -347,13 +349,13 @@ static rt_err_t _thread_init(struct rt_thread *thread,
* If the return value is any other values, it means this operation failed.
*/
rt_err_t rt_thread_init(struct rt_thread *thread,
- const char *name,
+ const char *name,
void (*entry)(void *parameter),
- void *parameter,
- void *stack_start,
- rt_uint32_t stack_size,
- rt_uint8_t priority,
- rt_uint32_t tick)
+ void *parameter,
+ void *stack_start,
+ rt_uint32_t stack_size,
+ rt_uint8_t priority,
+ rt_uint32_t tick)
{
/* parameter check */
RT_ASSERT(thread != RT_NULL);
@@ -388,10 +390,10 @@ rt_thread_t rt_thread_self(void)
#ifndef RT_USING_SMP
return rt_cpu_self()->current_thread;
-#elif defined (ARCH_USING_HW_THREAD_SELF)
+#elif defined(ARCH_USING_HW_THREAD_SELF)
return rt_hw_thread_self();
-#else /* !ARCH_USING_HW_THREAD_SELF */
+#else /* !ARCH_USING_HW_THREAD_SELF */
rt_thread_t self;
rt_base_t lock;
@@ -559,9 +561,9 @@ static rt_err_t _thread_detach(rt_thread_t thread)
*/
rt_thread_t rt_thread_create(const char *name,
void (*entry)(void *parameter),
- void *parameter,
+ void *parameter,
rt_uint32_t stack_size,
- rt_uint8_t priority,
+ rt_uint8_t priority,
rt_uint32_t tick)
{
/* parameter check */
@@ -573,7 +575,9 @@ rt_thread_t rt_thread_create(const char *name,
thread = (struct rt_thread *)rt_object_allocate(RT_Object_Class_Thread,
name);
if (thread == RT_NULL)
+ {
return RT_NULL;
+ }
stack_start = (void *)RT_KERNEL_MALLOC(stack_size);
if (stack_start == RT_NULL)
@@ -693,7 +697,9 @@ static rt_err_t _thread_sleep(rt_tick_t tick)
/* clear error number of this thread to RT_EOK */
if (thread->error == -RT_ETIMEOUT)
+ {
thread->error = RT_EOK;
+ }
}
else
{
@@ -832,56 +838,56 @@ rt_err_t rt_thread_control(rt_thread_t thread, int cmd, void *arg)
switch (cmd)
{
- case RT_THREAD_CTRL_CHANGE_PRIORITY:
- {
- rt_err_t error;
- rt_sched_lock_level_t slvl;
- rt_sched_lock(&slvl);
- error = rt_sched_thread_change_priority(thread, *(rt_uint8_t *)arg);
- rt_sched_unlock(slvl);
- return error;
- }
+ case RT_THREAD_CTRL_CHANGE_PRIORITY:
+ {
+ rt_err_t error;
+ rt_sched_lock_level_t slvl;
+ rt_sched_lock(&slvl);
+ error = rt_sched_thread_change_priority(thread, *(rt_uint8_t *)arg);
+ rt_sched_unlock(slvl);
+ return error;
+ }
- case RT_THREAD_CTRL_RESET_PRIORITY:
- {
- rt_err_t error;
- rt_sched_lock_level_t slvl;
- rt_sched_lock(&slvl);
- error = rt_sched_thread_reset_priority(thread, *(rt_uint8_t *)arg);
- rt_sched_unlock(slvl);
- return error;
- }
+ case RT_THREAD_CTRL_RESET_PRIORITY:
+ {
+ rt_err_t error;
+ rt_sched_lock_level_t slvl;
+ rt_sched_lock(&slvl);
+ error = rt_sched_thread_reset_priority(thread, *(rt_uint8_t *)arg);
+ rt_sched_unlock(slvl);
+ return error;
+ }
+
+ case RT_THREAD_CTRL_STARTUP:
+ {
+ return rt_thread_startup(thread);
+ }
+
+ case RT_THREAD_CTRL_CLOSE:
+ {
+ rt_err_t rt_err = -RT_EINVAL;
- case RT_THREAD_CTRL_STARTUP:
+ if (rt_object_is_systemobject((rt_object_t)thread) == RT_TRUE)
{
- return rt_thread_startup(thread);
+ rt_err = rt_thread_detach(thread);
}
-
- case RT_THREAD_CTRL_CLOSE:
+#ifdef RT_USING_HEAP
+ else
{
- rt_err_t rt_err = -RT_EINVAL;
-
- if (rt_object_is_systemobject((rt_object_t)thread) == RT_TRUE)
- {
- rt_err = rt_thread_detach(thread);
- }
- #ifdef RT_USING_HEAP
- else
- {
- rt_err = rt_thread_delete(thread);
- }
- #endif /* RT_USING_HEAP */
- rt_schedule();
- return rt_err;
+ rt_err = rt_thread_delete(thread);
}
+#endif /* RT_USING_HEAP */
+ rt_schedule();
+ return rt_err;
+ }
- case RT_THREAD_CTRL_BIND_CPU:
- {
- rt_uint8_t cpu;
+ case RT_THREAD_CTRL_BIND_CPU:
+ {
+ rt_uint8_t cpu;
- cpu = (rt_uint8_t)(rt_size_t)arg;
- return rt_sched_thread_bind_cpu(thread, cpu);
- }
+ cpu = (rt_uint8_t)(rt_size_t)arg;
+ return rt_sched_thread_bind_cpu(thread, cpu);
+ }
default:
break;
@@ -1182,7 +1188,7 @@ rt_err_t rt_thread_wakeup(rt_thread_t thread)
}
RTM_EXPORT(rt_thread_wakeup);
-void rt_thread_wakeup_set(struct rt_thread *thread, rt_wakeup_func_t func, void* user_data)
+void rt_thread_wakeup_set(struct rt_thread *thread, rt_wakeup_func_t func, void *user_data)
{
rt_sched_lock_level_t slvl;
diff --git a/tools/attachconfig.py b/tools/attachconfig.py
index df89fd23c3..d5a77fb68b 100644
--- a/tools/attachconfig.py
+++ b/tools/attachconfig.py
@@ -15,7 +15,7 @@ def GenAttachConfigProject(program = None):
if GetOption('attach') == '?':
attachconfig=[]
GetAttachConfig("get",attachconfig,0)
- print("\033[32m✅ AttachConfig has: \033[0m")
+ print("\033[32m[OK] AttachConfig has: \033[0m")
prefix=attachconfig[0]
for line in attachconfig:
temp_prefix=line.split(".", 1)
@@ -32,13 +32,13 @@ def GenAttachConfigProject(program = None):
if os.path.exists(rtconfig__bacakup):
shutil.copyfile(rtconfig__bacakup, rtconfig_file)
os.remove(rtconfig__bacakup)
- print("\033[32m✅ Default .config and rtconfig.h recovery success!\033[0m")
+ print("\033[32m[OK] Default .config and rtconfig.h recovery success!\033[0m")
else:
attachconfig=GetOption('attach')
attachconfig_result=[]
GetAttachConfig("search",attachconfig,attachconfig_result)
if attachconfig_result==[]:
- print("❌\033[31m Without this AttachConfig:"+attachconfig+"\033[0m")
+ print("[ERR]\033[31m Without this AttachConfig:"+attachconfig+"\033[0m")
return
if os.path.exists(config_bacakup)==False:
shutil.copyfile(config_file, config_bacakup)
@@ -49,7 +49,7 @@ def GenAttachConfigProject(program = None):
destination.write(line + '\n')
from env_utility import defconfig
defconfig(Rtt_Root)
- print("\033[32m✅ AttachConfig add success!\033[0m")
+ print("\033[32m[OK] AttachConfig add success!\033[0m")
def GetAttachConfig(action,attachconfig,attachconfig_result):
rtt_root = os.getcwd()