summaryrefslogtreecommitdiff
path: root/py/dynruntime.h
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2024-03-25 13:10:12 +1100
committerDamien George <damien@micropython.org>2024-03-28 16:18:09 +1100
commitd2276f0d41c2fa66a224725fdb2411846c91cf1a (patch)
treee3f25bf47b4e8adfd5fd341819fded5457d961e4 /py/dynruntime.h
parent4662a71f44bd8a0f8ff96d12e43f69be3bff8488 (diff)
py/dynruntime: Add mp_binary_get_size/get_val_array/set_val_array.
These are needed to read/write array.array objects, which is useful in native code to provide fast extensions that work with big arrays of data. Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'py/dynruntime.h')
-rw-r--r--py/dynruntime.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/py/dynruntime.h b/py/dynruntime.h
index 7765fca40..d07b1dce2 100644
--- a/py/dynruntime.h
+++ b/py/dynruntime.h
@@ -29,6 +29,7 @@
// This header file contains definitions to dynamically implement the static
// MicroPython runtime API defined in py/obj.h and py/runtime.h.
+#include "py/binary.h"
#include "py/nativeglue.h"
#include "py/objfun.h"
#include "py/objstr.h"
@@ -184,6 +185,10 @@ static inline void *mp_obj_malloc_helper_dyn(size_t num_bytes, const mp_obj_type
/******************************************************************************/
// General runtime functions
+#define mp_binary_get_size(struct_type, val_type, palign) (mp_fun_table.binary_get_size((struct_type), (val_type), (palign)))
+#define mp_binary_get_val_array(typecode, p, index) (mp_fun_table.binary_get_val_array((typecode), (p), (index)))
+#define mp_binary_set_val_array(typecode, p, index, val_in) (mp_fun_table.binary_set_val_array((typecode), (p), (index), (val_in)))
+
#define mp_load_name(qst) (mp_fun_table.load_name((qst)))
#define mp_load_global(qst) (mp_fun_table.load_global((qst)))
#define mp_load_attr(base, attr) (mp_fun_table.load_attr((base), (attr)))