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 #ifndef __EMSCRIPTEN__
66 #define MICROPY_STACK_CHECK         (1)
67 #endif
68 #define MICROPY_HELPER_LEXER_UNIX   (1)
69 #define MICROPY_LONGINT_IMPL        (MICROPY_LONGINT_IMPL_MPZ)
70 #define MICROPY_ENABLE_SOURCE_LINE  (1)
71 #define MICROPY_ENABLE_DOC_STRING   (0)
72 #define MICROPY_ERROR_REPORTING     (MICROPY_ERROR_REPORTING_DETAILED)
73 #define MICROPY_WARNINGS            (1)
74 
75 #define MICROPY_FLOAT_IMPL          (MICROPY_FLOAT_IMPL_DOUBLE)
76 #define MICROPY_CPYTHON_COMPAT      (1)
77 #define MICROPY_USE_INTERNAL_PRINTF (0)
78 
79 #define MICROPY_PY_FSTRINGS         (1)
80 #define MICROPY_PY_BUILTINS_STR_UNICODE (1)
81 
82 #if !(defined(MICROPY_GCREGS_SETJMP) || defined(__x86_64__) || defined(__i386__) || defined(__thumb2__) || defined(__thumb__) || defined(__arm__))
83 // Fall back to setjmp() implementation for discovery of GC pointers in registers.
84 #define MICROPY_GCREGS_SETJMP (1)
85 #endif
86 
87 #define MICROPY_PY___FILE__         (0)
88 #define MICROPY_PY_ARRAY            (0)
89 #define MICROPY_PY_ATTRTUPLE        (0)
90 #define MICROPY_PY_COLLECTIONS      (0)
91 #define MICROPY_PY_MATH             (0)
92 #define MICROPY_PY_CMATH            (0)
93 #define MICROPY_PY_GC               (0)
94 #define MICROPY_PY_IO               (0)
95 #define MICROPY_PY_SYS              (0)
96 
97 // type definitions for the specific machine
98 
99 #ifdef __LP64__
100 typedef long mp_int_t; // must be pointer size
101 typedef unsigned long mp_uint_t; // must be pointer size
102 #elif defined(__MINGW32__) && defined(_WIN64)
103 #include <stdint.h>
104 typedef __int64 mp_int_t;
105 typedef unsigned __int64 mp_uint_t;
106 #elif defined(_MSC_VER) && defined(_WIN64)
107 typedef __int64 mp_int_t;
108 typedef unsigned __int64 mp_uint_t;
109 #else
110 // These are definitions for machines where sizeof(int) == sizeof(void*),
111 // regardless for actual size.
112 typedef int mp_int_t; // must be pointer size
113 typedef unsigned int mp_uint_t; // must be pointer size
114 #endif
115 
116 // Cannot include <sys/types.h>, as it may lead to symbol name clashes
117 #if _FILE_OFFSET_BITS == 64 && !defined(__LP64__)
118 typedef long long mp_off_t;
119 #else
120 typedef long mp_off_t;
121 #endif
122 
123 #define MP_PLAT_PRINT_STRN(str, len) (void)0
124 
125 // We need to provide a declaration/definition of alloca()
126 #ifdef __FreeBSD__
127 #include <stdlib.h>
128 #elif defined(_WIN32)
129 #include <malloc.h>
130 #else
131 #include <alloca.h>
132 #endif
133 
134 #include <stdint.h>
135 
136 // MSVC specifics - see windows/mpconfigport.h for explanation
137 #ifdef _MSC_VER
138 
139 #define MP_ENDIANNESS_LITTLE        (1)
140 #define NORETURN                    __declspec(noreturn)
141 #define MP_NOINLINE                 __declspec(noinline)
142 #define MP_LIKELY(x)                (x)
143 #define MP_UNLIKELY(x)              (x)
144 #define MICROPY_PORT_CONSTANTS      { "dummy", 0 }
145 #ifdef _WIN64
146 #define MP_SSIZE_MAX                _I64_MAX
147 #else
148 #define MP_SSIZE_MAX                _I32_MAX
149 #endif
150 #define MICROPY_MAKE_POINTER_CALLABLE(p) ((void *)(p)) // Avoid compiler warning about different const qualifiers
151 #define restrict
152 #define inline                      __inline
153 #define alignof(t)                  __alignof(t)
154 #undef MICROPY_ALLOC_PATH_MAX
155 #define MICROPY_ALLOC_PATH_MAX      260
156 #define PATH_MAX                    MICROPY_ALLOC_PATH_MAX
157 #define S_ISREG(m)                  (((m) & S_IFMT) == S_IFREG)
158 #define S_ISDIR(m)                  (((m) & S_IFMT) == S_IFDIR)
159 #ifdef _WIN64
160 #define SSIZE_MAX                   _I64_MAX
161 typedef __int64 ssize_t;
162 #else
163 #define SSIZE_MAX                   _I32_MAX
164 typedef int ssize_t;
165 #endif
166 typedef mp_off_t off_t;
167 
168 #endif
169