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 | 635b60e | 2014-06-28 10:29:52 +0100 | [diff] [blame] | 44 | #define MICROPY_PY_BUILTINS_STR_UNICODE (0) |
Damien George | fb510b3 | 2014-06-01 13:32:54 +0100 | [diff] [blame] | 45 | #define MICROPY_PY_BUILTINS_FROZENSET (1) |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 46 | #define MICROPY_PY_SYS_EXIT (1) |
Paul Sokolovsky | b9b9354 | 2014-06-07 23:40:04 +0300 | [diff] [blame] | 47 | #define MICROPY_PY_SYS_PLATFORM "linux" |
Paul Sokolovsky | 4e0eeeb | 2014-07-03 16:50:11 +0300 | [diff] [blame^] | 48 | #define MICROPY_PY_SYS_MAXSIZE (1) |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 49 | #define MICROPY_PY_SYS_STDFILES (1) |
| 50 | #define MICROPY_PY_CMATH (1) |
| 51 | #define MICROPY_PY_IO_FILEIO (1) |
Paul Sokolovsky | 755a55f | 2014-06-05 22:48:02 +0300 | [diff] [blame] | 52 | #define MICROPY_PY_GC_COLLECT_RETVAL (1) |
Paul Sokolovsky | 1f85d62 | 2014-05-01 01:35:38 +0300 | [diff] [blame] | 53 | // 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 Sokolovsky | 76c8a4c | 2014-06-05 04:32:17 +0300 | [diff] [blame] | 56 | // Define to 1 to use untested inefficient GC helper implementation |
| 57 | // (if more efficient arch-specific one is not available). |
Paul Sokolovsky | 17a4943 | 2014-06-20 20:17:43 +0300 | [diff] [blame] | 58 | #ifndef MICROPY_GCREGS_SETJMP |
Paul Sokolovsky | 76c8a4c | 2014-06-05 04:32:17 +0300 | [diff] [blame] | 59 | #define MICROPY_GCREGS_SETJMP (0) |
Paul Sokolovsky | 17a4943 | 2014-06-20 20:17:43 +0300 | [diff] [blame] | 60 | #endif |
Damien | c025ebb | 2013-10-12 14:30:21 +0100 | [diff] [blame] | 61 | |
Paul Sokolovsky | 0c124c3 | 2014-05-14 22:08:45 +0300 | [diff] [blame] | 62 | extern const struct _mp_obj_module_t mp_module_os; |
Paul Sokolovsky | eb2fc97 | 2014-04-17 18:28:38 +0300 | [diff] [blame] | 63 | extern const struct _mp_obj_module_t mp_module_time; |
Paul Sokolovsky | e1e4249 | 2014-04-17 20:34:04 +0300 | [diff] [blame] | 64 | extern const struct _mp_obj_module_t mp_module_socket; |
Paul Sokolovsky | 4abaa1b | 2014-04-18 00:00:15 +0300 | [diff] [blame] | 65 | extern const struct _mp_obj_module_t mp_module_ffi; |
stijn | f42dbb9 | 2014-05-12 21:46:29 +0200 | [diff] [blame] | 66 | |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 67 | #if MICROPY_PY_FFI |
| 68 | #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] | 69 | #else |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 70 | #define MICROPY_PY_FFI_DEF |
stijn | f42dbb9 | 2014-05-12 21:46:29 +0200 | [diff] [blame] | 71 | #endif |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 72 | #if MICROPY_PY_TIME |
| 73 | #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] | 74 | #else |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 75 | #define MICROPY_PY_TIME_DEF |
stijn | f42dbb9 | 2014-05-12 21:46:29 +0200 | [diff] [blame] | 76 | #endif |
| 77 | |
Damien George | 58ebde4 | 2014-05-21 20:32:59 +0100 | [diff] [blame] | 78 | #define MICROPY_PORT_BUILTIN_MODULES \ |
Damien George | ee3fd46 | 2014-05-24 23:03:12 +0100 | [diff] [blame] | 79 | MICROPY_PY_FFI_DEF \ |
| 80 | MICROPY_PY_TIME_DEF \ |
Paul Sokolovsky | e1e4249 | 2014-04-17 20:34:04 +0300 | [diff] [blame] | 81 | { 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] | 82 | { 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] | 83 | |
Damien | c025ebb | 2013-10-12 14:30:21 +0100 | [diff] [blame] | 84 | // type definitions for the specific machine |
| 85 | |
Paul Sokolovsky | e85c389 | 2013-12-30 03:38:32 +0200 | [diff] [blame] | 86 | #ifdef __LP64__ |
Damien George | 40f3c02 | 2014-07-03 13:25:24 +0100 | [diff] [blame] | 87 | typedef long mp_int_t; // must be pointer size |
| 88 | typedef unsigned long mp_uint_t; // must be pointer size |
Paul Sokolovsky | e85c389 | 2013-12-30 03:38:32 +0200 | [diff] [blame] | 89 | #else |
| 90 | // These are definitions for machines where sizeof(int) == sizeof(void*), |
| 91 | // regardless for actual size. |
Damien George | 40f3c02 | 2014-07-03 13:25:24 +0100 | [diff] [blame] | 92 | typedef int mp_int_t; // must be pointer size |
| 93 | typedef unsigned int mp_uint_t; // must be pointer size |
Paul Sokolovsky | e85c389 | 2013-12-30 03:38:32 +0200 | [diff] [blame] | 94 | #endif |
Damien | d276f63 | 2013-10-22 16:05:47 +0100 | [diff] [blame] | 95 | |
Damien George | 40f3c02 | 2014-07-03 13:25:24 +0100 | [diff] [blame] | 96 | #define BYTES_PER_WORD sizeof(mp_int_t) |
Paul Sokolovsky | e85c389 | 2013-12-30 03:38:32 +0200 | [diff] [blame] | 97 | |
Damien | c025ebb | 2013-10-12 14:30:21 +0100 | [diff] [blame] | 98 | typedef void *machine_ptr_t; // must be of pointer size |
Damien | d99b052 | 2013-12-21 18:17:45 +0000 | [diff] [blame] | 99 | typedef const void *machine_const_ptr_t; // must be of pointer size |
Paul Sokolovsky | 910843e | 2014-02-14 12:02:34 +0200 | [diff] [blame] | 100 | |
Dave Hylands | 117c46d | 2014-05-07 07:15:00 -0700 | [diff] [blame] | 101 | extern const struct _mp_obj_fun_native_t mp_builtin_input_obj; |
Paul Sokolovsky | 910843e | 2014-02-14 12:02:34 +0200 | [diff] [blame] | 102 | extern const struct _mp_obj_fun_native_t mp_builtin_open_obj; |
Damien George | 58ebde4 | 2014-05-21 20:32:59 +0100 | [diff] [blame] | 103 | #define MICROPY_PORT_BUILTINS \ |
Dave Hylands | 117c46d | 2014-05-07 07:15:00 -0700 | [diff] [blame] | 104 | { 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] | 105 | { 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] | 106 | |
Damien George | 4480cb3 | 2014-06-08 13:25:33 +0100 | [diff] [blame] | 107 | // We need to provide a declaration/definition of alloca() |
Marcus von Appen | 0c90eb1 | 2014-06-07 09:36:04 +0200 | [diff] [blame] | 108 | #ifdef __FreeBSD__ |
| 109 | #include <stdlib.h> |
| 110 | #else |
| 111 | #include <alloca.h> |
| 112 | #endif |