mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 08:47:28 +01:00
[python] upgrade to micropython 1.12
This commit is contained in:
committed by
LeaNumworks
parent
010fb1894f
commit
7df8c2935a
@@ -31,7 +31,63 @@
|
||||
#include "py/emitglue.h"
|
||||
|
||||
// The current version of .mpy files
|
||||
#define MPY_VERSION 4
|
||||
#define MPY_VERSION 5
|
||||
|
||||
// Macros to encode/decode flags to/from the feature byte
|
||||
#define MPY_FEATURE_ENCODE_FLAGS(flags) (flags)
|
||||
#define MPY_FEATURE_DECODE_FLAGS(feat) ((feat) & 3)
|
||||
|
||||
// Macros to encode/decode native architecture to/from the feature byte
|
||||
#define MPY_FEATURE_ENCODE_ARCH(arch) ((arch) << 2)
|
||||
#define MPY_FEATURE_DECODE_ARCH(feat) ((feat) >> 2)
|
||||
|
||||
// The feature flag bits encode the compile-time config options that
|
||||
// affect the generate bytecode.
|
||||
#define MPY_FEATURE_FLAGS ( \
|
||||
((MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) << 0) \
|
||||
| ((MICROPY_PY_BUILTINS_STR_UNICODE) << 1) \
|
||||
)
|
||||
// This is a version of the flags that can be configured at runtime.
|
||||
#define MPY_FEATURE_FLAGS_DYNAMIC ( \
|
||||
((MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE_DYNAMIC) << 0) \
|
||||
| ((MICROPY_PY_BUILTINS_STR_UNICODE_DYNAMIC) << 1) \
|
||||
)
|
||||
|
||||
// Define the host architecture
|
||||
#if MICROPY_EMIT_X86
|
||||
#define MPY_FEATURE_ARCH (MP_NATIVE_ARCH_X86)
|
||||
#elif MICROPY_EMIT_X64
|
||||
#define MPY_FEATURE_ARCH (MP_NATIVE_ARCH_X64)
|
||||
#elif MICROPY_EMIT_THUMB
|
||||
#if defined(__thumb2__)
|
||||
#if defined(__ARM_FP) && (__ARM_FP & 8) == 8
|
||||
#define MPY_FEATURE_ARCH (MP_NATIVE_ARCH_ARMV7EMDP)
|
||||
#elif defined(__ARM_FP) && (__ARM_FP & 4) == 4
|
||||
#define MPY_FEATURE_ARCH (MP_NATIVE_ARCH_ARMV7EMSP)
|
||||
#else
|
||||
#define MPY_FEATURE_ARCH (MP_NATIVE_ARCH_ARMV7EM)
|
||||
#endif
|
||||
#else
|
||||
#define MPY_FEATURE_ARCH (MP_NATIVE_ARCH_ARMV7M)
|
||||
#endif
|
||||
#define MPY_FEATURE_ARCH_TEST(x) (MP_NATIVE_ARCH_ARMV6M <= (x) && (x) <= MPY_FEATURE_ARCH)
|
||||
#elif MICROPY_EMIT_ARM
|
||||
#define MPY_FEATURE_ARCH (MP_NATIVE_ARCH_ARMV6)
|
||||
#elif MICROPY_EMIT_XTENSA
|
||||
#define MPY_FEATURE_ARCH (MP_NATIVE_ARCH_XTENSA)
|
||||
#elif MICROPY_EMIT_XTENSAWIN
|
||||
#define MPY_FEATURE_ARCH (MP_NATIVE_ARCH_XTENSAWIN)
|
||||
#else
|
||||
#define MPY_FEATURE_ARCH (MP_NATIVE_ARCH_NONE)
|
||||
#endif
|
||||
|
||||
#ifndef MPY_FEATURE_ARCH_TEST
|
||||
#define MPY_FEATURE_ARCH_TEST(x) ((x) == MPY_FEATURE_ARCH)
|
||||
#endif
|
||||
|
||||
// 16-bit little-endian integer with the second and third bytes of supported .mpy files
|
||||
#define MPY_FILE_HEADER_INT (MPY_VERSION \
|
||||
| (MPY_FEATURE_ENCODE_FLAGS(MPY_FEATURE_FLAGS) | MPY_FEATURE_ENCODE_ARCH(MPY_FEATURE_ARCH)) << 8)
|
||||
|
||||
enum {
|
||||
MP_NATIVE_ARCH_NONE = 0,
|
||||
@@ -44,6 +100,7 @@ enum {
|
||||
MP_NATIVE_ARCH_ARMV7EMSP,
|
||||
MP_NATIVE_ARCH_ARMV7EMDP,
|
||||
MP_NATIVE_ARCH_XTENSA,
|
||||
MP_NATIVE_ARCH_XTENSAWIN,
|
||||
};
|
||||
|
||||
mp_raw_code_t *mp_raw_code_load(mp_reader_t *reader);
|
||||
@@ -53,4 +110,6 @@ mp_raw_code_t *mp_raw_code_load_file(const char *filename);
|
||||
void mp_raw_code_save(mp_raw_code_t *rc, mp_print_t *print);
|
||||
void mp_raw_code_save_file(mp_raw_code_t *rc, const char *filename);
|
||||
|
||||
void mp_native_relocate(void *reloc, uint8_t *text, uintptr_t reloc_text);
|
||||
|
||||
#endif // MICROPY_INCLUDED_PY_PERSISTENTCODE_H
|
||||
|
||||
Reference in New Issue
Block a user