mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Update libmp
This commit is contained in:
parent
c1588d7175
commit
16b91e4a52
@ -1,7 +1,5 @@
|
||||
#ifndef __LIBMP_H__
|
||||
#define __LIBMP_H__
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "misc.h"
|
||||
#include "mpconfig.h"
|
||||
#include "qstr.h"
|
||||
|
||||
@ -63,8 +63,8 @@ bool unichar_isxdigit(unichar c);
|
||||
/** variable string *********************************************/
|
||||
|
||||
typedef struct _vstr_t {
|
||||
int alloc;
|
||||
int len;
|
||||
uint alloc;
|
||||
uint len;
|
||||
char *buf;
|
||||
bool had_error : 1;
|
||||
bool fixed_buf : 1;
|
||||
@ -94,7 +94,11 @@ void vstr_add_str(vstr_t *vstr, const char *str);
|
||||
void vstr_add_strn(vstr_t *vstr, const char *str, int len);
|
||||
//void vstr_add_le16(vstr_t *vstr, unsigned short v);
|
||||
//void vstr_add_le32(vstr_t *vstr, unsigned int v);
|
||||
void vstr_cut_tail(vstr_t *vstr, int len);
|
||||
void vstr_ins_byte(vstr_t *vstr, uint byte_pos, byte b);
|
||||
void vstr_ins_char(vstr_t *vstr, uint char_pos, unichar chr);
|
||||
void vstr_cut_head_bytes(vstr_t *vstr, uint bytes_to_cut);
|
||||
void vstr_cut_tail_bytes(vstr_t *vstr, uint bytes_to_cut);
|
||||
void vstr_cut_out_bytes(vstr_t *vstr, uint byte_pos, uint bytes_to_cut);
|
||||
void vstr_printf(vstr_t *vstr, const char *fmt, ...);
|
||||
|
||||
/** non-dynamic size-bounded variable buffer/string *************/
|
||||
|
||||
@ -84,8 +84,24 @@ typedef long long mp_longint_impl_t;
|
||||
#define MICROPY_ENABLE_SOURCE_LINE (0)
|
||||
#endif
|
||||
|
||||
// Whether to support float and complex types
|
||||
#ifndef MICROPY_ENABLE_FLOAT
|
||||
// Float and complex implementation
|
||||
#define MICROPY_FLOAT_IMPL_NONE (0)
|
||||
#define MICROPY_FLOAT_IMPL_FLOAT (1)
|
||||
#define MICROPY_FLOAT_IMPL_DOUBLE (2)
|
||||
|
||||
#ifndef MICROPY_FLOAT_IMPL
|
||||
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_NONE)
|
||||
#endif
|
||||
|
||||
#if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT
|
||||
#define MICROPY_ENABLE_FLOAT (1)
|
||||
#define MICROPY_FLOAT_C_FUN(fun) fun##f
|
||||
typedef float mp_float_t;
|
||||
#elif MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE
|
||||
#define MICROPY_ENABLE_FLOAT (1)
|
||||
#define MICROPY_FLOAT_C_FUN(fun) fun
|
||||
typedef double mp_float_t;
|
||||
#else
|
||||
#define MICROPY_ENABLE_FLOAT (0)
|
||||
#endif
|
||||
|
||||
|
||||
@ -6,8 +6,8 @@
|
||||
#define MICROPY_EMIT_INLINE_THUMB (1)
|
||||
#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_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT)
|
||||
#define MICROPY_PATH_MAX (128)
|
||||
/* Enable FatFS LFNs
|
||||
0: Disable LFN feature.
|
||||
@ -15,7 +15,7 @@
|
||||
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_ENABLE_LFN (2)
|
||||
#define MICROPY_LFN_CODE_PAGE (437) /* 1=SFN/ANSI 437=LFN/U.S.(OEM) */
|
||||
|
||||
// type definitions for the specific machine
|
||||
@ -29,9 +29,6 @@ typedef int32_t machine_int_t; // must be pointer size
|
||||
typedef uint32_t machine_uint_t; // must be pointer size
|
||||
typedef void *machine_ptr_t; // must be of pointer size
|
||||
typedef const void *machine_const_ptr_t; // must be of pointer size
|
||||
typedef float machine_float_t;
|
||||
|
||||
machine_float_t machine_sqrt(machine_float_t x);
|
||||
|
||||
// There is no classical C heap in bare-metal ports, only Python
|
||||
// garbage-collected heap. For completeness, emulate C heap via
|
||||
|
||||
@ -9,12 +9,6 @@ typedef machine_const_ptr_t mp_const_obj_t;
|
||||
|
||||
typedef machine_int_t mp_small_int_t;
|
||||
|
||||
// The machine floating-point type used for float and complex numbers
|
||||
|
||||
#if MICROPY_ENABLE_FLOAT
|
||||
typedef machine_float_t mp_float_t;
|
||||
#endif
|
||||
|
||||
// Anything that wants to be a Micro Python object must have
|
||||
// mp_obj_base_t as its first member (except NULL and small ints)
|
||||
|
||||
@ -35,6 +29,8 @@ typedef struct _mp_obj_base_t mp_obj_base_t;
|
||||
// - xxxx...xx00: a pointer to an mp_obj_base_t
|
||||
|
||||
// In SMALL_INT, next-to-highest bits is used as sign, so both must match for value in range
|
||||
#define MP_SMALL_INT_MIN ((mp_small_int_t)(((machine_int_t)WORD_MSBIT_HIGH) >> 1))
|
||||
#define MP_SMALL_INT_MAX ((mp_small_int_t)(~(MP_SMALL_INT_MIN)))
|
||||
#define MP_OBJ_FITS_SMALL_INT(n) ((((n) ^ ((n) << 1)) & WORD_MSBIT_HIGH) == 0)
|
||||
#define MP_OBJ_IS_SMALL_INT(o) ((((mp_small_int_t)(o)) & 1) != 0)
|
||||
#define MP_OBJ_IS_QSTR(o) ((((mp_small_int_t)(o)) & 3) == 2)
|
||||
@ -224,9 +220,7 @@ 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_int_from_ll(long long val); // this must return a multi-precision integer object (or raise an overflow exception)
|
||||
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
|
||||
@ -273,7 +267,7 @@ void mp_obj_get_complex(mp_obj_t self_in, mp_float_t *real, mp_float_t *imag);
|
||||
#endif
|
||||
//qstr mp_obj_get_qstr(mp_obj_t arg);
|
||||
mp_obj_t *mp_obj_get_array_fixed_n(mp_obj_t o, machine_int_t n);
|
||||
uint mp_get_index(const mp_obj_type_t *type, machine_uint_t len, mp_obj_t index);
|
||||
uint mp_get_index(const mp_obj_type_t *type, machine_uint_t len, mp_obj_t index, bool is_slice);
|
||||
mp_obj_t mp_obj_len_maybe(mp_obj_t o_in); /* may return NULL */
|
||||
|
||||
// none
|
||||
@ -318,12 +312,16 @@ extern const mp_obj_type_t bytes_type;
|
||||
|
||||
#if MICROPY_ENABLE_FLOAT
|
||||
// float
|
||||
extern const mp_obj_type_t float_type;
|
||||
typedef struct _mp_obj_float_t {
|
||||
mp_obj_base_t base;
|
||||
mp_float_t value;
|
||||
} mp_obj_float_t;
|
||||
extern const mp_obj_type_t mp_type_float;
|
||||
mp_float_t mp_obj_float_get(mp_obj_t self_in);
|
||||
mp_obj_t mp_obj_float_binary_op(int op, mp_float_t lhs_val, mp_obj_t rhs);
|
||||
|
||||
// complex
|
||||
extern const mp_obj_type_t complex_type;
|
||||
extern const mp_obj_type_t mp_type_complex;
|
||||
void mp_obj_complex_get(mp_obj_t self_in, mp_float_t *real, mp_float_t *imag);
|
||||
mp_obj_t mp_obj_complex_binary_op(int op, mp_float_t lhs_real, mp_float_t lhs_imag, mp_obj_t rhs_in);
|
||||
#endif
|
||||
@ -398,7 +396,12 @@ extern const mp_obj_type_t super_type;
|
||||
extern const mp_obj_type_t gen_instance_type;
|
||||
|
||||
// module
|
||||
extern const mp_obj_type_t module_type;
|
||||
typedef struct _mp_obj_module_t {
|
||||
mp_obj_base_t base;
|
||||
qstr name;
|
||||
struct _mp_map_t *globals;
|
||||
} mp_obj_module_t;
|
||||
extern const mp_obj_type_t mp_type_module;
|
||||
mp_obj_t mp_obj_new_module(qstr module_name);
|
||||
mp_obj_t mp_obj_module_get(qstr module_name);
|
||||
struct _mp_map_t *mp_obj_module_get_globals(mp_obj_t self_in);
|
||||
|
||||
@ -2,4 +2,4 @@ void pyexec_raw_repl(void);
|
||||
void pyexec_repl(void);
|
||||
bool pyexec_file(const char *filename);
|
||||
|
||||
mp_obj_t pyb_set_repl_info(mp_obj_t o_value);
|
||||
MP_DECLARE_CONST_FUN_OBJ(pyb_set_repl_info_obj);
|
||||
|
||||
@ -16,3 +16,6 @@ char *strstr(const char *haystack, const char *needle);
|
||||
|
||||
int printf(const char *fmt, ...);
|
||||
int snprintf(char *str, size_t size, const char *fmt, ...);
|
||||
#ifndef NULL
|
||||
#define NULL (0)
|
||||
#endif
|
||||
|
||||
BIN
lib/libmp.a
BIN
lib/libmp.a
Binary file not shown.
Loading…
Reference in New Issue
Block a user