blob: 98132ac6e74127f5eea688c0d74645f704c218f1 [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
Damienc025ebb2013-10-12 14:30:21 +010027// options to control how Micro Python is built
28
Damien George58ebde42014-05-21 20:32:59 +010029#define MICROPY_ALLOC_PATH_MAX (PATH_MAX)
Damiend2755ec2013-10-16 23:58:48 +010030#define MICROPY_EMIT_X64 (1)
Damien3ef4abb2013-10-12 16:53:13 +010031#define MICROPY_EMIT_THUMB (0)
32#define MICROPY_EMIT_INLINE_THUMB (0)
Paul Sokolovsky78e8e302014-04-02 20:57:19 +030033#define MICROPY_ENABLE_GC (1)
Damien George12bab722014-04-05 20:35:48 +010034#define MICROPY_ENABLE_FINALISER (1)
Damien George136f6752014-01-07 14:54:15 +000035#define MICROPY_MEM_STATS (1)
Damien Georgecbd2f742014-01-19 11:48:48 +000036#define MICROPY_DEBUG_PRINTERS (1)
Damien George58ebde42014-05-21 20:32:59 +010037#define MICROPY_HELPER_REPL (1)
38#define MICROPY_HELPER_LEXER_UNIX (1)
Damien George62ad1892014-01-29 21:51:51 +000039#define MICROPY_ENABLE_SOURCE_LINE (1)
Damien George0c36da02014-03-08 15:24:39 +000040#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_DOUBLE)
Damien George438c88d2014-02-22 19:25:23 +000041#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ)
Paul Sokolovsky0ef015b2014-05-07 02:23:46 +030042#define MICROPY_STREAMS_NON_BLOCK (1)
Damien George58ebde42014-05-21 20:32:59 +010043#define MICROPY_OPT_COMPUTED_GOTO (1)
Damien George635b60e2014-06-28 10:29:52 +010044#define MICROPY_PY_BUILTINS_STR_UNICODE (0)
Damien Georgefb510b32014-06-01 13:32:54 +010045#define MICROPY_PY_BUILTINS_FROZENSET (1)
Damien Georgeee3fd462014-05-24 23:03:12 +010046#define MICROPY_PY_SYS_EXIT (1)
Paul Sokolovskyb9b93542014-06-07 23:40:04 +030047#define MICROPY_PY_SYS_PLATFORM "linux"
Paul Sokolovsky4e0eeeb2014-07-03 16:50:11 +030048#define MICROPY_PY_SYS_MAXSIZE (1)
Damien Georgeee3fd462014-05-24 23:03:12 +010049#define MICROPY_PY_SYS_STDFILES (1)
50#define MICROPY_PY_CMATH (1)
51#define MICROPY_PY_IO_FILEIO (1)
Paul Sokolovsky755a55f2014-06-05 22:48:02 +030052#define MICROPY_PY_GC_COLLECT_RETVAL (1)
Paul Sokolovsky1f85d622014-05-01 01:35:38 +030053// Define to MICROPY_ERROR_REPORTING_DETAILED to get function, etc.
54// names in exception messages (may require more RAM).
55#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_DETAILED)
Paul Sokolovsky76c8a4c2014-06-05 04:32:17 +030056// Define to 1 to use untested inefficient GC helper implementation
57// (if more efficient arch-specific one is not available).
Paul Sokolovsky17a49432014-06-20 20:17:43 +030058#ifndef MICROPY_GCREGS_SETJMP
Paul Sokolovsky76c8a4c2014-06-05 04:32:17 +030059#define MICROPY_GCREGS_SETJMP (0)
Paul Sokolovsky17a49432014-06-20 20:17:43 +030060#endif
Damienc025ebb2013-10-12 14:30:21 +010061
Paul Sokolovsky0c124c32014-05-14 22:08:45 +030062extern const struct _mp_obj_module_t mp_module_os;
Paul Sokolovskyeb2fc972014-04-17 18:28:38 +030063extern const struct _mp_obj_module_t mp_module_time;
Paul Sokolovskye1e42492014-04-17 20:34:04 +030064extern const struct _mp_obj_module_t mp_module_socket;
Paul Sokolovsky4abaa1b2014-04-18 00:00:15 +030065extern const struct _mp_obj_module_t mp_module_ffi;
stijnf42dbb92014-05-12 21:46:29 +020066
Damien Georgeee3fd462014-05-24 23:03:12 +010067#if MICROPY_PY_FFI
68#define MICROPY_PY_FFI_DEF { MP_OBJ_NEW_QSTR(MP_QSTR_ffi), (mp_obj_t)&mp_module_ffi },
stijnf42dbb92014-05-12 21:46:29 +020069#else
Damien Georgeee3fd462014-05-24 23:03:12 +010070#define MICROPY_PY_FFI_DEF
stijnf42dbb92014-05-12 21:46:29 +020071#endif
Damien Georgeee3fd462014-05-24 23:03:12 +010072#if MICROPY_PY_TIME
73#define MICROPY_PY_TIME_DEF { MP_OBJ_NEW_QSTR(MP_QSTR_time), (mp_obj_t)&mp_module_time },
stijnf42dbb92014-05-12 21:46:29 +020074#else
Damien Georgeee3fd462014-05-24 23:03:12 +010075#define MICROPY_PY_TIME_DEF
stijnf42dbb92014-05-12 21:46:29 +020076#endif
77
Damien George58ebde42014-05-21 20:32:59 +010078#define MICROPY_PORT_BUILTIN_MODULES \
Damien Georgeee3fd462014-05-24 23:03:12 +010079 MICROPY_PY_FFI_DEF \
80 MICROPY_PY_TIME_DEF \
Paul Sokolovskye1e42492014-04-17 20:34:04 +030081 { MP_OBJ_NEW_QSTR(MP_QSTR_microsocket), (mp_obj_t)&mp_module_socket }, \
Paul Sokolovsky0c124c32014-05-14 22:08:45 +030082 { MP_OBJ_NEW_QSTR(MP_QSTR__os), (mp_obj_t)&mp_module_os }, \
Paul Sokolovskyeb2fc972014-04-17 18:28:38 +030083
Damienc025ebb2013-10-12 14:30:21 +010084// type definitions for the specific machine
85
Paul Sokolovskye85c3892013-12-30 03:38:32 +020086#ifdef __LP64__
Damien George40f3c022014-07-03 13:25:24 +010087typedef long mp_int_t; // must be pointer size
88typedef unsigned long mp_uint_t; // must be pointer size
Paul Sokolovskye85c3892013-12-30 03:38:32 +020089#else
90// These are definitions for machines where sizeof(int) == sizeof(void*),
91// regardless for actual size.
Damien George40f3c022014-07-03 13:25:24 +010092typedef int mp_int_t; // must be pointer size
93typedef unsigned int mp_uint_t; // must be pointer size
Paul Sokolovskye85c3892013-12-30 03:38:32 +020094#endif
Damiend276f632013-10-22 16:05:47 +010095
Damien George40f3c022014-07-03 13:25:24 +010096#define BYTES_PER_WORD sizeof(mp_int_t)
Paul Sokolovskye85c3892013-12-30 03:38:32 +020097
Damienc025ebb2013-10-12 14:30:21 +010098typedef void *machine_ptr_t; // must be of pointer size
Damiend99b0522013-12-21 18:17:45 +000099typedef const void *machine_const_ptr_t; // must be of pointer size
Paul Sokolovsky910843e2014-02-14 12:02:34 +0200100
Dave Hylands117c46d2014-05-07 07:15:00 -0700101extern const struct _mp_obj_fun_native_t mp_builtin_input_obj;
Paul Sokolovsky910843e2014-02-14 12:02:34 +0200102extern const struct _mp_obj_fun_native_t mp_builtin_open_obj;
Damien George58ebde42014-05-21 20:32:59 +0100103#define MICROPY_PORT_BUILTINS \
Dave Hylands117c46d2014-05-07 07:15:00 -0700104 { MP_OBJ_NEW_QSTR(MP_QSTR_input), (mp_obj_t)&mp_builtin_input_obj }, \
Damien George7efc5b32014-04-05 22:36:42 +0100105 { MP_OBJ_NEW_QSTR(MP_QSTR_open), (mp_obj_t)&mp_builtin_open_obj },
Marcus von Appen0c90eb12014-06-07 09:36:04 +0200106
Damien George4480cb32014-06-08 13:25:33 +0100107// We need to provide a declaration/definition of alloca()
Marcus von Appen0c90eb12014-06-07 09:36:04 +0200108#ifdef __FreeBSD__
109#include <stdlib.h>
110#else
111#include <alloca.h>
112#endif