mpconfig.h 53 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694
  1. /*
  2. * This file is part of the MicroPython 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. #ifndef MICROPY_INCLUDED_PY_MPCONFIG_H
  27. #define MICROPY_INCLUDED_PY_MPCONFIG_H
  28. // Current version of MicroPython
  29. #define MICROPY_VERSION_MAJOR 1
  30. #define MICROPY_VERSION_MINOR 13
  31. #define MICROPY_VERSION_MICRO 0
  32. // Combined version as a 32-bit number for convenience
  33. #define MICROPY_VERSION ( \
  34. MICROPY_VERSION_MAJOR << 16 \
  35. | MICROPY_VERSION_MINOR << 8 \
  36. | MICROPY_VERSION_MICRO)
  37. // String version
  38. #define MICROPY_VERSION_STRING \
  39. MP_STRINGIFY(MICROPY_VERSION_MAJOR) "." \
  40. MP_STRINGIFY(MICROPY_VERSION_MINOR) "." \
  41. MP_STRINGIFY(MICROPY_VERSION_MICRO)
  42. // This file contains default configuration settings for MicroPython.
  43. // You can override any of the options below using mpconfigport.h file
  44. // located in a directory of your port.
  45. // mpconfigport.h is a file containing configuration settings for a
  46. // particular port. mpconfigport.h is actually a default name for
  47. // such config, and it can be overridden using MP_CONFIGFILE preprocessor
  48. // define (you can do that by passing CFLAGS_EXTRA='-DMP_CONFIGFILE="<file.h>"'
  49. // argument to make when using standard MicroPython makefiles).
  50. // This is useful to have more than one config per port, for example,
  51. // release vs debug configs, etc. Note that if you switch from one config
  52. // to another, you must rebuild from scratch using "-B" switch to make.
  53. #ifdef MP_CONFIGFILE
  54. #include MP_CONFIGFILE
  55. #else
  56. #include <mpconfigport.h>
  57. #endif
  58. // Any options not explicitly set in mpconfigport.h will get default
  59. // values below.
  60. /*****************************************************************************/
  61. /* Object representation */
  62. // A MicroPython object is a machine word having the following form:
  63. // - xxxx...xxx1 : a small int, bits 1 and above are the value
  64. // - xxxx...x010 : a qstr, bits 3 and above are the value
  65. // - xxxx...x110 : an immediate object, bits 3 and above are the value
  66. // - xxxx...xx00 : a pointer to an mp_obj_base_t (unless a fake object)
  67. #define MICROPY_OBJ_REPR_A (0)
  68. // A MicroPython object is a machine word having the following form:
  69. // - xxxx...xx01 : a small int, bits 2 and above are the value
  70. // - xxxx...x011 : a qstr, bits 3 and above are the value
  71. // - xxxx...x111 : an immediate object, bits 3 and above are the value
  72. // - xxxx...xxx0 : a pointer to an mp_obj_base_t (unless a fake object)
  73. #define MICROPY_OBJ_REPR_B (1)
  74. // A MicroPython object is a machine word having the following form (called R):
  75. // - iiiiiiii iiiiiiii iiiiiiii iiiiiii1 small int with 31-bit signed value
  76. // - 01111111 1qqqqqqq qqqqqqqq qqqq0110 str with 19-bit qstr value
  77. // - 01111111 10000000 00000000 ssss1110 immediate object with 4-bit value
  78. // - s1111111 10000000 00000000 00000010 +/- inf
  79. // - s1111111 1xxxxxxx xxxxxxxx xxxxx010 nan, x != 0
  80. // - seeeeeee efffffff ffffffff ffffff10 30-bit fp, e != 0xff
  81. // - pppppppp pppppppp pppppppp pppppp00 ptr (4 byte alignment)
  82. // Str, immediate and float stored as O = R + 0x80800000, retrieved as R = O - 0x80800000.
  83. // This makes strs/immediates easier to encode/decode as they have zeros in the top 9 bits.
  84. // This scheme only works with 32-bit word size and float enabled.
  85. #define MICROPY_OBJ_REPR_C (2)
  86. // A MicroPython object is a 64-bit word having the following form (called R):
  87. // - seeeeeee eeeeffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff 64-bit fp, e != 0x7ff
  88. // - s1111111 11110000 00000000 00000000 00000000 00000000 00000000 00000000 +/- inf
  89. // - 01111111 11111000 00000000 00000000 00000000 00000000 00000000 00000000 normalised nan
  90. // - 01111111 11111101 iiiiiiii iiiiiiii iiiiiiii iiiiiiii iiiiiiii iiiiiii1 small int
  91. // - 01111111 11111110 00000000 00000000 qqqqqqqq qqqqqqqq qqqqqqqq qqqqqqq1 str
  92. // - 01111111 11111111 ss000000 00000000 00000000 00000000 00000000 00000000 immediate object
  93. // - 01111111 11111100 00000000 00000000 pppppppp pppppppp pppppppp pppppp00 ptr (4 byte alignment)
  94. // Stored as O = R + 0x8004000000000000, retrieved as R = O - 0x8004000000000000.
  95. // This makes pointers have all zeros in the top 32 bits.
  96. // Small-ints and strs have 1 as LSB to make sure they don't look like pointers
  97. // to the garbage collector.
  98. #define MICROPY_OBJ_REPR_D (3)
  99. #ifndef MICROPY_OBJ_REPR
  100. #define MICROPY_OBJ_REPR (MICROPY_OBJ_REPR_A)
  101. #endif
  102. // Whether to encode None/False/True as immediate objects instead of pointers to
  103. // real objects. Reduces code size by a decent amount without hurting
  104. // performance, for all representations except D on some architectures.
  105. #ifndef MICROPY_OBJ_IMMEDIATE_OBJS
  106. #define MICROPY_OBJ_IMMEDIATE_OBJS (MICROPY_OBJ_REPR != MICROPY_OBJ_REPR_D)
  107. #endif
  108. /*****************************************************************************/
  109. /* Memory allocation policy */
  110. // Number of bytes in memory allocation/GC block. Any size allocated will be
  111. // rounded up to be multiples of this.
  112. #ifndef MICROPY_BYTES_PER_GC_BLOCK
  113. #define MICROPY_BYTES_PER_GC_BLOCK (4 * BYTES_PER_WORD)
  114. #endif
  115. // Number of words allocated (in BSS) to the GC stack (minimum is 1)
  116. #ifndef MICROPY_ALLOC_GC_STACK_SIZE
  117. #define MICROPY_ALLOC_GC_STACK_SIZE (64)
  118. #endif
  119. // The C-type to use for entries in the GC stack. By default it allows the
  120. // heap to be as large as the address space, but the bit-width of this type can
  121. // be reduced to save memory when the heap is small enough. The type must be
  122. // big enough to index all blocks in the heap, which is set by
  123. // heap-size-in-bytes / MICROPY_BYTES_PER_GC_BLOCK.
  124. #ifndef MICROPY_GC_STACK_ENTRY_TYPE
  125. #define MICROPY_GC_STACK_ENTRY_TYPE size_t
  126. #endif
  127. // Be conservative and always clear to zero newly (re)allocated memory in the GC.
  128. // This helps eliminate stray pointers that hold on to memory that's no longer
  129. // used. It decreases performance due to unnecessary memory clearing.
  130. // A memory manager which always clears memory can set this to 0.
  131. // TODO Do analysis to understand why some memory is not properly cleared and
  132. // find a more efficient way to clear it.
  133. #ifndef MICROPY_GC_CONSERVATIVE_CLEAR
  134. #define MICROPY_GC_CONSERVATIVE_CLEAR (MICROPY_ENABLE_GC)
  135. #endif
  136. // Support automatic GC when reaching allocation threshold,
  137. // configurable by gc.threshold().
  138. #ifndef MICROPY_GC_ALLOC_THRESHOLD
  139. #define MICROPY_GC_ALLOC_THRESHOLD (1)
  140. #endif
  141. // Number of bytes to allocate initially when creating new chunks to store
  142. // interned string data. Smaller numbers lead to more chunks being needed
  143. // and more wastage at the end of the chunk. Larger numbers lead to wasted
  144. // space at the end when no more strings need interning.
  145. #ifndef MICROPY_ALLOC_QSTR_CHUNK_INIT
  146. #define MICROPY_ALLOC_QSTR_CHUNK_INIT (128)
  147. #endif
  148. // Initial amount for lexer indentation level
  149. #ifndef MICROPY_ALLOC_LEXER_INDENT_INIT
  150. #define MICROPY_ALLOC_LEXER_INDENT_INIT (10)
  151. #endif
  152. // Increment for lexer indentation level
  153. #ifndef MICROPY_ALLOC_LEXEL_INDENT_INC
  154. #define MICROPY_ALLOC_LEXEL_INDENT_INC (8)
  155. #endif
  156. // Initial amount for parse rule stack
  157. #ifndef MICROPY_ALLOC_PARSE_RULE_INIT
  158. #define MICROPY_ALLOC_PARSE_RULE_INIT (64)
  159. #endif
  160. // Increment for parse rule stack
  161. #ifndef MICROPY_ALLOC_PARSE_RULE_INC
  162. #define MICROPY_ALLOC_PARSE_RULE_INC (16)
  163. #endif
  164. // Initial amount for parse result stack
  165. #ifndef MICROPY_ALLOC_PARSE_RESULT_INIT
  166. #define MICROPY_ALLOC_PARSE_RESULT_INIT (32)
  167. #endif
  168. // Increment for parse result stack
  169. #ifndef MICROPY_ALLOC_PARSE_RESULT_INC
  170. #define MICROPY_ALLOC_PARSE_RESULT_INC (16)
  171. #endif
  172. // Strings this length or less will be interned by the parser
  173. #ifndef MICROPY_ALLOC_PARSE_INTERN_STRING_LEN
  174. #define MICROPY_ALLOC_PARSE_INTERN_STRING_LEN (10)
  175. #endif
  176. // Number of bytes to allocate initially when creating new chunks to store
  177. // parse nodes. Small leads to fragmentation, large leads to excess use.
  178. #ifndef MICROPY_ALLOC_PARSE_CHUNK_INIT
  179. #define MICROPY_ALLOC_PARSE_CHUNK_INIT (128)
  180. #endif
  181. // Initial amount for ids in a scope
  182. #ifndef MICROPY_ALLOC_SCOPE_ID_INIT
  183. #define MICROPY_ALLOC_SCOPE_ID_INIT (4)
  184. #endif
  185. // Increment for ids in a scope
  186. #ifndef MICROPY_ALLOC_SCOPE_ID_INC
  187. #define MICROPY_ALLOC_SCOPE_ID_INC (6)
  188. #endif
  189. // Maximum length of a path in the filesystem
  190. // So we can allocate a buffer on the stack for path manipulation in import
  191. #ifndef MICROPY_ALLOC_PATH_MAX
  192. #define MICROPY_ALLOC_PATH_MAX (512)
  193. #endif
  194. // Initial size of module dict
  195. #ifndef MICROPY_MODULE_DICT_SIZE
  196. #define MICROPY_MODULE_DICT_SIZE (1)
  197. #endif
  198. // Whether realloc/free should be passed allocated memory region size
  199. // You must enable this if MICROPY_MEM_STATS is enabled
  200. #ifndef MICROPY_MALLOC_USES_ALLOCATED_SIZE
  201. #define MICROPY_MALLOC_USES_ALLOCATED_SIZE (0)
  202. #endif
  203. // Number of bytes used to store qstr length
  204. // Dictates hard limit on maximum Python identifier length, but 1 byte
  205. // (limit of 255 bytes in an identifier) should be enough for everyone
  206. #ifndef MICROPY_QSTR_BYTES_IN_LEN
  207. #define MICROPY_QSTR_BYTES_IN_LEN (1)
  208. #endif
  209. // Number of bytes used to store qstr hash
  210. #ifndef MICROPY_QSTR_BYTES_IN_HASH
  211. #define MICROPY_QSTR_BYTES_IN_HASH (2)
  212. #endif
  213. // Avoid using C stack when making Python function calls. C stack still
  214. // may be used if there's no free heap.
  215. #ifndef MICROPY_STACKLESS
  216. #define MICROPY_STACKLESS (0)
  217. #endif
  218. // Never use C stack when making Python function calls. This may break
  219. // testsuite as will subtly change which exception is thrown in case
  220. // of too deep recursion and other similar cases.
  221. #ifndef MICROPY_STACKLESS_STRICT
  222. #define MICROPY_STACKLESS_STRICT (0)
  223. #endif
  224. // Don't use alloca calls. As alloca() is not part of ANSI C, this
  225. // workaround option is provided for compilers lacking this de-facto
  226. // standard function. The way it works is allocating from heap, and
  227. // relying on garbage collection to free it eventually. This is of
  228. // course much less optimal than real alloca().
  229. #if defined(MICROPY_NO_ALLOCA) && MICROPY_NO_ALLOCA
  230. #undef alloca
  231. #define alloca(x) m_malloc(x)
  232. #endif
  233. /*****************************************************************************/
  234. /* MicroPython emitters */
  235. // Whether to support loading of persistent code
  236. #ifndef MICROPY_PERSISTENT_CODE_LOAD
  237. #define MICROPY_PERSISTENT_CODE_LOAD (0)
  238. #endif
  239. // Whether to support saving of persistent code
  240. #ifndef MICROPY_PERSISTENT_CODE_SAVE
  241. #define MICROPY_PERSISTENT_CODE_SAVE (0)
  242. #endif
  243. // Whether generated code can persist independently of the VM/runtime instance
  244. // This is enabled automatically when needed by other features
  245. #ifndef MICROPY_PERSISTENT_CODE
  246. #define MICROPY_PERSISTENT_CODE (MICROPY_PERSISTENT_CODE_LOAD || MICROPY_PERSISTENT_CODE_SAVE || MICROPY_MODULE_FROZEN_MPY)
  247. #endif
  248. // Whether to emit x64 native code
  249. #ifndef MICROPY_EMIT_X64
  250. #define MICROPY_EMIT_X64 (0)
  251. #endif
  252. // Whether to emit x86 native code
  253. #ifndef MICROPY_EMIT_X86
  254. #define MICROPY_EMIT_X86 (0)
  255. #endif
  256. // Whether to emit thumb native code
  257. #ifndef MICROPY_EMIT_THUMB
  258. #define MICROPY_EMIT_THUMB (0)
  259. #endif
  260. // Whether to enable the thumb inline assembler
  261. #ifndef MICROPY_EMIT_INLINE_THUMB
  262. #define MICROPY_EMIT_INLINE_THUMB (0)
  263. #endif
  264. // Whether to enable ARMv7-M instruction support in the Thumb2 inline assembler
  265. #ifndef MICROPY_EMIT_INLINE_THUMB_ARMV7M
  266. #define MICROPY_EMIT_INLINE_THUMB_ARMV7M (1)
  267. #endif
  268. // Whether to enable float support in the Thumb2 inline assembler
  269. #ifndef MICROPY_EMIT_INLINE_THUMB_FLOAT
  270. #define MICROPY_EMIT_INLINE_THUMB_FLOAT (1)
  271. #endif
  272. // Whether to emit ARM native code
  273. #ifndef MICROPY_EMIT_ARM
  274. #define MICROPY_EMIT_ARM (0)
  275. #endif
  276. // Whether to emit Xtensa native code
  277. #ifndef MICROPY_EMIT_XTENSA
  278. #define MICROPY_EMIT_XTENSA (0)
  279. #endif
  280. // Whether to enable the Xtensa inline assembler
  281. #ifndef MICROPY_EMIT_INLINE_XTENSA
  282. #define MICROPY_EMIT_INLINE_XTENSA (0)
  283. #endif
  284. // Whether to emit Xtensa-Windowed native code
  285. #ifndef MICROPY_EMIT_XTENSAWIN
  286. #define MICROPY_EMIT_XTENSAWIN (0)
  287. #endif
  288. // Convenience definition for whether any native emitter is enabled
  289. #define MICROPY_EMIT_NATIVE (MICROPY_EMIT_X64 || MICROPY_EMIT_X86 || MICROPY_EMIT_THUMB || MICROPY_EMIT_ARM || MICROPY_EMIT_XTENSA || MICROPY_EMIT_XTENSAWIN)
  290. // Select prelude-as-bytes-object for certain emitters
  291. #define MICROPY_EMIT_NATIVE_PRELUDE_AS_BYTES_OBJ (MICROPY_EMIT_XTENSAWIN)
  292. // Convenience definition for whether any inline assembler emitter is enabled
  293. #define MICROPY_EMIT_INLINE_ASM (MICROPY_EMIT_INLINE_THUMB || MICROPY_EMIT_INLINE_XTENSA)
  294. // Convenience definition for whether any native or inline assembler emitter is enabled
  295. #define MICROPY_EMIT_MACHINE_CODE (MICROPY_EMIT_NATIVE || MICROPY_EMIT_INLINE_ASM)
  296. // Whether native relocatable code loaded from .mpy files is explicitly tracked
  297. // so that the GC cannot reclaim it. Needed on architectures that allocate
  298. // executable memory on the MicroPython heap and don't explicitly track this
  299. // data some other way.
  300. #ifndef MICROPY_PERSISTENT_CODE_TRACK_RELOC_CODE
  301. #if !MICROPY_EMIT_MACHINE_CODE || defined(MP_PLAT_ALLOC_EXEC) || defined(MP_PLAT_COMMIT_EXEC)
  302. #define MICROPY_PERSISTENT_CODE_TRACK_RELOC_CODE (0)
  303. #else
  304. #define MICROPY_PERSISTENT_CODE_TRACK_RELOC_CODE (1)
  305. #endif
  306. #endif
  307. /*****************************************************************************/
  308. /* Compiler configuration */
  309. // Whether to include the compiler
  310. #ifndef MICROPY_ENABLE_COMPILER
  311. #define MICROPY_ENABLE_COMPILER (1)
  312. #endif
  313. // Whether the compiler is dynamically configurable (ie at runtime)
  314. // This will disable the ability to execute native/viper code
  315. #ifndef MICROPY_DYNAMIC_COMPILER
  316. #define MICROPY_DYNAMIC_COMPILER (0)
  317. #endif
  318. // Configure dynamic compiler macros
  319. #if MICROPY_DYNAMIC_COMPILER
  320. #define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE_DYNAMIC (mp_dynamic_compiler.opt_cache_map_lookup_in_bytecode)
  321. #define MICROPY_PY_BUILTINS_STR_UNICODE_DYNAMIC (mp_dynamic_compiler.py_builtins_str_unicode)
  322. #else
  323. #define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE_DYNAMIC MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE
  324. #define MICROPY_PY_BUILTINS_STR_UNICODE_DYNAMIC MICROPY_PY_BUILTINS_STR_UNICODE
  325. #endif
  326. // Whether to enable constant folding; eg 1+2 rewritten as 3
  327. #ifndef MICROPY_COMP_CONST_FOLDING
  328. #define MICROPY_COMP_CONST_FOLDING (1)
  329. #endif
  330. // Whether to enable optimisations for constant literals, eg OrderedDict
  331. #ifndef MICROPY_COMP_CONST_LITERAL
  332. #define MICROPY_COMP_CONST_LITERAL (1)
  333. #endif
  334. // Whether to enable lookup of constants in modules; eg module.CONST
  335. #ifndef MICROPY_COMP_MODULE_CONST
  336. #define MICROPY_COMP_MODULE_CONST (0)
  337. #endif
  338. // Whether to enable constant optimisation; id = const(value)
  339. #ifndef MICROPY_COMP_CONST
  340. #define MICROPY_COMP_CONST (1)
  341. #endif
  342. // Whether to enable optimisation of: a, b = c, d
  343. // Costs 124 bytes (Thumb2)
  344. #ifndef MICROPY_COMP_DOUBLE_TUPLE_ASSIGN
  345. #define MICROPY_COMP_DOUBLE_TUPLE_ASSIGN (1)
  346. #endif
  347. // Whether to enable optimisation of: a, b, c = d, e, f
  348. // Requires MICROPY_COMP_DOUBLE_TUPLE_ASSIGN and costs 68 bytes (Thumb2)
  349. #ifndef MICROPY_COMP_TRIPLE_TUPLE_ASSIGN
  350. #define MICROPY_COMP_TRIPLE_TUPLE_ASSIGN (0)
  351. #endif
  352. // Whether to enable optimisation of: return a if b else c
  353. // Costs about 80 bytes (Thumb2) and saves 2 bytes of bytecode for each use
  354. #ifndef MICROPY_COMP_RETURN_IF_EXPR
  355. #define MICROPY_COMP_RETURN_IF_EXPR (0)
  356. #endif
  357. /*****************************************************************************/
  358. /* Internal debugging stuff */
  359. // Whether to collect memory allocation stats
  360. #ifndef MICROPY_MEM_STATS
  361. #define MICROPY_MEM_STATS (0)
  362. #endif
  363. // The mp_print_t printer used for debugging output
  364. #ifndef MICROPY_DEBUG_PRINTER
  365. #define MICROPY_DEBUG_PRINTER (&mp_plat_print)
  366. #endif
  367. // Whether to build functions that print debugging info:
  368. // mp_bytecode_print
  369. // mp_parse_node_print
  370. #ifndef MICROPY_DEBUG_PRINTERS
  371. #define MICROPY_DEBUG_PRINTERS (0)
  372. #endif
  373. // Whether to enable all debugging outputs (it will be extremely verbose)
  374. #ifndef MICROPY_DEBUG_VERBOSE
  375. #define MICROPY_DEBUG_VERBOSE (0)
  376. #endif
  377. // Whether to enable debugging versions of MP_OBJ_NULL/STOP_ITERATION/SENTINEL
  378. #ifndef MICROPY_DEBUG_MP_OBJ_SENTINELS
  379. #define MICROPY_DEBUG_MP_OBJ_SENTINELS (0)
  380. #endif
  381. // Whether to print parse rule names (rather than integers) in mp_parse_node_print
  382. #ifndef MICROPY_DEBUG_PARSE_RULE_NAME
  383. #define MICROPY_DEBUG_PARSE_RULE_NAME (0)
  384. #endif
  385. // Whether to enable a simple VM stack overflow check
  386. #ifndef MICROPY_DEBUG_VM_STACK_OVERFLOW
  387. #define MICROPY_DEBUG_VM_STACK_OVERFLOW (0)
  388. #endif
  389. /*****************************************************************************/
  390. /* Optimisations */
  391. // Whether to use computed gotos in the VM, or a switch
  392. // Computed gotos are roughly 10% faster, and increase VM code size by a little
  393. // Note: enabling this will use the gcc-specific extensions of ranged designated
  394. // initialisers and addresses of labels, which are not part of the C99 standard.
  395. #ifndef MICROPY_OPT_COMPUTED_GOTO
  396. #define MICROPY_OPT_COMPUTED_GOTO (0)
  397. #endif
  398. // Whether to cache result of map lookups in LOAD_NAME, LOAD_GLOBAL, LOAD_ATTR,
  399. // STORE_ATTR bytecodes. Uses 1 byte extra RAM for each of these opcodes and
  400. // uses a bit of extra code ROM, but greatly improves lookup speed.
  401. #ifndef MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE
  402. #define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE (0)
  403. #endif
  404. // Whether to use fast versions of bitwise operations (and, or, xor) when the
  405. // arguments are both positive. Increases Thumb2 code size by about 250 bytes.
  406. #ifndef MICROPY_OPT_MPZ_BITWISE
  407. #define MICROPY_OPT_MPZ_BITWISE (0)
  408. #endif
  409. // Whether math.factorial is large, fast and recursive (1) or small and slow (0).
  410. #ifndef MICROPY_OPT_MATH_FACTORIAL
  411. #define MICROPY_OPT_MATH_FACTORIAL (0)
  412. #endif
  413. /*****************************************************************************/
  414. /* Python internal features */
  415. // Whether to enable import of external modules
  416. // When disabled, only importing of built-in modules is supported
  417. // When enabled, a port must implement mp_import_stat (among other things)
  418. #ifndef MICROPY_ENABLE_EXTERNAL_IMPORT
  419. #define MICROPY_ENABLE_EXTERNAL_IMPORT (1)
  420. #endif
  421. // Whether to use the POSIX reader for importing files
  422. #ifndef MICROPY_READER_POSIX
  423. #define MICROPY_READER_POSIX (0)
  424. #endif
  425. // Whether to use the VFS reader for importing files
  426. #ifndef MICROPY_READER_VFS
  427. #define MICROPY_READER_VFS (0)
  428. #endif
  429. // Whether any readers have been defined
  430. #ifndef MICROPY_HAS_FILE_READER
  431. #define MICROPY_HAS_FILE_READER (MICROPY_READER_POSIX || MICROPY_READER_VFS)
  432. #endif
  433. // Hook for the VM at the start of the opcode loop (can contain variable
  434. // definitions usable by the other hook functions)
  435. #ifndef MICROPY_VM_HOOK_INIT
  436. #define MICROPY_VM_HOOK_INIT
  437. #endif
  438. // Hook for the VM during the opcode loop (but only after jump opcodes)
  439. #ifndef MICROPY_VM_HOOK_LOOP
  440. #define MICROPY_VM_HOOK_LOOP
  441. #endif
  442. // Hook for the VM just before return opcode is finished being interpreted
  443. #ifndef MICROPY_VM_HOOK_RETURN
  444. #define MICROPY_VM_HOOK_RETURN
  445. #endif
  446. // Whether to include the garbage collector
  447. #ifndef MICROPY_ENABLE_GC
  448. #define MICROPY_ENABLE_GC (0)
  449. #endif
  450. // Whether to enable finalisers in the garbage collector (ie call __del__)
  451. #ifndef MICROPY_ENABLE_FINALISER
  452. #define MICROPY_ENABLE_FINALISER (0)
  453. #endif
  454. // Whether to enable a separate allocator for the Python stack.
  455. // If enabled then the code must call mp_pystack_init before mp_init.
  456. #ifndef MICROPY_ENABLE_PYSTACK
  457. #define MICROPY_ENABLE_PYSTACK (0)
  458. #endif
  459. // Number of bytes that memory returned by mp_pystack_alloc will be aligned by.
  460. #ifndef MICROPY_PYSTACK_ALIGN
  461. #define MICROPY_PYSTACK_ALIGN (8)
  462. #endif
  463. // Whether to check C stack usage. C stack used for calling Python functions,
  464. // etc. Not checking means segfault on overflow.
  465. #ifndef MICROPY_STACK_CHECK
  466. #define MICROPY_STACK_CHECK (0)
  467. #endif
  468. // Whether to have an emergency exception buffer
  469. #ifndef MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF
  470. #define MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF (0)
  471. #endif
  472. #if MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF
  473. #ifndef MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE
  474. #define MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE (0) // 0 - implies dynamic allocation
  475. #endif
  476. #endif
  477. // Whether to provide the mp_kbd_exception object, and micropython.kbd_intr function
  478. #ifndef MICROPY_KBD_EXCEPTION
  479. #define MICROPY_KBD_EXCEPTION (0)
  480. #endif
  481. // Prefer to raise KeyboardInterrupt asynchronously (from signal or interrupt
  482. // handler) - if supported by a particular port.
  483. #ifndef MICROPY_ASYNC_KBD_INTR
  484. #define MICROPY_ASYNC_KBD_INTR (0)
  485. #endif
  486. // Whether to include REPL helper function
  487. #ifndef MICROPY_HELPER_REPL
  488. #define MICROPY_HELPER_REPL (0)
  489. #endif
  490. // Allow enabling debug prints after each REPL line
  491. #ifndef MICROPY_REPL_INFO
  492. #define MICROPY_REPL_INFO (0)
  493. #endif
  494. // Whether to include emacs-style readline behavior in REPL
  495. #ifndef MICROPY_REPL_EMACS_KEYS
  496. #define MICROPY_REPL_EMACS_KEYS (0)
  497. #endif
  498. // Whether to include emacs-style word movement/kill readline behavior in REPL.
  499. // This adds Alt+F, Alt+B, Alt+D and Alt+Backspace for forward-word, backward-word, forward-kill-word
  500. // and backward-kill-word, respectively.
  501. #ifndef MICROPY_REPL_EMACS_WORDS_MOVE
  502. #define MICROPY_REPL_EMACS_WORDS_MOVE (0)
  503. #endif
  504. // Whether to include extra convenience keys for word movement/kill in readline REPL.
  505. // This adds Ctrl+Right, Ctrl+Left and Ctrl+W for forward-word, backward-word and backward-kill-word
  506. // respectively. Ctrl+Delete is not implemented because it's a very different escape sequence.
  507. // Depends on MICROPY_REPL_EMACS_WORDS_MOVE.
  508. #ifndef MICROPY_REPL_EMACS_EXTRA_WORDS_MOVE
  509. #define MICROPY_REPL_EMACS_EXTRA_WORDS_MOVE (0)
  510. #endif
  511. // Whether to implement auto-indent in REPL
  512. #ifndef MICROPY_REPL_AUTO_INDENT
  513. #define MICROPY_REPL_AUTO_INDENT (0)
  514. #endif
  515. // Whether port requires event-driven REPL functions
  516. #ifndef MICROPY_REPL_EVENT_DRIVEN
  517. #define MICROPY_REPL_EVENT_DRIVEN (0)
  518. #endif
  519. // Whether to include lexer helper function for unix
  520. #ifndef MICROPY_HELPER_LEXER_UNIX
  521. #define MICROPY_HELPER_LEXER_UNIX (0)
  522. #endif
  523. // Long int implementation
  524. #define MICROPY_LONGINT_IMPL_NONE (0)
  525. #define MICROPY_LONGINT_IMPL_LONGLONG (1)
  526. #define MICROPY_LONGINT_IMPL_MPZ (2)
  527. #ifndef MICROPY_LONGINT_IMPL
  528. #define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_NONE)
  529. #endif
  530. #if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_LONGLONG
  531. typedef long long mp_longint_impl_t;
  532. #endif
  533. // Whether to include information in the byte code to determine source
  534. // line number (increases RAM usage, but doesn't slow byte code execution)
  535. #ifndef MICROPY_ENABLE_SOURCE_LINE
  536. #define MICROPY_ENABLE_SOURCE_LINE (0)
  537. #endif
  538. // Whether to include doc strings (increases RAM usage)
  539. #ifndef MICROPY_ENABLE_DOC_STRING
  540. #define MICROPY_ENABLE_DOC_STRING (0)
  541. #endif
  542. // Exception messages are short static strings
  543. #define MICROPY_ERROR_REPORTING_TERSE (1)
  544. // Exception messages provide basic error details
  545. #define MICROPY_ERROR_REPORTING_NORMAL (2)
  546. // Exception messages provide full info, e.g. object names
  547. #define MICROPY_ERROR_REPORTING_DETAILED (3)
  548. #ifndef MICROPY_ERROR_REPORTING
  549. #define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_NORMAL)
  550. #endif
  551. // Whether issue warnings during compiling/execution
  552. #ifndef MICROPY_WARNINGS
  553. #define MICROPY_WARNINGS (0)
  554. #endif
  555. // Whether to support warning categories
  556. #ifndef MICROPY_WARNINGS_CATEGORY
  557. #define MICROPY_WARNINGS_CATEGORY (0)
  558. #endif
  559. // This macro is used when printing runtime warnings and errors
  560. #ifndef MICROPY_ERROR_PRINTER
  561. #define MICROPY_ERROR_PRINTER (&mp_plat_print)
  562. #endif
  563. // Float and complex implementation
  564. #define MICROPY_FLOAT_IMPL_NONE (0)
  565. #define MICROPY_FLOAT_IMPL_FLOAT (1)
  566. #define MICROPY_FLOAT_IMPL_DOUBLE (2)
  567. #ifndef MICROPY_FLOAT_IMPL
  568. #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_NONE)
  569. #endif
  570. #if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT
  571. #define MICROPY_PY_BUILTINS_FLOAT (1)
  572. #define MICROPY_FLOAT_CONST(x) x##F
  573. #define MICROPY_FLOAT_C_FUN(fun) fun##f
  574. typedef float mp_float_t;
  575. #elif MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE
  576. #define MICROPY_PY_BUILTINS_FLOAT (1)
  577. #define MICROPY_FLOAT_CONST(x) x
  578. #define MICROPY_FLOAT_C_FUN(fun) fun
  579. typedef double mp_float_t;
  580. #else
  581. #define MICROPY_PY_BUILTINS_FLOAT (0)
  582. #endif
  583. #ifndef MICROPY_PY_BUILTINS_COMPLEX
  584. #define MICROPY_PY_BUILTINS_COMPLEX (MICROPY_PY_BUILTINS_FLOAT)
  585. #endif
  586. // Whether to provide a high-quality hash for float and complex numbers.
  587. // Otherwise the default is a very simple but correct hashing function.
  588. #ifndef MICROPY_FLOAT_HIGH_QUALITY_HASH
  589. #define MICROPY_FLOAT_HIGH_QUALITY_HASH (0)
  590. #endif
  591. // Enable features which improve CPython compatibility
  592. // but may lead to more code size/memory usage.
  593. // TODO: Originally intended as generic category to not
  594. // add bunch of once-off options. May need refactoring later
  595. #ifndef MICROPY_CPYTHON_COMPAT
  596. #define MICROPY_CPYTHON_COMPAT (1)
  597. #endif
  598. // Perform full checks as done by CPython. Disabling this
  599. // may produce incorrect results, if incorrect data is fed,
  600. // but should not lead to MicroPython crashes or similar
  601. // grave issues (in other words, only user app should be,
  602. // affected, not system).
  603. #ifndef MICROPY_FULL_CHECKS
  604. #define MICROPY_FULL_CHECKS (1)
  605. #endif
  606. // Whether POSIX-semantics non-blocking streams are supported
  607. #ifndef MICROPY_STREAMS_NON_BLOCK
  608. #define MICROPY_STREAMS_NON_BLOCK (0)
  609. #endif
  610. // Whether to provide stream functions with POSIX-like signatures
  611. // (useful for porting existing libraries to MicroPython).
  612. #ifndef MICROPY_STREAMS_POSIX_API
  613. #define MICROPY_STREAMS_POSIX_API (0)
  614. #endif
  615. // Whether to call __init__ when importing builtin modules for the first time
  616. #ifndef MICROPY_MODULE_BUILTIN_INIT
  617. #define MICROPY_MODULE_BUILTIN_INIT (0)
  618. #endif
  619. // Whether to support module-level __getattr__ (see PEP 562)
  620. #ifndef MICROPY_MODULE_GETATTR
  621. #define MICROPY_MODULE_GETATTR (1)
  622. #endif
  623. // Whether module weak links are supported
  624. #ifndef MICROPY_MODULE_WEAK_LINKS
  625. #define MICROPY_MODULE_WEAK_LINKS (0)
  626. #endif
  627. // Whether frozen modules are supported in the form of strings
  628. #ifndef MICROPY_MODULE_FROZEN_STR
  629. #define MICROPY_MODULE_FROZEN_STR (0)
  630. #endif
  631. // Whether frozen modules are supported in the form of .mpy files
  632. #ifndef MICROPY_MODULE_FROZEN_MPY
  633. #define MICROPY_MODULE_FROZEN_MPY (0)
  634. #endif
  635. // Convenience macro for whether frozen modules are supported
  636. #ifndef MICROPY_MODULE_FROZEN
  637. #define MICROPY_MODULE_FROZEN (MICROPY_MODULE_FROZEN_STR || MICROPY_MODULE_FROZEN_MPY)
  638. #endif
  639. // Whether you can override builtins in the builtins module
  640. #ifndef MICROPY_CAN_OVERRIDE_BUILTINS
  641. #define MICROPY_CAN_OVERRIDE_BUILTINS (0)
  642. #endif
  643. // Whether to check that the "self" argument of a builtin method has the
  644. // correct type. Such an explicit check is only needed if a builtin
  645. // method escapes to Python land without a first argument, eg
  646. // list.append([], 1). Without this check such calls will have undefined
  647. // behaviour (usually segfault) if the first argument is the wrong type.
  648. #ifndef MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG
  649. #define MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG (1)
  650. #endif
  651. // Whether to use internally defined errno's (otherwise system provided ones)
  652. #ifndef MICROPY_USE_INTERNAL_ERRNO
  653. #define MICROPY_USE_INTERNAL_ERRNO (0)
  654. #endif
  655. // Whether to use internally defined *printf() functions (otherwise external ones)
  656. #ifndef MICROPY_USE_INTERNAL_PRINTF
  657. #define MICROPY_USE_INTERNAL_PRINTF (1)
  658. #endif
  659. // Support for internal scheduler
  660. #ifndef MICROPY_ENABLE_SCHEDULER
  661. #define MICROPY_ENABLE_SCHEDULER (0)
  662. #endif
  663. // Maximum number of entries in the scheduler
  664. #ifndef MICROPY_SCHEDULER_DEPTH
  665. #define MICROPY_SCHEDULER_DEPTH (4)
  666. #endif
  667. // Support for generic VFS sub-system
  668. #ifndef MICROPY_VFS
  669. #define MICROPY_VFS (0)
  670. #endif
  671. // Support for VFS POSIX component, to mount a POSIX filesystem within VFS
  672. #ifndef MICROPY_VFS
  673. #define MICROPY_VFS_POSIX (0)
  674. #endif
  675. // Support for VFS FAT component, to mount a FAT filesystem within VFS
  676. #ifndef MICROPY_VFS
  677. #define MICROPY_VFS_FAT (0)
  678. #endif
  679. /*****************************************************************************/
  680. /* Fine control over Python builtins, classes, modules, etc */
  681. // Whether to support multiple inheritance of Python classes. Multiple
  682. // inheritance makes some C functions inherently recursive, and adds a bit of
  683. // code overhead.
  684. #ifndef MICROPY_MULTIPLE_INHERITANCE
  685. #define MICROPY_MULTIPLE_INHERITANCE (1)
  686. #endif
  687. // Whether to implement attributes on functions
  688. #ifndef MICROPY_PY_FUNCTION_ATTRS
  689. #define MICROPY_PY_FUNCTION_ATTRS (0)
  690. #endif
  691. // Whether to support the descriptors __get__, __set__, __delete__
  692. // This costs some code size and makes load/store/delete of instance
  693. // attributes slower for the classes that use this feature
  694. #ifndef MICROPY_PY_DESCRIPTORS
  695. #define MICROPY_PY_DESCRIPTORS (0)
  696. #endif
  697. // Whether to support class __delattr__ and __setattr__ methods
  698. // This costs some code size and makes store/delete of instance
  699. // attributes slower for the classes that use this feature
  700. #ifndef MICROPY_PY_DELATTR_SETATTR
  701. #define MICROPY_PY_DELATTR_SETATTR (0)
  702. #endif
  703. // Support for async/await/async for/async with
  704. #ifndef MICROPY_PY_ASYNC_AWAIT
  705. #define MICROPY_PY_ASYNC_AWAIT (1)
  706. #endif
  707. // Support for assignment expressions with := (see PEP 572, Python 3.8+)
  708. #ifndef MICROPY_PY_ASSIGN_EXPR
  709. #define MICROPY_PY_ASSIGN_EXPR (1)
  710. #endif
  711. // Non-standard .pend_throw() method for generators, allowing for
  712. // Future-like behavior with respect to exception handling: an
  713. // exception set with .pend_throw() will activate on the next call
  714. // to generator's .send() or .__next__(). (This is useful to implement
  715. // async schedulers.)
  716. #ifndef MICROPY_PY_GENERATOR_PEND_THROW
  717. #define MICROPY_PY_GENERATOR_PEND_THROW (1)
  718. #endif
  719. // Issue a warning when comparing str and bytes objects
  720. #ifndef MICROPY_PY_STR_BYTES_CMP_WARN
  721. #define MICROPY_PY_STR_BYTES_CMP_WARN (0)
  722. #endif
  723. // Whether str object is proper unicode
  724. #ifndef MICROPY_PY_BUILTINS_STR_UNICODE
  725. #define MICROPY_PY_BUILTINS_STR_UNICODE (0)
  726. #endif
  727. // Whether to check for valid UTF-8 when converting bytes to str
  728. #ifndef MICROPY_PY_BUILTINS_STR_UNICODE_CHECK
  729. #define MICROPY_PY_BUILTINS_STR_UNICODE_CHECK (MICROPY_PY_BUILTINS_STR_UNICODE)
  730. #endif
  731. // Whether str.center() method provided
  732. #ifndef MICROPY_PY_BUILTINS_STR_CENTER
  733. #define MICROPY_PY_BUILTINS_STR_CENTER (0)
  734. #endif
  735. // Whether str.count() method provided
  736. #ifndef MICROPY_PY_BUILTINS_STR_COUNT
  737. #define MICROPY_PY_BUILTINS_STR_COUNT (1)
  738. #endif
  739. // Whether str % (...) formatting operator provided
  740. #ifndef MICROPY_PY_BUILTINS_STR_OP_MODULO
  741. #define MICROPY_PY_BUILTINS_STR_OP_MODULO (1)
  742. #endif
  743. // Whether str.partition()/str.rpartition() method provided
  744. #ifndef MICROPY_PY_BUILTINS_STR_PARTITION
  745. #define MICROPY_PY_BUILTINS_STR_PARTITION (0)
  746. #endif
  747. // Whether str.splitlines() method provided
  748. #ifndef MICROPY_PY_BUILTINS_STR_SPLITLINES
  749. #define MICROPY_PY_BUILTINS_STR_SPLITLINES (0)
  750. #endif
  751. // Whether to support bytearray object
  752. #ifndef MICROPY_PY_BUILTINS_BYTEARRAY
  753. #define MICROPY_PY_BUILTINS_BYTEARRAY (1)
  754. #endif
  755. // Whether to support dict.fromkeys() class method
  756. #ifndef MICROPY_PY_BUILTINS_DICT_FROMKEYS
  757. #define MICROPY_PY_BUILTINS_DICT_FROMKEYS (1)
  758. #endif
  759. // Whether to support memoryview object
  760. #ifndef MICROPY_PY_BUILTINS_MEMORYVIEW
  761. #define MICROPY_PY_BUILTINS_MEMORYVIEW (0)
  762. #endif
  763. // Whether to support memoryview.itemsize attribute
  764. #ifndef MICROPY_PY_BUILTINS_MEMORYVIEW_ITEMSIZE
  765. #define MICROPY_PY_BUILTINS_MEMORYVIEW_ITEMSIZE (0)
  766. #endif
  767. // Whether to support set object
  768. #ifndef MICROPY_PY_BUILTINS_SET
  769. #define MICROPY_PY_BUILTINS_SET (1)
  770. #endif
  771. // Whether to support slice subscript operators and slice object
  772. #ifndef MICROPY_PY_BUILTINS_SLICE
  773. #define MICROPY_PY_BUILTINS_SLICE (1)
  774. #endif
  775. // Whether to support slice attribute read access,
  776. // i.e. slice.start, slice.stop, slice.step
  777. #ifndef MICROPY_PY_BUILTINS_SLICE_ATTRS
  778. #define MICROPY_PY_BUILTINS_SLICE_ATTRS (0)
  779. #endif
  780. // Whether to support the .indices(len) method on slice objects
  781. #ifndef MICROPY_PY_BUILTINS_SLICE_INDICES
  782. #define MICROPY_PY_BUILTINS_SLICE_INDICES (0)
  783. #endif
  784. // Whether to support frozenset object
  785. #ifndef MICROPY_PY_BUILTINS_FROZENSET
  786. #define MICROPY_PY_BUILTINS_FROZENSET (0)
  787. #endif
  788. // Whether to support property object
  789. #ifndef MICROPY_PY_BUILTINS_PROPERTY
  790. #define MICROPY_PY_BUILTINS_PROPERTY (1)
  791. #endif
  792. // Whether to implement the start/stop/step attributes (readback) on
  793. // the "range" builtin type. Rarely used, and costs ~60 bytes (x86).
  794. #ifndef MICROPY_PY_BUILTINS_RANGE_ATTRS
  795. #define MICROPY_PY_BUILTINS_RANGE_ATTRS (1)
  796. #endif
  797. // Whether to support binary ops [only (in)equality is defined] between range
  798. // objects. With this option disabled all range objects that are not exactly
  799. // the same object will compare as not-equal. With it enabled the semantics
  800. // match CPython and ranges are equal if they yield the same sequence of items.
  801. #ifndef MICROPY_PY_BUILTINS_RANGE_BINOP
  802. #define MICROPY_PY_BUILTINS_RANGE_BINOP (0)
  803. #endif
  804. // Support for callling next() with second argument
  805. #ifndef MICROPY_PY_BUILTINS_NEXT2
  806. #define MICROPY_PY_BUILTINS_NEXT2 (0)
  807. #endif
  808. // Whether to support rounding of integers (incl bignum); eg round(123,-1)=120
  809. #ifndef MICROPY_PY_BUILTINS_ROUND_INT
  810. #define MICROPY_PY_BUILTINS_ROUND_INT (0)
  811. #endif
  812. // Whether to support complete set of special methods for user
  813. // classes, or only the most used ones. "Inplace" methods are
  814. // controlled by MICROPY_PY_ALL_INPLACE_SPECIAL_METHODS below.
  815. // "Reverse" methods are controlled by
  816. // MICROPY_PY_REVERSE_SPECIAL_METHODS below.
  817. #ifndef MICROPY_PY_ALL_SPECIAL_METHODS
  818. #define MICROPY_PY_ALL_SPECIAL_METHODS (0)
  819. #endif
  820. // Whether to support all inplace arithmetic operarion methods
  821. // (__imul__, etc.)
  822. #ifndef MICROPY_PY_ALL_INPLACE_SPECIAL_METHODS
  823. #define MICROPY_PY_ALL_INPLACE_SPECIAL_METHODS (0)
  824. #endif
  825. // Whether to support reverse arithmetic operarion methods
  826. // (__radd__, etc.). Additionally gated by
  827. // MICROPY_PY_ALL_SPECIAL_METHODS.
  828. #ifndef MICROPY_PY_REVERSE_SPECIAL_METHODS
  829. #define MICROPY_PY_REVERSE_SPECIAL_METHODS (0)
  830. #endif
  831. // Whether to support compile function
  832. #ifndef MICROPY_PY_BUILTINS_COMPILE
  833. #define MICROPY_PY_BUILTINS_COMPILE (0)
  834. #endif
  835. // Whether to support enumerate function(type)
  836. #ifndef MICROPY_PY_BUILTINS_ENUMERATE
  837. #define MICROPY_PY_BUILTINS_ENUMERATE (1)
  838. #endif
  839. // Whether to support eval and exec functions
  840. // By default they are supported if the compiler is enabled
  841. #ifndef MICROPY_PY_BUILTINS_EVAL_EXEC
  842. #define MICROPY_PY_BUILTINS_EVAL_EXEC (MICROPY_ENABLE_COMPILER)
  843. #endif
  844. // Whether to support the Python 2 execfile function
  845. #ifndef MICROPY_PY_BUILTINS_EXECFILE
  846. #define MICROPY_PY_BUILTINS_EXECFILE (0)
  847. #endif
  848. // Whether to support filter function(type)
  849. #ifndef MICROPY_PY_BUILTINS_FILTER
  850. #define MICROPY_PY_BUILTINS_FILTER (1)
  851. #endif
  852. // Whether to support reversed function(type)
  853. #ifndef MICROPY_PY_BUILTINS_REVERSED
  854. #define MICROPY_PY_BUILTINS_REVERSED (1)
  855. #endif
  856. // Whether to define "NotImplemented" special constant
  857. #ifndef MICROPY_PY_BUILTINS_NOTIMPLEMENTED
  858. #define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (0)
  859. #endif
  860. // Whether to provide the built-in input() function. The implementation of this
  861. // uses mp-readline, so can only be enabled if the port uses this readline.
  862. #ifndef MICROPY_PY_BUILTINS_INPUT
  863. #define MICROPY_PY_BUILTINS_INPUT (0)
  864. #endif
  865. // Whether to support min/max functions
  866. #ifndef MICROPY_PY_BUILTINS_MIN_MAX
  867. #define MICROPY_PY_BUILTINS_MIN_MAX (1)
  868. #endif
  869. // Support for calls to pow() with 3 integer arguments
  870. #ifndef MICROPY_PY_BUILTINS_POW3
  871. #define MICROPY_PY_BUILTINS_POW3 (0)
  872. #endif
  873. // Whether to provide the help function
  874. #ifndef MICROPY_PY_BUILTINS_HELP
  875. #define MICROPY_PY_BUILTINS_HELP (0)
  876. #endif
  877. // Use this to configure the help text shown for help(). It should be a
  878. // variable with the type "const char*". A sensible default is provided.
  879. #ifndef MICROPY_PY_BUILTINS_HELP_TEXT
  880. #define MICROPY_PY_BUILTINS_HELP_TEXT mp_help_default_text
  881. #endif
  882. // Add the ability to list the available modules when executing help('modules')
  883. #ifndef MICROPY_PY_BUILTINS_HELP_MODULES
  884. #define MICROPY_PY_BUILTINS_HELP_MODULES (0)
  885. #endif
  886. // Whether to set __file__ for imported modules
  887. #ifndef MICROPY_PY___FILE__
  888. #define MICROPY_PY___FILE__ (1)
  889. #endif
  890. // Whether to provide mem-info related functions in micropython module
  891. #ifndef MICROPY_PY_MICROPYTHON_MEM_INFO
  892. #define MICROPY_PY_MICROPYTHON_MEM_INFO (0)
  893. #endif
  894. // Whether to provide "micropython.stack_use" function
  895. #ifndef MICROPY_PY_MICROPYTHON_STACK_USE
  896. #define MICROPY_PY_MICROPYTHON_STACK_USE (MICROPY_PY_MICROPYTHON_MEM_INFO)
  897. #endif
  898. // Whether to provide the "micropython.heap_locked" function
  899. #ifndef MICROPY_PY_MICROPYTHON_HEAP_LOCKED
  900. #define MICROPY_PY_MICROPYTHON_HEAP_LOCKED (0)
  901. #endif
  902. // Whether to provide "array" module. Note that large chunk of the
  903. // underlying code is shared with "bytearray" builtin type, so to
  904. // get real savings, it should be disabled too.
  905. #ifndef MICROPY_PY_ARRAY
  906. #define MICROPY_PY_ARRAY (1)
  907. #endif
  908. // Whether to support slice assignments for array (and bytearray).
  909. // This is rarely used, but adds ~0.5K of code.
  910. #ifndef MICROPY_PY_ARRAY_SLICE_ASSIGN
  911. #define MICROPY_PY_ARRAY_SLICE_ASSIGN (0)
  912. #endif
  913. // Whether to support attrtuple type (MicroPython extension)
  914. // It provides space-efficient tuples with attribute access
  915. #ifndef MICROPY_PY_ATTRTUPLE
  916. #define MICROPY_PY_ATTRTUPLE (1)
  917. #endif
  918. // Whether to provide "collections" module
  919. #ifndef MICROPY_PY_COLLECTIONS
  920. #define MICROPY_PY_COLLECTIONS (1)
  921. #endif
  922. // Whether to provide "ucollections.deque" type
  923. #ifndef MICROPY_PY_COLLECTIONS_DEQUE
  924. #define MICROPY_PY_COLLECTIONS_DEQUE (0)
  925. #endif
  926. // Whether to provide "collections.OrderedDict" type
  927. #ifndef MICROPY_PY_COLLECTIONS_ORDEREDDICT
  928. #define MICROPY_PY_COLLECTIONS_ORDEREDDICT (0)
  929. #endif
  930. // Whether to provide the _asdict function for namedtuple
  931. #ifndef MICROPY_PY_COLLECTIONS_NAMEDTUPLE__ASDICT
  932. #define MICROPY_PY_COLLECTIONS_NAMEDTUPLE__ASDICT (0)
  933. #endif
  934. // Whether to provide "math" module
  935. #ifndef MICROPY_PY_MATH
  936. #define MICROPY_PY_MATH (1)
  937. #endif
  938. // Whether to provide special math functions: math.{erf,erfc,gamma,lgamma}
  939. #ifndef MICROPY_PY_MATH_SPECIAL_FUNCTIONS
  940. #define MICROPY_PY_MATH_SPECIAL_FUNCTIONS (0)
  941. #endif
  942. // Whether to provide math.factorial function
  943. #ifndef MICROPY_PY_MATH_FACTORIAL
  944. #define MICROPY_PY_MATH_FACTORIAL (0)
  945. #endif
  946. // Whether to provide math.isclose function
  947. #ifndef MICROPY_PY_MATH_ISCLOSE
  948. #define MICROPY_PY_MATH_ISCLOSE (0)
  949. #endif
  950. // Whether to provide fix for atan2 Inf handling.
  951. #ifndef MICROPY_PY_MATH_ATAN2_FIX_INFNAN
  952. #define MICROPY_PY_MATH_ATAN2_FIX_INFNAN (0)
  953. #endif
  954. // Whether to provide fix for fmod Inf handling.
  955. #ifndef MICROPY_PY_MATH_FMOD_FIX_INFNAN
  956. #define MICROPY_PY_MATH_FMOD_FIX_INFNAN (0)
  957. #endif
  958. // Whether to provide fix for modf negative zero handling.
  959. #ifndef MICROPY_PY_MATH_MODF_FIX_NEGZERO
  960. #define MICROPY_PY_MATH_MODF_FIX_NEGZERO (0)
  961. #endif
  962. // Whether to provide fix for pow(1, NaN) and pow(NaN, 0), which both should be 1 not NaN.
  963. #ifndef MICROPY_PY_MATH_POW_FIX_NAN
  964. #define MICROPY_PY_MATH_POW_FIX_NAN (0)
  965. #endif
  966. // Whether to provide "cmath" module
  967. #ifndef MICROPY_PY_CMATH
  968. #define MICROPY_PY_CMATH (0)
  969. #endif
  970. // Whether to provide "gc" module
  971. #ifndef MICROPY_PY_GC
  972. #define MICROPY_PY_GC (1)
  973. #endif
  974. // Whether to return number of collected objects from gc.collect()
  975. #ifndef MICROPY_PY_GC_COLLECT_RETVAL
  976. #define MICROPY_PY_GC_COLLECT_RETVAL (0)
  977. #endif
  978. // Whether to provide "io" module
  979. #ifndef MICROPY_PY_IO
  980. #define MICROPY_PY_IO (1)
  981. #endif
  982. // Whether to provide "io.IOBase" class to support user streams
  983. #ifndef MICROPY_PY_IO_IOBASE
  984. #define MICROPY_PY_IO_IOBASE (0)
  985. #endif
  986. // Whether to provide "uio.resource_stream()" function with
  987. // the semantics of CPython's pkg_resources.resource_stream()
  988. // (allows to access binary resources in frozen source packages).
  989. // Note that the same functionality can be achieved in "pure
  990. // Python" by prepocessing binary resources into Python source
  991. // and bytecode-freezing it (with a simple helper module available
  992. // e.g. in micropython-lib).
  993. #ifndef MICROPY_PY_IO_RESOURCE_STREAM
  994. #define MICROPY_PY_IO_RESOURCE_STREAM (0)
  995. #endif
  996. // Whether to provide "io.FileIO" class
  997. #ifndef MICROPY_PY_IO_FILEIO
  998. #define MICROPY_PY_IO_FILEIO (0)
  999. #endif
  1000. // Whether to provide "io.BytesIO" class
  1001. #ifndef MICROPY_PY_IO_BYTESIO
  1002. #define MICROPY_PY_IO_BYTESIO (1)
  1003. #endif
  1004. // Whether to provide "io.BufferedWriter" class
  1005. #ifndef MICROPY_PY_IO_BUFFEREDWRITER
  1006. #define MICROPY_PY_IO_BUFFEREDWRITER (0)
  1007. #endif
  1008. // Whether to provide "struct" module
  1009. #ifndef MICROPY_PY_STRUCT
  1010. #define MICROPY_PY_STRUCT (1)
  1011. #endif
  1012. // Whether to provide "sys" module
  1013. #ifndef MICROPY_PY_SYS
  1014. #define MICROPY_PY_SYS (1)
  1015. #endif
  1016. // Whether to provide "sys.maxsize" constant
  1017. #ifndef MICROPY_PY_SYS_MAXSIZE
  1018. #define MICROPY_PY_SYS_MAXSIZE (0)
  1019. #endif
  1020. // Whether to provide "sys.modules" dictionary
  1021. #ifndef MICROPY_PY_SYS_MODULES
  1022. #define MICROPY_PY_SYS_MODULES (1)
  1023. #endif
  1024. // Whether to provide "sys.exc_info" function
  1025. // Avoid enabling this, this function is Python2 heritage
  1026. #ifndef MICROPY_PY_SYS_EXC_INFO
  1027. #define MICROPY_PY_SYS_EXC_INFO (0)
  1028. #endif
  1029. // Whether to provide "sys.exit" function
  1030. #ifndef MICROPY_PY_SYS_EXIT
  1031. #define MICROPY_PY_SYS_EXIT (1)
  1032. #endif
  1033. // Whether to provide "sys.atexit" function (MicroPython extension)
  1034. #ifndef MICROPY_PY_SYS_ATEXIT
  1035. #define MICROPY_PY_SYS_ATEXIT (0)
  1036. #endif
  1037. // Whether to provide "sys.settrace" function
  1038. #ifndef MICROPY_PY_SYS_SETTRACE
  1039. #define MICROPY_PY_SYS_SETTRACE (0)
  1040. #endif
  1041. // Whether to provide "sys.getsizeof" function
  1042. #ifndef MICROPY_PY_SYS_GETSIZEOF
  1043. #define MICROPY_PY_SYS_GETSIZEOF (0)
  1044. #endif
  1045. // Whether to provide sys.{stdin,stdout,stderr} objects
  1046. #ifndef MICROPY_PY_SYS_STDFILES
  1047. #define MICROPY_PY_SYS_STDFILES (0)
  1048. #endif
  1049. // Whether to provide sys.{stdin,stdout,stderr}.buffer object
  1050. // This is implemented per-port
  1051. #ifndef MICROPY_PY_SYS_STDIO_BUFFER
  1052. #define MICROPY_PY_SYS_STDIO_BUFFER (0)
  1053. #endif
  1054. // Whether to provide "uerrno" module
  1055. #ifndef MICROPY_PY_UERRNO
  1056. #define MICROPY_PY_UERRNO (0)
  1057. #endif
  1058. // Whether to provide the uerrno.errorcode dict
  1059. #ifndef MICROPY_PY_UERRNO_ERRORCODE
  1060. #define MICROPY_PY_UERRNO_ERRORCODE (1)
  1061. #endif
  1062. // Whether to provide "uselect" module (baremetal implementation)
  1063. #ifndef MICROPY_PY_USELECT
  1064. #define MICROPY_PY_USELECT (0)
  1065. #endif
  1066. // Whether to provide "utime" module functions implementation
  1067. // in terms of mp_hal_* functions.
  1068. #ifndef MICROPY_PY_UTIME_MP_HAL
  1069. #define MICROPY_PY_UTIME_MP_HAL (0)
  1070. #endif
  1071. // Period of values returned by utime.ticks_ms(), ticks_us(), ticks_cpu()
  1072. // functions. Should be power of two. All functions above use the same
  1073. // period, so if underlying hardware/API has different periods, the
  1074. // minimum of them should be used. The value below is the maximum value
  1075. // this parameter can take (corresponding to 30 bit tick values on 32-bit
  1076. // system).
  1077. #ifndef MICROPY_PY_UTIME_TICKS_PERIOD
  1078. #define MICROPY_PY_UTIME_TICKS_PERIOD (MP_SMALL_INT_POSITIVE_MASK + 1)
  1079. #endif
  1080. // Whether to provide "_thread" module
  1081. #ifndef MICROPY_PY_THREAD
  1082. #define MICROPY_PY_THREAD (0)
  1083. #endif
  1084. // Whether to make the VM/runtime thread-safe using a global lock
  1085. // If not enabled then thread safety must be provided at the Python level
  1086. #ifndef MICROPY_PY_THREAD_GIL
  1087. #define MICROPY_PY_THREAD_GIL (MICROPY_PY_THREAD)
  1088. #endif
  1089. // Number of VM jump-loops to do before releasing the GIL.
  1090. // Set this to 0 to disable the divisor.
  1091. #ifndef MICROPY_PY_THREAD_GIL_VM_DIVISOR
  1092. #define MICROPY_PY_THREAD_GIL_VM_DIVISOR (32)
  1093. #endif
  1094. // Extended modules
  1095. #ifndef MICROPY_PY_UASYNCIO
  1096. #define MICROPY_PY_UASYNCIO (0)
  1097. #endif
  1098. #ifndef MICROPY_PY_UCTYPES
  1099. #define MICROPY_PY_UCTYPES (0)
  1100. #endif
  1101. // Whether to provide SHORT, INT, LONG, etc. types in addition to
  1102. // exact-bitness types like INT16, INT32, etc.
  1103. #ifndef MICROPY_PY_UCTYPES_NATIVE_C_TYPES
  1104. #define MICROPY_PY_UCTYPES_NATIVE_C_TYPES (1)
  1105. #endif
  1106. #ifndef MICROPY_PY_UZLIB
  1107. #define MICROPY_PY_UZLIB (0)
  1108. #endif
  1109. #ifndef MICROPY_PY_UJSON
  1110. #define MICROPY_PY_UJSON (0)
  1111. #endif
  1112. #ifndef MICROPY_PY_URE
  1113. #define MICROPY_PY_URE (0)
  1114. #endif
  1115. #ifndef MICROPY_PY_URE_DEBUG
  1116. #define MICROPY_PY_URE_DEBUG (0)
  1117. #endif
  1118. #ifndef MICROPY_PY_URE_MATCH_GROUPS
  1119. #define MICROPY_PY_URE_MATCH_GROUPS (0)
  1120. #endif
  1121. #ifndef MICROPY_PY_URE_MATCH_SPAN_START_END
  1122. #define MICROPY_PY_URE_MATCH_SPAN_START_END (0)
  1123. #endif
  1124. #ifndef MICROPY_PY_URE_SUB
  1125. #define MICROPY_PY_URE_SUB (0)
  1126. #endif
  1127. #ifndef MICROPY_PY_UHEAPQ
  1128. #define MICROPY_PY_UHEAPQ (0)
  1129. #endif
  1130. // Optimized heap queue for relative timestamps
  1131. #ifndef MICROPY_PY_UTIMEQ
  1132. #define MICROPY_PY_UTIMEQ (0)
  1133. #endif
  1134. #ifndef MICROPY_PY_UHASHLIB
  1135. #define MICROPY_PY_UHASHLIB (0)
  1136. #endif
  1137. #ifndef MICROPY_PY_UHASHLIB_MD5
  1138. #define MICROPY_PY_UHASHLIB_MD5 (0)
  1139. #endif
  1140. #ifndef MICROPY_PY_UHASHLIB_SHA1
  1141. #define MICROPY_PY_UHASHLIB_SHA1 (0)
  1142. #endif
  1143. #ifndef MICROPY_PY_UHASHLIB_SHA256
  1144. #define MICROPY_PY_UHASHLIB_SHA256 (1)
  1145. #endif
  1146. #ifndef MICROPY_PY_UCRYPTOLIB
  1147. #define MICROPY_PY_UCRYPTOLIB (0)
  1148. #endif
  1149. // Depends on MICROPY_PY_UCRYPTOLIB
  1150. #ifndef MICROPY_PY_UCRYPTOLIB_CTR
  1151. #define MICROPY_PY_UCRYPTOLIB_CTR (0)
  1152. #endif
  1153. #ifndef MICROPY_PY_UCRYPTOLIB_CONSTS
  1154. #define MICROPY_PY_UCRYPTOLIB_CONSTS (0)
  1155. #endif
  1156. #ifndef MICROPY_PY_UBINASCII
  1157. #define MICROPY_PY_UBINASCII (0)
  1158. #endif
  1159. // Depends on MICROPY_PY_UZLIB
  1160. #ifndef MICROPY_PY_UBINASCII_CRC32
  1161. #define MICROPY_PY_UBINASCII_CRC32 (0)
  1162. #endif
  1163. #ifndef MICROPY_PY_URANDOM
  1164. #define MICROPY_PY_URANDOM (0)
  1165. #endif
  1166. // Whether to include: randrange, randint, choice, random, uniform
  1167. #ifndef MICROPY_PY_URANDOM_EXTRA_FUNCS
  1168. #define MICROPY_PY_URANDOM_EXTRA_FUNCS (0)
  1169. #endif
  1170. #ifndef MICROPY_PY_MACHINE
  1171. #define MICROPY_PY_MACHINE (0)
  1172. #endif
  1173. // Whether to include: time_pulse_us
  1174. #ifndef MICROPY_PY_MACHINE_PULSE
  1175. #define MICROPY_PY_MACHINE_PULSE (0)
  1176. #endif
  1177. #ifndef MICROPY_PY_MACHINE_I2C
  1178. #define MICROPY_PY_MACHINE_I2C (0)
  1179. #endif
  1180. #ifndef MICROPY_PY_MACHINE_SPI
  1181. #define MICROPY_PY_MACHINE_SPI (0)
  1182. #endif
  1183. #ifndef MICROPY_PY_USSL
  1184. #define MICROPY_PY_USSL (0)
  1185. // Whether to add finaliser code to ussl objects
  1186. #define MICROPY_PY_USSL_FINALISER (0)
  1187. #endif
  1188. #ifndef MICROPY_PY_UWEBSOCKET
  1189. #define MICROPY_PY_UWEBSOCKET (0)
  1190. #endif
  1191. #ifndef MICROPY_PY_FRAMEBUF
  1192. #define MICROPY_PY_FRAMEBUF (0)
  1193. #endif
  1194. #ifndef MICROPY_PY_BTREE
  1195. #define MICROPY_PY_BTREE (0)
  1196. #endif
  1197. /*****************************************************************************/
  1198. /* Hooks for a port to add builtins */
  1199. // Additional builtin function definitions - see modbuiltins.c:mp_module_builtins_globals_table for format.
  1200. #ifndef MICROPY_PORT_BUILTINS
  1201. #define MICROPY_PORT_BUILTINS
  1202. #endif
  1203. // Additional builtin module definitions - see objmodule.c:mp_builtin_module_table for format.
  1204. #ifndef MICROPY_PORT_BUILTIN_MODULES
  1205. #define MICROPY_PORT_BUILTIN_MODULES
  1206. #endif
  1207. // Additional constant definitions for the compiler - see compile.c:mp_constants_table.
  1208. #ifndef MICROPY_PORT_CONSTANTS
  1209. #define MICROPY_PORT_CONSTANTS
  1210. #endif
  1211. // Any root pointers for GC scanning - see mpstate.c
  1212. #ifndef MICROPY_PORT_ROOT_POINTERS
  1213. #define MICROPY_PORT_ROOT_POINTERS
  1214. #endif
  1215. /*****************************************************************************/
  1216. /* Hooks for a port to wrap functions with attributes */
  1217. #ifndef MICROPY_WRAP_MP_KEYBOARD_INTERRUPT
  1218. #define MICROPY_WRAP_MP_KEYBOARD_INTERRUPT(f) f
  1219. #endif
  1220. #ifndef MICROPY_WRAP_MP_SCHED_SCHEDULE
  1221. #define MICROPY_WRAP_MP_SCHED_SCHEDULE(f) f
  1222. #endif
  1223. /*****************************************************************************/
  1224. /* Miscellaneous settings */
  1225. // All uPy objects in ROM must be aligned on at least a 4 byte boundary
  1226. // so that the small-int/qstr/pointer distinction can be made. For machines
  1227. // that don't do this (eg 16-bit CPU), define the following macro to something
  1228. // like __attribute__((aligned(4))).
  1229. #ifndef MICROPY_OBJ_BASE_ALIGNMENT
  1230. #define MICROPY_OBJ_BASE_ALIGNMENT
  1231. #endif
  1232. // On embedded platforms, these will typically enable/disable irqs.
  1233. #ifndef MICROPY_BEGIN_ATOMIC_SECTION
  1234. #define MICROPY_BEGIN_ATOMIC_SECTION() (0)
  1235. #endif
  1236. #ifndef MICROPY_END_ATOMIC_SECTION
  1237. #define MICROPY_END_ATOMIC_SECTION(state) (void)(state)
  1238. #endif
  1239. // Allow to override static modifier for global objects, e.g. to use with
  1240. // object code analysis tools which don't support static symbols.
  1241. #ifndef STATIC
  1242. #define STATIC static
  1243. #endif
  1244. // Number of bytes in a word
  1245. #ifndef BYTES_PER_WORD
  1246. #define BYTES_PER_WORD (sizeof(mp_uint_t))
  1247. #endif
  1248. #ifndef BITS_PER_BYTE
  1249. #define BITS_PER_BYTE (8)
  1250. #endif
  1251. #define BITS_PER_WORD (BITS_PER_BYTE * BYTES_PER_WORD)
  1252. // mp_int_t value with most significant bit set
  1253. #define WORD_MSBIT_HIGH (((mp_uint_t)1) << (BYTES_PER_WORD * 8 - 1))
  1254. // Make sure both MP_ENDIANNESS_LITTLE and MP_ENDIANNESS_BIG are
  1255. // defined and that they are the opposite of each other.
  1256. #if defined(MP_ENDIANNESS_LITTLE)
  1257. #define MP_ENDIANNESS_BIG (!MP_ENDIANNESS_LITTLE)
  1258. #elif defined(MP_ENDIANNESS_BIG)
  1259. #define MP_ENDIANNESS_LITTLE (!MP_ENDIANNESS_BIG)
  1260. #else
  1261. // Endianness not defined by port so try to autodetect it.
  1262. #if defined(__BYTE_ORDER__)
  1263. #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
  1264. #define MP_ENDIANNESS_LITTLE (1)
  1265. #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
  1266. #define MP_ENDIANNESS_LITTLE (0)
  1267. #endif
  1268. #else
  1269. #include <endian.h>
  1270. #if defined(__BYTE_ORDER)
  1271. #if __BYTE_ORDER == __LITTLE_ENDIAN
  1272. #define MP_ENDIANNESS_LITTLE (1)
  1273. #elif __BYTE_ORDER == __BIG_ENDIAN
  1274. #define MP_ENDIANNESS_LITTLE (0)
  1275. #endif
  1276. #endif
  1277. #endif
  1278. #ifndef MP_ENDIANNESS_LITTLE
  1279. #error endianness not defined and cannot detect it
  1280. #endif
  1281. #define MP_ENDIANNESS_BIG (!MP_ENDIANNESS_LITTLE)
  1282. #endif
  1283. // Make a pointer to RAM callable (eg set lower bit for Thumb code)
  1284. // (This scheme won't work if we want to mix Thumb and normal ARM code.)
  1285. #ifndef MICROPY_MAKE_POINTER_CALLABLE
  1286. #define MICROPY_MAKE_POINTER_CALLABLE(p) (p)
  1287. #endif
  1288. // If these MP_PLAT_*_EXEC macros are overridden then the memory allocated by them
  1289. // must be somehow reachable for marking by the GC, since the native code
  1290. // generators store pointers to GC managed memory in the code.
  1291. #ifndef MP_PLAT_ALLOC_EXEC
  1292. #define MP_PLAT_ALLOC_EXEC(min_size, ptr, size) do { *ptr = m_new(byte, min_size); *size = min_size; } while (0)
  1293. #endif
  1294. #ifndef MP_PLAT_FREE_EXEC
  1295. #define MP_PLAT_FREE_EXEC(ptr, size) m_del(byte, ptr, size)
  1296. #endif
  1297. // This macro is used to do all output (except when MICROPY_PY_IO is defined)
  1298. #ifndef MP_PLAT_PRINT_STRN
  1299. #define MP_PLAT_PRINT_STRN(str, len) mp_hal_stdout_tx_strn_cooked(str, len)
  1300. #endif
  1301. #ifndef MP_SSIZE_MAX
  1302. #define MP_SSIZE_MAX SSIZE_MAX
  1303. #endif
  1304. // printf format spec to use for mp_int_t and friends
  1305. #ifndef INT_FMT
  1306. #if defined(__LP64__)
  1307. // Archs where mp_int_t == long, long != int
  1308. #define UINT_FMT "%lu"
  1309. #define INT_FMT "%ld"
  1310. #elif defined(_WIN64)
  1311. #define UINT_FMT "%llu"
  1312. #define INT_FMT "%lld"
  1313. #else
  1314. // Archs where mp_int_t == int
  1315. #define UINT_FMT "%u"
  1316. #define INT_FMT "%d"
  1317. #endif
  1318. #endif // INT_FMT
  1319. // Modifier for function which doesn't return
  1320. #ifndef NORETURN
  1321. #define NORETURN __attribute__((noreturn))
  1322. #endif
  1323. // Modifier for weak functions
  1324. #ifndef MP_WEAK
  1325. #define MP_WEAK __attribute__((weak))
  1326. #endif
  1327. // Modifier for functions which should be never inlined
  1328. #ifndef MP_NOINLINE
  1329. #define MP_NOINLINE __attribute__((noinline))
  1330. #endif
  1331. // Modifier for functions which should be always inlined
  1332. #ifndef MP_ALWAYSINLINE
  1333. #define MP_ALWAYSINLINE __attribute__((always_inline))
  1334. #endif
  1335. // Condition is likely to be true, to help branch prediction
  1336. #ifndef MP_LIKELY
  1337. #define MP_LIKELY(x) __builtin_expect((x), 1)
  1338. #endif
  1339. // Condition is likely to be false, to help branch prediction
  1340. #ifndef MP_UNLIKELY
  1341. #define MP_UNLIKELY(x) __builtin_expect((x), 0)
  1342. #endif
  1343. // To annotate that code is unreachable
  1344. #ifndef MP_UNREACHABLE
  1345. #if defined(__GNUC__)
  1346. #define MP_UNREACHABLE __builtin_unreachable();
  1347. #else
  1348. #define MP_UNREACHABLE for (;;);
  1349. #endif
  1350. #endif
  1351. // Explicitly annotate switch case fall throughs
  1352. #if defined(__GNUC__) && __GNUC__ >= 7
  1353. #define MP_FALLTHROUGH __attribute__((fallthrough));
  1354. #else
  1355. #define MP_FALLTHROUGH
  1356. #endif
  1357. #ifndef MP_HTOBE16
  1358. #if MP_ENDIANNESS_LITTLE
  1359. #define MP_HTOBE16(x) ((uint16_t)((((x) & 0xff) << 8) | (((x) >> 8) & 0xff)))
  1360. #define MP_BE16TOH(x) MP_HTOBE16(x)
  1361. #else
  1362. #define MP_HTOBE16(x) (x)
  1363. #define MP_BE16TOH(x) (x)
  1364. #endif
  1365. #endif
  1366. #ifndef MP_HTOBE32
  1367. #if MP_ENDIANNESS_LITTLE
  1368. #define MP_HTOBE32(x) ((uint32_t)((((x) & 0xff) << 24) | (((x) & 0xff00) << 8) | (((x) >> 8) & 0xff00) | (((x) >> 24) & 0xff)))
  1369. #define MP_BE32TOH(x) MP_HTOBE32(x)
  1370. #else
  1371. #define MP_HTOBE32(x) (x)
  1372. #define MP_BE32TOH(x) (x)
  1373. #endif
  1374. #endif
  1375. // Warning categories are by default implemented as strings, though
  1376. // hook is left for a port to define them as something else.
  1377. #if MICROPY_WARNINGS_CATEGORY
  1378. #ifndef MP_WARN_CAT
  1379. #define MP_WARN_CAT(x) #x
  1380. #endif
  1381. #else
  1382. #undef MP_WARN_CAT
  1383. #define MP_WARN_CAT(x) (NULL)
  1384. #endif
  1385. // Feature dependency check.
  1386. #if MICROPY_PY_SYS_SETTRACE
  1387. #if !MICROPY_PERSISTENT_CODE_SAVE
  1388. #error "MICROPY_PY_SYS_SETTRACE requires MICROPY_PERSISTENT_CODE_SAVE to be enabled"
  1389. #endif
  1390. #if MICROPY_COMP_CONST
  1391. #error "MICROPY_PY_SYS_SETTRACE requires MICROPY_COMP_CONST to be disabled"
  1392. #endif
  1393. #endif
  1394. #endif // MICROPY_INCLUDED_PY_MPCONFIG_H