mirror of
https://github.com/micropython/micropython.git
synced 2026-01-06 04:00:28 +01:00
unix: Use STATIC modifier to enable code size analysis via map file.
This commit is contained in:
24
unix/file.c
24
unix/file.c
@@ -17,14 +17,14 @@ typedef struct _mp_obj_fdfile_t {
|
||||
int fd;
|
||||
} mp_obj_fdfile_t;
|
||||
|
||||
static const mp_obj_type_t rawfile_type;
|
||||
STATIC const mp_obj_type_t rawfile_type;
|
||||
|
||||
static void fdfile_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
|
||||
STATIC void fdfile_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
|
||||
mp_obj_fdfile_t *self = self_in;
|
||||
print(env, "<io.FileIO %d>", self->fd);
|
||||
}
|
||||
|
||||
static machine_int_t fdfile_read(mp_obj_t o_in, void *buf, machine_uint_t size, int *errcode) {
|
||||
STATIC machine_int_t fdfile_read(mp_obj_t o_in, void *buf, machine_uint_t size, int *errcode) {
|
||||
mp_obj_fdfile_t *o = o_in;
|
||||
machine_int_t r = read(o->fd, buf, size);
|
||||
if (r == -1) {
|
||||
@@ -33,7 +33,7 @@ static machine_int_t fdfile_read(mp_obj_t o_in, void *buf, machine_uint_t size,
|
||||
return r;
|
||||
}
|
||||
|
||||
static machine_int_t fdfile_write(mp_obj_t o_in, const void *buf, machine_uint_t size, int *errcode) {
|
||||
STATIC machine_int_t fdfile_write(mp_obj_t o_in, const void *buf, machine_uint_t size, int *errcode) {
|
||||
mp_obj_fdfile_t *o = o_in;
|
||||
machine_int_t r = write(o->fd, buf, size);
|
||||
if (r == -1) {
|
||||
@@ -42,32 +42,32 @@ static machine_int_t fdfile_write(mp_obj_t o_in, const void *buf, machine_uint_t
|
||||
return r;
|
||||
}
|
||||
|
||||
static mp_obj_t fdfile_close(mp_obj_t self_in) {
|
||||
STATIC mp_obj_t fdfile_close(mp_obj_t self_in) {
|
||||
mp_obj_fdfile_t *self = self_in;
|
||||
close(self->fd);
|
||||
return mp_const_none;
|
||||
}
|
||||
static MP_DEFINE_CONST_FUN_OBJ_1(fdfile_close_obj, fdfile_close);
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(fdfile_close_obj, fdfile_close);
|
||||
|
||||
mp_obj_t fdfile___exit__(uint n_args, const mp_obj_t *args) {
|
||||
return fdfile_close(args[0]);
|
||||
}
|
||||
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(fdfile___exit___obj, 4, 4, fdfile___exit__);
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(fdfile___exit___obj, 4, 4, fdfile___exit__);
|
||||
|
||||
static mp_obj_t fdfile_fileno(mp_obj_t self_in) {
|
||||
STATIC mp_obj_t fdfile_fileno(mp_obj_t self_in) {
|
||||
mp_obj_fdfile_t *self = self_in;
|
||||
return MP_OBJ_NEW_SMALL_INT((machine_int_t)self->fd);
|
||||
}
|
||||
static MP_DEFINE_CONST_FUN_OBJ_1(fdfile_fileno_obj, fdfile_fileno);
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(fdfile_fileno_obj, fdfile_fileno);
|
||||
|
||||
static mp_obj_fdfile_t *fdfile_new(int fd) {
|
||||
STATIC mp_obj_fdfile_t *fdfile_new(int fd) {
|
||||
mp_obj_fdfile_t *o = m_new_obj(mp_obj_fdfile_t);
|
||||
o->base.type = &rawfile_type;
|
||||
o->fd = fd;
|
||||
return o;
|
||||
}
|
||||
|
||||
static mp_obj_t fdfile_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t fdfile_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
mp_obj_fdfile_t *o = m_new_obj(mp_obj_fdfile_t);
|
||||
o->base.type = type_in;
|
||||
|
||||
@@ -123,7 +123,7 @@ STATIC const mp_map_elem_t rawfile_locals_dict_table[] = {
|
||||
|
||||
STATIC MP_DEFINE_CONST_DICT(rawfile_locals_dict, rawfile_locals_dict_table);
|
||||
|
||||
static const mp_obj_type_t rawfile_type = {
|
||||
STATIC const mp_obj_type_t rawfile_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_io_dot_FileIO,
|
||||
.print = fdfile_print,
|
||||
|
||||
Reference in New Issue
Block a user