| 1 | /* |
| 2 | * This file is part of the MicroPython project, http://micropython.org/ |
| 3 | * |
| 4 | * The MIT License (MIT) |
| 5 | * |
| 6 | * Copyright (c) 2013-2015 Damien P. George |
| 7 | * |
| 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 9 | * of this software and associated documentation files (the "Software"), to deal |
| 10 | * in the Software without restriction, including without limitation the rights |
| 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 12 | * copies of the Software, and to permit persons to whom the Software is |
| 13 | * furnished to do so, subject to the following conditions: |
| 14 | * |
| 15 | * The above copyright notice and this permission notice shall be included in |
| 16 | * all copies or substantial portions of the Software. |
| 17 | * |
| 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 24 | * THE SOFTWARE. |
| 25 | */ |
| 26 | |
| 27 | // options to control how MicroPython is built |
| 28 | |
| 29 | #define MICROPY_ALLOC_PATH_MAX (PATH_MAX) |
| 30 | #define MICROPY_PERSISTENT_CODE_LOAD (0) |
| 31 | #define MICROPY_PERSISTENT_CODE_SAVE (1) |
| 32 | |
| 33 | #ifndef MICROPY_PERSISTENT_CODE_SAVE_FILE |
| 34 | #if defined(__i386__) || defined(__x86_64__) || defined(_WIN32) || defined(__unix__) || defined(__APPLE__) |
| 35 | #define MICROPY_PERSISTENT_CODE_SAVE_FILE (1) |
| 36 | #else |
| 37 | #define MICROPY_PERSISTENT_CODE_SAVE_FILE (0) |
| 38 | #endif |
| 39 | #endif |
| 40 | |
| 41 | #define MICROPY_EMIT_X64 (1) |
| 42 | #define MICROPY_EMIT_X86 (1) |
| 43 | #define MICROPY_EMIT_THUMB (1) |
| 44 | #define MICROPY_EMIT_INLINE_THUMB (1) |
| 45 | #define MICROPY_EMIT_INLINE_THUMB_ARMV7M (1) |
| 46 | #define MICROPY_EMIT_INLINE_THUMB_FLOAT (1) |
| 47 | #define MICROPY_EMIT_ARM (1) |
| 48 | #define MICROPY_EMIT_XTENSA (1) |
| 49 | #define MICROPY_EMIT_INLINE_XTENSA (1) |
| 50 | #define MICROPY_EMIT_XTENSAWIN (1) |
| 51 | |
| 52 | #define MICROPY_DYNAMIC_COMPILER (1) |
| 53 | #define MICROPY_COMP_CONST_FOLDING (1) |
| 54 | #define MICROPY_COMP_MODULE_CONST (1) |
| 55 | #define MICROPY_COMP_CONST (1) |
| 56 | #define MICROPY_COMP_DOUBLE_TUPLE_ASSIGN (1) |
| 57 | #define MICROPY_COMP_TRIPLE_TUPLE_ASSIGN (1) |
| 58 | #define MICROPY_COMP_RETURN_IF_EXPR (1) |
| 59 | |
| 60 | #define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE (0) |
| 61 | |
| 62 | #define MICROPY_READER_POSIX (1) |
| 63 | #define MICROPY_ENABLE_RUNTIME (0) |
| 64 | #define MICROPY_ENABLE_GC (1) |
| 65 | #define MICROPY_STACK_CHECK (1) |
| 66 | #define MICROPY_HELPER_LEXER_UNIX (1) |
| 67 | #define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ) |
| 68 | #define MICROPY_ENABLE_SOURCE_LINE (1) |
| 69 | #define MICROPY_ENABLE_DOC_STRING (0) |
| 70 | #define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_DETAILED) |
| 71 | #define MICROPY_WARNINGS (1) |
| 72 | |
| 73 | #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_DOUBLE) |
| 74 | #define MICROPY_CPYTHON_COMPAT (1) |
| 75 | #define MICROPY_USE_INTERNAL_PRINTF (0) |
| 76 | |
| 77 | #define MICROPY_PY_BUILTINS_STR_UNICODE (1) |
| 78 | |
| 79 | #if !(defined(MICROPY_GCREGS_SETJMP) || defined(__x86_64__) || defined(__i386__) || defined(__thumb2__) || defined(__thumb__) || defined(__arm__)) |
| 80 | // Fall back to setjmp() implementation for discovery of GC pointers in registers. |
| 81 | #define MICROPY_GCREGS_SETJMP (1) |
| 82 | #endif |
| 83 | |
| 84 | #define MICROPY_PY___FILE__ (0) |
| 85 | #define MICROPY_PY_ARRAY (0) |
| 86 | #define MICROPY_PY_ATTRTUPLE (0) |
| 87 | #define MICROPY_PY_COLLECTIONS (0) |
| 88 | #define MICROPY_PY_MATH (0) |
| 89 | #define MICROPY_PY_CMATH (0) |
| 90 | #define MICROPY_PY_GC (0) |
| 91 | #define MICROPY_PY_IO (0) |
| 92 | #define MICROPY_PY_SYS (0) |
| 93 | |
| 94 | // type definitions for the specific machine |
| 95 | |
| 96 | #ifdef __LP64__ |
| 97 | typedef long mp_int_t; // must be pointer size |
| 98 | typedef unsigned long mp_uint_t; // must be pointer size |
| 99 | #elif defined(__MINGW32__) && defined(_WIN64) |
| 100 | #include <stdint.h> |
| 101 | typedef __int64 mp_int_t; |
| 102 | typedef unsigned __int64 mp_uint_t; |
| 103 | #elif defined(_MSC_VER) && defined(_WIN64) |
| 104 | typedef __int64 mp_int_t; |
| 105 | typedef unsigned __int64 mp_uint_t; |
| 106 | #else |
| 107 | // These are definitions for machines where sizeof(int) == sizeof(void*), |
| 108 | // regardless for actual size. |
| 109 | typedef int mp_int_t; // must be pointer size |
| 110 | typedef unsigned int mp_uint_t; // must be pointer size |
| 111 | #endif |
| 112 | |
| 113 | // Cannot include <sys/types.h>, as it may lead to symbol name clashes |
| 114 | #if _FILE_OFFSET_BITS == 64 && !defined(__LP64__) |
| 115 | typedef long long mp_off_t; |
| 116 | #else |
| 117 | typedef long mp_off_t; |
| 118 | #endif |
| 119 | |
| 120 | #define MP_PLAT_PRINT_STRN(str, len) (void)0 |
| 121 | |
| 122 | // We need to provide a declaration/definition of alloca() |
| 123 | #ifdef __FreeBSD__ |
| 124 | #include <stdlib.h> |
| 125 | #elif defined(_WIN32) |
| 126 | #include <malloc.h> |
| 127 | #else |
| 128 | #include <alloca.h> |
| 129 | #endif |
| 130 | |
| 131 | #include <stdint.h> |
| 132 | |
| 133 | // MSVC specifics - see windows/mpconfigport.h for explanation |
| 134 | #ifdef _MSC_VER |
| 135 | |
| 136 | #define MP_ENDIANNESS_LITTLE (1) |
| 137 | #define NORETURN __declspec(noreturn) |
| 138 | #define MP_NOINLINE __declspec(noinline) |
| 139 | #define MP_LIKELY(x) (x) |
| 140 | #define MP_UNLIKELY(x) (x) |
| 141 | #define MICROPY_PORT_CONSTANTS { "dummy", 0 } |
| 142 | #ifdef _WIN64 |
| 143 | #define MP_SSIZE_MAX _I64_MAX |
| 144 | #else |
| 145 | #define MP_SSIZE_MAX _I32_MAX |
| 146 | #endif |
| 147 | #define MICROPY_MAKE_POINTER_CALLABLE(p) ((void *)(p)) // Avoid compiler warning about different const qualifiers |
| 148 | #define restrict |
| 149 | #define inline __inline |
| 150 | #define alignof(t) __alignof(t) |
| 151 | #undef MICROPY_ALLOC_PATH_MAX |
| 152 | #define MICROPY_ALLOC_PATH_MAX 260 |
| 153 | #define PATH_MAX MICROPY_ALLOC_PATH_MAX |
| 154 | #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) |
| 155 | #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) |
| 156 | #ifdef _WIN64 |
| 157 | #define SSIZE_MAX _I64_MAX |
| 158 | typedef __int64 ssize_t; |
| 159 | #else |
| 160 | #define SSIZE_MAX _I32_MAX |
| 161 | typedef int ssize_t; |
| 162 | #endif |
| 163 | typedef mp_off_t off_t; |
| 164 | |
| 165 | #endif |
| 166 | |