π
<-
Chat plein-écran
[^]

À quand KhiCas pour TI-83 Premium CE / Edition Python ?

Assembleur, Axe, C/C++, ICE...

Re: À quand KhiCas pour TI-83 Premium CE / Edition Python ?

Message non lude parisse » 23 Jan 2023, 08:02

Adriweb a écrit:Un programme/app de 350K ça serait pas de taille moyenne, mais ça serait de très loin le plus gros sur CE (j'exclue le cas particulier de l'app python de TI parce que la majorité du poids c'est le firmware du coprocesseur - mais même avec ça il me semble que c'est pas aussi gros? Je sais plus :p)

En fait l'application lua de CBG serait un très bon exemple (lua prend 255K d'après CBG), mais en regardant https://www.cemetech.net/forum/viewtopic.php?p=299723 et le github de CBG je ne vois pas de code source public, et ce n'est pas clair que ca tourne sur la calculatrice physique, et pas juste sur l'emulateur.
Avant de me lancer sur la 83, je dois évaluer si l'investissement en travail a des chances raisonnables de succès. J'étais dans une situation analogue en 2018 avec les calculatrices Casio, mais c'était nettement plus favorable : j'avais sous la main le code source d'Eigenmaths (pour m'exercer sur de la taille moyenne avant de passer à plus gros) et une architecture cible dont la difficulté principale à gérer était l'endianness. D'ailleurs, ce serait intéressant de comprendre pourquoi personne ne semble avoir essayé de porter Eigenmaths sur la CE, alors que le portage sur Casio occupe un peu moins de 300K et que les solutions existantes de calcul symbolique sur 83/84+ sont loin d'être satisfaisantes à ce jour. Pourtant le potentiel d'utilisateurs est très important!

Pour la STL, on a déjà fait des essais à priori conclusifs avec uSTL.

Bonne nouvelle, est-il prévu de l'intégrer directement à la toolchain?
Avatar de l’utilisateur
parisseVIP++
Niveau 12: CP (Calculatrice sur Pattes)
Niveau 12: CP (Calculatrice sur Pattes)
Prochain niv.: 77.8%
 
Messages: 3511
Inscription: 13 Déc 2013, 16:35
Genre: Non spécifié
Calculatrice(s):
MyCalcs profile

Re: À quand KhiCas pour TI-83 Premium CE / Edition Python ?

Message non lude Adriweb » 23 Jan 2023, 08:28

Pour la compilation réussie (et c'est tout, ca ne va pas plus loin :p) de python sur CE, c'était donc micropython, et mateo avait mis sa branche ez80 sur github: https://github.com/mateoconlechuga/micr ... /tree/ez80

En fait côté app, ce n'est pas "super balisé" parce que cette extension non-intégrée et "non officielle" est tout juste sortie il y a quelques semaines je crois, et donc en gros personne en l'a pas encore utilisée ou presque. La toolchain n'est à la base pas du tout prévue pour ça (programmes sous formes d'app), et donc aucune doc n'est dispo pour. C'est encore quasiment de l'ordre du bidouillage... et il y a des problèmes connus lors de l'utilisation (des fonctionnalités de débug qui ne fonctionnent plus par exemple, j'ai entendu dire). Je ne sais pas si ça va finir par être upstreamé dans la toolchain, il y a encore du boulot je pense (et de tests, et de doc). Peut être une intégration préliminaire sur le project builder pourrait être envisagée cela dit...
Ça ne devrait pas avoir de différence entre CEmu et une vraie calc, pour son app Lua d'ailleurs (au passage, CEmu est en train d'évoluer grandement ces jours ci, pour la gestion du hardware rev M, avec les travaux de jacobly il y a quelques temps, et de nos jours repris et améliorés avec les connaissances actuelles plus vastes, par Calc84Maniac)

Je vais voir avec CBG s'il peut partager son état actuel de Lua pour se donner une meilleure idée de ce qu'il a du faire. (Il ne l'a pas encore fait parce qu'il voulait mettre en place le système de libs en flash/app d'abord, ce qui n'est pas un problème résolu pour le moment).
Pour le moment je l'ai déjà informé de ce topic. Peut être qu'il passera par ici répondre.

En ce qui concerne la uSTL/tinySTL (c'était plutôt cette dernière en fait avec laquelle j'avais fait des essais concluants), pas de plans immédiats pour l'intégrer dans la toolchain mais bon heureusement ça devrait être simple de rajouter ça dans son propre projet.
Je pourrai essayer de regarder ça aussi cote project builder d'ailleurs :)

Au passage, la toolchain CE a fini par gérer les entiers 64 bits depuis une version relativement récente, mais ne gère pas les flottants 64 bits (les doubles sont en fait gérés comme des floats, à l'heure actuelle).

Pour ce qui est de support, on est "tous" sur le IRC #ez80-dev d'EFNet (bridgé au même channel du server CE-Programming sur Discord, ici, l'avantage c'est que ça n'a pas besoin d'être autant synchrone que IRC vu que l'historique est disponible et conservé par le serveur). Cote forum, ca serait ici ou cemetech (la bas directement en anglais donc possiblement plus simple pour eux puisqu'ils y sont déjà tout le temps). Mais bon les 2 personnes qui pourraient aider pour tout ceci seraient à priori MateoC et CBG. Il y aurait sinon Jacobly niveau compilateur forcément mais je suis pas sûr qu'on en arrive à des problématiques de clang pour l'instant
Image

MyCalcs: Help the community's calculator documentations by filling out your calculators info!
MyCalcs: Aidez la communauté à documenter les calculatrices en donnant des infos sur vos calculatrices !
Inspired-Lua.org: All about TI-Nspire Lua programming (tutorials, wiki/docs...)
Avatar de l’utilisateur
AdriwebAdmin
Niveau 16: CC2 (Commandeur des Calculatrices)
Niveau 16: CC2 (Commandeur des Calculatrices)
Prochain niv.: 80.2%
 
Messages: 14614
Images: 1218
Inscription: 01 Juin 2007, 00:00
Localisation: France
Genre: Homme
Calculatrice(s):
MyCalcs profile
Twitter/X: adriweb
GitHub: adriweb

Re: À quand KhiCas pour TI-83 Premium CE / Edition Python ?

Message non lude parisse » 23 Jan 2023, 09:50

Pas mal de points encourageants, merci!
On a donc un port de la micropython qui compile et qui devrait etre utilisable sous forme de librairie statique, ce qui est attendu par micropy.

As-tu le lien d'une tinySTL qui fonctionne? Je vois https://github.com/mendsley/tinystl/tree/master/include/TINYSTL, ou il manque map. Le lien https://github.com/frezcirno/TinySTL semble plus complet, avec en prime une lib d'entiers multi-précision. Ca pourrait me permettre de commencer à tester l'environnement de développement, en compilant dans un premier temps une version de micropy sans interpréteur réel.

Le support des entiers 64 bits par le compilateur est très intéressant. Il pourrait permettre de faire un mini-CAS sans multi-précision, qui pourrait suffire pour la quasi-totalité des situations rencontrées sur une calculatrice. Il peut aussi permettre de supporter giac si j'arrive à remplacer partout où c'est nécessaire int et long long par les types ayant le bon nombre de bits.

Je vais en rester aux forums pour les discussions.
Avatar de l’utilisateur
parisseVIP++
Niveau 12: CP (Calculatrice sur Pattes)
Niveau 12: CP (Calculatrice sur Pattes)
Prochain niv.: 77.8%
 
Messages: 3511
Inscription: 13 Déc 2013, 16:35
Genre: Non spécifié
Calculatrice(s):
MyCalcs profile

Re: À quand KhiCas pour TI-83 Premium CE / Edition Python ?

Message non lude parisse » 23 Jan 2023, 10:05

P.S.: il faudrait aussi comprendre comment fonctionne la flash exécutable. Car pour un projet moyen ou gros, le code executable, la data read-only doivent être en flash, on pourrait disposer de 64K de heap en 0xD1987E, et garder l'espace en 0xD052C6 (60K) pour stack, data et bss.
Avatar de l’utilisateur
parisseVIP++
Niveau 12: CP (Calculatrice sur Pattes)
Niveau 12: CP (Calculatrice sur Pattes)
Prochain niv.: 77.8%
 
Messages: 3511
Inscription: 13 Déc 2013, 16:35
Genre: Non spécifié
Calculatrice(s):
MyCalcs profile

Re: À quand KhiCas pour TI-83 Premium CE / Edition Python ?

Message non lude Adriweb » 23 Jan 2023, 13:31

Pour TinySTL je n'ai plus l'origine mais bon de toute façon il faudra prendre la plus complète qui compile et semble fonctionner ^^

Pour l'exécution en flash et les différentes zones utilisées, tout est déjà suffisamment connu, mais pas par moi et encore moins de tête :p

Je crois qu'il faudra au moins qu'il n'y ait pas de SMC dans les endroits en flash puisque ça c'est possible uniquement en RAM. Mais bon ça ça devrait être OK pour du code compile et pas de l'asm optimisé/écrit à la main.
Image

MyCalcs: Help the community's calculator documentations by filling out your calculators info!
MyCalcs: Aidez la communauté à documenter les calculatrices en donnant des infos sur vos calculatrices !
Inspired-Lua.org: All about TI-Nspire Lua programming (tutorials, wiki/docs...)
Avatar de l’utilisateur
AdriwebAdmin
Niveau 16: CC2 (Commandeur des Calculatrices)
Niveau 16: CC2 (Commandeur des Calculatrices)
Prochain niv.: 80.2%
 
Messages: 14614
Images: 1218
Inscription: 01 Juin 2007, 00:00
Localisation: France
Genre: Homme
Calculatrice(s):
MyCalcs profile
Twitter/X: adriweb
GitHub: adriweb

Re: À quand KhiCas pour TI-83 Premium CE / Edition Python ?

Message non lude parisse » 23 Jan 2023, 13:42

Qu'est-ce que SMC?
Avatar de l’utilisateur
parisseVIP++
Niveau 12: CP (Calculatrice sur Pattes)
Niveau 12: CP (Calculatrice sur Pattes)
Prochain niv.: 77.8%
 
Messages: 3511
Inscription: 13 Déc 2013, 16:35
Genre: Non spécifié
Calculatrice(s):
MyCalcs profile

Re: À quand KhiCas pour TI-83 Premium CE / Edition Python ?

Message non lude Adriweb » 23 Jan 2023, 13:49

Self Modifying Code
Image

MyCalcs: Help the community's calculator documentations by filling out your calculators info!
MyCalcs: Aidez la communauté à documenter les calculatrices en donnant des infos sur vos calculatrices !
Inspired-Lua.org: All about TI-Nspire Lua programming (tutorials, wiki/docs...)
Avatar de l’utilisateur
AdriwebAdmin
Niveau 16: CC2 (Commandeur des Calculatrices)
Niveau 16: CC2 (Commandeur des Calculatrices)
Prochain niv.: 80.2%
 
Messages: 14614
Images: 1218
Inscription: 01 Juin 2007, 00:00
Localisation: France
Genre: Homme
Calculatrice(s):
MyCalcs profile
Twitter/X: adriweb
GitHub: adriweb

Re: À quand KhiCas pour TI-83 Premium CE / Edition Python ?

Message non lude parisse » 23 Jan 2023, 14:43

Merci pour l'éclaircissement. Ca ne concerne ni micropy ni giac (en fait ça ne doit pas concerner grand monde...)
Avatar de l’utilisateur
parisseVIP++
Niveau 12: CP (Calculatrice sur Pattes)
Niveau 12: CP (Calculatrice sur Pattes)
Prochain niv.: 77.8%
 
Messages: 3511
Inscription: 13 Déc 2013, 16:35
Genre: Non spécifié
Calculatrice(s):
MyCalcs profile

Re: À quand KhiCas pour TI-83 Premium CE / Edition Python ?

Message non lude parisse » 24 Jan 2023, 08:26

J'ai installé la toolchain (package debian 11) et essayé de compiler micropython à partir de https://github.com/mateoconlechuga/micropython/tree/ez80 sans rien changer à part une petite correction sur le path de crt0.src dans le Makefile.
Ensuite j'ai une erreur fatale:
Code: Tout sélectionner
python3 ../../py/makeversionhdr.py build/genhdr/mpversion.h
CC ../../py/gc.c
ez80-clang -S -Wall -Werror -std=c99 -Wdouble-promotion -Wfloat-conversion -Oz -nostdlib -nostdinc -isystem /home/parisse/CEdev/include -I. -I../.. -Ibuild -fno-threadsafe-statics -Xclang -fforce-mangle-main-argc-argv -mllvm -profile-guided-section-prefix=false -D_EZ80 -DHAS_PRINTF=1 -DFFCONF_H=\"lib/oofatfs/ffconf.h\" -DFFCONF_H=\"lib/oofatfs/ffconf.h\" -O3 -c -MD -o build/py/gc.o ../../py/gc.c
fatal error: error in backend: unable to legalize instruction: %63:_(s48) = G_LSHR %61:_, %64:_(s8) (in function: gc_init)
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.   Program arguments: ez80-clang -S -Wall -Werror -std=c99 -Wdouble-promotion -Wfloat-conversion -Oz -nostdlib -nostdinc -isystem /home/parisse/CEdev/include -I. -I../.. -Ibuild -fno-threadsafe-statics -Xclang -fforce-mangle-main-argc-argv -mllvm -profile-guided-section-prefix=false -D_EZ80 -DHAS_PRINTF=1 -DFFCONF_H=\"lib/oofatfs/ffconf.h\" -DFFCONF_H=\"lib/oofatfs/ffconf.h\" -O3 -c -MD -o build/py/gc.o ../../py/gc.c
1.   <eof> parser at end of file
2.   Code generation
3.   Running pass 'Function Pass Manager' on module '../../py/gc.c'.
4.   Running pass 'Legalizer' on function '@gc_init'
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
ez80-clang(_ZN4llvm3sys15PrintStackTraceERNS_11raw_ostreamEi+0x23)[0x201d1e3]
ez80-clang(_ZN4llvm3sys17RunSignalHandlersEv+0xee)[0x201b10e]
ez80-clang(_ZN4llvm3sys15CleanupOnSignalEm+0xdd)[0x201c70d]
ez80-clang[0x1f94e2a]
ez80-clang[0x1f94dcb]
ez80-clang(_ZN4llvm3sys7Process4ExitEib+0x27)[0x20174c7]
ez80-clang[0x11d0dc2]
ez80-clang(_ZN4llvm18report_fatal_errorERKNS_5TwineEb+0x128)[0x1f98a38]
ez80-clang[0x2de4fa4]
ez80-clang(_ZN4llvm18reportGISelFailureERNS_15MachineFunctionERKNS_16TargetPassConfigERNS_32MachineOptimizationRemarkEmitterEPKcNS_9StringRefERKNS_12MachineInstrE+0x2fd)[0x2de52cd]
ez80-clang(_ZN4llvm9Legalizer20runOnMachineFunctionERNS_15MachineFunctionE+0x355)[0x2d8d175]
ez80-clang(_ZN4llvm19MachineFunctionPass13runOnFunctionERNS_8FunctionE+0x10e)[0x15957ee]
ez80-clang(_ZN4llvm13FPPassManager13runOnFunctionERNS_8FunctionE+0x39d)[0x1959a8d]
ez80-clang(_ZN4llvm13FPPassManager11runOnModuleERNS_6ModuleE+0x33)[0x195f703]
ez80-clang(_ZN4llvm6legacy15PassManagerImpl3runERNS_6ModuleE+0x3cf)[0x195a0cf]
ez80-clang(_ZN5clang17EmitBackendOutputERNS_17DiagnosticsEngineERKNS_19HeaderSearchOptionsERKNS_14CodeGenOptionsERKNS_13TargetOptionsERKNS_11LangOptionsEN4llvm9StringRefEPNSE_6ModuleENS_13BackendActionESt10unique_ptrINSE_17raw_pwrite_streamESt14default_deleteISK_EE+0x1bf4)[0x229d914]
ez80-clang[0x2b066f8]
ez80-clang(_ZN5clang8ParseASTERNS_4SemaEbb+0x2a3)[0x39c3b03]
ez80-clang(_ZN5clang14FrontendAction7ExecuteEv+0x57)[0x2a592a7]
ez80-clang(_ZN5clang16CompilerInstance13ExecuteActionERNS_14FrontendActionE+0x346)[0x29d0aa6]
ez80-clang(_ZN5clang25ExecuteCompilerInvocationEPNS_16CompilerInstanceE+0x27b)[0x2b00c6b]
ez80-clang(_Z8cc1_mainN4llvm8ArrayRefIPKcEES2_Pv+0xad8)[0x11d0a78]
ez80-clang[0x11cebab]
ez80-clang[0x2858a42]
ez80-clang(_ZN4llvm20CrashRecoveryContext9RunSafelyENS_12function_refIFvvEEE+0xdd)[0x1f94dad]
ez80-clang(_ZNK5clang6driver10CC1Command7ExecuteEN4llvm8ArrayRefINS2_8OptionalINS2_9StringRefEEEEEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPb+0x134)[0x2858574]
ez80-clang(_ZNK5clang6driver11Compilation14ExecuteCommandERKNS0_7CommandERPS3_+0x1a4)[0x281bae4]
ez80-clang(_ZNK5clang6driver11Compilation11ExecuteJobsERKNS0_7JobListERN4llvm15SmallVectorImplISt4pairIiPKNS0_7CommandEEEE+0x77)[0x281bf77]
ez80-clang(_ZN5clang6driver6Driver18ExecuteCompilationERNS0_11CompilationERN4llvm15SmallVectorImplISt4pairIiPKNS0_7CommandEEEE+0x188)[0x28386f8]
ez80-clang(main+0x2737)[0x11ce2b7]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xea)[0x7fa9a2beed0a]
ez80-clang(_start+0x2e)[0x11cb8ae]
ez80-clang: error: clang frontend command failed with exit code 70 (use -v to see invocation)
clang version 15.0.0 (https://github.com/jacobly0/llvm-project 6d9aa7a16db70f3d02ae304b08d4a03011281fef)
Target: ez80
Thread model: posix
InstalledDir: /home/parisse/CEdev/bin
ez80-clang: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
ez80-clang: note: diagnostic msg: /tmp/gc-961ef8.c
ez80-clang: note: diagnostic msg: /tmp/gc-961ef8.sh
ez80-clang: note: diagnostic msg:

********************
make: *** [../../py/mkrules.mk:77 : build/py/gc.o] Erreur 1

le fichier c preprocessed
Code: Tout sélectionner
# 1 "<built-in>"
# 1 "../../py/gc.c"
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2013, 2014 Damien P. George
* Copyright (c) 2014 Paul Sokolovsky
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

#if 0 /* expanded by -frewrite-includes */
#include <assert.h>
#endif /* expanded by -frewrite-includes */
# 28 "../../py/gc.c"
# 1 "/home/parisse/CEdev/include/assert.h" 1 3
#ifndef _ASSERT_H
#define _ASSERT_H

#if 0 /* expanded by -frewrite-includes */
#include <cdefs.h>
#endif /* expanded by -frewrite-includes */
# 4 "/home/parisse/CEdev/include/assert.h" 3
# 1 "/home/parisse/CEdev/include/cdefs.h" 1 3
#ifndef _CDEFS_H
#define _CDEFS_H

#define __JOIN2(x, y)     x ## y
#define __JOIN3(x, y, z)  x ## y ## z
#define __CONCAT(x, y)    __JOIN2(x, y)
#define __TOSTRING(x)     #x

#define __STDINT_C(C, T)  __CONCAT(C, __##T##_C_SUFFIX__)
#define __STDINT_WIDTH(T) (sizeof(__##T##_TYPE__)*__CHAR_BIT__)

#ifndef __cplusplus
# define __BEGIN_DECLS
# define __END_DECLS
# define __NOEXCEPT     __attribute__((__nothrow__, __leaf__))
# define __IGNORE(expr) ((void)(expr))
#else /* __cplusplus */
# 18 "/home/parisse/CEdev/include/cdefs.h" 3
# define __BEGIN_DECLS  extern "C" {
# define __END_DECLS    }
# define __NOEXCEPT     noexcept
# define __IGNORE(expr) (static_cast<void>(expr))
#endif /* __cplusplus */
# 23 "/home/parisse/CEdev/include/cdefs.h" 3

#ifndef NULL
# ifndef __cplusplus
#  define NULL ((void *)0)
# else /* __cplusplus */
# 28 "/home/parisse/CEdev/include/cdefs.h" 3
#  define NULL 0
# endif /* __cplusplus */
# 30 "/home/parisse/CEdev/include/cdefs.h" 3
#endif /* NULL */
# 31 "/home/parisse/CEdev/include/cdefs.h" 3

#ifndef SIZE_T_DEFINED
#define SIZE_T_DEFINED
typedef __SIZE_TYPE__ size_t;
#endif /* SIZE_T_DEFINED */
# 36 "/home/parisse/CEdev/include/cdefs.h" 3

#endif /* _CDEFS_H */
# 38 "/home/parisse/CEdev/include/cdefs.h" 3
# 5 "/home/parisse/CEdev/include/assert.h" 2 3

#ifdef NDEBUG

# define assert(expr) __IGNORE(0)

#else /* NDEBUG */
# 11 "/home/parisse/CEdev/include/assert.h" 3

__BEGIN_DECLS

struct __assert_loc {
    const char *__file;
    __UINT32_TYPE__ __line;
    const char *__function;
    const char *__assertion;
};

extern void __assert_fail_loc(const struct __assert_loc *__loc)
    __NOEXCEPT __attribute__((__cold__, __noreturn__));

__END_DECLS

/* Avoid putting extra parens around expr because it can hide warnings. */
# define assert(expr) do if (expr) {} else {                            \
            static const struct __assert_loc __loc = {                  \
                .__file = __FILE__,                                     \
                .__line = __STDINT_C(__LINE__, UINT32),                 \
                .__function = __extension__ __PRETTY_FUNCTION__,        \
                .__assertion = #expr,                                   \
            };                                                          \
            __assert_fail_loc(&__loc);                                  \
        } while (0)

#endif /* NDEBUG */
# 38 "/home/parisse/CEdev/include/assert.h" 3

#if 0 /* disabled by -frewrite-includes */
#if __STDC_VERSION__ >= 201112L && !defined(__cplusplus)
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 40 "/home/parisse/CEdev/include/assert.h" 3
# undef static_assert
# define static_assert _Static_assert
#endif
# 43 "/home/parisse/CEdev/include/assert.h" 3

#endif /* _ASSERT_H */
# 45 "/home/parisse/CEdev/include/assert.h" 3
# 29 "../../py/gc.c" 2
#if 0 /* expanded by -frewrite-includes */
#include <stdio.h>
#endif /* expanded by -frewrite-includes */
# 29 "../../py/gc.c"
# 1 "/home/parisse/CEdev/include/stdio.h" 1 3
#ifndef _STDIO_H
#define _STDIO_H

#if 0 /* expanded by -frewrite-includes */
#include <cdefs.h>
#endif /* expanded by -frewrite-includes */
# 4 "/home/parisse/CEdev/include/stdio.h" 3
# 5 "/home/parisse/CEdev/include/stdio.h" 3
#if 0 /* expanded by -frewrite-includes */
#include <stdarg.h>
#endif /* expanded by -frewrite-includes */
# 5 "/home/parisse/CEdev/include/stdio.h" 3
# 1 "/home/parisse/CEdev/include/stdarg.h" 1 3
#ifndef _STDARG_H
#define _STDARG_H

#ifndef __GNUC_VA_LIST
#define __GNUC_VA_LIST
typedef __builtin_va_list __gnuc_va_list;
#endif /* __GNUC_VA_LIST */
# 8 "/home/parisse/CEdev/include/stdarg.h" 3

#ifndef _VA_LIST
#define _VA_LIST
typedef __builtin_va_list va_list;
#endif /* _VA_LIST */
# 13 "/home/parisse/CEdev/include/stdarg.h" 3

#define va_start(ap, param)  __builtin_va_start(ap, param)
#define va_end(ap)           __builtin_va_end(ap)
#define va_arg(ap, type)     __builtin_va_arg(ap, type)
#define __va_copy(dest, src) __builtin_va_copy(dest, src)
#if 0 /* disabled by -frewrite-includes */
#if __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L
#endif
#endif /* disabled by -frewrite-includes */
#if 1 /* evaluated by -frewrite-includes */
# 19 "/home/parisse/CEdev/include/stdarg.h" 3
# define va_copy(dest, src)   __builtin_va_copy(dest, src)
#endif /* __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L */
# 21 "/home/parisse/CEdev/include/stdarg.h" 3

#endif /* _STDARG_H */
# 23 "/home/parisse/CEdev/include/stdarg.h" 3
# 6 "/home/parisse/CEdev/include/stdio.h" 2 3

#ifdef HAS_CUSTOM_FILE
#if 0 /* expanded by -frewrite-includes */
#include CUSTOM_FILE_FILE
#endif /* expanded by -frewrite-includes */
# 8 "/home/parisse/CEdev/include/stdio.h" 3
# 9 "/home/parisse/CEdev/include/stdio.h" 3
#else
# 10 "/home/parisse/CEdev/include/stdio.h" 3
typedef struct
{
    unsigned char slot;
    unsigned char eof;
    unsigned char err;
} FILE;
#define FOPEN_MAX  5
#define stdin      ((FILE*)1)
#define stdout     ((FILE*)2)
#define stderr     ((FILE*)2)
#endif
# 21 "/home/parisse/CEdev/include/stdio.h" 3

#ifndef EOF
#define EOF (-1)
#endif
# 25 "/home/parisse/CEdev/include/stdio.h" 3

#ifndef SEEK_CUR
#define SEEK_CUR  1
#endif
# 29 "/home/parisse/CEdev/include/stdio.h" 3
#ifndef SEEK_END
#define SEEK_END  2
#endif
# 32 "/home/parisse/CEdev/include/stdio.h" 3
#ifndef SEEK_SET
#define SEEK_SET  0
#endif
# 35 "/home/parisse/CEdev/include/stdio.h" 3

__BEGIN_DECLS

/* weak user-defined functions */
char inchar(void);

void outchar(char character);

FILE *fopen(const char *__restrict filename,
    const char *__restrict mode);

int fclose(FILE *stream);

int fflush(FILE *stream);

int ferror(FILE *stream);

int feof(FILE *stream);

void clearerr(FILE *stream);

int fputs(const char *__restrict str, FILE *__restrict stream);

size_t fread(void *ptr, size_t size, size_t count, FILE *__restrict stream);

size_t fwrite(const void *__restrict ptr, size_t size, size_t count,
    FILE *__restrict stream);

long int ftell(FILE *stream) __attribute__((__warn_unused_result__));

int fseek(FILE *stream, long int offset, int origin);

int fgetc(FILE *stream);
#define getc(...) fgetc(__VA_ARGS__)

int fputc(int c, FILE *stream);
#define putc(...) fputc(__VA_ARGS__)

char *fgets(char *__restrict str, int num, FILE *__restrict stream);

int remove(const char *filename);

void rewind(FILE *stream);

/* standard impls */
int getchar(void);

int putchar(int character);

int puts(const char *str);

int printf(const char *__restrict format, ...)
    __attribute__((format(__printf__, 1, 2)));

int vprintf(const char *__restrict format, va_list va)
    __attribute__((format(__printf__, 1, 0)));

int vsprintf(char *__restrict buffer, const char *__restrict format,
    va_list va)
    __attribute__((format(__printf__, 1, 0)));

int snprintf(char* buffer, size_t count, const char *__restrict format, ...)
    __attribute__((format(__printf__, 3, 4)));

int vsnprintf(char* buffer, size_t count, const char *__restrict format,
    va_list va)
    __attribute__((format(__printf__, 3, 0)));

int sprintf(char *__restrict buffer,
    const char *__restrict format, ...)
    __attribute__ ((format (__printf__, 2, 3)));

__END_DECLS

#endif /* _STDIO_H */
# 110 "/home/parisse/CEdev/include/stdio.h" 3
# 30 "../../py/gc.c" 2
#if 0 /* expanded by -frewrite-includes */
#include <string.h>
#endif /* expanded by -frewrite-includes */
# 30 "../../py/gc.c"
# 1 "/home/parisse/CEdev/include/string.h" 1 3
#ifndef _STRING_H
#define _STRING_H

#if 0 /* expanded by -frewrite-includes */
#include <cdefs.h>
#endif /* expanded by -frewrite-includes */
# 4 "/home/parisse/CEdev/include/string.h" 3
# 5 "/home/parisse/CEdev/include/string.h" 3

__BEGIN_DECLS

extern void *memcpy(void *__restrict dest, const void *__restrict src,
                    size_t n) __attribute__((nonnull(1, 2)));

void *memmove(void *dest, const void *src, size_t n)
              __attribute__((nonnull(1, 2)));

void *memset(void *s, int c, size_t n) __attribute__((nonnull(1)));

int memcmp(const void *s1, const void *s2, size_t n)
          __attribute__((nonnull(1, 2)));

void *memchr(const void *s, int c, size_t n) __attribute__((nonnull(1)));

char *strcpy(char *__restrict dest, const char *__restrict src)
             __attribute__((nonnull(1, 2)));

char *strncpy(char *__restrict dest, const char *__restrict src, size_t n)
              __attribute__((nonnull(1, 2)));

char *strcat(char *__restrict dest, const char *__restrict src)
             __attribute__((nonnull(1, 2)));

char *strncat(char *__restrict dest, const char *__restrict src, size_t n)
              __attribute__((nonnull(1, 2)));

char *strchr(const char *s, int c) __attribute__((nonnull(1)));

char *strrchr(const char *s, int c) __attribute__((nonnull(1)));

char *strpbrk(const char *s, const char *accept) __attribute__((nonnull(1, 2)));

char *strstr(const char *haystack, const char *needle)
             __attribute__((nonnull(1, 2)));

char *strtok(char *__restrict s, const char *__restrict delim)
             __attribute__((nonnull(2)));

char *strdup(const char *s)
             __attribute__ ((__malloc__)) __attribute__((nonnull(1)));

char *strndup(const char *s, size_t n)
              __attribute__ ((__malloc__)) __attribute__((nonnull(1)));

size_t strcspn(const char *s, const char *reject)
               __attribute__((nonnull(1, 2)));

size_t strspn(const char *s, const char *accept)
              __attribute__((nonnull(1, 2)));

size_t strlen(const char *s)
              __attribute__((nonnull(1)));

size_t strnlen(const char *s, size_t maxlen)
               __attribute__((nonnull(1)));

int strcmp(const char *s1, const char *s2)
           __attribute__((nonnull(1, 2)));

int strncmp(const char *s1, const char *s2, size_t n)
            __attribute__((nonnull(1, 2)));

int strcasecmp(const char *s1, const char *s2)
               __attribute__((nonnull(1, 2)));

int strncasecmp(const char *s1, const char *s2, size_t n)
                __attribute__((nonnull(1, 2)));


__END_DECLS

#endif /* _STRING_H */
# 79 "/home/parisse/CEdev/include/string.h" 3
# 31 "../../py/gc.c" 2

#if 0 /* expanded by -frewrite-includes */
#include "py/gc.h"
#endif /* expanded by -frewrite-includes */
# 32 "../../py/gc.c"
# 1 "../../py/gc.h" 1
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef MICROPY_INCLUDED_PY_GC_H
#define MICROPY_INCLUDED_PY_GC_H

#if 0 /* expanded by -frewrite-includes */
#include <stdbool.h>
#endif /* expanded by -frewrite-includes */
# 29 "../../py/gc.h"
# 1 "/home/parisse/CEdev/include/stdbool.h" 1 3
#ifndef _STDBOOL_H
#define _STDBOOL_H

#ifndef __cplusplus

#define bool  _Bool
#define false 0
#define true  1

#else /* __cplusplus */
# 11 "/home/parisse/CEdev/include/stdbool.h" 3

#define _Bool bool

#endif /* __cplusplus */
# 15 "/home/parisse/CEdev/include/stdbool.h" 3

#define __bool_true_false_are_defined 1

#endif /* _STDBOOL_H */
# 19 "/home/parisse/CEdev/include/stdbool.h" 3
# 30 "../../py/gc.h" 2
#if 0 /* expanded by -frewrite-includes */
#include <stddef.h>
#endif /* expanded by -frewrite-includes */
# 30 "../../py/gc.h"
# 1 "/home/parisse/CEdev/include/stddef.h" 1 3
#ifndef _STDDEF_H
#define _STDDEF_H

#if 0 /* expanded by -frewrite-includes */
#include <cdefs.h>
#endif /* expanded by -frewrite-includes */
# 4 "/home/parisse/CEdev/include/stddef.h" 3
# 5 "/home/parisse/CEdev/include/stddef.h" 3

#define offsetof(type, member) __builtin_offsetof(type, member)

typedef __PTRDIFF_TYPE__ ptrdiff_t;

#ifndef _WCHAR_T_DEFINED
#define _WCHAR_T_DEFINED
#ifndef __cplusplus
typedef __WCHAR_TYPE__ wchar_t;
#endif /* __cplusplus */
# 15 "/home/parisse/CEdev/include/stddef.h" 3
#endif /* _WCHAR_T_DEFINED */
# 16 "/home/parisse/CEdev/include/stddef.h" 3

typedef struct {
    long long    __max_align_ll __attribute__((__aligned__(__alignof__(  long long))));
    long double  __max_align_ld __attribute__((__aligned__(__alignof__(long double))));
#ifdef __FLOAT128__
    __float128 __max_align_f128 __attribute__((__aligned__(__alignof__( __float128))));
#endif
# 23 "/home/parisse/CEdev/include/stddef.h" 3
} max_align_t;

#endif /* _STDDEF_H */
# 26 "/home/parisse/CEdev/include/stddef.h" 3
# 31 "../../py/gc.h" 2

void gc_init(void *start, void *end);

// These lock/unlock functions can be nested.
// They can be used to prevent the GC from allocating/freeing.
void gc_lock(void);
void gc_unlock(void);
bool gc_is_locked(void);

// A given port must implement gc_collect by using the other collect functions.
void gc_collect(void);
void gc_collect_start(void);
void gc_collect_root(void **ptrs, size_t len);
void gc_collect_end(void);

// Use this function to sweep the whole heap and run all finalisers
void gc_sweep_all(void);

enum {
    GC_ALLOC_FLAG_HAS_FINALISER = 1,
};

void *gc_alloc(size_t n_bytes, unsigned int alloc_flags);
void gc_free(void *ptr); // does not call finaliser
size_t gc_nbytes(const void *ptr);
void *gc_realloc(void *ptr, size_t n_bytes, bool allow_move);

typedef struct _gc_info_t {
    size_t total;
    size_t used;
    size_t free;
    size_t max_free;
    size_t num_1block;
    size_t num_2block;
    size_t max_block;
} gc_info_t;

void gc_info(gc_info_t *info);
void gc_dump_info(void);
void gc_dump_alloc_table(void);

#endif // MICROPY_INCLUDED_PY_GC_H
# 73 "../../py/gc.h"
# 33 "../../py/gc.c" 2
#if 0 /* expanded by -frewrite-includes */
#include "py/runtime.h"
#endif /* expanded by -frewrite-includes */
# 33 "../../py/gc.c"
# 1 "../../py/runtime.h" 1
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef MICROPY_INCLUDED_PY_RUNTIME_H
#define MICROPY_INCLUDED_PY_RUNTIME_H

#if 0 /* expanded by -frewrite-includes */
#include "py/mpstate.h"
#endif /* expanded by -frewrite-includes */
# 29 "../../py/runtime.h"
# 1 "../../py/mpstate.h" 1
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef MICROPY_INCLUDED_PY_MPSTATE_H
#define MICROPY_INCLUDED_PY_MPSTATE_H

#if 0 /* expanded by -frewrite-includes */
#include <stdint.h>
#endif /* expanded by -frewrite-includes */
# 29 "../../py/mpstate.h"
# 1 "/home/parisse/CEdev/include/stdint.h" 1 3
#ifndef _STDINT_H
#define _STDINT_H

#if 0 /* expanded by -frewrite-includes */
#include <cdefs.h>
#endif /* expanded by -frewrite-includes */
# 4 "/home/parisse/CEdev/include/stdint.h" 3
# 5 "/home/parisse/CEdev/include/stdint.h" 3

typedef          __INT8_TYPE__                        int8_t;
#define            INT8_MIN                       (~__INT8_MAX__)
#define            INT8_MAX                         __INT8_MAX__
#define            INT8_WIDTH          __STDINT_WIDTH(INT8)
#define            INT8_C(C)            __STDINT_C(C, INT8)
typedef         __UINT8_TYPE__                       uint8_t;
#define           UINT8_MAX                        __UINT8_MAX__
#define           UINT8_WIDTH         __STDINT_WIDTH(UINT8)
#define           UINT8_C(C)           __STDINT_C(C, UINT8)
typedef     __INT_FAST8_TYPE__                   int_fast8_t;
#define       INT_FAST8_MIN                  (~__INT_FAST8_MAX__)
#define       INT_FAST8_MAX                    __INT_FAST8_MAX__
#define       INT_FAST8_WIDTH     __STDINT_WIDTH(INT_FAST8)
typedef    __UINT_FAST8_TYPE__                  uint_fast8_t;
#define      UINT_FAST8_MAX                   __UINT_FAST8_MAX__
#define      UINT_FAST8_WIDTH    __STDINT_WIDTH(UINT_FAST8)
typedef    __INT_LEAST8_TYPE__                  int_least8_t;
#define      INT_LEAST8_MIN                 (~__INT_LEAST8_MAX__)
#define      INT_LEAST8_MAX                   __INT_LEAST8_MAX__
#define      INT_LEAST8_WIDTH    __STDINT_WIDTH(INT_LEAST8)
typedef   __UINT_LEAST8_TYPE__                 uint_least8_t;
#define     UINT_LEAST8_MAX                  __UINT_LEAST8_MAX__
#define     UINT_LEAST8_WIDTH   __STDINT_WIDTH(UINT_LEAST8)

typedef         __INT16_TYPE__                       int16_t;
#define           INT16_MIN                      (~__INT16_MAX__)
#define           INT16_MAX                        __INT16_MAX__
#define           INT16_WIDTH         __STDINT_WIDTH(INT16)
#define           INT16_C(C)           __STDINT_C(C, INT16)
typedef        __UINT16_TYPE__                      uint16_t;
#define          UINT16_MAX                       __UINT16_MAX__
#define          UINT16_WIDTH        __STDINT_WIDTH(UINT16)
#define          UINT16_C(C)          __STDINT_C(C, UINT16)
typedef    __INT_FAST16_TYPE__                  int_fast16_t;
#define      INT_FAST16_MIN                 (~__INT_FAST16_MAX__)
#define      INT_FAST16_MAX                   __INT_FAST16_MAX__
#define      INT_FAST16_WIDTH    __STDINT_WIDTH(INT_FAST16)
typedef   __UINT_FAST16_TYPE__                 uint_fast16_t;
#define     UINT_FAST16_MAX                  __UINT_FAST16_MAX__
#define     UINT_FAST16_WIDTH   __STDINT_WIDTH(UINT_FAST16)
typedef   __INT_LEAST16_TYPE__                 int_least16_t;
#define     INT_LEAST16_MIN                (~__INT_LEAST16_MAX__)
#define     INT_LEAST16_MAX                  __INT_LEAST16_MAX__
#define     INT_LEAST16_WIDTH   __STDINT_WIDTH(INT_LEAST16)
typedef  __UINT_LEAST16_TYPE__                uint_least16_t;
#define    UINT_LEAST16_MAX                 __UINT_LEAST16_MAX__
#define    UINT_LEAST16_WIDTH  __STDINT_WIDTH(UINT_LEAST16)

#ifdef          __INT24_TYPE__
typedef         __INT24_TYPE__                       int24_t;
#define           INT24_MIN                      (~__INT24_MAX__)
#define           INT24_MAX                        __INT24_MAX__
#define           INT24_WIDTH         __STDINT_WIDTH(INT24)
#define           INT24_C(C)           __STDINT_C(C, INT24)
typedef        __UINT24_TYPE__                      uint24_t;
#define          UINT24_MAX                       __UINT24_MAX__
#define          UINT24_WIDTH        __STDINT_WIDTH(UINT24)
#define          UINT24_C(C)          __STDINT_C(C, UINT24)
#endif        /*__INT24_TYPE_*/
# 65 "/home/parisse/CEdev/include/stdint.h" 3

typedef         __INT32_TYPE__                       int32_t;
#define           INT32_MIN                      (~__INT32_MAX__)
#define           INT32_MAX                        __INT32_MAX__
#define           INT32_WIDTH         __STDINT_WIDTH(INT32)
#define           INT32_C(C)           __STDINT_C(C, INT32)
typedef        __UINT32_TYPE__                      uint32_t;
#define          UINT32_MAX                       __UINT32_MAX__
#define          UINT32_WIDTH        __STDINT_WIDTH(UINT32)
#define          UINT32_C(C)          __STDINT_C(C, UINT32)
typedef    __INT_FAST32_TYPE__                  int_fast32_t;
#define      INT_FAST32_MIN                 (~__INT_FAST32_MAX__)
#define      INT_FAST32_MAX                   __INT_FAST32_MAX__
#define      INT_FAST32_WIDTH    __STDINT_WIDTH(INT_FAST32)
typedef   __UINT_FAST32_TYPE__                 uint_fast32_t;
#define     UINT_FAST32_MAX                  __UINT_FAST32_MAX__
#define     UINT_FAST32_WIDTH   __STDINT_WIDTH(UINT_FAST32)
typedef   __INT_LEAST32_TYPE__                 int_least32_t;
#define     INT_LEAST32_MIN                (~__INT_LEAST32_MAX__)
#define     INT_LEAST32_MAX                  __INT_LEAST32_MAX__
#define     INT_LEAST32_WIDTH   __STDINT_WIDTH(INT_LEAST32)
typedef  __UINT_LEAST32_TYPE__                uint_least32_t;
#define    UINT_LEAST32_MAX                 __UINT_LEAST32_MAX__
#define    UINT_LEAST32_WIDTH  __STDINT_WIDTH(UINT_LEAST32)

#ifdef   __SIZEOF_INT48__
#define         __INT48_TYPE__              signed __int48
#define         __INT48_MAX__  ((__UINT48_TYPE__)(__UINT48_MAX__>>1))
typedef         __INT48_TYPE__                       int48_t;
#define           INT48_MIN                      (~__INT48_MAX__)
#define           INT48_MAX                        __INT48_MAX__
#define           INT48_WIDTH         __STDINT_WIDTH(INT48)
#define           INT48_C(C)                     ((__INT48_TYPE__)(INT64_C(C)))
#define        __UINT48_TYPE__            unsigned __int48
#define        __UINT48_MAX__                   ((__UINT48_TYPE__)~0)
typedef        __UINT48_TYPE__                      uint48_t;
#define          UINT48_MAX                       __UINT48_MAX__
#define          UINT48_WIDTH        __STDINT_WIDTH(UINT48)
#define          UINT48_C(C)                    ((__UINT48_TYPE__)(UINT64_C(C)))
#endif /*__SIZEOF_INT48__*/
# 105 "/home/parisse/CEdev/include/stdint.h" 3

typedef         __INT64_TYPE__                       int64_t;
#define           INT64_MIN                      (~__INT64_MAX__)
#define           INT64_MAX                        __INT64_MAX__
#define           INT64_WIDTH         __STDINT_WIDTH(INT64)
#define           INT64_C(C)           __STDINT_C(C, INT64)
typedef        __UINT64_TYPE__                      uint64_t;
#define          UINT64_MAX                       __UINT64_MAX__
#define          UINT64_WIDTH        __STDINT_WIDTH(UINT64)
#define          UINT64_C(C)          __STDINT_C(C, UINT64)
typedef    __INT_FAST64_TYPE__                  int_fast64_t;
#define      INT_FAST64_MIN                 (~__INT_FAST64_MAX__)
#define      INT_FAST64_MAX                   __INT_FAST64_MAX__
#define      INT_FAST64_WIDTH    __STDINT_WIDTH(INT_FAST64)
typedef   __UINT_FAST64_TYPE__                 uint_fast64_t;
#define     UINT_FAST64_MAX                  __UINT_FAST64_MAX__
#define     UINT_FAST64_WIDTH   __STDINT_WIDTH(UINT_FAST64)
typedef   __INT_LEAST64_TYPE__                 int_least64_t;
#define     INT_LEAST64_MIN                (~__INT_LEAST64_MAX__)
#define     INT_LEAST64_MAX                  __INT_LEAST64_MAX__
#define     INT_LEAST64_WIDTH   __STDINT_WIDTH(INT_LEAST64)
typedef  __UINT_LEAST64_TYPE__                uint_least64_t;
#define    UINT_LEAST64_MAX                 __UINT_LEAST64_MAX__
#define    UINT_LEAST64_WIDTH  __STDINT_WIDTH(UINT_LEAST64)

#ifdef  __SIZEOF_INT128__
#define        __INT128_TYPE__             signed __int128
#define        __INT128_MAX__ ((__INT128_TYPE__)(__UINT128_MAX__>>1))
typedef        __INT128_TYPE__                      int128_t;
#define          INT128_MIN                     (~__INT128_MAX__)
#define          INT128_MAX                       __INT128_MAX__
#define          INT128_WIDTH        __STDINT_WIDTH(INT128)
#define       __UINT128_TYPE__           unsigned __int128
#define       __UINT128_MAX__                  ((__UINT128_TYPE__)~0)
typedef       __UINT128_TYPE__                     uint128_t;
#define         UINT128_MAX                      __UINT128_MAX__
#define         UINT128_WIDTH       __STDINT_WIDTH(UINT128)
#endif/*__SIZEOF_INT128__*/
# 143 "/home/parisse/CEdev/include/stdint.h" 3

typedef        __INTMAX_TYPE__                      intmax_t;
#define          INTMAX_MIN                     (~__INTMAX_MAX__)
#define          INTMAX_MAX                       __INTMAX_MAX__
#define          INTMAX_WIDTH                     __INTMAX_WIDTH__
#define          INTMAX_C(C)          __STDINT_C(C, INTMAX)
typedef       __UINTMAX_TYPE__                     uintmax_t;
#define         UINTMAX_MAX                      __UINTMAX_MAX__
#define         UINTMAX_WIDTH                    __UINTMAX_WIDTH__
#define         UINTMAX_C(C)         __STDINT_C(C, UINTMAX)

typedef        __INTPTR_TYPE__                      intptr_t;
#define          INTPTR_MIN                     (~__INTPTR_MAX__)
#define          INTPTR_MAX                       __INTPTR_MAX__
#define          INTPTR_WIDTH                     __INTPTR_WIDTH__
typedef       __UINTPTR_TYPE__                     uintptr_t;
#define         UINTPTR_MAX                      __UINTPTR_MAX__
#define         UINTPTR_WIDTH                    __UINTPTR_WIDTH__

#define         PTRDIFF_MIN                    (~__PTRDIFF_MAX__)
#define         PTRDIFF_MAX                      __PTRDIFF_MAX__
#define         PTRDIFF_WIDTH                    __PTRDIFF_WIDTH__

#define            SIZE_MAX                         __SIZE_MAX__
#define            SIZE_WIDTH                       __SIZE_WIDTH__

#define            WINT_MIN                       (~__WINT_MAX__)
#define            WINT_MAX                         __WINT_MAX__
#define            WINT_WIDTH                       __WINT_WIDTH__

#ifndef _WCHAR_LIMITS_DEFINED
#define _WCHAR_LIMITS_DEFINED
#define           WCHAR_MIN                      (~__WCHAR_MAX__)
#define           WCHAR_MAX                        __WCHAR_MAX__
#define           WCHAR_WIDTH                      __WCHAR_WIDTH__
#endif
# 179 "/home/parisse/CEdev/include/stdint.h" 3

#endif/*_STDINT_H*/
# 181 "/home/parisse/CEdev/include/stdint.h" 3
# 30 "../../py/mpstate.h" 2

#if 0 /* expanded by -frewrite-includes */
#include "py/mpconfig.h"
#endif /* expanded by -frewrite-includes */
# 31 "../../py/mpstate.h"
# 1 "../../py/mpconfig.h" 1
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef MICROPY_INCLUDED_PY_MPCONFIG_H
#define MICROPY_INCLUDED_PY_MPCONFIG_H

// Current version of MicroPython
#define MICROPY_VERSION_MAJOR 1
#define MICROPY_VERSION_MINOR 17
#define MICROPY_VERSION_MICRO 0

// Combined version as a 32-bit number for convenience
#define MICROPY_VERSION ( \
    MICROPY_VERSION_MAJOR << 16 \
        | MICROPY_VERSION_MINOR << 8 \
        | MICROPY_VERSION_MICRO)

// String version
#define MICROPY_VERSION_STRING \
    MP_STRINGIFY(MICROPY_VERSION_MAJOR) "." \
    MP_STRINGIFY(MICROPY_VERSION_MINOR) "." \
    MP_STRINGIFY(MICROPY_VERSION_MICRO)

// This file contains default configuration settings for MicroPython.
// You can override any of the options below using mpconfigport.h file
// located in a directory of your port.

// mpconfigport.h is a file containing configuration settings for a
// particular port. mpconfigport.h is actually a default name for
// such config, and it can be overridden using MP_CONFIGFILE preprocessor
// define (you can do that by passing CFLAGS_EXTRA='-DMP_CONFIGFILE="<file.h>"'
// argument to make when using standard MicroPython makefiles).
// This is useful to have more than one config per port, for example,
// release vs debug configs, etc. Note that if you switch from one config
// to another, you must rebuild from scratch using "-B" switch to make.

#ifdef MP_CONFIGFILE
#if 0 /* expanded by -frewrite-includes */
#include MP_CONFIGFILE
#endif /* expanded by -frewrite-includes */
# 60 "../../py/mpconfig.h"
# 61 "../../py/mpconfig.h"
#else
# 62 "../../py/mpconfig.h"
#if 0 /* expanded by -frewrite-includes */
#include <mpconfigport.h>
#endif /* expanded by -frewrite-includes */
# 62 "../../py/mpconfig.h"
# 1 "./mpconfigport.h" 1
#if 0 /* expanded by -frewrite-includes */
#include <stdint.h>
#endif /* expanded by -frewrite-includes */
# 1 "./mpconfigport.h"
# 2 "./mpconfigport.h"
#if 0 /* expanded by -frewrite-includes */
#include <alloca.h>
#endif /* expanded by -frewrite-includes */
# 2 "./mpconfigport.h"
# 1 "/home/parisse/CEdev/include/alloca.h" 1 3
#ifndef _ALLOCA_H
#define _ALLOCA_H

#if 0 /* expanded by -frewrite-includes */
#include <cdefs.h>
#endif /* expanded by -frewrite-includes */
# 4 "/home/parisse/CEdev/include/alloca.h" 3
# 5 "/home/parisse/CEdev/include/alloca.h" 3

__BEGIN_DECLS

void *alloca(size_t __size) __NOEXCEPT;
#define alloca(size) __builtin_alloca(size)

__END_DECLS

#endif /* _ALLOCA_H */
# 14 "/home/parisse/CEdev/include/alloca.h" 3
# 3 "./mpconfigport.h" 2

#define MICROPY_OBJ_REPR                    (MICROPY_OBJ_REPR_B)
#define MICROPY_GC_STACK_ENTRY_TYPE         uint24_t
#define MICROPY_ALLOC_PATH_MAX              (128)
#define MICROPY_ALLOC_LEXER_INDENT_INIT     (8)
#define MICROPY_ALLOC_PARSE_RULE_INIT       (48)
#define MICROPY_ALLOC_PARSE_RULE_INC        (8)
#define MICROPY_ALLOC_PARSE_RESULT_INC      (8)
#define MICROPY_ALLOC_PARSE_CHUNK_INIT      (16)
#define MICROPY_MEM_STATS                   (0)

#define MICROPY_CONFIG_ROM_LEVEL            (MICROPY_CONFIG_ROM_LEVEL_MINIMUM)

#define MICROPY_ENABLE_COMPILER             (1)

#define MICROPY_QSTR_EXTRA_POOL             mp_qstr_frozen_const_pool
#define MICROPY_ENABLE_GC                   (1)
#define MICROPY_HELPER_REPL                 (1)
#define MICROPY_MODULE_FROZEN_MPY           (1)
#define MICROPY_ENABLE_EXTERNAL_IMPORT      (1)
#define MICROPY_PY_MATH                     (1)
#define MICROPY_USE_INTERNAL_ERRNO          (1)

#define MICROPY_COMP_CONST_FOLDING          (1)
#define MICROPY_COMP_CONST_LITERAL          (1)
#define MICROPY_FULL_CHECKS                 (1)
#define MICROPY_MULTIPLE_INHERITANCE        (1)
#define MICROPY_PY_GENERATOR_PEND_THROW     (1)
#define MICROPY_PY_BUILTINS_RANGE_ATTRS     (1)

typedef intptr_t mp_int_t;
typedef uintptr_t mp_uint_t;
typedef long mp_off_t;

#define MICROPY_PORT_BUILTINS \
    { MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&mp_builtin_open_obj) },

#define MICROPY_HW_BOARD_NAME "minimal"
#define MICROPY_HW_MCU_NAME "ez80-cpu"

#define MP_STATE_PORT MP_STATE_VM

#define MICROPY_PORT_ROOT_POINTERS \
    const char *readline_hist[8];
# 63 "../../py/mpconfig.h" 2
#endif
# 64 "../../py/mpconfig.h"

// Disable all optional features (i.e. minimal port).
#define MICROPY_CONFIG_ROM_LEVEL_MINIMUM (0)
// Only enable core features (constrained flash, e.g. STM32L072)
#define MICROPY_CONFIG_ROM_LEVEL_CORE_FEATURES (10)
// Enable most common features (small on-device flash, e.g. STM32F411)
#define MICROPY_CONFIG_ROM_LEVEL_BASIC_FEATURES (20)
// Enable convenience features (medium on-device flash, e.g. STM32F405)
#define MICROPY_CONFIG_ROM_LEVEL_EXTRA_FEATURES (30)
// Enable all common features (large/external flash, rp2, unix)
#define MICROPY_CONFIG_ROM_LEVEL_FULL_FEATURES (40)
// Enable everything (e.g. coverage)
#define MICROPY_CONFIG_ROM_LEVEL_EVERYTHING (50)

// Ports/boards should set this, but default to level=core.
#ifndef MICROPY_CONFIG_ROM_LEVEL
#define MICROPY_CONFIG_ROM_LEVEL (MICROPY_CONFIG_ROM_LEVEL_CORE_FEATURES)
#endif
# 82 "../../py/mpconfig.h"

// Helper macros for "have at least this level".
#define MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES (MICROPY_CONFIG_ROM_LEVEL >= MICROPY_CONFIG_ROM_LEVEL_CORE_FEATURES)
#define MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_BASIC_FEATURES (MICROPY_CONFIG_ROM_LEVEL >= MICROPY_CONFIG_ROM_LEVEL_BASIC_FEATURES)
#define MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES (MICROPY_CONFIG_ROM_LEVEL >= MICROPY_CONFIG_ROM_LEVEL_EXTRA_FEATURES)
#define MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_FULL_FEATURES (MICROPY_CONFIG_ROM_LEVEL >= MICROPY_CONFIG_ROM_LEVEL_FULL_FEATURES)
#define MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING (MICROPY_CONFIG_ROM_LEVEL >= MICROPY_CONFIG_ROM_LEVEL_EVERYTHING)

// Any options not explicitly set in mpconfigport.h will get default
// values below.

/*****************************************************************************/
/* Object representation                                                     */

// A MicroPython object is a machine word having the following form:
//  - xxxx...xxx1 : a small int, bits 1 and above are the value
//  - xxxx...x010 : a qstr, bits 3 and above are the value
//  - xxxx...x110 : an immediate object, bits 3 and above are the value
//  - xxxx...xx00 : a pointer to an mp_obj_base_t (unless a fake object)
#define MICROPY_OBJ_REPR_A (0)

// A MicroPython object is a machine word having the following form:
//  - xxxx...xx01 : a small int, bits 2 and above are the value
//  - xxxx...x011 : a qstr, bits 3 and above are the value
//  - xxxx...x111 : an immediate object, bits 3 and above are the value
//  - xxxx...xxx0 : a pointer to an mp_obj_base_t (unless a fake object)
#define MICROPY_OBJ_REPR_B (1)

// A MicroPython object is a machine word having the following form (called R):
//  - iiiiiiii iiiiiiii iiiiiiii iiiiiii1 small int with 31-bit signed value
//  - 01111111 1qqqqqqq qqqqqqqq qqqq0110 str with 19-bit qstr value
//  - 01111111 10000000 00000000 ssss1110 immediate object with 4-bit value
//  - s1111111 10000000 00000000 00000010 +/- inf
//  - s1111111 1xxxxxxx xxxxxxxx xxxxx010 nan, x != 0
//  - seeeeeee efffffff ffffffff ffffff10 30-bit fp, e != 0xff
//  - pppppppp pppppppp pppppppp pppppp00 ptr (4 byte alignment)
// Str, immediate and float stored as O = R + 0x80800000, retrieved as R = O - 0x80800000.
// This makes strs/immediates easier to encode/decode as they have zeros in the top 9 bits.
// This scheme only works with 32-bit word size and float enabled.
#define MICROPY_OBJ_REPR_C (2)

// A MicroPython object is a 64-bit word having the following form (called R):
//  - seeeeeee eeeeffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff 64-bit fp, e != 0x7ff
//  - s1111111 11110000 00000000 00000000 00000000 00000000 00000000 00000000 +/- inf
//  - 01111111 11111000 00000000 00000000 00000000 00000000 00000000 00000000 normalised nan
//  - 01111111 11111101 iiiiiiii iiiiiiii iiiiiiii iiiiiiii iiiiiiii iiiiiii1 small int
//  - 01111111 11111110 00000000 00000000 qqqqqqqq qqqqqqqq qqqqqqqq qqqqqqq1 str
//  - 01111111 11111111 ss000000 00000000 00000000 00000000 00000000 00000000 immediate object
//  - 01111111 11111100 00000000 00000000 pppppppp pppppppp pppppppp pppppp00 ptr (4 byte alignment)
// Stored as O = R + 0x8004000000000000, retrieved as R = O - 0x8004000000000000.
// This makes pointers have all zeros in the top 32 bits.
// Small-ints and strs have 1 as LSB to make sure they don't look like pointers
// to the garbage collector.
#define MICROPY_OBJ_REPR_D (3)

#ifndef MICROPY_OBJ_REPR
#define MICROPY_OBJ_REPR (MICROPY_OBJ_REPR_A)
#endif
# 140 "../../py/mpconfig.h"

// Whether to encode None/False/True as immediate objects instead of pointers to
// real objects.  Reduces code size by a decent amount without hurting
// performance, for all representations except D on some architectures.
#ifndef MICROPY_OBJ_IMMEDIATE_OBJS
#define MICROPY_OBJ_IMMEDIATE_OBJS (MICROPY_OBJ_REPR != MICROPY_OBJ_REPR_D)
#endif
# 147 "../../py/mpconfig.h"

/*****************************************************************************/
/* Memory allocation policy                                                  */

// Number of bytes in memory allocation/GC block. Any size allocated will be
// rounded up to be multiples of this.
#ifndef MICROPY_BYTES_PER_GC_BLOCK
#define MICROPY_BYTES_PER_GC_BLOCK (4 * MP_BYTES_PER_OBJ_WORD)
#endif
# 156 "../../py/mpconfig.h"

// Number of words allocated (in BSS) to the GC stack (minimum is 1)
#ifndef MICROPY_ALLOC_GC_STACK_SIZE
#define MICROPY_ALLOC_GC_STACK_SIZE (64)
#endif
# 161 "../../py/mpconfig.h"

// The C-type to use for entries in the GC stack.  By default it allows the
// heap to be as large as the address space, but the bit-width of this type can
// be reduced to save memory when the heap is small enough.  The type must be
// big enough to index all blocks in the heap, which is set by
// heap-size-in-bytes / MICROPY_BYTES_PER_GC_BLOCK.
#ifndef MICROPY_GC_STACK_ENTRY_TYPE
#define MICROPY_GC_STACK_ENTRY_TYPE size_t
#endif
# 170 "../../py/mpconfig.h"

// Be conservative and always clear to zero newly (re)allocated memory in the GC.
// This helps eliminate stray pointers that hold on to memory that's no longer
// used.  It decreases performance due to unnecessary memory clearing.
// A memory manager which always clears memory can set this to 0.
// TODO Do analysis to understand why some memory is not properly cleared and
// find a more efficient way to clear it.
#ifndef MICROPY_GC_CONSERVATIVE_CLEAR
#define MICROPY_GC_CONSERVATIVE_CLEAR (MICROPY_ENABLE_GC)
#endif
# 180 "../../py/mpconfig.h"

// Support automatic GC when reaching allocation threshold,
// configurable by gc.threshold().
#ifndef MICROPY_GC_ALLOC_THRESHOLD
#define MICROPY_GC_ALLOC_THRESHOLD (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
#endif
# 186 "../../py/mpconfig.h"

// Number of bytes to allocate initially when creating new chunks to store
// interned string data.  Smaller numbers lead to more chunks being needed
// and more wastage at the end of the chunk.  Larger numbers lead to wasted
// space at the end when no more strings need interning.
#ifndef MICROPY_ALLOC_QSTR_CHUNK_INIT
#define MICROPY_ALLOC_QSTR_CHUNK_INIT (128)
#endif
# 194 "../../py/mpconfig.h"

// Initial amount for lexer indentation level
#ifndef MICROPY_ALLOC_LEXER_INDENT_INIT
#define MICROPY_ALLOC_LEXER_INDENT_INIT (10)
#endif
# 199 "../../py/mpconfig.h"

// Increment for lexer indentation level
#ifndef MICROPY_ALLOC_LEXEL_INDENT_INC
#define MICROPY_ALLOC_LEXEL_INDENT_INC (8)
#endif
# 204 "../../py/mpconfig.h"

// Initial amount for parse rule stack
#ifndef MICROPY_ALLOC_PARSE_RULE_INIT
#define MICROPY_ALLOC_PARSE_RULE_INIT (64)
#endif
# 209 "../../py/mpconfig.h"

// Increment for parse rule stack
#ifndef MICROPY_ALLOC_PARSE_RULE_INC
#define MICROPY_ALLOC_PARSE_RULE_INC (16)
#endif
# 214 "../../py/mpconfig.h"

// Initial amount for parse result stack
#ifndef MICROPY_ALLOC_PARSE_RESULT_INIT
#define MICROPY_ALLOC_PARSE_RESULT_INIT (32)
#endif
# 219 "../../py/mpconfig.h"

// Increment for parse result stack
#ifndef MICROPY_ALLOC_PARSE_RESULT_INC
#define MICROPY_ALLOC_PARSE_RESULT_INC (16)
#endif
# 224 "../../py/mpconfig.h"

// Strings this length or less will be interned by the parser
#ifndef MICROPY_ALLOC_PARSE_INTERN_STRING_LEN
#define MICROPY_ALLOC_PARSE_INTERN_STRING_LEN (10)
#endif
# 229 "../../py/mpconfig.h"

// Number of bytes to allocate initially when creating new chunks to store
// parse nodes.  Small leads to fragmentation, large leads to excess use.
#ifndef MICROPY_ALLOC_PARSE_CHUNK_INIT
#define MICROPY_ALLOC_PARSE_CHUNK_INIT (128)
#endif
# 235 "../../py/mpconfig.h"

// Initial amount for ids in a scope
#ifndef MICROPY_ALLOC_SCOPE_ID_INIT
#define MICROPY_ALLOC_SCOPE_ID_INIT (4)
#endif
# 240 "../../py/mpconfig.h"

// Increment for ids in a scope
#ifndef MICROPY_ALLOC_SCOPE_ID_INC
#define MICROPY_ALLOC_SCOPE_ID_INC (6)
#endif
# 245 "../../py/mpconfig.h"

// Maximum length of a path in the filesystem
// So we can allocate a buffer on the stack for path manipulation in import
#ifndef MICROPY_ALLOC_PATH_MAX
#define MICROPY_ALLOC_PATH_MAX (512)
#endif
# 251 "../../py/mpconfig.h"

// Initial size of module dict
#ifndef MICROPY_MODULE_DICT_SIZE
#define MICROPY_MODULE_DICT_SIZE (1)
#endif
# 256 "../../py/mpconfig.h"

// Initial size of sys.modules dict
#ifndef MICROPY_LOADED_MODULES_DICT_SIZE
#define MICROPY_LOADED_MODULES_DICT_SIZE (3)
#endif
# 261 "../../py/mpconfig.h"

// Whether realloc/free should be passed allocated memory region size
// You must enable this if MICROPY_MEM_STATS is enabled
#ifndef MICROPY_MALLOC_USES_ALLOCATED_SIZE
#define MICROPY_MALLOC_USES_ALLOCATED_SIZE (0)
#endif
# 267 "../../py/mpconfig.h"

// Number of bytes used to store qstr length
// Dictates hard limit on maximum Python identifier length, but 1 byte
// (limit of 255 bytes in an identifier) should be enough for everyone
#ifndef MICROPY_QSTR_BYTES_IN_LEN
#define MICROPY_QSTR_BYTES_IN_LEN (1)
#endif
# 274 "../../py/mpconfig.h"

// Number of bytes used to store qstr hash
#ifndef MICROPY_QSTR_BYTES_IN_HASH
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 278 "../../py/mpconfig.h"
#define MICROPY_QSTR_BYTES_IN_HASH (2)
#else
# 280 "../../py/mpconfig.h"
#define MICROPY_QSTR_BYTES_IN_HASH (1)
#endif
# 282 "../../py/mpconfig.h"
#endif
# 283 "../../py/mpconfig.h"

// Avoid using C stack when making Python function calls. C stack still
// may be used if there's no free heap.
#ifndef MICROPY_STACKLESS
#define MICROPY_STACKLESS (0)
#endif
# 289 "../../py/mpconfig.h"

// Never use C stack when making Python function calls. This may break
// testsuite as will subtly change which exception is thrown in case
// of too deep recursion and other similar cases.
#ifndef MICROPY_STACKLESS_STRICT
#define MICROPY_STACKLESS_STRICT (0)
#endif
# 296 "../../py/mpconfig.h"

// Don't use alloca calls. As alloca() is not part of ANSI C, this
// workaround option is provided for compilers lacking this de-facto
// standard function. The way it works is allocating from heap, and
// relying on garbage collection to free it eventually. This is of
// course much less optimal than real alloca().
#if 0 /* disabled by -frewrite-includes */
#if defined(MICROPY_NO_ALLOCA) && MICROPY_NO_ALLOCA
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 303 "../../py/mpconfig.h"
#undef alloca
#define alloca(x) m_malloc(x)
#endif
# 306 "../../py/mpconfig.h"

/*****************************************************************************/
/* MicroPython emitters                                                     */

// Whether to support loading of persistent code
#ifndef MICROPY_PERSISTENT_CODE_LOAD
#define MICROPY_PERSISTENT_CODE_LOAD (0)
#endif
# 314 "../../py/mpconfig.h"

// Whether to support saving of persistent code
#ifndef MICROPY_PERSISTENT_CODE_SAVE
#define MICROPY_PERSISTENT_CODE_SAVE (0)
#endif
# 319 "../../py/mpconfig.h"

// Whether to support saving persistent code to a file via mp_raw_code_save_file
#ifndef MICROPY_PERSISTENT_CODE_SAVE_FILE
#define MICROPY_PERSISTENT_CODE_SAVE_FILE (0)
#endif
# 324 "../../py/mpconfig.h"

// Whether generated code can persist independently of the VM/runtime instance
// This is enabled automatically when needed by other features
#ifndef MICROPY_PERSISTENT_CODE
#define MICROPY_PERSISTENT_CODE (MICROPY_PERSISTENT_CODE_LOAD || MICROPY_PERSISTENT_CODE_SAVE || MICROPY_MODULE_FROZEN_MPY)
#endif
# 330 "../../py/mpconfig.h"

// Whether to emit x64 native code
#ifndef MICROPY_EMIT_X64
#define MICROPY_EMIT_X64 (0)
#endif
# 335 "../../py/mpconfig.h"

// Whether to emit x86 native code
#ifndef MICROPY_EMIT_X86
#define MICROPY_EMIT_X86 (0)
#endif
# 340 "../../py/mpconfig.h"

// Whether to emit thumb native code
#ifndef MICROPY_EMIT_THUMB
#define MICROPY_EMIT_THUMB (0)
#endif
# 345 "../../py/mpconfig.h"

// Whether to emit ARMv7-M instruction support in thumb native code
#ifndef MICROPY_EMIT_THUMB_ARMV7M
#define MICROPY_EMIT_THUMB_ARMV7M (1)
#endif
# 350 "../../py/mpconfig.h"

// Whether to enable the thumb inline assembler
#ifndef MICROPY_EMIT_INLINE_THUMB
#define MICROPY_EMIT_INLINE_THUMB (0)
#endif
# 355 "../../py/mpconfig.h"

// Whether to enable ARMv7-M instruction support in the Thumb2 inline assembler
#ifndef MICROPY_EMIT_INLINE_THUMB_ARMV7M
#define MICROPY_EMIT_INLINE_THUMB_ARMV7M (1)
#endif
# 360 "../../py/mpconfig.h"

// Whether to enable float support in the Thumb2 inline assembler
#ifndef MICROPY_EMIT_INLINE_THUMB_FLOAT
#define MICROPY_EMIT_INLINE_THUMB_FLOAT (1)
#endif
# 365 "../../py/mpconfig.h"

// Whether to emit ARM native code
#ifndef MICROPY_EMIT_ARM
#define MICROPY_EMIT_ARM (0)
#endif
# 370 "../../py/mpconfig.h"

// Whether to emit Xtensa native code
#ifndef MICROPY_EMIT_XTENSA
#define MICROPY_EMIT_XTENSA (0)
#endif
# 375 "../../py/mpconfig.h"

// Whether to enable the Xtensa inline assembler
#ifndef MICROPY_EMIT_INLINE_XTENSA
#define MICROPY_EMIT_INLINE_XTENSA (0)
#endif
# 380 "../../py/mpconfig.h"

// Whether to emit Xtensa-Windowed native code
#ifndef MICROPY_EMIT_XTENSAWIN
#define MICROPY_EMIT_XTENSAWIN (0)
#endif
# 385 "../../py/mpconfig.h"

// Convenience definition for whether any native emitter is enabled
#define MICROPY_EMIT_NATIVE (MICROPY_EMIT_X64 || MICROPY_EMIT_X86 || MICROPY_EMIT_THUMB || MICROPY_EMIT_ARM || MICROPY_EMIT_XTENSA || MICROPY_EMIT_XTENSAWIN)

// Select prelude-as-bytes-object for certain emitters
#define MICROPY_EMIT_NATIVE_PRELUDE_AS_BYTES_OBJ (MICROPY_EMIT_XTENSAWIN)

// Convenience definition for whether any inline assembler emitter is enabled
#define MICROPY_EMIT_INLINE_ASM (MICROPY_EMIT_INLINE_THUMB || MICROPY_EMIT_INLINE_XTENSA)

// Convenience definition for whether any native or inline assembler emitter is enabled
#define MICROPY_EMIT_MACHINE_CODE (MICROPY_EMIT_NATIVE || MICROPY_EMIT_INLINE_ASM)

// Whether native relocatable code loaded from .mpy files is explicitly tracked
// so that the GC cannot reclaim it.  Needed on architectures that allocate
// executable memory on the MicroPython heap and don't explicitly track this
// data some other way.
#ifndef MICROPY_PERSISTENT_CODE_TRACK_RELOC_CODE
#if 0 /* disabled by -frewrite-includes */
#if !MICROPY_EMIT_MACHINE_CODE || defined(MP_PLAT_ALLOC_EXEC) || defined(MP_PLAT_COMMIT_EXEC)
#endif
#endif /* disabled by -frewrite-includes */
#if 1 /* evaluated by -frewrite-includes */
# 404 "../../py/mpconfig.h"
#define MICROPY_PERSISTENT_CODE_TRACK_RELOC_CODE (0)
#else
# 406 "../../py/mpconfig.h"
#define MICROPY_PERSISTENT_CODE_TRACK_RELOC_CODE (1)
#endif
# 408 "../../py/mpconfig.h"
#endif
# 409 "../../py/mpconfig.h"

/*****************************************************************************/
/* Compiler configuration                                                    */

// Whether to include the compiler
#ifndef MICROPY_ENABLE_COMPILER
#define MICROPY_ENABLE_COMPILER (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
#endif
# 417 "../../py/mpconfig.h"

// Whether the compiler is dynamically configurable (ie at runtime)
// This will disable the ability to execute native/viper code
#ifndef MICROPY_DYNAMIC_COMPILER
#define MICROPY_DYNAMIC_COMPILER (0)
#endif
# 423 "../../py/mpconfig.h"

// Configure dynamic compiler macros
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_DYNAMIC_COMPILER
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 426 "../../py/mpconfig.h"
#define MICROPY_PY_BUILTINS_STR_UNICODE_DYNAMIC (mp_dynamic_compiler.py_builtins_str_unicode)
#else
# 428 "../../py/mpconfig.h"
#define MICROPY_PY_BUILTINS_STR_UNICODE_DYNAMIC MICROPY_PY_BUILTINS_STR_UNICODE
#endif
# 430 "../../py/mpconfig.h"

// Whether to enable constant folding; eg 1+2 rewritten as 3
#ifndef MICROPY_COMP_CONST_FOLDING
#define MICROPY_COMP_CONST_FOLDING (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
#endif
# 435 "../../py/mpconfig.h"

// Whether to enable optimisations for constant literals, eg OrderedDict
#ifndef MICROPY_COMP_CONST_LITERAL
#define MICROPY_COMP_CONST_LITERAL (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
#endif
# 440 "../../py/mpconfig.h"

// Whether to enable lookup of constants in modules; eg module.CONST
#ifndef MICROPY_COMP_MODULE_CONST
#define MICROPY_COMP_MODULE_CONST (0)
#endif
# 445 "../../py/mpconfig.h"

// Whether to enable constant optimisation; id = const(value)
#ifndef MICROPY_COMP_CONST
#define MICROPY_COMP_CONST (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
#endif
# 450 "../../py/mpconfig.h"

// Whether to enable optimisation of: a, b = c, d
// Costs 124 bytes (Thumb2)
#ifndef MICROPY_COMP_DOUBLE_TUPLE_ASSIGN
#define MICROPY_COMP_DOUBLE_TUPLE_ASSIGN (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
#endif
# 456 "../../py/mpconfig.h"

// Whether to enable optimisation of: a, b, c = d, e, f
// Requires MICROPY_COMP_DOUBLE_TUPLE_ASSIGN and costs 68 bytes (Thumb2)
#ifndef MICROPY_COMP_TRIPLE_TUPLE_ASSIGN
#define MICROPY_COMP_TRIPLE_TUPLE_ASSIGN (0)
#endif
# 462 "../../py/mpconfig.h"

// Whether to enable optimisation of: return a if b else c
// Costs about 80 bytes (Thumb2) and saves 2 bytes of bytecode for each use
#ifndef MICROPY_COMP_RETURN_IF_EXPR
#define MICROPY_COMP_RETURN_IF_EXPR (0)
#endif
# 468 "../../py/mpconfig.h"

/*****************************************************************************/
/* Internal debugging stuff                                                  */

// Whether to collect memory allocation stats
#ifndef MICROPY_MEM_STATS
#define MICROPY_MEM_STATS (0)
#endif
# 476 "../../py/mpconfig.h"

// The mp_print_t printer used for debugging output
#ifndef MICROPY_DEBUG_PRINTER
#define MICROPY_DEBUG_PRINTER (&mp_plat_print)
#endif
# 481 "../../py/mpconfig.h"

// Whether to build functions that print debugging info:
//   mp_bytecode_print
//   mp_parse_node_print
#ifndef MICROPY_DEBUG_PRINTERS
#define MICROPY_DEBUG_PRINTERS (0)
#endif
# 488 "../../py/mpconfig.h"

// Whether to enable all debugging outputs (it will be extremely verbose)
#ifndef MICROPY_DEBUG_VERBOSE
#define MICROPY_DEBUG_VERBOSE (0)
#endif
# 493 "../../py/mpconfig.h"

// Whether to enable debugging versions of MP_OBJ_NULL/STOP_ITERATION/SENTINEL
#ifndef MICROPY_DEBUG_MP_OBJ_SENTINELS
#define MICROPY_DEBUG_MP_OBJ_SENTINELS (0)
#endif
# 498 "../../py/mpconfig.h"

// Whether to print parse rule names (rather than integers) in mp_parse_node_print
#ifndef MICROPY_DEBUG_PARSE_RULE_NAME
#define MICROPY_DEBUG_PARSE_RULE_NAME (0)
#endif
# 503 "../../py/mpconfig.h"

// Whether to enable a simple VM stack overflow check
#ifndef MICROPY_DEBUG_VM_STACK_OVERFLOW
#define MICROPY_DEBUG_VM_STACK_OVERFLOW (0)
#endif
# 508 "../../py/mpconfig.h"

/*****************************************************************************/
/* Optimisations                                                             */

// Whether to use computed gotos in the VM, or a switch
// Computed gotos are roughly 10% faster, and increase VM code size by a little,
// e.g. ~1kiB on Cortex M4.
// Note: enabling this will use the gcc-specific extensions of ranged designated
// initialisers and addresses of labels, which are not part of the C99 standard.
#ifndef MICROPY_OPT_COMPUTED_GOTO
#define MICROPY_OPT_COMPUTED_GOTO (0)
#endif
# 520 "../../py/mpconfig.h"

// Optimise the fast path for loading attributes from instance types. Increases
// Thumb2 code size by about 48 bytes.
#ifndef MICROPY_OPT_LOAD_ATTR_FAST_PATH
#define MICROPY_OPT_LOAD_ATTR_FAST_PATH (0)
#endif
# 526 "../../py/mpconfig.h"

// Use extra RAM to cache map lookups by remembering the likely location of
// the index. Avoids the hash computation on unordered maps, and avoids the
// linear search on ordered (especially in-ROM) maps. Can provide a +10-15%
// performance improvement on benchmarks involving lots of attribute access
// or dictionary lookup.
#ifndef MICROPY_OPT_MAP_LOOKUP_CACHE
#define MICROPY_OPT_MAP_LOOKUP_CACHE (0)
#endif
# 535 "../../py/mpconfig.h"

// How much RAM (in bytes) to use for the map lookup cache.
#ifndef MICROPY_OPT_MAP_LOOKUP_CACHE_SIZE
#define MICROPY_OPT_MAP_LOOKUP_CACHE_SIZE (128)
#endif
# 540 "../../py/mpconfig.h"

// Whether to use fast versions of bitwise operations (and, or, xor) when the
// arguments are both positive.  Increases Thumb2 code size by about 250 bytes.
#ifndef MICROPY_OPT_MPZ_BITWISE
#define MICROPY_OPT_MPZ_BITWISE (0)
#endif
# 546 "../../py/mpconfig.h"


// Whether math.factorial is large, fast and recursive (1) or small and slow (0).
#ifndef MICROPY_OPT_MATH_FACTORIAL
#define MICROPY_OPT_MATH_FACTORIAL (0)
#endif
# 552 "../../py/mpconfig.h"

/*****************************************************************************/
/* Python internal features                                                  */

// Whether to enable import of external modules
// When disabled, only importing of built-in modules is supported
// When enabled, a port must implement mp_import_stat (among other things)
#ifndef MICROPY_ENABLE_EXTERNAL_IMPORT
#define MICROPY_ENABLE_EXTERNAL_IMPORT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
#endif
# 562 "../../py/mpconfig.h"

// Whether to use the POSIX reader for importing files
#ifndef MICROPY_READER_POSIX
#define MICROPY_READER_POSIX (0)
#endif
# 567 "../../py/mpconfig.h"

// Whether to use the VFS reader for importing files
#ifndef MICROPY_READER_VFS
#define MICROPY_READER_VFS (0)
#endif
# 572 "../../py/mpconfig.h"

// Whether any readers have been defined
#ifndef MICROPY_HAS_FILE_READER
#define MICROPY_HAS_FILE_READER (MICROPY_READER_POSIX || MICROPY_READER_VFS)
#endif
# 577 "../../py/mpconfig.h"

// Hook for the VM at the start of the opcode loop (can contain variable
// definitions usable by the other hook functions)
#ifndef MICROPY_VM_HOOK_INIT
#define MICROPY_VM_HOOK_INIT
#endif
# 583 "../../py/mpconfig.h"

// Hook for the VM during the opcode loop (but only after jump opcodes)
#ifndef MICROPY_VM_HOOK_LOOP
#define MICROPY_VM_HOOK_LOOP
#endif
# 588 "../../py/mpconfig.h"

// Hook for the VM just before return opcode is finished being interpreted
#ifndef MICROPY_VM_HOOK_RETURN
#define MICROPY_VM_HOOK_RETURN
#endif
# 593 "../../py/mpconfig.h"

// Hook for mp_sched_schedule when a function gets scheduled on sched_queue
// (this macro executes within an atomic section)
#ifndef MICROPY_SCHED_HOOK_SCHEDULED
#define MICROPY_SCHED_HOOK_SCHEDULED
#endif
# 599 "../../py/mpconfig.h"

// Whether to include the garbage collector
#ifndef MICROPY_ENABLE_GC
#define MICROPY_ENABLE_GC (0)
#endif
# 604 "../../py/mpconfig.h"

// Whether to enable finalisers in the garbage collector (ie call __del__)
#ifndef MICROPY_ENABLE_FINALISER
#define MICROPY_ENABLE_FINALISER (0)
#endif
# 609 "../../py/mpconfig.h"

// Whether to enable a separate allocator for the Python stack.
// If enabled then the code must call mp_pystack_init before mp_init.
#ifndef MICROPY_ENABLE_PYSTACK
#define MICROPY_ENABLE_PYSTACK (0)
#endif
# 615 "../../py/mpconfig.h"

// Number of bytes that memory returned by mp_pystack_alloc will be aligned by.
#ifndef MICROPY_PYSTACK_ALIGN
#define MICROPY_PYSTACK_ALIGN (8)
#endif
# 620 "../../py/mpconfig.h"

// Whether to check C stack usage. C stack used for calling Python functions,
// etc. Not checking means segfault on overflow.
#ifndef MICROPY_STACK_CHECK
#define MICROPY_STACK_CHECK (0)
#endif
# 626 "../../py/mpconfig.h"

// Whether to have an emergency exception buffer
#ifndef MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF
#define MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF (0)
#endif
# 631 "../../py/mpconfig.h"
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 632 "../../py/mpconfig.h"
#ifndef MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE
#define MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE (0)      // 0 - implies dynamic allocation
#endif
# 635 "../../py/mpconfig.h"
#endif
# 636 "../../py/mpconfig.h"

// Whether to provide the mp_kbd_exception object, and micropython.kbd_intr function
#ifndef MICROPY_KBD_EXCEPTION
#define MICROPY_KBD_EXCEPTION (0)
#endif
# 641 "../../py/mpconfig.h"

// Prefer to raise KeyboardInterrupt asynchronously (from signal or interrupt
// handler) - if supported by a particular port.
#ifndef MICROPY_ASYNC_KBD_INTR
#define MICROPY_ASYNC_KBD_INTR (0)
#endif
# 647 "../../py/mpconfig.h"

// Whether to include REPL helper function
#ifndef MICROPY_HELPER_REPL
#define MICROPY_HELPER_REPL (0)
#endif
# 652 "../../py/mpconfig.h"

// Allow enabling debug prints after each REPL line
#ifndef MICROPY_REPL_INFO
#define MICROPY_REPL_INFO (0)
#endif
# 657 "../../py/mpconfig.h"

// Whether to include emacs-style readline behavior in REPL
#ifndef MICROPY_REPL_EMACS_KEYS
#define MICROPY_REPL_EMACS_KEYS (0)
#endif
# 662 "../../py/mpconfig.h"

// Whether to include emacs-style word movement/kill readline behavior in REPL.
// This adds Alt+F, Alt+B, Alt+D and Alt+Backspace for forward-word, backward-word, forward-kill-word
// and backward-kill-word, respectively.
#ifndef MICROPY_REPL_EMACS_WORDS_MOVE
#define MICROPY_REPL_EMACS_WORDS_MOVE (0)
#endif
# 669 "../../py/mpconfig.h"

// Whether to include extra convenience keys for word movement/kill in readline REPL.
// This adds Ctrl+Right, Ctrl+Left and Ctrl+W for forward-word, backward-word and backward-kill-word
// respectively. Ctrl+Delete is not implemented because it's a very different escape sequence.
// Depends on MICROPY_REPL_EMACS_WORDS_MOVE.
#ifndef MICROPY_REPL_EMACS_EXTRA_WORDS_MOVE
#define MICROPY_REPL_EMACS_EXTRA_WORDS_MOVE (0)
#endif
# 677 "../../py/mpconfig.h"

// Whether to implement auto-indent in REPL
#ifndef MICROPY_REPL_AUTO_INDENT
#define MICROPY_REPL_AUTO_INDENT (0)
#endif
# 682 "../../py/mpconfig.h"

// Whether port requires event-driven REPL functions
#ifndef MICROPY_REPL_EVENT_DRIVEN
#define MICROPY_REPL_EVENT_DRIVEN (0)
#endif
# 687 "../../py/mpconfig.h"

// Whether to include lexer helper function for unix
#ifndef MICROPY_HELPER_LEXER_UNIX
#define MICROPY_HELPER_LEXER_UNIX (0)
#endif
# 692 "../../py/mpconfig.h"

// Long int implementation
#define MICROPY_LONGINT_IMPL_NONE (0)
#define MICROPY_LONGINT_IMPL_LONGLONG (1)
#define MICROPY_LONGINT_IMPL_MPZ (2)

#ifndef MICROPY_LONGINT_IMPL
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_NONE)
#endif
# 701 "../../py/mpconfig.h"

#if 0 /* disabled by -frewrite-includes */
#if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_LONGLONG
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 703 "../../py/mpconfig.h"
typedef long long mp_longint_impl_t;
#endif
# 705 "../../py/mpconfig.h"

// Whether to include information in the byte code to determine source
// line number (increases RAM usage, but doesn't slow byte code execution)
#ifndef MICROPY_ENABLE_SOURCE_LINE
#define MICROPY_ENABLE_SOURCE_LINE (0)
#endif
# 711 "../../py/mpconfig.h"

// Whether to include doc strings (increases RAM usage)
#ifndef MICROPY_ENABLE_DOC_STRING
#define MICROPY_ENABLE_DOC_STRING (0)
#endif
# 716 "../../py/mpconfig.h"

// Exception messages are removed (requires disabling MICROPY_ROM_TEXT_COMPRESSION)
#define MICROPY_ERROR_REPORTING_NONE     (0)
// Exception messages are short static strings
#define MICROPY_ERROR_REPORTING_TERSE    (1)
// Exception messages provide basic error details
#define MICROPY_ERROR_REPORTING_NORMAL   (2)
// Exception messages provide full info, e.g. object names
#define MICROPY_ERROR_REPORTING_DETAILED (3)

#ifndef MICROPY_ERROR_REPORTING
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_FULL_FEATURES
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 728 "../../py/mpconfig.h"
#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_DETAILED)
#if 0 /* disabled by -frewrite-includes */
#if 0
#elif MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES
#endif
#endif /* disabled by -frewrite-includes */
#elif 0 /* evaluated by -frewrite-includes */
# 730 "../../py/mpconfig.h"
#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_NORMAL)
#else
# 732 "../../py/mpconfig.h"
#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_TERSE)
#endif
# 734 "../../py/mpconfig.h"
#endif
# 735 "../../py/mpconfig.h"

// Whether issue warnings during compiling/execution
#ifndef MICROPY_WARNINGS
#define MICROPY_WARNINGS (0)
#endif
# 740 "../../py/mpconfig.h"

// Whether to support warning categories
#ifndef MICROPY_WARNINGS_CATEGORY
#define MICROPY_WARNINGS_CATEGORY (0)
#endif
# 745 "../../py/mpconfig.h"

// This macro is used when printing runtime warnings and errors
#ifndef MICROPY_ERROR_PRINTER
#define MICROPY_ERROR_PRINTER (&mp_plat_print)
#endif
# 750 "../../py/mpconfig.h"

// Float and complex implementation
#define MICROPY_FLOAT_IMPL_NONE (0)
#define MICROPY_FLOAT_IMPL_FLOAT (1)
#define MICROPY_FLOAT_IMPL_DOUBLE (2)

#ifndef MICROPY_FLOAT_IMPL
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_NONE)
#endif
# 759 "../../py/mpconfig.h"

#if 0 /* disabled by -frewrite-includes */
#if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 761 "../../py/mpconfig.h"
#define MICROPY_PY_BUILTINS_FLOAT (1)
#define MICROPY_FLOAT_CONST(x) x##F
#define MICROPY_FLOAT_C_FUN(fun) fun##f
typedef float mp_float_t;
#if 0 /* disabled by -frewrite-includes */
#if 0
#elif MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE
#endif
#endif /* disabled by -frewrite-includes */
#elif 0 /* evaluated by -frewrite-includes */
# 766 "../../py/mpconfig.h"
#define MICROPY_PY_BUILTINS_FLOAT (1)
#define MICROPY_FLOAT_CONST(x) x
#define MICROPY_FLOAT_C_FUN(fun) fun
typedef double mp_float_t;
#else
# 771 "../../py/mpconfig.h"
#define MICROPY_PY_BUILTINS_FLOAT (0)
#endif
# 773 "../../py/mpconfig.h"

#ifndef MICROPY_PY_BUILTINS_COMPLEX
#define MICROPY_PY_BUILTINS_COMPLEX (MICROPY_PY_BUILTINS_FLOAT)
#endif
# 777 "../../py/mpconfig.h"

// Whether to provide a high-quality hash for float and complex numbers.
// Otherwise the default is a very simple but correct hashing function.
#ifndef MICROPY_FLOAT_HIGH_QUALITY_HASH
#define MICROPY_FLOAT_HIGH_QUALITY_HASH (0)
#endif
# 783 "../../py/mpconfig.h"

// Enable features which improve CPython compatibility
// but may lead to more code size/memory usage.
// TODO: Originally intended as generic category to not
// add bunch of once-off options. May need refactoring later
#ifndef MICROPY_CPYTHON_COMPAT
#define MICROPY_CPYTHON_COMPAT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
#endif
# 791 "../../py/mpconfig.h"

// Perform full checks as done by CPython. Disabling this
// may produce incorrect results, if incorrect data is fed,
// but should not lead to MicroPython crashes or similar
// grave issues (in other words, only user app should be,
// affected, not system).
#ifndef MICROPY_FULL_CHECKS
#define MICROPY_FULL_CHECKS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
#endif
# 800 "../../py/mpconfig.h"

// Whether POSIX-semantics non-blocking streams are supported
#ifndef MICROPY_STREAMS_NON_BLOCK
#define MICROPY_STREAMS_NON_BLOCK (0)
#endif
# 805 "../../py/mpconfig.h"

// Whether to provide stream functions with POSIX-like signatures
// (useful for porting existing libraries to MicroPython).
#ifndef MICROPY_STREAMS_POSIX_API
#define MICROPY_STREAMS_POSIX_API (0)
#endif
# 811 "../../py/mpconfig.h"

// Whether to call __init__ when importing builtin modules for the first time
#ifndef MICROPY_MODULE_BUILTIN_INIT
#define MICROPY_MODULE_BUILTIN_INIT (0)
#endif
# 816 "../../py/mpconfig.h"

// Whether to support module-level __getattr__ (see PEP 562)
#ifndef MICROPY_MODULE_GETATTR
#define MICROPY_MODULE_GETATTR (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
#endif
# 821 "../../py/mpconfig.h"

// Whether module weak links are supported
#ifndef MICROPY_MODULE_WEAK_LINKS
#define MICROPY_MODULE_WEAK_LINKS (0)
#endif
# 826 "../../py/mpconfig.h"

// Whether frozen modules are supported in the form of strings
#ifndef MICROPY_MODULE_FROZEN_STR
#define MICROPY_MODULE_FROZEN_STR (0)
#endif
# 831 "../../py/mpconfig.h"

// Whether frozen modules are supported in the form of .mpy files
#ifndef MICROPY_MODULE_FROZEN_MPY
#define MICROPY_MODULE_FROZEN_MPY (0)
#endif
# 836 "../../py/mpconfig.h"

// Convenience macro for whether frozen modules are supported
#ifndef MICROPY_MODULE_FROZEN
#define MICROPY_MODULE_FROZEN (MICROPY_MODULE_FROZEN_STR || MICROPY_MODULE_FROZEN_MPY)
#endif
# 841 "../../py/mpconfig.h"

// Whether you can override builtins in the builtins module
#ifndef MICROPY_CAN_OVERRIDE_BUILTINS
#define MICROPY_CAN_OVERRIDE_BUILTINS (0)
#endif
# 846 "../../py/mpconfig.h"

// Whether to check that the "self" argument of a builtin method has the
// correct type.  Such an explicit check is only needed if a builtin
// method escapes to Python land without a first argument, eg
// list.append([], 1).  Without this check such calls will have undefined
// behaviour (usually segfault) if the first argument is the wrong type.
#ifndef MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG
#define MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
#endif
# 855 "../../py/mpconfig.h"

// Whether to use internally defined errno's (otherwise system provided ones)
#ifndef MICROPY_USE_INTERNAL_ERRNO
#define MICROPY_USE_INTERNAL_ERRNO (0)
#endif
# 860 "../../py/mpconfig.h"

// Whether to use internally defined *printf() functions (otherwise external ones)
#ifndef MICROPY_USE_INTERNAL_PRINTF
#define MICROPY_USE_INTERNAL_PRINTF (1)
#endif
# 865 "../../py/mpconfig.h"

// Support for internal scheduler
#ifndef MICROPY_ENABLE_SCHEDULER
#define MICROPY_ENABLE_SCHEDULER (0)
#endif
# 870 "../../py/mpconfig.h"

// Maximum number of entries in the scheduler
#ifndef MICROPY_SCHEDULER_DEPTH
#define MICROPY_SCHEDULER_DEPTH (4)
#endif
# 875 "../../py/mpconfig.h"

// Support for generic VFS sub-system
#ifndef MICROPY_VFS
#define MICROPY_VFS (0)
#endif
# 880 "../../py/mpconfig.h"

// Support for VFS POSIX component, to mount a POSIX filesystem within VFS
#ifndef MICROPY_VFS
#define MICROPY_VFS_POSIX (0)
#endif
# 885 "../../py/mpconfig.h"

// Support for VFS FAT component, to mount a FAT filesystem within VFS
#ifndef MICROPY_VFS
#define MICROPY_VFS_FAT (0)
#endif
# 890 "../../py/mpconfig.h"

/*****************************************************************************/
/* Fine control over Python builtins, classes, modules, etc                  */

// Whether to support multiple inheritance of Python classes.  Multiple
// inheritance makes some C functions inherently recursive, and adds a bit of
// code overhead.
#ifndef MICROPY_MULTIPLE_INHERITANCE
#define MICROPY_MULTIPLE_INHERITANCE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
#endif
# 900 "../../py/mpconfig.h"

// Whether to implement attributes on functions
#ifndef MICROPY_PY_FUNCTION_ATTRS
#define MICROPY_PY_FUNCTION_ATTRS (0)
#endif
# 905 "../../py/mpconfig.h"

// Whether to support the descriptors __get__, __set__, __delete__
// This costs some code size and makes load/store/delete of instance
// attributes slower for the classes that use this feature
#ifndef MICROPY_PY_DESCRIPTORS
#define MICROPY_PY_DESCRIPTORS (0)
#endif
# 912 "../../py/mpconfig.h"

// Whether to support class __delattr__ and __setattr__ methods
// This costs some code size and makes store/delete of instance
// attributes slower for the classes that use this feature
#ifndef MICROPY_PY_DELATTR_SETATTR
#define MICROPY_PY_DELATTR_SETATTR (0)
#endif
# 919 "../../py/mpconfig.h"

// Support for async/await/async for/async with
#ifndef MICROPY_PY_ASYNC_AWAIT
#define MICROPY_PY_ASYNC_AWAIT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
#endif
# 924 "../../py/mpconfig.h"

// Support for literal string interpolation, f-strings (see PEP 498, Python 3.6+)
#ifndef MICROPY_PY_FSTRINGS
#define MICROPY_PY_FSTRINGS (0)
#endif
# 929 "../../py/mpconfig.h"

// Support for assignment expressions with := (see PEP 572, Python 3.8+)
#ifndef MICROPY_PY_ASSIGN_EXPR
#define MICROPY_PY_ASSIGN_EXPR (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
#endif
# 934 "../../py/mpconfig.h"

// Non-standard .pend_throw() method for generators, allowing for
// Future-like behavior with respect to exception handling: an
// exception set with .pend_throw() will activate on the next call
// to generator's .send() or .__next__(). (This is useful to implement
// async schedulers.)
#ifndef MICROPY_PY_GENERATOR_PEND_THROW
#define MICROPY_PY_GENERATOR_PEND_THROW (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
#endif
# 943 "../../py/mpconfig.h"

// Issue a warning when comparing str and bytes objects
#ifndef MICROPY_PY_STR_BYTES_CMP_WARN
#define MICROPY_PY_STR_BYTES_CMP_WARN (0)
#endif
# 948 "../../py/mpconfig.h"

// Whether str object is proper unicode
#ifndef MICROPY_PY_BUILTINS_STR_UNICODE
#define MICROPY_PY_BUILTINS_STR_UNICODE (0)
#endif
# 953 "../../py/mpconfig.h"

// Whether to check for valid UTF-8 when converting bytes to str
#ifndef MICROPY_PY_BUILTINS_STR_UNICODE_CHECK
#define MICROPY_PY_BUILTINS_STR_UNICODE_CHECK (MICROPY_PY_BUILTINS_STR_UNICODE)
#endif
# 958 "../../py/mpconfig.h"

// Whether str.center() method provided
#ifndef MICROPY_PY_BUILTINS_STR_CENTER
#define MICROPY_PY_BUILTINS_STR_CENTER (0)
#endif
# 963 "../../py/mpconfig.h"

// Whether str.count() method provided
#ifndef MICROPY_PY_BUILTINS_STR_COUNT
#define MICROPY_PY_BUILTINS_STR_COUNT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
#endif
# 968 "../../py/mpconfig.h"

// Whether str % (...) formatting operator provided
#ifndef MICROPY_PY_BUILTINS_STR_OP_MODULO
#define MICROPY_PY_BUILTINS_STR_OP_MODULO (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
#endif
# 973 "../../py/mpconfig.h"

// Whether str.partition()/str.rpartition() method provided
#ifndef MICROPY_PY_BUILTINS_STR_PARTITION
#define MICROPY_PY_BUILTINS_STR_PARTITION (0)
#endif
# 978 "../../py/mpconfig.h"

// Whether str.splitlines() method provided
#ifndef MICROPY_PY_BUILTINS_STR_SPLITLINES
#define MICROPY_PY_BUILTINS_STR_SPLITLINES (0)
#endif
# 983 "../../py/mpconfig.h"

// Whether to support bytearray object
#ifndef MICROPY_PY_BUILTINS_BYTEARRAY
#define MICROPY_PY_BUILTINS_BYTEARRAY (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
#endif
# 988 "../../py/mpconfig.h"

// Whether to support dict.fromkeys() class method
#ifndef MICROPY_PY_BUILTINS_DICT_FROMKEYS
#define MICROPY_PY_BUILTINS_DICT_FROMKEYS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
#endif
# 993 "../../py/mpconfig.h"

// Whether to support memoryview object
#ifndef MICROPY_PY_BUILTINS_MEMORYVIEW
#define MICROPY_PY_BUILTINS_MEMORYVIEW (0)
#endif
# 998 "../../py/mpconfig.h"

// Whether to support memoryview.itemsize attribute
#ifndef MICROPY_PY_BUILTINS_MEMORYVIEW_ITEMSIZE
#define MICROPY_PY_BUILTINS_MEMORYVIEW_ITEMSIZE (0)
#endif
# 1003 "../../py/mpconfig.h"

// Whether to support set object
#ifndef MICROPY_PY_BUILTINS_SET
#define MICROPY_PY_BUILTINS_SET (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
#endif
# 1008 "../../py/mpconfig.h"

// Whether to support slice subscript operators and slice object
#ifndef MICROPY_PY_BUILTINS_SLICE
#define MICROPY_PY_BUILTINS_SLICE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
#endif
# 1013 "../../py/mpconfig.h"

// Whether to support slice attribute read access,
// i.e. slice.start, slice.stop, slice.step
#ifndef MICROPY_PY_BUILTINS_SLICE_ATTRS
#define MICROPY_PY_BUILTINS_SLICE_ATTRS (0)
#endif
# 1019 "../../py/mpconfig.h"

// Whether to support the .indices(len) method on slice objects
#ifndef MICROPY_PY_BUILTINS_SLICE_INDICES
#define MICROPY_PY_BUILTINS_SLICE_INDICES (0)
#endif
# 1024 "../../py/mpconfig.h"

// Whether to support frozenset object
#ifndef MICROPY_PY_BUILTINS_FROZENSET
#define MICROPY_PY_BUILTINS_FROZENSET (0)
#endif
# 1029 "../../py/mpconfig.h"

// Whether to support property object
#ifndef MICROPY_PY_BUILTINS_PROPERTY
#define MICROPY_PY_BUILTINS_PROPERTY (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
#endif
# 1034 "../../py/mpconfig.h"

// Whether to implement the start/stop/step attributes (readback) on
// the "range" builtin type. Rarely used, and costs ~60 bytes (x86).
#ifndef MICROPY_PY_BUILTINS_RANGE_ATTRS
#define MICROPY_PY_BUILTINS_RANGE_ATTRS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
#endif
# 1040 "../../py/mpconfig.h"

// Whether to support binary ops [only (in)equality is defined] between range
// objects.  With this option disabled all range objects that are not exactly
// the same object will compare as not-equal.  With it enabled the semantics
// match CPython and ranges are equal if they yield the same sequence of items.
#ifndef MICROPY_PY_BUILTINS_RANGE_BINOP
#define MICROPY_PY_BUILTINS_RANGE_BINOP (0)
#endif
# 1048 "../../py/mpconfig.h"

// Support for callling next() with second argument
#ifndef MICROPY_PY_BUILTINS_NEXT2
#define MICROPY_PY_BUILTINS_NEXT2 (0)
#endif
# 1053 "../../py/mpconfig.h"

// Whether to support rounding of integers (incl bignum); eg round(123,-1)=120
#ifndef MICROPY_PY_BUILTINS_ROUND_INT
#define MICROPY_PY_BUILTINS_ROUND_INT (0)
#endif
# 1058 "../../py/mpconfig.h"

// Whether to support complete set of special methods for user
// classes, or only the most used ones. "Inplace" methods are
// controlled by MICROPY_PY_ALL_INPLACE_SPECIAL_METHODS below.
// "Reverse" methods are controlled by
// MICROPY_PY_REVERSE_SPECIAL_METHODS below.
#ifndef MICROPY_PY_ALL_SPECIAL_METHODS
#define MICROPY_PY_ALL_SPECIAL_METHODS (0)
#endif
# 1067 "../../py/mpconfig.h"

// Whether to support all inplace arithmetic operarion methods
// (__imul__, etc.)
#ifndef MICROPY_PY_ALL_INPLACE_SPECIAL_METHODS
#define MICROPY_PY_ALL_INPLACE_SPECIAL_METHODS (0)
#endif
# 1073 "../../py/mpconfig.h"

// Whether to support reverse arithmetic operarion methods
// (__radd__, etc.). Additionally gated by
// MICROPY_PY_ALL_SPECIAL_METHODS.
#ifndef MICROPY_PY_REVERSE_SPECIAL_METHODS
#define MICROPY_PY_REVERSE_SPECIAL_METHODS (0)
#endif
# 1080 "../../py/mpconfig.h"

// Whether to support compile function
#ifndef MICROPY_PY_BUILTINS_COMPILE
#define MICROPY_PY_BUILTINS_COMPILE (0)
#endif
# 1085 "../../py/mpconfig.h"

// Whether to support enumerate function(type)
#ifndef MICROPY_PY_BUILTINS_ENUMERATE
#define MICROPY_PY_BUILTINS_ENUMERATE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
#endif
# 1090 "../../py/mpconfig.h"

// Whether to support eval and exec functions
// By default they are supported if the compiler is enabled
#ifndef MICROPY_PY_BUILTINS_EVAL_EXEC
#define MICROPY_PY_BUILTINS_EVAL_EXEC (MICROPY_ENABLE_COMPILER)
#endif
# 1096 "../../py/mpconfig.h"

// Whether to support the Python 2 execfile function
#ifndef MICROPY_PY_BUILTINS_EXECFILE
#define MICROPY_PY_BUILTINS_EXECFILE (0)
#endif
# 1101 "../../py/mpconfig.h"

// Whether to support filter function(type)
#ifndef MICROPY_PY_BUILTINS_FILTER
#define MICROPY_PY_BUILTINS_FILTER (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
#endif
# 1106 "../../py/mpconfig.h"

// Whether to support reversed function(type)
#ifndef MICROPY_PY_BUILTINS_REVERSED
#define MICROPY_PY_BUILTINS_REVERSED (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
#endif
# 1111 "../../py/mpconfig.h"

// Whether to define "NotImplemented" special constant
#ifndef MICROPY_PY_BUILTINS_NOTIMPLEMENTED
#define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (0)
#endif
# 1116 "../../py/mpconfig.h"

// Whether to provide the built-in input() function. The implementation of this
// uses shared/readline, so can only be enabled if the port uses this readline.
#ifndef MICROPY_PY_BUILTINS_INPUT
#define MICROPY_PY_BUILTINS_INPUT (0)
#endif
# 1122 "../../py/mpconfig.h"

// Whether to support min/max functions
#ifndef MICROPY_PY_BUILTINS_MIN_MAX
#define MICROPY_PY_BUILTINS_MIN_MAX (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
#endif
# 1127 "../../py/mpconfig.h"

// Support for calls to pow() with 3 integer arguments
#ifndef MICROPY_PY_BUILTINS_POW3
#define MICROPY_PY_BUILTINS_POW3 (0)
#endif
# 1132 "../../py/mpconfig.h"

// Whether to provide the help function
#ifndef MICROPY_PY_BUILTINS_HELP
#define MICROPY_PY_BUILTINS_HELP (0)
#endif
# 1137 "../../py/mpconfig.h"

// Use this to configure the help text shown for help().  It should be a
// variable with the type "const char*".  A sensible default is provided.
#ifndef MICROPY_PY_BUILTINS_HELP_TEXT
#define MICROPY_PY_BUILTINS_HELP_TEXT mp_help_default_text
#endif
# 1143 "../../py/mpconfig.h"

// Add the ability to list the available modules when executing help('modules')
#ifndef MICROPY_PY_BUILTINS_HELP_MODULES
#define MICROPY_PY_BUILTINS_HELP_MODULES (0)
#endif
# 1148 "../../py/mpconfig.h"

// Whether to set __file__ for imported modules
#ifndef MICROPY_PY___FILE__
#define MICROPY_PY___FILE__ (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
#endif
# 1153 "../../py/mpconfig.h"

// Whether to provide mem-info related functions in micropython module
#ifndef MICROPY_PY_MICROPYTHON_MEM_INFO
#define MICROPY_PY_MICROPYTHON_MEM_INFO (0)
#endif
# 1158 "../../py/mpconfig.h"

// Whether to provide "micropython.stack_use" function
#ifndef MICROPY_PY_MICROPYTHON_STACK_USE
#define MICROPY_PY_MICROPYTHON_STACK_USE (MICROPY_PY_MICROPYTHON_MEM_INFO)
#endif
# 1163 "../../py/mpconfig.h"

// Whether to provide the "micropython.heap_locked" function
#ifndef MICROPY_PY_MICROPYTHON_HEAP_LOCKED
#define MICROPY_PY_MICROPYTHON_HEAP_LOCKED (0)
#endif
# 1168 "../../py/mpconfig.h"

// Whether to provide "array" module. Note that large chunk of the
// underlying code is shared with "bytearray" builtin type, so to
// get real savings, it should be disabled too.
#ifndef MICROPY_PY_ARRAY
#define MICROPY_PY_ARRAY (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
#endif
# 1175 "../../py/mpconfig.h"

// Whether to support slice assignments for array (and bytearray).
// This is rarely used, but adds ~0.5K of code.
#ifndef MICROPY_PY_ARRAY_SLICE_ASSIGN
#define MICROPY_PY_ARRAY_SLICE_ASSIGN (0)
#endif
# 1181 "../../py/mpconfig.h"

// Whether to support attrtuple type (MicroPython extension)
// It provides space-efficient tuples with attribute access
#ifndef MICROPY_PY_ATTRTUPLE
#define MICROPY_PY_ATTRTUPLE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
#endif
# 1187 "../../py/mpconfig.h"

// Whether to provide "collections" module
#ifndef MICROPY_PY_COLLECTIONS
#define MICROPY_PY_COLLECTIONS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
#endif
# 1192 "../../py/mpconfig.h"

// Whether to provide "ucollections.deque" type
#ifndef MICROPY_PY_COLLECTIONS_DEQUE
#define MICROPY_PY_COLLECTIONS_DEQUE (0)
#endif
# 1197 "../../py/mpconfig.h"

// Whether to provide "collections.OrderedDict" type
#ifndef MICROPY_PY_COLLECTIONS_ORDEREDDICT
#define MICROPY_PY_COLLECTIONS_ORDEREDDICT (0)
#endif
# 1202 "../../py/mpconfig.h"

// Whether to provide the _asdict function for namedtuple
#ifndef MICROPY_PY_COLLECTIONS_NAMEDTUPLE__ASDICT
#define MICROPY_PY_COLLECTIONS_NAMEDTUPLE__ASDICT (0)
#endif
# 1207 "../../py/mpconfig.h"

// Whether to provide "math" module
#ifndef MICROPY_PY_MATH
#define MICROPY_PY_MATH (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
#endif
# 1212 "../../py/mpconfig.h"

// Whether to provide special math functions: math.{erf,erfc,gamma,lgamma}
#ifndef MICROPY_PY_MATH_SPECIAL_FUNCTIONS
#define MICROPY_PY_MATH_SPECIAL_FUNCTIONS (0)
#endif
# 1217 "../../py/mpconfig.h"

// Whether to provide math.factorial function
#ifndef MICROPY_PY_MATH_FACTORIAL
#define MICROPY_PY_MATH_FACTORIAL (0)
#endif
# 1222 "../../py/mpconfig.h"

// Whether to provide math.isclose function
#ifndef MICROPY_PY_MATH_ISCLOSE
#define MICROPY_PY_MATH_ISCLOSE (0)
#endif
# 1227 "../../py/mpconfig.h"

// Whether to provide fix for atan2 Inf handling.
#ifndef MICROPY_PY_MATH_ATAN2_FIX_INFNAN
#define MICROPY_PY_MATH_ATAN2_FIX_INFNAN (0)
#endif
# 1232 "../../py/mpconfig.h"

// Whether to provide fix for fmod Inf handling.
#ifndef MICROPY_PY_MATH_FMOD_FIX_INFNAN
#define MICROPY_PY_MATH_FMOD_FIX_INFNAN (0)
#endif
# 1237 "../../py/mpconfig.h"

// Whether to provide fix for modf negative zero handling.
#ifndef MICROPY_PY_MATH_MODF_FIX_NEGZERO
#define MICROPY_PY_MATH_MODF_FIX_NEGZERO (0)
#endif
# 1242 "../../py/mpconfig.h"

// Whether to provide fix for pow(1, NaN) and pow(NaN, 0), which both should be 1 not NaN.
#ifndef MICROPY_PY_MATH_POW_FIX_NAN
#define MICROPY_PY_MATH_POW_FIX_NAN (0)
#endif
# 1247 "../../py/mpconfig.h"

// Whether to provide "cmath" module
#ifndef MICROPY_PY_CMATH
#define MICROPY_PY_CMATH (0)
#endif
# 1252 "../../py/mpconfig.h"

// Whether to provide "gc" module
#ifndef MICROPY_PY_GC
#define MICROPY_PY_GC (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
#endif
# 1257 "../../py/mpconfig.h"

// Whether to return number of collected objects from gc.collect()
#ifndef MICROPY_PY_GC_COLLECT_RETVAL
#define MICROPY_PY_GC_COLLECT_RETVAL (0)
#endif
# 1262 "../../py/mpconfig.h"

// Whether to provide "io" module
#ifndef MICROPY_PY_IO
#define MICROPY_PY_IO (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
#endif
# 1267 "../../py/mpconfig.h"

// Whether to provide "io.IOBase" class to support user streams
#ifndef MICROPY_PY_IO_IOBASE
#define MICROPY_PY_IO_IOBASE (0)
#endif
# 1272 "../../py/mpconfig.h"

// Whether to provide "uio.resource_stream()" function with
// the semantics of CPython's pkg_resources.resource_stream()
// (allows to access binary resources in frozen source packages).
// Note that the same functionality can be achieved in "pure
// Python" by prepocessing binary resources into Python source
// and bytecode-freezing it (with a simple helper module available
// e.g. in micropython-lib).
#ifndef MICROPY_PY_IO_RESOURCE_STREAM
#define MICROPY_PY_IO_RESOURCE_STREAM (0)
#endif
# 1283 "../../py/mpconfig.h"

// Whether to provide "io.FileIO" class
#ifndef MICROPY_PY_IO_FILEIO
#define MICROPY_PY_IO_FILEIO (0)
#endif
# 1288 "../../py/mpconfig.h"

// Whether to provide "io.BytesIO" class
#ifndef MICROPY_PY_IO_BYTESIO
#define MICROPY_PY_IO_BYTESIO (1)
#endif
# 1293 "../../py/mpconfig.h"

// Whether to provide "io.BufferedWriter" class
#ifndef MICROPY_PY_IO_BUFFEREDWRITER
#define MICROPY_PY_IO_BUFFEREDWRITER (0)
#endif
# 1298 "../../py/mpconfig.h"

// Whether to provide "struct" module
#ifndef MICROPY_PY_STRUCT
#define MICROPY_PY_STRUCT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
#endif
# 1303 "../../py/mpconfig.h"

// Whether to provide "sys" module
#ifndef MICROPY_PY_SYS
#define MICROPY_PY_SYS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
#endif
# 1308 "../../py/mpconfig.h"

// Whether to provide "sys.maxsize" constant
#ifndef MICROPY_PY_SYS_MAXSIZE
#define MICROPY_PY_SYS_MAXSIZE (0)
#endif
# 1313 "../../py/mpconfig.h"

// Whether to provide "sys.modules" dictionary
#ifndef MICROPY_PY_SYS_MODULES
#define MICROPY_PY_SYS_MODULES (1)
#endif
# 1318 "../../py/mpconfig.h"

// Whether to provide "sys.exc_info" function
// Avoid enabling this, this function is Python2 heritage
#ifndef MICROPY_PY_SYS_EXC_INFO
#define MICROPY_PY_SYS_EXC_INFO (0)
#endif
# 1324 "../../py/mpconfig.h"

// Whether to provide "sys.exit" function
#ifndef MICROPY_PY_SYS_EXIT
#define MICROPY_PY_SYS_EXIT (1)
#endif
# 1329 "../../py/mpconfig.h"

// Whether to provide "sys.atexit" function (MicroPython extension)
#ifndef MICROPY_PY_SYS_ATEXIT
#define MICROPY_PY_SYS_ATEXIT (0)
#endif
# 1334 "../../py/mpconfig.h"

// Whether to provide "sys.settrace" function
#ifndef MICROPY_PY_SYS_SETTRACE
#define MICROPY_PY_SYS_SETTRACE (0)
#endif
# 1339 "../../py/mpconfig.h"

// Whether to provide "sys.getsizeof" function
#ifndef MICROPY_PY_SYS_GETSIZEOF
#define MICROPY_PY_SYS_GETSIZEOF (0)
#endif
# 1344 "../../py/mpconfig.h"

// Whether to provide sys.{stdin,stdout,stderr} objects
#ifndef MICROPY_PY_SYS_STDFILES
#define MICROPY_PY_SYS_STDFILES (0)
#endif
# 1349 "../../py/mpconfig.h"

// Whether to provide sys.{stdin,stdout,stderr}.buffer object
// This is implemented per-port
#ifndef MICROPY_PY_SYS_STDIO_BUFFER
#define MICROPY_PY_SYS_STDIO_BUFFER (0)
#endif
# 1355 "../../py/mpconfig.h"

// Whether to provide "uerrno" module
#ifndef MICROPY_PY_UERRNO
#define MICROPY_PY_UERRNO (0)
#endif
# 1360 "../../py/mpconfig.h"

// Whether to provide the uerrno.errorcode dict
#ifndef MICROPY_PY_UERRNO_ERRORCODE
#define MICROPY_PY_UERRNO_ERRORCODE (1)
#endif
# 1365 "../../py/mpconfig.h"

// Whether to provide "uselect" module (baremetal implementation)
#ifndef MICROPY_PY_USELECT
#define MICROPY_PY_USELECT (0)
#endif
# 1370 "../../py/mpconfig.h"

// Whether to enable the select() function in the "uselect" module (baremetal
// implementation). This is present for compatibility but can be disabled to
// save space.
#ifndef MICROPY_PY_USELECT_SELECT
#define MICROPY_PY_USELECT_SELECT (1)
#endif
# 1377 "../../py/mpconfig.h"

// Whether to provide "utime" module functions implementation
// in terms of mp_hal_* functions.
#ifndef MICROPY_PY_UTIME_MP_HAL
#define MICROPY_PY_UTIME_MP_HAL (0)
#endif
# 1383 "../../py/mpconfig.h"

// Period of values returned by utime.ticks_ms(), ticks_us(), ticks_cpu()
// functions. Should be power of two. All functions above use the same
// period, so if underlying hardware/API has different periods, the
// minimum of them should be used. The value below is the maximum value
// this parameter can take (corresponding to 30 bit tick values on 32-bit
// system).
#ifndef MICROPY_PY_UTIME_TICKS_PERIOD
#define MICROPY_PY_UTIME_TICKS_PERIOD (MP_SMALL_INT_POSITIVE_MASK + 1)
#endif
# 1393 "../../py/mpconfig.h"

// Whether to provide "_thread" module
#ifndef MICROPY_PY_THREAD
#define MICROPY_PY_THREAD (0)
#endif
# 1398 "../../py/mpconfig.h"

// Whether to make the VM/runtime thread-safe using a global lock
// If not enabled then thread safety must be provided at the Python level
#ifndef MICROPY_PY_THREAD_GIL
#define MICROPY_PY_THREAD_GIL (MICROPY_PY_THREAD)
#endif
# 1404 "../../py/mpconfig.h"

// Number of VM jump-loops to do before releasing the GIL.
// Set this to 0 to disable the divisor.
#ifndef MICROPY_PY_THREAD_GIL_VM_DIVISOR
#define MICROPY_PY_THREAD_GIL_VM_DIVISOR (32)
#endif
# 1410 "../../py/mpconfig.h"

// Extended modules

#ifndef MICROPY_PY_UASYNCIO
#define MICROPY_PY_UASYNCIO (0)
#endif
# 1416 "../../py/mpconfig.h"

#ifndef MICROPY_PY_UCTYPES
#define MICROPY_PY_UCTYPES (0)
#endif
# 1420 "../../py/mpconfig.h"

// Whether to provide SHORT, INT, LONG, etc. types in addition to
// exact-bitness types like INT16, INT32, etc.
#ifndef MICROPY_PY_UCTYPES_NATIVE_C_TYPES
#define MICROPY_PY_UCTYPES_NATIVE_C_TYPES (1)
#endif
# 1426 "../../py/mpconfig.h"

#ifndef MICROPY_PY_UZLIB
#define MICROPY_PY_UZLIB (0)
#endif
# 1430 "../../py/mpconfig.h"

#ifndef MICROPY_PY_UJSON
#define MICROPY_PY_UJSON (0)
#endif
# 1434 "../../py/mpconfig.h"

// Whether to support the "separators" argument to dump, dumps
#ifndef MICROPY_PY_UJSON_SEPARATORS
#define MICROPY_PY_UJSON_SEPARATORS (1)
#endif
# 1439 "../../py/mpconfig.h"

#ifndef MICROPY_PY_URE
#define MICROPY_PY_URE (0)
#endif
# 1443 "../../py/mpconfig.h"

#ifndef MICROPY_PY_URE_DEBUG
#define MICROPY_PY_URE_DEBUG (0)
#endif
# 1447 "../../py/mpconfig.h"

#ifndef MICROPY_PY_URE_MATCH_GROUPS
#define MICROPY_PY_URE_MATCH_GROUPS (0)
#endif
# 1451 "../../py/mpconfig.h"

#ifndef MICROPY_PY_URE_MATCH_SPAN_START_END
#define MICROPY_PY_URE_MATCH_SPAN_START_END (0)
#endif
# 1455 "../../py/mpconfig.h"

#ifndef MICROPY_PY_URE_SUB
#define MICROPY_PY_URE_SUB (0)
#endif
# 1459 "../../py/mpconfig.h"

#ifndef MICROPY_PY_UHEAPQ
#define MICROPY_PY_UHEAPQ (0)
#endif
# 1463 "../../py/mpconfig.h"

// Optimized heap queue for relative timestamps
#ifndef MICROPY_PY_UTIMEQ
#define MICROPY_PY_UTIMEQ (0)
#endif
# 1468 "../../py/mpconfig.h"

#ifndef MICROPY_PY_UHASHLIB
#define MICROPY_PY_UHASHLIB (0)
#endif
# 1472 "../../py/mpconfig.h"

#ifndef MICROPY_PY_UHASHLIB_MD5
#define MICROPY_PY_UHASHLIB_MD5 (0)
#endif
# 1476 "../../py/mpconfig.h"

#ifndef MICROPY_PY_UHASHLIB_SHA1
#define MICROPY_PY_UHASHLIB_SHA1  (0)
#endif
# 1480 "../../py/mpconfig.h"

#ifndef MICROPY_PY_UHASHLIB_SHA256
#define MICROPY_PY_UHASHLIB_SHA256 (1)
#endif
# 1484 "../../py/mpconfig.h"

#ifndef MICROPY_PY_UCRYPTOLIB
#define MICROPY_PY_UCRYPTOLIB (0)
#endif
# 1488 "../../py/mpconfig.h"

// Depends on MICROPY_PY_UCRYPTOLIB
#ifndef MICROPY_PY_UCRYPTOLIB_CTR
#define MICROPY_PY_UCRYPTOLIB_CTR (0)
#endif
# 1493 "../../py/mpconfig.h"

#ifndef MICROPY_PY_UCRYPTOLIB_CONSTS
#define MICROPY_PY_UCRYPTOLIB_CONSTS (0)
#endif
# 1497 "../../py/mpconfig.h"

#ifndef MICROPY_PY_UBINASCII
#define MICROPY_PY_UBINASCII (0)
#endif
# 1501 "../../py/mpconfig.h"

// Depends on MICROPY_PY_UZLIB
#ifndef MICROPY_PY_UBINASCII_CRC32
#define MICROPY_PY_UBINASCII_CRC32 (0)
#endif
# 1506 "../../py/mpconfig.h"

#ifndef MICROPY_PY_URANDOM
#define MICROPY_PY_URANDOM (0)
#endif
# 1510 "../../py/mpconfig.h"

// Whether to include: randrange, randint, choice, random, uniform
#ifndef MICROPY_PY_URANDOM_EXTRA_FUNCS
#define MICROPY_PY_URANDOM_EXTRA_FUNCS (0)
#endif
# 1515 "../../py/mpconfig.h"

#ifndef MICROPY_PY_MACHINE
#define MICROPY_PY_MACHINE (0)
#endif
# 1519 "../../py/mpconfig.h"

// Whether to include: bitstream
#ifndef MICROPY_PY_MACHINE_BITSTREAM
#define MICROPY_PY_MACHINE_BITSTREAM (0)
#endif
# 1524 "../../py/mpconfig.h"

// Whether to include: time_pulse_us
#ifndef MICROPY_PY_MACHINE_PULSE
#define MICROPY_PY_MACHINE_PULSE (0)
#endif
# 1529 "../../py/mpconfig.h"

#ifndef MICROPY_PY_MACHINE_I2C
#define MICROPY_PY_MACHINE_I2C (0)
#endif
# 1533 "../../py/mpconfig.h"

// Whether to provide the "machine.SoftI2C" class
#ifndef MICROPY_PY_MACHINE_SOFTI2C
#define MICROPY_PY_MACHINE_SOFTI2C (0)
#endif
# 1538 "../../py/mpconfig.h"

#ifndef MICROPY_PY_MACHINE_SPI
#define MICROPY_PY_MACHINE_SPI (0)
#endif
# 1542 "../../py/mpconfig.h"

// Whether to provide the "machine.SoftSPI" class
#ifndef MICROPY_PY_MACHINE_SOFTSPI
#define MICROPY_PY_MACHINE_SOFTSPI (0)
#endif
# 1547 "../../py/mpconfig.h"

#ifndef MICROPY_PY_USSL
#define MICROPY_PY_USSL (0)
// Whether to add finaliser code to ussl objects
#define MICROPY_PY_USSL_FINALISER (0)
#endif
# 1553 "../../py/mpconfig.h"

#ifndef MICROPY_PY_UWEBSOCKET
#define MICROPY_PY_UWEBSOCKET (0)
#endif
# 1557 "../../py/mpconfig.h"

#ifndef MICROPY_PY_FRAMEBUF
#define MICROPY_PY_FRAMEBUF (0)
#endif
# 1561 "../../py/mpconfig.h"

#ifndef MICROPY_PY_BTREE
#define MICROPY_PY_BTREE (0)
#endif
# 1565 "../../py/mpconfig.h"

// Whether to provide the low-level "_onewire" module
#ifndef MICROPY_PY_ONEWIRE
#define MICROPY_PY_ONEWIRE (0)
#endif
# 1570 "../../py/mpconfig.h"

/*****************************************************************************/
/* Hooks for a port to add builtins                                          */

// Additional builtin function definitions - see modbuiltins.c:mp_module_builtins_globals_table for format.
#ifndef MICROPY_PORT_BUILTINS
#define MICROPY_PORT_BUILTINS
#endif
# 1578 "../../py/mpconfig.h"

// Additional builtin module definitions - see objmodule.c:mp_builtin_module_table for format.
#ifndef MICROPY_PORT_BUILTIN_MODULES
#define MICROPY_PORT_BUILTIN_MODULES
#endif
# 1583 "../../py/mpconfig.h"

// Additional constant definitions for the compiler - see compile.c:mp_constants_table.
#ifndef MICROPY_PORT_CONSTANTS
#define MICROPY_PORT_CONSTANTS
#endif
# 1588 "../../py/mpconfig.h"

// Any root pointers for GC scanning - see mpstate.c
#ifndef MICROPY_PORT_ROOT_POINTERS
#define MICROPY_PORT_ROOT_POINTERS
#endif
# 1593 "../../py/mpconfig.h"

/*****************************************************************************/
/* Hooks for a port to wrap functions with attributes                        */

#ifndef MICROPY_WRAP_MP_BINARY_OP
#define MICROPY_WRAP_MP_BINARY_OP(f) f
#endif
# 1600 "../../py/mpconfig.h"

#ifndef MICROPY_WRAP_MP_EXECUTE_BYTECODE
#define MICROPY_WRAP_MP_EXECUTE_BYTECODE(f) f
#endif
# 1604 "../../py/mpconfig.h"

#ifndef MICROPY_WRAP_MP_LOAD_GLOBAL
#define MICROPY_WRAP_MP_LOAD_GLOBAL(f) f
#endif
# 1608 "../../py/mpconfig.h"

#ifndef MICROPY_WRAP_MP_LOAD_NAME
#define MICROPY_WRAP_MP_LOAD_NAME(f) f
#endif
# 1612 "../../py/mpconfig.h"

#ifndef MICROPY_WRAP_MP_MAP_LOOKUP
#define MICROPY_WRAP_MP_MAP_LOOKUP(f) f
#endif
# 1616 "../../py/mpconfig.h"

#ifndef MICROPY_WRAP_MP_OBJ_GET_TYPE
#define MICROPY_WRAP_MP_OBJ_GET_TYPE(f) f
#endif
# 1620 "../../py/mpconfig.h"

#ifndef MICROPY_WRAP_MP_SCHED_EXCEPTION
#define MICROPY_WRAP_MP_SCHED_EXCEPTION(f) f
#endif
# 1624 "../../py/mpconfig.h"

#ifndef MICROPY_WRAP_MP_SCHED_KEYBOARD_INTERRUPT
#define MICROPY_WRAP_MP_SCHED_KEYBOARD_INTERRUPT(f) f
#endif
# 1628 "../../py/mpconfig.h"

#ifndef MICROPY_WRAP_MP_SCHED_SCHEDULE
#define MICROPY_WRAP_MP_SCHED_SCHEDULE(f) f
#endif
# 1632 "../../py/mpconfig.h"

/*****************************************************************************/
/* Miscellaneous settings                                                    */

// All uPy objects in ROM must be aligned on at least a 4 byte boundary
// so that the small-int/qstr/pointer distinction can be made.  For machines
// that don't do this (eg 16-bit CPU), define the following macro to something
// like __attribute__((aligned(4))).
#ifndef MICROPY_OBJ_BASE_ALIGNMENT
#define MICROPY_OBJ_BASE_ALIGNMENT
#endif
# 1643 "../../py/mpconfig.h"

// On embedded platforms, these will typically enable/disable irqs.
#ifndef MICROPY_BEGIN_ATOMIC_SECTION
#define MICROPY_BEGIN_ATOMIC_SECTION() (0)
#endif
# 1648 "../../py/mpconfig.h"
#ifndef MICROPY_END_ATOMIC_SECTION
#define MICROPY_END_ATOMIC_SECTION(state) (void)(state)
#endif
# 1651 "../../py/mpconfig.h"

// Allow to override static modifier for global objects, e.g. to use with
// object code analysis tools which don't support static symbols.
#ifndef STATIC
#define STATIC static
#endif
# 1657 "../../py/mpconfig.h"

// Number of bytes in an object word: mp_obj_t, mp_uint_t, mp_uint_t
#ifndef MP_BYTES_PER_OBJ_WORD
#define MP_BYTES_PER_OBJ_WORD (sizeof(mp_uint_t))
#endif
# 1662 "../../py/mpconfig.h"

// Number of bits in a byte
#ifndef MP_BITS_PER_BYTE
#define MP_BITS_PER_BYTE (8)
#endif
# 1667 "../../py/mpconfig.h"
// mp_int_t value with most significant bit set
#define MP_OBJ_WORD_MSBIT_HIGH (((mp_uint_t)1) << (MP_BYTES_PER_OBJ_WORD * MP_BITS_PER_BYTE - 1))

// Make sure both MP_ENDIANNESS_LITTLE and MP_ENDIANNESS_BIG are
// defined and that they are the opposite of each other.
#if 0 /* disabled by -frewrite-includes */
#if defined(MP_ENDIANNESS_LITTLE)
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 1673 "../../py/mpconfig.h"
#define MP_ENDIANNESS_BIG (!MP_ENDIANNESS_LITTLE)
#if 0 /* disabled by -frewrite-includes */
#if 0
#elif defined(MP_ENDIANNESS_BIG)
#endif
#endif /* disabled by -frewrite-includes */
#elif 0 /* evaluated by -frewrite-includes */
# 1675 "../../py/mpconfig.h"
#define MP_ENDIANNESS_LITTLE (!MP_ENDIANNESS_BIG)
#else
# 1677 "../../py/mpconfig.h"
// Endianness not defined by port so try to autodetect it.
 
#if 0 /* disabled by -frewrite-includes */
#if defined(__BYTE_ORDER__)
#endif
#endif /* disabled by -frewrite-includes */
#if 1 /* evaluated by -frewrite-includes */
# 1679 "../../py/mpconfig.h"
   
#if 0 /* disabled by -frewrite-includes */
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#endif
#endif /* disabled by -frewrite-includes */
#if 1 /* evaluated by -frewrite-includes */
# 1680 "../../py/mpconfig.h"
      #define MP_ENDIANNESS_LITTLE (1)
   
#if 0 /* disabled by -frewrite-includes */
#if 0
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
#endif
#endif /* disabled by -frewrite-includes */
#elif 0 /* evaluated by -frewrite-includes */
# 1682 "../../py/mpconfig.h"
      #define MP_ENDIANNESS_LITTLE (0)
    #endif
# 1684 "../../py/mpconfig.h"
  #else
# 1685 "../../py/mpconfig.h"
    #if 0 /* expanded by -frewrite-includes */
#include <endian.h>
#endif /* expanded by -frewrite-includes */
# 1685 "../../py/mpconfig.h"
# 1686 "../../py/mpconfig.h"
     
#if 0 /* disabled by -frewrite-includes */
#if defined(__BYTE_ORDER)
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 1687 "../../py/mpconfig.h"
       
#if 0 /* disabled by -frewrite-includes */
#if __BYTE_ORDER == __LITTLE_ENDIAN
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 1688 "../../py/mpconfig.h"
          #define MP_ENDIANNESS_LITTLE (1)
       
#if 0 /* disabled by -frewrite-includes */
#if 0
#elif __BYTE_ORDER == __BIG_ENDIAN
#endif
#endif /* disabled by -frewrite-includes */
#elif 0 /* evaluated by -frewrite-includes */
# 1690 "../../py/mpconfig.h"
          #define MP_ENDIANNESS_LITTLE (0)
        #endif
# 1692 "../../py/mpconfig.h"
      #endif
# 1693 "../../py/mpconfig.h"
  #endif
# 1694 "../../py/mpconfig.h"
  #ifndef MP_ENDIANNESS_LITTLE
    #error endianness not defined and cannot detect it
  #endif
# 1697 "../../py/mpconfig.h"
  #define MP_ENDIANNESS_BIG (!MP_ENDIANNESS_LITTLE)
#endif
# 1699 "../../py/mpconfig.h"

// Make a pointer to RAM callable (eg set lower bit for Thumb code)
// (This scheme won't work if we want to mix Thumb and normal ARM code.)
#ifndef MICROPY_MAKE_POINTER_CALLABLE
#define MICROPY_MAKE_POINTER_CALLABLE(p) (p)
#endif
# 1705 "../../py/mpconfig.h"

// If these MP_PLAT_*_EXEC macros are overridden then the memory allocated by them
// must be somehow reachable for marking by the GC, since the native code
// generators store pointers to GC managed memory in the code.
#ifndef MP_PLAT_ALLOC_EXEC
#define MP_PLAT_ALLOC_EXEC(min_size, ptr, size) do { *ptr = m_new(byte, min_size); *size = min_size; } while (0)
#endif
# 1712 "../../py/mpconfig.h"

#ifndef MP_PLAT_FREE_EXEC
#define MP_PLAT_FREE_EXEC(ptr, size) m_del(byte, ptr, size)
#endif
# 1716 "../../py/mpconfig.h"

// This macro is used to do all output (except when MICROPY_PY_IO is defined)
#ifndef MP_PLAT_PRINT_STRN
#define MP_PLAT_PRINT_STRN(str, len) mp_hal_stdout_tx_strn_cooked(str, len)
#endif
# 1721 "../../py/mpconfig.h"

#ifndef MP_SSIZE_MAX
#define MP_SSIZE_MAX SSIZE_MAX
#endif
# 1725 "../../py/mpconfig.h"

// printf format spec to use for mp_int_t and friends
#ifndef INT_FMT
#if 0 /* disabled by -frewrite-includes */
#if defined(__LP64__)
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 1729 "../../py/mpconfig.h"
// Archs where mp_int_t == long, long != int
#define UINT_FMT "%lu"
#define INT_FMT "%ld"
#if 0 /* disabled by -frewrite-includes */
#if 0
#elif defined(_WIN64)
#endif
#endif /* disabled by -frewrite-includes */
#elif 0 /* evaluated by -frewrite-includes */
# 1733 "../../py/mpconfig.h"
#define UINT_FMT "%llu"
#define INT_FMT "%lld"
#else
# 1736 "../../py/mpconfig.h"
// Archs where mp_int_t == int
#define UINT_FMT "%u"
#define INT_FMT "%d"
#endif
# 1740 "../../py/mpconfig.h"
#endif // INT_FMT
# 1741 "../../py/mpconfig.h"

// Modifier for function which doesn't return
#ifndef NORETURN
#define NORETURN __attribute__((noreturn))
#endif
# 1746 "../../py/mpconfig.h"

// Modifier for weak functions
#ifndef MP_WEAK
#define MP_WEAK __attribute__((weak))
#endif
# 1751 "../../py/mpconfig.h"

// Modifier for functions which should be never inlined
#ifndef MP_NOINLINE
#define MP_NOINLINE __attribute__((noinline))
#endif
# 1756 "../../py/mpconfig.h"

// Modifier for functions which should be always inlined
#ifndef MP_ALWAYSINLINE
#define MP_ALWAYSINLINE __attribute__((always_inline))
#endif
# 1761 "../../py/mpconfig.h"

// Condition is likely to be true, to help branch prediction
#ifndef MP_LIKELY
#define MP_LIKELY(x) __builtin_expect((x), 1)
#endif
# 1766 "../../py/mpconfig.h"

// Condition is likely to be false, to help branch prediction
#ifndef MP_UNLIKELY
#define MP_UNLIKELY(x) __builtin_expect((x), 0)
#endif
# 1771 "../../py/mpconfig.h"

// To annotate that code is unreachable
#ifndef MP_UNREACHABLE
#if 0 /* disabled by -frewrite-includes */
#if defined(__GNUC__)
#endif
#endif /* disabled by -frewrite-includes */
#if 1 /* evaluated by -frewrite-includes */
# 1775 "../../py/mpconfig.h"
#define MP_UNREACHABLE __builtin_unreachable();
#else
# 1777 "../../py/mpconfig.h"
#define MP_UNREACHABLE for (;;);
#endif
# 1779 "../../py/mpconfig.h"
#endif
# 1780 "../../py/mpconfig.h"

// Explicitly annotate switch case fall throughs
#if 0 /* disabled by -frewrite-includes */
#if defined(__GNUC__) && __GNUC__ >= 7
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 1783 "../../py/mpconfig.h"
#define MP_FALLTHROUGH __attribute__((fallthrough));
#else
# 1785 "../../py/mpconfig.h"
#define MP_FALLTHROUGH
#endif
# 1787 "../../py/mpconfig.h"

#ifndef MP_HTOBE16
#if 0 /* disabled by -frewrite-includes */
#if MP_ENDIANNESS_LITTLE
#endif
#endif /* disabled by -frewrite-includes */
#if 1 /* evaluated by -frewrite-includes */
# 1790 "../../py/mpconfig.h"
#define MP_HTOBE16(x) ((uint16_t)((((x) & 0xff) << 8) | (((x) >> 8) & 0xff)))
#define MP_BE16TOH(x) MP_HTOBE16(x)
#else
# 1793 "../../py/mpconfig.h"
#define MP_HTOBE16(x) (x)
#define MP_BE16TOH(x) (x)
#endif
# 1796 "../../py/mpconfig.h"
#endif
# 1797 "../../py/mpconfig.h"

#ifndef MP_HTOBE32
#if 0 /* disabled by -frewrite-includes */
#if MP_ENDIANNESS_LITTLE
#endif
#endif /* disabled by -frewrite-includes */
#if 1 /* evaluated by -frewrite-includes */
# 1800 "../../py/mpconfig.h"
#define MP_HTOBE32(x) ((uint32_t)((((x) & 0xff) << 24) | (((x) & 0xff00) << 8) | (((x) >> 8) & 0xff00) | (((x) >> 24) & 0xff)))
#define MP_BE32TOH(x) MP_HTOBE32(x)
#else
# 1803 "../../py/mpconfig.h"
#define MP_HTOBE32(x) (x)
#define MP_BE32TOH(x) (x)
#endif
# 1806 "../../py/mpconfig.h"
#endif
# 1807 "../../py/mpconfig.h"

// Warning categories are by default implemented as strings, though
// hook is left for a port to define them as something else.
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_WARNINGS_CATEGORY
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 1811 "../../py/mpconfig.h"
#ifndef MP_WARN_CAT
#define MP_WARN_CAT(x) #x
#endif
# 1814 "../../py/mpconfig.h"
#else
# 1815 "../../py/mpconfig.h"
#undef MP_WARN_CAT
#define MP_WARN_CAT(x) (NULL)
#endif
# 1818 "../../py/mpconfig.h"

// Feature dependency check.
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_PY_SYS_SETTRACE
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 1821 "../../py/mpconfig.h"
#if 0 /* disabled by -frewrite-includes */
#if !MICROPY_PERSISTENT_CODE_SAVE
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 1822 "../../py/mpconfig.h"
#error "MICROPY_PY_SYS_SETTRACE requires MICROPY_PERSISTENT_CODE_SAVE to be enabled"
#endif
# 1824 "../../py/mpconfig.h"
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_COMP_CONST
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 1825 "../../py/mpconfig.h"
#error "MICROPY_PY_SYS_SETTRACE requires MICROPY_COMP_CONST to be disabled"
#endif
# 1827 "../../py/mpconfig.h"
#endif
# 1828 "../../py/mpconfig.h"

#endif // MICROPY_INCLUDED_PY_MPCONFIG_H
# 1830 "../../py/mpconfig.h"
# 32 "../../py/mpstate.h" 2
#if 0 /* expanded by -frewrite-includes */
#include "py/mpthread.h"
#endif /* expanded by -frewrite-includes */
# 32 "../../py/mpstate.h"
# 1 "../../py/mpthread.h" 1
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef MICROPY_INCLUDED_PY_MPTHREAD_H
#define MICROPY_INCLUDED_PY_MPTHREAD_H

#if 0 /* expanded by -frewrite-includes */
#include "py/mpconfig.h"
#endif /* expanded by -frewrite-includes */
# 29 "../../py/mpthread.h"
# 30 "../../py/mpthread.h"

#if 0 /* disabled by -frewrite-includes */
#if MICROPY_PY_THREAD
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 32 "../../py/mpthread.h"

struct _mp_state_thread_t;

#ifdef MICROPY_MPTHREADPORT_H
#if 0 /* expanded by -frewrite-includes */
#include MICROPY_MPTHREADPORT_H
#endif /* expanded by -frewrite-includes */
# 36 "../../py/mpthread.h"
# 37 "../../py/mpthread.h"
#else
# 38 "../../py/mpthread.h"
#if 0 /* expanded by -frewrite-includes */
#include <mpthreadport.h>
#endif /* expanded by -frewrite-includes */
# 38 "../../py/mpthread.h"
# 39 "../../py/mpthread.h"
#endif
# 40 "../../py/mpthread.h"

struct _mp_state_thread_t *mp_thread_get_state(void);
void mp_thread_set_state(struct _mp_state_thread_t *state);
void mp_thread_create(void *(*entry)(void *), void *arg, size_t *stack_size);
void mp_thread_start(void);
void mp_thread_finish(void);
void mp_thread_mutex_init(mp_thread_mutex_t *mutex);
int mp_thread_mutex_lock(mp_thread_mutex_t *mutex, int wait);
void mp_thread_mutex_unlock(mp_thread_mutex_t *mutex);

#endif // MICROPY_PY_THREAD
# 51 "../../py/mpthread.h"

#if 0 /* disabled by -frewrite-includes */
#if MICROPY_PY_THREAD && MICROPY_PY_THREAD_GIL
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 53 "../../py/mpthread.h"
#if 0 /* expanded by -frewrite-includes */
#include "py/mpstate.h"
#endif /* expanded by -frewrite-includes */
# 53 "../../py/mpthread.h"
# 54 "../../py/mpthread.h"
#define MP_THREAD_GIL_ENTER() mp_thread_mutex_lock(&MP_STATE_VM(gil_mutex), 1)
#define MP_THREAD_GIL_EXIT() mp_thread_mutex_unlock(&MP_STATE_VM(gil_mutex))
#else
# 57 "../../py/mpthread.h"
#define MP_THREAD_GIL_ENTER()
#define MP_THREAD_GIL_EXIT()
#endif
# 60 "../../py/mpthread.h"

#endif // MICROPY_INCLUDED_PY_MPTHREAD_H
# 62 "../../py/mpthread.h"
# 33 "../../py/mpstate.h" 2
#if 0 /* expanded by -frewrite-includes */
#include "py/misc.h"
#endif /* expanded by -frewrite-includes */
# 33 "../../py/mpstate.h"
# 1 "../../py/misc.h" 1
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef MICROPY_INCLUDED_PY_MISC_H
#define MICROPY_INCLUDED_PY_MISC_H

// a mini library of useful types and functions

/** types *******************************************************/

#if 0 /* expanded by -frewrite-includes */
#include <stdbool.h>
#endif /* expanded by -frewrite-includes */
# 33 "../../py/misc.h"
# 34 "../../py/misc.h"
#if 0 /* expanded by -frewrite-includes */
#include <stdint.h>
#endif /* expanded by -frewrite-includes */
# 34 "../../py/misc.h"
# 35 "../../py/misc.h"
#if 0 /* expanded by -frewrite-includes */
#include <stddef.h>
#endif /* expanded by -frewrite-includes */
# 35 "../../py/misc.h"
# 36 "../../py/misc.h"

typedef unsigned char byte;
typedef unsigned int uint;

/** generic ops *************************************************/

#ifndef MIN
#define MIN(x, y) ((x) < (y) ? (x) : (y))
#endif
# 45 "../../py/misc.h"
#ifndef MAX
#define MAX(x, y) ((x) > (y) ? (x) : (y))
#endif
# 48 "../../py/misc.h"

// Classical double-indirection stringification of preprocessor macro's value
#define MP_STRINGIFY_HELPER(x) #x
#define MP_STRINGIFY(x) MP_STRINGIFY_HELPER(x)

// Static assertion macro
#define MP_STATIC_ASSERT(cond) ((void)sizeof(char[1 - 2 * !(cond)]))

// Round-up integer division
#define MP_CEIL_DIVIDE(a, b) (((a) + (b) - 1) / (b))
#define MP_ROUND_DIVIDE(a, b) (((a) + (b) / 2) / (b))

/** memory allocation ******************************************/

// TODO make a lazy m_renew that can increase by a smaller amount than requested (but by at least 1 more element)

#define m_new(type, num) ((type *)(m_malloc(sizeof(type) * (num))))
#define m_new_maybe(type, num) ((type *)(m_malloc_maybe(sizeof(type) * (num))))
#define m_new0(type, num) ((type *)(m_malloc0(sizeof(type) * (num))))
#define m_new_obj(type) (m_new(type, 1))
#define m_new_obj_maybe(type) (m_new_maybe(type, 1))
#define m_new_obj_var(obj_type, var_type, var_num) ((obj_type *)m_malloc(sizeof(obj_type) + sizeof(var_type) * (var_num)))
#define m_new_obj_var_maybe(obj_type, var_type, var_num) ((obj_type *)m_malloc_maybe(sizeof(obj_type) + sizeof(var_type) * (var_num)))
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_ENABLE_FINALISER
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 72 "../../py/misc.h"
#define m_new_obj_with_finaliser(type) ((type *)(m_malloc_with_finaliser(sizeof(type))))
#define m_new_obj_var_with_finaliser(type, var_type, var_num) ((type *)m_malloc_with_finaliser(sizeof(type) + sizeof(var_type) * (var_num)))
#else
# 75 "../../py/misc.h"
#define m_new_obj_with_finaliser(type) m_new_obj(type)
#define m_new_obj_var_with_finaliser(type, var_type, var_num) m_new_obj_var(type, var_type, var_num)
#endif
# 78 "../../py/misc.h"
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_MALLOC_USES_ALLOCATED_SIZE
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 79 "../../py/misc.h"
#define m_renew(type, ptr, old_num, new_num) ((type *)(m_realloc((ptr), sizeof(type) * (old_num), sizeof(type) * (new_num))))
#define m_renew_maybe(type, ptr, old_num, new_num, allow_move) ((type *)(m_realloc_maybe((ptr), sizeof(type) * (old_num), sizeof(type) * (new_num), (allow_move))))
#define m_del(type, ptr, num) m_free(ptr, sizeof(type) * (num))
#define m_del_var(obj_type, var_type, var_num, ptr) (m_free(ptr, sizeof(obj_type) + sizeof(var_type) * (var_num)))
#else
# 84 "../../py/misc.h"
#define m_renew(type, ptr, old_num, new_num) ((type *)(m_realloc((ptr), sizeof(type) * (new_num))))
#define m_renew_maybe(type, ptr, old_num, new_num, allow_move) ((type *)(m_realloc_maybe((ptr), sizeof(type) * (new_num), (allow_move))))
#define m_del(type, ptr, num) ((void)(num), m_free(ptr))
#define m_del_var(obj_type, var_type, var_num, ptr) ((void)(var_num), m_free(ptr))
#endif
# 89 "../../py/misc.h"
#define m_del_obj(type, ptr) (m_del(type, ptr, 1))

void *m_malloc(size_t num_bytes);
void *m_malloc_maybe(size_t num_bytes);
void *m_malloc_with_finaliser(size_t num_bytes);
void *m_malloc0(size_t num_bytes);
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_MALLOC_USES_ALLOCATED_SIZE
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 96 "../../py/misc.h"
void *m_realloc(void *ptr, size_t old_num_bytes, size_t new_num_bytes);
void *m_realloc_maybe(void *ptr, size_t old_num_bytes, size_t new_num_bytes, bool allow_move);
void m_free(void *ptr, size_t num_bytes);
#else
# 100 "../../py/misc.h"
void *m_realloc(void *ptr, size_t new_num_bytes);
void *m_realloc_maybe(void *ptr, size_t new_num_bytes, bool allow_move);
void m_free(void *ptr);
#endif
# 104 "../../py/misc.h"
NORETURN void m_malloc_fail(size_t num_bytes);

#if 0 /* disabled by -frewrite-includes */
#if MICROPY_MEM_STATS
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 107 "../../py/misc.h"
size_t m_get_total_bytes_allocated(void);
size_t m_get_current_bytes_allocated(void);
size_t m_get_peak_bytes_allocated(void);
#endif
# 111 "../../py/misc.h"

/** array helpers ***********************************************/

// get the number of elements in a fixed-size array
#define MP_ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))

// align ptr to the nearest multiple of "alignment"
#define MP_ALIGN(ptr, alignment) (void *)(((uintptr_t)(ptr) + ((alignment) - 1)) & ~((alignment) - 1))

/** unichar / UTF-8 *********************************************/

#if 0 /* disabled by -frewrite-includes */
#if MICROPY_PY_BUILTINS_STR_UNICODE
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 123 "../../py/misc.h"
// with unicode enabled we need a type which can fit chars up to 0x10ffff
typedef uint32_t unichar;
#else
# 126 "../../py/misc.h"
// without unicode enabled we can only need to fit chars up to 0xff
// (on 16-bit archs uint is 16-bits and more efficient than uint32_t)
typedef uint unichar;
#endif
# 130 "../../py/misc.h"

#if 0 /* disabled by -frewrite-includes */
#if MICROPY_PY_BUILTINS_STR_UNICODE
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 132 "../../py/misc.h"
unichar utf8_get_char(const byte *s);
const byte *utf8_next_char(const byte *s);
size_t utf8_charlen(const byte *str, size_t len);
#else
# 136 "../../py/misc.h"
static inline unichar utf8_get_char(const byte *s) {
    return *s;
}
static inline const byte *utf8_next_char(const byte *s) {
    return s + 1;
}
static inline size_t utf8_charlen(const byte *str, size_t len) {
    (void)str;
    return len;
}
#endif
# 147 "../../py/misc.h"

bool unichar_isspace(unichar c);
bool unichar_isalpha(unichar c);
bool unichar_isprint(unichar c);
bool unichar_isdigit(unichar c);
bool unichar_isxdigit(unichar c);
bool unichar_isident(unichar c);
bool unichar_isalnum(unichar c);
bool unichar_isupper(unichar c);
bool unichar_islower(unichar c);
unichar unichar_tolower(unichar c);
unichar unichar_toupper(unichar c);
mp_uint_t unichar_xdigit_value(unichar c);
#define UTF8_IS_NONASCII(ch) ((ch) & 0x80)
#define UTF8_IS_CONT(ch) (((ch) & 0xC0) == 0x80)

/** variable string *********************************************/

typedef struct _vstr_t {
    size_t alloc;
    size_t len;
    char *buf;
    bool fixed_buf : 1;
} vstr_t;

// convenience macro to declare a vstr with a fixed size buffer on the stack
#define VSTR_FIXED(vstr, alloc) vstr_t vstr; char vstr##_buf[(alloc)]; vstr_init_fixed_buf(&vstr, (alloc), vstr##_buf);

void vstr_init(vstr_t *vstr, size_t alloc);
void vstr_init_len(vstr_t *vstr, size_t len);
void vstr_init_fixed_buf(vstr_t *vstr, size_t alloc, char *buf);
struct _mp_print_t;
void vstr_init_print(vstr_t *vstr, size_t alloc, struct _mp_print_t *print);
void vstr_clear(vstr_t *vstr);
vstr_t *vstr_new(size_t alloc);
void vstr_free(vstr_t *vstr);
static inline void vstr_reset(vstr_t *vstr) {
    vstr->len = 0;
}
static inline char *vstr_str(vstr_t *vstr) {
    return vstr->buf;
}
static inline size_t vstr_len(vstr_t *vstr) {
    return vstr->len;
}
void vstr_hint_size(vstr_t *vstr, size_t size);
char *vstr_extend(vstr_t *vstr, size_t size);
char *vstr_add_len(vstr_t *vstr, size_t len);
char *vstr_null_terminated_str(vstr_t *vstr);
void vstr_add_byte(vstr_t *vstr, byte v);
void vstr_add_char(vstr_t *vstr, unichar chr);
void vstr_add_str(vstr_t *vstr, const char *str);
void vstr_add_strn(vstr_t *vstr, const char *str, size_t len);
void vstr_ins_byte(vstr_t *vstr, size_t byte_pos, byte b);
void vstr_ins_char(vstr_t *vstr, size_t char_pos, unichar chr);
void vstr_cut_head_bytes(vstr_t *vstr, size_t bytes_to_cut);
void vstr_cut_tail_bytes(vstr_t *vstr, size_t bytes_to_cut);
void vstr_cut_out_bytes(vstr_t *vstr, size_t byte_pos, size_t bytes_to_cut);
void vstr_printf(vstr_t *vstr, const char *fmt, ...);

/** non-dynamic size-bounded variable buffer/string *************/

#define CHECKBUF(buf, max_size) char buf[max_size + 1]; size_t buf##_len = max_size; char *buf##_p = buf;
#define CHECKBUF_RESET(buf, max_size) buf##_len = max_size; buf##_p = buf;
#define CHECKBUF_APPEND(buf, src, src_len) \
    { size_t l = MIN(src_len, buf##_len); \
      memcpy(buf##_p, src, l); \
      buf##_len -= l; \
      buf##_p += l; }
#define CHECKBUF_APPEND_0(buf) { *buf##_p = 0; }
#define CHECKBUF_LEN(buf) (buf##_p - buf)

#ifdef va_start
void vstr_vprintf(vstr_t *vstr, const char *fmt, va_list ap);
#endif
# 222 "../../py/misc.h"

// Debugging helpers
int DEBUG_printf(const char *fmt, ...);

extern mp_uint_t mp_verbose_flag;

/** float internals *************/

#if 0 /* disabled by -frewrite-includes */
#if MICROPY_PY_BUILTINS_FLOAT
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 231 "../../py/misc.h"

#if 0 /* disabled by -frewrite-includes */
#if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 233 "../../py/misc.h"
#define MP_FLOAT_EXP_BITS (11)
#define MP_FLOAT_FRAC_BITS (52)
typedef uint64_t mp_float_uint_t;
#if 0 /* disabled by -frewrite-includes */
#if 0
#elif MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT
#endif
#endif /* disabled by -frewrite-includes */
#elif 0 /* evaluated by -frewrite-includes */
# 237 "../../py/misc.h"
#define MP_FLOAT_EXP_BITS (8)
#define MP_FLOAT_FRAC_BITS (23)
typedef uint32_t mp_float_uint_t;
#endif
# 241 "../../py/misc.h"

#define MP_FLOAT_EXP_BIAS ((1 << (MP_FLOAT_EXP_BITS - 1)) - 1)

typedef union _mp_float_union_t {
    mp_float_t f;
   
#if 0 /* disabled by -frewrite-includes */
#if MP_ENDIANNESS_LITTLE
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 247 "../../py/misc.h"
    struct {
        mp_float_uint_t frc : MP_FLOAT_FRAC_BITS;
        mp_float_uint_t exp : MP_FLOAT_EXP_BITS;
        mp_float_uint_t sgn : 1;
    } p;
    #else
# 253 "../../py/misc.h"
    struct {
        mp_float_uint_t sgn : 1;
        mp_float_uint_t exp : MP_FLOAT_EXP_BITS;
        mp_float_uint_t frc : MP_FLOAT_FRAC_BITS;
    } p;
    #endif
# 259 "../../py/misc.h"
    mp_float_uint_t i;
} mp_float_union_t;

#endif // MICROPY_PY_BUILTINS_FLOAT
# 263 "../../py/misc.h"

/** ROM string compression *************/

#if 0 /* disabled by -frewrite-includes */
#if MICROPY_ROM_TEXT_COMPRESSION
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 267 "../../py/misc.h"

#if 0 /* disabled by -frewrite-includes */
#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_NONE
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 269 "../../py/misc.h"
#error "MICROPY_ERROR_REPORTING_NONE requires MICROPY_ROM_TEXT_COMPRESSION disabled"
#endif
# 271 "../../py/misc.h"

#ifdef NO_QSTR

// Compression enabled but doing QSTR extraction.
// So leave MP_COMPRESSED_ROM_TEXT in place for makeqstrdefs.py / makecompresseddata.py to find them.

#else
# 278 "../../py/misc.h"

// Compression enabled and doing a regular build.
// Map MP_COMPRESSED_ROM_TEXT to the compressed strings.

// Force usage of the MP_ERROR_TEXT macro by requiring an opaque type.
typedef struct {
    #ifdef __clang__
    // Fix "error: empty struct has size 0 in C, size 1 in C++".
    char dummy;
    #endif
# 288 "../../py/misc.h"
} *mp_rom_error_text_t;

#if 0 /* expanded by -frewrite-includes */
#include <string.h>
#endif /* expanded by -frewrite-includes */
# 290 "../../py/misc.h"
# 291 "../../py/misc.h"

inline __attribute__((always_inline)) const char *MP_COMPRESSED_ROM_TEXT(const char *msg) {
    // "genhdr/compressed.data.h" contains an invocation of the MP_MATCH_COMPRESSED macro for each compressed string.
    // The giant if(strcmp) tree is optimized by the compiler, which turns this into a direct return of the compressed data.
    #define MP_MATCH_COMPRESSED(a, b) if (strcmp(msg, a) == 0) { return b; } else

    // It also contains a single invocation of the MP_COMPRESSED_DATA macro, we don't need that here.
    #define MP_COMPRESSED_DATA(x)

    #if 0 /* expanded by -frewrite-includes */
#include "genhdr/compressed.data.h"
#endif /* expanded by -frewrite-includes */
# 300 "../../py/misc.h"
# 301 "../../py/misc.h"

#undef MP_COMPRESSED_DATA
#undef MP_MATCH_COMPRESSED

    return msg;
}

#endif
# 309 "../../py/misc.h"

#else
# 311 "../../py/misc.h"

// Compression not enabled, just make it a no-op.

typedef const char *mp_rom_error_text_t;
#define MP_COMPRESSED_ROM_TEXT(x) x

#endif // MICROPY_ROM_TEXT_COMPRESSION
# 318 "../../py/misc.h"

// Might add more types of compressed text in the future.
// For now, forward directly to MP_COMPRESSED_ROM_TEXT.
#define MP_ERROR_TEXT(x) (mp_rom_error_text_t)MP_COMPRESSED_ROM_TEXT(x)

#endif // MICROPY_INCLUDED_PY_MISC_H
# 324 "../../py/misc.h"
# 34 "../../py/mpstate.h" 2
#if 0 /* expanded by -frewrite-includes */
#include "py/nlr.h"
#endif /* expanded by -frewrite-includes */
# 34 "../../py/mpstate.h"
# 1 "../../py/nlr.h" 1
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef MICROPY_INCLUDED_PY_NLR_H
#define MICROPY_INCLUDED_PY_NLR_H

// non-local return
// exception handling, basically a stack of setjmp/longjmp buffers

#if 0 /* expanded by -frewrite-includes */
#include <limits.h>
#endif /* expanded by -frewrite-includes */
# 32 "../../py/nlr.h"
# 1 "/home/parisse/CEdev/include/limits.h" 1 3
#ifndef _LIMITS_H
#define _LIMITS_H

#define    BOOL_WIDTH      __BOOL_WIDTH__

#define    CHAR_BIT        __CHAR_BIT__
#ifndef __CHAR_UNSIGNED__
# define   CHAR_MIN     (~__SCHAR_MAX__)
# define   CHAR_MAX       __SCHAR_MAX__
#else /* __CHAR_UNSIGNED__ */
# 11 "/home/parisse/CEdev/include/limits.h" 3
# define   CHAR_MIN             0
# define   CHAR_MAX       __UCHAR_MAX__
#endif /* __CHAR_UNSIGNED__ */
# 14 "/home/parisse/CEdev/include/limits.h" 3
#define    CHAR_WIDTH      __CHAR_BIT__

#define   SCHAR_MIN     (~__SCHAR_MAX__)
#define   SCHAR_MAX       __SCHAR_MAX__
#define   SCHAR_WIDTH      __CHAR_BIT__

#define   UCHAR_MAX       __UCHAR_MAX__
#define   UCHAR_WIDTH      __CHAR_BIT__

#define    SHRT_MIN      (~__SHRT_MAX__)
#define    SHRT_MAX        __SHRT_MAX__
#define    SHRT_WIDTH      __SHRT_WIDTH__

#define   USHRT_MAX       __USHRT_MAX__
#define   USHRT_WIDTH      __SHRT_WIDTH__

#define     INT_MIN       (~__INT_MAX__)
#define     INT_MAX         __INT_MAX__
#define     INT_WIDTH       __INT_WIDTH__

#define    UINT_MAX        __UINT_MAX__
#define    UINT_WIDTH       __INT_WIDTH__

#define    LONG_MIN      (~__LONG_MAX__)
#define    LONG_MAX        __LONG_MAX__
#define    LONG_WIDTH      __LONG_WIDTH__

#define   ULONG_MAX       __ULONG_MAX__
#define   ULONG_WIDTH      __LONG_WIDTH__

#define   LLONG_MIN (~__LONG_LONG_MAX__)
#define   LLONG_MAX   __LONG_LONG_MAX__
#define   LLONG_WIDTH     __LLONG_WIDTH__

#define  ULLONG_MAX  __ULONG_LONG_MAX__
#define  ULLONG_WIDTH     __LLONG_WIDTH__

#endif /* _LIMITS_H */
# 52 "/home/parisse/CEdev/include/limits.h" 3
# 33 "../../py/nlr.h" 2
#if 0 /* expanded by -frewrite-includes */
#include <assert.h>
#endif /* expanded by -frewrite-includes */
# 33 "../../py/nlr.h"
# 34 "../../py/nlr.h"

#if 0 /* expanded by -frewrite-includes */
#include "py/mpconfig.h"
#endif /* expanded by -frewrite-includes */
# 35 "../../py/nlr.h"
# 36 "../../py/nlr.h"

#define MICROPY_NLR_NUM_REGS_X86            (6)
#define MICROPY_NLR_NUM_REGS_X64            (8)
#define MICROPY_NLR_NUM_REGS_X64_WIN        (10)
#define MICROPY_NLR_NUM_REGS_ARM_THUMB      (10)
#define MICROPY_NLR_NUM_REGS_ARM_THUMB_FP   (10 + 6)
#define MICROPY_NLR_NUM_REGS_AARCH64        (13)
#define MICROPY_NLR_NUM_REGS_XTENSA         (10)
#define MICROPY_NLR_NUM_REGS_XTENSAWIN      (17)

// *FORMAT-OFF*

// If MICROPY_NLR_SETJMP is not enabled then auto-detect the machine arch
#if 0 /* disabled by -frewrite-includes */
#if !MICROPY_NLR_SETJMP
#endif
#endif /* disabled by -frewrite-includes */
#if 1 /* evaluated by -frewrite-includes */
# 50 "../../py/nlr.h"
// A lot of nlr-related things need different treatment on Windows
#if 0 /* disabled by -frewrite-includes */
#if defined(_WIN32) || defined(__CYGWIN__)
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 52 "../../py/nlr.h"
#define MICROPY_NLR_OS_WINDOWS 1
#else
# 54 "../../py/nlr.h"
#define MICROPY_NLR_OS_WINDOWS 0
#endif
# 56 "../../py/nlr.h"
#if 0 /* disabled by -frewrite-includes */
#if defined(__i386__)
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 57 "../../py/nlr.h"
    #define MICROPY_NLR_X86 (1)
    #define MICROPY_NLR_NUM_REGS (MICROPY_NLR_NUM_REGS_X86)
#if 0 /* disabled by -frewrite-includes */
#if 0
#elif defined(__x86_64__)
#endif
#endif /* disabled by -frewrite-includes */
#elif 0 /* evaluated by -frewrite-includes */
# 60 "../../py/nlr.h"
    #define MICROPY_NLR_X64 (1)
   
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_NLR_OS_WINDOWS
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 62 "../../py/nlr.h"
        #define MICROPY_NLR_NUM_REGS (MICROPY_NLR_NUM_REGS_X64_WIN)
    #else
# 64 "../../py/nlr.h"
        #define MICROPY_NLR_NUM_REGS (MICROPY_NLR_NUM_REGS_X64)
    #endif
# 66 "../../py/nlr.h"
#if 0 /* disabled by -frewrite-includes */
#if 0
#elif defined(__thumb2__) || defined(__thumb__) || defined(__arm__)
#endif
#endif /* disabled by -frewrite-includes */
#elif 0 /* evaluated by -frewrite-includes */
# 67 "../../py/nlr.h"
    #define MICROPY_NLR_THUMB (1)
   
#if 0 /* disabled by -frewrite-includes */
#if defined(__SOFTFP__)
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 69 "../../py/nlr.h"
        #define MICROPY_NLR_NUM_REGS (MICROPY_NLR_NUM_REGS_ARM_THUMB)
    #else
# 71 "../../py/nlr.h"
        // With hardware FP registers s16-s31 are callee save so in principle
        // should be saved and restored by the NLR code.  gcc only uses s16-s21
        // so only save/restore those as an optimisation.
        #define MICROPY_NLR_NUM_REGS (MICROPY_NLR_NUM_REGS_ARM_THUMB_FP)
    #endif
# 76 "../../py/nlr.h"
#if 0 /* disabled by -frewrite-includes */
#if 0
#elif defined(__aarch64__)
#endif
#endif /* disabled by -frewrite-includes */
#elif 0 /* evaluated by -frewrite-includes */
# 77 "../../py/nlr.h"
    #define MICROPY_NLR_AARCH64 (1)
    #define MICROPY_NLR_NUM_REGS (MICROPY_NLR_NUM_REGS_AARCH64)
#if 0 /* disabled by -frewrite-includes */
#if 0
#elif defined(__xtensa__)
#endif
#endif /* disabled by -frewrite-includes */
#elif 0 /* evaluated by -frewrite-includes */
# 80 "../../py/nlr.h"
    #define MICROPY_NLR_XTENSA (1)
    #define MICROPY_NLR_NUM_REGS (MICROPY_NLR_NUM_REGS_XTENSA)
#if 0 /* disabled by -frewrite-includes */
#if 0
#elif defined(__powerpc__)
#endif
#endif /* disabled by -frewrite-includes */
#elif 0 /* evaluated by -frewrite-includes */
# 83 "../../py/nlr.h"
    #define MICROPY_NLR_POWERPC (1)
    // this could be less but using 128 for safety
    #define MICROPY_NLR_NUM_REGS (128)
#else
# 87 "../../py/nlr.h"
    #define MICROPY_NLR_SETJMP (1)
    //#warning "No native NLR support for this arch, using setjmp implementation"
#endif
# 90 "../../py/nlr.h"
#endif
# 91 "../../py/nlr.h"

// *FORMAT-ON*

#if 0 /* disabled by -frewrite-includes */
#if MICROPY_NLR_SETJMP
#endif
#endif /* disabled by -frewrite-includes */
#if 1 /* evaluated by -frewrite-includes */
# 95 "../../py/nlr.h"
#if 0 /* expanded by -frewrite-includes */
#include <setjmp.h>
#endif /* expanded by -frewrite-includes */
# 95 "../../py/nlr.h"
# 1 "/home/parisse/CEdev/include/setjmp.h" 1 3
#ifndef _SETJMP_H
#define _SETJMP_H

#if 0 /* expanded by -frewrite-includes */
#include <cdefs.h>
#endif /* expanded by -frewrite-includes */
# 4 "/home/parisse/CEdev/include/setjmp.h" 3
# 5 "/home/parisse/CEdev/include/setjmp.h" 3

__BEGIN_DECLS

typedef unsigned char jmp_buf[12];

int setjmp(jmp_buf env) __attribute__((returns_twice));
void longjmp(jmp_buf env, int val) __attribute__((noreturn));

__END_DECLS

#endif
# 16 "/home/parisse/CEdev/include/setjmp.h" 3
# 96 "../../py/nlr.h" 2
#endif
# 97 "../../py/nlr.h"

typedef struct _nlr_buf_t nlr_buf_t;
struct _nlr_buf_t {
    // the entries here must all be machine word size
    nlr_buf_t *prev;
    void *ret_val; // always a concrete object (an exception instance)

   
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_NLR_SETJMP
#endif
#endif /* disabled by -frewrite-includes */
#if 1 /* evaluated by -frewrite-includes */
# 105 "../../py/nlr.h"
    jmp_buf jmpbuf;
    #else
# 107 "../../py/nlr.h"
    void *regs[MICROPY_NLR_NUM_REGS];
    #endif
# 109 "../../py/nlr.h"

   
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_ENABLE_PYSTACK
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 111 "../../py/nlr.h"
    void *pystack;
    #endif
# 113 "../../py/nlr.h"
};

// Helper macros to save/restore the pystack state
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_ENABLE_PYSTACK
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 117 "../../py/nlr.h"
#define MP_NLR_SAVE_PYSTACK(nlr_buf) (nlr_buf)->pystack = MP_STATE_THREAD(pystack_cur)
#define MP_NLR_RESTORE_PYSTACK(nlr_buf) MP_STATE_THREAD(pystack_cur) = (nlr_buf)->pystack
#else
# 120 "../../py/nlr.h"
#define MP_NLR_SAVE_PYSTACK(nlr_buf) (void)nlr_buf
#define MP_NLR_RESTORE_PYSTACK(nlr_buf) (void)nlr_buf
#endif
# 123 "../../py/nlr.h"

// Helper macro to use at the start of a specific nlr_jump implementation
#define MP_NLR_JUMP_HEAD(val, top) \
    nlr_buf_t **_top_ptr = &MP_STATE_THREAD(nlr_top); \
    nlr_buf_t *top = *_top_ptr; \
    if (top == NULL) { \
        nlr_jump_fail(val); \
    } \
    top->ret_val = val; \
    MP_NLR_RESTORE_PYSTACK(top); \
    *_top_ptr = top->prev; \

#if 0 /* disabled by -frewrite-includes */
#if MICROPY_NLR_SETJMP
#endif
#endif /* disabled by -frewrite-includes */
#if 1 /* evaluated by -frewrite-includes */
# 136 "../../py/nlr.h"
// nlr_push() must be defined as a macro, because "The stack context will be
// invalidated if the function which called setjmp() returns."
// For this case it is safe to call nlr_push_tail() first.
#define nlr_push(buf) (nlr_push_tail(buf), setjmp((buf)->jmpbuf))
#else
# 141 "../../py/nlr.h"
unsigned int nlr_push(nlr_buf_t *);
#endif
# 143 "../../py/nlr.h"

unsigned int nlr_push_tail(nlr_buf_t *top);
void nlr_pop(void);
NORETURN void nlr_jump(void *val);

// This must be implemented by a port.  It's called by nlr_jump
// if no nlr buf has been pushed.  It must not return, but rather
// should bail out with a fatal error.
NORETURN void nlr_jump_fail(void *val);

// use nlr_raise instead of nlr_jump so that debugging is easier
#ifndef MICROPY_DEBUG_NLR
#define nlr_raise(val) nlr_jump(MP_OBJ_TO_PTR(val))
#else
# 157 "../../py/nlr.h"
#if 0 /* expanded by -frewrite-includes */
#include "mpstate.h"
#endif /* expanded by -frewrite-includes */
# 157 "../../py/nlr.h"
# 158 "../../py/nlr.h"
#define nlr_raise(val) \
    do { \
        /*printf("nlr_raise: nlr_top=%p\n", MP_STATE_THREAD(nlr_top)); \
        fflush(stdout);*/ \
        void *_val = MP_OBJ_TO_PTR(val); \
        assert(_val != NULL); \
        assert(mp_obj_is_exception_instance(val)); \
        nlr_jump(_val); \
    } while (0)

#if 0 /* disabled by -frewrite-includes */
#if !MICROPY_NLR_SETJMP
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 169 "../../py/nlr.h"
#define nlr_push(val) \
    assert(MP_STATE_THREAD(nlr_top) != val),nlr_push(val)

/*
#define nlr_push(val) \
    printf("nlr_push: before: nlr_top=%p, val=%p\n", MP_STATE_THREAD(nlr_top), val),assert(MP_STATE_THREAD(nlr_top) != val),nlr_push(val)
*/
#endif
# 177 "../../py/nlr.h"

#endif
# 179 "../../py/nlr.h"

#endif // MICROPY_INCLUDED_PY_NLR_H
# 181 "../../py/nlr.h"
# 35 "../../py/mpstate.h" 2
#if 0 /* expanded by -frewrite-includes */
#include "py/obj.h"
#endif /* expanded by -frewrite-includes */
# 35 "../../py/mpstate.h"
# 1 "../../py/obj.h" 1
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef MICROPY_INCLUDED_PY_OBJ_H
#define MICROPY_INCLUDED_PY_OBJ_H

#if 0 /* expanded by -frewrite-includes */
#include <assert.h>
#endif /* expanded by -frewrite-includes */
# 29 "../../py/obj.h"
# 30 "../../py/obj.h"

#if 0 /* expanded by -frewrite-includes */
#include "py/mpconfig.h"
#endif /* expanded by -frewrite-includes */
# 31 "../../py/obj.h"
# 32 "../../py/obj.h"
#if 0 /* expanded by -frewrite-includes */
#include "py/misc.h"
#endif /* expanded by -frewrite-includes */
# 32 "../../py/obj.h"
# 33 "../../py/obj.h"
#if 0 /* expanded by -frewrite-includes */
#include "py/qstr.h"
#endif /* expanded by -frewrite-includes */
# 33 "../../py/obj.h"
# 1 "../../py/qstr.h" 1
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef MICROPY_INCLUDED_PY_QSTR_H
#define MICROPY_INCLUDED_PY_QSTR_H

#if 0 /* expanded by -frewrite-includes */
#include "py/mpconfig.h"
#endif /* expanded by -frewrite-includes */
# 29 "../../py/qstr.h"
# 30 "../../py/qstr.h"
#if 0 /* expanded by -frewrite-includes */
#include "py/misc.h"
#endif /* expanded by -frewrite-includes */
# 30 "../../py/qstr.h"
# 31 "../../py/qstr.h"

// See qstrdefs.h for a list of qstr's that are available as constants.
// Reference them as MP_QSTR_xxxx.
//
// Note: it would be possible to define MP_QSTR_xxx as qstr_from_str("xxx")
// for qstrs that are referenced this way, but you don't want to have them in ROM.

// first entry in enum will be MP_QSTRnull=0, which indicates invalid/no qstr
enum {
    #ifndef NO_QSTR
#define QDEF(id, str) id,
    #if 0 /* expanded by -frewrite-includes */
#include "genhdr/qstrdefs.generated.h"
#endif /* expanded by -frewrite-includes */
# 42 "../../py/qstr.h"
# 1 "build/genhdr/qstrdefs.generated.h" 1
// This file was automatically generated by makeqstrdata.py

QDEF(MP_QSTRnull, (const byte*)"\x00\x00" "")
QDEF(MP_QSTR_, (const byte*)"\x05\x00" "")
QDEF(MP_QSTR___dir__, (const byte*)"\x7a\x07" "__dir__")
QDEF(MP_QSTR__0x0a_, (const byte*)"\xaf\x01" "\x0a")
QDEF(MP_QSTR__space_, (const byte*)"\x85\x01" " ")
QDEF(MP_QSTR__star_, (const byte*)"\x8f\x01" "*")
QDEF(MP_QSTR__slash_, (const byte*)"\x8a\x01" "/")
QDEF(MP_QSTR__lt_module_gt_, (const byte*)"\xbd\x08" "<module>")
QDEF(MP_QSTR__, (const byte*)"\xfa\x01" "_")
QDEF(MP_QSTR___call__, (const byte*)"\xa7\x08" "__call__")
QDEF(MP_QSTR___class__, (const byte*)"\x2b\x09" "__class__")
QDEF(MP_QSTR___delitem__, (const byte*)"\xfd\x0b" "__delitem__")
QDEF(MP_QSTR___enter__, (const byte*)"\x6d\x09" "__enter__")
QDEF(MP_QSTR___exit__, (const byte*)"\x45\x08" "__exit__")
QDEF(MP_QSTR___getattr__, (const byte*)"\x40\x0b" "__getattr__")
QDEF(MP_QSTR___getitem__, (const byte*)"\x26\x0b" "__getitem__")
QDEF(MP_QSTR___hash__, (const byte*)"\xf7\x08" "__hash__")
QDEF(MP_QSTR___init__, (const byte*)"\x5f\x08" "__init__")
QDEF(MP_QSTR___int__, (const byte*)"\x16\x07" "__int__")
QDEF(MP_QSTR___iter__, (const byte*)"\xcf\x08" "__iter__")
QDEF(MP_QSTR___len__, (const byte*)"\xe2\x07" "__len__")
QDEF(MP_QSTR___main__, (const byte*)"\x8e\x08" "__main__")
QDEF(MP_QSTR___module__, (const byte*)"\xff\x0a" "__module__")
QDEF(MP_QSTR___name__, (const byte*)"\xe2\x08" "__name__")
QDEF(MP_QSTR___new__, (const byte*)"\x79\x07" "__new__")
QDEF(MP_QSTR___next__, (const byte*)"\x02\x08" "__next__")
QDEF(MP_QSTR___qualname__, (const byte*)"\x6b\x0c" "__qualname__")
QDEF(MP_QSTR___repr__, (const byte*)"\x10\x08" "__repr__")
QDEF(MP_QSTR___setitem__, (const byte*)"\x32\x0b" "__setitem__")
QDEF(MP_QSTR___str__, (const byte*)"\xd0\x07" "__str__")
QDEF(MP_QSTR_ArithmeticError, (const byte*)"\x2d\x0f" "ArithmeticError")
QDEF(MP_QSTR_AssertionError, (const byte*)"\x97\x0e" "AssertionError")
QDEF(MP_QSTR_AttributeError, (const byte*)"\x21\x0e" "AttributeError")
QDEF(MP_QSTR_BaseException, (const byte*)"\x07\x0d" "BaseException")
QDEF(MP_QSTR_EOFError, (const byte*)"\x91\x08" "EOFError")
QDEF(MP_QSTR_Ellipsis, (const byte*)"\xf0\x08" "Ellipsis")
QDEF(MP_QSTR_Exception, (const byte*)"\xf2\x09" "Exception")
QDEF(MP_QSTR_GeneratorExit, (const byte*)"\x16\x0d" "GeneratorExit")
QDEF(MP_QSTR_ImportError, (const byte*)"\x20\x0b" "ImportError")
QDEF(MP_QSTR_IndentationError, (const byte*)"\x5c\x10" "IndentationError")
QDEF(MP_QSTR_IndexError, (const byte*)"\x83\x0a" "IndexError")
QDEF(MP_QSTR_KeyError, (const byte*)"\xea\x08" "KeyError")
QDEF(MP_QSTR_KeyboardInterrupt, (const byte*)"\xaf\x11" "KeyboardInterrupt")
QDEF(MP_QSTR_LookupError, (const byte*)"\xff\x0b" "LookupError")
QDEF(MP_QSTR_MemoryError, (const byte*)"\xdc\x0b" "MemoryError")
QDEF(MP_QSTR_NameError, (const byte*)"\xba\x09" "NameError")
QDEF(MP_QSTR_NoneType, (const byte*)"\x17\x08" "NoneType")
QDEF(MP_QSTR_NotImplementedError, (const byte*)"\xc6\x13" "NotImplementedError")
QDEF(MP_QSTR_OSError, (const byte*)"\xa1\x07" "OSError")
QDEF(MP_QSTR_OverflowError, (const byte*)"\x81\x0d" "OverflowError")
QDEF(MP_QSTR_RuntimeError, (const byte*)"\x61\x0c" "RuntimeError")
QDEF(MP_QSTR_StopIteration, (const byte*)"\xea\x0d" "StopIteration")
QDEF(MP_QSTR_SyntaxError, (const byte*)"\x94\x0b" "SyntaxError")
QDEF(MP_QSTR_SystemExit, (const byte*)"\x20\x0a" "SystemExit")
QDEF(MP_QSTR_TypeError, (const byte*)"\x25\x09" "TypeError")
QDEF(MP_QSTR_ValueError, (const byte*)"\x96\x0a" "ValueError")
QDEF(MP_QSTR_ZeroDivisionError, (const byte*)"\xb6\x11" "ZeroDivisionError")
QDEF(MP_QSTR_abs, (const byte*)"\x95\x03" "abs")
QDEF(MP_QSTR_all, (const byte*)"\x44\x03" "all")
QDEF(MP_QSTR_any, (const byte*)"\x13\x03" "any")
QDEF(MP_QSTR_append, (const byte*)"\x6b\x06" "append")
QDEF(MP_QSTR_args, (const byte*)"\xc2\x04" "args")
QDEF(MP_QSTR_bool, (const byte*)"\xeb\x04" "bool")
QDEF(MP_QSTR_builtins, (const byte*)"\xf7\x08" "builtins")
QDEF(MP_QSTR_bytearray, (const byte*)"\x76\x09" "bytearray")
QDEF(MP_QSTR_bytecode, (const byte*)"\x22\x08" "bytecode")
QDEF(MP_QSTR_bytes, (const byte*)"\x5c\x05" "bytes")
QDEF(MP_QSTR_callable, (const byte*)"\x0d\x08" "callable")
QDEF(MP_QSTR_chr, (const byte*)"\xdc\x03" "chr")
QDEF(MP_QSTR_classmethod, (const byte*)"\xb4\x0b" "classmethod")
QDEF(MP_QSTR_clear, (const byte*)"\x7c\x05" "clear")
QDEF(MP_QSTR_close, (const byte*)"\x33\x05" "close")
QDEF(MP_QSTR_const, (const byte*)"\xc0\x05" "const")
QDEF(MP_QSTR_copy, (const byte*)"\xe0\x04" "copy")
QDEF(MP_QSTR_count, (const byte*)"\xa6\x05" "count")
QDEF(MP_QSTR_dict, (const byte*)"\x3f\x04" "dict")
QDEF(MP_QSTR_dir, (const byte*)"\xfa\x03" "dir")
QDEF(MP_QSTR_divmod, (const byte*)"\xb8\x06" "divmod")
QDEF(MP_QSTR_end, (const byte*)"\x0a\x03" "end")
QDEF(MP_QSTR_endswith, (const byte*)"\x1b\x08" "endswith")
QDEF(MP_QSTR_eval, (const byte*)"\x9b\x04" "eval")
QDEF(MP_QSTR_exec, (const byte*)"\x1e\x04" "exec")
QDEF(MP_QSTR_extend, (const byte*)"\x63\x06" "extend")
QDEF(MP_QSTR_find, (const byte*)"\x01\x04" "find")
QDEF(MP_QSTR_format, (const byte*)"\x26\x06" "format")
QDEF(MP_QSTR_from_bytes, (const byte*)"\x35\x0a" "from_bytes")
QDEF(MP_QSTR_get, (const byte*)"\x33\x03" "get")
QDEF(MP_QSTR_getattr, (const byte*)"\xc0\x07" "getattr")
QDEF(MP_QSTR_globals, (const byte*)"\x9d\x07" "globals")
QDEF(MP_QSTR_hasattr, (const byte*)"\x8c\x07" "hasattr")
QDEF(MP_QSTR_hash, (const byte*)"\xb7\x04" "hash")
QDEF(MP_QSTR_id, (const byte*)"\x28\x02" "id")
QDEF(MP_QSTR_index, (const byte*)"\x7b\x05" "index")
QDEF(MP_QSTR_insert, (const byte*)"\x12\x06" "insert")
QDEF(MP_QSTR_int, (const byte*)"\x16\x03" "int")
QDEF(MP_QSTR_isalpha, (const byte*)"\xeb\x07" "isalpha")
QDEF(MP_QSTR_isdigit, (const byte*)"\xa8\x07" "isdigit")
QDEF(MP_QSTR_isinstance, (const byte*)"\xb6\x0a" "isinstance")
QDEF(MP_QSTR_islower, (const byte*)"\xfc\x07" "islower")
QDEF(MP_QSTR_isspace, (const byte*)"\x5b\x07" "isspace")
QDEF(MP_QSTR_issubclass, (const byte*)"\xb5\x0a" "issubclass")
QDEF(MP_QSTR_isupper, (const byte*)"\xdd\x07" "isupper")
QDEF(MP_QSTR_items, (const byte*)"\xe3\x05" "items")
QDEF(MP_QSTR_iter, (const byte*)"\x8f\x04" "iter")
QDEF(MP_QSTR_join, (const byte*)"\xa7\x04" "join")
QDEF(MP_QSTR_key, (const byte*)"\x32\x03" "key")
QDEF(MP_QSTR_keys, (const byte*)"\x01\x04" "keys")
QDEF(MP_QSTR_len, (const byte*)"\x62\x03" "len")
QDEF(MP_QSTR_list, (const byte*)"\x27\x04" "list")
QDEF(MP_QSTR_little, (const byte*)"\x89\x06" "little")
QDEF(MP_QSTR_locals, (const byte*)"\x3b\x06" "locals")
QDEF(MP_QSTR_lower, (const byte*)"\xc6\x05" "lower")
QDEF(MP_QSTR_lstrip, (const byte*)"\xe5\x06" "lstrip")
QDEF(MP_QSTR_main, (const byte*)"\xce\x04" "main")
QDEF(MP_QSTR_map, (const byte*)"\xb9\x03" "map")
QDEF(MP_QSTR_micropython, (const byte*)"\x0b\x0b" "micropython")
QDEF(MP_QSTR_next, (const byte*)"\x42\x04" "next")
QDEF(MP_QSTR_object, (const byte*)"\x90\x06" "object")
QDEF(MP_QSTR_open, (const byte*)"\xd1\x04" "open")
QDEF(MP_QSTR_ord, (const byte*)"\x1c\x03" "ord")
QDEF(MP_QSTR_pop, (const byte*)"\x2a\x03" "pop")
QDEF(MP_QSTR_popitem, (const byte*)"\xbf\x07" "popitem")
QDEF(MP_QSTR_pow, (const byte*)"\x2d\x03" "pow")
QDEF(MP_QSTR_print, (const byte*)"\x54\x05" "print")
QDEF(MP_QSTR_range, (const byte*)"\x1a\x05" "range")
QDEF(MP_QSTR_read, (const byte*)"\xb7\x04" "read")
QDEF(MP_QSTR_readinto, (const byte*)"\x4b\x08" "readinto")
QDEF(MP_QSTR_readline, (const byte*)"\xf9\x08" "readline")
QDEF(MP_QSTR_remove, (const byte*)"\x63\x06" "remove")
QDEF(MP_QSTR_replace, (const byte*)"\x49\x07" "replace")
QDEF(MP_QSTR_repr, (const byte*)"\xd0\x04" "repr")
QDEF(MP_QSTR_reverse, (const byte*)"\x25\x07" "reverse")
QDEF(MP_QSTR_rfind, (const byte*)"\xd2\x05" "rfind")
QDEF(MP_QSTR_rindex, (const byte*)"\xe9\x06" "rindex")
QDEF(MP_QSTR_round, (const byte*)"\xe7\x05" "round")
QDEF(MP_QSTR_rsplit, (const byte*)"\xa5\x06" "rsplit")
QDEF(MP_QSTR_rstrip, (const byte*)"\x3b\x06" "rstrip")
QDEF(MP_QSTR_self, (const byte*)"\x79\x04" "self")
QDEF(MP_QSTR_send, (const byte*)"\xb9\x04" "send")
QDEF(MP_QSTR_sep, (const byte*)"\x23\x03" "sep")
QDEF(MP_QSTR_set, (const byte*)"\x27\x03" "set")
QDEF(MP_QSTR_setattr, (const byte*)"\xd4\x07" "setattr")
QDEF(MP_QSTR_setdefault, (const byte*)"\x6c\x0a" "setdefault")
QDEF(MP_QSTR_sort, (const byte*)"\xbf\x04" "sort")
QDEF(MP_QSTR_sorted, (const byte*)"\x5e\x06" "sorted")
QDEF(MP_QSTR_split, (const byte*)"\xb7\x05" "split")
QDEF(MP_QSTR_start, (const byte*)"\x85\x05" "start")
QDEF(MP_QSTR_startswith, (const byte*)"\x74\x0a" "startswith")
QDEF(MP_QSTR_staticmethod, (const byte*)"\x62\x0c" "staticmethod")
QDEF(MP_QSTR_step, (const byte*)"\x57\x04" "step")
QDEF(MP_QSTR_stop, (const byte*)"\x9d\x04" "stop")
QDEF(MP_QSTR_str, (const byte*)"\x50\x03" "str")
QDEF(MP_QSTR_strip, (const byte*)"\x29\x05" "strip")
QDEF(MP_QSTR_sum, (const byte*)"\x2e\x03" "sum")
QDEF(MP_QSTR_super, (const byte*)"\xc4\x05" "super")
QDEF(MP_QSTR_throw, (const byte*)"\xb3\x05" "throw")
QDEF(MP_QSTR_to_bytes, (const byte*)"\xd8\x08" "to_bytes")
QDEF(MP_QSTR_tuple, (const byte*)"\xfd\x05" "tuple")
QDEF(MP_QSTR_type, (const byte*)"\x9d\x04" "type")
QDEF(MP_QSTR_update, (const byte*)"\xb4\x06" "update")
QDEF(MP_QSTR_upper, (const byte*)"\x27\x05" "upper")
QDEF(MP_QSTR_utf_hyphen_8, (const byte*)"\xb7\x05" "utf-8")
QDEF(MP_QSTR_value, (const byte*)"\x4e\x05" "value")
QDEF(MP_QSTR_values, (const byte*)"\x7d\x06" "values")
QDEF(MP_QSTR_write, (const byte*)"\x98\x05" "write")
QDEF(MP_QSTR_zip, (const byte*)"\xe6\x03" "zip")
QDEF(MP_QSTR___add__, (const byte*)"\xc4\x07" "__add__")
QDEF(MP_QSTR___bool__, (const byte*)"\x2b\x08" "__bool__")
QDEF(MP_QSTR___build_class__, (const byte*)"\x42\x0f" "__build_class__")
QDEF(MP_QSTR___contains__, (const byte*)"\xc6\x0c" "__contains__")
QDEF(MP_QSTR___eq__, (const byte*)"\x71\x06" "__eq__")
QDEF(MP_QSTR___ge__, (const byte*)"\xa7\x06" "__ge__")
QDEF(MP_QSTR___gt__, (const byte*)"\xb6\x06" "__gt__")
QDEF(MP_QSTR___iadd__, (const byte*)"\x6d\x08" "__iadd__")
QDEF(MP_QSTR___import__, (const byte*)"\x38\x0a" "__import__")
QDEF(MP_QSTR___isub__, (const byte*)"\x08\x08" "__isub__")
QDEF(MP_QSTR___le__, (const byte*)"\xcc\x06" "__le__")
QDEF(MP_QSTR___lt__, (const byte*)"\x5d\x06" "__lt__")
QDEF(MP_QSTR___ne__, (const byte*)"\x0e\x06" "__ne__")
QDEF(MP_QSTR___path__, (const byte*)"\xc8\x08" "__path__")
QDEF(MP_QSTR___repl_print__, (const byte*)"\x01\x0e" "__repl_print__")
QDEF(MP_QSTR___sub__, (const byte*)"\x21\x07" "__sub__")
QDEF(MP_QSTR___traceback__, (const byte*)"\x4f\x0d" "__traceback__")
QDEF(MP_QSTR__brace_open__colon__hash_o_brace_close_, (const byte*)"\xf5\x05" "{:#o}")
QDEF(MP_QSTR__brace_open__colon__hash_x_brace_close_, (const byte*)"\x02\x05" "{:#x}")
QDEF(MP_QSTR__brace_open__colon__hash_b_brace_close_, (const byte*)"\x58\x05" "{:#b}")
QDEF(MP_QSTR_maximum_space_recursion_space_depth_space_exceeded, (const byte*)"\x73\x20" "maximum recursion depth exceeded")
QDEF(MP_QSTR__lt_lambda_gt_, (const byte*)"\x80\x08" "<lambda>")
QDEF(MP_QSTR__lt_listcomp_gt_, (const byte*)"\xd4\x0a" "<listcomp>")
QDEF(MP_QSTR__lt_dictcomp_gt_, (const byte*)"\xcc\x0a" "<dictcomp>")
QDEF(MP_QSTR__lt_setcomp_gt_, (const byte*)"\x54\x09" "<setcomp>")
QDEF(MP_QSTR__lt_genexpr_gt_, (const byte*)"\x34\x09" "<genexpr>")
QDEF(MP_QSTR__lt_string_gt_, (const byte*)"\x52\x08" "<string>")
QDEF(MP_QSTR__lt_stdin_gt_, (const byte*)"\xe3\x07" "<stdin>")
QDEF(MP_QSTR_bin, (const byte*)"\xe0\x03" "bin")
QDEF(MP_QSTR_bound_method, (const byte*)"\x97\x0c" "bound_method")
QDEF(MP_QSTR_closure, (const byte*)"\x74\x07" "closure")
QDEF(MP_QSTR_dict_view, (const byte*)"\x2d\x09" "dict_view")
QDEF(MP_QSTR_errno, (const byte*)"\xc1\x05" "errno")
QDEF(MP_QSTR_function, (const byte*)"\x27\x08" "function")
QDEF(MP_QSTR_generator, (const byte*)"\x96\x09" "generator")
QDEF(MP_QSTR_heap_lock, (const byte*)"\xad\x09" "heap_lock")
QDEF(MP_QSTR_heap_unlock, (const byte*)"\x56\x0b" "heap_unlock")
QDEF(MP_QSTR_hex, (const byte*)"\x70\x03" "hex")
QDEF(MP_QSTR_iterator, (const byte*)"\x47\x08" "iterator")
QDEF(MP_QSTR_module, (const byte*)"\xbf\x06" "module")
QDEF(MP_QSTR_oct, (const byte*)"\xfd\x03" "oct")
QDEF(MP_QSTR_opt_level, (const byte*)"\x87\x09" "opt_level")
QDEF(MP_QSTR_pend_throw, (const byte*)"\xf3\x0a" "pend_throw")
# 43 "../../py/qstr.h" 2
#undef QDEF
    #endif
# 45 "../../py/qstr.h"
    MP_QSTRnumber_of, // no underscore so it can't clash with any of the above
};

typedef size_t qstr;

typedef struct _qstr_pool_t {
    struct _qstr_pool_t *prev;
    size_t total_prev_len;
    size_t alloc;
    size_t len;
    const byte *qstrs[];
} qstr_pool_t;

#define QSTR_TOTAL() (MP_STATE_VM(last_pool)->total_prev_len + MP_STATE_VM(last_pool)->len)

void qstr_init(void);

mp_uint_t qstr_compute_hash(const byte *data, size_t len);
qstr qstr_find_strn(const char *str, size_t str_len); // returns MP_QSTRnull if not found

qstr qstr_from_str(const char *str);
qstr qstr_from_strn(const char *str, size_t len);

mp_uint_t qstr_hash(qstr q);
const char *qstr_str(qstr q);
size_t qstr_len(qstr q);
const byte *qstr_data(qstr q, size_t *len);

void qstr_pool_info(size_t *n_pool, size_t *n_qstr, size_t *n_str_data_bytes, size_t *n_total_bytes);
void qstr_dump_data(void);

#if 0 /* disabled by -frewrite-includes */
#if MICROPY_ROM_TEXT_COMPRESSION
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 77 "../../py/qstr.h"
void mp_decompress_rom_string(byte *dst, mp_rom_error_text_t src);
#define MP_IS_COMPRESSED_ROM_STRING(s) (*(byte *)(s) == 0xff)
#endif
# 80 "../../py/qstr.h"

#endif // MICROPY_INCLUDED_PY_QSTR_H
# 82 "../../py/qstr.h"
# 34 "../../py/obj.h" 2
#if 0 /* expanded by -frewrite-includes */
#include "py/mpprint.h"
#endif /* expanded by -frewrite-includes */
# 34 "../../py/obj.h"
# 1 "../../py/mpprint.h" 1
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef MICROPY_INCLUDED_PY_MPPRINT_H
#define MICROPY_INCLUDED_PY_MPPRINT_H

#if 0 /* expanded by -frewrite-includes */
#include "py/mpconfig.h"
#endif /* expanded by -frewrite-includes */
# 29 "../../py/mpprint.h"
# 30 "../../py/mpprint.h"

#define PF_FLAG_LEFT_ADJUST       (0x001)
#define PF_FLAG_SHOW_SIGN         (0x002)
#define PF_FLAG_SPACE_SIGN        (0x004)
#define PF_FLAG_NO_TRAILZ         (0x008)
#define PF_FLAG_SHOW_PREFIX       (0x010)
#define PF_FLAG_SHOW_COMMA        (0x020)
#define PF_FLAG_PAD_AFTER_SIGN    (0x040)
#define PF_FLAG_CENTER_ADJUST     (0x080)
#define PF_FLAG_ADD_PERCENT       (0x100)
#define PF_FLAG_SHOW_OCTAL_LETTER (0x200)

#if 0 /* disabled by -frewrite-includes */
#if MICROPY_PY_IO && MICROPY_PY_SYS_STDFILES
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 43 "../../py/mpprint.h"
#define MP_PYTHON_PRINTER &mp_sys_stdout_print
#else
# 45 "../../py/mpprint.h"
#define MP_PYTHON_PRINTER &mp_plat_print
#endif
# 47 "../../py/mpprint.h"

typedef void (*mp_print_strn_t)(void *data, const char *str, size_t len);

typedef struct _mp_print_t {
    void *data;
    mp_print_strn_t print_strn;
} mp_print_t;

typedef struct _mp_print_ext_t {
    mp_print_t base;
    const char *item_separator;
    const char *key_separator;
}mp_print_ext_t;

#define MP_PRINT_GET_EXT(print) ((mp_print_ext_t *)print)

// All (non-debug) prints go through one of the two interfaces below.
// 1) Wrapper for platform print function, which wraps MP_PLAT_PRINT_STRN.
extern const mp_print_t mp_plat_print;
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_PY_IO && MICROPY_PY_SYS_STDFILES
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 67 "../../py/mpprint.h"
// 2) Wrapper for printing to sys.stdout.
extern const mp_print_t mp_sys_stdout_print;
#endif
# 70 "../../py/mpprint.h"

int mp_print_str(const mp_print_t *print, const char *str);
int mp_print_strn(const mp_print_t *print, const char *str, size_t len, int flags, char fill, int width);
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_PY_BUILTINS_FLOAT
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 74 "../../py/mpprint.h"
int mp_print_float(const mp_print_t *print, mp_float_t f, char fmt, int flags, char fill, int width, int prec);
#endif
# 76 "../../py/mpprint.h"

int mp_printf(const mp_print_t *print, const char *fmt, ...);
#ifdef va_start
int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args);
#endif
# 81 "../../py/mpprint.h"

#endif // MICROPY_INCLUDED_PY_MPPRINT_H
# 83 "../../py/mpprint.h"
# 35 "../../py/obj.h" 2
#if 0 /* expanded by -frewrite-includes */
#include "py/runtime0.h"
#endif /* expanded by -frewrite-includes */
# 35 "../../py/obj.h"
# 1 "../../py/runtime0.h" 1
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef MICROPY_INCLUDED_PY_RUNTIME0_H
#define MICROPY_INCLUDED_PY_RUNTIME0_H

// The first four must fit in 8 bits, see emitbc.c
// The remaining must fit in 16 bits, see scope.h
#define MP_SCOPE_FLAG_ALL_SIG      (0x0f)
#define MP_SCOPE_FLAG_GENERATOR    (0x01)
#define MP_SCOPE_FLAG_VARKEYWORDS  (0x02)
#define MP_SCOPE_FLAG_VARARGS      (0x04)
#define MP_SCOPE_FLAG_DEFKWARGS    (0x08)
#define MP_SCOPE_FLAG_REFGLOBALS   (0x10) // used only if native emitter enabled
#define MP_SCOPE_FLAG_HASCONSTS    (0x20) // used only if native emitter enabled
#define MP_SCOPE_FLAG_VIPERRET_POS    (6) // 3 bits used for viper return type, to pass from compiler to native emitter
#define MP_SCOPE_FLAG_VIPERRELOC   (0x10) // used only when loading viper from .mpy
#define MP_SCOPE_FLAG_VIPERRODATA  (0x20) // used only when loading viper from .mpy
#define MP_SCOPE_FLAG_VIPERBSS     (0x40) // used only when loading viper from .mpy

// types for native (viper) function signature
#define MP_NATIVE_TYPE_OBJ  (0x00)
#define MP_NATIVE_TYPE_BOOL (0x01)
#define MP_NATIVE_TYPE_INT  (0x02)
#define MP_NATIVE_TYPE_UINT (0x03)
#define MP_NATIVE_TYPE_PTR  (0x04)
#define MP_NATIVE_TYPE_PTR8 (0x05)
#define MP_NATIVE_TYPE_PTR16 (0x06)
#define MP_NATIVE_TYPE_PTR32 (0x07)

// Bytecode and runtime boundaries for unary ops
#define MP_UNARY_OP_NUM_BYTECODE    (MP_UNARY_OP_NOT + 1)
#define MP_UNARY_OP_NUM_RUNTIME     (MP_UNARY_OP_SIZEOF + 1)

// Bytecode and runtime boundaries for binary ops
#define MP_BINARY_OP_NUM_BYTECODE   (MP_BINARY_OP_POWER + 1)
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_PY_REVERSE_SPECIAL_METHODS
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 60 "../../py/runtime0.h"
#define MP_BINARY_OP_NUM_RUNTIME    (MP_BINARY_OP_REVERSE_POWER + 1)
#else
# 62 "../../py/runtime0.h"
#define MP_BINARY_OP_NUM_RUNTIME    (MP_BINARY_OP_CONTAINS + 1)
#endif
# 64 "../../py/runtime0.h"

typedef enum {
    // These ops may appear in the bytecode. Changing this group
    // in any way requires changing the bytecode version.
    MP_UNARY_OP_POSITIVE,
    MP_UNARY_OP_NEGATIVE,
    MP_UNARY_OP_INVERT,
    MP_UNARY_OP_NOT,

    // Following ops cannot appear in the bytecode
    MP_UNARY_OP_BOOL, // __bool__
    MP_UNARY_OP_LEN, // __len__
    MP_UNARY_OP_HASH, // __hash__; must return a small int
    MP_UNARY_OP_ABS, // __abs__
    MP_UNARY_OP_INT, // __int__
    MP_UNARY_OP_SIZEOF, // for sys.getsizeof()
} mp_unary_op_t;

typedef enum {
    // The following 9+13+13 ops are used in bytecode and changing
    // them requires changing the bytecode version.

    // 9 relational operations, should return a bool; order of first 6 matches corresponding mp_token_kind_t
    MP_BINARY_OP_LESS,
    MP_BINARY_OP_MORE,
    MP_BINARY_OP_EQUAL,
    MP_BINARY_OP_LESS_EQUAL,
    MP_BINARY_OP_MORE_EQUAL,
    MP_BINARY_OP_NOT_EQUAL,
    MP_BINARY_OP_IN,
    MP_BINARY_OP_IS,
    MP_BINARY_OP_EXCEPTION_MATCH,

    // 13 inplace arithmetic operations; order matches corresponding mp_token_kind_t
    MP_BINARY_OP_INPLACE_OR,
    MP_BINARY_OP_INPLACE_XOR,
    MP_BINARY_OP_INPLACE_AND,
    MP_BINARY_OP_INPLACE_LSHIFT,
    MP_BINARY_OP_INPLACE_RSHIFT,
    MP_BINARY_OP_INPLACE_ADD,
    MP_BINARY_OP_INPLACE_SUBTRACT,
    MP_BINARY_OP_INPLACE_MULTIPLY,
    MP_BINARY_OP_INPLACE_MAT_MULTIPLY,
    MP_BINARY_OP_INPLACE_FLOOR_DIVIDE,
    MP_BINARY_OP_INPLACE_TRUE_DIVIDE,
    MP_BINARY_OP_INPLACE_MODULO,
    MP_BINARY_OP_INPLACE_POWER,

    // 13 normal arithmetic operations; order matches corresponding mp_token_kind_t
    MP_BINARY_OP_OR,
    MP_BINARY_OP_XOR,
    MP_BINARY_OP_AND,
    MP_BINARY_OP_LSHIFT,
    MP_BINARY_OP_RSHIFT,
    MP_BINARY_OP_ADD,
    MP_BINARY_OP_SUBTRACT,
    MP_BINARY_OP_MULTIPLY,
    MP_BINARY_OP_MAT_MULTIPLY,
    MP_BINARY_OP_FLOOR_DIVIDE,
    MP_BINARY_OP_TRUE_DIVIDE,
    MP_BINARY_OP_MODULO,
    MP_BINARY_OP_POWER,

    // Operations below this line don't appear in bytecode, they
    // just identify special methods.

    // This is not emitted by the compiler but is supported by the runtime.
    // It must follow immediately after MP_BINARY_OP_POWER.
    MP_BINARY_OP_DIVMOD,

    // The runtime will convert MP_BINARY_OP_IN to this operator with swapped args.
    // A type should implement this containment operator instead of MP_BINARY_OP_IN.
    MP_BINARY_OP_CONTAINS,

    // 13 MP_BINARY_OP_REVERSE_* operations must be in the same order as MP_BINARY_OP_*,
    // and be the last ones supported by the runtime.
    MP_BINARY_OP_REVERSE_OR,
    MP_BINARY_OP_REVERSE_XOR,
    MP_BINARY_OP_REVERSE_AND,
    MP_BINARY_OP_REVERSE_LSHIFT,
    MP_BINARY_OP_REVERSE_RSHIFT,
    MP_BINARY_OP_REVERSE_ADD,
    MP_BINARY_OP_REVERSE_SUBTRACT,
    MP_BINARY_OP_REVERSE_MULTIPLY,
    MP_BINARY_OP_REVERSE_MAT_MULTIPLY,
    MP_BINARY_OP_REVERSE_FLOOR_DIVIDE,
    MP_BINARY_OP_REVERSE_TRUE_DIVIDE,
    MP_BINARY_OP_REVERSE_MODULO,
    MP_BINARY_OP_REVERSE_POWER,

    // These 2 are not supported by the runtime and must be synthesised by the emitter
    MP_BINARY_OP_NOT_IN,
    MP_BINARY_OP_IS_NOT,
} mp_binary_op_t;

#endif // MICROPY_INCLUDED_PY_RUNTIME0_H
# 160 "../../py/runtime0.h"
# 36 "../../py/obj.h" 2

// This is the definition of the opaque MicroPython object type.
// All concrete objects have an encoding within this type and the
// particular encoding is specified by MICROPY_OBJ_REPR.
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_D
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 41 "../../py/obj.h"
typedef uint64_t mp_obj_t;
typedef uint64_t mp_const_obj_t;
#else
# 44 "../../py/obj.h"
typedef void *mp_obj_t;
typedef const void *mp_const_obj_t;
#endif
# 47 "../../py/obj.h"

// This mp_obj_type_t struct is a concrete MicroPython object which holds info
// about a type.  See below for actual definition of the struct.
typedef struct _mp_obj_type_t mp_obj_type_t;

// Anything that wants to be a concrete MicroPython object must have mp_obj_base_t
// as its first member (small ints, qstr objs and inline floats are not concrete).
struct _mp_obj_base_t {
    const mp_obj_type_t *type MICROPY_OBJ_BASE_ALIGNMENT;
};
typedef struct _mp_obj_base_t mp_obj_base_t;

// These fake objects are used to indicate certain things in arguments or return
// values, and should only be used when explicitly allowed.
//
//  - MP_OBJ_NULL : used to indicate the absence of an object, or unsupported operation.
//  - MP_OBJ_STOP_ITERATION : used instead of throwing a StopIteration, for efficiency.
//  - MP_OBJ_SENTINEL : used for various internal purposes where one needs
//    an object which is unique from all other objects, including MP_OBJ_NULL.
//
// For debugging purposes they are all different.  For non-debug mode, we alias
// as many as we can to MP_OBJ_NULL because it's cheaper to load/compare 0.

#if 0 /* disabled by -frewrite-includes */
#if MICROPY_DEBUG_MP_OBJ_SENTINELS
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 71 "../../py/obj.h"
#define MP_OBJ_NULL             (MP_OBJ_FROM_PTR((void *)0))
#define MP_OBJ_STOP_ITERATION   (MP_OBJ_FROM_PTR((void *)4))
#define MP_OBJ_SENTINEL         (MP_OBJ_FROM_PTR((void *)8))
#else
# 75 "../../py/obj.h"
#define MP_OBJ_NULL             (MP_OBJ_FROM_PTR((void *)0))
#define MP_OBJ_STOP_ITERATION   (MP_OBJ_FROM_PTR((void *)0))
#define MP_OBJ_SENTINEL         (MP_OBJ_FROM_PTR((void *)4))
#endif
# 79 "../../py/obj.h"

// These macros/inline functions operate on objects and depend on the
// particular object representation.  They are used to query, pack and
// unpack small ints, qstrs and full object pointers.

#if 0 /* disabled by -frewrite-includes */
#if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_A
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 85 "../../py/obj.h"

static inline bool mp_obj_is_small_int(mp_const_obj_t o) {
    return (((mp_int_t)(o)) & 1) != 0;
}
#define MP_OBJ_SMALL_INT_VALUE(o) (((mp_int_t)(o)) >> 1)
#define MP_OBJ_NEW_SMALL_INT(small_int) ((mp_obj_t)((((mp_uint_t)(small_int)) << 1) | 1))

static inline bool mp_obj_is_qstr(mp_const_obj_t o) {
    return (((mp_int_t)(o)) & 7) == 2;
}
#define MP_OBJ_QSTR_VALUE(o) (((mp_uint_t)(o)) >> 3)
#define MP_OBJ_NEW_QSTR(qst) ((mp_obj_t)((((mp_uint_t)(qst)) << 3) | 2))

static inline bool mp_obj_is_immediate_obj(mp_const_obj_t o) {
    return (((mp_int_t)(o)) & 7) == 6;
}
#define MP_OBJ_IMMEDIATE_OBJ_VALUE(o) (((mp_uint_t)(o)) >> 3)
#define MP_OBJ_NEW_IMMEDIATE_OBJ(val) ((mp_obj_t)(((val) << 3) | 6))

#if 0 /* disabled by -frewrite-includes */
#if MICROPY_PY_BUILTINS_FLOAT
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 105 "../../py/obj.h"
#define mp_const_float_e MP_ROM_PTR(&mp_const_float_e_obj)
#define mp_const_float_pi MP_ROM_PTR(&mp_const_float_pi_obj)
extern const struct _mp_obj_float_t mp_const_float_e_obj;
extern const struct _mp_obj_float_t mp_const_float_pi_obj;

#define mp_obj_is_float(o) mp_obj_is_type((o), &mp_type_float)
mp_float_t mp_obj_float_get(mp_obj_t self_in);
mp_obj_t mp_obj_new_float(mp_float_t value);
#endif
# 114 "../../py/obj.h"

static inline bool mp_obj_is_obj(mp_const_obj_t o) {
    return (((mp_int_t)(o)) & 3) == 0;
}

#if 0 /* disabled by -frewrite-includes */
#if 0
#elif MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_B
#endif
#endif /* disabled by -frewrite-includes */
#elif 1 /* evaluated by -frewrite-includes */
# 120 "../../py/obj.h"

static inline bool mp_obj_is_small_int(mp_const_obj_t o) {
    return (((mp_int_t)(o)) & 3) == 1;
}
#define MP_OBJ_SMALL_INT_VALUE(o) (((mp_int_t)(o)) >> 2)
#define MP_OBJ_NEW_SMALL_INT(small_int) ((mp_obj_t)((((mp_uint_t)(small_int)) << 2) | 1))

static inline bool mp_obj_is_qstr(mp_const_obj_t o) {
    return (((mp_int_t)(o)) & 7) == 3;
}
#define MP_OBJ_QSTR_VALUE(o) (((mp_uint_t)(o)) >> 3)
#define MP_OBJ_NEW_QSTR(qst) ((mp_obj_t)((((mp_uint_t)(qst)) << 3) | 3))

static inline bool mp_obj_is_immediate_obj(mp_const_obj_t o) {
    return (((mp_int_t)(o)) & 7) == 7;
}
#define MP_OBJ_IMMEDIATE_OBJ_VALUE(o) (((mp_uint_t)(o)) >> 3)
#define MP_OBJ_NEW_IMMEDIATE_OBJ(val) ((mp_obj_t)(((val) << 3) | 7))

#if 0 /* disabled by -frewrite-includes */
#if MICROPY_PY_BUILTINS_FLOAT
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 140 "../../py/obj.h"
#define mp_const_float_e MP_ROM_PTR(&mp_const_float_e_obj)
#define mp_const_float_pi MP_ROM_PTR(&mp_const_float_pi_obj)
extern const struct _mp_obj_float_t mp_const_float_e_obj;
extern const struct _mp_obj_float_t mp_const_float_pi_obj;

#define mp_obj_is_float(o) mp_obj_is_type((o), &mp_type_float)
mp_float_t mp_obj_float_get(mp_obj_t self_in);
mp_obj_t mp_obj_new_float(mp_float_t value);
#endif
# 149 "../../py/obj.h"

static inline bool mp_obj_is_obj(mp_const_obj_t o) {
    return (((mp_int_t)(o)) & 1) == 0;
}

#if 0 /* disabled by -frewrite-includes */
#if 0
#elif MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_C
#endif
#endif /* disabled by -frewrite-includes */
#elif 0 /* evaluated by -frewrite-includes */
# 155 "../../py/obj.h"

static inline bool mp_obj_is_small_int(mp_const_obj_t o) {
    return (((mp_int_t)(o)) & 1) != 0;
}
#define MP_OBJ_SMALL_INT_VALUE(o) (((mp_int_t)(o)) >> 1)
#define MP_OBJ_NEW_SMALL_INT(small_int) ((mp_obj_t)((((mp_uint_t)(small_int)) << 1) | 1))

#if 0 /* disabled by -frewrite-includes */
#if MICROPY_PY_BUILTINS_FLOAT
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 163 "../../py/obj.h"
#define mp_const_float_e MP_ROM_PTR((mp_obj_t)(((0x402df854 & ~3) | 2) + 0x80800000))
#define mp_const_float_pi MP_ROM_PTR((mp_obj_t)(((0x40490fdb & ~3) | 2) + 0x80800000))

static inline bool mp_obj_is_float(mp_const_obj_t o) {
    return (((mp_uint_t)(o)) & 3) == 2 && (((mp_uint_t)(o)) & 0xff800007) != 0x00000006;
}
static inline mp_float_t mp_obj_float_get(mp_const_obj_t o) {
    union {
        mp_float_t f;
        mp_uint_t u;
    } num = {.u = ((mp_uint_t)o - 0x80800000) & ~3};
    return num.f;
}
static inline mp_obj_t mp_obj_new_float(mp_float_t f) {
    union {
        mp_float_t f;
        mp_uint_t u;
    } num = {.f = f};
    return (mp_obj_t)(((num.u & ~0x3) | 2) + 0x80800000);
}
#endif
# 184 "../../py/obj.h"

static inline bool mp_obj_is_qstr(mp_const_obj_t o) {
    return (((mp_uint_t)(o)) & 0xff80000f) == 0x00000006;
}
#define MP_OBJ_QSTR_VALUE(o) (((mp_uint_t)(o)) >> 4)
#define MP_OBJ_NEW_QSTR(qst) ((mp_obj_t)((((mp_uint_t)(qst)) << 4) | 0x00000006))

static inline bool mp_obj_is_immediate_obj(mp_const_obj_t o) {
    return (((mp_uint_t)(o)) & 0xff80000f) == 0x0000000e;
}
#define MP_OBJ_IMMEDIATE_OBJ_VALUE(o) (((mp_uint_t)(o)) >> 4)
#define MP_OBJ_NEW_IMMEDIATE_OBJ(val) ((mp_obj_t)(((val) << 4) | 0xe))

static inline bool mp_obj_is_obj(mp_const_obj_t o) {
    return (((mp_int_t)(o)) & 3) == 0;
}

#if 0 /* disabled by -frewrite-includes */
#if 0
#elif MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_D
#endif
#endif /* disabled by -frewrite-includes */
#elif 0 /* evaluated by -frewrite-includes */
# 202 "../../py/obj.h"

static inline bool mp_obj_is_small_int(mp_const_obj_t o) {
    return (((uint64_t)(o)) & 0xffff000000000000) == 0x0001000000000000;
}
#define MP_OBJ_SMALL_INT_VALUE(o) (((mp_int_t)((o) << 16)) >> 17)
#define MP_OBJ_NEW_SMALL_INT(small_int) (((((uint64_t)(small_int)) & 0x7fffffffffff) << 1) | 0x0001000000000001)

static inline bool mp_obj_is_qstr(mp_const_obj_t o) {
    return (((uint64_t)(o)) & 0xffff000000000000) == 0x0002000000000000;
}
#define MP_OBJ_QSTR_VALUE(o) ((((uint32_t)(o)) >> 1) & 0xffffffff)
#define MP_OBJ_NEW_QSTR(qst) ((mp_obj_t)(((uint64_t)(((uint32_t)(qst)) << 1)) | 0x0002000000000001))

static inline bool mp_obj_is_immediate_obj(mp_const_obj_t o) {
    return (((uint64_t)(o)) & 0xffff000000000000) == 0x0003000000000000;
}
#define MP_OBJ_IMMEDIATE_OBJ_VALUE(o) ((((uint32_t)(o)) >> 46) & 3)
#define MP_OBJ_NEW_IMMEDIATE_OBJ(val) (((uint64_t)(val) << 46) | 0x0003000000000000)

#if 0 /* disabled by -frewrite-includes */
#if MICROPY_PY_BUILTINS_FLOAT
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 222 "../../py/obj.h"

#if 0 /* disabled by -frewrite-includes */
#if MICROPY_FLOAT_IMPL != MICROPY_FLOAT_IMPL_DOUBLE
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 224 "../../py/obj.h"
#error MICROPY_OBJ_REPR_D requires MICROPY_FLOAT_IMPL_DOUBLE
#endif
# 226 "../../py/obj.h"

#define mp_const_float_e {((mp_obj_t)((uint64_t)0x4005bf0a8b145769 + 0x8004000000000000))}
#define mp_const_float_pi {((mp_obj_t)((uint64_t)0x400921fb54442d18 + 0x8004000000000000))}

static inline bool mp_obj_is_float(mp_const_obj_t o) {
    return ((uint64_t)(o) & 0xfffc000000000000) != 0;
}
static inline mp_float_t mp_obj_float_get(mp_const_obj_t o) {
    union {
        mp_float_t f;
        uint64_t r;
    } num = {.r = o - 0x8004000000000000};
    return num.f;
}
static inline mp_obj_t mp_obj_new_float(mp_float_t f) {
    union {
        mp_float_t f;
        uint64_t r;
    } num = {.f = f};
    return num.r + 0x8004000000000000;
}
#endif
# 248 "../../py/obj.h"

static inline bool mp_obj_is_obj(mp_const_obj_t o) {
    return (((uint64_t)(o)) & 0xffff000000000000) == 0x0000000000000000;
}
#define MP_OBJ_TO_PTR(o) ((void *)(uintptr_t)(o))
#define MP_OBJ_FROM_PTR(p) ((mp_obj_t)((uintptr_t)(p)))

// rom object storage needs special handling to widen 32-bit pointer to 64-bits
typedef union _mp_rom_obj_t { uint64_t u64;
                              struct { const void *lo, *hi;
                              } u32;
} mp_rom_obj_t;
#define MP_ROM_INT(i) {MP_OBJ_NEW_SMALL_INT(i)}
#define MP_ROM_QSTR(q) {MP_OBJ_NEW_QSTR(q)}
#if 0 /* disabled by -frewrite-includes */
#if MP_ENDIANNESS_LITTLE
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 263 "../../py/obj.h"
#define MP_ROM_PTR(p) {.u32 = {.lo = (p), .hi = NULL}}
#else
# 265 "../../py/obj.h"
#define MP_ROM_PTR(p) {.u32 = {.lo = NULL, .hi = (p)}}
#endif
# 267 "../../py/obj.h"

#endif
# 269 "../../py/obj.h"

// Macros to convert between mp_obj_t and concrete object types.
// These are identity operations in MicroPython, but ability to override
// these operations are provided to experiment with other methods of
// object representation and memory management.

// Cast mp_obj_t to object pointer
#ifndef MP_OBJ_TO_PTR
#define MP_OBJ_TO_PTR(o) ((void *)o)
#endif
# 279 "../../py/obj.h"

// Cast object pointer to mp_obj_t
#ifndef MP_OBJ_FROM_PTR
#define MP_OBJ_FROM_PTR(p) ((mp_obj_t)p)
#endif
# 284 "../../py/obj.h"

// Macros to create objects that are stored in ROM.

#ifndef MP_ROM_NONE
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_OBJ_IMMEDIATE_OBJS
#endif
#endif /* disabled by -frewrite-includes */
#if 1 /* evaluated by -frewrite-includes */
# 289 "../../py/obj.h"
#define MP_ROM_NONE mp_const_none
#else
# 291 "../../py/obj.h"
#define MP_ROM_NONE MP_ROM_PTR(&mp_const_none_obj)
#endif
# 293 "../../py/obj.h"
#endif
# 294 "../../py/obj.h"

#ifndef MP_ROM_FALSE
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_OBJ_IMMEDIATE_OBJS
#endif
#endif /* disabled by -frewrite-includes */
#if 1 /* evaluated by -frewrite-includes */
# 297 "../../py/obj.h"
#define MP_ROM_FALSE mp_const_false
#define MP_ROM_TRUE mp_const_true
#else
# 300 "../../py/obj.h"
#define MP_ROM_FALSE MP_ROM_PTR(&mp_const_false_obj)
#define MP_ROM_TRUE MP_ROM_PTR(&mp_const_true_obj)
#endif
# 303 "../../py/obj.h"
#endif
# 304 "../../py/obj.h"

#ifndef MP_ROM_INT
typedef mp_const_obj_t mp_rom_obj_t;
#define MP_ROM_INT(i) MP_OBJ_NEW_SMALL_INT(i)
#define MP_ROM_QSTR(q) MP_OBJ_NEW_QSTR(q)
#define MP_ROM_PTR(p) (p)
/* for testing
typedef struct _mp_rom_obj_t { mp_const_obj_t o; } mp_rom_obj_t;
#define MP_ROM_INT(i) {MP_OBJ_NEW_SMALL_INT(i)}
#define MP_ROM_QSTR(q) {MP_OBJ_NEW_QSTR(q)}
#define MP_ROM_PTR(p) {.o = p}
*/
#endif
# 317 "../../py/obj.h"

// These macros are used to declare and define constant function objects
// You can put "static" in front of the definitions to make them local

#define MP_DECLARE_CONST_FUN_OBJ_0(obj_name) extern const mp_obj_fun_builtin_fixed_t obj_name
#define MP_DECLARE_CONST_FUN_OBJ_1(obj_name) extern const mp_obj_fun_builtin_fixed_t obj_name
#define MP_DECLARE_CONST_FUN_OBJ_2(obj_name) extern const mp_obj_fun_builtin_fixed_t obj_name
#define MP_DECLARE_CONST_FUN_OBJ_3(obj_name) extern const mp_obj_fun_builtin_fixed_t obj_name
#define MP_DECLARE_CONST_FUN_OBJ_VAR(obj_name) extern const mp_obj_fun_builtin_var_t obj_name
#define MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(obj_name) extern const mp_obj_fun_builtin_var_t obj_name
#define MP_DECLARE_CONST_FUN_OBJ_KW(obj_name) extern const mp_obj_fun_builtin_var_t obj_name

#define MP_OBJ_FUN_ARGS_MAX (0xffff) // to set maximum value in n_args_max below
#define MP_OBJ_FUN_MAKE_SIG(n_args_min, n_args_max, takes_kw) ((uint32_t)((((uint32_t)(n_args_min)) << 17) | (((uint32_t)(n_args_max)) << 1) | ((takes_kw) ? 1 : 0)))

#define MP_DEFINE_CONST_FUN_OBJ_0(obj_name, fun_name) \
    const mp_obj_fun_builtin_fixed_t obj_name = \
    {{&mp_type_fun_builtin_0}, .fun._0 = fun_name}
#define MP_DEFINE_CONST_FUN_OBJ_1(obj_name, fun_name) \
    const mp_obj_fun_builtin_fixed_t obj_name = \
    {{&mp_type_fun_builtin_1}, .fun._1 = fun_name}
#define MP_DEFINE_CONST_FUN_OBJ_2(obj_name, fun_name) \
    const mp_obj_fun_builtin_fixed_t obj_name = \
    {{&mp_type_fun_builtin_2}, .fun._2 = fun_name}
#define MP_DEFINE_CONST_FUN_OBJ_3(obj_name, fun_name) \
    const mp_obj_fun_builtin_fixed_t obj_name = \
    {{&mp_type_fun_builtin_3}, .fun._3 = fun_name}
#define MP_DEFINE_CONST_FUN_OBJ_VAR(obj_name, n_args_min, fun_name) \
    const mp_obj_fun_builtin_var_t obj_name = \
    {{&mp_type_fun_builtin_var}, MP_OBJ_FUN_MAKE_SIG(n_args_min, MP_OBJ_FUN_ARGS_MAX, false), .fun.var = fun_name}
#define MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(obj_name, n_args_min, n_args_max, fun_name) \
    const mp_obj_fun_builtin_var_t obj_name = \
    {{&mp_type_fun_builtin_var}, MP_OBJ_FUN_MAKE_SIG(n_args_min, n_args_max, false), .fun.var = fun_name}
#define MP_DEFINE_CONST_FUN_OBJ_KW(obj_name, n_args_min, fun_name) \
    const mp_obj_fun_builtin_var_t obj_name = \
    {{&mp_type_fun_builtin_var}, MP_OBJ_FUN_MAKE_SIG(n_args_min, MP_OBJ_FUN_ARGS_MAX, true), .fun.kw = fun_name}

// These macros are used to define constant map/dict objects
// You can put "static" in front of the definition to make it local

#define MP_DEFINE_CONST_MAP(map_name, table_name) \
    const mp_map_t map_name = { \
        .all_keys_are_qstrs = 1, \
        .is_fixed = 1, \
        .is_ordered = 1, \
        .used = MP_ARRAY_SIZE(table_name), \
        .alloc = MP_ARRAY_SIZE(table_name), \
        .table = (mp_map_elem_t *)(mp_rom_map_elem_t *)table_name, \
    }

#define MP_DEFINE_CONST_DICT(dict_name, table_name) \
    const mp_obj_dict_t dict_name = { \
        .base = {&mp_type_dict}, \
        .map = { \
            .all_keys_are_qstrs = 1, \
            .is_fixed = 1, \
            .is_ordered = 1, \
            .used = MP_ARRAY_SIZE(table_name), \
            .alloc = MP_ARRAY_SIZE(table_name), \
            .table = (mp_map_elem_t *)(mp_rom_map_elem_t *)table_name, \
        }, \
    }

// These macros are used to declare and define constant staticmethond and classmethod objects
// You can put "static" in front of the definitions to make them local

#define MP_DECLARE_CONST_STATICMETHOD_OBJ(obj_name) extern const mp_rom_obj_static_class_method_t obj_name
#define MP_DECLARE_CONST_CLASSMETHOD_OBJ(obj_name) extern const mp_rom_obj_static_class_method_t obj_name

#define MP_DEFINE_CONST_STATICMETHOD_OBJ(obj_name, fun_name) const mp_rom_obj_static_class_method_t obj_name = {{&mp_type_staticmethod}, fun_name}
#define MP_DEFINE_CONST_CLASSMETHOD_OBJ(obj_name, fun_name) const mp_rom_obj_static_class_method_t obj_name = {{&mp_type_classmethod}, fun_name}

// Declare a module as a builtin, processed by makemoduledefs.py
// param module_name: MP_QSTR_<module name>
// param obj_module: mp_obj_module_t instance
// prarm enabled_define: used as `#if (enabled_define) around entry`

#define MP_REGISTER_MODULE(module_name, obj_module, enabled_define)

// Underlying map/hash table implementation (not dict object or map function)

typedef struct _mp_map_elem_t {
    mp_obj_t key;
    mp_obj_t value;
} mp_map_elem_t;

typedef struct _mp_rom_map_elem_t {
    mp_rom_obj_t key;
    mp_rom_obj_t value;
} mp_rom_map_elem_t;

typedef struct _mp_map_t {
    size_t all_keys_are_qstrs : 1;
    size_t is_fixed : 1;    // if set, table is fixed/read-only and can't be modified
    size_t is_ordered : 1;  // if set, table is an ordered array, not a hash map
    size_t used : (8 * sizeof(size_t) - 3);
    size_t alloc;
    mp_map_elem_t *table;
} mp_map_t;

// mp_set_lookup requires these constants to have the values they do
typedef enum _mp_map_lookup_kind_t {
    MP_MAP_LOOKUP = 0,
    MP_MAP_LOOKUP_ADD_IF_NOT_FOUND = 1,
    MP_MAP_LOOKUP_REMOVE_IF_FOUND = 2,
    MP_MAP_LOOKUP_ADD_IF_NOT_FOUND_OR_REMOVE_IF_FOUND = 3, // only valid for mp_set_lookup
} mp_map_lookup_kind_t;

static inline bool mp_map_slot_is_filled(const mp_map_t *map, size_t pos) {
    assert(pos < map->alloc);
    return (map)->table[pos].key != MP_OBJ_NULL && (map)->table[pos].key != MP_OBJ_SENTINEL;
}

void mp_map_init(mp_map_t *map, size_t n);
void mp_map_init_fixed_table(mp_map_t *map, size_t n, const mp_obj_t *table);
mp_map_t *mp_map_new(size_t n);
void mp_map_deinit(mp_map_t *map);
void mp_map_free(mp_map_t *map);
mp_map_elem_t *mp_map_lookup(mp_map_t *map, mp_obj_t index, mp_map_lookup_kind_t lookup_kind);
void mp_map_clear(mp_map_t *map);
void mp_map_dump(mp_map_t *map);

// Underlying set implementation (not set object)

typedef struct _mp_set_t {
    size_t alloc;
    size_t used;
    mp_obj_t *table;
} mp_set_t;

static inline bool mp_set_slot_is_filled(const mp_set_t *set, size_t pos) {
    return (set)->table[pos] != MP_OBJ_NULL && (set)->table[pos] != MP_OBJ_SENTINEL;
}

void mp_set_init(mp_set_t *set, size_t n);
mp_obj_t mp_set_lookup(mp_set_t *set, mp_obj_t index, mp_map_lookup_kind_t lookup_kind);
mp_obj_t mp_set_remove_first(mp_set_t *set);
void mp_set_clear(mp_set_t *set);

// Type definitions for methods

typedef mp_obj_t (*mp_fun_0_t)(void);
typedef mp_obj_t (*mp_fun_1_t)(mp_obj_t);
typedef mp_obj_t (*mp_fun_2_t)(mp_obj_t, mp_obj_t);
typedef mp_obj_t (*mp_fun_3_t)(mp_obj_t, mp_obj_t, mp_obj_t);
typedef mp_obj_t (*mp_fun_var_t)(size_t n, const mp_obj_t *);
// mp_fun_kw_t takes mp_map_t* (and not const mp_map_t*) to ease passing
// this arg to mp_map_lookup().
typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *);

// Flags for type behaviour (mp_obj_type_t.flags)
// If MP_TYPE_FLAG_EQ_NOT_REFLEXIVE is clear then __eq__ is reflexive (A==A returns True).
// If MP_TYPE_FLAG_EQ_CHECKS_OTHER_TYPE is clear then the type can't be equal to an
// instance of any different class that also clears this flag.  If this flag is set
// then the type may check for equality against a different type.
// If MP_TYPE_FLAG_EQ_HAS_NEQ_TEST is clear then the type only implements the __eq__
// operator and not the __ne__ operator.  If it's set then __ne__ may be implemented.
// If MP_TYPE_FLAG_BINDS_SELF is set then the type as a method binds self as the first arg.
// If MP_TYPE_FLAG_BUILTIN_FUN is set then the type is a built-in function type.
#define MP_TYPE_FLAG_IS_SUBCLASSED (0x0001)
#define MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS (0x0002)
#define MP_TYPE_FLAG_EQ_NOT_REFLEXIVE (0x0004)
#define MP_TYPE_FLAG_EQ_CHECKS_OTHER_TYPE (0x0008)
#define MP_TYPE_FLAG_EQ_HAS_NEQ_TEST (0x0010)
#define MP_TYPE_FLAG_BINDS_SELF (0x0020)
#define MP_TYPE_FLAG_BUILTIN_FUN (0x0040)

typedef enum {
    PRINT_STR = 0,
    PRINT_REPR = 1,
    PRINT_EXC = 2, // Special format for printing exception in unhandled exception message
    PRINT_JSON = 3,
    PRINT_RAW = 4, // Special format for printing bytes as an undercorated string
    PRINT_EXC_SUBCLASS = 0x80, // Internal flag for printing exception subclasses
} mp_print_kind_t;

typedef struct _mp_obj_iter_buf_t {
    mp_obj_base_t base;
    mp_obj_t buf[3];
} mp_obj_iter_buf_t;

// The number of slots that an mp_obj_iter_buf_t needs on the Python value stack.
// It's rounded up in case mp_obj_base_t is smaller than mp_obj_t (eg for OBJ_REPR_D).
#define MP_OBJ_ITER_BUF_NSLOTS ((sizeof(mp_obj_iter_buf_t) + sizeof(mp_obj_t) - 1) / sizeof(mp_obj_t))

typedef void (*mp_print_fun_t)(const mp_print_t *print, mp_obj_t o, mp_print_kind_t kind);
typedef mp_obj_t (*mp_make_new_fun_t)(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args);
typedef mp_obj_t (*mp_call_fun_t)(mp_obj_t fun, size_t n_args, size_t n_kw, const mp_obj_t *args);
typedef mp_obj_t (*mp_unary_op_fun_t)(mp_unary_op_t op, mp_obj_t);
typedef mp_obj_t (*mp_binary_op_fun_t)(mp_binary_op_t op, mp_obj_t, mp_obj_t);
typedef void (*mp_attr_fun_t)(mp_obj_t self_in, qstr attr, mp_obj_t *dest);
typedef mp_obj_t (*mp_subscr_fun_t)(mp_obj_t self_in, mp_obj_t index, mp_obj_t value);
typedef mp_obj_t (*mp_getiter_fun_t)(mp_obj_t self_in, mp_obj_iter_buf_t *iter_buf);

// Buffer protocol
typedef struct _mp_buffer_info_t {
    void *buf;      // can be NULL if len == 0
    size_t len;     // in bytes
    int typecode;   // as per binary.h
} mp_buffer_info_t;
#define MP_BUFFER_READ  (1)
#define MP_BUFFER_WRITE (2)
#define MP_BUFFER_RW (MP_BUFFER_READ | MP_BUFFER_WRITE)
typedef struct _mp_buffer_p_t {
    mp_int_t (*get_buffer)(mp_obj_t obj, mp_buffer_info_t *bufinfo, mp_uint_t flags);
} mp_buffer_p_t;
bool mp_get_buffer(mp_obj_t obj, mp_buffer_info_t *bufinfo, mp_uint_t flags);
void mp_get_buffer_raise(mp_obj_t obj, mp_buffer_info_t *bufinfo, mp_uint_t flags);

struct _mp_obj_type_t {
    // A type is an object so must start with this entry, which points to mp_type_type.
    mp_obj_base_t base;

    // Flags associated with this type.
    uint16_t flags;

    // The name of this type, a qstr.
    uint16_t name;

    // Corresponds to __repr__ and __str__ special methods.
    mp_print_fun_t print;

    // Corresponds to __new__ and __init__ special methods, to make an instance of the type.
    mp_make_new_fun_t make_new;

    // Corresponds to __call__ special method, ie T(...).
    mp_call_fun_t call;

    // Implements unary and binary operations.
    // Can return MP_OBJ_NULL if the operation is not supported.
    mp_unary_op_fun_t unary_op;
    mp_binary_op_fun_t binary_op;

    // Implements load, store and delete attribute.
    //
    // dest[0] = MP_OBJ_NULL means load
    //  return: for fail, do nothing
    //          for attr, dest[0] = value
    //          for method, dest[0] = method, dest[1] = self
    //
    // dest[0,1] = {MP_OBJ_SENTINEL, MP_OBJ_NULL} means delete
    // dest[0,1] = {MP_OBJ_SENTINEL, object} means store
    //  return: for fail, do nothing
    //          for success set dest[0] = MP_OBJ_NULL
    mp_attr_fun_t attr;

    // Implements load, store and delete subscripting:
    //  - value = MP_OBJ_SENTINEL means load
    //  - value = MP_OBJ_NULL means delete
    //  - all other values mean store the value
    // Can return MP_OBJ_NULL if operation not supported.
    mp_subscr_fun_t subscr;

    // Corresponds to __iter__ special method.
    // Can use the given mp_obj_iter_buf_t to store iterator object,
    // otherwise can return a pointer to an object on the heap.
    mp_getiter_fun_t getiter;

    // Corresponds to __next__ special method.  May return MP_OBJ_STOP_ITERATION
    // as an optimisation instead of raising StopIteration() with no args.
    mp_fun_1_t iternext;

    // Implements the buffer protocol if supported by this type.
    mp_buffer_p_t buffer_p;

    // One of disjoint protocols (interfaces), like mp_stream_p_t, etc.
    const void *protocol;

    // A pointer to the parents of this type:
    //  - 0 parents: pointer is NULL (object is implicitly the single parent)
    //  - 1 parent: a pointer to the type of that parent
    //  - 2 or more parents: pointer to a tuple object containing the parent types
    const void *parent;

    // A dict mapping qstrs to objects local methods/constants/etc.
    struct _mp_obj_dict_t *locals_dict;
};

// Constant types, globally accessible
extern const mp_obj_type_t mp_type_type;
extern const mp_obj_type_t mp_type_object;
extern const mp_obj_type_t mp_type_NoneType;
extern const mp_obj_type_t mp_type_bool;
extern const mp_obj_type_t mp_type_int;
extern const mp_obj_type_t mp_type_str;
extern const mp_obj_type_t mp_type_bytes;
extern const mp_obj_type_t mp_type_bytearray;
extern const mp_obj_type_t mp_type_memoryview;
extern const mp_obj_type_t mp_type_float;
extern const mp_obj_type_t mp_type_complex;
extern const mp_obj_type_t mp_type_tuple;
extern const mp_obj_type_t mp_type_list;
extern const mp_obj_type_t mp_type_map; // map (the python builtin, not the dict implementation detail)
extern const mp_obj_type_t mp_type_enumerate;
extern const mp_obj_type_t mp_type_filter;
extern const mp_obj_type_t mp_type_deque;
extern const mp_obj_type_t mp_type_dict;
extern const mp_obj_type_t mp_type_ordereddict;
extern const mp_obj_type_t mp_type_range;
extern const mp_obj_type_t mp_type_set;
extern const mp_obj_type_t mp_type_frozenset;
extern const mp_obj_type_t mp_type_slice;
extern const mp_obj_type_t mp_type_zip;
extern const mp_obj_type_t mp_type_array;
extern const mp_obj_type_t mp_type_super;
extern const mp_obj_type_t mp_type_gen_wrap;
extern const mp_obj_type_t mp_type_native_gen_wrap;
extern const mp_obj_type_t mp_type_gen_instance;
extern const mp_obj_type_t mp_type_fun_builtin_0;
extern const mp_obj_type_t mp_type_fun_builtin_1;
extern const mp_obj_type_t mp_type_fun_builtin_2;
extern const mp_obj_type_t mp_type_fun_builtin_3;
extern const mp_obj_type_t mp_type_fun_builtin_var;
extern const mp_obj_type_t mp_type_fun_bc;
extern const mp_obj_type_t mp_type_module;
extern const mp_obj_type_t mp_type_staticmethod;
extern const mp_obj_type_t mp_type_classmethod;
extern const mp_obj_type_t mp_type_property;
extern const mp_obj_type_t mp_type_stringio;
extern const mp_obj_type_t mp_type_bytesio;
extern const mp_obj_type_t mp_type_reversed;
extern const mp_obj_type_t mp_type_polymorph_iter;

// Exceptions
extern const mp_obj_type_t mp_type_BaseException;
extern const mp_obj_type_t mp_type_ArithmeticError;
extern const mp_obj_type_t mp_type_AssertionError;
extern const mp_obj_type_t mp_type_AttributeError;
extern const mp_obj_type_t mp_type_EOFError;
extern const mp_obj_type_t mp_type_Exception;
extern const mp_obj_type_t mp_type_GeneratorExit;
extern const mp_obj_type_t mp_type_ImportError;
extern const mp_obj_type_t mp_type_IndentationError;
extern const mp_obj_type_t mp_type_IndexError;
extern const mp_obj_type_t mp_type_KeyboardInterrupt;
extern const mp_obj_type_t mp_type_KeyError;
extern const mp_obj_type_t mp_type_LookupError;
extern const mp_obj_type_t mp_type_MemoryError;
extern const mp_obj_type_t mp_type_NameError;
extern const mp_obj_type_t mp_type_NotImplementedError;
extern const mp_obj_type_t mp_type_OSError;
extern const mp_obj_type_t mp_type_OverflowError;
extern const mp_obj_type_t mp_type_RuntimeError;
extern const mp_obj_type_t mp_type_StopAsyncIteration;
extern const mp_obj_type_t mp_type_StopIteration;
extern const mp_obj_type_t mp_type_SyntaxError;
extern const mp_obj_type_t mp_type_SystemExit;
extern const mp_obj_type_t mp_type_TypeError;
extern const mp_obj_type_t mp_type_UnicodeError;
extern const mp_obj_type_t mp_type_ValueError;
extern const mp_obj_type_t mp_type_ViperTypeError;
extern const mp_obj_type_t mp_type_ZeroDivisionError;

// Constant objects, globally accessible: None, False, True
// These should always be accessed via the below macros.
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_OBJ_IMMEDIATE_OBJS
#endif
#endif /* disabled by -frewrite-includes */
#if 1 /* evaluated by -frewrite-includes */
# 673 "../../py/obj.h"
// None is even while False/True are odd so their types can be distinguished with 1 bit.
#define mp_const_none MP_OBJ_NEW_IMMEDIATE_OBJ(0)
#define mp_const_false MP_OBJ_NEW_IMMEDIATE_OBJ(1)
#define mp_const_true MP_OBJ_NEW_IMMEDIATE_OBJ(3)
#else
# 678 "../../py/obj.h"
#define mp_const_none (MP_OBJ_FROM_PTR(&mp_const_none_obj))
#define mp_const_false (MP_OBJ_FROM_PTR(&mp_const_false_obj))
#define mp_const_true (MP_OBJ_FROM_PTR(&mp_const_true_obj))
extern const struct _mp_obj_none_t mp_const_none_obj;
extern const struct _mp_obj_bool_t mp_const_false_obj;
extern const struct _mp_obj_bool_t mp_const_true_obj;
#endif
# 685 "../../py/obj.h"

// Constant objects, globally accessible: b'', (), {}, Ellipsis, NotImplemented, GeneratorExit()
// The below macros are for convenience only.
#define mp_const_empty_bytes (MP_OBJ_FROM_PTR(&mp_const_empty_bytes_obj))
#define mp_const_empty_tuple (MP_OBJ_FROM_PTR(&mp_const_empty_tuple_obj))
#define mp_const_notimplemented (MP_OBJ_FROM_PTR(&mp_const_notimplemented_obj))
extern const struct _mp_obj_str_t mp_const_empty_bytes_obj;
extern const struct _mp_obj_tuple_t mp_const_empty_tuple_obj;
extern const struct _mp_obj_dict_t mp_const_empty_dict_obj;
extern const struct _mp_obj_singleton_t mp_const_ellipsis_obj;
extern const struct _mp_obj_singleton_t mp_const_notimplemented_obj;
extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj;

// Fixed empty map. Useful when calling keyword-receiving functions
// without any keywords from C, etc.
#define mp_const_empty_map (mp_const_empty_dict_obj.map)

// General API for objects

// These macros are derived from more primitive ones and are used to
// check for more specific object types.
// Note: these are kept as macros because inline functions sometimes use much
// more code space than the equivalent macros, depending on the compiler.
#define mp_obj_is_type(o, t) (mp_obj_is_obj(o) && (((mp_obj_base_t *)MP_OBJ_TO_PTR(o))->type == (t))) // this does not work for checking int, str or fun; use below macros for that
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_OBJ_IMMEDIATE_OBJS
#endif
#endif /* disabled by -frewrite-includes */
#if 1 /* evaluated by -frewrite-includes */
# 710 "../../py/obj.h"
// bool's are immediates, not real objects, so test for the 2 possible values.
#define mp_obj_is_bool(o) ((o) == mp_const_false || (o) == mp_const_true)
#else
# 713 "../../py/obj.h"
#define mp_obj_is_bool(o) mp_obj_is_type(o, &mp_type_bool)
#endif
# 715 "../../py/obj.h"
#define mp_obj_is_int(o) (mp_obj_is_small_int(o) || mp_obj_is_type(o, &mp_type_int))
#define mp_obj_is_str(o) (mp_obj_is_qstr(o) || mp_obj_is_type(o, &mp_type_str))
#define mp_obj_is_str_or_bytes(o) (mp_obj_is_qstr(o) || (mp_obj_is_obj(o) && ((mp_obj_base_t *)MP_OBJ_TO_PTR(o))->type->binary_op == mp_obj_str_binary_op))
#define mp_obj_is_dict_or_ordereddict(o) (mp_obj_is_obj(o) && ((mp_obj_base_t *)MP_OBJ_TO_PTR(o))->type->make_new == mp_obj_dict_make_new)
#define mp_obj_is_fun(o) (mp_obj_is_obj(o) && (((mp_obj_base_t *)MP_OBJ_TO_PTR(o))->type->name == MP_QSTR_function))

mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict);
static inline mp_obj_t mp_obj_new_bool(mp_int_t x) {
    return x ? mp_const_true : mp_const_false;
}
mp_obj_t mp_obj_new_cell(mp_obj_t obj);
mp_obj_t mp_obj_new_int(mp_int_t value);
mp_obj_t mp_obj_new_int_from_uint(mp_uint_t value);
mp_obj_t mp_obj_new_int_from_str_len(const char **str, size_t len, bool neg, unsigned int base);
mp_obj_t mp_obj_new_int_from_ll(long long val); // this must return a multi-precision integer object (or raise an overflow exception)
mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); // this must return a multi-precision integer object (or raise an overflow exception)
mp_obj_t mp_obj_new_str(const char *data, size_t len);
mp_obj_t mp_obj_new_str_via_qstr(const char *data, size_t len);
mp_obj_t mp_obj_new_str_from_vstr(const mp_obj_type_t *type, vstr_t *vstr);
mp_obj_t mp_obj_new_bytes(const byte *data, size_t len);
mp_obj_t mp_obj_new_bytearray(size_t n, void *items);
mp_obj_t mp_obj_new_bytearray_by_ref(size_t n, void *items);
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_PY_BUILTINS_FLOAT
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 738 "../../py/obj.h"
mp_obj_t mp_obj_new_int_from_float(mp_float_t val);
mp_obj_t mp_obj_new_complex(mp_float_t real, mp_float_t imag);
#endif
# 741 "../../py/obj.h"
mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type);
mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args);
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_NONE
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 744 "../../py/obj.h"
#define mp_obj_new_exception_msg(exc_type, msg) mp_obj_new_exception(exc_type)
#define mp_obj_new_exception_msg_varg(exc_type, ...) mp_obj_new_exception(exc_type)
#else
# 747 "../../py/obj.h"
mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, mp_rom_error_text_t msg);
mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, mp_rom_error_text_t fmt, ...); // counts args by number of % symbols in fmt, excluding %%; can only handle void* sizes (ie no float/double!)
#endif
# 750 "../../py/obj.h"
#ifdef va_start
mp_obj_t mp_obj_new_exception_msg_vlist(const mp_obj_type_t *exc_type, mp_rom_error_text_t fmt, va_list arg); // same fmt restrictions as above
#endif
# 753 "../../py/obj.h"
mp_obj_t mp_obj_new_fun_bc(mp_obj_t def_args, mp_obj_t def_kw_args, const byte *code, const mp_uint_t *const_table);
mp_obj_t mp_obj_new_fun_native(mp_obj_t def_args_in, mp_obj_t def_kw_args, const void *fun_data, const mp_uint_t *const_table);
mp_obj_t mp_obj_new_fun_asm(size_t n_args, const void *fun_data, mp_uint_t type_sig);
mp_obj_t mp_obj_new_gen_wrap(mp_obj_t fun);
mp_obj_t mp_obj_new_closure(mp_obj_t fun, size_t n_closed, const mp_obj_t *closed);
mp_obj_t mp_obj_new_tuple(size_t n, const mp_obj_t *items);
mp_obj_t mp_obj_new_list(size_t n, mp_obj_t *items);
mp_obj_t mp_obj_new_dict(size_t n_args);
mp_obj_t mp_obj_new_set(size_t n_args, mp_obj_t *items);
mp_obj_t mp_obj_new_slice(mp_obj_t start, mp_obj_t stop, mp_obj_t step);
mp_obj_t mp_obj_new_bound_meth(mp_obj_t meth, mp_obj_t self);
mp_obj_t mp_obj_new_getitem_iter(mp_obj_t *args, mp_obj_iter_buf_t *iter_buf);
mp_obj_t mp_obj_new_module(qstr module_name);
mp_obj_t mp_obj_new_memoryview(byte typecode, size_t nitems, void *items);

const mp_obj_type_t *mp_obj_get_type(mp_const_obj_t o_in);
const char *mp_obj_get_type_str(mp_const_obj_t o_in);
bool mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo); // arguments should be type objects
mp_obj_t mp_obj_cast_to_native_base(mp_obj_t self_in, mp_const_obj_t native_type);

void mp_obj_print_helper(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind);
void mp_obj_print(mp_obj_t o, mp_print_kind_t kind);
void mp_obj_print_exception(const mp_print_t *print, mp_obj_t exc);

bool mp_obj_is_true(mp_obj_t arg);
bool mp_obj_is_callable(mp_obj_t o_in);
mp_obj_t mp_obj_equal_not_equal(mp_binary_op_t op, mp_obj_t o1, mp_obj_t o2);
bool mp_obj_equal(mp_obj_t o1, mp_obj_t o2);

// returns true if o is bool, small int or long int
static inline bool mp_obj_is_integer(mp_const_obj_t o) {
    return mp_obj_is_int(o) || mp_obj_is_bool(o);
}

mp_int_t mp_obj_get_int(mp_const_obj_t arg);
mp_int_t mp_obj_get_int_truncated(mp_const_obj_t arg);
bool mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value);
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_PY_BUILTINS_FLOAT
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 791 "../../py/obj.h"
mp_float_t mp_obj_get_float(mp_obj_t self_in);
bool mp_obj_get_float_maybe(mp_obj_t arg, mp_float_t *value);
void mp_obj_get_complex(mp_obj_t self_in, mp_float_t *real, mp_float_t *imag);
bool mp_obj_get_complex_maybe(mp_obj_t self_in, mp_float_t *real, mp_float_t *imag);
#endif
# 796 "../../py/obj.h"
void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items); // *items may point inside a GC block
void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items); // *items may point inside a GC block
size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, bool is_slice);
mp_obj_t mp_obj_id(mp_obj_t o_in);
mp_obj_t mp_obj_len(mp_obj_t o_in);
mp_obj_t mp_obj_len_maybe(mp_obj_t o_in); // may return MP_OBJ_NULL
mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t val);
mp_obj_t mp_generic_unary_op(mp_unary_op_t op, mp_obj_t o_in);

// cell
mp_obj_t mp_obj_cell_get(mp_obj_t self_in);
void mp_obj_cell_set(mp_obj_t self_in, mp_obj_t obj);

// int
// For long int, returns value truncated to mp_int_t
mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in);
// Will raise exception if value doesn't fit into mp_int_t
mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in);
// Will raise exception if value is negative or doesn't fit into mp_uint_t
mp_uint_t mp_obj_int_get_uint_checked(mp_const_obj_t self_in);

// exception
#define mp_obj_is_native_exception_instance(o) (mp_obj_get_type(o)->make_new == mp_obj_exception_make_new)
bool mp_obj_is_exception_type(mp_obj_t self_in);
bool mp_obj_is_exception_instance(mp_obj_t self_in);
bool mp_obj_exception_match(mp_obj_t exc, mp_const_obj_t exc_type);
void mp_obj_exception_clear_traceback(mp_obj_t self_in);
void mp_obj_exception_add_traceback(mp_obj_t self_in, qstr file, size_t line, qstr block);
void mp_obj_exception_get_traceback(mp_obj_t self_in, size_t *n, size_t **values);
mp_obj_t mp_obj_exception_get_value(mp_obj_t self_in);
mp_obj_t mp_obj_exception_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args);
mp_obj_t mp_alloc_emergency_exception_buf(mp_obj_t size_in);
void mp_init_emergency_exception_buf(void);
static inline mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg) {
    assert(exc_type->make_new == mp_obj_exception_make_new);
    return mp_obj_exception_make_new(exc_type, 1, 0, &arg);
}

// str
bool mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2);
qstr mp_obj_str_get_qstr(mp_obj_t self_in); // use this if you will anyway convert the string to a qstr
const char *mp_obj_str_get_str(mp_obj_t self_in); // use this only if you need the string to be null terminated
const char *mp_obj_str_get_data(mp_obj_t self_in, size_t *len);
mp_obj_t mp_obj_str_intern(mp_obj_t str);
mp_obj_t mp_obj_str_intern_checked(mp_obj_t obj);
void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, bool is_bytes);

#if 0 /* disabled by -frewrite-includes */
#if MICROPY_PY_BUILTINS_FLOAT
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 844 "../../py/obj.h"
// float
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 846 "../../py/obj.h"
static inline float mp_obj_get_float_to_f(mp_obj_t o) {
    return mp_obj_get_float(o);
}

static inline double mp_obj_get_float_to_d(mp_obj_t o) {
    return (double)mp_obj_get_float(o);
}

static inline mp_obj_t mp_obj_new_float_from_f(float o) {
    return mp_obj_new_float(o);
}

static inline mp_obj_t mp_obj_new_float_from_d(double o) {
    return mp_obj_new_float((mp_float_t)o);
}
#if 0 /* disabled by -frewrite-includes */
#if 0
#elif MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE
#endif
#endif /* disabled by -frewrite-includes */
#elif 0 /* evaluated by -frewrite-includes */
# 862 "../../py/obj.h"
static inline float mp_obj_get_float_to_f(mp_obj_t o) {
    return (float)mp_obj_get_float(o);
}

static inline double mp_obj_get_float_to_d(mp_obj_t o) {
    return mp_obj_get_float(o);
}

static inline mp_obj_t mp_obj_new_float_from_f(float o) {
    return mp_obj_new_float((mp_float_t)o);
}

static inline mp_obj_t mp_obj_new_float_from_d(double o) {
    return mp_obj_new_float(o);
}
#endif
# 878 "../../py/obj.h"
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_FLOAT_HIGH_QUALITY_HASH
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 879 "../../py/obj.h"
mp_int_t mp_float_hash(mp_float_t val);
#else
# 881 "../../py/obj.h"
static inline mp_int_t mp_float_hash(mp_float_t val) {
    return (mp_int_t)val;
}
#endif
# 885 "../../py/obj.h"
mp_obj_t mp_obj_float_binary_op(mp_binary_op_t op, mp_float_t lhs_val, mp_obj_t rhs); // can return MP_OBJ_NULL if op not supported

// complex
void mp_obj_complex_get(mp_obj_t self_in, mp_float_t *real, mp_float_t *imag);
mp_obj_t mp_obj_complex_binary_op(mp_binary_op_t op, mp_float_t lhs_real, mp_float_t lhs_imag, mp_obj_t rhs_in); // can return MP_OBJ_NULL if op not supported
#else
# 891 "../../py/obj.h"
#define mp_obj_is_float(o) (false)
#endif
# 893 "../../py/obj.h"

// tuple
void mp_obj_tuple_get(mp_obj_t self_in, size_t *len, mp_obj_t **items);
void mp_obj_tuple_del(mp_obj_t self_in);
mp_int_t mp_obj_tuple_hash(mp_obj_t self_in);

// list
mp_obj_t mp_obj_list_append(mp_obj_t self_in, mp_obj_t arg);
mp_obj_t mp_obj_list_remove(mp_obj_t self_in, mp_obj_t value);
void mp_obj_list_get(mp_obj_t self_in, size_t *len, mp_obj_t **items);
void mp_obj_list_set_len(mp_obj_t self_in, size_t len);
void mp_obj_list_store(mp_obj_t self_in, mp_obj_t index, mp_obj_t value);
mp_obj_t mp_obj_list_sort(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs);

// dict
typedef struct _mp_obj_dict_t {
    mp_obj_base_t base;
    mp_map_t map;
} mp_obj_dict_t;
mp_obj_t mp_obj_dict_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args);
void mp_obj_dict_init(mp_obj_dict_t *dict, size_t n_args);
size_t mp_obj_dict_len(mp_obj_t self_in);
mp_obj_t mp_obj_dict_get(mp_obj_t self_in, mp_obj_t index);
mp_obj_t mp_obj_dict_store(mp_obj_t self_in, mp_obj_t key, mp_obj_t value);
mp_obj_t mp_obj_dict_delete(mp_obj_t self_in, mp_obj_t key);
mp_obj_t mp_obj_dict_copy(mp_obj_t self_in);
static inline mp_map_t *mp_obj_dict_get_map(mp_obj_t dict) {
    return &((mp_obj_dict_t *)MP_OBJ_TO_PTR(dict))->map;
}

// set
void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item);

// slice indexes resolved to particular sequence
typedef struct {
    mp_int_t start;
    mp_int_t stop;
    mp_int_t step;
} mp_bound_slice_t;

// slice
typedef struct _mp_obj_slice_t {
    mp_obj_base_t base;
    mp_obj_t start;
    mp_obj_t stop;
    mp_obj_t step;
} mp_obj_slice_t;
void mp_obj_slice_indices(mp_obj_t self_in, mp_int_t length, mp_bound_slice_t *result);

// functions

typedef struct _mp_obj_fun_builtin_fixed_t {
    mp_obj_base_t base;
    union {
        mp_fun_0_t _0;
        mp_fun_1_t _1;
        mp_fun_2_t _2;
        mp_fun_3_t _3;
    } fun;
} mp_obj_fun_builtin_fixed_t;

typedef struct _mp_obj_fun_builtin_var_t {
    mp_obj_base_t base;
    uint32_t sig; // see MP_OBJ_FUN_MAKE_SIG
    union {
        mp_fun_var_t var;
        mp_fun_kw_t kw;
    } fun;
} mp_obj_fun_builtin_var_t;

qstr mp_obj_fun_get_name(mp_const_obj_t fun);
qstr mp_obj_code_get_name(const byte *code_info);

mp_obj_t mp_identity(mp_obj_t self);
MP_DECLARE_CONST_FUN_OBJ_1(mp_identity_obj);
mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf);

// module
typedef struct _mp_obj_module_t {
    mp_obj_base_t base;
    mp_obj_dict_t *globals;
} mp_obj_module_t;
static inline mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t module) {
    return ((mp_obj_module_t *)MP_OBJ_TO_PTR(module))->globals;
}
// check if given module object is a package
bool mp_obj_is_package(mp_obj_t module);

// staticmethod and classmethod types; defined here so we can make const versions
// this structure is used for instances of both staticmethod and classmethod
typedef struct _mp_obj_static_class_method_t {
    mp_obj_base_t base;
    mp_obj_t fun;
} mp_obj_static_class_method_t;
typedef struct _mp_rom_obj_static_class_method_t {
    mp_obj_base_t base;
    mp_rom_obj_t fun;
} mp_rom_obj_static_class_method_t;

// property
const mp_obj_t *mp_obj_property_get(mp_obj_t self_in);

// sequence helpers

void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest);
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_PY_BUILTINS_SLICE
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 999 "../../py/obj.h"
bool mp_seq_get_fast_slice_indexes(mp_uint_t len, mp_obj_t slice, mp_bound_slice_t *indexes);
#endif
# 1001 "../../py/obj.h"
#define mp_seq_copy(dest, src, len, item_t) memcpy(dest, src, len * sizeof(item_t))
#define mp_seq_cat(dest, src1, len1, src2, len2, item_t) { memcpy(dest, src1, (len1) * sizeof(item_t)); memcpy(dest + (len1), src2, (len2) * sizeof(item_t)); }
bool mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2);
bool mp_seq_cmp_objs(mp_uint_t op, const mp_obj_t *items1, size_t len1, const mp_obj_t *items2, size_t len2);
mp_obj_t mp_seq_index_obj(const mp_obj_t *items, size_t len, size_t n_args, const mp_obj_t *args);
mp_obj_t mp_seq_count_obj(const mp_obj_t *items, size_t len, mp_obj_t value);
mp_obj_t mp_seq_extract_slice(size_t len, const mp_obj_t *seq, mp_bound_slice_t *indexes);

// Helper to clear stale pointers from allocated, but unused memory, to preclude GC problems
#define mp_seq_clear(start, len, alloc_len, item_sz) memset((byte *)(start) + (len) * (item_sz), 0, ((alloc_len) - (len)) * (item_sz))

// Note: dest and slice regions may overlap
#define mp_seq_replace_slice_no_grow(dest, dest_len, beg, end, slice, slice_len, item_sz) \
    memmove(((char *)dest) + (beg) * (item_sz), slice, slice_len * (item_sz)); \
    memmove(((char *)dest) + (beg + slice_len) * (item_sz), ((char *)dest) + (end) * (item_sz), (dest_len - end) * (item_sz));

// Note: dest and slice regions may overlap
#define mp_seq_replace_slice_grow_inplace(dest, dest_len, beg, end, slice, slice_len, len_adj, item_sz) \
    memmove(((char *)dest) + (beg + slice_len) * (item_sz), ((char *)dest) + (end) * (item_sz), ((dest_len) + (len_adj) - ((beg) + (slice_len))) * (item_sz)); \
    memmove(((char *)dest) + (beg) * (item_sz), slice, slice_len * (item_sz));

// Provide translation for legacy API
#define MP_OBJ_IS_SMALL_INT mp_obj_is_small_int
#define MP_OBJ_IS_QSTR mp_obj_is_qstr
#define MP_OBJ_IS_OBJ mp_obj_is_obj
#define MP_OBJ_IS_INT mp_obj_is_int
#define MP_OBJ_IS_TYPE mp_obj_is_type
#define MP_OBJ_IS_STR mp_obj_is_str
#define MP_OBJ_IS_STR_OR_BYTES mp_obj_is_str_or_bytes
#define MP_OBJ_IS_FUN mp_obj_is_fun
#define MP_MAP_SLOT_IS_FILLED mp_map_slot_is_filled
#define MP_SET_SLOT_IS_FILLED mp_set_slot_is_filled

#endif // MICROPY_INCLUDED_PY_OBJ_H
# 1035 "../../py/obj.h"
# 36 "../../py/mpstate.h" 2
#if 0 /* expanded by -frewrite-includes */
#include "py/objlist.h"
#endif /* expanded by -frewrite-includes */
# 36 "../../py/mpstate.h"
# 1 "../../py/objlist.h" 1
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef MICROPY_INCLUDED_PY_OBJLIST_H
#define MICROPY_INCLUDED_PY_OBJLIST_H

#if 0 /* expanded by -frewrite-includes */
#include "py/obj.h"
#endif /* expanded by -frewrite-includes */
# 29 "../../py/objlist.h"
# 30 "../../py/objlist.h"

typedef struct _mp_obj_list_t {
    mp_obj_base_t base;
    size_t alloc;
    size_t len;
    mp_obj_t *items;
} mp_obj_list_t;

void mp_obj_list_init(mp_obj_list_t *o, size_t n);

#endif // MICROPY_INCLUDED_PY_OBJLIST_H
# 41 "../../py/objlist.h"
# 37 "../../py/mpstate.h" 2
#if 0 /* expanded by -frewrite-includes */
#include "py/objexcept.h"
#endif /* expanded by -frewrite-includes */
# 37 "../../py/mpstate.h"
# 1 "../../py/objexcept.h" 1
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef MICROPY_INCLUDED_PY_OBJEXCEPT_H
#define MICROPY_INCLUDED_PY_OBJEXCEPT_H

#if 0 /* expanded by -frewrite-includes */
#include "py/obj.h"
#endif /* expanded by -frewrite-includes */
# 29 "../../py/objexcept.h"
# 30 "../../py/objexcept.h"
#if 0 /* expanded by -frewrite-includes */
#include "py/objtuple.h"
#endif /* expanded by -frewrite-includes */
# 30 "../../py/objexcept.h"
# 1 "../../py/objtuple.h" 1
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef MICROPY_INCLUDED_PY_OBJTUPLE_H
#define MICROPY_INCLUDED_PY_OBJTUPLE_H

#if 0 /* expanded by -frewrite-includes */
#include "py/obj.h"
#endif /* expanded by -frewrite-includes */
# 29 "../../py/objtuple.h"
# 30 "../../py/objtuple.h"

typedef struct _mp_obj_tuple_t {
    mp_obj_base_t base;
    size_t len;
    mp_obj_t items[];
} mp_obj_tuple_t;

typedef struct _mp_rom_obj_tuple_t {
    mp_obj_base_t base;
    size_t len;
    mp_rom_obj_t items[];
} mp_rom_obj_tuple_t;

void mp_obj_tuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind);
mp_obj_t mp_obj_tuple_unary_op(mp_unary_op_t op, mp_obj_t self_in);
mp_obj_t mp_obj_tuple_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs);
mp_obj_t mp_obj_tuple_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value);
mp_obj_t mp_obj_tuple_getiter(mp_obj_t o_in, mp_obj_iter_buf_t *iter_buf);

extern const mp_obj_type_t mp_type_attrtuple;

#define MP_DEFINE_ATTRTUPLE(tuple_obj_name, fields, nitems, ...) \
    const mp_rom_obj_tuple_t tuple_obj_name = { \
        .base = {&mp_type_attrtuple}, \
        .len = nitems, \
        .items = { __VA_ARGS__, MP_ROM_PTR((void *)fields) } \
    }

#if 0 /* disabled by -frewrite-includes */
#if MICROPY_PY_COLLECTIONS
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 59 "../../py/objtuple.h"
void mp_obj_attrtuple_print_helper(const mp_print_t *print, const qstr *fields, mp_obj_tuple_t *o);
#endif
# 61 "../../py/objtuple.h"

mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items);

#endif // MICROPY_INCLUDED_PY_OBJTUPLE_H
# 65 "../../py/objtuple.h"
# 31 "../../py/objexcept.h" 2

typedef struct _mp_obj_exception_t {
    mp_obj_base_t base;
    size_t traceback_alloc : (8 * sizeof(size_t) / 2);
    size_t traceback_len : (8 * sizeof(size_t) / 2);
    size_t *traceback_data;
    mp_obj_tuple_t *args;
} mp_obj_exception_t;

void mp_obj_exception_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind);
void mp_obj_exception_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest);

#define MP_DEFINE_EXCEPTION(exc_name, base_name) \
    const mp_obj_type_t mp_type_##exc_name = { \
        { &mp_type_type }, \
        .name = MP_QSTR_##exc_name, \
        .print = mp_obj_exception_print, \
        .make_new = mp_obj_exception_make_new, \
        .attr = mp_obj_exception_attr, \
        .parent = &mp_type_##base_name, \
    };

#endif // MICROPY_INCLUDED_PY_OBJEXCEPT_H
# 54 "../../py/objexcept.h"
# 38 "../../py/mpstate.h" 2

// This file contains structures defining the state of the MicroPython
// memory system, runtime and virtual machine.  The state is a global
// variable, but in the future it is hoped that the state can become local.

// This structure contains dynamic configuration for the compiler.
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_DYNAMIC_COMPILER
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 45 "../../py/mpstate.h"
typedef struct mp_dynamic_compiler_t {
    uint8_t small_int_bits; // must be <= host small_int_bits
    bool py_builtins_str_unicode;
    uint8_t native_arch;
    uint8_t nlr_buf_num_regs;
} mp_dynamic_compiler_t;
extern mp_dynamic_compiler_t mp_dynamic_compiler;
#endif
# 53 "../../py/mpstate.h"

// These are the values for sched_state
#define MP_SCHED_IDLE (1)
#define MP_SCHED_LOCKED (-1)
#define MP_SCHED_PENDING (0) // 0 so it's a quick check in the VM

typedef struct _mp_sched_item_t {
    mp_obj_t func;
    mp_obj_t arg;
} mp_sched_item_t;

// This structure hold information about the memory allocation system.
typedef struct _mp_state_mem_t {
   
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_MEM_STATS
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 67 "../../py/mpstate.h"
    size_t total_bytes_allocated;
    size_t current_bytes_allocated;
    size_t peak_bytes_allocated;
    #endif
# 71 "../../py/mpstate.h"

    byte *gc_alloc_table_start;
    size_t gc_alloc_table_byte_len;
   
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_ENABLE_FINALISER
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 75 "../../py/mpstate.h"
    byte *gc_finaliser_table_start;
    #endif
# 77 "../../py/mpstate.h"
    byte *gc_pool_start;
    byte *gc_pool_end;

    int gc_stack_overflow;
    MICROPY_GC_STACK_ENTRY_TYPE gc_stack[MICROPY_ALLOC_GC_STACK_SIZE];

    // This variable controls auto garbage collection.  If set to 0 then the
    // GC won't automatically run when gc_alloc can't find enough blocks.  But
    // you can still allocate/free memory and also explicitly call gc_collect.
    uint16_t gc_auto_collect_enabled;

   
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_GC_ALLOC_THRESHOLD
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 89 "../../py/mpstate.h"
    size_t gc_alloc_amount;
    size_t gc_alloc_threshold;
    #endif
# 92 "../../py/mpstate.h"

    size_t gc_last_free_atb_index;

   
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_PY_GC_COLLECT_RETVAL
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 96 "../../py/mpstate.h"
    size_t gc_collected;
    #endif
# 98 "../../py/mpstate.h"

   
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_PY_THREAD && !MICROPY_PY_THREAD_GIL
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 100 "../../py/mpstate.h"
    // This is a global mutex used to make the GC thread-safe.
    mp_thread_mutex_t gc_mutex;
    #endif
# 103 "../../py/mpstate.h"
} mp_state_mem_t;

// This structure hold runtime and VM information.  It includes a section
// which contains root pointers that must be scanned by the GC.
typedef struct _mp_state_vm_t {
    //
    // CONTINUE ROOT POINTER SECTION
    // This must start at the start of this structure and follows
    // the state in the mp_state_thread_t structure, continuing
    // the root pointer section from there.
    //

    qstr_pool_t *last_pool;

    // non-heap memory for creating an exception if we can't allocate RAM
    mp_obj_exception_t mp_emergency_exception_obj;

    // memory for exception arguments if we can't allocate RAM
   
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 122 "../../py/mpstate.h"
   
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE > 0
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 123 "../../py/mpstate.h"
    // statically allocated buf (needs to be aligned to mp_obj_t)
    mp_obj_t mp_emergency_exception_buf[MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE / sizeof(mp_obj_t)];
    #else
# 126 "../../py/mpstate.h"
    // dynamically allocated buf
    byte *mp_emergency_exception_buf;
    #endif
# 129 "../../py/mpstate.h"
    #endif
# 130 "../../py/mpstate.h"

   
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_KBD_EXCEPTION
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 132 "../../py/mpstate.h"
    // exception object of type KeyboardInterrupt
    mp_obj_exception_t mp_kbd_exception;
    #endif
# 135 "../../py/mpstate.h"

    // dictionary with loaded modules (may be exposed as sys.modules)
    mp_obj_dict_t mp_loaded_modules_dict;

   
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_ENABLE_SCHEDULER
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 140 "../../py/mpstate.h"
    mp_sched_item_t sched_queue[MICROPY_SCHEDULER_DEPTH];
    #endif
# 142 "../../py/mpstate.h"

    // current exception being handled, for sys.exc_info()
   
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_PY_SYS_EXC_INFO
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 145 "../../py/mpstate.h"
    mp_obj_base_t *cur_exception;
    #endif
# 147 "../../py/mpstate.h"

   
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_PY_SYS_ATEXIT
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 149 "../../py/mpstate.h"
    // exposed through sys.atexit function
    mp_obj_t sys_exitfunc;
    #endif
# 152 "../../py/mpstate.h"

    // dictionary for the __main__ module
    mp_obj_dict_t dict_main;

    // these two lists must be initialised per port, after the call to mp_init
    mp_obj_list_t mp_sys_path_obj;
    mp_obj_list_t mp_sys_argv_obj;

    // dictionary for overridden builtins
   
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_CAN_OVERRIDE_BUILTINS
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 162 "../../py/mpstate.h"
    mp_obj_dict_t *mp_module_builtins_override_dict;
    #endif
# 164 "../../py/mpstate.h"

   
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_PERSISTENT_CODE_TRACK_RELOC_CODE
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 166 "../../py/mpstate.h"
    // An mp_obj_list_t that tracks relocated native code to prevent the GC from reclaiming them.
    mp_obj_t track_reloc_code_list;
    #endif
# 169 "../../py/mpstate.h"

    // include any root pointers defined by a port
    MICROPY_PORT_ROOT_POINTERS

    // root pointers for extmod

   
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_REPL_EVENT_DRIVEN
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 176 "../../py/mpstate.h"
    vstr_t *repl_line;
    #endif
# 178 "../../py/mpstate.h"

   
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_PY_OS_DUPTERM
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 180 "../../py/mpstate.h"
    mp_obj_t dupterm_objs[MICROPY_PY_OS_DUPTERM];
    #endif
# 182 "../../py/mpstate.h"

   
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_PY_LWIP_SLIP
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 184 "../../py/mpstate.h"
    mp_obj_t lwip_slip_stream;
    #endif
# 186 "../../py/mpstate.h"

   
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_VFS
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 188 "../../py/mpstate.h"
    struct _mp_vfs_mount_t *vfs_cur;
    struct _mp_vfs_mount_t *vfs_mount_table;
    #endif
# 191 "../../py/mpstate.h"

   
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_PY_BLUETOOTH
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 193 "../../py/mpstate.h"
    mp_obj_t bluetooth;
    #endif
# 195 "../../py/mpstate.h"

    //
    // END ROOT POINTER SECTION
    ////////////////////////////////////////////////////////////

    // pointer and sizes to store interned string data
    // (qstr_last_chunk can be root pointer but is also stored in qstr pool)
    byte *qstr_last_chunk;
    size_t qstr_last_alloc;
    size_t qstr_last_used;

   
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_PY_THREAD && !MICROPY_PY_THREAD_GIL
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 207 "../../py/mpstate.h"
    // This is a global mutex used to make qstr interning thread-safe.
    mp_thread_mutex_t qstr_mutex;
    #endif
# 210 "../../py/mpstate.h"

   
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_ENABLE_COMPILER
#endif
#endif /* disabled by -frewrite-includes */
#if 1 /* evaluated by -frewrite-includes */
# 212 "../../py/mpstate.h"
    mp_uint_t mp_optimise_value;
   
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_EMIT_NATIVE
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 214 "../../py/mpstate.h"
    uint8_t default_emit_opt; // one of MP_EMIT_OPT_xxx
    #endif
# 216 "../../py/mpstate.h"
    #endif
# 217 "../../py/mpstate.h"

    // size of the emergency exception buf, if it's dynamically allocated
   
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF && MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE == 0
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 220 "../../py/mpstate.h"
    mp_int_t mp_emergency_exception_buf_size;
    #endif
# 222 "../../py/mpstate.h"

   
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_ENABLE_SCHEDULER
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 224 "../../py/mpstate.h"
    volatile int16_t sched_state;
    uint8_t sched_len;
    uint8_t sched_idx;
    #endif
# 228 "../../py/mpstate.h"

   
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_PY_THREAD_GIL
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 230 "../../py/mpstate.h"
    // This is a global mutex used to make the VM/runtime thread-safe.
    mp_thread_mutex_t gil_mutex;
    #endif
# 233 "../../py/mpstate.h"

   
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_OPT_MAP_LOOKUP_CACHE
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 235 "../../py/mpstate.h"
    // See mp_map_lookup.
    uint8_t map_lookup_cache[MICROPY_OPT_MAP_LOOKUP_CACHE_SIZE];
    #endif
# 238 "../../py/mpstate.h"
} mp_state_vm_t;

// This structure holds state that is specific to a given thread.
// Everything in this structure is scanned for root pointers.
typedef struct _mp_state_thread_t {
    // Stack top at the start of program
    char *stack_top;

   
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_STACK_CHECK
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 247 "../../py/mpstate.h"
    size_t stack_limit;
    #endif
# 249 "../../py/mpstate.h"

   
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_ENABLE_PYSTACK
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 251 "../../py/mpstate.h"
    uint8_t *pystack_start;
    uint8_t *pystack_end;
    uint8_t *pystack_cur;
    #endif
# 255 "../../py/mpstate.h"

    // Locking of the GC is done per thread.
    uint16_t gc_lock_depth;

    ////////////////////////////////////////////////////////////
    // START ROOT POINTER SECTION
    // Everything that needs GC scanning must start here, and
    // is followed by state in the mp_state_vm_t structure.
    //

    mp_obj_dict_t *dict_locals;
    mp_obj_dict_t *dict_globals;

    nlr_buf_t *nlr_top;

    // pending exception object (MP_OBJ_NULL if not pending)
    volatile mp_obj_t mp_pending_exception;

    // If MP_OBJ_STOP_ITERATION is propagated then this holds its argument.
    mp_obj_t stop_iteration_arg;

   
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_PY_SYS_SETTRACE
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 277 "../../py/mpstate.h"
    mp_obj_t prof_trace_callback;
    bool prof_callback_is_executing;
    struct _mp_code_state_t *current_code_state;
    #endif
# 281 "../../py/mpstate.h"
} mp_state_thread_t;

// This structure combines the above 3 structures.
// The order of the entries are important for root pointer scanning in the GC to work.
typedef struct _mp_state_ctx_t {
    mp_state_thread_t thread;
    mp_state_vm_t vm;
    mp_state_mem_t mem;
} mp_state_ctx_t;

extern mp_state_ctx_t mp_state_ctx;

#define MP_STATE_VM(x) (mp_state_ctx.vm.x)
#define MP_STATE_MEM(x) (mp_state_ctx.mem.x)
#define MP_STATE_MAIN_THREAD(x) (mp_state_ctx.thread.x)

#if 0 /* disabled by -frewrite-includes */
#if MICROPY_PY_THREAD
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 298 "../../py/mpstate.h"
extern mp_state_thread_t *mp_thread_get_state(void);
#define MP_STATE_THREAD(x) (mp_thread_get_state()->x)
#else
# 301 "../../py/mpstate.h"
#define MP_STATE_THREAD(x)  MP_STATE_MAIN_THREAD(x)
#endif
# 303 "../../py/mpstate.h"

#endif // MICROPY_INCLUDED_PY_MPSTATE_H
# 305 "../../py/mpstate.h"
# 30 "../../py/runtime.h" 2
#if 0 /* expanded by -frewrite-includes */
#include "py/pystack.h"
#endif /* expanded by -frewrite-includes */
# 30 "../../py/runtime.h"
# 1 "../../py/pystack.h" 1
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2017 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef MICROPY_INCLUDED_PY_PYSTACK_H
#define MICROPY_INCLUDED_PY_PYSTACK_H

#if 0 /* expanded by -frewrite-includes */
#include "py/mpstate.h"
#endif /* expanded by -frewrite-includes */
# 29 "../../py/pystack.h"
# 30 "../../py/pystack.h"

// Enable this debugging option to check that the amount of memory freed is
// consistent with amounts that were previously allocated.
#define MP_PYSTACK_DEBUG (0)

#if 0 /* disabled by -frewrite-includes */
#if MICROPY_ENABLE_PYSTACK
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 36 "../../py/pystack.h"

void mp_pystack_init(void *start, void *end);
void *mp_pystack_alloc(size_t n_bytes);

// This function can free multiple continuous blocks at once: just pass the
// pointer to the block that was allocated first and it and all subsequently
// allocated blocks will be freed.
static inline void mp_pystack_free(void *ptr) {
    assert((uint8_t *)ptr >= MP_STATE_THREAD(pystack_start));
    assert((uint8_t *)ptr <= MP_STATE_THREAD(pystack_cur));
   
#if 0 /* disabled by -frewrite-includes */
#if MP_PYSTACK_DEBUG
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 47 "../../py/pystack.h"
    size_t n_bytes_to_free = MP_STATE_THREAD(pystack_cur) - (uint8_t *)ptr;
    size_t n_bytes = *(size_t *)(MP_STATE_THREAD(pystack_cur) - MICROPY_PYSTACK_ALIGN);
    while (n_bytes < n_bytes_to_free) {
        n_bytes += *(size_t *)(MP_STATE_THREAD(pystack_cur) - n_bytes - MICROPY_PYSTACK_ALIGN);
    }
    if (n_bytes != n_bytes_to_free) {
        mp_printf(&mp_plat_print, "mp_pystack_free() failed: %u != %u\n", (uint)n_bytes_to_free,
            (uint)*(size_t *)(MP_STATE_THREAD(pystack_cur) - MICROPY_PYSTACK_ALIGN));
        assert(0);
    }
    #endif
# 58 "../../py/pystack.h"
    MP_STATE_THREAD(pystack_cur) = (uint8_t *)ptr;
}

static inline void mp_pystack_realloc(void *ptr, size_t n_bytes) {
    mp_pystack_free(ptr);
    mp_pystack_alloc(n_bytes);
}

static inline size_t mp_pystack_usage(void) {
    return MP_STATE_THREAD(pystack_cur) - MP_STATE_THREAD(pystack_start);
}

static inline size_t mp_pystack_limit(void) {
    return MP_STATE_THREAD(pystack_end) - MP_STATE_THREAD(pystack_start);
}

#endif
# 75 "../../py/pystack.h"

#if 0 /* disabled by -frewrite-includes */
#if !MICROPY_ENABLE_PYSTACK
#endif
#endif /* disabled by -frewrite-includes */
#if 1 /* evaluated by -frewrite-includes */
# 77 "../../py/pystack.h"

#define mp_local_alloc(n_bytes) alloca(n_bytes)

static inline void mp_local_free(void *ptr) {
    (void)ptr;
}

static inline void *mp_nonlocal_alloc(size_t n_bytes) {
    return m_new(uint8_t, n_bytes);
}

static inline void *mp_nonlocal_realloc(void *ptr, size_t old_n_bytes, size_t new_n_bytes) {
    return m_renew(uint8_t, ptr, old_n_bytes, new_n_bytes);
}

static inline void mp_nonlocal_free(void *ptr, size_t n_bytes) {
    m_del(uint8_t, ptr, n_bytes);
}

#else
# 97 "../../py/pystack.h"

static inline void *mp_local_alloc(size_t n_bytes) {
    return mp_pystack_alloc(n_bytes);
}

static inline void mp_local_free(void *ptr) {
    mp_pystack_free(ptr);
}

static inline void *mp_nonlocal_alloc(size_t n_bytes) {
    return mp_pystack_alloc(n_bytes);
}

static inline void *mp_nonlocal_realloc(void *ptr, size_t old_n_bytes, size_t new_n_bytes) {
    (void)old_n_bytes;
    mp_pystack_realloc(ptr, new_n_bytes);
    return ptr;
}

static inline void mp_nonlocal_free(void *ptr, size_t n_bytes) {
    (void)n_bytes;
    mp_pystack_free(ptr);
}

#endif
# 122 "../../py/pystack.h"

#endif // MICROPY_INCLUDED_PY_PYSTACK_H
# 124 "../../py/pystack.h"
# 31 "../../py/runtime.h" 2

typedef enum {
    MP_VM_RETURN_NORMAL,
    MP_VM_RETURN_YIELD,
    MP_VM_RETURN_EXCEPTION,
} mp_vm_return_kind_t;

typedef enum {
    MP_ARG_BOOL      = 0x001,
    MP_ARG_INT       = 0x002,
    MP_ARG_OBJ       = 0x003,
    MP_ARG_KIND_MASK = 0x0ff,
    MP_ARG_REQUIRED  = 0x100,
    MP_ARG_KW_ONLY   = 0x200,
} mp_arg_flag_t;

typedef union _mp_arg_val_t {
    bool u_bool;
    mp_int_t u_int;
    mp_obj_t u_obj;
    mp_rom_obj_t u_rom_obj;
} mp_arg_val_t;

typedef struct _mp_arg_t {
    uint16_t qst;
    uint16_t flags;
    mp_arg_val_t defval;
} mp_arg_t;

// Tables mapping operator enums to qstrs, defined in objtype.c
extern const byte mp_unary_op_method_name[];
extern const byte mp_binary_op_method_name[];

void mp_init(void);
void mp_deinit(void);

void mp_sched_exception(mp_obj_t exc);
void mp_sched_keyboard_interrupt(void);
void mp_handle_pending(bool raise_exc);
void mp_handle_pending_tail(mp_uint_t atomic_state);

#if 0 /* disabled by -frewrite-includes */
#if MICROPY_ENABLE_SCHEDULER
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 73 "../../py/runtime.h"
void mp_sched_lock(void);
void mp_sched_unlock(void);
#define mp_sched_num_pending() (MP_STATE_VM(sched_len))
bool mp_sched_schedule(mp_obj_t function, mp_obj_t arg);
#endif
# 78 "../../py/runtime.h"

// extra printing method specifically for mp_obj_t's which are integral type
int mp_print_mp_int(const mp_print_t *print, mp_obj_t x, int base, int base_char, int flags, char fill, int width, int prec);

void mp_arg_check_num_sig(size_t n_args, size_t n_kw, uint32_t sig);
static inline void mp_arg_check_num(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, bool takes_kw) {
    mp_arg_check_num_sig(n_args, n_kw, MP_OBJ_FUN_MAKE_SIG(n_args_min, n_args_max, takes_kw));
}
void mp_arg_parse_all(size_t n_pos, const mp_obj_t *pos, mp_map_t *kws, size_t n_allowed, const mp_arg_t *allowed, mp_arg_val_t *out_vals);
void mp_arg_parse_all_kw_array(size_t n_pos, size_t n_kw, const mp_obj_t *args, size_t n_allowed, const mp_arg_t *allowed, mp_arg_val_t *out_vals);
NORETURN void mp_arg_error_terse_mismatch(void);
NORETURN void mp_arg_error_unimpl_kw(void);

static inline mp_obj_dict_t *mp_locals_get(void) {
    return MP_STATE_THREAD(dict_locals);
}
static inline void mp_locals_set(mp_obj_dict_t *d) {
    MP_STATE_THREAD(dict_locals) = d;
}
static inline mp_obj_dict_t *mp_globals_get(void) {
    return MP_STATE_THREAD(dict_globals);
}
static inline void mp_globals_set(mp_obj_dict_t *d) {
    MP_STATE_THREAD(dict_globals) = d;
}

mp_obj_t mp_load_name(qstr qst);
mp_obj_t mp_load_global(qstr qst);
mp_obj_t mp_load_build_class(void);
void mp_store_name(qstr qst, mp_obj_t obj);
void mp_store_global(qstr qst, mp_obj_t obj);
void mp_delete_name(qstr qst);
void mp_delete_global(qstr qst);

mp_obj_t mp_unary_op(mp_unary_op_t op, mp_obj_t arg);
mp_obj_t mp_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs);

mp_obj_t mp_call_function_0(mp_obj_t fun);
mp_obj_t mp_call_function_1(mp_obj_t fun, mp_obj_t arg);
mp_obj_t mp_call_function_2(mp_obj_t fun, mp_obj_t arg1, mp_obj_t arg2);
mp_obj_t mp_call_function_n_kw(mp_obj_t fun, size_t n_args, size_t n_kw, const mp_obj_t *args);
mp_obj_t mp_call_method_n_kw(size_t n_args, size_t n_kw, const mp_obj_t *args);
mp_obj_t mp_call_method_n_kw_var(bool have_self, size_t n_args_n_kw, const mp_obj_t *args);
mp_obj_t mp_call_method_self_n_kw(mp_obj_t meth, mp_obj_t self, size_t n_args, size_t n_kw, const mp_obj_t *args);
// Call function and catch/dump exception - for Python callbacks from C code
// (return MP_OBJ_NULL in case of exception).
mp_obj_t mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg);
mp_obj_t mp_call_function_2_protected(mp_obj_t fun, mp_obj_t arg1, mp_obj_t arg2);

typedef struct _mp_call_args_t {
    mp_obj_t fun;
    size_t n_args, n_kw, n_alloc;
    mp_obj_t *args;
} mp_call_args_t;

#if 0 /* disabled by -frewrite-includes */
#if MICROPY_STACKLESS
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 134 "../../py/runtime.h"
// Takes arguments which are the most general mix of Python arg types, and
// prepares argument array suitable for passing to ->call() method of a
// function object (and mp_call_function_n_kw()).
// (Only needed in stackless mode.)
void mp_call_prepare_args_n_kw_var(bool have_self, size_t n_args_n_kw, const mp_obj_t *args, mp_call_args_t *out_args);
#endif
# 140 "../../py/runtime.h"

void mp_unpack_sequence(mp_obj_t seq, size_t num, mp_obj_t *items);
void mp_unpack_ex(mp_obj_t seq, size_t num, mp_obj_t *items);
mp_obj_t mp_store_map(mp_obj_t map, mp_obj_t key, mp_obj_t value);
mp_obj_t mp_load_attr(mp_obj_t base, qstr attr);
void mp_convert_member_lookup(mp_obj_t obj, const mp_obj_type_t *type, mp_obj_t member, mp_obj_t *dest);
void mp_load_method(mp_obj_t base, qstr attr, mp_obj_t *dest);
void mp_load_method_maybe(mp_obj_t base, qstr attr, mp_obj_t *dest);
void mp_load_method_protected(mp_obj_t obj, qstr attr, mp_obj_t *dest, bool catch_all_exc);
void mp_load_super_method(qstr attr, mp_obj_t *dest);
void mp_store_attr(mp_obj_t base, qstr attr, mp_obj_t val);

mp_obj_t mp_getiter(mp_obj_t o, mp_obj_iter_buf_t *iter_buf);
mp_obj_t mp_iternext_allow_raise(mp_obj_t o); // may return MP_OBJ_STOP_ITERATION instead of raising StopIteration()
mp_obj_t mp_iternext(mp_obj_t o); // will always return MP_OBJ_STOP_ITERATION instead of raising StopIteration(...)
mp_vm_return_kind_t mp_resume(mp_obj_t self_in, mp_obj_t send_value, mp_obj_t throw_value, mp_obj_t *ret_val);

static inline mp_obj_t mp_make_stop_iteration(mp_obj_t o) {
    MP_STATE_THREAD(stop_iteration_arg) = o;
    return MP_OBJ_STOP_ITERATION;
}

mp_obj_t mp_make_raise_obj(mp_obj_t o);

mp_obj_t mp_import_name(qstr name, mp_obj_t fromlist, mp_obj_t level);
mp_obj_t mp_import_from(mp_obj_t module, qstr name);
void mp_import_all(mp_obj_t module);

#if 0 /* disabled by -frewrite-includes */
#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_NONE
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 169 "../../py/runtime.h"
NORETURN void mp_raise_type(const mp_obj_type_t *exc_type);
NORETURN void mp_raise_ValueError_no_msg(void);
NORETURN void mp_raise_TypeError_no_msg(void);
NORETURN void mp_raise_NotImplementedError_no_msg(void);
#define mp_raise_msg(exc_type, msg) mp_raise_type(exc_type)
#define mp_raise_msg_varg(exc_type, ...) mp_raise_type(exc_type)
#define mp_raise_ValueError(msg) mp_raise_ValueError_no_msg()
#define mp_raise_TypeError(msg) mp_raise_TypeError_no_msg()
#define mp_raise_NotImplementedError(msg) mp_raise_NotImplementedError_no_msg()
#else
# 179 "../../py/runtime.h"
#define mp_raise_type(exc_type) mp_raise_msg(exc_type, NULL)
NORETURN void mp_raise_msg(const mp_obj_type_t *exc_type, mp_rom_error_text_t msg);
NORETURN void mp_raise_msg_varg(const mp_obj_type_t *exc_type, mp_rom_error_text_t fmt, ...);
NORETURN void mp_raise_ValueError(mp_rom_error_text_t msg);
NORETURN void mp_raise_TypeError(mp_rom_error_text_t msg);
NORETURN void mp_raise_NotImplementedError(mp_rom_error_text_t msg);
#endif
# 186 "../../py/runtime.h"

NORETURN void mp_raise_type_arg(const mp_obj_type_t *exc_type, mp_obj_t arg);
NORETURN void mp_raise_StopIteration(mp_obj_t arg);
NORETURN void mp_raise_OSError(int errno_);
NORETURN void mp_raise_recursion_depth(void);

#if 0 /* disabled by -frewrite-includes */
#if MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 193 "../../py/runtime.h"
#undef mp_check_self
#define mp_check_self(pred)
#else
# 196 "../../py/runtime.h"
// A port may define to raise TypeError for example
#ifndef mp_check_self
#define mp_check_self(pred) assert(pred)
#endif
# 200 "../../py/runtime.h"
#endif
# 201 "../../py/runtime.h"

// helper functions for native/viper code
int mp_native_type_from_qstr(qstr qst);
mp_uint_t mp_native_from_obj(mp_obj_t obj, mp_uint_t type);
mp_obj_t mp_native_to_obj(mp_uint_t val, mp_uint_t type);

#define mp_sys_path (MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_sys_path_obj)))
#define mp_sys_argv (MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_sys_argv_obj)))

#if 0 /* disabled by -frewrite-includes */
#if MICROPY_WARNINGS
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 211 "../../py/runtime.h"
#ifndef mp_warning
void mp_warning(const char *category, const char *msg, ...);
#endif
# 214 "../../py/runtime.h"
#else
# 215 "../../py/runtime.h"
#define mp_warning(...)
#endif
# 217 "../../py/runtime.h"

#endif // MICROPY_INCLUDED_PY_RUNTIME_H
# 219 "../../py/runtime.h"
# 34 "../../py/gc.c" 2

#if 0 /* disabled by -frewrite-includes */
#if MICROPY_ENABLE_GC
#endif
#endif /* disabled by -frewrite-includes */
#if 1 /* evaluated by -frewrite-includes */
# 36 "../../py/gc.c"

#if 0 /* disabled by -frewrite-includes */
#if MICROPY_DEBUG_VERBOSE // print debugging info
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 38 "../../py/gc.c"
#define DEBUG_PRINT (1)
#define DEBUG_printf DEBUG_printf
#else // don't print debugging info
# 41 "../../py/gc.c"
#define DEBUG_PRINT (0)
#define DEBUG_printf(...) (void)0
#endif
# 44 "../../py/gc.c"

// make this 1 to dump the heap each time it changes
#define EXTENSIVE_HEAP_PROFILING (0)

// make this 1 to zero out swept memory to more eagerly
// detect untraced object still in use
#define CLEAR_ON_SWEEP (0)

#define WORDS_PER_BLOCK ((MICROPY_BYTES_PER_GC_BLOCK) / MP_BYTES_PER_OBJ_WORD)
#define BYTES_PER_BLOCK (MICROPY_BYTES_PER_GC_BLOCK)

// ATB = allocation table byte
// 0b00 = FREE -- free block
// 0b01 = HEAD -- head of a chain of blocks
// 0b10 = TAIL -- in the tail of a chain of blocks
// 0b11 = MARK -- marked head block

#define AT_FREE (0)
#define AT_HEAD (1)
#define AT_TAIL (2)
#define AT_MARK (3)

#define BLOCKS_PER_ATB (4)
#define ATB_MASK_0 (0x03)
#define ATB_MASK_1 (0x0c)
#define ATB_MASK_2 (0x30)
#define ATB_MASK_3 (0xc0)

#define ATB_0_IS_FREE(a) (((a) & ATB_MASK_0) == 0)
#define ATB_1_IS_FREE(a) (((a) & ATB_MASK_1) == 0)
#define ATB_2_IS_FREE(a) (((a) & ATB_MASK_2) == 0)
#define ATB_3_IS_FREE(a) (((a) & ATB_MASK_3) == 0)

#define BLOCK_SHIFT(block) (2 * ((block) & (BLOCKS_PER_ATB - 1)))
#define ATB_GET_KIND(block) ((MP_STATE_MEM(gc_alloc_table_start)[(block) / BLOCKS_PER_ATB] >> BLOCK_SHIFT(block)) & 3)
#define ATB_ANY_TO_FREE(block) do { MP_STATE_MEM(gc_alloc_table_start)[(block) / BLOCKS_PER_ATB] &= (~(AT_MARK << BLOCK_SHIFT(block))); } while (0)
#define ATB_FREE_TO_HEAD(block) do { MP_STATE_MEM(gc_alloc_table_start)[(block) / BLOCKS_PER_ATB] |= (AT_HEAD << BLOCK_SHIFT(block)); } while (0)
#define ATB_FREE_TO_TAIL(block) do { MP_STATE_MEM(gc_alloc_table_start)[(block) / BLOCKS_PER_ATB] |= (AT_TAIL << BLOCK_SHIFT(block)); } while (0)
#define ATB_HEAD_TO_MARK(block) do { MP_STATE_MEM(gc_alloc_table_start)[(block) / BLOCKS_PER_ATB] |= (AT_MARK << BLOCK_SHIFT(block)); } while (0)
#define ATB_MARK_TO_HEAD(block) do { MP_STATE_MEM(gc_alloc_table_start)[(block) / BLOCKS_PER_ATB] &= (~(AT_TAIL << BLOCK_SHIFT(block))); } while (0)

#define BLOCK_FROM_PTR(ptr) (((byte *)(ptr) - MP_STATE_MEM(gc_pool_start)) / BYTES_PER_BLOCK)
#define PTR_FROM_BLOCK(block) (((block) * BYTES_PER_BLOCK + (uintptr_t)MP_STATE_MEM(gc_pool_start)))
#define ATB_FROM_BLOCK(bl) ((bl) / BLOCKS_PER_ATB)

#if 0 /* disabled by -frewrite-includes */
#if MICROPY_ENABLE_FINALISER
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 90 "../../py/gc.c"
// FTB = finaliser table byte
// if set, then the corresponding block may have a finaliser

#define BLOCKS_PER_FTB (8)

#define FTB_GET(block) ((MP_STATE_MEM(gc_finaliser_table_start)[(block) / BLOCKS_PER_FTB] >> ((block) & 7)) & 1)
#define FTB_SET(block) do { MP_STATE_MEM(gc_finaliser_table_start)[(block) / BLOCKS_PER_FTB] |= (1 << ((block) & 7)); } while (0)
#define FTB_CLEAR(block) do { MP_STATE_MEM(gc_finaliser_table_start)[(block) / BLOCKS_PER_FTB] &= (~(1 << ((block) & 7))); } while (0)
#endif
# 99 "../../py/gc.c"

#if 0 /* disabled by -frewrite-includes */
#if MICROPY_PY_THREAD && !MICROPY_PY_THREAD_GIL
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 101 "../../py/gc.c"
#define GC_ENTER() mp_thread_mutex_lock(&MP_STATE_MEM(gc_mutex), 1)
#define GC_EXIT() mp_thread_mutex_unlock(&MP_STATE_MEM(gc_mutex))
#else
# 104 "../../py/gc.c"
#define GC_ENTER()
#define GC_EXIT()
#endif
# 107 "../../py/gc.c"

// TODO waste less memory; currently requires that all entries in alloc_table have a corresponding block in pool
void gc_init(void *start, void *end) {
    // align end pointer on block boundary
    end = (void *)((uintptr_t)end & (~(BYTES_PER_BLOCK - 1)));
    DEBUG_printf("Initializing GC heap: %p..%p = " UINT_FMT " bytes\n", start, end, (byte *)end - (byte *)start);

    // calculate parameters for GC (T=total, A=alloc table, F=finaliser table, P=pool; all in bytes):
    // T = A + F + P
    //     F = A * BLOCKS_PER_ATB / BLOCKS_PER_FTB
    //     P = A * BLOCKS_PER_ATB * BYTES_PER_BLOCK
    // => T = A * (1 + BLOCKS_PER_ATB / BLOCKS_PER_FTB + BLOCKS_PER_ATB * BYTES_PER_BLOCK)
    size_t total_byte_len = (byte *)end - (byte *)start;
   
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_ENABLE_FINALISER
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 121 "../../py/gc.c"
    MP_STATE_MEM(gc_alloc_table_byte_len) = total_byte_len * MP_BITS_PER_BYTE / (MP_BITS_PER_BYTE + MP_BITS_PER_BYTE * BLOCKS_PER_ATB / BLOCKS_PER_FTB + MP_BITS_PER_BYTE * BLOCKS_PER_ATB * BYTES_PER_BLOCK);
    #else
# 123 "../../py/gc.c"
    MP_STATE_MEM(gc_alloc_table_byte_len) = total_byte_len / (1 + MP_BITS_PER_BYTE / 2 * BYTES_PER_BLOCK);
    #endif
# 125 "../../py/gc.c"

    MP_STATE_MEM(gc_alloc_table_start) = (byte *)start;

   
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_ENABLE_FINALISER
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 129 "../../py/gc.c"
    size_t gc_finaliser_table_byte_len = (MP_STATE_MEM(gc_alloc_table_byte_len) * BLOCKS_PER_ATB + BLOCKS_PER_FTB - 1) / BLOCKS_PER_FTB;
    MP_STATE_MEM(gc_finaliser_table_start) = MP_STATE_MEM(gc_alloc_table_start) + MP_STATE_MEM(gc_alloc_table_byte_len);
    #endif
# 132 "../../py/gc.c"

    size_t gc_pool_block_len = MP_STATE_MEM(gc_alloc_table_byte_len) * BLOCKS_PER_ATB;
    MP_STATE_MEM(gc_pool_start) = (byte *)end - gc_pool_block_len * BYTES_PER_BLOCK;
    MP_STATE_MEM(gc_pool_end) = end;

   
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_ENABLE_FINALISER
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 138 "../../py/gc.c"
    assert(MP_STATE_MEM(gc_pool_start) >= MP_STATE_MEM(gc_finaliser_table_start) + gc_finaliser_table_byte_len);
    #endif
# 140 "../../py/gc.c"

    // clear ATBs
    memset(MP_STATE_MEM(gc_alloc_table_start), 0, MP_STATE_MEM(gc_alloc_table_byte_len));

   
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_ENABLE_FINALISER
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 145 "../../py/gc.c"
    // clear FTBs
    memset(MP_STATE_MEM(gc_finaliser_table_start), 0, gc_finaliser_table_byte_len);
    #endif
# 148 "../../py/gc.c"

    // set last free ATB index to start of heap
    MP_STATE_MEM(gc_last_free_atb_index) = 0;

    // unlock the GC
    MP_STATE_THREAD(gc_lock_depth) = 0;

    // allow auto collection
    MP_STATE_MEM(gc_auto_collect_enabled) = 1;

   
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_GC_ALLOC_THRESHOLD
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 159 "../../py/gc.c"
    // by default, maxuint for gc threshold, effectively turning gc-by-threshold off
    MP_STATE_MEM(gc_alloc_threshold) = (size_t)-1;
    MP_STATE_MEM(gc_alloc_amount) = 0;
    #endif
# 163 "../../py/gc.c"

   
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_PY_THREAD && !MICROPY_PY_THREAD_GIL
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 165 "../../py/gc.c"
    mp_thread_mutex_init(&MP_STATE_MEM(gc_mutex));
    #endif
# 167 "../../py/gc.c"

    DEBUG_printf("GC layout:\n");
    DEBUG_printf("  alloc table at %p, length " UINT_FMT " bytes, " UINT_FMT " blocks\n", MP_STATE_MEM(gc_alloc_table_start), MP_STATE_MEM(gc_alloc_table_byte_len), MP_STATE_MEM(gc_alloc_table_byte_len) * BLOCKS_PER_ATB);
   
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_ENABLE_FINALISER
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 171 "../../py/gc.c"
    DEBUG_printf("  finaliser table at %p, length " UINT_FMT " bytes, " UINT_FMT " blocks\n", MP_STATE_MEM(gc_finaliser_table_start), gc_finaliser_table_byte_len, gc_finaliser_table_byte_len * BLOCKS_PER_FTB);
    #endif
# 173 "../../py/gc.c"
    DEBUG_printf("  pool at %p, length " UINT_FMT " bytes, " UINT_FMT " blocks\n", MP_STATE_MEM(gc_pool_start), gc_pool_block_len * BYTES_PER_BLOCK, gc_pool_block_len);
}

void gc_lock(void) {
    // This does not need to be atomic or have the GC mutex because:
    // - each thread has its own gc_lock_depth so there are no races between threads;
    // - a hard interrupt will only change gc_lock_depth during its execution, and
    //   upon return will restore the value of gc_lock_depth.
    MP_STATE_THREAD(gc_lock_depth)++;
}

void gc_unlock(void) {
    // This does not need to be atomic, See comment above in gc_lock.
    MP_STATE_THREAD(gc_lock_depth)--;
}

bool gc_is_locked(void) {
    return MP_STATE_THREAD(gc_lock_depth) != 0;
}

// ptr should be of type void*
#define VERIFY_PTR(ptr) ( \
    ((uintptr_t)(ptr) & (BYTES_PER_BLOCK - 1)) == 0          /* must be aligned on a block */ \
    && ptr >= (void *)MP_STATE_MEM(gc_pool_start)        /* must be above start of pool */ \
    && ptr < (void *)MP_STATE_MEM(gc_pool_end)           /* must be below end of pool */ \
    )

#ifndef TRACE_MARK
#if 0 /* disabled by -frewrite-includes */
#if DEBUG_PRINT
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 202 "../../py/gc.c"
#define TRACE_MARK(block, ptr) DEBUG_printf("gc_mark(%p)\n", ptr)
#else
# 204 "../../py/gc.c"
#define TRACE_MARK(block, ptr)
#endif
# 206 "../../py/gc.c"
#endif
# 207 "../../py/gc.c"

// Take the given block as the topmost block on the stack. Check all it's
// children: mark the unmarked child blocks and put those newly marked
// blocks on the stack. When all children have been checked, pop off the
// topmost block on the stack and repeat with that one.
STATIC void gc_mark_subtree(size_t block) {
    // Start with the block passed in the argument.
    size_t sp = 0;
    for (;;) {
        // work out number of consecutive blocks in the chain starting with this one
        size_t n_blocks = 0;
        do {
            n_blocks += 1;
        } while (ATB_GET_KIND(block + n_blocks) == AT_TAIL);

        // check this block's children
        void **ptrs = (void **)PTR_FROM_BLOCK(block);
        for (size_t i = n_blocks * BYTES_PER_BLOCK / sizeof(void *); i > 0; i--, ptrs++) {
            void *ptr = *ptrs;
            if (VERIFY_PTR(ptr)) {
                // Mark and push this pointer
                size_t childblock = BLOCK_FROM_PTR(ptr);
                if (ATB_GET_KIND(childblock) == AT_HEAD) {
                    // an unmarked head, mark it, and push it on gc stack
                    TRACE_MARK(childblock, ptr);
                    ATB_HEAD_TO_MARK(childblock);
                    if (sp < MICROPY_ALLOC_GC_STACK_SIZE) {
                        MP_STATE_MEM(gc_stack)[sp++] = childblock;
                    } else {
                        MP_STATE_MEM(gc_stack_overflow) = 1;
                    }
                }
            }
        }

        // Are there any blocks on the stack?
        if (sp == 0) {
            break; // No, stack is empty, we're done.
        }

        // pop the next block off the stack
        block = MP_STATE_MEM(gc_stack)[--sp];
    }
}

STATIC void gc_deal_with_stack_overflow(void) {
    while (MP_STATE_MEM(gc_stack_overflow)) {
        MP_STATE_MEM(gc_stack_overflow) = 0;

        // scan entire memory looking for blocks which have been marked but not their children
        for (size_t block = 0; block < MP_STATE_MEM(gc_alloc_table_byte_len) * BLOCKS_PER_ATB; block++) {
            // trace (again) if mark bit set
            if (ATB_GET_KIND(block) == AT_MARK) {
                gc_mark_subtree(block);
            }
        }
    }
}

STATIC void gc_sweep(void) {
   
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_PY_GC_COLLECT_RETVAL
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 268 "../../py/gc.c"
    MP_STATE_MEM(gc_collected) = 0;
    #endif
# 270 "../../py/gc.c"
    // free unmarked heads and their tails
    int free_tail = 0;
    for (size_t block = 0; block < MP_STATE_MEM(gc_alloc_table_byte_len) * BLOCKS_PER_ATB; block++) {
        switch (ATB_GET_KIND(block)) {
            case AT_HEAD:
               
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_ENABLE_FINALISER
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 276 "../../py/gc.c"
                if (FTB_GET(block)) {
                    mp_obj_base_t *obj = (mp_obj_base_t *)PTR_FROM_BLOCK(block);
                    if (obj->type != NULL) {
                        // if the object has a type then see if it has a __del__ method
                        mp_obj_t dest[2];
                        mp_load_method_maybe(MP_OBJ_FROM_PTR(obj), MP_QSTR___del__, dest);
                        if (dest[0] != MP_OBJ_NULL) {
                            // load_method returned a method, execute it in a protected environment
                           
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_ENABLE_SCHEDULER
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 285 "../../py/gc.c"
                            mp_sched_lock();
                            #endif
# 287 "../../py/gc.c"
                            mp_call_function_1_protected(dest[0], dest[1]);
                           
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_ENABLE_SCHEDULER
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 289 "../../py/gc.c"
                            mp_sched_unlock();
                            #endif
# 291 "../../py/gc.c"
                        }
                    }
                    // clear finaliser flag
                    FTB_CLEAR(block);
                }
                #endif
# 297 "../../py/gc.c"
                free_tail = 1;
                DEBUG_printf("gc_sweep(%p)\n", (void *)PTR_FROM_BLOCK(block));
               
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_PY_GC_COLLECT_RETVAL
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 300 "../../py/gc.c"
                MP_STATE_MEM(gc_collected)++;
                #endif
# 302 "../../py/gc.c"
                // fall through to free the head
                MP_FALLTHROUGH

            case AT_TAIL:
                if (free_tail) {
                    ATB_ANY_TO_FREE(block);
                   
#if 0 /* disabled by -frewrite-includes */
#if CLEAR_ON_SWEEP
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 309 "../../py/gc.c"
                    memset((void *)PTR_FROM_BLOCK(block), 0, BYTES_PER_BLOCK);
                    #endif
# 311 "../../py/gc.c"
                }
                break;

            case AT_MARK:
                ATB_MARK_TO_HEAD(block);
                free_tail = 0;
                break;
        }
    }
}

void gc_collect_start(void) {
    GC_ENTER();
    MP_STATE_THREAD(gc_lock_depth)++;
   
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_GC_ALLOC_THRESHOLD
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 326 "../../py/gc.c"
    MP_STATE_MEM(gc_alloc_amount) = 0;
    #endif
# 328 "../../py/gc.c"
    MP_STATE_MEM(gc_stack_overflow) = 0;

    // Trace root pointers.  This relies on the root pointers being organised
    // correctly in the mp_state_ctx structure.  We scan nlr_top, dict_locals,
    // dict_globals, then the root pointer section of mp_state_vm.
    void **ptrs = (void **)(void *)&mp_state_ctx;
    size_t root_start = offsetof(mp_state_ctx_t, thread.dict_locals);
    size_t root_end = offsetof(mp_state_ctx_t, vm.qstr_last_chunk);
    gc_collect_root(ptrs + root_start / sizeof(void *), (root_end - root_start) / sizeof(void *));

   
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_ENABLE_PYSTACK
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 339 "../../py/gc.c"
    // Trace root pointers from the Python stack.
    ptrs = (void **)(void *)MP_STATE_THREAD(pystack_start);
    gc_collect_root(ptrs, (MP_STATE_THREAD(pystack_cur) - MP_STATE_THREAD(pystack_start)) / sizeof(void *));
    #endif
# 343 "../../py/gc.c"
}

// Address sanitizer needs to know that the access to ptrs[i] must always be
// considered OK, even if it's a load from an address that would normally be
// prohibited (due to being undefined, in a red zone, etc).
#if 0 /* disabled by -frewrite-includes */
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 349 "../../py/gc.c"
__attribute__((no_sanitize_address))
#endif
# 351 "../../py/gc.c"
static void *gc_get_ptr(void **ptrs, int i) {
    return ptrs[i];
}

void gc_collect_root(void **ptrs, size_t len) {
    for (size_t i = 0; i < len; i++) {
        void *ptr = gc_get_ptr(ptrs, i);
        if (VERIFY_PTR(ptr)) {
            size_t block = BLOCK_FROM_PTR(ptr);
            if (ATB_GET_KIND(block) == AT_HEAD) {
                // An unmarked head: mark it, and mark all its children
                TRACE_MARK(block, ptr);
                ATB_HEAD_TO_MARK(block);
                gc_mark_subtree(block);
            }
        }
    }
}

void gc_collect_end(void) {
    gc_deal_with_stack_overflow();
    gc_sweep();
    MP_STATE_MEM(gc_last_free_atb_index) = 0;
    MP_STATE_THREAD(gc_lock_depth)--;
    GC_EXIT();
}

void gc_sweep_all(void) {
    GC_ENTER();
    MP_STATE_THREAD(gc_lock_depth)++;
    MP_STATE_MEM(gc_stack_overflow) = 0;
    gc_collect_end();
}

void gc_info(gc_info_t *info) {
    GC_ENTER();
    info->total = MP_STATE_MEM(gc_pool_end) - MP_STATE_MEM(gc_pool_start);
    info->used = 0;
    info->free = 0;
    info->max_free = 0;
    info->num_1block = 0;
    info->num_2block = 0;
    info->max_block = 0;
    bool finish = false;
    for (size_t block = 0, len = 0, len_free = 0; !finish;) {
        size_t kind = ATB_GET_KIND(block);
        switch (kind) {
            case AT_FREE:
                info->free += 1;
                len_free += 1;
                len = 0;
                break;

            case AT_HEAD:
                info->used += 1;
                len = 1;
                break;

            case AT_TAIL:
                info->used += 1;
                len += 1;
                break;

            case AT_MARK:
                // shouldn't happen
                break;
        }

        block++;
        finish = (block == MP_STATE_MEM(gc_alloc_table_byte_len) * BLOCKS_PER_ATB);
        // Get next block type if possible
        if (!finish) {
            kind = ATB_GET_KIND(block);
        }

        if (finish || kind == AT_FREE || kind == AT_HEAD) {
            if (len == 1) {
                info->num_1block += 1;
            } else if (len == 2) {
                info->num_2block += 1;
            }
            if (len > info->max_block) {
                info->max_block = len;
            }
            if (finish || kind == AT_HEAD) {
                if (len_free > info->max_free) {
                    info->max_free = len_free;
                }
                len_free = 0;
            }
        }
    }

    info->used *= BYTES_PER_BLOCK;
    info->free *= BYTES_PER_BLOCK;
    GC_EXIT();
}

void *gc_alloc(size_t n_bytes, unsigned int alloc_flags) {
    bool has_finaliser = alloc_flags & GC_ALLOC_FLAG_HAS_FINALISER;
    size_t n_blocks = ((n_bytes + BYTES_PER_BLOCK - 1) & (~(BYTES_PER_BLOCK - 1))) / BYTES_PER_BLOCK;
    DEBUG_printf("gc_alloc(" UINT_FMT " bytes -> " UINT_FMT " blocks)\n", n_bytes, n_blocks);

    // check for 0 allocation
    if (n_blocks == 0) {
        return NULL;
    }

    // check if GC is locked
    if (MP_STATE_THREAD(gc_lock_depth) > 0) {
        return NULL;
    }

    GC_ENTER();

    size_t i;
    size_t end_block;
    size_t start_block;
    size_t n_free;
    int collected = !MP_STATE_MEM(gc_auto_collect_enabled);

   
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_GC_ALLOC_THRESHOLD
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 473 "../../py/gc.c"
    if (!collected && MP_STATE_MEM(gc_alloc_amount) >= MP_STATE_MEM(gc_alloc_threshold)) {
        GC_EXIT();
        gc_collect();
        collected = 1;
        GC_ENTER();
    }
    #endif
# 480 "../../py/gc.c"

    for (;;) {

        // look for a run of n_blocks available blocks
        n_free = 0;
        for (i = MP_STATE_MEM(gc_last_free_atb_index); i < MP_STATE_MEM(gc_alloc_table_byte_len); i++) {
            byte a = MP_STATE_MEM(gc_alloc_table_start)[i];
            // *FORMAT-OFF*
            if (ATB_0_IS_FREE(a)) { if (++n_free >= n_blocks) { i = i * BLOCKS_PER_ATB + 0; goto found; } } else { n_free = 0; }
            if (ATB_1_IS_FREE(a)) { if (++n_free >= n_blocks) { i = i * BLOCKS_PER_ATB + 1; goto found; } } else { n_free = 0; }
            if (ATB_2_IS_FREE(a)) { if (++n_free >= n_blocks) { i = i * BLOCKS_PER_ATB + 2; goto found; } } else { n_free = 0; }
            if (ATB_3_IS_FREE(a)) { if (++n_free >= n_blocks) { i = i * BLOCKS_PER_ATB + 3; goto found; } } else { n_free = 0; }
            // *FORMAT-ON*
        }

        GC_EXIT();
        // nothing found!
        if (collected) {
            return NULL;
        }
        DEBUG_printf("gc_alloc(" UINT_FMT "): no free mem, triggering GC\n", n_bytes);
        gc_collect();
        collected = 1;
        GC_ENTER();
    }

    // found, ending at block i inclusive
found:
    // get starting and end blocks, both inclusive
    end_block = i;
    start_block = i - n_free + 1;

    // Set last free ATB index to block after last block we found, for start of
    // next scan.  To reduce fragmentation, we only do this if we were looking
    // for a single free block, which guarantees that there are no free blocks
    // before this one.  Also, whenever we free or shink a block we must check
    // if this index needs adjusting (see gc_realloc and gc_free).
    if (n_free == 1) {
        MP_STATE_MEM(gc_last_free_atb_index) = (i + 1) / BLOCKS_PER_ATB;
    }

    // mark first block as used head
    ATB_FREE_TO_HEAD(start_block);

    // mark rest of blocks as used tail
    // TODO for a run of many blocks can make this more efficient
    for (size_t bl = start_block + 1; bl <= end_block; bl++) {
        ATB_FREE_TO_TAIL(bl);
    }

    // get pointer to first block
    // we must create this pointer before unlocking the GC so a collection can find it
    void *ret_ptr = (void *)(MP_STATE_MEM(gc_pool_start) + start_block * BYTES_PER_BLOCK);
    DEBUG_printf("gc_alloc(%p)\n", ret_ptr);

   
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_GC_ALLOC_THRESHOLD
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 536 "../../py/gc.c"
    MP_STATE_MEM(gc_alloc_amount) += n_blocks;
    #endif
# 538 "../../py/gc.c"

    GC_EXIT();

   
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_GC_CONSERVATIVE_CLEAR
#endif
#endif /* disabled by -frewrite-includes */
#if 1 /* evaluated by -frewrite-includes */
# 542 "../../py/gc.c"
    // be conservative and zero out all the newly allocated blocks
    memset((byte *)ret_ptr, 0, (end_block - start_block + 1) * BYTES_PER_BLOCK);
    #else
# 545 "../../py/gc.c"
    // zero out the additional bytes of the newly allocated blocks
    // This is needed because the blocks may have previously held pointers
    // to the heap and will not be set to something else if the caller
    // doesn't actually use the entire block.  As such they will continue
    // to point to the heap and may prevent other blocks from being reclaimed.
    memset((byte *)ret_ptr + n_bytes, 0, (end_block - start_block + 1) * BYTES_PER_BLOCK - n_bytes);
    #endif
# 552 "../../py/gc.c"

   
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_ENABLE_FINALISER
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 554 "../../py/gc.c"
    if (has_finaliser) {
        // clear type pointer in case it is never set
        ((mp_obj_base_t *)ret_ptr)->type = NULL;
        // set mp_obj flag only if it has a finaliser
        GC_ENTER();
        FTB_SET(start_block);
        GC_EXIT();
    }
    #else
# 563 "../../py/gc.c"
    (void)has_finaliser;
    #endif
# 565 "../../py/gc.c"

   
#if 0 /* disabled by -frewrite-includes */
#if EXTENSIVE_HEAP_PROFILING
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 567 "../../py/gc.c"
    gc_dump_alloc_table();
    #endif
# 569 "../../py/gc.c"

    return ret_ptr;
}

/*
void *gc_alloc(mp_uint_t n_bytes) {
    return _gc_alloc(n_bytes, false);
}

void *gc_alloc_with_finaliser(mp_uint_t n_bytes) {
    return _gc_alloc(n_bytes, true);
}
*/

// force the freeing of a piece of memory
// TODO: freeing here does not call finaliser
void gc_free(void *ptr) {
    if (MP_STATE_THREAD(gc_lock_depth) > 0) {
        // TODO how to deal with this error?
        return;
    }

    GC_ENTER();

    DEBUG_printf("gc_free(%p)\n", ptr);

    if (ptr == NULL) {
        GC_EXIT();
    } else {
        // get the GC block number corresponding to this pointer
        assert(VERIFY_PTR(ptr));
        size_t block = BLOCK_FROM_PTR(ptr);
        assert(ATB_GET_KIND(block) == AT_HEAD);

       
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_ENABLE_FINALISER
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 604 "../../py/gc.c"
        FTB_CLEAR(block);
        #endif
# 606 "../../py/gc.c"

        // set the last_free pointer to this block if it's earlier in the heap
        if (block / BLOCKS_PER_ATB < MP_STATE_MEM(gc_last_free_atb_index)) {
            MP_STATE_MEM(gc_last_free_atb_index) = block / BLOCKS_PER_ATB;
        }

        // free head and all of its tail blocks
        do {
            ATB_ANY_TO_FREE(block);
            block += 1;
        } while (ATB_GET_KIND(block) == AT_TAIL);

        GC_EXIT();

       
#if 0 /* disabled by -frewrite-includes */
#if EXTENSIVE_HEAP_PROFILING
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 621 "../../py/gc.c"
        gc_dump_alloc_table();
        #endif
# 623 "../../py/gc.c"
    }
}

size_t gc_nbytes(const void *ptr) {
    GC_ENTER();
    if (VERIFY_PTR(ptr)) {
        size_t block = BLOCK_FROM_PTR(ptr);
        if (ATB_GET_KIND(block) == AT_HEAD) {
            // work out number of consecutive blocks in the chain starting with this on
            size_t n_blocks = 0;
            do {
                n_blocks += 1;
            } while (ATB_GET_KIND(block + n_blocks) == AT_TAIL);
            GC_EXIT();
            return n_blocks * BYTES_PER_BLOCK;
        }
    }

    // invalid pointer
    GC_EXIT();
    return 0;
}

#if 0 /* disabled by -frewrite-includes */
#if 0
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 647 "../../py/gc.c"
// old, simple realloc that didn't expand memory in place
void *gc_realloc(void *ptr, mp_uint_t n_bytes) {
    mp_uint_t n_existing = gc_nbytes(ptr);
    if (n_bytes <= n_existing) {
        return ptr;
    } else {
        bool has_finaliser;
        if (ptr == NULL) {
            has_finaliser = false;
        } else {
           
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_ENABLE_FINALISER
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 658 "../../py/gc.c"
            has_finaliser = FTB_GET(BLOCK_FROM_PTR((mp_uint_t)ptr));
            #else
# 660 "../../py/gc.c"
            has_finaliser = false;
            #endif
# 662 "../../py/gc.c"
        }
        void *ptr2 = gc_alloc(n_bytes, has_finaliser);
        if (ptr2 == NULL) {
            return ptr2;
        }
        memcpy(ptr2, ptr, n_existing);
        gc_free(ptr);
        return ptr2;
    }
}

#else // Alternative gc_realloc impl
# 674 "../../py/gc.c"

void *gc_realloc(void *ptr_in, size_t n_bytes, bool allow_move) {
    // check for pure allocation
    if (ptr_in == NULL) {
        return gc_alloc(n_bytes, false);
    }

    // check for pure free
    if (n_bytes == 0) {
        gc_free(ptr_in);
        return NULL;
    }

    if (MP_STATE_THREAD(gc_lock_depth) > 0) {
        return NULL;
    }

    void *ptr = ptr_in;

    GC_ENTER();

    // get the GC block number corresponding to this pointer
    assert(VERIFY_PTR(ptr));
    size_t block = BLOCK_FROM_PTR(ptr);
    assert(ATB_GET_KIND(block) == AT_HEAD);

    // compute number of new blocks that are requested
    size_t new_blocks = (n_bytes + BYTES_PER_BLOCK - 1) / BYTES_PER_BLOCK;

    // Get the total number of consecutive blocks that are already allocated to
    // this chunk of memory, and then count the number of free blocks following
    // it.  Stop if we reach the end of the heap, or if we find enough extra
    // free blocks to satisfy the realloc.  Note that we need to compute the
    // total size of the existing memory chunk so we can correctly and
    // efficiently shrink it (see below for shrinking code).
    size_t n_free = 0;
    size_t n_blocks = 1; // counting HEAD block
    size_t max_block = MP_STATE_MEM(gc_alloc_table_byte_len) * BLOCKS_PER_ATB;
    for (size_t bl = block + n_blocks; bl < max_block; bl++) {
        byte block_type = ATB_GET_KIND(bl);
        if (block_type == AT_TAIL) {
            n_blocks++;
            continue;
        }
        if (block_type == AT_FREE) {
            n_free++;
            if (n_blocks + n_free >= new_blocks) {
                // stop as soon as we find enough blocks for n_bytes
                break;
            }
            continue;
        }
        break;
    }

    // return original ptr if it already has the requested number of blocks
    if (new_blocks == n_blocks) {
        GC_EXIT();
        return ptr_in;
    }

    // check if we can shrink the allocated area
    if (new_blocks < n_blocks) {
        // free unneeded tail blocks
        for (size_t bl = block + new_blocks, count = n_blocks - new_blocks; count > 0; bl++, count--) {
            ATB_ANY_TO_FREE(bl);
        }

        // set the last_free pointer to end of this block if it's earlier in the heap
        if ((block + new_blocks) / BLOCKS_PER_ATB < MP_STATE_MEM(gc_last_free_atb_index)) {
            MP_STATE_MEM(gc_last_free_atb_index) = (block + new_blocks) / BLOCKS_PER_ATB;
        }

        GC_EXIT();

       
#if 0 /* disabled by -frewrite-includes */
#if EXTENSIVE_HEAP_PROFILING
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 750 "../../py/gc.c"
        gc_dump_alloc_table();
        #endif
# 752 "../../py/gc.c"

        return ptr_in;
    }

    // check if we can expand in place
    if (new_blocks <= n_blocks + n_free) {
        // mark few more blocks as used tail
        for (size_t bl = block + n_blocks; bl < block + new_blocks; bl++) {
            assert(ATB_GET_KIND(bl) == AT_FREE);
            ATB_FREE_TO_TAIL(bl);
        }

        GC_EXIT();

       
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_GC_CONSERVATIVE_CLEAR
#endif
#endif /* disabled by -frewrite-includes */
#if 1 /* evaluated by -frewrite-includes */
# 767 "../../py/gc.c"
        // be conservative and zero out all the newly allocated blocks
        memset((byte *)ptr_in + n_blocks * BYTES_PER_BLOCK, 0, (new_blocks - n_blocks) * BYTES_PER_BLOCK);
        #else
# 770 "../../py/gc.c"
        // zero out the additional bytes of the newly allocated blocks (see comment above in gc_alloc)
        memset((byte *)ptr_in + n_bytes, 0, new_blocks * BYTES_PER_BLOCK - n_bytes);
        #endif
# 773 "../../py/gc.c"

       
#if 0 /* disabled by -frewrite-includes */
#if EXTENSIVE_HEAP_PROFILING
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 775 "../../py/gc.c"
        gc_dump_alloc_table();
        #endif
# 777 "../../py/gc.c"

        return ptr_in;
    }

   
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_ENABLE_FINALISER
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 782 "../../py/gc.c"
    bool ftb_state = FTB_GET(block);
    #else
# 784 "../../py/gc.c"
    bool ftb_state = false;
    #endif
# 786 "../../py/gc.c"

    GC_EXIT();

    if (!allow_move) {
        // not allowed to move memory block so return failure
        return NULL;
    }

    // can't resize inplace; try to find a new contiguous chain
    void *ptr_out = gc_alloc(n_bytes, ftb_state);

    // check that the alloc succeeded
    if (ptr_out == NULL) {
        return NULL;
    }

    DEBUG_printf("gc_realloc(%p -> %p)\n", ptr_in, ptr_out);
    memcpy(ptr_out, ptr_in, n_blocks * BYTES_PER_BLOCK);
    gc_free(ptr_in);
    return ptr_out;
}
#endif // Alternative gc_realloc impl
# 808 "../../py/gc.c"

void gc_dump_info(void) {
    gc_info_t info;
    gc_info(&info);
    mp_printf(&mp_plat_print, "GC: total: %u, used: %u, free: %u\n",
        (uint)info.total, (uint)info.used, (uint)info.free);
    mp_printf(&mp_plat_print, " No. of 1-blocks: %u, 2-blocks: %u, max blk sz: %u, max free sz: %u\n",
        (uint)info.num_1block, (uint)info.num_2block, (uint)info.max_block, (uint)info.max_free);
}

void gc_dump_alloc_table(void) {
    GC_ENTER();
    static const size_t DUMP_BYTES_PER_LINE = 64;
   
#if 0 /* disabled by -frewrite-includes */
#if !EXTENSIVE_HEAP_PROFILING
#endif
#endif /* disabled by -frewrite-includes */
#if 1 /* evaluated by -frewrite-includes */
# 822 "../../py/gc.c"
    // When comparing heap output we don't want to print the starting
    // pointer of the heap because it changes from run to run.
    mp_printf(&mp_plat_print, "GC memory layout; from %p:", MP_STATE_MEM(gc_pool_start));
    #endif
# 826 "../../py/gc.c"
    for (size_t bl = 0; bl < MP_STATE_MEM(gc_alloc_table_byte_len) * BLOCKS_PER_ATB; bl++) {
        if (bl % DUMP_BYTES_PER_LINE == 0) {
            // a new line of blocks
            {
                // check if this line contains only free blocks
                size_t bl2 = bl;
                while (bl2 < MP_STATE_MEM(gc_alloc_table_byte_len) * BLOCKS_PER_ATB && ATB_GET_KIND(bl2) == AT_FREE) {
                    bl2++;
                }
                if (bl2 - bl >= 2 * DUMP_BYTES_PER_LINE) {
                    // there are at least 2 lines containing only free blocks, so abbreviate their printing
                    mp_printf(&mp_plat_print, "\n       (%u lines all free)", (uint)(bl2 - bl) / DUMP_BYTES_PER_LINE);
                    bl = bl2 & (~(DUMP_BYTES_PER_LINE - 1));
                    if (bl >= MP_STATE_MEM(gc_alloc_table_byte_len) * BLOCKS_PER_ATB) {
                        // got to end of heap
                        break;
                    }
                }
            }
            // print header for new line of blocks
            // (the cast to uint32_t is for 16-bit ports)
            // mp_printf(&mp_plat_print, "\n%05x: ", (uint)(PTR_FROM_BLOCK(bl) & (uint32_t)0xfffff));
            mp_printf(&mp_plat_print, "\n%05x: ", (uint)((bl * BYTES_PER_BLOCK) & (uint32_t)0xfffff));
        }
        int c = ' ';
        switch (ATB_GET_KIND(bl)) {
            case AT_FREE:
                c = '.';
                break;
            /* this prints out if the object is reachable from BSS or STACK (for unix only)
            case AT_HEAD: {
                c = 'h';
                void **ptrs = (void**)(void*)&mp_state_ctx;
                mp_uint_t len = offsetof(mp_state_ctx_t, vm.stack_top) / sizeof(mp_uint_t);
                for (mp_uint_t i = 0; i < len; i++) {
                    mp_uint_t ptr = (mp_uint_t)ptrs[i];
                    if (VERIFY_PTR(ptr) && BLOCK_FROM_PTR(ptr) == bl) {
                        c = 'B';
                        break;
                    }
                }
                if (c == 'h') {
                    ptrs = (void**)&c;
                    len = ((mp_uint_t)MP_STATE_THREAD(stack_top) - (mp_uint_t)&c) / sizeof(mp_uint_t);
                    for (mp_uint_t i = 0; i < len; i++) {
                        mp_uint_t ptr = (mp_uint_t)ptrs[i];
                        if (VERIFY_PTR(ptr) && BLOCK_FROM_PTR(ptr) == bl) {
                            c = 'S';
                            break;
                        }
                    }
                }
                break;
            }
            */
            /* this prints the uPy object type of the head block */
            case AT_HEAD: {
                void **ptr = (void **)(MP_STATE_MEM(gc_pool_start) + bl * BYTES_PER_BLOCK);
                if (*ptr == &mp_type_tuple) {
                    c = 'T';
                } else if (*ptr == &mp_type_list) {
                    c = 'L';
                } else if (*ptr == &mp_type_dict) {
                    c = 'D';
                } else if (*ptr == &mp_type_str || *ptr == &mp_type_bytes) {
                    c = 'S';
                }
               
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_PY_BUILTINS_BYTEARRAY
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 894 "../../py/gc.c"
                else if (*ptr == &mp_type_bytearray) {
                    c = 'A';
                }
                #endif
# 898 "../../py/gc.c"
               
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_PY_ARRAY
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 899 "../../py/gc.c"
                else if (*ptr == &mp_type_array) {
                    c = 'A';
                }
                #endif
# 903 "../../py/gc.c"
               
#if 0 /* disabled by -frewrite-includes */
#if MICROPY_PY_BUILTINS_FLOAT
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 904 "../../py/gc.c"
                else if (*ptr == &mp_type_float) {
                    c = 'F';
                }
                #endif
# 908 "../../py/gc.c"
                else if (*ptr == &mp_type_fun_bc) {
                    c = 'B';
                } else if (*ptr == &mp_type_module) {
                    c = 'M';
                } else {
                    c = 'h';
                   
#if 0 /* disabled by -frewrite-includes */
#if 0
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 915 "../../py/gc.c"
                    // This code prints "Q" for qstr-pool data, and "q" for qstr-str
                    // data.  It can be useful to see how qstrs are being allocated,
                    // but is disabled by default because it is very slow.
                    for (qstr_pool_t *pool = MP_STATE_VM(last_pool); c == 'h' && pool != NULL; pool = pool->prev) {
                        if ((qstr_pool_t *)ptr == pool) {
                            c = 'Q';
                            break;
                        }
                        for (const byte **q = pool->qstrs, **q_top = pool->qstrs + pool->len; q < q_top; q++) {
                            if ((const byte *)ptr == *q) {
                                c = 'q';
                                break;
                            }
                        }
                    }
                    #endif
# 931 "../../py/gc.c"
                }
                break;
            }
            case AT_TAIL:
                c = '=';
                break;
            case AT_MARK:
                c = 'm';
                break;
        }
        mp_printf(&mp_plat_print, "%c", c);
    }
    mp_print_str(&mp_plat_print, "\n");
    GC_EXIT();
}

#if 0 /* disabled by -frewrite-includes */
#if 0
#endif
#endif /* disabled by -frewrite-includes */
#if 0 /* evaluated by -frewrite-includes */
# 948 "../../py/gc.c"
// For testing the GC functions
void gc_test(void) {
    mp_uint_t len = 500;
    mp_uint_t *heap = malloc(len);
    gc_init(heap, heap + len / sizeof(mp_uint_t));
    void *ptrs[100];
    {
        mp_uint_t **p = gc_alloc(16, false);
        p[0] = gc_alloc(64, false);
        p[1] = gc_alloc(1, false);
        p[2] = gc_alloc(1, false);
        p[3] = gc_alloc(1, false);
        mp_uint_t ***p2 = gc_alloc(16, false);
        p2[0] = p;
        p2[1] = p;
        ptrs[0] = p2;
    }
    for (int i = 0; i < 25; i += 2) {
        mp_uint_t *p = gc_alloc(i, false);
        printf("p=%p\n", p);
        if (i & 3) {
            // ptrs[i] = p;
        }
    }

    printf("Before GC:\n");
    gc_dump_alloc_table();
    printf("Starting GC...\n");
    gc_collect_start();
    gc_collect_root(ptrs, sizeof(ptrs) / sizeof(void *));
    gc_collect_end();
    printf("After GC:\n");
    gc_dump_alloc_table();
}
#endif
# 983 "../../py/gc.c"

#endif // MICROPY_ENABLE_GC
# 985 "../../py/gc.c"

le script
Code: Tout sélectionner
# Crash reproducer for clang version 15.0.0 (https://github.com/jacobly0/llvm-project 6d9aa7a16db70f3d02ae304b08d4a03011281fef)
# Driver args: "-target" "ez80" "-S" "-Wall" "-Werror" "-std=c99" "-Wdouble-promotion" "-Wfloat-conversion" "-Oz" "-nostdlib" "-nostdinc" "-isystem" "/home/parisse/CEdev/include" "-I" "." "-I" "../.." "-I" "build" "-fno-threadsafe-statics" "-Xclang" "-fforce-mangle-main-argc-argv" "-mllvm" "-profile-guided-section-prefix=false" "-D" "_EZ80" "-D" "HAS_PRINTF=1" "-D" "FFCONF_H=\"lib/oofatfs/ffconf.h\"" "-D" "FFCONF_H=\"lib/oofatfs/ffconf.h\"" "-O3" "-c" "-MD" "-o" "build/py/gc.o" "../../py/gc.c"
# Original command:  "/home/parisse/CEdev/bin/ez80-clang" "-cc1" "-triple" "ez80" "-S" "-disable-free" "-clear-ast-before-backend" "-disable-llvm-verifier" "-discard-value-names" "-main-file-name" "gc.c" "-mrelocation-model" "static" "-mframe-pointer=none" "-fmath-errno" "-ffp-contract=on" "-fno-rounding-math" "-fno-verbose-asm" "-no-integrated-as" "-mconstructor-aliases" "-target-cpu" "ez80" "-mllvm" "-treat-scalable-fixed-error-as-warning" "-debugger-tuning=gdb" "-fno-dwarf-directory-asm" "-fcoverage-compilation-dir=/home/parisse/CEdev/micropython/ports/ez80" "-nostdsysteminc" "-nobuiltininc" "-resource-dir" "/home/parisse/CEdev/lib/clang/15.0.0" "-dependency-file" "build/py/gc.d" "-MT" "build/py/gc.o" "-sys-header-deps" "-isystem" "/home/parisse/CEdev/include" "-I" "." "-I" "../.." "-I" "build" "-D" "_EZ80" "-D" "HAS_PRINTF=1" "-D" "FFCONF_H=\"lib/oofatfs/ffconf.h\"" "-D" "FFCONF_H=\"lib/oofatfs/ffconf.h\"" "-O3" "-Wall" "-Werror" "-Wdouble-promotion" "-Wfloat-conversion" "-std=c99" "-fdebug-compilation-dir=/home/parisse/CEdev/micropython/ports/ez80" "-ferror-limit" "19" "-fgnuc-version=4.2.1" "-fno-threadsafe-statics" "-vectorize-loops" "-vectorize-slp" "-fforce-mangle-main-argc-argv" "-mllvm" "-profile-guided-section-prefix=false" "-o" "build/py/gc.o" "-x" "c" "../../py/gc.c"
"/home/parisse/CEdev/bin/ez80-clang" "-cc1" "-triple" "ez80" "-S" "-disable-free" "-clear-ast-before-backend" "-disable-llvm-verifier" "-discard-value-names" "-main-file-name" "gc.c" "-mrelocation-model" "static" "-mframe-pointer=none" "-fmath-errno" "-ffp-contract=on" "-fno-rounding-math" "-fno-verbose-asm" "-no-integrated-as" "-mconstructor-aliases" "-target-cpu" "ez80" "-mllvm" "-treat-scalable-fixed-error-as-warning" "-debugger-tuning=gdb" "-fno-dwarf-directory-asm" "-fcoverage-compilation-dir=/home/parisse/CEdev/micropython/ports/ez80" "-nostdsysteminc" "-nobuiltininc" "-sys-header-deps" "-D" "_EZ80" "-D" "HAS_PRINTF=1" "-D" "FFCONF_H=\"lib/oofatfs/ffconf.h\"" "-D" "FFCONF_H=\"lib/oofatfs/ffconf.h\"" "-O3" "-Wall" "-Werror" "-Wdouble-promotion" "-Wfloat-conversion" "-std=c99" "-fdebug-compilation-dir=/home/parisse/CEdev/micropython/ports/ez80" "-ferror-limit" "19" "-fgnuc-version=4.2.1" "-fno-threadsafe-statics" "-vectorize-loops" "-vectorize-slp" "-fforce-mangle-main-argc-argv" "-mllvm" "-profile-guided-section-prefix=false" "-x" "c" "gc-961ef8.c"

Sinon, j'ai un peu survolé la doc. Si j'ai bien compris, la flash est accessible par l'intermédiaire de l'archivage de variables, plus précisément de variables dites d'application (appvar) qui jouent le role de fichiers. Par contre, je n'ai pas vu comment ces variables d'application en flash pouvaient se voir associer une adresse physique adressable par le CPU. Sur la Numworks, chaque secteur de la flash est une fois pour toutes adressée par le CPU, donc pour avoir du code en flash il faut le sauvegarder à une adresse précise (et même si on peut souvent produire du code qui est position independant avec -fPIC, il faut bien pouvoir l'appeler à une adresse donnée). Sur les Casio, c'est le lanceur d'addin qui se charge de programmer le MMU du CPU pour faire la bonne correspondance entre secteur de flash et adresse physique, les addins utilisent tous la même adresse physique et leur position sur un secteur donné de la flash n'a pas d'importance (il me semble même qu'un addin peut même être stocké sur des secteurs de flash non contigus).
Le mécanisme analogue est-il documenté sur les TI83?
Voilà, ce matin, je suis dubitatif. J'ai l'impression qu'au-delà de faire une app "normale" pour CE sous forme d'un miniCAS qui tienne dans 60K de code et autant de tas, tout est très expérimental avec à la clef pas mal de risque de tomber sur un problème incontournable.
Avatar de l’utilisateur
parisseVIP++
Niveau 12: CP (Calculatrice sur Pattes)
Niveau 12: CP (Calculatrice sur Pattes)
Prochain niv.: 77.8%
 
Messages: 3511
Inscription: 13 Déc 2013, 16:35
Genre: Non spécifié
Calculatrice(s):
MyCalcs profile

Re: À quand KhiCas pour TI-83 Premium CE / Edition Python ?

Message non lude Adriweb » 24 Jan 2023, 09:06

Pour la version de la toolchain c'est bien la dernière release ou bien la nightly (dans les releases github) ? Le sha de clang a l'air ok en tout cas, c'est deja ça.

Pour le crash du compilateur, c'est de plus en plus rare (en fait ca arrive même "jamais" sur les projets que font les gens à la main vote certains gros projets comme Lua, justement) mais en effet ça peut encore arriver sur des gros trucs externes, comme on le voit ici. Mais étrange, puisque ça a fonctionné au moins une fois pour MateoC, la compil... Ça peut aussi dépendre du degré d'optimisation (le flag -Oz vs -O0 etc). D'après l'erreur, il n'est pas arriver à générer ce qu'il fallait pour faire un shift right avec des valeurs 48bit et 64bit? 🤷‍♂️

Pour les fichiers/appvars, la toolchain a toute une lib d'io disponible (fileioc), mais ça a aussi été abstracté dans la couche de compat avec les fonctions C standards de fichiers (Même si on a moins de contrôle des spécificités du coup).
Pour rappel, les appvars sont vraiment des variables à considérer comme des fichiers (qui peuvent être en read only depuis la flash sans passer par la ram), et font eux aussi un peu plus de 60k maximum. Et ils doivent être gérées individuellement, puisque l'OS peut les déplacer à tout moment (defrag/garbageCollect), même si la toolchain a un hook de dispo pour que le programme puisse être au courant - pas de suppositions possibles à faire sur l'enchaînement de 2 appvars au niveau de leur adresse, par exemple (et puis, il y a des metadata de la variable au milieu de toute facon)

Il y a pas mal d'exemples (et presque tous avec des tests autos qui tournent en CI pour chaque commit) dans la toolchain, pour du stand-alone et des libs. Et puis la doc est normalement bien fournie.

Mais oui, pour le moment la toolchain est particulierement faite pour des programmes qui tournent en ram et qui subissent donc les contraintes habituelles. Mais les ressources externes en appvars c'est assez commun, et il y a plusieurs exemples dans la toolchain, par exemple pour la gestion de graphiques qui y sont stockés (tilemaps etc)
Image

MyCalcs: Help the community's calculator documentations by filling out your calculators info!
MyCalcs: Aidez la communauté à documenter les calculatrices en donnant des infos sur vos calculatrices !
Inspired-Lua.org: All about TI-Nspire Lua programming (tutorials, wiki/docs...)
Avatar de l’utilisateur
AdriwebAdmin
Niveau 16: CC2 (Commandeur des Calculatrices)
Niveau 16: CC2 (Commandeur des Calculatrices)
Prochain niv.: 80.2%
 
Messages: 14614
Images: 1218
Inscription: 01 Juin 2007, 00:00
Localisation: France
Genre: Homme
Calculatrice(s):
MyCalcs profile
Twitter/X: adriweb
GitHub: adriweb

PrécédenteSuivante

Retourner vers Langages alternatifs

Qui est en ligne

Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 18 invités

-
Rechercher
-
Social TI-Planet
-
Sujets à la une
Comparaisons des meilleurs prix pour acheter sa calculatrice !
Aidez la communauté à documenter les révisions matérielles en listant vos calculatrices graphiques !
Phi NumWorks jailbreak
123
-
Faire un don / Premium
Pour plus de concours, de lots, de tests, nous aider à payer le serveur et les domaines...
Faire un don
Découvrez les avantages d'un compte donateur !
JoinRejoignez the donors and/or premium!les donateurs et/ou premium !


Partenaires et pub
Notre partenaire Jarrety Calculatrices à acheter chez Calcuso
-
Stats.
1409 utilisateurs:
>1362 invités
>42 membres
>5 robots
Record simultané (sur 6 mois):
6892 utilisateurs (le 07/06/2017)
-
Autres sites intéressants
Texas Instruments Education
Global | France
 (English / Français)
Banque de programmes TI
ticalc.org
 (English)
La communauté TI-82
tout82.free.fr
 (Français)