mirror of
https://github.com/micropython/micropython.git
synced 2026-01-08 13:10:21 +01:00
extmod/modnetwork: Remove modnetwork socket u_state member.
To simplify the socket state. The CC3K driver (see drivers/cc3000/inc/socket.h and src/socket.c) has socket() returning an INT16 so there is now enough room to store it directly in the fileno member.
This commit is contained in:
committed by
Damien George
parent
f9d573a4ac
commit
d9749f90ad
@@ -72,15 +72,11 @@ typedef struct _mod_network_socket_obj_t {
|
||||
mp_obj_base_t base;
|
||||
mp_obj_t nic;
|
||||
mod_network_nic_type_t *nic_type;
|
||||
union {
|
||||
struct {
|
||||
uint8_t domain;
|
||||
uint8_t type;
|
||||
int8_t fileno;
|
||||
uint8_t bound;
|
||||
} u_param;
|
||||
mp_uint_t u_state;
|
||||
};
|
||||
uint32_t domain : 5;
|
||||
uint32_t type : 5;
|
||||
uint32_t proto : 5;
|
||||
uint32_t bound : 1;
|
||||
int32_t fileno : 16;
|
||||
#if MICROPY_PY_USOCKET_EXTENDED_STATE
|
||||
// Extended socket state for NICs/ports that need it.
|
||||
int32_t timeout;
|
||||
|
||||
@@ -51,16 +51,17 @@ STATIC mp_obj_t socket_make_new(const mp_obj_type_t *type, size_t n_args, size_t
|
||||
s->base.type = &socket_type;
|
||||
s->nic = MP_OBJ_NULL;
|
||||
s->nic_type = NULL;
|
||||
s->u_param.domain = MOD_NETWORK_AF_INET;
|
||||
s->u_param.type = MOD_NETWORK_SOCK_STREAM;
|
||||
s->u_param.fileno = -1;
|
||||
s->u_param.bound = false;
|
||||
s->domain = MOD_NETWORK_AF_INET;
|
||||
s->type = MOD_NETWORK_SOCK_STREAM;
|
||||
s->proto = 0;
|
||||
s->bound = false;
|
||||
s->fileno = -1;
|
||||
if (n_args >= 1) {
|
||||
s->u_param.domain = mp_obj_get_int(args[0]);
|
||||
s->domain = mp_obj_get_int(args[0]);
|
||||
if (n_args >= 2) {
|
||||
s->u_param.type = mp_obj_get_int(args[1]);
|
||||
s->type = mp_obj_get_int(args[1]);
|
||||
if (n_args >= 4) {
|
||||
s->u_param.fileno = mp_obj_get_int(args[3]);
|
||||
s->fileno = mp_obj_get_int(args[3]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user