Damien George | 04b9147 | 2014-05-03 23:27:38 +0100 | [diff] [blame] | 1 | /* |
| 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 | |
Damien | c025ebb | 2013-10-12 14:30:21 +0100 | [diff] [blame] | 27 | // options to control how Micro Python is built |
| 28 | |
Damien George | 58ebde4 | 2014-05-21 20:32:59 +0100 | [diff] [blame] | 29 | #define MICROPY_ALLOC_PATH_MAX (PATH_MAX) |
Damien | d2755ec | 2013-10-16 23:58:48 +0100 | [diff] [blame] | 30 | #define MICROPY_EMIT_X64 (1) |
Damien | 3ef4abb | 2013-10-12 16:53:13 +0100 | [diff] [blame] | 31 | #define MICROPY_EMIT_THUMB (0) |
| 32 | #define MICROPY_EMIT_INLINE_THUMB (0) |
Paul Sokolovsky | 78e8e30 | 2014-04-02 20:57:19 +0300 | [diff] [blame] | 33 | #define MICROPY_ENABLE_GC (1) |
Damien George | 12bab72 | 2014-04-05 20:35:48 +0100 | [diff] [blame] | 34 | #define MICROPY_ENABLE_FINALISER (1) |
Damien George | 136f675 | 2014-01-07 14:54:15 +0000 | [diff] [blame] | 35 | #define MICROPY_MEM_STATS (1) |
Damien George | cbd2f74 | 2014-01-19 11:48:48 +0000 | [diff] [blame] | 36 | #define MICROPY_DEBUG_PRINTERS (1) |
Damien George | 58ebde4 | 2014-05-21 20:32:59 +0100 | [diff] [blame] | 37 | #define MICROPY_HELPER_REPL (1) |
| 38 | #define MICROPY_HELPER_LEXER_UNIX (1) |
Damien George | 62ad189 | 2014-01-29 21:51:51 +0000 | [diff] [blame] | 39 | #define MICROPY_ENABLE_SOURCE_LINE (1) |
Damien George | 0c36da0 | 2014-03-08 15:24:39 +0000 | [diff] [blame] | 40 | #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_DOUBLE) |
Damien George | 438c88d | 2014-02-22 19:25:23 +0000 | [diff] [blame] | 41 | #define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ) |
Paul Sokolovsky | 0ef015b | 2014-05-07 02:23:46 +0300 | [diff] [blame] | 42 | #define MICROPY_STREAMS_NON_BLOCK (1) |
Damien George | 58ebde4 | 2014-05-21 20:32:59 +0100 | [diff] [blame] | 43 | #define MICROPY_OPT_COMPUTED_GOTO (1) |
Damien George | fb510b3 | 2014-06-01 13:32:54 +0100 | [diff] [blame] | 44 | #define MICROPY_PY_BUILTINS_FROZENSET (1) |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 45 | #define MICROPY_PY_SYS_EXIT (1) |
Paul Sokolovsky | b9b9354 | 2014-06-07 23:40:04 +0300 | [diff] [blame] | 46 | #define MICROPY_PY_SYS_PLATFORM "linux" |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 47 | #define MICROPY_PY_SYS_STDFILES (1) |
| 48 | #define MICROPY_PY_CMATH (1) |
| 49 | #define MICROPY_PY_IO_FILEIO (1) |
Paul Sokolovsky | 755a55f | 2014-06-05 22:48:02 +0300 | [diff] [blame] | 50 | #define MICROPY_PY_GC_COLLECT_RETVAL (1) |
Paul Sokolovsky | 1f85d62 | 2014-05-01 01:35:38 +0300 | [diff] [blame] | 51 | // Define to MICROPY_ERROR_REPORTING_DETAILED to get function, etc. |
| 52 | // names in exception messages (may require more RAM). |
| 53 | #define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_DETAILED) |
Paul Sokolovsky | 76c8a4c | 2014-06-05 04:32:17 +0300 | [diff] [blame] | 54 | // Define to 1 to use untested inefficient GC helper implementation |
| 55 | // (if more efficient arch-specific one is not available). |
| 56 | #define MICROPY_GCREGS_SETJMP (0) |
Damien | c025ebb | 2013-10-12 14:30:21 +0100 | [diff] [blame] | 57 | |
Paul Sokolovsky | 0c124c3 | 2014-05-14 22:08:45 +0300 | [diff] [blame] | 58 | extern const struct _mp_obj_module_t mp_module_os; |
Paul Sokolovsky | eb2fc97 | 2014-04-17 18:28:38 +0300 | [diff] [blame] | 59 | extern const struct _mp_obj_module_t mp_module_time; |
Paul Sokolovsky | e1e4249 | 2014-04-17 20:34:04 +0300 | [diff] [blame] | 60 | extern const struct _mp_obj_module_t mp_module_socket; |
Paul Sokolovsky | 4abaa1b | 2014-04-18 00:00:15 +0300 | [diff] [blame] | 61 | extern const struct _mp_obj_module_t mp_module_ffi; |
stijn | f42dbb9 | 2014-05-12 21:46:29 +0200 | [diff] [blame] | 62 | |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 63 | #if MICROPY_PY_FFI |
| 64 | #define MICROPY_PY_FFI_DEF { MP_OBJ_NEW_QSTR(MP_QSTR_ffi), (mp_obj_t)&mp_module_ffi }, |
stijn | f42dbb9 | 2014-05-12 21:46:29 +0200 | [diff] [blame] | 65 | #else |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 66 | #define MICROPY_PY_FFI_DEF |
stijn | f42dbb9 | 2014-05-12 21:46:29 +0200 | [diff] [blame] | 67 | #endif |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 68 | #if MICROPY_PY_TIME |
| 69 | #define MICROPY_PY_TIME_DEF { MP_OBJ_NEW_QSTR(MP_QSTR_time), (mp_obj_t)&mp_module_time }, |
stijn | f42dbb9 | 2014-05-12 21:46:29 +0200 | [diff] [blame] | 70 | #else |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 71 | #define MICROPY_PY_TIME_DEF |
stijn | f42dbb9 | 2014-05-12 21:46:29 +0200 | [diff] [blame] | 72 | #endif |
| 73 | |
Damien George | 58ebde4 | 2014-05-21 20:32:59 +0100 | [diff] [blame] | 74 | #define MICROPY_PORT_BUILTIN_MODULES \ |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 75 | MICROPY_PY_FFI_DEF \ |
| 76 | MICROPY_PY_TIME_DEF \ |
Paul Sokolovsky | e1e4249 | 2014-04-17 20:34:04 +0300 | [diff] [blame] | 77 | { MP_OBJ_NEW_QSTR(MP_QSTR_microsocket), (mp_obj_t)&mp_module_socket }, \ |
Paul Sokolovsky | 0c124c3 | 2014-05-14 22:08:45 +0300 | [diff] [blame] | 78 | { MP_OBJ_NEW_QSTR(MP_QSTR__os), (mp_obj_t)&mp_module_os }, \ |
Paul Sokolovsky | eb2fc97 | 2014-04-17 18:28:38 +0300 | [diff] [blame] | 79 | |
Damien | c025ebb | 2013-10-12 14:30:21 +0100 | [diff] [blame] | 80 | // type definitions for the specific machine |
| 81 | |
Paul Sokolovsky | e85c389 | 2013-12-30 03:38:32 +0200 | [diff] [blame] | 82 | #ifdef __LP64__ |
| 83 | typedef long machine_int_t; // must be pointer size |
| 84 | typedef unsigned long machine_uint_t; // must be pointer size |
Paul Sokolovsky | e85c389 | 2013-12-30 03:38:32 +0200 | [diff] [blame] | 85 | #else |
| 86 | // These are definitions for machines where sizeof(int) == sizeof(void*), |
| 87 | // regardless for actual size. |
| 88 | typedef int machine_int_t; // must be pointer size |
| 89 | typedef unsigned int machine_uint_t; // must be pointer size |
Paul Sokolovsky | e85c389 | 2013-12-30 03:38:32 +0200 | [diff] [blame] | 90 | #endif |
Damien | d276f63 | 2013-10-22 16:05:47 +0100 | [diff] [blame] | 91 | |
Paul Sokolovsky | e85c389 | 2013-12-30 03:38:32 +0200 | [diff] [blame] | 92 | #define BYTES_PER_WORD sizeof(machine_int_t) |
| 93 | |
Damien | c025ebb | 2013-10-12 14:30:21 +0100 | [diff] [blame] | 94 | typedef void *machine_ptr_t; // must be of pointer size |
Damien | d99b052 | 2013-12-21 18:17:45 +0000 | [diff] [blame] | 95 | typedef const void *machine_const_ptr_t; // must be of pointer size |
Paul Sokolovsky | 910843e | 2014-02-14 12:02:34 +0200 | [diff] [blame] | 96 | |
Dave Hylands | 117c46d | 2014-05-07 07:15:00 -0700 | [diff] [blame] | 97 | extern const struct _mp_obj_fun_native_t mp_builtin_input_obj; |
Paul Sokolovsky | 910843e | 2014-02-14 12:02:34 +0200 | [diff] [blame] | 98 | extern const struct _mp_obj_fun_native_t mp_builtin_open_obj; |
Damien George | 58ebde4 | 2014-05-21 20:32:59 +0100 | [diff] [blame] | 99 | #define MICROPY_PORT_BUILTINS \ |
Dave Hylands | 117c46d | 2014-05-07 07:15:00 -0700 | [diff] [blame] | 100 | { MP_OBJ_NEW_QSTR(MP_QSTR_input), (mp_obj_t)&mp_builtin_input_obj }, \ |
Damien George | 7efc5b3 | 2014-04-05 22:36:42 +0100 | [diff] [blame] | 101 | { MP_OBJ_NEW_QSTR(MP_QSTR_open), (mp_obj_t)&mp_builtin_open_obj }, |
Marcus von Appen | 0c90eb1 | 2014-06-07 09:36:04 +0200 | [diff] [blame] | 102 | |
Damien George | 4480cb3 | 2014-06-08 13:25:33 +0100 | [diff] [blame^] | 103 | // We need to provide a declaration/definition of alloca() |
Marcus von Appen | 0c90eb1 | 2014-06-07 09:36:04 +0200 | [diff] [blame] | 104 | #ifdef __FreeBSD__ |
| 105 | #include <stdlib.h> |
| 106 | #else |
| 107 | #include <alloca.h> |
| 108 | #endif |