diff options
author | Damien George <damien.p.george@gmail.com> | 2017-08-14 12:19:09 +1000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2017-08-14 12:19:09 +1000 |
commit | bb254ba0ea89ce60dd6deab94991b2651c00dff3 (patch) | |
tree | fa2b66f3a1a9fd4bb90b2c83ce9954099b06fe01 /examples/embedding | |
parent | 5e76ea4affd0bd46e67b456496818803010a2d24 (diff) | |
parent | e4e4526954f8bcd88ceb21fe789963bfa710fa4f (diff) | |
download | micropython-bb254ba0ea89ce60dd6deab94991b2651c00dff3.tar.gz micropython-bb254ba0ea89ce60dd6deab94991b2651c00dff3.zip |
Merge tag 'v1.8.3' into parse-bytecode
Many small improvements and additions, with btree support in ESP8266 port
This release brings various improvements and additions to the core,
extended modules and the ESP8266 port, as well as enhancements to the docs.
There is now a "threshold" function in the gc module for the user to
configure the garbage collector to run earlier than usual, in order to help
reduce fragmentation of the heap. The btree module is now available in the
ESP8266 port, and there is improved WebREPL file transfer: get file is now
non-blocking (this change requires an update of the client software).
py core:
- nlrx64.S: prefix mp_thread_get_state with an underscore on Mac
- stream: implement 2- and 3-arg write() method as an extension to CPython
- gc: implement GC running by allocation threshold, user configurable
- fix nlrthumb.c when DEBUG=1 is defined
- obj: issue a warning when str and bytes objects are compared
- mpconfig.h: fix description for MICROPY_PY_STR_BYTES_CMP_WARN
- objstrunicode: str_index_to_ptr: should handle bytes too
- objstrunicode: str_index_to_ptr: implement positive indexing properly
- stream: implement generic flush() method, in terms of C-level ioctl
- objstringio: add MP_STREAM_FLUSH ioctl and flush() method
- objstringio: implement MP_STREAM_SEEK ioctl and add seek() method
- stream: add adapter methods with POSIX-compatible signatures
- mpconfig.h: add MICROPY_STREAMS_POSIX_API setting
- py.mk: extra switches to build "embedded" BerkeleyDB BTree lib
- mkrules.mk: allow to add more items for "clean" target using CLEAN_EXTRA
- objstr: make .partition()/.rpartition() methods configurable
- mpconfig.h: define MP_ALWAYSINLINE for reuse
extmod:
- modussl: rename to modussl_axtls.c, to allow impl using other SSL libs
- modussl_axtls: further changes to allow alternative SSL modules
- modussl_axtls: add dummy setblocking() method
- vfs_fat: implement rmdir() method (aliases to unlink)
- modussl_axtls: use mp_stream_close() method
- modwebrepl: use mp_stream_close() method
- modbtree: check __bt_open() return value for error
- modbtree: switch to accepting stream object instead of filename
- modbtree: implement __contains__ operation
- modwebrepl: factor out "GET" iteration to write_file_chunk()
- modwebrepl: make GET_FILE operation non-blocking
- modbtree: open(): add option kwargs
- modwebsocket: add readline method
- modwebsocket: make compatible with non-default object models
- modwebsocket: use mp_rom_map_elem_t and friends
- modwebrepl: add GET_VER operation to query MicroPython version
lib:
- axtls: upgrade to axTLS 1.5.4 + MicroPython patchset
- axtls: update, fixes esp8266 build
- utils/stdout_helpers: move from minimal/uart_extra.c for reuse
- embed/abort_: implementation of abort_() function raising uPy exception
- berkeley-db-1.xx: switch to "embedded" branch
- berkeley-db-1.xx: update, sets default page size to 4096
tests:
- add test for extended arguments to stream .write() method
- extmod/machine_pinbase: skip if machine.PinBase is not available
- bytes_compare: rework test for bytes <-> str comparison
- extmod/btree1: close database at the end of test
- unicode_subscr.py: detailed test for subscripting unicode strings
- run-tests: make "regex'ed .exp" facility available to device tests
- io/bytesio_ext: test for .seek()/.flush() on BytesIO
- extmod/btree1: tests against in-memory DB (using io.BytesIO)
- machine_mem.py: too non-portable, rework as an example for unix port
- machine1: revamp to work with unix port (which has "umachine")
- basics: bytes/str.partition/rpartition are now optional
mpy-cross:
- fix Makefile to handle gc-sections linker flags on OS X
- use binary file translation mode for creating mpy files on windows
- fix mingw and msys2 compilation
minimal port:
- disable MICROPY_GC_ALLOC_THRESHOLD
unix port:
- mpthreadport: adjust minimum thread stack, and stack limit check
- cache libaxtls.a in local build dir
- disable MICROPY_GC_ALLOC_THRESHOLD for minimal build
- enable MICROPY_PY_STR_BYTES_CMP_WARN
- mpconfigport.h: include stdio.h by default
- file: implement MP_STREAM_FLUSH ioctl
- file: ioctl(): check that file is open before operations
- file: fdfile_ioctl(): fix argument to check_fd_is_open()
- file: use generic stream flush() method
- enable websocket module
- moduselect: allow poll.register(), etc. accept fd-like objects
stmhal port:
- fix malloc when used with external libraries
- make SPI NSS pin definition optional
- fix I2C mappings for STM32F429DISC board
esp8266 port:
- select axTLS for SSL implementation, following recent refactor
- moduos: add rmdir() function
- cache Xtensa-built libaxtls.a in local build dir
- enable MICROPY_PY_STR_BYTES_CMP_WARN
- dupterm_task_init() should be called before running _boot.py, etc
- _boot.py: set GC alloc threshold to half of heap size
- _boot.py: decrease GC alloc threshold to quarter of heap size
- modpybuart: fix UART parity setting
- axtls_helpers: remove abort_(), now in lib/embed/
- mpconfigport.h: include sys/types.h for POSIX types definitions
- esp_mphal: implement libc's errno
- enable btree module
- eagle.rom.addr.v6.ld: add Enable_QMode symbol from SDK 2.0.0
- make APA102 driver inclusion configurable
- makeimg.py: store firmware size as last 4 bytes of padding area
- makeimg.py: append md5 hash to the generated binary
- modesp: add check_fw() function to check integrity of the firmware
- scripts/port_diag.py: include esp.check_fw() call
- flashbdev: reserve extra sysparam sector for SDK 2.0.0 compatibility
- scripts/inisetup: add commented-out call to esp.osdebug(None)
- modmachine: implement idle() function
- esp_mphal.h: add mp_hal_ticks_cpu() for reuse
- modutime: actually implement ticks_cpu()
- modmachine: implement dummy sleep() function
- tutorial/intro: reword para abou -fm dio switch
- modules/flashbdev: start filesystem at 0x90000
- esp8266.ld: increase firmware image size to 0x90000 (576K)
docs:
- add DHT to ESP8266 Quick Ref and Tutorial
- fix some spelling mistakes
- array: document array module
- library/index: include array module in ToC
- esp8266/intro: rename to "Getting started" from "Introduction"
- esp8266/intro: add troubleshooting section
- esp8266/quickref: link to installation instructions
- esp8266/tutorial/intro: add anchor for link from quickeref
- esp8266/intro: focus on hazards of unearthed power wrt electronics
- uio: mention seek()/flush() support for io.BytesIO
misc:
- logo/1bit-logo A black & white version of the logo
examples:
- http_server*: update for buffered-like streams (read line by line)
- embedding: example for embedding MicroPython in an app
- embedding: add README
- http_client*: be sure to close socket
- network: split recv- and read-based HTTP servers
qemu-arm:
- enable gcc LTO option for nlrthumb.c
Diffstat (limited to 'examples/embedding')
-rw-r--r-- | examples/embedding/Makefile | 8 | ||||
-rw-r--r-- | examples/embedding/Makefile.upylib | 200 | ||||
-rw-r--r-- | examples/embedding/README | 66 | ||||
-rw-r--r-- | examples/embedding/hello-embed.c | 74 | ||||
l--------- | examples/embedding/mpconfigport.h | 1 | ||||
-rw-r--r-- | examples/embedding/mpconfigport_minimal.h | 138 |
6 files changed, 487 insertions, 0 deletions
diff --git a/examples/embedding/Makefile b/examples/embedding/Makefile new file mode 100644 index 0000000000..99f239a7c5 --- /dev/null +++ b/examples/embedding/Makefile @@ -0,0 +1,8 @@ +MPTOP = ../.. +CFLAGS = -std=c99 -I. -I$(MPTOP) -DNO_QSTR +LDFLAGS = -L. + +hello-embed: hello-embed.o -lmicropython + +-lmicropython: + $(MAKE) -f $(MPTOP)/examples/embedding/Makefile.upylib MPTOP=$(MPTOP) diff --git a/examples/embedding/Makefile.upylib b/examples/embedding/Makefile.upylib new file mode 100644 index 0000000000..d8dbade3fe --- /dev/null +++ b/examples/embedding/Makefile.upylib @@ -0,0 +1,200 @@ +MPTOP = ../.. +-include mpconfigport.mk +include $(MPTOP)/py/mkenv.mk + +all: lib + +# OS name, for simple autoconfig +UNAME_S := $(shell uname -s) + +# include py core make definitions +include $(MPTOP)/py/py.mk + +INC += -I. +INC += -I.. +INC += -I$(MPTOP) +INC += -I$(MPTOP)/unix +#INC += -I../lib/timeutils +INC += -I$(BUILD) + +# compiler settings +CWARN = -Wall -Werror +CWARN += -Wpointer-arith -Wuninitialized +CFLAGS = $(INC) $(CWARN) -ansi -std=gnu99 -DUNIX $(CFLAGS_MOD) $(COPT) $(CFLAGS_EXTRA) + +# Debugging/Optimization +ifdef DEBUG +CFLAGS += -g +COPT = -O0 +else +COPT = -Os #-DNDEBUG +# _FORTIFY_SOURCE is a feature in gcc/glibc which is intended to provide extra +# security for detecting buffer overflows. Some distros (Ubuntu at the very least) +# have it enabled by default. +# +# gcc already optimizes some printf calls to call puts and/or putchar. When +# _FORTIFY_SOURCE is enabled and compiling with -O1 or greater, then some +# printf calls will also be optimized to call __printf_chk (in glibc). Any +# printfs which get redirected to __printf_chk are then no longer synchronized +# with printfs that go through mp_printf. +# +# In MicroPython, we don't want to use the runtime library's printf but rather +# go through mp_printf, so that stdout is properly tied into streams, etc. +# This means that we either need to turn off _FORTIFY_SOURCE or provide our +# own implementation of __printf_chk. We've chosen to turn off _FORTIFY_SOURCE. +# It should also be noted that the use of printf in MicroPython is typically +# quite limited anyways (primarily for debug and some error reporting, etc +# in the unix version). +# +# Information about _FORTIFY_SOURCE seems to be rather scarce. The best I could +# find was this: https://securityblog.redhat.com/2014/03/26/fortify-and-you/ +# Original patchset was introduced by +# https://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html . +# +# Turning off _FORTIFY_SOURCE is only required when compiling with -O1 or greater +CFLAGS += -U _FORTIFY_SOURCE +endif + +# On OSX, 'gcc' is a symlink to clang unless a real gcc is installed. +# The unix port of micropython on OSX must be compiled with clang, +# while cross-compile ports require gcc, so we test here for OSX and +# if necessary override the value of 'CC' set in py/mkenv.mk +ifeq ($(UNAME_S),Darwin) +CC = clang +# Use clang syntax for map file +LDFLAGS_ARCH = -Wl,-map,$@.map +else +# Use gcc syntax for map file +LDFLAGS_ARCH = -Wl,-Map=$@.map,--cref +endif +LDFLAGS = $(LDFLAGS_MOD) $(LDFLAGS_ARCH) -lm $(LDFLAGS_EXTRA) + +ifeq ($(MICROPY_FORCE_32BIT),1) +# Note: you may need to install i386 versions of dependency packages, +# starting with linux-libc-dev:i386 +ifeq ($(MICROPY_PY_FFI),1) +ifeq ($(UNAME_S),Linux) +CFLAGS_MOD += -I/usr/include/i686-linux-gnu +endif +endif +endif + +ifeq ($(MICROPY_USE_READLINE),1) +INC += -I../lib/mp-readline +CFLAGS_MOD += -DMICROPY_USE_READLINE=1 +LIB_SRC_C_EXTRA += mp-readline/readline.c +endif +ifeq ($(MICROPY_USE_READLINE),2) +CFLAGS_MOD += -DMICROPY_USE_READLINE=2 +LDFLAGS_MOD += -lreadline +# the following is needed for BSD +#LDFLAGS_MOD += -ltermcap +endif +ifeq ($(MICROPY_PY_TIME),1) +CFLAGS_MOD += -DMICROPY_PY_TIME=1 +SRC_MOD += modtime.c +endif +ifeq ($(MICROPY_PY_TERMIOS),1) +CFLAGS_MOD += -DMICROPY_PY_TERMIOS=1 +SRC_MOD += modtermios.c +endif +ifeq ($(MICROPY_PY_SOCKET),1) +CFLAGS_MOD += -DMICROPY_PY_SOCKET=1 +SRC_MOD += modsocket.c +endif + +ifeq ($(MICROPY_PY_FFI),1) + +ifeq ($(MICROPY_STANDALONE),1) +LIBFFI_CFLAGS_MOD := -I$(shell ls -1d ../lib/libffi/build_dir/out/lib/libffi-*/include) + ifeq ($(MICROPY_FORCE_32BIT),1) + LIBFFI_LDFLAGS_MOD = ../lib/libffi/build_dir/out/lib32/libffi.a + else + LIBFFI_LDFLAGS_MOD = ../lib/libffi/build_dir/out/lib/libffi.a + endif +else +LIBFFI_CFLAGS_MOD := $(shell pkg-config --cflags libffi) +LIBFFI_LDFLAGS_MOD := $(shell pkg-config --libs libffi) +endif + +ifeq ($(UNAME_S),Linux) +LIBFFI_LDFLAGS_MOD += -ldl +endif + +CFLAGS_MOD += $(LIBFFI_CFLAGS_MOD) -DMICROPY_PY_FFI=1 +LDFLAGS_MOD += $(LIBFFI_LDFLAGS_MOD) +SRC_MOD += modffi.c +endif + +MAIN_C = main.c + +# source files +SRC_C = $(addprefix $(MPTOP)/unix/,\ + $(MAIN_C) \ + gccollect.c \ + unix_mphal.c \ + input.c \ + file.c \ + modmachine.c \ + modos.c \ + moduselect.c \ + alloc.c \ + coverage.c \ + fatfs_port.c \ + $(SRC_MOD) \ + ) + +LIB_SRC_C = $(addprefix lib/,\ + $(LIB_SRC_C_EXTRA) \ + utils/printf.c \ + timeutils/timeutils.c \ + ) + +ifeq ($(MICROPY_FATFS),1) +LIB_SRC_C += $(addprefix lib/,\ + fatfs/ff.c \ + fatfs/option/ccsbcs.c \ + ) +endif + +OBJ = $(PY_O) +OBJ += $(addprefix $(BUILD)/, $(SRC_C:.c=.o)) +OBJ += $(addprefix $(BUILD)/, $(LIB_SRC_C:.c=.o)) +OBJ += $(addprefix $(BUILD)/, $(STMHAL_SRC_C:.c=.o)) + +# List of sources for qstr extraction +SRC_QSTR += $(SRC_C) $(LIB_SRC_C) +# Append any auto-generated sources that are needed by sources listed in +# SRC_QSTR +SRC_QSTR_AUTO_DEPS += + +include $(MPTOP)/py/mkrules.mk + +# Value of configure's --host= option (required for cross-compilation). +# Deduce it from CROSS_COMPILE by default, but can be overriden. +ifneq ($(CROSS_COMPILE),) +CROSS_COMPILE_HOST = --host=$(patsubst %-,%,$(CROSS_COMPILE)) +else +CROSS_COMPILE_HOST = +endif + +deplibs: libffi axtls + +# install-exec-recursive & install-data-am targets are used to avoid building +# docs and depending on makeinfo +libffi: + cd ../lib/libffi; git clean -d -x -f + cd ../lib/libffi; ./autogen.sh + mkdir -p ../lib/libffi/build_dir; cd ../lib/libffi/build_dir; \ + ../configure $(CROSS_COMPILE_HOST) --prefix=$$PWD/out CC="$(CC)" CXX="$(CXX)" LD="$(LD)"; \ + make install-exec-recursive; make -C include install-data-am + +axtls: ../lib/axtls/README + cd ../lib/axtls; cp config/upyconfig config/.config + cd ../lib/axtls; make oldconfig -B + cd ../lib/axtls; make clean + cd ../lib/axtls; make all CC="$(CC)" LD="$(LD)" + +../lib/axtls/README: + @echo "You cloned without --recursive, fetching submodules for you." + (cd ..; git submodule update --init --recursive) diff --git a/examples/embedding/README b/examples/embedding/README new file mode 100644 index 0000000000..0475e8739a --- /dev/null +++ b/examples/embedding/README @@ -0,0 +1,66 @@ +Example of embedding MicroPython in a standlone C application +============================================================= + +This directory contains a (very simple!) example of how to embed a MicroPython +in an existing C application. + +A C application is represented by the file hello-embed.c. It executes a simple +Python statement which prints to the standard output. + + +Building the example +-------------------- + +Build the example is as simple as running: + + make + +It's worth to trace what's happening behind the scenes though: + +1. As a first step, a MicroPython library is built. This is handled by a +seperate makefile, Makefile.upylib. It is more or less complex, but the +good news is that you won't need to change anything in it, just use it +as is, the main Makefile shows how. What may need editing though is +MicroPython configuration file. MicroPython is highly configurable, so +you would need to build a library suiting your application well, while +not bloating its size. Check the options in the file "mpconfigport.h". +Included is a copy of "minimal" Unix port, which should be good start +for minimal embedding. For list of all available options, see py/mpconfig.h. + +2. Once the library is built, your application is compiled and linked with +the MicroPython library produced in the previous step. The main Makefile +is very simple and shows that changes you would need to do to your +application's Makefile (or other build configuration) are also simple: + +a) You would need to use C99 standard (you're using 15+ years old standard +already, not a 25+ years old one, right?). + +b) You need to provide path to MicroPython's top-level dir, for includes. + +c) You need to include -DNO_QSTR compile-time flag. + +d) Otherwise, just link with micropython library produced in step 1. + + +Out of tree build +----------------- + +This example set up to work out of the box, being part of the MicroPython +tree. Your application of course will be outside of its tree, but the +only thing you need to do is to pass MPTOP variable pointing to +MicroPython directory to both Makefiles (in this example, the main Makefile +automatically pass it to Makefile.upylib; in your own Makefile, don't forget +to use suitable value). + +A practical way to embed MicroPython in your application is to include it +as a git submodule. Suppose you included it as libs/micropython. Then in +your main Makefile you would have something like: + +~~~ +MPTOP = libs/micropython + +my_app: $(MY_OBJS) -lmicropython + +-lmicropython: + $(MAKE) -f $(MPTOP)/examples/embedding/Makefile.upylib MPTOP=$(MPTOP) +~~~ diff --git a/examples/embedding/hello-embed.c b/examples/embedding/hello-embed.c new file mode 100644 index 0000000000..1949305184 --- /dev/null +++ b/examples/embedding/hello-embed.c @@ -0,0 +1,74 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 Paul Sokolovsky + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include <string.h> +#include <stdio.h> +#include <stdlib.h> + +#include "py/compile.h" +#include "py/runtime.h" +#include "py/gc.h" +#include "py/stackctrl.h" + +static char heap[16384]; + +mp_obj_t execute_from_lexer(mp_lexer_t *lex) { + nlr_buf_t nlr; + if (nlr_push(&nlr) == 0) { + mp_parse_tree_t pt = mp_parse(lex, MP_PARSE_FILE_INPUT); + mp_obj_t module_fun = mp_compile(&pt, lex->source_name, MP_EMIT_OPT_NONE, false); + mp_call_function_0(module_fun); + nlr_pop(); + return 0; + } else { + // uncaught exception + return (mp_obj_t)nlr.ret_val; + } +} + +int main() { + // Initialized stack limit + mp_stack_set_limit(40000 * (BYTES_PER_WORD / 4)); + // Initialize heap + gc_init(heap, heap + sizeof(heap)); + // Initialize interpreter + mp_init(); + + const char str[] = "print('Hello world of easy embedding!')"; + mp_lexer_t *lex = mp_lexer_new_from_str_len(0/*MP_QSTR_*/, str, strlen(str), false); + if (execute_from_lexer(lex)) { + printf("Error\n"); + } +} + +uint mp_import_stat(const char *path) { + return MP_IMPORT_STAT_NO_EXIST; +} + +void nlr_jump_fail(void *val) { + printf("FATAL: uncaught NLR %p\n", val); + exit(1); +} diff --git a/examples/embedding/mpconfigport.h b/examples/embedding/mpconfigport.h new file mode 120000 index 0000000000..142e5d6f43 --- /dev/null +++ b/examples/embedding/mpconfigport.h @@ -0,0 +1 @@ +mpconfigport_minimal.h
\ No newline at end of file diff --git a/examples/embedding/mpconfigport_minimal.h b/examples/embedding/mpconfigport_minimal.h new file mode 100644 index 0000000000..9f080ab0e1 --- /dev/null +++ b/examples/embedding/mpconfigport_minimal.h @@ -0,0 +1,138 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2015 Damien P. George + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// options to control how Micro Python is built + +#define MICROPY_ALLOC_PATH_MAX (PATH_MAX) +#define MICROPY_ENABLE_GC (1) +#define MICROPY_ENABLE_FINALISER (0) +#define MICROPY_STACK_CHECK (0) +#define MICROPY_COMP_CONST (0) +#define MICROPY_MEM_STATS (0) +#define MICROPY_DEBUG_PRINTERS (0) +#define MICROPY_HELPER_REPL (1) +#define MICROPY_HELPER_LEXER_UNIX (1) +#define MICROPY_ENABLE_SOURCE_LINE (0) +#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_TERSE) +#define MICROPY_WARNINGS (0) +#define MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF (0) +#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_NONE) +#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_NONE) +#define MICROPY_STREAMS_NON_BLOCK (0) +#define MICROPY_OPT_COMPUTED_GOTO (0) +#define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE (0) +#define MICROPY_CAN_OVERRIDE_BUILTINS (0) +#define MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG (0) +#define MICROPY_CPYTHON_COMPAT (0) +#define MICROPY_PY_BUILTINS_BYTEARRAY (0) +#define MICROPY_PY_BUILTINS_MEMORYVIEW (0) +#define MICROPY_PY_BUILTINS_COMPILE (0) +#define MICROPY_PY_BUILTINS_ENUMERATE (0) +#define MICROPY_PY_BUILTINS_FILTER (0) +#define MICROPY_PY_BUILTINS_FROZENSET (0) +#define MICROPY_PY_BUILTINS_REVERSED (0) +#define MICROPY_PY_BUILTINS_SET (0) +#define MICROPY_PY_BUILTINS_SLICE (0) +#define MICROPY_PY_BUILTINS_STR_UNICODE (0) +#define MICROPY_PY_BUILTINS_PROPERTY (0) +#define MICROPY_PY_BUILTINS_MIN_MAX (0) +#define MICROPY_PY___FILE__ (0) +#define MICROPY_PY_MICROPYTHON_MEM_INFO (0) +#define MICROPY_PY_GC (0) +#define MICROPY_PY_GC_COLLECT_RETVAL (0) +#define MICROPY_PY_ARRAY (0) +#define MICROPY_PY_COLLECTIONS (0) +#define MICROPY_PY_MATH (0) +#define MICROPY_PY_CMATH (0) +#define MICROPY_PY_IO (0) +#define MICROPY_PY_IO_FILEIO (0) +#define MICROPY_PY_STRUCT (0) +#define MICROPY_PY_SYS (1) +#define MICROPY_PY_SYS_EXIT (0) +#define MICROPY_PY_SYS_PLATFORM "linux" +#define MICROPY_PY_SYS_MAXSIZE (0) +#define MICROPY_PY_SYS_STDFILES (0) +#define MICROPY_PY_CMATH (0) +#define MICROPY_PY_UCTYPES (0) +#define MICROPY_PY_UZLIB (0) +#define MICROPY_PY_UJSON (0) +#define MICROPY_PY_URE (0) +#define MICROPY_PY_UHEAPQ (0) +#define MICROPY_PY_UHASHLIB (0) +#define MICROPY_PY_UBINASCII (0) + +extern const struct _mp_obj_module_t mp_module_os; + +#define MICROPY_PORT_BUILTIN_MODULES \ + { MP_OBJ_NEW_QSTR(MP_QSTR_uos), (mp_obj_t)&mp_module_os }, \ + +#define MICROPY_PORT_ROOT_POINTERS \ + mp_obj_t keyboard_interrupt_obj; + +////////////////////////////////////////// +// Do not change anything beyond this line +////////////////////////////////////////// + +// Define to 1 to use undertested inefficient GC helper implementation +// (if more efficient arch-specific one is not available). +#ifndef MICROPY_GCREGS_SETJMP + #ifdef __mips__ + #define MICROPY_GCREGS_SETJMP (1) + #else + #define MICROPY_GCREGS_SETJMP (0) + #endif +#endif + +// type definitions for the specific machine + +#ifdef __LP64__ +typedef long mp_int_t; // must be pointer size +typedef unsigned long mp_uint_t; // must be pointer size +#else +// These are definitions for machines where sizeof(int) == sizeof(void*), +// regardless for actual size. +typedef int mp_int_t; // must be pointer size +typedef unsigned int mp_uint_t; // must be pointer size +#endif + +#define BYTES_PER_WORD sizeof(mp_int_t) + +// Cannot include <sys/types.h>, as it may lead to symbol name clashes +#if _FILE_OFFSET_BITS == 64 && !defined(__LP64__) +typedef long long mp_off_t; +#else +typedef long mp_off_t; +#endif + +typedef void *machine_ptr_t; // must be of pointer size +typedef const void *machine_const_ptr_t; // must be of pointer size + +// We need to provide a declaration/definition of alloca() +#ifdef __FreeBSD__ +#include <stdlib.h> +#else +#include <alloca.h> +#endif |