Skip to content

Commit 7e76504

Browse files
committed
【删除】对于 Finsh 组件的依赖。
Signed-off-by: armink <[email protected]>
1 parent 0aba78a commit 7e76504

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

port/modrtthread.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,13 @@ STATIC mp_obj_t mod_current_tid(void) {
5050
STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_current_tid_obj, mod_current_tid);
5151

5252
STATIC mp_obj_t mod_stacks_analyze(void) {
53+
#ifdef RT_USING_FINSH
5354
extern long list_thread(void);
5455
list_thread();
56+
#else
57+
rt_kprintf("Not available when FINSH module disable\n");
58+
#endif
59+
5560
return mp_const_none;
5661
}
5762
STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_stacks_analyze_obj, mod_stacks_analyze);

port/moduos_file.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,6 @@ mp_obj_t mp_posix_mkdir(mp_obj_t path_in) {
161161
MP_DEFINE_CONST_FUN_OBJ_1(mp_posix_mkdir_obj, mp_posix_mkdir);
162162

163163
mp_obj_t mp_posix_remove(uint n_args, const mp_obj_t *arg) {
164-
extern void rm(const char *filename);
165-
166164
int index;
167165
if (n_args == 0) {
168166
rt_kprintf("Usage: rm FILE...\n");
@@ -171,7 +169,7 @@ mp_obj_t mp_posix_remove(uint n_args, const mp_obj_t *arg) {
171169
}
172170
for (index = 0; index < n_args; index++) {
173171
//rt_kprintf("Remove %s.\n", mp_obj_str_get_str(arg[index]));
174-
rm(mp_obj_str_get_str(arg[index]));
172+
unlink(mp_obj_str_get_str(arg[index]));
175173
}
176174
// TODO recursive deletion
177175
return mp_const_none;

port/mpthreadport.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838

3939
#define MP_THREAD_MIN_STACK_SIZE (4 * 1024)
4040
#define MP_THREAD_DEFAULT_STACK_SIZE (MP_THREAD_MIN_STACK_SIZE + 1024)
41-
#define MP_THREAD_PRIORITY (FINSH_THREAD_PRIORITY - 1)
4241

4342
#define MP_THREAD_STATUS_READY 0
4443
#define MP_THREAD_STATUS_RUNNING 1
@@ -160,12 +159,17 @@ void mp_thread_create_ex(void *(*entry)(void*), void *arg, size_t *stack_size, i
160159

161160
void mp_thread_create(void *(*entry)(void*), void *arg, size_t *stack_size) {
162161
static uint8_t count = 0;
162+
int priority = rt_thread_self()->current_priority;
163163
char name[RT_NAME_MAX];
164164

165+
if (priority > 0) {
166+
priority --;
167+
}
168+
165169
/* build name */
166170
rt_snprintf(name, sizeof(name), "mp%02d", count++);
167171

168-
mp_thread_create_ex(entry, arg, stack_size, MP_THREAD_PRIORITY, name);
172+
mp_thread_create_ex(entry, arg, stack_size, priority, name);
169173
}
170174

171175
void mp_thread_finish(void) {

port/mpy_main.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#include <string.h>
3030

3131
#include <rtthread.h>
32-
#include <shell.h>
3332

3433
#ifdef RT_USING_DFS
3534
#include <dfs_posix.h>
@@ -78,7 +77,7 @@ void mpy_main(const char *filename) {
7877

7978
mp_stack_set_top(stack_top);
8079
// Make MicroPython's stack limit somewhat smaller than full stack available
81-
mp_stack_set_limit(FINSH_THREAD_STACK_SIZE - 1024);
80+
mp_stack_set_limit(rt_thread_self()->stack_size - 1024);
8281

8382
#if MICROPY_ENABLE_GC
8483
heap = rt_malloc(MICROPY_HEAP_SIZE);

0 commit comments

Comments
 (0)