blob: 78147609ca9e9a6d07a03c43cd848087135fc05e [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/*****************************************************************************/
37/* Micro Python emitters */
38
39// Whether to emit CPython byte codes (for debugging/testing)
40// Enabling this overrides all other emitters
41#ifndef MICROPY_EMIT_CPYTHON
42#define MICROPY_EMIT_CPYTHON (0)
43#endif
44
45// Whether to emit x64 native code
46#ifndef MICROPY_EMIT_X64
47#define MICROPY_EMIT_X64 (0)
48#endif
49
50// Whether to emit thumb native code
51#ifndef MICROPY_EMIT_THUMB
52#define MICROPY_EMIT_THUMB (0)
53#endif
54
55// Whether to enable the thumb inline assembler
56#ifndef MICROPY_EMIT_INLINE_THUMB
57#define MICROPY_EMIT_INLINE_THUMB (0)
58#endif
59
60/*****************************************************************************/
61/* Internal debugging stuff */
62
63// Whether to collect memory allocation stats
64#ifndef MICROPY_MEM_STATS
65#define MICROPY_MEM_STATS (0)
66#endif
67
Damien Georgecbd2f742014-01-19 11:48:48 +000068// Whether to build functions that print debugging info:
Damien Georgec5966122014-02-15 16:10:44 +000069// mp_token_show
Damien Georgecbd2f742014-01-19 11:48:48 +000070// mp_byte_code_print
71// mp_parse_node_print
72#ifndef MICROPY_DEBUG_PRINTERS
73#define MICROPY_DEBUG_PRINTERS (0)
Damien Georged3ebe482014-01-07 15:20:33 +000074#endif
75
Damien George136f6752014-01-07 14:54:15 +000076/*****************************************************************************/
77/* Fine control over Python features */
78
Damien Georged3ebe482014-01-07 15:20:33 +000079// Whether to include the garbage collector
80#ifndef MICROPY_ENABLE_GC
81#define MICROPY_ENABLE_GC (0)
82#endif
83
Damien George12bab722014-04-05 20:35:48 +010084// Whether to enable finalisers in the garbage collector (ie call __del__)
85#ifndef MICROPY_ENABLE_GC_FINALISER
86#define MICROPY_ENABLE_GC_FINALISER (0)
87#endif
88
Damien George136f6752014-01-07 14:54:15 +000089// Whether to include REPL helper function
90#ifndef MICROPY_ENABLE_REPL_HELPERS
91#define MICROPY_ENABLE_REPL_HELPERS (0)
92#endif
93
Damien Georged3ebe482014-01-07 15:20:33 +000094// Whether to include lexer helper function for unix
95#ifndef MICROPY_ENABLE_LEXER_UNIX
96#define MICROPY_ENABLE_LEXER_UNIX (0)
97#endif
98
Paul Sokolovsky48b35722014-01-12 17:30:48 +020099// Long int implementation
100#define MICROPY_LONGINT_IMPL_NONE (0)
101#define MICROPY_LONGINT_IMPL_LONGLONG (1)
Damien George438c88d2014-02-22 19:25:23 +0000102#define MICROPY_LONGINT_IMPL_MPZ (2)
Paul Sokolovsky48b35722014-01-12 17:30:48 +0200103
104#ifndef MICROPY_LONGINT_IMPL
105#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_NONE)
106#endif
107
108#if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_LONGLONG
109typedef long long mp_longint_impl_t;
110#endif
111
Damien George62ad1892014-01-29 21:51:51 +0000112// Whether to include information in the byte code to determine source
113// line number (increases RAM usage, but doesn't slow byte code execution)
114#ifndef MICROPY_ENABLE_SOURCE_LINE
115#define MICROPY_ENABLE_SOURCE_LINE (0)
116#endif
117
Damien George1463c1f2014-04-25 23:52:57 +0100118// Whether to include doc strings (increases RAM usage)
119#ifndef MICROPY_ENABLE_DOC_STRING
120#define MICROPY_ENABLE_DOC_STRING (0)
121#endif
122
Paul Sokolovsky1f85d622014-05-01 01:35:38 +0300123// Exception messages are short static strings (TODO)
124#define MICROPY_ERROR_REPORTING_TERSE (1)
125// Exception messages provide basic error details
126#define MICROPY_ERROR_REPORTING_NORMAL (2)
127// Exception messages provide full info, e.g. object names
128#define MICROPY_ERROR_REPORTING_DETAILED (3)
129
130#ifndef MICROPY_ERROR_REPORTING
131#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_NORMAL)
132#endif
133
Damien George0c36da02014-03-08 15:24:39 +0000134// Float and complex implementation
135#define MICROPY_FLOAT_IMPL_NONE (0)
136#define MICROPY_FLOAT_IMPL_FLOAT (1)
137#define MICROPY_FLOAT_IMPL_DOUBLE (2)
138
139#ifndef MICROPY_FLOAT_IMPL
140#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_NONE)
141#endif
142
143#if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT
144#define MICROPY_ENABLE_FLOAT (1)
145#define MICROPY_FLOAT_C_FUN(fun) fun##f
146typedef float mp_float_t;
147#elif MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE
148#define MICROPY_ENABLE_FLOAT (1)
149#define MICROPY_FLOAT_C_FUN(fun) fun
150typedef double mp_float_t;
151#else
Damien George136f6752014-01-07 14:54:15 +0000152#define MICROPY_ENABLE_FLOAT (0)
153#endif
154
Damien George107c9fb2014-04-26 10:31:15 +0100155// Whether to provide "collections" module
156#ifndef MICROPY_ENABLE_MOD_COLLECTIONS
157#define MICROPY_ENABLE_MOD_COLLECTIONS (1)
158#endif
159
Damien Georgedbdfee12014-04-17 17:11:03 +0100160// Whether to provide "math" module
161#ifndef MICROPY_ENABLE_MOD_MATH
162#define MICROPY_ENABLE_MOD_MATH (1)
163#endif
164
165// Whether to provide "cmath" module
166#ifndef MICROPY_ENABLE_MOD_CMATH
167#define MICROPY_ENABLE_MOD_CMATH (0)
168#endif
169
Paul Sokolovsky98a627d2014-04-03 14:57:53 +0300170// Whether to provide "io" module
171#ifndef MICROPY_ENABLE_MOD_IO
172#define MICROPY_ENABLE_MOD_IO (1)
173#endif
174
Paul Sokolovskye9db8402014-04-10 03:45:38 +0300175// Whether to provide "struct" module
176#ifndef MICROPY_ENABLE_MOD_STRUCT
177#define MICROPY_ENABLE_MOD_STRUCT (1)
178#endif
179
Paul Sokolovsky5500cde2014-04-13 06:43:18 +0300180// Whether to provide "sys" module
181#ifndef MICROPY_ENABLE_MOD_SYS
182#define MICROPY_ENABLE_MOD_SYS (1)
183#endif
184
Paul Sokolovsky4165cd12014-04-13 07:00:37 +0300185#ifndef MICROPY_MOD_SYS_STDFILES
186#define MICROPY_MOD_SYS_STDFILES (0)
187#endif
188
Damien George136f6752014-01-07 14:54:15 +0000189// Whether to support slice object and correspondingly
190// slice subscript operators
191#ifndef MICROPY_ENABLE_SLICE
192#define MICROPY_ENABLE_SLICE (1)
193#endif
194
Damien George777b0f32014-04-13 18:59:45 +0100195// Whether to support the property object
196#ifndef MICROPY_ENABLE_PROPERTY
Damien Georgec9f6f6b2014-04-17 17:02:30 +0100197#define MICROPY_ENABLE_PROPERTY (1)
Damien George777b0f32014-04-13 18:59:45 +0100198#endif
199
Paul Sokolovskydcac8802014-01-16 19:19:50 +0200200// Enable features which improve CPython compatibility
201// but may lead to more code size/memory usage.
202// TODO: Originally intended as generic category to not
203// add bunch of once-off options. May need refactoring later
204#ifndef MICROPY_CPYTHON_COMPAT
205#define MICROPY_CPYTHON_COMPAT (1)
206#endif
207
Damien George354d15a2014-02-06 21:11:19 +0000208// Maximum length of a path in the filesystem
209// So we can allocate a buffer on the stack for path manipulation in import
210#ifndef MICROPY_PATH_MAX
211#define MICROPY_PATH_MAX (512)
212#endif
213
Damien George3bb8bd82014-04-14 21:20:30 +0100214// Whether to use computed gotos in the VM, or a switch
215// Computed gotos are roughly 10% faster, and increase VM code size by a little
Damien George5b65f0c2014-04-17 23:24:13 +0100216#ifndef MICROPY_USE_COMPUTED_GOTO
217#define MICROPY_USE_COMPUTED_GOTO (0)
Damien George3bb8bd82014-04-14 21:20:30 +0100218#endif
219
Damien Georgecaac5422014-03-25 14:18:18 +0000220// Additional builtin function definitions - see builtintables.c:builtin_object_table for format.
Paul Sokolovsky910843e2014-02-14 12:02:34 +0200221#ifndef MICROPY_EXTRA_BUILTINS
222#define MICROPY_EXTRA_BUILTINS
223#endif
Damien Georgecaac5422014-03-25 14:18:18 +0000224
225// Additional builtin module definitions - see builtintables.c:builtin_module_table for format.
226#ifndef MICROPY_EXTRA_BUILTIN_MODULES
227#define MICROPY_EXTRA_BUILTIN_MODULES
228#endif
229
Damien George57e99eb2014-04-10 22:42:11 +0100230// Additional constant definitions for the compiler - see compile.c:mp_constants_table.
231#ifndef MICROPY_EXTRA_CONSTANTS
232#define MICROPY_EXTRA_CONSTANTS
233#endif
234
Damien George136f6752014-01-07 14:54:15 +0000235/*****************************************************************************/
236/* Miscellaneous settings */
237
Paul Sokolovskyd5df6cd2014-02-12 18:15:40 +0200238// Allow to override static modifier for global objects, e.g. to use with
239// object code analysis tools which don't support static symbols.
240#ifndef STATIC
241#define STATIC static
242#endif
243
Paul Sokolovskyfc5aac82014-01-12 16:10:19 +0200244#define BITS_PER_BYTE (8)
245#define BITS_PER_WORD (BITS_PER_BYTE * BYTES_PER_WORD)
Paul Sokolovskyc260bc52014-01-12 16:15:47 +0200246// machine_int_t value with most significant bit set
Damien George23005372014-01-13 19:39:01 +0000247#define WORD_MSBIT_HIGH (((machine_uint_t)1) << (BYTES_PER_WORD * 8 - 1))
Paul Sokolovskyfc5aac82014-01-12 16:10:19 +0200248
Paul Sokolovsky2da81fa2014-04-11 03:44:00 +0300249#if !defined(MP_ENDIANNESS_LITTLE) && !defined(MP_ENDIANNESS_BIG)
250// Just because most archs are such?
251#define MP_ENDIANNESS_LITTLE (1)
252#endif
Andrew Schellercc837372014-04-14 02:39:56 +0100253// Ensure we don't accidentally set both endiannesses
254#if MP_ENDIANNESS_BIG
255#define MP_ENDIANNESS_LITTLE (0)
256#endif
Paul Sokolovsky2da81fa2014-04-11 03:44:00 +0300257
Paul Sokolovskyc90c0f62014-01-04 01:57:00 +0200258// printf format spec to use for machine_int_t and friends
Damien George136f6752014-01-07 14:54:15 +0000259#ifndef INT_FMT
Paul Sokolovskyc90c0f62014-01-04 01:57:00 +0200260#ifdef __LP64__
261// Archs where machine_int_t == long, long != int
262#define UINT_FMT "%lu"
263#define INT_FMT "%ld"
264#else
265// Archs where machine_int_t == int
266#define UINT_FMT "%u"
267#define INT_FMT "%d"
268#endif
269#endif //INT_FMT
Paul Sokolovskye9085912014-04-30 05:35:18 +0300270
271// Modifier for function which doesn't return
272#define NORETURN __attribute__((noreturn))