blob: a7e1c4a40da181139a0c91b1bd37542bb219bc16 [file] [log] [blame]
Damien George04b91472014-05-03 23:27:38 +01001/*
2 * This file is part of the Micro Python project, http://micropython.org/
3 *
4 * The MIT License (MIT)
5 *
6 * Copyright (c) 2013, 2014 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
Paul Sokolovskyb372bfc2014-01-03 17:15:53 +020027// This file contains default configuration settings for MicroPython.
28// You can override any of these options using mpconfigport.h file located
29// in a directory of your port.
30
31#include <mpconfigport.h>
32
Damien George136f6752014-01-07 14:54:15 +000033// Any options not explicitly set in mpconfigport.h will get default
34// values below.
35
36/*****************************************************************************/
Damien George66e18f02014-05-05 13:19:03 +010037/* Memory allocation policy */
38
Damien Georgee1199ec2014-05-10 17:48:01 +010039// Initial amount for lexer indentation level
40#ifndef MP_ALLOC_LEXER_INDENT_INIT
41#define MP_ALLOC_LEXER_INDENT_INIT (10)
42#endif
43
44// Increment for lexer indentation level
45#ifndef MP_ALLOC_LEXEL_INDENT_INC
46#define MP_ALLOC_LEXEL_INDENT_INC (8)
47#endif
48
Damien George66e18f02014-05-05 13:19:03 +010049// Initial amount for parse rule stack
50#ifndef MP_ALLOC_PARSE_RULE_INIT
51#define MP_ALLOC_PARSE_RULE_INIT (64)
52#endif
53
54// Increment for parse rule stack
55#ifndef MP_ALLOC_PARSE_RULE_INC
56#define MP_ALLOC_PARSE_RULE_INC (16)
57#endif
58
59// Initial amount for parse result stack
60#ifndef MP_ALLOC_PARSE_RESULT_INIT
61#define MP_ALLOC_PARSE_RESULT_INIT (32)
62#endif
63
64// Increment for parse result stack
65#ifndef MP_ALLOC_PARSE_RESULT_INC
66#define MP_ALLOC_PARSE_RESULT_INC (16)
67#endif
68
69// Initial amount for ids in a scope
70#ifndef MP_ALLOC_SCOPE_ID_INIT
71#define MP_ALLOC_SCOPE_ID_INIT (4)
72#endif
73
74// Increment for ids in a scope
75#ifndef MP_ALLOC_SCOPE_ID_INC
76#define MP_ALLOC_SCOPE_ID_INC (6)
77#endif
78
79/*****************************************************************************/
Damien George136f6752014-01-07 14:54:15 +000080/* Micro Python emitters */
81
82// Whether to emit CPython byte codes (for debugging/testing)
83// Enabling this overrides all other emitters
84#ifndef MICROPY_EMIT_CPYTHON
85#define MICROPY_EMIT_CPYTHON (0)
86#endif
87
88// Whether to emit x64 native code
89#ifndef MICROPY_EMIT_X64
90#define MICROPY_EMIT_X64 (0)
91#endif
92
93// Whether to emit thumb native code
94#ifndef MICROPY_EMIT_THUMB
95#define MICROPY_EMIT_THUMB (0)
96#endif
97
98// Whether to enable the thumb inline assembler
99#ifndef MICROPY_EMIT_INLINE_THUMB
100#define MICROPY_EMIT_INLINE_THUMB (0)
101#endif
102
103/*****************************************************************************/
104/* Internal debugging stuff */
105
106// Whether to collect memory allocation stats
107#ifndef MICROPY_MEM_STATS
108#define MICROPY_MEM_STATS (0)
109#endif
110
Damien Georgecbd2f742014-01-19 11:48:48 +0000111// Whether to build functions that print debugging info:
Damien Georgec5966122014-02-15 16:10:44 +0000112// mp_token_show
Damien George3417bc22014-05-10 10:36:38 +0100113// mp_bytecode_print
Damien Georgecbd2f742014-01-19 11:48:48 +0000114// mp_parse_node_print
115#ifndef MICROPY_DEBUG_PRINTERS
116#define MICROPY_DEBUG_PRINTERS (0)
Damien Georged3ebe482014-01-07 15:20:33 +0000117#endif
118
Damien George136f6752014-01-07 14:54:15 +0000119/*****************************************************************************/
120/* Fine control over Python features */
121
Damien Georgeffae48d2014-05-08 15:58:39 +0000122// Whether to enable constant optimisation; id = const(value)
123#ifndef MICROPY_ENABLE_CONST
124#define MICROPY_ENABLE_CONST (1)
125#endif
126
Damien Georged3ebe482014-01-07 15:20:33 +0000127// Whether to include the garbage collector
128#ifndef MICROPY_ENABLE_GC
129#define MICROPY_ENABLE_GC (0)
130#endif
131
Damien George12bab722014-04-05 20:35:48 +0100132// Whether to enable finalisers in the garbage collector (ie call __del__)
133#ifndef MICROPY_ENABLE_GC_FINALISER
134#define MICROPY_ENABLE_GC_FINALISER (0)
135#endif
136
Damien George136f6752014-01-07 14:54:15 +0000137// Whether to include REPL helper function
138#ifndef MICROPY_ENABLE_REPL_HELPERS
139#define MICROPY_ENABLE_REPL_HELPERS (0)
140#endif
141
Damien Georged3ebe482014-01-07 15:20:33 +0000142// Whether to include lexer helper function for unix
143#ifndef MICROPY_ENABLE_LEXER_UNIX
144#define MICROPY_ENABLE_LEXER_UNIX (0)
145#endif
146
Paul Sokolovsky48b35722014-01-12 17:30:48 +0200147// Long int implementation
148#define MICROPY_LONGINT_IMPL_NONE (0)
149#define MICROPY_LONGINT_IMPL_LONGLONG (1)
Damien George438c88d2014-02-22 19:25:23 +0000150#define MICROPY_LONGINT_IMPL_MPZ (2)
Paul Sokolovsky48b35722014-01-12 17:30:48 +0200151
152#ifndef MICROPY_LONGINT_IMPL
153#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_NONE)
154#endif
155
156#if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_LONGLONG
157typedef long long mp_longint_impl_t;
158#endif
159
Damien George62ad1892014-01-29 21:51:51 +0000160// Whether to include information in the byte code to determine source
161// line number (increases RAM usage, but doesn't slow byte code execution)
162#ifndef MICROPY_ENABLE_SOURCE_LINE
163#define MICROPY_ENABLE_SOURCE_LINE (0)
164#endif
165
Damien George1463c1f2014-04-25 23:52:57 +0100166// Whether to include doc strings (increases RAM usage)
167#ifndef MICROPY_ENABLE_DOC_STRING
168#define MICROPY_ENABLE_DOC_STRING (0)
169#endif
170
Paul Sokolovsky1f85d622014-05-01 01:35:38 +0300171// Exception messages are short static strings (TODO)
172#define MICROPY_ERROR_REPORTING_TERSE (1)
173// Exception messages provide basic error details
174#define MICROPY_ERROR_REPORTING_NORMAL (2)
175// Exception messages provide full info, e.g. object names
176#define MICROPY_ERROR_REPORTING_DETAILED (3)
177
178#ifndef MICROPY_ERROR_REPORTING
179#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_NORMAL)
180#endif
181
Damien George0c36da02014-03-08 15:24:39 +0000182// Float and complex implementation
183#define MICROPY_FLOAT_IMPL_NONE (0)
184#define MICROPY_FLOAT_IMPL_FLOAT (1)
185#define MICROPY_FLOAT_IMPL_DOUBLE (2)
186
187#ifndef MICROPY_FLOAT_IMPL
188#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_NONE)
189#endif
190
191#if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT
192#define MICROPY_ENABLE_FLOAT (1)
193#define MICROPY_FLOAT_C_FUN(fun) fun##f
194typedef float mp_float_t;
195#elif MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE
196#define MICROPY_ENABLE_FLOAT (1)
197#define MICROPY_FLOAT_C_FUN(fun) fun
198typedef double mp_float_t;
199#else
Damien George136f6752014-01-07 14:54:15 +0000200#define MICROPY_ENABLE_FLOAT (0)
201#endif
202
Damien George107c9fb2014-04-26 10:31:15 +0100203// Whether to provide "collections" module
204#ifndef MICROPY_ENABLE_MOD_COLLECTIONS
205#define MICROPY_ENABLE_MOD_COLLECTIONS (1)
206#endif
207
Damien Georgedbdfee12014-04-17 17:11:03 +0100208// Whether to provide "math" module
209#ifndef MICROPY_ENABLE_MOD_MATH
210#define MICROPY_ENABLE_MOD_MATH (1)
211#endif
212
213// Whether to provide "cmath" module
214#ifndef MICROPY_ENABLE_MOD_CMATH
215#define MICROPY_ENABLE_MOD_CMATH (0)
216#endif
217
Paul Sokolovskyf9e54e02014-05-06 02:16:43 +0300218// Whether to provide "gc" module
219#ifndef MICROPY_ENABLE_MOD_GC
220#define MICROPY_ENABLE_MOD_GC (1)
221#endif
222
Paul Sokolovsky98a627d2014-04-03 14:57:53 +0300223// Whether to provide "io" module
224#ifndef MICROPY_ENABLE_MOD_IO
225#define MICROPY_ENABLE_MOD_IO (1)
226#endif
227
Paul Sokolovskye9db8402014-04-10 03:45:38 +0300228// Whether to provide "struct" module
229#ifndef MICROPY_ENABLE_MOD_STRUCT
230#define MICROPY_ENABLE_MOD_STRUCT (1)
231#endif
232
Paul Sokolovsky5500cde2014-04-13 06:43:18 +0300233// Whether to provide "sys" module
234#ifndef MICROPY_ENABLE_MOD_SYS
235#define MICROPY_ENABLE_MOD_SYS (1)
236#endif
237
Paul Sokolovsky4165cd12014-04-13 07:00:37 +0300238#ifndef MICROPY_MOD_SYS_STDFILES
239#define MICROPY_MOD_SYS_STDFILES (0)
240#endif
241
Paul Sokolovskydeaeaac2014-05-10 17:26:47 +0300242// sys.exit() availability
243#ifndef MICROPY_SYS_EXIT
244#define MICROPY_SYS_EXIT (0)
245#endif
246
Damien George136f6752014-01-07 14:54:15 +0000247// Whether to support slice object and correspondingly
248// slice subscript operators
249#ifndef MICROPY_ENABLE_SLICE
250#define MICROPY_ENABLE_SLICE (1)
251#endif
252
Paul Sokolovskyb181b582014-05-10 16:02:17 +0300253// Whether to support frozenset object
254#ifndef MICROPY_ENABLE_FROZENSET
Paul Sokolovskyd80e2472014-05-10 16:11:04 +0300255#define MICROPY_ENABLE_FROZENSET (0)
Paul Sokolovskyb181b582014-05-10 16:02:17 +0300256#endif
257
Damien George777b0f32014-04-13 18:59:45 +0100258// Whether to support the property object
259#ifndef MICROPY_ENABLE_PROPERTY
Damien Georgec9f6f6b2014-04-17 17:02:30 +0100260#define MICROPY_ENABLE_PROPERTY (1)
Damien George777b0f32014-04-13 18:59:45 +0100261#endif
262
Paul Sokolovskydcac8802014-01-16 19:19:50 +0200263// Enable features which improve CPython compatibility
264// but may lead to more code size/memory usage.
265// TODO: Originally intended as generic category to not
266// add bunch of once-off options. May need refactoring later
267#ifndef MICROPY_CPYTHON_COMPAT
268#define MICROPY_CPYTHON_COMPAT (1)
269#endif
270
Damien George354d15a2014-02-06 21:11:19 +0000271// Maximum length of a path in the filesystem
272// So we can allocate a buffer on the stack for path manipulation in import
273#ifndef MICROPY_PATH_MAX
274#define MICROPY_PATH_MAX (512)
275#endif
276
Paul Sokolovsky0ef015b2014-05-07 02:23:46 +0300277// Whether POSIX-semantics non-blocking streams are supported
278#ifndef MICROPY_STREAMS_NON_BLOCK
279#define MICROPY_STREAMS_NON_BLOCK (0)
280#endif
281
Damien George3bb8bd82014-04-14 21:20:30 +0100282// Whether to use computed gotos in the VM, or a switch
283// Computed gotos are roughly 10% faster, and increase VM code size by a little
Damien George5b65f0c2014-04-17 23:24:13 +0100284#ifndef MICROPY_USE_COMPUTED_GOTO
285#define MICROPY_USE_COMPUTED_GOTO (0)
Damien George3bb8bd82014-04-14 21:20:30 +0100286#endif
287
Damien Georgecaac5422014-03-25 14:18:18 +0000288// Additional builtin function definitions - see builtintables.c:builtin_object_table for format.
Paul Sokolovsky910843e2014-02-14 12:02:34 +0200289#ifndef MICROPY_EXTRA_BUILTINS
290#define MICROPY_EXTRA_BUILTINS
291#endif
Damien Georgecaac5422014-03-25 14:18:18 +0000292
293// Additional builtin module definitions - see builtintables.c:builtin_module_table for format.
294#ifndef MICROPY_EXTRA_BUILTIN_MODULES
295#define MICROPY_EXTRA_BUILTIN_MODULES
296#endif
297
Damien George57e99eb2014-04-10 22:42:11 +0100298// Additional constant definitions for the compiler - see compile.c:mp_constants_table.
299#ifndef MICROPY_EXTRA_CONSTANTS
300#define MICROPY_EXTRA_CONSTANTS
301#endif
302
Damien George136f6752014-01-07 14:54:15 +0000303/*****************************************************************************/
304/* Miscellaneous settings */
305
Paul Sokolovskyd5df6cd2014-02-12 18:15:40 +0200306// Allow to override static modifier for global objects, e.g. to use with
307// object code analysis tools which don't support static symbols.
308#ifndef STATIC
309#define STATIC static
310#endif
311
Paul Sokolovskyfc5aac82014-01-12 16:10:19 +0200312#define BITS_PER_BYTE (8)
313#define BITS_PER_WORD (BITS_PER_BYTE * BYTES_PER_WORD)
Paul Sokolovskyc260bc52014-01-12 16:15:47 +0200314// machine_int_t value with most significant bit set
Damien George23005372014-01-13 19:39:01 +0000315#define WORD_MSBIT_HIGH (((machine_uint_t)1) << (BYTES_PER_WORD * 8 - 1))
Paul Sokolovskyfc5aac82014-01-12 16:10:19 +0200316
Paul Sokolovsky2da81fa2014-04-11 03:44:00 +0300317#if !defined(MP_ENDIANNESS_LITTLE) && !defined(MP_ENDIANNESS_BIG)
318// Just because most archs are such?
319#define MP_ENDIANNESS_LITTLE (1)
320#endif
Andrew Schellercc837372014-04-14 02:39:56 +0100321// Ensure we don't accidentally set both endiannesses
322#if MP_ENDIANNESS_BIG
323#define MP_ENDIANNESS_LITTLE (0)
324#endif
Paul Sokolovsky2da81fa2014-04-11 03:44:00 +0300325
Paul Sokolovskyc90c0f62014-01-04 01:57:00 +0200326// printf format spec to use for machine_int_t and friends
Damien George136f6752014-01-07 14:54:15 +0000327#ifndef INT_FMT
Paul Sokolovskyc90c0f62014-01-04 01:57:00 +0200328#ifdef __LP64__
329// Archs where machine_int_t == long, long != int
330#define UINT_FMT "%lu"
331#define INT_FMT "%ld"
332#else
333// Archs where machine_int_t == int
334#define UINT_FMT "%u"
335#define INT_FMT "%d"
336#endif
337#endif //INT_FMT
Paul Sokolovskye9085912014-04-30 05:35:18 +0300338
339// Modifier for function which doesn't return
stijn01d6be42014-05-05 12:18:27 +0200340#ifndef NORETURN
Paul Sokolovskye9085912014-04-30 05:35:18 +0300341#define NORETURN __attribute__((noreturn))
stijn01d6be42014-05-05 12:18:27 +0200342#endif