mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Update libmp
* Fixes a bug in gc
This commit is contained in:
parent
ab05fb6213
commit
2e147d5415
@ -19,3 +19,4 @@ typedef struct _gc_info_t {
|
||||
|
||||
void gc_info(gc_info_t *info);
|
||||
void gc_dump_info(void);
|
||||
void gc_dump_alloc_table(void);
|
||||
|
||||
@ -60,18 +60,14 @@ bool unichar_isxdigit(unichar c);
|
||||
#define streq(s1, s2) (strcmp((s1), (s2)) == 0)
|
||||
*/
|
||||
|
||||
long strtonum(const char *restrict s, int base);
|
||||
|
||||
/** variable string *********************************************/
|
||||
|
||||
typedef struct _vstr_t {
|
||||
int alloc;
|
||||
int len;
|
||||
char *buf;
|
||||
struct {
|
||||
bool had_error : 1;
|
||||
bool fixed_buf : 1;
|
||||
};
|
||||
bool had_error : 1;
|
||||
bool fixed_buf : 1;
|
||||
} vstr_t;
|
||||
|
||||
// convenience macro to declare a vstr with a fixed size buffer on the stack
|
||||
|
||||
@ -68,6 +68,7 @@
|
||||
// Long int implementation
|
||||
#define MICROPY_LONGINT_IMPL_NONE (0)
|
||||
#define MICROPY_LONGINT_IMPL_LONGLONG (1)
|
||||
#define MICROPY_LONGINT_IMPL_MPZ (2)
|
||||
|
||||
#ifndef MICROPY_LONGINT_IMPL
|
||||
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_NONE)
|
||||
|
||||
@ -7,7 +7,16 @@
|
||||
#define MICROPY_ENABLE_GC (1)
|
||||
#define MICROPY_ENABLE_REPL_HELPERS (1)
|
||||
#define MICROPY_ENABLE_FLOAT (1)
|
||||
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ)
|
||||
#define MICROPY_PATH_MAX (128)
|
||||
/* Enable FatFS LFNs
|
||||
0: Disable LFN feature.
|
||||
1: Enable LFN with static working buffer on the BSS. Always NOT reentrant.
|
||||
2: Enable LFN with dynamic working buffer on the STACK.
|
||||
3: Enable LFN with dynamic working buffer on the HEAP.
|
||||
*/
|
||||
#define MICROPY_ENABLE_LFN (1)
|
||||
#define MICROPY_LFN_CODE_PAGE (437) /* 1=SFN/ANSI 437=LFN/U.S.(OEM) */
|
||||
|
||||
// type definitions for the specific machine
|
||||
|
||||
|
||||
@ -3,23 +3,19 @@
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
//#ifndef __WORDSIZE
|
||||
//#error __WORDSIZE needs to be defined
|
||||
//#endif
|
||||
|
||||
typedef struct _nlr_buf_t nlr_buf_t;
|
||||
struct _nlr_buf_t {
|
||||
// the entries here must all be machine word size
|
||||
nlr_buf_t *prev;
|
||||
void *ret_val;
|
||||
#if __WORDSIZE == 32
|
||||
#if defined(__i386__)
|
||||
void *regs[6];
|
||||
#elif __WORDSIZE == 64
|
||||
#elif defined(__x86_64__)
|
||||
void *regs[8];
|
||||
#else
|
||||
// hack for thumb
|
||||
#elif defined(__thumb2__)
|
||||
void *regs[10];
|
||||
//#error Unsupported __WORDSIZE
|
||||
#else
|
||||
#error Unknown arch in nlr.h
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@ -54,14 +54,14 @@ typedef struct _mp_obj_base_t mp_obj_base_t;
|
||||
|
||||
#define MP_DECLARE_CONST_FUN_OBJ(obj_name) extern const mp_obj_fun_native_t obj_name
|
||||
|
||||
#define MP_DEFINE_CONST_FUN_OBJ_VOID_PTR(obj_name, is_kw, n_args_min, n_args_max, fun_name) const mp_obj_fun_native_t obj_name = {{&fun_native_type}, {is_kw, n_args_min}, n_args_max, (void *)fun_name}
|
||||
#define MP_DEFINE_CONST_FUN_OBJ_VOID_PTR(obj_name, is_kw, n_args_min, n_args_max, fun_name) const mp_obj_fun_native_t obj_name = {{&fun_native_type}, is_kw, n_args_min, n_args_max, (void *)fun_name}
|
||||
#define MP_DEFINE_CONST_FUN_OBJ_0(obj_name, fun_name) MP_DEFINE_CONST_FUN_OBJ_VOID_PTR(obj_name, false, 0, 0, (mp_fun_0_t)fun_name)
|
||||
#define MP_DEFINE_CONST_FUN_OBJ_1(obj_name, fun_name) MP_DEFINE_CONST_FUN_OBJ_VOID_PTR(obj_name, false, 1, 1, (mp_fun_1_t)fun_name)
|
||||
#define MP_DEFINE_CONST_FUN_OBJ_2(obj_name, fun_name) MP_DEFINE_CONST_FUN_OBJ_VOID_PTR(obj_name, false, 2, 2, (mp_fun_2_t)fun_name)
|
||||
#define MP_DEFINE_CONST_FUN_OBJ_3(obj_name, fun_name) MP_DEFINE_CONST_FUN_OBJ_VOID_PTR(obj_name, false, 3, 3, (mp_fun_3_t)fun_name)
|
||||
#define MP_DEFINE_CONST_FUN_OBJ_VAR(obj_name, n_args_min, fun_name) MP_DEFINE_CONST_FUN_OBJ_VOID_PTR(obj_name, false, n_args_min, (~((machine_uint_t)0)), (mp_fun_var_t)fun_name)
|
||||
#define MP_DEFINE_CONST_FUN_OBJ_VAR(obj_name, n_args_min, fun_name) MP_DEFINE_CONST_FUN_OBJ_VOID_PTR(obj_name, false, n_args_min, MP_OBJ_FUN_ARGS_MAX, (mp_fun_var_t)fun_name)
|
||||
#define MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(obj_name, n_args_min, n_args_max, fun_name) MP_DEFINE_CONST_FUN_OBJ_VOID_PTR(obj_name, false, n_args_min, n_args_max, (mp_fun_var_t)fun_name)
|
||||
#define MP_DEFINE_CONST_FUN_OBJ_KW(obj_name, n_args_min, fun_name) MP_DEFINE_CONST_FUN_OBJ_VOID_PTR(obj_name, true, n_args_min, (~((machine_uint_t)0)), (mp_fun_kw_t)fun_name)
|
||||
#define MP_DEFINE_CONST_FUN_OBJ_KW(obj_name, n_args_min, fun_name) MP_DEFINE_CONST_FUN_OBJ_VOID_PTR(obj_name, true, n_args_min, MP_OBJ_FUN_ARGS_MAX, (mp_fun_kw_t)fun_name)
|
||||
|
||||
// These macros are used to declare and define constant staticmethond and classmethod objects
|
||||
// You can put "static" in front of the definitions to make them local
|
||||
@ -75,7 +75,6 @@ typedef struct _mp_obj_base_t mp_obj_base_t;
|
||||
// Need to declare this here so we are not dependent on map.h
|
||||
struct _mp_map_t;
|
||||
struct _mp_map_elem_t;
|
||||
enum _mp_map_lookup_kind_t;
|
||||
|
||||
// Type definitions for methods
|
||||
|
||||
@ -225,6 +224,9 @@ mp_obj_t mp_obj_new_cell(mp_obj_t obj);
|
||||
mp_obj_t mp_obj_new_int(machine_int_t value);
|
||||
mp_obj_t mp_obj_new_int_from_uint(machine_uint_t value);
|
||||
mp_obj_t mp_obj_new_int_from_long_str(const char *s);
|
||||
#if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE
|
||||
mp_obj_t mp_obj_new_int_from_ll(long long val);
|
||||
#endif
|
||||
mp_obj_t mp_obj_new_str(const byte* data, uint len, bool make_qstr_if_not_already);
|
||||
mp_obj_t mp_obj_new_bytes(const byte* data, uint len);
|
||||
#if MICROPY_ENABLE_FLOAT
|
||||
@ -370,13 +372,12 @@ uint mp_obj_array_len(mp_obj_t self_in);
|
||||
mp_obj_t mp_obj_new_bytearray_by_ref(uint n, void *items);
|
||||
|
||||
// functions
|
||||
#define MP_OBJ_FUN_ARGS_MAX (0xffff) // to set maximum value in n_args_max below
|
||||
typedef struct _mp_obj_fun_native_t { // need this so we can define const objects (to go in ROM)
|
||||
mp_obj_base_t base;
|
||||
struct {
|
||||
bool is_kw : 1;
|
||||
machine_uint_t n_args_min : (8 * sizeof(machine_uint_t) - 1); // inclusive
|
||||
};
|
||||
machine_uint_t n_args_max; // inclusive
|
||||
bool is_kw : 1;
|
||||
uint n_args_min : 15; // inclusive
|
||||
uint n_args_max : 16; // inclusive
|
||||
void *fun;
|
||||
// TODO add mp_map_t *globals
|
||||
// for const function objects, make an empty, const map
|
||||
|
||||
@ -2,29 +2,30 @@ struct _mp_lexer_t;
|
||||
|
||||
// a mp_parse_node_t is:
|
||||
// - 0000...0000: no node
|
||||
// - xxxx...0001: an identifier; bits 4 and above are the qstr
|
||||
// - xxxx...0011: a small integer; bits 4 and above are the signed value, 2's complement
|
||||
// - xxxx...0101: an integer; bits 4 and above are the qstr holding the value
|
||||
// - xxxx...0111: a decimal; bits 4 and above are the qstr holding the value
|
||||
// - xxxx...1001: a string; bits 4 and above are the qstr holding the value
|
||||
// - xxxx...1011: a string with triple quotes; bits 4 and above are the qstr holding the value
|
||||
// - xxxx...1101: a token; bits 4 and above are mp_token_kind_t
|
||||
// - xxxx...xxx0: pointer to mp_parse_node_struct_t
|
||||
// - xxxx...xxx1: a small integer; bits 1 and above are the signed value, 2's complement
|
||||
// - xxxx...xx00: pointer to mp_parse_node_struct_t
|
||||
// - xx...x00010: an identifier; bits 5 and above are the qstr
|
||||
// - xx...x00110: an integer; bits 5 and above are the qstr holding the value
|
||||
// - xx...x01010: a decimal; bits 5 and above are the qstr holding the value
|
||||
// - xx...x01110: a string; bits 5 and above are the qstr holding the value
|
||||
// - xx...x10010: a string of bytes; bits 5 and above are the qstr holding the value
|
||||
// - xx...x10110: a token; bits 5 and above are mp_token_kind_t
|
||||
|
||||
// makes sure the top 5 bits of x are all cleared (positive number) or all set (negavite number)
|
||||
// TODO: these can now be unified with MP_OBJ_FITS_SMALL_INT(x)
|
||||
// makes sure the top 2 bits of x are all cleared (positive number) or all set (negavite number)
|
||||
// these macros can probably go somewhere else because they are used more than just in the parser
|
||||
#define MP_UINT_HIGH_5_BITS (~((~((machine_uint_t)0)) >> 5))
|
||||
#define MP_UINT_HIGH_2_BITS (~((~((machine_uint_t)0)) >> 2))
|
||||
// parser's small ints are different from VM small int
|
||||
#define MP_PARSE_FITS_SMALL_INT(x) (((((machine_uint_t)(x)) & MP_UINT_HIGH_5_BITS) == 0) || ((((machine_uint_t)(x)) & MP_UINT_HIGH_5_BITS) == MP_UINT_HIGH_5_BITS))
|
||||
#define MP_PARSE_FITS_SMALL_INT(x) (((((machine_uint_t)(x)) & MP_UINT_HIGH_2_BITS) == 0) || ((((machine_uint_t)(x)) & MP_UINT_HIGH_2_BITS) == MP_UINT_HIGH_2_BITS))
|
||||
|
||||
#define MP_PARSE_NODE_NULL (0)
|
||||
#define MP_PARSE_NODE_ID (0x1)
|
||||
#define MP_PARSE_NODE_SMALL_INT (0x3)
|
||||
#define MP_PARSE_NODE_INTEGER (0x5)
|
||||
#define MP_PARSE_NODE_DECIMAL (0x7)
|
||||
#define MP_PARSE_NODE_STRING (0x9)
|
||||
#define MP_PARSE_NODE_BYTES (0xb)
|
||||
#define MP_PARSE_NODE_TOKEN (0xd)
|
||||
#define MP_PARSE_NODE_SMALL_INT (0x1)
|
||||
#define MP_PARSE_NODE_ID (0x02)
|
||||
#define MP_PARSE_NODE_INTEGER (0x06)
|
||||
#define MP_PARSE_NODE_DECIMAL (0x0a)
|
||||
#define MP_PARSE_NODE_STRING (0x0e)
|
||||
#define MP_PARSE_NODE_BYTES (0x12)
|
||||
#define MP_PARSE_NODE_TOKEN (0x16)
|
||||
|
||||
typedef machine_uint_t mp_parse_node_t; // must be pointer size
|
||||
|
||||
@ -38,18 +39,19 @@ typedef struct _mp_parse_node_struct_t {
|
||||
// some of these evaluate their argument more than once
|
||||
|
||||
#define MP_PARSE_NODE_IS_NULL(pn) ((pn) == MP_PARSE_NODE_NULL)
|
||||
#define MP_PARSE_NODE_IS_LEAF(pn) ((pn) & 1)
|
||||
#define MP_PARSE_NODE_IS_STRUCT(pn) ((pn) != MP_PARSE_NODE_NULL && ((pn) & 1) == 0)
|
||||
#define MP_PARSE_NODE_IS_STRUCT_KIND(pn, k) ((pn) != MP_PARSE_NODE_NULL && ((pn) & 1) == 0 && MP_PARSE_NODE_STRUCT_KIND((mp_parse_node_struct_t*)(pn)) == (k))
|
||||
#define MP_PARSE_NODE_IS_LEAF(pn) ((pn) & 3)
|
||||
#define MP_PARSE_NODE_IS_STRUCT(pn) ((pn) != MP_PARSE_NODE_NULL && ((pn) & 3) == 0)
|
||||
#define MP_PARSE_NODE_IS_STRUCT_KIND(pn, k) ((pn) != MP_PARSE_NODE_NULL && ((pn) & 3) == 0 && MP_PARSE_NODE_STRUCT_KIND((mp_parse_node_struct_t*)(pn)) == (k))
|
||||
|
||||
#define MP_PARSE_NODE_IS_ID(pn) (((pn) & 0xf) == MP_PARSE_NODE_ID)
|
||||
#define MP_PARSE_NODE_IS_SMALL_INT(pn) (((pn) & 0xf) == MP_PARSE_NODE_SMALL_INT)
|
||||
#define MP_PARSE_NODE_IS_TOKEN(pn) (((pn) & 0xf) == MP_PARSE_NODE_TOKEN)
|
||||
#define MP_PARSE_NODE_IS_TOKEN_KIND(pn, k) ((pn) == (MP_PARSE_NODE_TOKEN | (k << 4)))
|
||||
#define MP_PARSE_NODE_IS_SMALL_INT(pn) (((pn) & 0x1) == MP_PARSE_NODE_SMALL_INT)
|
||||
#define MP_PARSE_NODE_IS_ID(pn) (((pn) & 0x1f) == MP_PARSE_NODE_ID)
|
||||
#define MP_PARSE_NODE_IS_TOKEN(pn) (((pn) & 0x1f) == MP_PARSE_NODE_TOKEN)
|
||||
#define MP_PARSE_NODE_IS_TOKEN_KIND(pn, k) ((pn) == (MP_PARSE_NODE_TOKEN | ((k) << 5)))
|
||||
|
||||
#define MP_PARSE_NODE_LEAF_KIND(pn) ((pn) & 0xf)
|
||||
#define MP_PARSE_NODE_LEAF_KIND(pn) ((pn) & 0x1f)
|
||||
// TODO should probably have int and uint versions of this macro
|
||||
#define MP_PARSE_NODE_LEAF_ARG(pn) (((machine_int_t)(pn)) >> 4)
|
||||
#define MP_PARSE_NODE_LEAF_ARG(pn) (((machine_uint_t)(pn)) >> 5)
|
||||
#define MP_PARSE_NODE_LEAF_SMALL_INT(pn) (((machine_int_t)(pn)) >> 1)
|
||||
#define MP_PARSE_NODE_STRUCT_KIND(pns) ((pns)->kind_num_nodes & 0xff)
|
||||
#define MP_PARSE_NODE_STRUCT_NUM_NODES(pns) ((pns)->kind_num_nodes >> 8)
|
||||
|
||||
|
||||
@ -4,7 +4,10 @@
|
||||
#define VCP_CHAR_CTRL_C (3)
|
||||
#define VCP_CHAR_CTRL_D (4)
|
||||
|
||||
void pyb_usb_dev_init(void);
|
||||
#define PYB_USB_DEV_VCP_MSC (0)
|
||||
#define PYB_USB_DEV_HID (1)
|
||||
|
||||
void pyb_usb_dev_init(int usb_dev_type);
|
||||
bool usb_vcp_is_enabled(void);
|
||||
bool usb_vcp_is_connected(void);
|
||||
void usb_vcp_set_interrupt_char(int c);
|
||||
|
||||
BIN
lib/libmp.a
BIN
lib/libmp.a
Binary file not shown.
Loading…
Reference in New Issue
Block a user