Skip to content

Commit cd31d82

Browse files
committed
unix: Use STATIC modifier to enable code size analysis via map file.
1 parent 6582a41 commit cd31d82

4 files changed

Lines changed: 68 additions & 68 deletions

File tree

unix/file.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ typedef struct _mp_obj_fdfile_t {
1717
int fd;
1818
} mp_obj_fdfile_t;
1919

20-
static const mp_obj_type_t rawfile_type;
20+
STATIC const mp_obj_type_t rawfile_type;
2121

22-
static void fdfile_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
22+
STATIC void fdfile_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
2323
mp_obj_fdfile_t *self = self_in;
2424
print(env, "<io.FileIO %d>", self->fd);
2525
}
2626

27-
static machine_int_t fdfile_read(mp_obj_t o_in, void *buf, machine_uint_t size, int *errcode) {
27+
STATIC machine_int_t fdfile_read(mp_obj_t o_in, void *buf, machine_uint_t size, int *errcode) {
2828
mp_obj_fdfile_t *o = o_in;
2929
machine_int_t r = read(o->fd, buf, size);
3030
if (r == -1) {
@@ -33,7 +33,7 @@ static machine_int_t fdfile_read(mp_obj_t o_in, void *buf, machine_uint_t size,
3333
return r;
3434
}
3535

36-
static machine_int_t fdfile_write(mp_obj_t o_in, const void *buf, machine_uint_t size, int *errcode) {
36+
STATIC machine_int_t fdfile_write(mp_obj_t o_in, const void *buf, machine_uint_t size, int *errcode) {
3737
mp_obj_fdfile_t *o = o_in;
3838
machine_int_t r = write(o->fd, buf, size);
3939
if (r == -1) {
@@ -42,32 +42,32 @@ static machine_int_t fdfile_write(mp_obj_t o_in, const void *buf, machine_uint_t
4242
return r;
4343
}
4444

45-
static mp_obj_t fdfile_close(mp_obj_t self_in) {
45+
STATIC mp_obj_t fdfile_close(mp_obj_t self_in) {
4646
mp_obj_fdfile_t *self = self_in;
4747
close(self->fd);
4848
return mp_const_none;
4949
}
50-
static MP_DEFINE_CONST_FUN_OBJ_1(fdfile_close_obj, fdfile_close);
50+
STATIC MP_DEFINE_CONST_FUN_OBJ_1(fdfile_close_obj, fdfile_close);
5151

5252
mp_obj_t fdfile___exit__(uint n_args, const mp_obj_t *args) {
5353
return fdfile_close(args[0]);
5454
}
55-
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(fdfile___exit___obj, 4, 4, fdfile___exit__);
55+
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(fdfile___exit___obj, 4, 4, fdfile___exit__);
5656

57-
static mp_obj_t fdfile_fileno(mp_obj_t self_in) {
57+
STATIC mp_obj_t fdfile_fileno(mp_obj_t self_in) {
5858
mp_obj_fdfile_t *self = self_in;
5959
return MP_OBJ_NEW_SMALL_INT((machine_int_t)self->fd);
6060
}
61-
static MP_DEFINE_CONST_FUN_OBJ_1(fdfile_fileno_obj, fdfile_fileno);
61+
STATIC MP_DEFINE_CONST_FUN_OBJ_1(fdfile_fileno_obj, fdfile_fileno);
6262

63-
static mp_obj_fdfile_t *fdfile_new(int fd) {
63+
STATIC mp_obj_fdfile_t *fdfile_new(int fd) {
6464
mp_obj_fdfile_t *o = m_new_obj(mp_obj_fdfile_t);
6565
o->base.type = &rawfile_type;
6666
o->fd = fd;
6767
return o;
6868
}
6969

70-
static mp_obj_t fdfile_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
70+
STATIC mp_obj_t fdfile_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
7171
mp_obj_fdfile_t *o = m_new_obj(mp_obj_fdfile_t);
7272
o->base.type = type_in;
7373

@@ -123,7 +123,7 @@ STATIC const mp_map_elem_t rawfile_locals_dict_table[] = {
123123

124124
STATIC MP_DEFINE_CONST_DICT(rawfile_locals_dict, rawfile_locals_dict_table);
125125

126-
static const mp_obj_type_t rawfile_type = {
126+
STATIC const mp_obj_type_t rawfile_type = {
127127
{ &mp_type_type },
128128
.name = MP_QSTR_io_dot_FileIO,
129129
.print = fdfile_print,

unix/main.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ void microsocket_init();
4242
void time_init();
4343
void ffi_init();
4444

45-
static void execute_from_lexer(mp_lexer_t *lex, mp_parse_input_kind_t input_kind, bool is_repl) {
45+
STATIC void execute_from_lexer(mp_lexer_t *lex, mp_parse_input_kind_t input_kind, bool is_repl) {
4646
if (lex == NULL) {
4747
return;
4848
}
@@ -94,7 +94,7 @@ static void execute_from_lexer(mp_lexer_t *lex, mp_parse_input_kind_t input_kind
9494
}
9595
}
9696

97-
static char *strjoin(const char *s1, int sep_char, const char *s2) {
97+
STATIC char *strjoin(const char *s1, int sep_char, const char *s2) {
9898
int l1 = strlen(s1);
9999
int l2 = strlen(s2);
100100
char *s = malloc(l1 + l2 + 2);
@@ -108,7 +108,7 @@ static char *strjoin(const char *s1, int sep_char, const char *s2) {
108108
return s;
109109
}
110110

111-
static char *prompt(char *p) {
111+
STATIC char *prompt(char *p) {
112112
#if MICROPY_USE_READLINE
113113
char *line = readline(p);
114114
if (line) {
@@ -133,7 +133,7 @@ static char *prompt(char *p) {
133133
return line;
134134
}
135135

136-
static void do_repl(void) {
136+
STATIC void do_repl(void) {
137137
for (;;) {
138138
char *line = prompt(">>> ");
139139
if (line == NULL) {
@@ -159,12 +159,12 @@ static void do_repl(void) {
159159
}
160160
}
161161

162-
static void do_file(const char *file) {
162+
STATIC void do_file(const char *file) {
163163
mp_lexer_t *lex = mp_lexer_new_from_file(file);
164164
execute_from_lexer(lex, MP_PARSE_FILE_INPUT, false);
165165
}
166166

167-
static void do_str(const char *str) {
167+
STATIC void do_str(const char *str) {
168168
mp_lexer_t *lex = mp_lexer_new_from_str_len(MP_QSTR__lt_stdin_gt_, str, strlen(str), false);
169169
execute_from_lexer(lex, MP_PARSE_SINGLE_INPUT, false);
170170
}
@@ -174,33 +174,33 @@ typedef struct _test_obj_t {
174174
int value;
175175
} test_obj_t;
176176

177-
static void test_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
177+
STATIC void test_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
178178
test_obj_t *self = self_in;
179179
print(env, "<test %d>", self->value);
180180
}
181181

182-
static mp_obj_t test_get(mp_obj_t self_in) {
182+
STATIC mp_obj_t test_get(mp_obj_t self_in) {
183183
test_obj_t *self = self_in;
184184
return mp_obj_new_int(self->value);
185185
}
186186

187-
static mp_obj_t test_set(mp_obj_t self_in, mp_obj_t arg) {
187+
STATIC mp_obj_t test_set(mp_obj_t self_in, mp_obj_t arg) {
188188
test_obj_t *self = self_in;
189189
self->value = mp_obj_get_int(arg);
190190
return mp_const_none;
191191
}
192192

193-
static MP_DEFINE_CONST_FUN_OBJ_1(test_get_obj, test_get);
194-
static MP_DEFINE_CONST_FUN_OBJ_2(test_set_obj, test_set);
193+
STATIC MP_DEFINE_CONST_FUN_OBJ_1(test_get_obj, test_get);
194+
STATIC MP_DEFINE_CONST_FUN_OBJ_2(test_set_obj, test_set);
195195

196-
static const mp_map_elem_t test_locals_dict_table[] = {
196+
STATIC const mp_map_elem_t test_locals_dict_table[] = {
197197
{ MP_OBJ_NEW_QSTR(MP_QSTR_get), (mp_obj_t)&test_get_obj },
198198
{ MP_OBJ_NEW_QSTR(MP_QSTR_set), (mp_obj_t)&test_set_obj },
199199
};
200200

201201
STATIC MP_DEFINE_CONST_DICT(test_locals_dict, test_locals_dict_table);
202202

203-
static const mp_obj_type_t test_type = {
203+
STATIC const mp_obj_type_t test_type = {
204204
{ &mp_type_type },
205205
.name = MP_QSTR_Test,
206206
.print = test_print,
@@ -249,7 +249,7 @@ mp_obj_t qstr_info(void) {
249249

250250
#if MICROPY_ENABLE_GC
251251
// TODO: this doesn't belong here
252-
static mp_obj_t pyb_gc(void) {
252+
STATIC mp_obj_t pyb_gc(void) {
253253
gc_collect();
254254
return mp_const_none;
255255
}

0 commit comments

Comments
 (0)