summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Lechner <david@pybricks.com>2022-07-01 14:24:16 -0500
committerDamien George <damien@micropython.org>2022-07-18 13:50:14 +1000
commite531b72b56cfac9a309f79cd242070d675d6ee0e (patch)
tree1a617b37e827f988d2c52e11f0e78cb3aba2d27f
parent8fa6191f955c81678ac4ec3b45f92a72c641f0b1 (diff)
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 <david@pybricks.com>
-rw-r--r--extmod/nimble/modbluetooth_nimble.c5
-rw-r--r--ports/esp32/mpconfigport.h8
-rw-r--r--ports/rp2/mpconfigport.h9
-rw-r--r--ports/stm32/mpconfigport.h11
-rw-r--r--ports/unix/mpconfigport.h13
5 files changed, 5 insertions, 41 deletions
diff --git a/extmod/nimble/modbluetooth_nimble.c b/extmod/nimble/modbluetooth_nimble.c
index fce99bcdf..c26c09e61 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 a374d8120..7cfce49d3 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 87bddbeb7..8b7cb7ca4 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 9c719b8d0..bf7183a81 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 e020e54bf..97846f81f 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