From e531b72b56cfac9a309f79cd242070d675d6ee0e Mon Sep 17 00:00:00 2001 From: David Lechner Date: Fri, 1 Jul 2022 14:24:16 -0500 Subject: [PATCH] extmod/nimble: Use MP_REGISTER_ROOT_POINTER(). This uses MP_REGISTER_ROOT_POINTER() to register bluetooth_nimble_memory and bluetooth_nimble_root_pointers and removes the same from all mpconfigport.h. Signed-off-by: David Lechner --- extmod/nimble/modbluetooth_nimble.c | 5 +++++ ports/esp32/mpconfigport.h | 8 -------- ports/rp2/mpconfigport.h | 9 --------- ports/stm32/mpconfigport.h | 11 ----------- ports/unix/mpconfigport.h | 13 ------------- 5 files changed, 5 insertions(+), 41 deletions(-) diff --git a/extmod/nimble/modbluetooth_nimble.c b/extmod/nimble/modbluetooth_nimble.c index fce99bcdf5..c26c09e61a 100644 --- a/extmod/nimble/modbluetooth_nimble.c +++ b/extmod/nimble/modbluetooth_nimble.c @@ -1966,4 +1966,9 @@ STATIC int ble_secret_store_delete(int obj_type, const union ble_store_key *key) #endif // MICROPY_PY_BLUETOOTH_ENABLE_PAIRING_BONDING +#if !MICROPY_BLUETOOTH_NIMBLE_BINDINGS_ONLY +MP_REGISTER_ROOT_POINTER(struct _mp_bluetooth_nimble_malloc_t *bluetooth_nimble_memory); +#endif +MP_REGISTER_ROOT_POINTER(struct _mp_bluetooth_nimble_root_pointers_t *bluetooth_nimble_root_pointers); + #endif // MICROPY_PY_BLUETOOTH && MICROPY_BLUETOOTH_NIMBLE diff --git a/ports/esp32/mpconfigport.h b/ports/esp32/mpconfigport.h index a374d81203..7cfce49d37 100644 --- a/ports/esp32/mpconfigport.h +++ b/ports/esp32/mpconfigport.h @@ -138,19 +138,11 @@ struct _machine_timer_obj_t; -#if MICROPY_BLUETOOTH_NIMBLE -struct mp_bluetooth_nimble_root_pointers_t; -#define MICROPY_PORT_ROOT_POINTER_BLUETOOTH_NIMBLE struct _mp_bluetooth_nimble_root_pointers_t *bluetooth_nimble_root_pointers; -#else -#define MICROPY_PORT_ROOT_POINTER_BLUETOOTH_NIMBLE -#endif - #define MICROPY_PORT_ROOT_POINTERS \ mp_obj_t machine_pin_irq_handler[40]; \ struct _machine_timer_obj_t *machine_timer_obj_head; \ struct _machine_i2s_obj_t *machine_i2s_obj[I2S_NUM_MAX]; \ mp_obj_t native_code_pointers; \ - MICROPY_PORT_ROOT_POINTER_BLUETOOTH_NIMBLE // type definitions for the specific machine diff --git a/ports/rp2/mpconfigport.h b/ports/rp2/mpconfigport.h index 87bddbeb77..8b7cb7ca42 100644 --- a/ports/rp2/mpconfigport.h +++ b/ports/rp2/mpconfigport.h @@ -147,14 +147,6 @@ #define MICROPY_PORT_ROOT_POINTER_BLUETOOTH #endif -#if MICROPY_BLUETOOTH_NIMBLE -struct _mp_bluetooth_nimble_root_pointers_t; -struct _mp_bluetooth_nimble_malloc_t; -#define MICROPY_PORT_ROOT_POINTER_BLUETOOTH_NIMBLE struct _mp_bluetooth_nimble_malloc_t *bluetooth_nimble_memory; struct _mp_bluetooth_nimble_root_pointers_t *bluetooth_nimble_root_pointers; -#else -#define MICROPY_PORT_ROOT_POINTER_BLUETOOTH_NIMBLE -#endif - // By default networking should include sockets, ssl, websockets, webrepl, dupterm. #if MICROPY_PY_NETWORK #ifndef MICROPY_PY_USOCKET @@ -238,7 +230,6 @@ extern const struct _mod_network_nic_type_t mod_network_nic_type_wiznet5k; NETWORK_ROOT_POINTERS \ MICROPY_BOARD_ROOT_POINTERS \ MICROPY_PORT_ROOT_POINTER_BLUETOOTH \ - MICROPY_PORT_ROOT_POINTER_BLUETOOTH_NIMBLE \ #define MP_STATE_PORT MP_STATE_VM diff --git a/ports/stm32/mpconfigport.h b/ports/stm32/mpconfigport.h index 9c719b8d06..bf7183a81d 100644 --- a/ports/stm32/mpconfigport.h +++ b/ports/stm32/mpconfigport.h @@ -238,14 +238,6 @@ extern const struct _mod_network_nic_type_t mod_network_nic_type_cc3k; #define MP_STATE_PORT MP_STATE_VM -#if MICROPY_BLUETOOTH_NIMBLE -struct _mp_bluetooth_nimble_root_pointers_t; -struct _mp_bluetooth_nimble_malloc_t; -#define MICROPY_PORT_ROOT_POINTER_BLUETOOTH_NIMBLE struct _mp_bluetooth_nimble_malloc_t *bluetooth_nimble_memory; struct _mp_bluetooth_nimble_root_pointers_t *bluetooth_nimble_root_pointers; -#else -#define MICROPY_PORT_ROOT_POINTER_BLUETOOTH_NIMBLE -#endif - #ifndef MICROPY_BOARD_ROOT_POINTERS #define MICROPY_BOARD_ROOT_POINTERS #endif @@ -283,9 +275,6 @@ struct _mp_bluetooth_nimble_malloc_t; /* list of registered NICs */ \ mp_obj_list_t mod_network_nic_list; \ \ - /* root pointers for sub-systems */ \ - MICROPY_PORT_ROOT_POINTER_BLUETOOTH_NIMBLE \ - \ /* root pointers defined by a board */ \ MICROPY_BOARD_ROOT_POINTERS \ diff --git a/ports/unix/mpconfigport.h b/ports/unix/mpconfigport.h index e020e54bf5..97846f81f0 100644 --- a/ports/unix/mpconfigport.h +++ b/ports/unix/mpconfigport.h @@ -290,19 +290,6 @@ static inline unsigned long mp_urandom_seed_init(void) { #define MP_STATE_PORT MP_STATE_VM -#if MICROPY_PY_BLUETOOTH -#if MICROPY_BLUETOOTH_NIMBLE -struct _mp_bluetooth_nimble_root_pointers_t; -struct _mp_bluetooth_nimble_malloc_t; -#define MICROPY_BLUETOOTH_ROOT_POINTERS struct _mp_bluetooth_nimble_malloc_t *bluetooth_nimble_memory; struct _mp_bluetooth_nimble_root_pointers_t *bluetooth_nimble_root_pointers; -#endif -#else -#define MICROPY_BLUETOOTH_ROOT_POINTERS -#endif - -#define MICROPY_PORT_ROOT_POINTERS \ - MICROPY_BLUETOOTH_ROOT_POINTERS \ - // We need to provide a declaration/definition of alloca() // unless support for it is disabled. #if !defined(MICROPY_NO_ALLOCA) || MICROPY_NO_ALLOCA == 0