Skip to content

Commit 0cc8910

Browse files
committed
extmod: Give vars/funcs unique names so STATIC can be set to nothing.
Fixes issue adafruit#5018.
1 parent 3327dfc commit 0cc8910

5 files changed

Lines changed: 49 additions & 49 deletions

File tree

extmod/moduheapq.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@
3131

3232
// the algorithm here is modelled on CPython's heapq.py
3333

34-
STATIC mp_obj_list_t *get_heap(mp_obj_t heap_in) {
34+
STATIC mp_obj_list_t *uheapq_get_heap(mp_obj_t heap_in) {
3535
if (!mp_obj_is_type(heap_in, &mp_type_list)) {
3636
mp_raise_TypeError("heap must be a list");
3737
}
3838
return MP_OBJ_TO_PTR(heap_in);
3939
}
4040

41-
STATIC void heap_siftdown(mp_obj_list_t *heap, mp_uint_t start_pos, mp_uint_t pos) {
41+
STATIC void uheapq_heap_siftdown(mp_obj_list_t *heap, mp_uint_t start_pos, mp_uint_t pos) {
4242
mp_obj_t item = heap->items[pos];
4343
while (pos > start_pos) {
4444
mp_uint_t parent_pos = (pos - 1) >> 1;
@@ -53,7 +53,7 @@ STATIC void heap_siftdown(mp_obj_list_t *heap, mp_uint_t start_pos, mp_uint_t po
5353
heap->items[pos] = item;
5454
}
5555

56-
STATIC void heap_siftup(mp_obj_list_t *heap, mp_uint_t pos) {
56+
STATIC void uheapq_heap_siftup(mp_obj_list_t *heap, mp_uint_t pos) {
5757
mp_uint_t start_pos = pos;
5858
mp_uint_t end_pos = heap->len;
5959
mp_obj_t item = heap->items[pos];
@@ -67,19 +67,19 @@ STATIC void heap_siftup(mp_obj_list_t *heap, mp_uint_t pos) {
6767
pos = child_pos;
6868
}
6969
heap->items[pos] = item;
70-
heap_siftdown(heap, start_pos, pos);
70+
uheapq_heap_siftdown(heap, start_pos, pos);
7171
}
7272

7373
STATIC mp_obj_t mod_uheapq_heappush(mp_obj_t heap_in, mp_obj_t item) {
74-
mp_obj_list_t *heap = get_heap(heap_in);
74+
mp_obj_list_t *heap = uheapq_get_heap(heap_in);
7575
mp_obj_list_append(heap_in, item);
76-
heap_siftdown(heap, 0, heap->len - 1);
76+
uheapq_heap_siftdown(heap, 0, heap->len - 1);
7777
return mp_const_none;
7878
}
7979
STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_uheapq_heappush_obj, mod_uheapq_heappush);
8080

8181
STATIC mp_obj_t mod_uheapq_heappop(mp_obj_t heap_in) {
82-
mp_obj_list_t *heap = get_heap(heap_in);
82+
mp_obj_list_t *heap = uheapq_get_heap(heap_in);
8383
if (heap->len == 0) {
8484
nlr_raise(mp_obj_new_exception_msg(&mp_type_IndexError, "empty heap"));
8585
}
@@ -88,16 +88,16 @@ STATIC mp_obj_t mod_uheapq_heappop(mp_obj_t heap_in) {
8888
heap->items[0] = heap->items[heap->len];
8989
heap->items[heap->len] = MP_OBJ_NULL; // so we don't retain a pointer
9090
if (heap->len) {
91-
heap_siftup(heap, 0);
91+
uheapq_heap_siftup(heap, 0);
9292
}
9393
return item;
9494
}
9595
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_uheapq_heappop_obj, mod_uheapq_heappop);
9696

9797
STATIC mp_obj_t mod_uheapq_heapify(mp_obj_t heap_in) {
98-
mp_obj_list_t *heap = get_heap(heap_in);
98+
mp_obj_list_t *heap = uheapq_get_heap(heap_in);
9999
for (mp_uint_t i = heap->len / 2; i > 0;) {
100-
heap_siftup(heap, --i);
100+
uheapq_heap_siftup(heap, --i);
101101
}
102102
return mp_const_none;
103103
}

extmod/modussl_axtls.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ struct ssl_args {
5454

5555
STATIC const mp_obj_type_t ussl_socket_type;
5656

57-
STATIC mp_obj_ssl_socket_t *socket_new(mp_obj_t sock, struct ssl_args *args) {
57+
STATIC mp_obj_ssl_socket_t *ussl_socket_new(mp_obj_t sock, struct ssl_args *args) {
5858
#if MICROPY_PY_USSL_FINALISER
5959
mp_obj_ssl_socket_t *o = m_new_obj_with_finaliser(mp_obj_ssl_socket_t);
6060
#else
@@ -118,13 +118,13 @@ STATIC mp_obj_ssl_socket_t *socket_new(mp_obj_t sock, struct ssl_args *args) {
118118
return o;
119119
}
120120

121-
STATIC void socket_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
121+
STATIC void ussl_socket_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
122122
(void)kind;
123123
mp_obj_ssl_socket_t *self = MP_OBJ_TO_PTR(self_in);
124124
mp_printf(print, "<_SSLSocket %p>", self->ssl_sock);
125125
}
126126

127-
STATIC mp_uint_t socket_read(mp_obj_t o_in, void *buf, mp_uint_t size, int *errcode) {
127+
STATIC mp_uint_t ussl_socket_read(mp_obj_t o_in, void *buf, mp_uint_t size, int *errcode) {
128128
mp_obj_ssl_socket_t *o = MP_OBJ_TO_PTR(o_in);
129129

130130
if (o->ssl_sock == NULL) {
@@ -173,7 +173,7 @@ STATIC mp_uint_t socket_read(mp_obj_t o_in, void *buf, mp_uint_t size, int *errc
173173
return size;
174174
}
175175

176-
STATIC mp_uint_t socket_write(mp_obj_t o_in, const void *buf, mp_uint_t size, int *errcode) {
176+
STATIC mp_uint_t ussl_socket_write(mp_obj_t o_in, const void *buf, mp_uint_t size, int *errcode) {
177177
mp_obj_ssl_socket_t *o = MP_OBJ_TO_PTR(o_in);
178178

179179
if (o->ssl_sock == NULL) {
@@ -189,7 +189,7 @@ STATIC mp_uint_t socket_write(mp_obj_t o_in, const void *buf, mp_uint_t size, in
189189
return r;
190190
}
191191

192-
STATIC mp_uint_t socket_ioctl(mp_obj_t o_in, mp_uint_t request, uintptr_t arg, int *errcode) {
192+
STATIC mp_uint_t ussl_socket_ioctl(mp_obj_t o_in, mp_uint_t request, uintptr_t arg, int *errcode) {
193193
mp_obj_ssl_socket_t *self = MP_OBJ_TO_PTR(o_in);
194194
if (request == MP_STREAM_CLOSE && self->ssl_sock != NULL) {
195195
ssl_free(self->ssl_sock);
@@ -200,7 +200,7 @@ STATIC mp_uint_t socket_ioctl(mp_obj_t o_in, mp_uint_t request, uintptr_t arg, i
200200
return mp_get_stream(self->sock)->ioctl(self->sock, request, arg, errcode);
201201
}
202202

203-
STATIC mp_obj_t socket_setblocking(mp_obj_t self_in, mp_obj_t flag_in) {
203+
STATIC mp_obj_t ussl_socket_setblocking(mp_obj_t self_in, mp_obj_t flag_in) {
204204
mp_obj_ssl_socket_t *o = MP_OBJ_TO_PTR(self_in);
205205
mp_obj_t sock = o->sock;
206206
mp_obj_t dest[3];
@@ -210,14 +210,14 @@ STATIC mp_obj_t socket_setblocking(mp_obj_t self_in, mp_obj_t flag_in) {
210210
o->blocking = mp_obj_is_true(flag_in);
211211
return res;
212212
}
213-
STATIC MP_DEFINE_CONST_FUN_OBJ_2(socket_setblocking_obj, socket_setblocking);
213+
STATIC MP_DEFINE_CONST_FUN_OBJ_2(ussl_socket_setblocking_obj, ussl_socket_setblocking);
214214

215215
STATIC const mp_rom_map_elem_t ussl_socket_locals_dict_table[] = {
216216
{ MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&mp_stream_read_obj) },
217217
{ MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&mp_stream_readinto_obj) },
218218
{ MP_ROM_QSTR(MP_QSTR_readline), MP_ROM_PTR(&mp_stream_unbuffered_readline_obj) },
219219
{ MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&mp_stream_write_obj) },
220-
{ MP_ROM_QSTR(MP_QSTR_setblocking), MP_ROM_PTR(&socket_setblocking_obj) },
220+
{ MP_ROM_QSTR(MP_QSTR_setblocking), MP_ROM_PTR(&ussl_socket_setblocking_obj) },
221221
{ MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&mp_stream_close_obj) },
222222
#if MICROPY_PY_USSL_FINALISER
223223
{ MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&mp_stream_close_obj) },
@@ -227,16 +227,16 @@ STATIC const mp_rom_map_elem_t ussl_socket_locals_dict_table[] = {
227227
STATIC MP_DEFINE_CONST_DICT(ussl_socket_locals_dict, ussl_socket_locals_dict_table);
228228

229229
STATIC const mp_stream_p_t ussl_socket_stream_p = {
230-
.read = socket_read,
231-
.write = socket_write,
232-
.ioctl = socket_ioctl,
230+
.read = ussl_socket_read,
231+
.write = ussl_socket_write,
232+
.ioctl = ussl_socket_ioctl,
233233
};
234234

235235
STATIC const mp_obj_type_t ussl_socket_type = {
236236
{ &mp_type_type },
237237
// Save on qstr's, reuse same as for module
238238
.name = MP_QSTR_ussl,
239-
.print = socket_print,
239+
.print = ussl_socket_print,
240240
.getiter = NULL,
241241
.iternext = NULL,
242242
.protocol = &ussl_socket_stream_p,
@@ -260,7 +260,7 @@ STATIC mp_obj_t mod_ssl_wrap_socket(size_t n_args, const mp_obj_t *pos_args, mp_
260260
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args,
261261
MP_ARRAY_SIZE(allowed_args), allowed_args, (mp_arg_val_t*)&args);
262262

263-
return MP_OBJ_FROM_PTR(socket_new(sock, &args));
263+
return MP_OBJ_FROM_PTR(ussl_socket_new(sock, &args));
264264
}
265265
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mod_ssl_wrap_socket_obj, 1, mod_ssl_wrap_socket);
266266

extmod/modutimeq.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ typedef struct _mp_obj_utimeq_t {
5555

5656
STATIC mp_uint_t utimeq_id;
5757

58-
STATIC mp_obj_utimeq_t *get_heap(mp_obj_t heap_in) {
58+
STATIC mp_obj_utimeq_t *utimeq_get_heap(mp_obj_t heap_in) {
5959
return MP_OBJ_TO_PTR(heap_in);
6060
}
6161

@@ -85,7 +85,7 @@ STATIC mp_obj_t utimeq_make_new(const mp_obj_type_t *type, size_t n_args, size_t
8585
return MP_OBJ_FROM_PTR(o);
8686
}
8787

88-
STATIC void heap_siftdown(mp_obj_utimeq_t *heap, mp_uint_t start_pos, mp_uint_t pos) {
88+
STATIC void utimeq_heap_siftdown(mp_obj_utimeq_t *heap, mp_uint_t start_pos, mp_uint_t pos) {
8989
struct qentry item = heap->items[pos];
9090
while (pos > start_pos) {
9191
mp_uint_t parent_pos = (pos - 1) >> 1;
@@ -101,7 +101,7 @@ STATIC void heap_siftdown(mp_obj_utimeq_t *heap, mp_uint_t start_pos, mp_uint_t
101101
heap->items[pos] = item;
102102
}
103103

104-
STATIC void heap_siftup(mp_obj_utimeq_t *heap, mp_uint_t pos) {
104+
STATIC void utimeq_heap_siftup(mp_obj_utimeq_t *heap, mp_uint_t pos) {
105105
mp_uint_t start_pos = pos;
106106
mp_uint_t end_pos = heap->len;
107107
struct qentry item = heap->items[pos];
@@ -118,13 +118,13 @@ STATIC void heap_siftup(mp_obj_utimeq_t *heap, mp_uint_t pos) {
118118
pos = child_pos;
119119
}
120120
heap->items[pos] = item;
121-
heap_siftdown(heap, start_pos, pos);
121+
utimeq_heap_siftdown(heap, start_pos, pos);
122122
}
123123

124124
STATIC mp_obj_t mod_utimeq_heappush(size_t n_args, const mp_obj_t *args) {
125125
(void)n_args;
126126
mp_obj_t heap_in = args[0];
127-
mp_obj_utimeq_t *heap = get_heap(heap_in);
127+
mp_obj_utimeq_t *heap = utimeq_get_heap(heap_in);
128128
if (heap->len == heap->alloc) {
129129
mp_raise_msg(&mp_type_IndexError, "queue overflow");
130130
}
@@ -133,14 +133,14 @@ STATIC mp_obj_t mod_utimeq_heappush(size_t n_args, const mp_obj_t *args) {
133133
heap->items[l].id = utimeq_id++;
134134
heap->items[l].callback = args[2];
135135
heap->items[l].args = args[3];
136-
heap_siftdown(heap, 0, heap->len);
136+
utimeq_heap_siftdown(heap, 0, heap->len);
137137
heap->len++;
138138
return mp_const_none;
139139
}
140140
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_utimeq_heappush_obj, 4, 4, mod_utimeq_heappush);
141141

142142
STATIC mp_obj_t mod_utimeq_heappop(mp_obj_t heap_in, mp_obj_t list_ref) {
143-
mp_obj_utimeq_t *heap = get_heap(heap_in);
143+
mp_obj_utimeq_t *heap = utimeq_get_heap(heap_in);
144144
if (heap->len == 0) {
145145
nlr_raise(mp_obj_new_exception_msg(&mp_type_IndexError, "empty heap"));
146146
}
@@ -158,14 +158,14 @@ STATIC mp_obj_t mod_utimeq_heappop(mp_obj_t heap_in, mp_obj_t list_ref) {
158158
heap->items[heap->len].callback = MP_OBJ_NULL; // so we don't retain a pointer
159159
heap->items[heap->len].args = MP_OBJ_NULL;
160160
if (heap->len) {
161-
heap_siftup(heap, 0);
161+
utimeq_heap_siftup(heap, 0);
162162
}
163163
return mp_const_none;
164164
}
165165
STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_utimeq_heappop_obj, mod_utimeq_heappop);
166166

167167
STATIC mp_obj_t mod_utimeq_peektime(mp_obj_t heap_in) {
168-
mp_obj_utimeq_t *heap = get_heap(heap_in);
168+
mp_obj_utimeq_t *heap = utimeq_get_heap(heap_in);
169169
if (heap->len == 0) {
170170
nlr_raise(mp_obj_new_exception_msg(&mp_type_IndexError, "empty heap"));
171171
}
@@ -177,7 +177,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_utimeq_peektime_obj, mod_utimeq_peektime);
177177

178178
#if DEBUG
179179
STATIC mp_obj_t mod_utimeq_dump(mp_obj_t heap_in) {
180-
mp_obj_utimeq_t *heap = get_heap(heap_in);
180+
mp_obj_utimeq_t *heap = utimeq_get_heap(heap_in);
181181
for (int i = 0; i < heap->len; i++) {
182182
printf(UINT_FMT "\t%p\t%p\n", heap->items[i].time,
183183
MP_OBJ_TO_PTR(heap->items[i].callback), MP_OBJ_TO_PTR(heap->items[i].args));

extmod/vfs_fat_file.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ STATIC mp_obj_t file_obj_make_new(const mp_obj_type_t *type, size_t n_args, size
219219

220220
// TODO gc hook to close the file if not already closed
221221

222-
STATIC const mp_rom_map_elem_t rawfile_locals_dict_table[] = {
222+
STATIC const mp_rom_map_elem_t vfs_fat_rawfile_locals_dict_table[] = {
223223
{ MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&mp_stream_read_obj) },
224224
{ MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&mp_stream_readinto_obj) },
225225
{ MP_ROM_QSTR(MP_QSTR_readline), MP_ROM_PTR(&mp_stream_unbuffered_readline_obj) },
@@ -234,10 +234,10 @@ STATIC const mp_rom_map_elem_t rawfile_locals_dict_table[] = {
234234
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&file_obj___exit___obj) },
235235
};
236236

237-
STATIC MP_DEFINE_CONST_DICT(rawfile_locals_dict, rawfile_locals_dict_table);
237+
STATIC MP_DEFINE_CONST_DICT(vfs_fat_rawfile_locals_dict, vfs_fat_rawfile_locals_dict_table);
238238

239239
#if MICROPY_PY_IO_FILEIO
240-
STATIC const mp_stream_p_t fileio_stream_p = {
240+
STATIC const mp_stream_p_t vfs_fat_fileio_stream_p = {
241241
.read = file_obj_read,
242242
.write = file_obj_write,
243243
.ioctl = file_obj_ioctl,
@@ -250,12 +250,12 @@ const mp_obj_type_t mp_type_vfs_fat_fileio = {
250250
.make_new = file_obj_make_new,
251251
.getiter = mp_identity_getiter,
252252
.iternext = mp_stream_unbuffered_iter,
253-
.protocol = &fileio_stream_p,
254-
.locals_dict = (mp_obj_dict_t*)&rawfile_locals_dict,
253+
.protocol = &vfs_fat_fileio_stream_p,
254+
.locals_dict = (mp_obj_dict_t*)&vfs_fat_rawfile_locals_dict,
255255
};
256256
#endif
257257

258-
STATIC const mp_stream_p_t textio_stream_p = {
258+
STATIC const mp_stream_p_t vfs_fat_textio_stream_p = {
259259
.read = file_obj_read,
260260
.write = file_obj_write,
261261
.ioctl = file_obj_ioctl,
@@ -269,8 +269,8 @@ const mp_obj_type_t mp_type_vfs_fat_textio = {
269269
.make_new = file_obj_make_new,
270270
.getiter = mp_identity_getiter,
271271
.iternext = mp_stream_unbuffered_iter,
272-
.protocol = &textio_stream_p,
273-
.locals_dict = (mp_obj_dict_t*)&rawfile_locals_dict,
272+
.protocol = &vfs_fat_textio_stream_p,
273+
.locals_dict = (mp_obj_dict_t*)&vfs_fat_rawfile_locals_dict,
274274
};
275275

276276
// Factory function for I/O stream classes

extmod/vfs_posix_file.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ STATIC mp_uint_t vfs_posix_file_ioctl(mp_obj_t o_in, mp_uint_t request, uintptr_
200200
}
201201
}
202202

203-
STATIC const mp_rom_map_elem_t rawfile_locals_dict_table[] = {
203+
STATIC const mp_rom_map_elem_t vfs_posix_rawfile_locals_dict_table[] = {
204204
{ MP_ROM_QSTR(MP_QSTR_fileno), MP_ROM_PTR(&vfs_posix_file_fileno_obj) },
205205
{ MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&mp_stream_read_obj) },
206206
{ MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&mp_stream_readinto_obj) },
@@ -215,10 +215,10 @@ STATIC const mp_rom_map_elem_t rawfile_locals_dict_table[] = {
215215
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&vfs_posix_file___exit___obj) },
216216
};
217217

218-
STATIC MP_DEFINE_CONST_DICT(rawfile_locals_dict, rawfile_locals_dict_table);
218+
STATIC MP_DEFINE_CONST_DICT(vfs_posix_rawfile_locals_dict, vfs_posix_rawfile_locals_dict_table);
219219

220220
#if MICROPY_PY_IO_FILEIO
221-
STATIC const mp_stream_p_t fileio_stream_p = {
221+
STATIC const mp_stream_p_t vfs_posix_fileio_stream_p = {
222222
.read = vfs_posix_file_read,
223223
.write = vfs_posix_file_write,
224224
.ioctl = vfs_posix_file_ioctl,
@@ -231,12 +231,12 @@ const mp_obj_type_t mp_type_vfs_posix_fileio = {
231231
.make_new = vfs_posix_file_make_new,
232232
.getiter = mp_identity_getiter,
233233
.iternext = mp_stream_unbuffered_iter,
234-
.protocol = &fileio_stream_p,
235-
.locals_dict = (mp_obj_dict_t*)&rawfile_locals_dict,
234+
.protocol = &vfs_posix_fileio_stream_p,
235+
.locals_dict = (mp_obj_dict_t*)&vfs_posix_rawfile_locals_dict,
236236
};
237237
#endif
238238

239-
STATIC const mp_stream_p_t textio_stream_p = {
239+
STATIC const mp_stream_p_t vfs_posix_textio_stream_p = {
240240
.read = vfs_posix_file_read,
241241
.write = vfs_posix_file_write,
242242
.ioctl = vfs_posix_file_ioctl,
@@ -250,8 +250,8 @@ const mp_obj_type_t mp_type_vfs_posix_textio = {
250250
.make_new = vfs_posix_file_make_new,
251251
.getiter = mp_identity_getiter,
252252
.iternext = mp_stream_unbuffered_iter,
253-
.protocol = &textio_stream_p,
254-
.locals_dict = (mp_obj_dict_t*)&rawfile_locals_dict,
253+
.protocol = &vfs_posix_textio_stream_p,
254+
.locals_dict = (mp_obj_dict_t*)&vfs_posix_rawfile_locals_dict,
255255
};
256256

257257
const mp_obj_vfs_posix_file_t mp_sys_stdin_obj = {{&mp_type_textio}, STDIN_FILENO};

0 commit comments

Comments
 (0)