blob: 853d475c3eb86fcfdb32e85ad2091242a1a87426 [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
Damien George58ebde42014-05-21 20:32:59 +010040#ifndef MICROPY_ALLOC_LEXER_INDENT_INIT
41#define MICROPY_ALLOC_LEXER_INDENT_INIT (10)
Damien Georgee1199ec2014-05-10 17:48:01 +010042#endif
43
44// Increment for lexer indentation level
Damien George58ebde42014-05-21 20:32:59 +010045#ifndef MICROPY_ALLOC_LEXEL_INDENT_INC
46#define MICROPY_ALLOC_LEXEL_INDENT_INC (8)
Damien Georgee1199ec2014-05-10 17:48:01 +010047#endif
48
Damien George66e18f02014-05-05 13:19:03 +010049// Initial amount for parse rule stack
Damien George58ebde42014-05-21 20:32:59 +010050#ifndef MICROPY_ALLOC_PARSE_RULE_INIT
51#define MICROPY_ALLOC_PARSE_RULE_INIT (64)
Damien George66e18f02014-05-05 13:19:03 +010052#endif
53
54// Increment for parse rule stack
Damien George58ebde42014-05-21 20:32:59 +010055#ifndef MICROPY_ALLOC_PARSE_RULE_INC
56#define MICROPY_ALLOC_PARSE_RULE_INC (16)
Damien George66e18f02014-05-05 13:19:03 +010057#endif
58
59// Initial amount for parse result stack
Damien George58ebde42014-05-21 20:32:59 +010060#ifndef MICROPY_ALLOC_PARSE_RESULT_INIT
61#define MICROPY_ALLOC_PARSE_RESULT_INIT (32)
Damien George66e18f02014-05-05 13:19:03 +010062#endif
63
64// Increment for parse result stack
Damien George58ebde42014-05-21 20:32:59 +010065#ifndef MICROPY_ALLOC_PARSE_RESULT_INC
66#define MICROPY_ALLOC_PARSE_RESULT_INC (16)
Damien George66e18f02014-05-05 13:19:03 +010067#endif
68
69// Initial amount for ids in a scope
Damien George58ebde42014-05-21 20:32:59 +010070#ifndef MICROPY_ALLOC_SCOPE_ID_INIT
71#define MICROPY_ALLOC_SCOPE_ID_INIT (4)
Damien George66e18f02014-05-05 13:19:03 +010072#endif
73
74// Increment for ids in a scope
Damien George58ebde42014-05-21 20:32:59 +010075#ifndef MICROPY_ALLOC_SCOPE_ID_INC
76#define MICROPY_ALLOC_SCOPE_ID_INC (6)
77#endif
78
79// Maximum length of a path in the filesystem
80// So we can allocate a buffer on the stack for path manipulation in import
81#ifndef MICROPY_ALLOC_PATH_MAX
82#define MICROPY_ALLOC_PATH_MAX (512)
Damien George66e18f02014-05-05 13:19:03 +010083#endif
84
85/*****************************************************************************/
Damien George136f6752014-01-07 14:54:15 +000086/* Micro Python emitters */
87
88// Whether to emit CPython byte codes (for debugging/testing)
89// Enabling this overrides all other emitters
90#ifndef MICROPY_EMIT_CPYTHON
91#define MICROPY_EMIT_CPYTHON (0)
92#endif
93
94// Whether to emit x64 native code
95#ifndef MICROPY_EMIT_X64
96#define MICROPY_EMIT_X64 (0)
97#endif
98
99// Whether to emit thumb native code
100#ifndef MICROPY_EMIT_THUMB
101#define MICROPY_EMIT_THUMB (0)
102#endif
103
104// Whether to enable the thumb inline assembler
105#ifndef MICROPY_EMIT_INLINE_THUMB
106#define MICROPY_EMIT_INLINE_THUMB (0)
107#endif
108
109/*****************************************************************************/
Damien George58ebde42014-05-21 20:32:59 +0100110/* Compiler configuration */
111
112// Whether to enable constant optimisation; id = const(value)
113#ifndef MICROPY_COMP_CONST
114#define MICROPY_COMP_CONST (1)
115#endif
116
117/*****************************************************************************/
Damien George136f6752014-01-07 14:54:15 +0000118/* Internal debugging stuff */
119
120// Whether to collect memory allocation stats
121#ifndef MICROPY_MEM_STATS
122#define MICROPY_MEM_STATS (0)
123#endif
124
Damien Georgecbd2f742014-01-19 11:48:48 +0000125// Whether to build functions that print debugging info:
Damien Georgec5966122014-02-15 16:10:44 +0000126// mp_token_show
Damien George3417bc22014-05-10 10:36:38 +0100127// mp_bytecode_print
Damien Georgecbd2f742014-01-19 11:48:48 +0000128// mp_parse_node_print
129#ifndef MICROPY_DEBUG_PRINTERS
130#define MICROPY_DEBUG_PRINTERS (0)
Damien Georged3ebe482014-01-07 15:20:33 +0000131#endif
132
Damien George136f6752014-01-07 14:54:15 +0000133/*****************************************************************************/
Damien Georgeee3fd462014-05-24 23:03:12 +0100134/* Optimisations */
135
136// Whether to use computed gotos in the VM, or a switch
137// Computed gotos are roughly 10% faster, and increase VM code size by a little
138#ifndef MICROPY_OPT_COMPUTED_GOTO
139#define MICROPY_OPT_COMPUTED_GOTO (0)
140#endif
141
142/*****************************************************************************/
143/* Python internal features */
Damien George136f6752014-01-07 14:54:15 +0000144
Damien Georged3ebe482014-01-07 15:20:33 +0000145// Whether to include the garbage collector
146#ifndef MICROPY_ENABLE_GC
147#define MICROPY_ENABLE_GC (0)
148#endif
149
Damien George12bab722014-04-05 20:35:48 +0100150// Whether to enable finalisers in the garbage collector (ie call __del__)
151#ifndef MICROPY_ENABLE_GC_FINALISER
152#define MICROPY_ENABLE_GC_FINALISER (0)
153#endif
154
Damien George136f6752014-01-07 14:54:15 +0000155// Whether to include REPL helper function
Damien George58ebde42014-05-21 20:32:59 +0100156#ifndef MICROPY_HELPER_REPL
157#define MICROPY_HELPER_REPL (0)
Damien George136f6752014-01-07 14:54:15 +0000158#endif
159
Damien Georged3ebe482014-01-07 15:20:33 +0000160// Whether to include lexer helper function for unix
Damien George58ebde42014-05-21 20:32:59 +0100161#ifndef MICROPY_HELPER_LEXER_UNIX
162#define MICROPY_HELPER_LEXER_UNIX (0)
Damien Georged3ebe482014-01-07 15:20:33 +0000163#endif
164
Paul Sokolovsky48b35722014-01-12 17:30:48 +0200165// Long int implementation
166#define MICROPY_LONGINT_IMPL_NONE (0)
167#define MICROPY_LONGINT_IMPL_LONGLONG (1)
Damien George438c88d2014-02-22 19:25:23 +0000168#define MICROPY_LONGINT_IMPL_MPZ (2)
Paul Sokolovsky48b35722014-01-12 17:30:48 +0200169
170#ifndef MICROPY_LONGINT_IMPL
171#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_NONE)
172#endif
173
174#if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_LONGLONG
175typedef long long mp_longint_impl_t;
176#endif
177
Damien George62ad1892014-01-29 21:51:51 +0000178// Whether to include information in the byte code to determine source
179// line number (increases RAM usage, but doesn't slow byte code execution)
180#ifndef MICROPY_ENABLE_SOURCE_LINE
181#define MICROPY_ENABLE_SOURCE_LINE (0)
182#endif
183
Damien George1463c1f2014-04-25 23:52:57 +0100184// Whether to include doc strings (increases RAM usage)
185#ifndef MICROPY_ENABLE_DOC_STRING
186#define MICROPY_ENABLE_DOC_STRING (0)
187#endif
188
Paul Sokolovsky1f85d622014-05-01 01:35:38 +0300189// Exception messages are short static strings (TODO)
190#define MICROPY_ERROR_REPORTING_TERSE (1)
191// Exception messages provide basic error details
192#define MICROPY_ERROR_REPORTING_NORMAL (2)
193// Exception messages provide full info, e.g. object names
194#define MICROPY_ERROR_REPORTING_DETAILED (3)
195
196#ifndef MICROPY_ERROR_REPORTING
197#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_NORMAL)
198#endif
199
Damien George0c36da02014-03-08 15:24:39 +0000200// Float and complex implementation
201#define MICROPY_FLOAT_IMPL_NONE (0)
202#define MICROPY_FLOAT_IMPL_FLOAT (1)
203#define MICROPY_FLOAT_IMPL_DOUBLE (2)
204
205#ifndef MICROPY_FLOAT_IMPL
206#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_NONE)
207#endif
208
209#if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT
210#define MICROPY_ENABLE_FLOAT (1)
211#define MICROPY_FLOAT_C_FUN(fun) fun##f
212typedef float mp_float_t;
213#elif MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE
214#define MICROPY_ENABLE_FLOAT (1)
215#define MICROPY_FLOAT_C_FUN(fun) fun
216typedef double mp_float_t;
217#else
Damien George136f6752014-01-07 14:54:15 +0000218#define MICROPY_ENABLE_FLOAT (0)
219#endif
220
Paul Sokolovskydcac8802014-01-16 19:19:50 +0200221// Enable features which improve CPython compatibility
222// but may lead to more code size/memory usage.
223// TODO: Originally intended as generic category to not
224// add bunch of once-off options. May need refactoring later
225#ifndef MICROPY_CPYTHON_COMPAT
226#define MICROPY_CPYTHON_COMPAT (1)
227#endif
228
Paul Sokolovsky0ef015b2014-05-07 02:23:46 +0300229// Whether POSIX-semantics non-blocking streams are supported
230#ifndef MICROPY_STREAMS_NON_BLOCK
231#define MICROPY_STREAMS_NON_BLOCK (0)
232#endif
233
Damien Georgeee3fd462014-05-24 23:03:12 +0100234/*****************************************************************************/
235/* Fine control over Python builtins, classes, modules, etc */
236
237// Whether to support slice object and correspondingly
238// slice subscript operators
239#ifndef MICROPY_PY_SLICE
240#define MICROPY_PY_SLICE (1)
241#endif
242
243// Whether to support frozenset object
244#ifndef MICROPY_PY_FROZENSET
245#define MICROPY_PY_FROZENSET (0)
246#endif
247
248// Whether to support the property object
249#ifndef MICROPY_PY_PROPERTY
250#define MICROPY_PY_PROPERTY (1)
251#endif
252
253// Whether to provide "collections" module
254#ifndef MICROPY_PY_COLLECTIONS
255#define MICROPY_PY_COLLECTIONS (1)
256#endif
257
258// Whether to provide "math" module
259#ifndef MICROPY_PY_MATH
260#define MICROPY_PY_MATH (1)
261#endif
262
263// Whether to provide "cmath" module
264#ifndef MICROPY_PY_CMATH
265#define MICROPY_PY_CMATH (0)
266#endif
267
268// Whether to provide "gc" module
269#ifndef MICROPY_PY_GC
270#define MICROPY_PY_GC (1)
271#endif
272
273// Whether to provide "io" module
274#ifndef MICROPY_PY_IO
275#define MICROPY_PY_IO (1)
276#endif
277
278// Whether to provide "io.FileIO" class
279#ifndef MICROPY_PY_IO_FILEIO
280#define MICROPY_PY_IO_FILEIO (0)
281#endif
282
283// Whether to provide "io.BytesIO" class
284#ifndef MICROPY_PY_IO_BYTESIO
285#define MICROPY_PY_IO_BYTESIO (1)
286#endif
287
288// Whether to provide "struct" module
289#ifndef MICROPY_PY_STRUCT
290#define MICROPY_PY_STRUCT (1)
291#endif
292
293// Whether to provide "sys" module
294#ifndef MICROPY_PY_SYS
295#define MICROPY_PY_SYS (1)
296#endif
297
298// Whether to provide "sys.exit" function
299#ifndef MICROPY_PY_SYS_EXIT
300#define MICROPY_PY_SYS_EXIT (0)
301#endif
302
303// Whether to provide sys.{stdin,stdout,stderr} objects
304#ifndef MICROPY_PY_SYS_STDFILES
305#define MICROPY_PY_SYS_STDFILES (0)
Damien George3bb8bd82014-04-14 21:20:30 +0100306#endif
307
Damien George58ebde42014-05-21 20:32:59 +0100308/*****************************************************************************/
309/* Hooks for a port to add builtins */
310
Damien Georgecaac5422014-03-25 14:18:18 +0000311// Additional builtin function definitions - see builtintables.c:builtin_object_table for format.
Damien George58ebde42014-05-21 20:32:59 +0100312#ifndef MICROPY_PORT_BUILTINS
313#define MICROPY_PORT_BUILTINS
Paul Sokolovsky910843e2014-02-14 12:02:34 +0200314#endif
Damien Georgecaac5422014-03-25 14:18:18 +0000315
316// Additional builtin module definitions - see builtintables.c:builtin_module_table for format.
Damien George58ebde42014-05-21 20:32:59 +0100317#ifndef MICROPY_PORT_BUILTIN_MODULES
318#define MICROPY_PORT_BUILTIN_MODULES
Damien Georgecaac5422014-03-25 14:18:18 +0000319#endif
320
Damien George57e99eb2014-04-10 22:42:11 +0100321// Additional constant definitions for the compiler - see compile.c:mp_constants_table.
Damien George58ebde42014-05-21 20:32:59 +0100322#ifndef MICROPY_PORT_CONSTANTS
323#define MICROPY_PORT_CONSTANTS
Damien George57e99eb2014-04-10 22:42:11 +0100324#endif
325
Damien George136f6752014-01-07 14:54:15 +0000326/*****************************************************************************/
327/* Miscellaneous settings */
328
Paul Sokolovskyd5df6cd2014-02-12 18:15:40 +0200329// Allow to override static modifier for global objects, e.g. to use with
330// object code analysis tools which don't support static symbols.
331#ifndef STATIC
332#define STATIC static
333#endif
334
Paul Sokolovskyfc5aac82014-01-12 16:10:19 +0200335#define BITS_PER_BYTE (8)
336#define BITS_PER_WORD (BITS_PER_BYTE * BYTES_PER_WORD)
Paul Sokolovskyc260bc52014-01-12 16:15:47 +0200337// machine_int_t value with most significant bit set
Damien George23005372014-01-13 19:39:01 +0000338#define WORD_MSBIT_HIGH (((machine_uint_t)1) << (BYTES_PER_WORD * 8 - 1))
Paul Sokolovskyfc5aac82014-01-12 16:10:19 +0200339
Paul Sokolovsky2da81fa2014-04-11 03:44:00 +0300340#if !defined(MP_ENDIANNESS_LITTLE) && !defined(MP_ENDIANNESS_BIG)
341// Just because most archs are such?
342#define MP_ENDIANNESS_LITTLE (1)
343#endif
Andrew Schellercc837372014-04-14 02:39:56 +0100344// Ensure we don't accidentally set both endiannesses
345#if MP_ENDIANNESS_BIG
346#define MP_ENDIANNESS_LITTLE (0)
347#endif
Paul Sokolovsky2da81fa2014-04-11 03:44:00 +0300348
Paul Sokolovskyc90c0f62014-01-04 01:57:00 +0200349// printf format spec to use for machine_int_t and friends
Damien George136f6752014-01-07 14:54:15 +0000350#ifndef INT_FMT
Paul Sokolovskyc90c0f62014-01-04 01:57:00 +0200351#ifdef __LP64__
352// Archs where machine_int_t == long, long != int
353#define UINT_FMT "%lu"
354#define INT_FMT "%ld"
355#else
356// Archs where machine_int_t == int
357#define UINT_FMT "%u"
358#define INT_FMT "%d"
359#endif
360#endif //INT_FMT
Paul Sokolovskye9085912014-04-30 05:35:18 +0300361
362// Modifier for function which doesn't return
stijn01d6be42014-05-05 12:18:27 +0200363#ifndef NORETURN
Paul Sokolovskye9085912014-04-30 05:35:18 +0300364#define NORETURN __attribute__((noreturn))
stijn01d6be42014-05-05 12:18:27 +0200365#endif