Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3968582

Browse files
committed
Fixes last couple of compile errors for the ESP32 port
1 parent8b4781d commit3968582

File tree

9 files changed

+58
-51
lines changed

9 files changed

+58
-51
lines changed

‎ext_mod/threading/common/inc/thread_event.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88

99
#include"thread_port.h"
1010

11-
typedefstruct_mp_obj_thread_event_t {
11+
typedefstruct_mp_obj_event_t {
1212
mp_obj_base_tbase;
1313
thread_event_tevent;
1414
boolis_set;
15-
}mp_obj_thread_event_t;
15+
}mp_obj_event_t;
1616

1717
voidthreading_event_set(thread_event_t*event);// needs to be defined in port
1818
boolthreading_event_isset(thread_event_t*event);// needs to be defined in port

‎ext_mod/threading/common/inc/thread_semaphore.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88

99
#include"thread_port.h"
1010

11-
typedefstruct_mp_obj_thread_semaphore_t {
11+
typedefstruct_mp_obj_semaphore_t {
1212
mp_obj_base_tbase;
1313
thread_semaphore_tsem;
1414
uint16_tstart_value;
15-
}mp_obj_thread_semaphore_t;
15+
}mp_obj_semaphore_t;
1616

1717
uint16_tthreading_semaphore_get_count(thread_semaphore_t*sem);// needs to be defined in port
1818
boolthreading_semaphore_acquire(thread_semaphore_t*sem,int32_twait_ms);// needs to be defined in port

‎ext_mod/threading/common/src/thread_event.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
staticmp_obj_tevent_is_set(mp_obj_tself_in)
1515
{
16-
mp_obj_thread_event_t*self=MP_OBJ_TO_PTR(self_in);
16+
mp_obj_event_t*self=MP_OBJ_TO_PTR(self_in);
1717
returnmp_obj_new_bool(self->event.is_set);
1818
}
1919

@@ -23,7 +23,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(event_is_set_obj, event_is_set);
2323

2424
staticmp_obj_tevent_set(mp_obj_tself_in)
2525
{
26-
mp_obj_thread_event_t*self=MP_OBJ_TO_PTR(self_in);
26+
mp_obj_event_t*self=MP_OBJ_TO_PTR(self_in);
2727
self->event.is_set= true;
2828
threading_event_set(&self->event);
2929
returnmp_const_none;
@@ -35,7 +35,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(event_set_obj, event_set);
3535

3636
staticmp_obj_tevent_clear(mp_obj_tself_in)
3737
{
38-
mp_obj_thread_event_t*self=MP_OBJ_TO_PTR(self_in);
38+
mp_obj_event_t*self=MP_OBJ_TO_PTR(self_in);
3939
self->event.is_set= false;
4040
threading_event_clear(&self->event);
4141
returnmp_const_none;
@@ -55,7 +55,7 @@ static mp_obj_t event_wait(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw
5555
mp_arg_val_targs[MP_ARRAY_SIZE(allowed_args)];
5656
mp_arg_parse_all(n_args,pos_args,kw_args,MP_ARRAY_SIZE(allowed_args),allowed_args,args);
5757

58-
mp_obj_thread_event_t*self= (mp_obj_thread_event_t*)args[ARG_self].u_obj;
58+
mp_obj_event_t*self= (mp_obj_event_t*)args[ARG_self].u_obj;
5959

6060
floattimeout_f;
6161

@@ -77,7 +77,7 @@ static MP_DEFINE_CONST_FUN_OBJ_KW(event_wait_obj, 1, event_wait);
7777

7878
staticmp_obj_tevent__del__(mp_obj_tself_in)
7979
{
80-
mp_obj_thread_event_t*self=MP_OBJ_TO_PTR(self_in);
80+
mp_obj_event_t*self=MP_OBJ_TO_PTR(self_in);
8181
threading_event_delete(&self->event);
8282
returnmp_const_none;
8383
}
@@ -93,7 +93,7 @@ static mp_obj_t thread_event_make_new(const mp_obj_type_t *type, size_t n_args,
9393
THREAD_UNUSED(all_args);
9494

9595
// create new object
96-
mp_obj_thread_event_t*self=m_new_obj(mp_obj_thread_event_t);
96+
mp_obj_event_t*self=m_new_obj(mp_obj_event_t);
9797
self->base.type=&mp_type_threading_event_t;
9898
self->event.is_set= false;
9999
threading_event_init(&self->event);
@@ -134,7 +134,7 @@ static mp_obj_t multiprocess_event_make_new(const mp_obj_type_t *type, size_t n_
134134
THREAD_UNUSED(all_args);
135135

136136
// create new object
137-
mp_obj_thread_event_t*self=m_new_obj(mp_obj_thread_event_t);
137+
mp_obj_event_t*self=m_new_obj(mp_obj_event_t);
138138
self->base.type=&mp_type_multiprocessing_event_t;
139139
self->event.is_set= false;
140140
threading_event_init(&self->event);

‎ext_mod/threading/common/src/thread_lock.c‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ static mp_obj_t lock_acquire(size_t n_args, const mp_obj_t *pos_args, mp_map_t *
1919
mp_arg_val_targs[MP_ARRAY_SIZE(allowed_args)];
2020
mp_arg_parse_all(n_args,pos_args,kw_args,MP_ARRAY_SIZE(allowed_args),allowed_args,args);
2121

22-
mp_obj_thread_lock_t*self=MP_OBJ_TO_PTR(args[ARG_self].u_obj);
22+
mp_obj_lock_t*self=MP_OBJ_TO_PTR(args[ARG_self].u_obj);
2323
floattimeout_f;
2424

2525
if (args[ARG_timeout].u_obj!=mp_const_none) {
@@ -57,11 +57,11 @@ static MP_DEFINE_CONST_FUN_OBJ_KW(lock_acquire_obj, 3, lock_acquire);
5757
staticmp_obj_tlock__enter__(size_tn_args,constmp_obj_t*args)
5858
{
5959
(void)n_args;// unused
60-
mp_obj_thread_lock_t*self=MP_OBJ_TO_PTR(args[0]);
60+
mp_obj_lock_t*self=MP_OBJ_TO_PTR(args[0]);
6161

6262
self->lock.ref_count+=1;
6363
threading_lock_acquire(&self->lock,-1);
64-
returnmp_const_none
64+
returnmp_const_none;
6565
}
6666

6767

@@ -70,11 +70,11 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(lock__enter__obj, 1, 1, lock__enter__
7070

7171
staticmp_obj_tlock_release(mp_obj_tself_in)
7272
{
73-
mp_obj_thread_lock_t*self=MP_OBJ_TO_PTR(self_in);
73+
mp_obj_lock_t*self=MP_OBJ_TO_PTR(self_in);
7474
if (self->lock.ref_count==0) {
75-
mp_raise_msg(&mp_type_RuntimeError,MP_ERROR_TEXT("Lock is already released");
75+
mp_raise_msg(&mp_type_RuntimeError,MP_ERROR_TEXT("Lock is already released"));
7676
}else {
77-
threading_lock_release(&self->mutex);
77+
threading_lock_release(&self->lock);
7878
}
7979

8080
self->lock.ref_count-=1;
@@ -97,7 +97,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(lock__exit__obj, 4, 4, lock__exit__);
9797

9898
staticmp_obj_tlock_locked(mp_obj_tself_in)
9999
{
100-
mp_obj_thread_lock_t*self=MP_OBJ_TO_PTR(self_in);
100+
mp_obj_lock_t*self=MP_OBJ_TO_PTR(self_in);
101101

102102
returnmp_obj_new_bool(self->lock.ref_count!=0);
103103
}
@@ -113,21 +113,21 @@ static mp_obj_t thread_lock_make_new(const mp_obj_type_t *type, size_t n_args, s
113113
THREAD_UNUSED(n_kw);
114114
THREAD_UNUSED(all_args);
115115

116-
mp_obj_thread_lock_t*self=m_new_obj(mp_obj_thread_lock_t);
116+
mp_obj_lock_t*self=m_new_obj(mp_obj_lock_t);
117117
self->base.type=&mp_type_threading_lock_t;
118118

119-
threading_lock_init(&self->lock;
119+
threading_lock_init(&self->lock);
120120
self->locked= false;
121121
returnMP_OBJ_FROM_PTR(self);
122122
}
123123

124124

125125
staticconstmp_rom_map_elem_tlock_locals_dict_table[]= {
126-
{MP_ROM_QSTR(MP_QSTR_acquire),MP_ROM_PTR(&thread_lock_acquire_obj) },
127-
{MP_ROM_QSTR(MP_QSTR_release),MP_ROM_PTR(&thread_lock_release_obj) },
128-
{MP_ROM_QSTR(MP_QSTR___enter__),MP_ROM_PTR(&thread_lock__enter__obj) },
129-
{MP_ROM_QSTR(MP_QSTR___exit__),MP_ROM_PTR(&thread_lock__exit__obj) },
130-
{MP_ROM_QSTR(MP_QSTR_locked),MP_ROM_PTR(&thread_lock_locked_obj) },
126+
{MP_ROM_QSTR(MP_QSTR_acquire),MP_ROM_PTR(&lock_acquire_obj) },
127+
{MP_ROM_QSTR(MP_QSTR_release),MP_ROM_PTR(&lock_release_obj) },
128+
{MP_ROM_QSTR(MP_QSTR___enter__),MP_ROM_PTR(&lock__enter__obj) },
129+
{MP_ROM_QSTR(MP_QSTR___exit__),MP_ROM_PTR(&lock__exit__obj) },
130+
{MP_ROM_QSTR(MP_QSTR_locked),MP_ROM_PTR(&lock_locked_obj) },
131131
};
132132

133133
staticMP_DEFINE_CONST_DICT(lock_locals_dict,lock_locals_dict_table);
@@ -155,7 +155,7 @@ static mp_obj_t multiprocess_lock_make_new(const mp_obj_type_t *type, size_t n_a
155155
THREAD_UNUSED(n_kw);
156156
THREAD_UNUSED(all_args);
157157

158-
mp_obj_thread_lock_t*self=m_new_obj(mp_obj_thread_lock_t);
158+
mp_obj_lock_t*self=m_new_obj(mp_obj_lock_t);
159159
self->base.type=&mp_type_multiprocessing_lock_t;
160160

161161
threading_lock_init(&self->lock);

‎ext_mod/threading/common/src/thread_semaphore.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
staticvoidsemaphore_attr_func(mp_obj_tself_in,qstrattr,mp_obj_t*dest)
1212
{
13-
mp_obj_thread_semaphore_t*self=MP_OBJ_TO_PTR(self_in);
13+
mp_obj_semaphore_t*self=MP_OBJ_TO_PTR(self_in);
1414

1515
if (dest[0]==MP_OBJ_NULL) {
1616
// load attribute
@@ -52,7 +52,7 @@ static mp_obj_t semaphore_acquire(size_t n_args, const mp_obj_t *pos_args, mp_ma
5252
mp_arg_val_targs[MP_ARRAY_SIZE(allowed_args)];
5353
mp_arg_parse_all(n_args,pos_args,kw_args,MP_ARRAY_SIZE(allowed_args),allowed_args,args);
5454

55-
mp_obj_thread_semaphore_t*self=MP_OBJ_TO_PTR(args[ARG_self].u_obj);
55+
mp_obj_semaphore_t*self=MP_OBJ_TO_PTR(args[ARG_self].u_obj);
5656

5757
boolblocking= (bool)args[ARG_blocking].u_bool;
5858

@@ -101,7 +101,7 @@ static mp_obj_t semaphore_release(size_t n_args, const mp_obj_t *pos_args, mp_ma
101101
mp_arg_val_targs[MP_ARRAY_SIZE(allowed_args)];
102102
mp_arg_parse_all(n_args,pos_args,kw_args,MP_ARRAY_SIZE(allowed_args),allowed_args,args);
103103

104-
mp_obj_thread_semaphore_t*self= (mp_obj_thread_semaphore_t*)args[ARG_self].u_obj;
104+
mp_obj_semaphore_t*self= (mp_obj_semaphore_t*)args[ARG_self].u_obj;
105105

106106
uint16_tn= (uint16_t)args[ARG_n].u_int;
107107

@@ -129,7 +129,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(semaphore__exit__obj, 4, 4, semaphore
129129

130130
staticmp_obj_tsemaphore__del__(mp_obj_tself_in)
131131
{
132-
mp_obj_thread_semaphore_t*self=MP_OBJ_TO_PTR(self_in);
132+
mp_obj_semaphore_t*self=MP_OBJ_TO_PTR(self_in);
133133

134134
for (uint16_ti=0;i<self->start_value;i++) {
135135
threading_semaphore_release(&self->sem);
@@ -158,7 +158,7 @@ static mp_obj_t thread_semaphore_make_new(const mp_obj_type_t *type, size_t n_ar
158158
);
159159

160160
// create new object
161-
mp_obj_thread_semaphore_t*self=m_new_obj(mp_obj_thread_semaphore_t);
161+
mp_obj_semaphore_t*self=m_new_obj(mp_obj_semaphore_t);
162162
self->base.type=&mp_type_threading_semaphore_t;
163163

164164
int32_tstart_value= (int32_t)args[ARG_value].u_int;
@@ -221,7 +221,7 @@ static mp_obj_t multiprocess_semaphore_make_new(const mp_obj_type_t *type, size_
221221
);
222222

223223
// create new object
224-
mp_obj_thread_semaphore_t*self=m_new_obj(mp_obj_thread_semaphore_t);
224+
mp_obj_semaphore_t*self=m_new_obj(mp_obj_semaphore_t);
225225
self->base.type=&mp_type_multiprocessing_semaphore_t;
226226

227227
int32_tstart_value= (int32_t)args[ARG_value].u_int;

‎ext_mod/threading/common/src/thread_thread.c‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@
55
#include"threading.h"
66
#include"thread_thread.h"
77

8+
#include"multiprocessing.h"
9+
10+
#include<string.h>
811

912

1013
staticmp_obj_tthread_start(mp_obj_tself_in)
1114
{
12-
mp_obj_thread_thread_t*self=MP_OBJ_TO_PTR(self_in);
15+
mp_obj_thread_t*self=MP_OBJ_TO_PTR(self_in);
1316
self->ident=mp_obj_new_int_from_uint(threading_create_thread(self));
1417

1518
returnmp_const_none;
@@ -20,7 +23,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(thread_start_obj, thread_start);
2023

2124
staticmp_obj_tthread_is_alive(mp_obj_tself_in)
2225
{
23-
mp_obj_thread_thread_t*self=MP_OBJ_TO_PTR(self_in);
26+
mp_obj_thread_t*self=MP_OBJ_TO_PTR(self_in);
2427
returnmp_obj_new_bool(self->is_alive);
2528
}
2629

@@ -29,7 +32,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(thread_is_alive_obj, thread_is_alive);
2932

3033
staticvoidthread_attr_func(mp_obj_tself_in,qstrattr,mp_obj_t*dest)
3134
{
32-
mp_obj_thread_thread_t*self=MP_OBJ_TO_PTR(self_in);
35+
mp_obj_thread_t*self=MP_OBJ_TO_PTR(self_in);
3336

3437
if (dest[0]==MP_OBJ_NULL) {
3538
// load attribute
@@ -82,7 +85,7 @@ static mp_obj_t threading_thread_make_new(const mp_obj_type_t *type, size_t n_ar
8285
);
8386

8487
// create new object
85-
mp_obj_thread_thread_t*self=m_new_obj(mp_obj_thread_thread_t);
88+
mp_obj_thread_t*self=m_new_obj(mp_obj_thread_t);
8689
self->base.type=&mp_type_threading_thread_t;
8790

8891
self->name=args[ARG_name].u_obj;
@@ -185,7 +188,7 @@ static mp_obj_t multiprocessing_process_make_new(const mp_obj_type_t *type, size
185188
}
186189

187190
// create new object
188-
mp_obj_thread_thread_t*self=m_new_obj(mp_obj_thread_thread_t);
191+
mp_obj_thread_t*self=m_new_obj(mp_obj_thread_t);
189192
self->base.type=&mp_type_multiprocessing_process_t;
190193

191194
self->name=args[ARG_name].u_obj;

‎ext_mod/threading/common/src/threading.c‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020
#include"thread_event.h"
2121

2222

23-
staticmp_obj_tget_ident(void)
23+
staticmp_obj_tget_ident_func(void)
2424
{
2525
returnmp_obj_new_int_from_uint((mp_uint_t)mp_get_current_thread_id());
2626
}
2727

28-
staticMP_DEFINE_CONST_FUN_OBJ_0(get_ident_obj,get_ident);
28+
staticMP_DEFINE_CONST_FUN_OBJ_0(get_ident_func_obj,get_ident_func);
2929

3030

3131
mp_obj_tmp_get_main_thread(void)
@@ -34,30 +34,30 @@ mp_obj_t mp_get_main_thread(void)
3434
}
3535

3636

37-
staticMP_DEFINE_CONST_FUN_OBJ_0(threading_main_thread_obj,mp_get_main_thread);
37+
staticMP_DEFINE_CONST_FUN_OBJ_0(main_thread_func_obj,mp_get_main_thread);
3838

3939

4040
mp_obj_tmp_enumerate_threads(void)
4141
{
4242
mp_obj_tlist=mp_obj_new_list(0,NULL);
4343

44-
lock_acquire(&t_mutex,1);
44+
threading_lock_acquire(&t_mutex,1);
4545

46-
for (mp_obj_thread_thread_t*th=t_thread;th!=NULL;th=th->next) {
46+
for (mp_obj_thread_t*th=t_thread;th!=NULL;th=th->next) {
4747
if (!th->is_alive) {
4848
continue;
4949
}
5050
mp_obj_list_append(list,MP_OBJ_FROM_PTR(th));
5151
}
5252

53-
lock_release(&t_mutex);
53+
threading_lock_release(&t_mutex);
5454
returnlist;
5555
}
5656

57-
staticMP_DEFINE_CONST_FUN_OBJ_0(threading_enumerate_obj,mp_enumerate_threads);
57+
staticMP_DEFINE_CONST_FUN_OBJ_0(enumerate_func_obj,mp_enumerate_threads);
5858

5959

60-
staticmp_obj_tthreading_stack_size(size_tn_args,constmp_obj_t*args) {
60+
staticmp_obj_tstack_size_func(size_tn_args,constmp_obj_t*args) {
6161
mp_obj_tret=mp_obj_new_int_from_uint(thread_stack_size);
6262
if (n_args==1) {
6363
thread_stack_size=mp_obj_get_int(args[0]);
@@ -66,7 +66,7 @@ static mp_obj_t threading_stack_size(size_t n_args, const mp_obj_t *args) {
6666
returnret;
6767
}
6868

69-
staticMP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(threading_stack_size_obj,0,1,threading_stack_size);
69+
staticMP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(stack_size_func_obj,0,1,stack_size_func);
7070

7171

7272
staticconstmp_rom_map_elem_tmp_module_threading_globals_table[]= {
@@ -76,10 +76,10 @@ static const mp_rom_map_elem_t mp_module_threading_globals_table[] = {
7676
{MP_ROM_QSTR(MP_QSTR_Event), (mp_obj_t)&mp_type_threading_event_t },
7777
{MP_ROM_QSTR(MP_QSTR_Thread), (mp_obj_t)&mp_type_threading_thread_t },
7878
{MP_ROM_QSTR(MP_QSTR_Semaphore), (mp_obj_t)&mp_type_threading_semaphore_t },
79-
{MP_ROM_QSTR(MP_QSTR_get_ident),MP_ROM_PTR(&threading_get_ident_obj) },
80-
{MP_ROM_QSTR(MP_QSTR_enumerate),MP_ROM_PTR(&threading_enumerate_obj) },
81-
{MP_ROM_QSTR(MP_QSTR_main_thread),MP_ROM_PTR(&threading_main_thread_obj) },
82-
{MP_ROM_QSTR(MP_QSTR_stack_size),MP_ROM_PTR(&threading_stack_size_obj) },
79+
{MP_ROM_QSTR(MP_QSTR_get_ident),MP_ROM_PTR(&get_ident_func_obj) },
80+
{MP_ROM_QSTR(MP_QSTR_enumerate),MP_ROM_PTR(&enumerate_func_obj) },
81+
{MP_ROM_QSTR(MP_QSTR_main_thread),MP_ROM_PTR(&main_thread_func_obj) },
82+
{MP_ROM_QSTR(MP_QSTR_stack_size),MP_ROM_PTR(&stack_size_func_obj) },
8383

8484
};
8585

‎ext_mod/threading/esp32/thread_port.c‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
#include"freertos/task.h"
88
#include"freertos/semphr.h"
99
#include"freertos/queue.h"
10+
#include"freertos/event_groups.h"
11+
#include"freertos/idf_additions.h"
12+
1013
#include"esp_task.h"
1114

1215

@@ -277,7 +280,7 @@ void threading_gc_others(void)
277280

278281
for (mp_obj_thread_t*th=t_thread;th!=NULL;th=th->next) {
279282
gc_collect_root((void**)&th,1);
280-
gc_collect_root(&th->call_args,1);// probably not needed
283+
gc_collect_root((void**)&th->call_args,1);// probably not needed
281284
if (th->thread.handle==xTaskGetCurrentTaskHandle()) {
282285
continue;
283286
}

‎ext_mod/threading/esp32/thread_port.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include"freertos/task.h"
33
#include"freertos/semphr.h"
44
#include"freertos/queue.h"
5+
#include"freertos/event_groups.h"
56

67

78
#ifndef__THREAD_PORT_H__

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp